From nobody@FreeBSD.org  Tue Jun 12 03:08:49 2001
Return-Path: <nobody@FreeBSD.org>
Received: from freefall.freebsd.org (freefall.freebsd.org [216.136.204.21])
	by hub.freebsd.org (Postfix) with ESMTP id 5A3F837B401
	for <freebsd-gnats-submit@FreeBSD.org>; Tue, 12 Jun 2001 03:08:49 -0700 (PDT)
	(envelope-from nobody@FreeBSD.org)
Received: (from nobody@localhost)
	by freefall.freebsd.org (8.11.3/8.11.3) id f5CA8nC54137;
	Tue, 12 Jun 2001 03:08:49 -0700 (PDT)
	(envelope-from nobody)
Message-Id: <200106121008.f5CA8nC54137@freefall.freebsd.org>
Date: Tue, 12 Jun 2001 03:08:49 -0700 (PDT)
From: bill@twwells.com
To: freebsd-gnats-submit@FreeBSD.org
Subject: [PATCH] pax may descend into directories even when -d specified
X-Send-Pr-Version: www-1.0

>Number:         28095
>Category:       bin
>Synopsis:       [PATCH] pax may descend into directories even when -d specified
>Confidential:   no
>Severity:       serious
>Priority:       medium
>Responsible:    brian
>State:          closed
>Quarter:        
>Keywords:       
>Date-Required:  
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Tue Jun 12 03:10:01 PDT 2001
>Closed-Date:    Mon Jan 24 14:04:54 GMT 2005
>Last-Modified:  Mon Jan 24 14:04:54 GMT 2005
>Originator:     Bill Wells
>Release:        4.3-STABLE
>Organization:
>Environment:
>Description:
When the -d option is specified and a -T, -G, or -U option causes a directory to be skipped, pax will descend into that directory. Other selection options may have a similar problem. I have not addressed that.
>How-To-Repeat:
pax -w -v -d -G tty -f /dev/null /usr/bin

This will dump wall and write, which are group tty, even though the -d option says to not descend into /usr/bin.
>Fix:
Sorry for the very likely screwiness of this patch; this is not my normal interface. When my system is back up, I'll e-mail the patch if requested.

diff -bru pax.orig/ar_subs.c pax/ar_subs.c
--- pax.orig/ar_subs.c  Fri Aug 27 16:14:39 1999
+++ pax/ar_subs.c       Tue Jun 12 02:53:37 2001
@@ -395,8 +395,10 @@
                /*
                 * check if this file meets user specified options match.
                 */
-               if (sel_chk(arcn) != 0)
+               if (sel_chk(arcn) != 0) {
+                       ftree_notsel(arcn);
                        continue;
+               }
                fd = -1;
                if (uflag) {
                        /*
@@ -791,9 +793,10 @@
                /*
                 * check if this file meets user specified options
                 */
-               if (sel_chk(arcn) != 0)
+               if (sel_chk(arcn) != 0) {
+                       ftree_notsel(arcn);
                        continue;
-
+               }
                /*
                 * if there is already a file in the destination directory with
                 * the same name and it is newer, skip the one stored on the
diff -bru pax.orig/extern.h pax/extern.h
--- pax.orig/extern.h   Mon Mar  5 04:30:41 2001
+++ pax/extern.h        Tue Jun 12 02:48:42 2001
@@ -157,6 +157,7 @@
 int ftree_start __P((void));
 int ftree_add __P((register char *));
 void ftree_sel __P((register ARCHD *));
+void ftree_notsel __P((register ARCHD *));
 void ftree_chk __P((void));
 int next_file __P((register ARCHD *));
 
diff -bru pax.orig/ftree.c pax/ftree.c
--- pax.orig/ftree.c    Fri Aug 27 16:14:42 1999
+++ pax/ftree.c Tue Jun 12 02:48:21 2001
@@ -234,6 +234,24 @@
 }
 
 /*
+ * ftree_notsel()
+ *      this entry has been skipped by pax.
+ */
+
+#if __STDC__
+void
+ftree_notsel(register ARCHD *arcn)
+#else
+void
+ftree_notsel(arcn)
+       register ARCHD *arcn;
+#endif
+{
+       if (ftent != NULL)
+               (void)fts_set(ftsp, ftent, FTS_SKIP);
+}
+
+/*
  * ftree_chk()
  *     called at end on pax execution. Prints all those file args that did not
  *     have a selected member (reference count still 0)


>Release-Note:
>Audit-Trail:
Responsible-Changed-From-To: freebsd-bugs->brian 
Responsible-Changed-By: brian 
Responsible-Changed-When: Wed Jan 12 03:27:09 GMT 2005 
Responsible-Changed-Why:  
I'll apply the patch (or something similar!) 

http://www.freebsd.org/cgi/query-pr.cgi?pr=28095 
State-Changed-From-To: open->patched 
State-Changed-By: brian 
State-Changed-When: Wed Jan 12 03:27:37 GMT 2005 
State-Changed-Why:  
Committed to -current.  I'll MFC in 7 days if there are no objections 

http://www.freebsd.org/cgi/query-pr.cgi?pr=28095 
State-Changed-From-To: patched->closed 
State-Changed-By: brian 
State-Changed-When: Mon Jan 24 14:03:27 GMT 2005 
State-Changed-Why:  
Committed to RELENG_5 

http://www.freebsd.org/cgi/query-pr.cgi?pr=28095 
>Unformatted:
