make -d honor system umask(#484997)

This commit is contained in:
Ondrej Vasik 2009-02-11 09:22:49 +00:00
parent 39fcc651a7
commit 3a74730950
2 changed files with 62 additions and 1 deletions

56
cpio-2.9-sys_umask.patch Normal file
View File

@ -0,0 +1,56 @@
diff -urp cpio-2.9.90-orig/src/extern.h cpio-2.9.90/src/extern.h
--- cpio-2.9.90-orig/src/extern.h 2008-08-25 16:42:48.000000000 +0200
+++ cpio-2.9.90/src/extern.h 2009-02-10 16:29:34.000000000 +0100
@@ -96,6 +96,7 @@ extern char output_is_special;
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) ();
diff -urp cpio-2.9.90-orig/src/global.c cpio-2.9.90/src/global.c
--- cpio-2.9.90-orig/src/global.c 2007-06-28 12:54:11.000000000 +0200
+++ cpio-2.9.90/src/global.c 2009-02-10 16:34:41.000000000 +0100
@@ -187,6 +187,9 @@ bool to_stdout_option = false;
/* The name this program was run with. */
char *program_name;
+/* 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) ();
diff -urp cpio-2.9.90-orig/src/main.c cpio-2.9.90/src/main.c
--- cpio-2.9.90-orig/src/main.c 2008-08-25 16:42:48.000000000 +0200
+++ cpio-2.9.90/src/main.c 2009-02-10 17:44:47.000000000 +0100
@@ -790,6 +790,7 @@ main (int argc, char *argv[])
program_name = argv[0];
process_args (argc, argv);
+ sys_umask = umask(0);
initialize_buffers ();
diff -urp cpio-2.9.90-orig/src/util.c cpio-2.9.90/src/util.c
--- cpio-2.9.90-orig/src/util.c 2008-08-25 16:42:48.000000000 +0200
+++ cpio-2.9.90/src/util.c 2009-02-10 17:46:35.000000000 +0100
@@ -605,7 +605,7 @@ create_all_directories (char *name)
#endif
dir = dir_name (name);
- mode = 0700;
+ mode = 0777 & ~ (sys_umask);
#ifdef HPUX_CDF
cdf = islastparentcdf (name);
if (cdf)
@@ -620,7 +620,7 @@ create_all_directories (char *name)
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);
}

View File

@ -3,7 +3,7 @@
Summary: A GNU archiving program
Name: cpio
Version: 2.9.90
Release: 2%{?dist}
Release: 3%{?dist}
License: GPLv3+
Group: Applications/Archiving
URL: http://www.gnu.org/software/cpio/
@ -16,6 +16,7 @@ Patch3: cpio-2.9-chmodRaceC.patch
Patch4: cpio-2.9-exitCode.patch
Patch5: cpio-2.9-dir_perm.patch
Patch6: cpio-2.9-dev_number.patch
Patch7: cpio-2.9-sys_umask.patch
Requires(post): /sbin/install-info
Requires(preun): /sbin/install-info
BuildRequires: texinfo, autoconf, gettext
@ -43,6 +44,7 @@ Install cpio if you need a program to manage file archives.
%patch4 -p1 -b .exitCode
%patch5 -p1 -b .dir_perm
%patch6 -p1 -b .dev_number
%patch7 -p1 -b .sys_umask
autoheader
@ -83,6 +85,9 @@ fi
%{_infodir}/*.info*
%changelog
* Wed Feb 11 2009 Ondrej Vasik <ovasik@redhat.com> 2.9.90-3
- make -d honor system umask(#484997)
* Fri Jul 18 2008 Kamil Dudka <kdudka@redhat.com> 2.9.90-2
- Support major/minor device numbers over 127 (bz#450109)