diff options
author | kientzle <kientzle@FreeBSD.org> | 2008-03-15 03:06:46 +0000 |
---|---|---|
committer | kientzle <kientzle@FreeBSD.org> | 2008-03-15 03:06:46 +0000 |
commit | e3d8bdbf5590edf7776ca1213dbcfc2634d98bb0 (patch) | |
tree | b71d9b5155e2b02073080b764627ba88dde1d40a /usr.bin/tar/read.c | |
parent | 0d1e934945c730a93df2007db901e3c2d434a2f3 (diff) | |
download | FreeBSD-src-e3d8bdbf5590edf7776ca1213dbcfc2634d98bb0.zip FreeBSD-src-e3d8bdbf5590edf7776ca1213dbcfc2634d98bb0.tar.gz |
--chroot implementation thanks to Joerg Sonnenberger.
Diffstat (limited to 'usr.bin/tar/read.c')
-rw-r--r-- | usr.bin/tar/read.c | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/usr.bin/tar/read.c b/usr.bin/tar/read.c index de08fd1..a0267a3 100644 --- a/usr.bin/tar/read.c +++ b/usr.bin/tar/read.c @@ -118,6 +118,17 @@ read_archive(struct bsdtar *bsdtar, char mode) archive_error_string(a)); do_chdir(bsdtar); + + if (mode == 'x' && bsdtar->option_chroot) { +#if HAVE_CHROOT + if (chroot(".") != 0) + bsdtar_errc(bsdtar, 1, errno, "Can't chroot to \".\""); +#else + bsdtar_errc(bsdtar, 1, 0, + "chroot isn't supported on this platform"); +#endif + } + for (;;) { /* Support --fast-read option */ if (bsdtar->option_fast_read && |