fyfe@bgsuvax.UUCP (Bob Fyfe) (08/16/90)
I have a faculty member who has brought a tape with him from a different site. It is a tar tape and the files were stored using absolute pathnames. The difficulty is that we don't have the same file structure names and so when I would try to restore the files, it fills up the root file structure quickly (we don't keep a whole lot of space available in that partition). I was wondering if there are any PD programs that exist or whether someone has written a script to get around this problem. I could write a script to extract a file at a time and then move it but its a hassle trying to maintain the directory structure that the faculty member has and preserve modification dates. I've also considered writing a C program using the chroot function and doing a system call to tar but that seems messy too. Is there anything out there available or am I missing something in my own backyard? Any help would be appreciated. You can direct email any solutions to me. Bob Fyfe *************************************************************************** * Bob Fyfe / EMT-A/ Ham Radio KA8YWQ | INTERNET: fyfe@andy.bgsu.edu * * University Computer Services | BITNET: fyfe@bgsuopie * * Bowling Green State University (OH)| UUCP: ...!osu-cis!bgsuvax!fyfe * *************************************************************************** -- *************************************************************************** * Bob Fyfe / EMT-A/ Ham Radio KA8YWQ | INTERNET: fyfe@andy.bgsu.edu * * University Computer Services | BITNET: fyfe@bgsuopie * * Bowling Green State University (OH)| UUCP: ...!osu-cis!bgsuvax!fyfe * ***************************************************************************
deven@rpi.edu (Deven T. Corzine) (08/18/90)
> I have a faculty member who has brought a tape with him from a > different site. It is a tar tape and the files were stored using > absolute pathnames. The difficulty is that we don't have the same > file structure names and so when I would try to restore the files, > it fills up the root file structure quickly (we don't keep a whole > lot of space available in that partition). > I was wondering if there are any PD programs that exist or whether > someone has written a script to get around this problem. I could > write a script to extract a file at a time and then move it but its > a hassle trying to maintain the directory structure that the faculty > member has and preserve modification dates. I've also considered > writing a C program using the chroot function and doing a system > call to tar but that seems messy too. Yes, I have written a Perl script to do exactly this. It uses the chroot(2) call, and must run setuid root, but it will setuid back to the real uid after performing the chroot. It appears fairly secure, and it does work. The only real thing you need to be sure of is that tar(1) will run standalone, with NO system libraries available. I wrote and tested the script under SunOS 4.0.3 using Perl 3.0; Sun's /bin/tar does indeed work standalone (doesn't need the shared libraries) so it works. If you have a dynamically compiled one, you might have to statically link it for it to work. The suidperl program is needed to execute the script, but it is in memory when running, so it doesn't need the ability to run standalone. Enough caveats; here's the script. [Can anyone think of a good name for it?] ---- #!/usr/local/bin/suidperl if ($#ARGV != 1) { print STDERR "Usage: $0 <tarfile> <dir>\n"; exit 1; } $ENV{'PATH'} = '/bin:/usr/bin'; $tar = $ARGV[0]; $ARGV[1] =~ /(\w+)$/; $dir = $1; if (! -f $tar) { print STDERR "Error: tar file does not exist.\n"; exit 1; } if (-e $dir) { print STDERR "Error: directory must not exist.\n"; exit 1; } if (! -W ".") { print STDERR "Error: No write permission on current directory.\n"; exit 1; } mkdir($dir,0777); chown $<,$(,$dir; system "/bin/cp","/bin/tar",$dir; system "/bin/cp",$tar,"$dir/absolute.tar"; chdir $dir; chroot "."; ($>,$)) = ($<,$(); system "./tar","-xvf","absolute.tar"; unlink "tar"; unlink "absolute.tar"; exit 0; ---- Have fun. Deven -- Deven T. Corzine Internet: deven@rpi.edu, shadow@pawl.rpi.edu Snail: 2214 12th St. Apt. 2, Troy, NY 12180 Phone: (518) 271-0750 Bitnet: deven@rpitsmts, userfxb6@rpitsmts UUCP: uunet!rpi!deven Simple things should be simple and complex things should be possible. -- Deven T. Corzine Internet: deven@rpi.edu, shadow@pawl.rpi.edu Snail: 2214 12th St. Apt. 2, Troy, NY 12180 Phone: (518) 271-0750 Bitnet: deven@rpitsmts, userfxb6@rpitsmts UUCP: uunet!rpi!deven Simple things should be simple and complex things should be possible.
jon@savant.uucp (Jon Gefaell) (08/20/90)
In article <6155@bgsuvax.UUCP> fyfe@bgsuvax.UUCP (Bob Fyfe) writes: > > >I have a faculty member who has brought a tape with him from a different site. >It is a tar tape and the files were stored using absolute pathnames. The >difficulty is that we don't have the same file structure names and so when >I would try to restore the files, it fills up the root file structure >quickly (we don't keep a whole lot of space available in that partition). > GNU tar will take care of this for you. As a rule it doesnt' allow absolute pathnames and will strip the leading / if there is one... -- +----------- Domain? DOMAIN? We Don't Need No Steeeenkin' Domain! -----------+ |I wish I had something interesting to put in my .signature file, but I don't| +-savant!jon@virginia.edu {...}!uunet!virginia!savant!jon jeg7e@virginia.edu-+
karish@mindcrf.UUCP (Chuck Karish) (08/24/90)
In article <6155@bgsuvax.UUCP> fyfe@bgsuvax.UUCP (Bob Fyfe) writes: >I have a faculty member who has brought a tape with him from a different site. >It is a tar tape and the files were stored using absolute pathnames... >I was wondering if there are any PD programs that exist or whether someone >has written a script to get around this problem. The 'pax' program, written by Mark Colburn for USENIX, lets you edit the path prefixes on extraction, using a 'sed'-like pattern. It understands both tar and cpio formats, and the new POSIX tar format. Available from the comp.org.usenix archives, or on the USENIX sofrware distribution tapes. -- Chuck Karish karish@mindcraft.com Mindcraft, Inc. (415) 323-9000
pml@basin.cacs.usl.edu (Patrick M. Landry) (08/24/90)
In article <6155@bgsuvax.UUCP> fyfe@bgsuvax.UUCP (Bob Fyfe) writes: >I have a faculty member who has brought a tape with him from a different site. >It is a tar tape and the files were stored using absolute pathnames... >I was wondering if there are any PD programs that exist or whether someone >has written a script to get around this problem. What I have done in the past with tapes such as these is to create a link from where the tar wants to put files to the place I really want them. This obviously only works if there is some common directory on the tape under which all the files reside. Just a thought. -- patrick pml@cacs.usl.edu
ryee@sandstorm.Berkeley.EDU (Raymond Yee) (06/21/91)
This should be a simple question (although I can't figure it out.) I have a tar archive file sitting on my disk and I would like to extract the files. How do I do it? I've tried a mix of the x and f key options, but I constantly get a tape read error. I'd greatly appreciate any help I can get. TIA. Raymond Yee (ryee@ocf.berkeley.edu) PS. How would I collect a group of files into a tar archive?
greg@athena.cs.uga.edu (Greg Whitlock) (06/21/91)
In article <1991Jun20.174511.5658@agate.berkeley.edu> ryee@sandstorm.Berkeley.EDU (Raymond Yee) writes: > >This should be a simple question (although I can't figure it out.) I have ...should be.... :-) >a tar archive file sitting on my disk and I would like to extract the files. >How do I do it? I've tried a mix of the x and f key options, but I >constantly get a tape read error. Using 'tar xvf <file>' should work. A tape read error sounds like a different problem. _____________________________________________________________________________ Greg Whitlock | Hey! It's the Gregster...Gregarino.. Department of Computer Science | ...the Greg-meister...Greginsky..the ACM chairman of UGA | man from Greg...Gregatollah...Greg-a University of Georgia, Athens | -loo...General Gregkopf...the Greg- E-mail: greg@athena.cs.uga.edu | man...Grego..come to do some Unix... _______________________________________|_____________________________________