summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJim Meyering <jim@meyering.net>2000-09-30 08:49:17 +0000
committerJim Meyering <jim@meyering.net>2000-09-30 08:49:17 +0000
commit105cbe3ea31fbb1700051c98b222c069701746e2 (patch)
treefc9dcd2b9e9e3e0f314be7516f266875ee776ea9
parentf14dbb1710d6cf7ee0acb5c65af367d1c8e322c0 (diff)
downloadcoreutils-105cbe3ea31fbb1700051c98b222c069701746e2.tar.xz
(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.
-rw-r--r--src/mkdir.c15
1 files changed, 10 insertions, 5 deletions
diff --git a/src/mkdir.c b/src/mkdir.c
index a8934c793..e282fa7d2 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);