Source-Changes-HG archive

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

[src/netbsd-1-6]: src/gnu/usr.bin/tar Pullup patch (requested by wennmach in ...



details:   https://anonhg.NetBSD.org/src/rev/196a14e0965f
branches:  netbsd-1-6
changeset: 530196:196a14e0965f
user:      jmc <jmc%NetBSD.org@localhost>
date:      Tue Mar 25 19:56:51 2003 +0000

description:
Pullup patch (requested by wennmach in ticket #1229)
 If an entry for a directory into which files are to be extracted is
 missing in an archive, tar handles this by noticing it, and creating
 the necessary directory itself. Since the mode for that directory is
 not regietered in the incomplete archive, tar creates these
 directories mode 0777, expecting the user's umask to strip of all
 unwanted permission bits. However, if tar is called with the -p
 option (preserve modes) the umask is cleared, and thus directories not
 contained in the archive are created mode 0777. The attached patch
 fixes this by honouring the umask in this special case.

diffstat:

 gnu/usr.bin/tar/extract.c |  9 ++++++---
 1 files changed, 6 insertions(+), 3 deletions(-)

diffs (44 lines):

diff -r 06f2f5862e73 -r 196a14e0965f gnu/usr.bin/tar/extract.c
--- a/gnu/usr.bin/tar/extract.c Sun Mar 23 01:30:11 2003 +0000
+++ b/gnu/usr.bin/tar/extract.c Tue Mar 25 19:56:51 2003 +0000
@@ -18,7 +18,7 @@
 the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.  */
 
 #ifndef lint
-static char rcsid[] = "$NetBSD: extract.c,v 1.8 1997/10/08 22:55:31 enami Exp $";
+static char rcsid[] = "$NetBSD: extract.c,v 1.8.12.1 2003/03/25 19:56:51 jmc Exp $";
 #endif /* not lint */
 
 /*
@@ -98,6 +98,7 @@
 static time_t now = 0;         /* Current time */
 static we_are_root = 0;                /* True if our effective uid == 0 */
 static int notumask = ~0;      /* Masks out bits user doesn't want */
+static int dirmode = 0755;     /* Default directory create mask */
 
 /*
  * "Scratch" space to store the information about a sparse file before
@@ -136,11 +137,13 @@
         * leave our kernel umask at 0, and our "notumask" at ~0.
         */
   ourmask = umask (0);         /* Read it */
+  dirmode = ~ourmask;
   if (!f_use_protection)
     {
       (void) umask (ourmask);  /* Set it back how it was */
-      notumask = ~ourmask;     /* Make umask override permissions */
+      notumask = dirmode;      /* Make umask override permissions */
     }
+  dirmode &= 0777;
 }
 
 
@@ -837,7 +840,7 @@
       if (p[-1] == '.' && (p == pathname + 1 || p[-2] == '/'))
        continue;
       *p = 0;                  /* Truncate the path there */
-      check = mkdir (pathname, 0777);  /* Try to create it as a dir */
+      check = mkdir (pathname, dirmode); /* Try to create it as a dir */
       if (check == 0)
        {
          /* Fix ownership */



Home | Main Index | Thread Index | Old Index