summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPaul Eggert <eggert@cs.ucla.edu>2005-04-22 23:52:35 +0000
committerPaul Eggert <eggert@cs.ucla.edu>2005-04-22 23:52:35 +0000
commit5ce302fba5b3734fd21315d27948f10bce74b614 (patch)
tree74c001e6e00900a197fbc085d5a221ab7e22973e
parente8feb9eaf5d66686b80bf629938bdbe4d2d9bbc1 (diff)
downloadcoreutils-5ce302fba5b3734fd21315d27948f10bce74b614.tar.xz
(main): Compile mode with MODE_MASK_ALL and initial umask.
-rw-r--r--src/mkdir.c21
1 files changed, 11 insertions, 10 deletions
diff --git a/src/mkdir.c b/src/mkdir.c
index e52ac9cfb..d0c975f70 100644
--- a/src/mkdir.c
+++ b/src/mkdir.c
@@ -1,5 +1,5 @@
/* mkdir -- make directories
- Copyright (C) 90, 1995-2002, 2004 Free Software Foundation, Inc.
+ Copyright (C) 90, 1995-2002, 2004, 2005 Free Software Foundation, Inc.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
@@ -82,7 +82,7 @@ int
main (int argc, char **argv)
{
mode_t newmode;
- mode_t parent_mode;
+ mode_t parent_mode IF_LINT (= 0);
const char *specified_mode = NULL;
const char *verbose_fmt_string = NULL;
int exit_status = EXIT_SUCCESS;
@@ -125,16 +125,9 @@ main (int argc, char **argv)
}
newmode = S_IRWXUGO;
- {
- mode_t umask_value = umask (0);
- umask (umask_value); /* Restore the old value. */
- parent_mode = (newmode & (~ umask_value)) | S_IWUSR | S_IXUSR;
- }
-
if (specified_mode)
{
- struct mode_change *change = mode_compile (specified_mode, 0);
- newmode &= ~ umask (0);
+ struct mode_change *change = mode_compile (specified_mode, MODE_MASK_ALL);
if (change == MODE_INVALID)
error (EXIT_FAILURE, 0, _("invalid mode %s"), quote (specified_mode));
else if (change == MODE_MEMORY_EXHAUSTED)
@@ -142,6 +135,14 @@ main (int argc, char **argv)
newmode = mode_adjust (newmode, change);
}
+ if (specified_mode || create_parents)
+ {
+ mode_t umask_value = umask (0);
+ if (! specified_mode)
+ umask (umask_value);
+ parent_mode = (S_IRWXUGO & ~umask_value) | (S_IWUSR | S_IXUSR);
+ }
+
for (; optind < argc; ++optind)
{
bool ok;