bug-cpio
[Top][All Lists]
Advanced

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

[Bug-cpio] respecting umask with -d


From: Clint Adams
Subject: [Bug-cpio] respecting umask with -d
Date: Sat, 11 Mar 2006 20:36:33 -0500
User-agent: Mutt/1.5.11+cvs20060126

This patch was applied to the Debian package in 2001, and was lost
later.  It's meant to respect the user's umask when creating
directories with -d.

--- orig/src/extern.h
+++ mod/src/extern.h
@@ -101,6 +101,7 @@
 extern char input_is_seekable;
 extern char output_is_seekable;
 extern char *program_name;
+extern mode_t sys_umask;
 extern int (*xstat) ();
 extern void (*copy_function) ();
 


--- orig/src/global.c
+++ mod/src/global.c
@@ -205,6 +205,9 @@
 /* The name this program was run with.  */
 char *program_name;
 
+/* Debian hack to make the -d option honor the umask.  */
+mode_t sys_umask;
+
 /* A pointer to either lstat or stat, depending on whether
    dereferencing of symlinks is done for input files.  */
 int (*xstat) ();


--- orig/src/main.c
+++ mod/src/main.c
@@ -750,7 +750,7 @@
 #endif
 
   process_args (argc, argv);
-  umask (0);
+  sys_umask = umask (0);
 
   initialize_buffers ();
 


--- orig/src/util.c
+++ mod/src/util.c
@@ -577,7 +577,7 @@
 #endif
 
   dir = dir_name (name);
-  mode = 0700;
+  mode = 0777 & ~sys_umask;
 #ifdef HPUX_CDF
   cdf = islastparentcdf (name);
   if (cdf)
@@ -592,7 +592,7 @@
     error (2, 0, _("virtual memory exhausted"));
 
   if (dir[0] != '.' || dir[1] != '\0')
-    make_path (dir, mode, 0700, -1, -1, (char *) NULL);
+    make_path (dir, mode, 0777 & ~sys_umask, -1, -1, (char *) NULL);
 
   free (dir);
 }







reply via email to

[Prev in Thread] Current Thread [Next in Thread]