Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/bin/pax PR/30132: Juan RP: tar --chroot refuses to extract f...



details:   https://anonhg.NetBSD.org/src/rev/adc36746067b
branches:  trunk
changeset: 580709:adc36746067b
user:      christos <christos%NetBSD.org@localhost>
date:      Thu May 05 14:54:49 2005 +0000

description:
PR/30132: Juan RP: tar --chroot refuses to extract files.
fchroot() changes the effective path, so we need to call updatepath().

diffstat:

 bin/pax/ar_subs.c |  25 +++++++++++++++++--------
 1 files changed, 17 insertions(+), 8 deletions(-)

diffs (68 lines):

diff -r 13f747704cdb -r adc36746067b bin/pax/ar_subs.c
--- a/bin/pax/ar_subs.c Thu May 05 12:08:24 2005 +0000
+++ b/bin/pax/ar_subs.c Thu May 05 14:54:49 2005 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: ar_subs.c,v 1.38 2005/04/24 03:36:54 christos Exp $    */
+/*     $NetBSD: ar_subs.c,v 1.39 2005/05/05 14:54:49 christos Exp $    */
 
 /*-
  * Copyright (c) 1992 Keith Muller.
@@ -42,7 +42,7 @@
 #if 0
 static char sccsid[] = "@(#)ar_subs.c  8.2 (Berkeley) 4/18/94";
 #else
-__RCSID("$NetBSD: ar_subs.c,v 1.38 2005/04/24 03:36:54 christos Exp $");
+__RCSID("$NetBSD: ar_subs.c,v 1.39 2005/05/05 14:54:49 christos Exp $");
 #endif
 #endif /* not lint */
 
@@ -66,6 +66,7 @@
 static void wr_archive(ARCHD *, int is_app);
 static int get_arc(void);
 static int next_head(ARCHD *);
+static int fdochroot(int);
 extern sigset_t s_mask;
 
 /*
@@ -92,9 +93,9 @@
 }
 
 int
-fdochdir(int fdwd)
+fdochdir(int fcwd)
 {
-       if (fchdir(fdwd) == -1) {
+       if (fchdir(fcwd) == -1) {
                syswarn(1, errno, "Cannot chdir to `.'");
                return -1;
        }
@@ -110,6 +111,16 @@
 }
 
 static int
+fdochroot(int fcwd)
+{
+       if (fchroot(fcwd) != 0) {
+               syswarn(1, errno, "Can't fchroot to \".\"");
+               return -1;
+       }
+       return updatepath();
+}
+
+static int
 path_check(ARCHD *arcn, int level)
 {
        char buf[MAXPATHLEN];
@@ -260,10 +271,8 @@
 
        now = time((time_t *)NULL);
 #if !HAVE_NBTOOL_CONFIG_H
-       if (do_chroot && fchroot(cwdfd) != 0) {
-               syswarn(1, errno, "Can't fchroot to \".\"");
-               return;
-       }
+       if (do_chroot)
+               (void)fdochroot(cwdfd);
 #endif
 
        /*



Home | Main Index | Thread Index | Old Index