From: Jim Meyering Date: Sat, 30 Sep 2000 08:49:17 +0000 (+0000) Subject: (main): Don't set the umask to 0 and hand-apply X-Git-Tag: TEXTUTILS-2_0_8~96 X-Git-Url: http://git.ipfire.org/gitweb/index.cgi?a=commitdiff_plain;h=105cbe3ea31fbb1700051c98b222c069701746e2;p=thirdparty%2Fcoreutils.git (main): Don't set the umask to 0 and hand-apply the previously-set umask unconditionally. Do that only when a MODE has been specified. Otherwise, call mkdir with the full creation mask (0777 or 0666) and let the kernel apply the umask. The difference shows up only on file systems with ACL support when the containing directory has a default ACL. Patch by Andreas Gruenbacher. --- diff --git a/src/mkdir.c b/src/mkdir.c index a8934c7937..e282fa7d2f 100644 --- a/src/mkdir.c +++ b/src/mkdir.c @@ -119,17 +119,18 @@ main (int argc, char **argv) usage (1); } - newmode = S_IRWXUGO & ~ umask (0); - parent_mode = S_IWUSR | S_IXUSR | newmode; + newmode = S_IRWXUGO; if (symbolic_mode) { struct mode_change *change = mode_compile (symbolic_mode, 0); + newmode &= ~ umask (0); if (change == MODE_INVALID) error (1, 0, _("invalid mode %s"), quote (symbolic_mode)); else if (change == MODE_MEMORY_EXHAUSTED) xalloc_die (); newmode = mode_adjust (newmode, change); } + parent_mode = S_IWUSR | S_IXUSR | newmode; for (; optind < argc; ++optind) { @@ -150,8 +151,11 @@ main (int argc, char **argv) /* mkdir(2) is required to honor only the file permission bits. In particular, it needn't do anything about `special' bits, - so if any were set in newmode, apply them with chmod. */ - if (fail == 0 && (newmode & ~S_IRWXUGO)) + so if any were set in newmode, apply them with chmod. + This extra step is necessary in some cases when the containing + directory has a default ACL. */ + + if (fail == 0 && symbolic_mode) { fail = chmod (argv[optind], newmode); if (fail) @@ -160,7 +164,8 @@ main (int argc, char **argv) } } - errors |= fail; + if (fail) + errors = 1; } exit (errors);