1832932 Members
2765 Online
110048 Solutions
New Discussion

Preserve the owner

 
Cheung_2
Frequent Advisor

Preserve the owner

After I gzip a file , then gunzip the file , the owner will be changed to me , how can I preserve the ownership to the original owner.

eg.

# ll abc.prn
-rw-rw-rw- UserA abc.prn
# whoami
UserB
# gzip abc.prn
# ll
-rw-rw-rw- UserB abc.prn.gz
#gunzip abc.prn.gz
#ll
-rw-rw-rw- UserB abc.prn

How to preserve the owner of the file abc.prn to original owner ( UserA) ? Thx.
Andy
10 REPLIES 10
U.SivaKumar_2
Honored Contributor

Re: Preserve the owner

Hi,

Iam using gzip version 1.3 . There is no altering of ownership by gzip in my server. It perfectly preserves the ownership.

try installing latest gzip.

regards,
U.SivaKumar

Innovations are made when conventions are broken
Cheung_2
Frequent Advisor

Re: Preserve the owner

Hi U.SivaKumar ,

Thx your response and valuable suggestoin, I am new comer to Linux and want to know more about it, how can I know the existing version in my system , eg . OS version , tools version ? thx.
Andy
Cheung_2
Frequent Advisor

Re: Preserve the owner

Where can I download the update zip program ? thx.
Andy
U.SivaKumar_2
Honored Contributor

Re: Preserve the owner

Hi ,

To find out your kernel version.

#uname -r

To find out version of utilities.
use -v or --version option .

eg:-

uname --version

To --version or -v is not supported try this

gzip --help

See the first line of output.

regards,
U.SivaKumar





Innovations are made when conventions are broken
U.SivaKumar_2
Honored Contributor

Re: Preserve the owner

Hi,

http://www.gzip.org

regards,
U.SivaKumar
Innovations are made when conventions are broken
Cheung_2
Frequent Advisor

Re: Preserve the owner

Hi U.SivaKumar ,

I checked that my zip version is 1.3 , do you have other suggestion to fix my previous problem ? thx.
Andy
U.SivaKumar_2
Honored Contributor

Re: Preserve the owner

Hi,

check the permissions , owner, file size of /bin/gzip .
compare with mine,

-rwxr-xr-x 3 root root 50652 Feb 8 2001 /bin/gzip


regards,
U.SivaKumar

Innovations are made when conventions are broken
Cheung_2
Frequent Advisor

Re: Preserve the owner

mine is
-rwxr-xr-x 3 root root 51228 Aug 24 2001 /bin/gzip

It seems newer than yours.

Andy
U.SivaKumar_2
Honored Contributor

Re: Preserve the owner

hi ,

there is difference in file size , download latest gzip from the link in my previous post.

regards,

U.SivaKumar
Innovations are made when conventions are broken
Ralph Smith_5
New Member

Re: Preserve the owner

This is trickier than it seems. If you run as the root user, ownership should be preserved by gzip/gunzip. But if UserB is not root, it will not. The reason is that gzip/gunzip actually creates new files and must try to change ownership. On recent versions of Linux, the system call for changing ownership only works for root. (Check this with "man 2 chown".) This is not true on some other operating systems, where it leads to interesting problems.

Two ways to get around this are to create a setuid-root copy
of gzip (dangerous) or (better) let UserB use sudo to run gzip as root. If UserB can't be trusted, he is out of luck.