[CentOS] /bin/tar bug

Mon Jun 26 15:45:39 UTC 2006
Paul Griffith <paulg at cs.yorku.ca>

It like we may have a bug in tar  that ships with Centos.
It looks like -o is mapped to --same-owner.


Some basic info....

uname -a
Linux jazzy 2.6.9-34.0.1.ELsmp #1 SMP Wed May 24 08:14:29 CDT 2006
i686 i686 i386 GNU/Linux

cat /etc/redhat-release 
CentOS release 4.3 (Final)

% /bin/tar --version
tar (GNU tar) 1.14

--same-owner     try extracting files with the same ownership
--no-same-owner  extract files as yourself

Compatibility options:
  -o   when creating, same as --old-archive
       when extracting, same as --no-same-owner



and Now a test!


#goto tmp dir
cd /tmp

#become root
su - root

#create three test files
touch afile bfile cfile

#verify ownership
ls -l
total 0
-rw-r--r--  1 root root 0 Jun 26 11:16 afile
-rw-r--r--  1 root root 0 Jun 26 11:16 bfile
-rw-r--r--  1 root root 0 Jun 26 11:16 cfile

#create a tar archive
tar zcvf testoh.tgz afile bfile cfil

#become regular user

tar -zxof testoh.tgz
tar: afile: Cannot change ownership to uid 0, gid 0: Operation not ermitted
tar: bfile: Cannot change ownership to uid 0, gid 0: Operation not ermitted
tar: cfile: Cannot change ownership to uid 0, gid 0: Operation not ermitted
tar: Error exit delayed from previous errors

This error should not happen!


tar --no-same-owner -zxf testoh.tgz
jazzy 328 % ls -l
total 4
-rw-------  1 paulg tech   0 Jun 26 11:16 afile
-rw-------  1 paulg tech   0 Jun 26 11:16 bfile
-rw-------  1 paulg tech   0 Jun 26 11:16 cfile
-rw-r--r--  1 root  root 125 Jun 26 11:17 testoh.tgz

This works but according to the manpages -o should also work!


It looks like -o is mapped to --same-owner 

jazzy 329 % tar --same-owner -zxf testoh.tgz
tar: afile: Cannot change ownership to uid 0, gid 0: Operation not ermitted
tar: bfile: Cannot change ownership to uid 0, gid 0: Operation not ermitted
tar: cfile: Cannot change ownership to uid 0, gid 0: Operation not ermitted
tar: Error exit delayed from previous errors


Thanks
Paul