[comp.unix.wizards] restore tar archives with different uid?

dt@yenta.alb.nm.us (David B. Thomas) (08/22/90)

Is there a way to restore a tar archive, but force all the files
thus created to be owned by you?

					David

omerzu@quando.quantum.de (Thomas Omerzu) (08/22/90)

In article <1740@yenta.alb.nm.us> dt@yenta.alb.nm.us (David B. Thomas) writes:

>Is there a way to restore a tar archive, but force all the files
>thus created to be owned by you?

Well David,

that depends on the version of 'tar' you're using.
A BSD-based tar does do that by default, whereas an ATT-tar
has got the 'o'-option.

TFM reads:
          o       Causes extracted files to take on the user and group
                  identifier of the user running the program rather
                  than those on the tape.



-- 
*-----------------------------------------------------------------------------*
Thomas Omerzu      UUCP:     ...!unido!quando!omerzu / omerzu@quando.uucp
  Quantum GmbH,    Bitnet:   UNIDO!quando!omerzu / omerzu%quando@UNIDO(.bitnet)
Dortmund, Germany  Internet: omerzu@quando.quantum.de

merritt@iris613.gsfc.nasa.gov (John H Merritt) (08/23/90)

In article <1674@quando.quantum.de> omerzu@quando.quantum.de (Thomas Omerzu) writes:
>that depends on the version of 'tar' you're using.
>A BSD-based tar does do that by default, whereas an ATT-tar
>has got the 'o'-option.
>
>TFM reads:
>          o       Causes extracted files to take on the user and group
>                  identifier of the user running the program rather
>                  than those on the tape.
>
And in our IRIX (SGI's Unix):

		o		Do not chown (or chgrp) files.

Keep the owner and group that's on the tape, or don't change the
extracted files to the owner and group that's on the tape?  You have
to run this once to determine what it really does.

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
John H. Merritt                   #  Yesterday I knew nothing,
Applied Research Corporation      #  Today I know that.
merritt@iris613.gsfc.nasa.gov     #

amoss@huji.ac.il (Amos Shapira) (08/24/90)

sa.gov>
Sender: news@shum.huji.ac.il
Distribution: comp
Lines: 26
Apparently-To: post-usenet@ucbvax.berkeley.edu

merritt@iris613.gsfc.nasa.gov (John H Merritt) writes:

:
>And in our IRIX (SGI's Unix):

>  o  Do not chown (or chgrp) files.

>Keep the owner and group that's on the tape, or don't change the
>extracted files to the owner and group that's on the tape?  You have
>to run this once to determine what it really does.

On SysV, a process can do chown/chgrp to any file which it owns (or which
belongs to its effective group ID). What tar does is to create the file
(which belongs to the user who ran tar) and chown/chgrp if the 'o' flag
wasn't specify. So in that matter, Irix is not different from other SysV-
based UN*X'es.

>~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
>John H. Merritt                   #  Yesterday I knew nothing,
>Applied Research Corporation      #  Today I know that.
>merritt@iris613.gsfc.nasa.gov     #

Hope this helps,
Amos Shapira
amoss@batata.huji.ac.il

chad@anasaz.UUCP (Chad R. Larson) (08/25/90)

In article <1740@yenta.alb.nm.us> dt@yenta.alb.nm.us (David B. Thomas) writes:
+---------------
| Is there a way to restore a tar archive, but force all the files
| thus created to be owned by you?
+---------------
Well, you don't tell which version of tar you are playing with (DOS? SysV?
BSD?), but it sure sounds like a RTFM question to me.

SysVr3.2 TAR(1) partial extract, speaking of key arguments:

    "o" - Causes the extracted files to assume the owner and group ID
	  of the user running the program rather than those on the
	  archive tape.
-- 
Chad R. Larson          ...{mcdphx,asuvax}!anasaz!chad or chad@anasaz.UUCP
Anasazi, Inc. - 7500 North Dreamy Draw Drive, Suite 120, Phoenix, Az 85020
(602) 870-3330            "I read the news today, oh boy!"  -- John Lennon

dnichols@uunet.uu.net (Donald Nichols) (08/26/90)

"Chad R. Larson says:"
> 
> In article <1740@yenta.alb.nm.us> dt@yenta.alb.nm.us (David B. Thomas) writes:
> +---------------
> | Is there a way to restore a tar archive, but force all the files
> | thus created to be owned by you?
> +---------------
> Well, you don't tell which version of tar you are playing with (DOS? SysV?
> BSD?), but it sure sounds like a RTFM question to me.
> 
> SysVr3.2 TAR(1) partial extract, speaking of key arguments:
> 
>     "o" - Causes the extracted files to assume the owner and group ID
> 	  of the user running the program rather than those on the
> 	  archive tape.

	But - for example - TFM for 3.51 unix for the unix-pc from at&t
(that's actually SysVR2 + some Berkely stuff) DOES NOT MENTION the -o
option.  Yes - it does work, but no - it is not documented.  This may have
also been the case on the system which the original poster uses.

	IMHO, this is a misfeature, since it is easy for someone to
partially extract an archive and not be able to read it. (At least, he can
get rid of it :-)

	When AT&T, in their great wisdom, decided to let the Great Unwashed
User change the ownership of files that s/he owns, they should have modified
tar so that if the uid is not 0, the -o option is automatically set.  This
would preserve the behavior found under V7 and BSD.  Perhaps also they could
have made the -o option invert THIS behavior for non-root invokers.  Under
V7 and BSD, they could get away with blindly chown(2)ing each file or
directory created, knowing that it would not work for a non-root user.
SysV, however, produces problems, and should not have this as the DEFAULT
behavior.

> -- 
> Chad R. Larson          ...{mcdphx,asuvax}!anasaz!chad or chad@anasaz.UUCP
> Anasazi, Inc. - 7500 North Dreamy Draw Drive, Suite 120, Phoenix, Az 85020
> (602) 870-3330            "I read the news today, oh boy!"  -- John Lennon
> 


-- 
Donald Nichols (DoN.)		| Voice (Days):	(703) 664-1585
D&D Data			| Voice (Eves):	(703) 938-4564
Disclaimer: from here - None	| Email:	<dnichols@ceilidh.beartrack.com>
	--- Black Holes are where God is dividing by zero ---

douglas@dekalb.UUCP (Douglas B. Jones) (09/04/90)

In article <2932@anasaz.UUCP> chad@anasaz.UUCP (Chad R. Larson) writes:
>In article <1740@yenta.alb.nm.us> dt@yenta.alb.nm.us (David B. Thomas) writes:
>+---------------
>| Is there a way to restore a tar archive, but force all the files
>| thus created to be owned by you?
>+---------------
>Well, you don't tell which version of tar you are playing with (DOS? SysV?
>BSD?), but it sure sounds like a RTFM question to me.
>SysVr3.2 TAR(1) partial extract, speaking of key arguments:
>    "o" - Causes the extracted files to assume the owner and group ID
>	  of the user running the program rather than those on the
>	  archive tape.
>-- 
>Chad R. Larson          ...{mcdphx,asuvax}!anasaz!chad or chad@anasaz.UUCP
>Anasazi, Inc. - 7500 North Dreamy Draw Drive, Suite 120, Phoenix, Az 85020
>(602) 870-3330            "I read the news today, oh boy!"  -- John Lennon


Under Ultrix 3.0 , "o" means:
---------
     o         Suppress the normal directory information.  On
               output, tar normally places information specifying
               owner and modes of directories in the archive.
               Former versions of tar, when encountering this
               information will give error message of the form,

                    <name>/: cannot create

               tar will place information specifying owner and
               modes of directories in the archive.
---------

A better question than:
>+---------------
>| Is there a way to restore a tar archive, but force all the files
>| thus created to be owned by you?
>+---------------
might be to say: "Is there an option to set files to uids/gids that are
specified by the user. Of course if the user is Fred, he should not
be able to set his tar files to Joe or Joe's tar files to Fred. But,
"root" should be able to set them as wished. Personally, I think it
would be nice if tar and restore would allow for the setting of user
and group ids. Restore sets them according to what was dumped, but
in restoreing files the root person might want to set them to another
id. Many a time I have created a student id from quarters past, but
with a differecnt uid/gid number. Restore asked me do I want to set
uid and gid and I said yes. Even if the login name was the same, it
set the uid and gid of each file and directory to what came from tape,
which in many cases was another user current uid and/or gid numbers.

Anyway, from Chad's response, it appears the "o" (and maybe other
options as well) have different meanings.

One other point: the tape drive devices should not be open to the
general user. Tar/restore should be able to access them for the
general user, but have the appropriate security to prevent Joe from
getting Freds files.

Here on this system (Ultrix 3.0), I set the devices to:
crw-rw----  1 root     system    36,  12 Apr 13  1989 /dev/nrmt0h
crw-rw----  1 root     system    36,   4 Dec 20  1988 /dev/nrmt0l
crw-rw----  1 root     system    16,  12 Dec 20  1988 /dev/nrmt1h
crw-rw----  1 root     system    36,   8 Aug 31 14:30 /dev/rmt0h
crw-rw----  1 root     system    36,   0 Dec 20  1988 /dev/rmt0l
crw-rw----  1 root     system    16,   8 Feb 22  1990 /dev/rmt1h

This is a quick fix that only allows root and people in system (trusted
people) to have access to the drives. Since we are a small shop, the
only way a user gets/store stuff from/on tape is to ask a super-user
(only 3 of us). So, I have not bothered to check tar/restore/dump out
for more security. Once the security measures wanted were defined, I
imagine the codeing would not be a major undertaking....

Above, I said "tape drive devices". This should also apply to other
devices that exist now days. Notice how the disk drives are set up.
(partial listing from /dev).
brw-------  1 root     system     9,   0 Oct 16  1989 /dev/ra0a
brw-------  1 root     system     9,   1 Dec 20  1988 /dev/ra0b
crw-------  1 root     system     9,   6 Aug 30 22:01 /dev/rra0g
brw-------  1 root     system     9,   8 Feb  7  1990 /dev/ra1a
brw-------  1 root     system     9,  14 Dec 20  1988 /dev/ra1g
brw-------  1 root     system     9,  15 Dec 20  1988 /dev/ra1h
crw-------  1 root     system     9,   0 Dec 20  1988 /dev/rra0a
crw-------  1 root     system     9,   1 Aug 30 22:09 /dev/rra0b
crw-------  1 root     system     9,   6 Aug 30 22:01 /dev/rra0g
crw-------  1 root     system     9,   8 Aug 30 22:08 /dev/rra1a
crw-------  1 root     system     9,  14 Aug 30 22:09 /dev/rra1g
crw-------  1 root     system     9,  15 Aug 30 22:08 /dev/rra1h

Improved security here would help move Ultrix (U*X) more into the
commercial world.... Maybe some U*X have already addressed this....

Douglas

-- 
Doulas B. Jones					douglas@dekalb
Academic Computer Center		or	gatech!dekalb!douglas
DeKalb College
555 N. Indian Creek Drive/Clarkston, Ga. 30021  (404) 299-4233