untarring write-protected directories

Dave Olson olson at anchor.esd.sgi.com
Wed Aug 1 04:25:53 AEST 1990


In <JIM.90Jul30150137 at baroque.Stanford.EDU> jim at baroque.Stanford.EDU (James Helman) writes:

| Unlike BSD/SunOS, IRIX tar religiously obeys the directory modes
| defined in an archive.  This means that if you restore an archive
| which contains write-protected directories, tar is unable to write any
| part of the archive beneath that point (unless one is root).  One
| solution is repeatedly untar and unprotect the offending directories,
| but this could take many iterations if the protected tree is deep.
| There must be a better way, but I don't see any flags that help.
| 
| In a similar vein (i.e. IRIX tar shooting itself in the foot),
| something which bugs the bejesus out of me is tar's restoring
| directory/file ownerships for normal users.  Why should normal users
| need or even be able to create files and directories they don't own?
| This usually means that tar then fails to retrieve the requested files
| because of protection mismatches as above.  In addition, if the
| protections on what they just restored are restrictive, they may even
| have to call a rotorooter to remove the directory!  Of course the "-o"
| flag will save you, but why leave an open hole for novice or
| BSD-acclimated users to trip into?
| 

This one has been pretty well beat to death.  The issue is that SysV
allows users to chown files to someone else (stripping setuid, etc.
if not the superuser).  Many religous arguments have been carried out
about this, but that is the way things are.  Tar has always (even on
V7/BSD/SunOS) tried to chown the files and directory away, but silently
fails if you aren't the superuser.

One could certainly argue (and many have) that the o option ought to
be the default on Sys V.  It is unlikely that this will change, so I
would suggest simply aliasing tar to always use the 'o' option.
The o option was added to system V tar because whoever ported it at least
recognized the problem (and clearly felt that giving files away by default
was good, or at least was less work, we may never know which).
--

	Dave Olson

Life would be so much easier if we could just look at the source code.



More information about the Comp.sys.sgi mailing list