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
Paul Griffith wrote:
% /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
The info page tells something different:
`-o' When creating -- `--no-same-owner', when extracting -- `--portability'.
The later usage is deprecated. It is retained for compatibility with the earlier versions of GNU `tar'. In the future releases `-o' will be equivalent to `--no-same-owner' only.
The manual page says:
-o, --old-archive, --portability write a V7 format archive, rather than ANSI format
So yes, there is a bug somewhere, but I'm not really sure, where it is.
I'd file it as a documentation bug inside of tar.
Ralph