diff options
author | Paul Eggert <eggert@cs.ucla.edu> | 2005-04-28 16:31:09 +0000 |
---|---|---|
committer | Paul Eggert <eggert@cs.ucla.edu> | 2005-04-28 16:31:09 +0000 |
commit | b1fdaf5ac762d11268d204df221051c737fdb0b3 (patch) | |
tree | 6145d86717d6356922b4df168d335e820edcf279 /src | |
parent | 30f5286c505979dab83b5b009c3681d9b4fa9671 (diff) | |
download | coreutils-b1fdaf5ac762d11268d204df221051c737fdb0b3.tar.xz |
(main): Adjust to new modechange API.
Also, free the mode_change object when done.
Diffstat (limited to 'src')
-rw-r--r-- | src/install.c | 9 | ||||
-rw-r--r-- | src/mkdir.c | 24 | ||||
-rw-r--r-- | src/mkfifo.c | 11 | ||||
-rw-r--r-- | src/mknod.c | 11 |
4 files changed, 25 insertions, 30 deletions
diff --git a/src/install.c b/src/install.c index 61c1fedab..5659bc70e 100644 --- a/src/install.c +++ b/src/install.c @@ -353,12 +353,11 @@ main (int argc, char **argv) if (specified_mode) { - struct mode_change *change = mode_compile (specified_mode, 0); - if (change == MODE_INVALID) + struct mode_change *change = mode_compile (specified_mode); + if (!change) error (EXIT_FAILURE, 0, _("invalid mode %s"), quote (specified_mode)); - else if (change == MODE_MEMORY_EXHAUSTED) - xalloc_die (); - mode = mode_adjust (0, change); + mode = mode_adjust (0, change, 0); + mode_free (change); } get_ids (); diff --git a/src/mkdir.c b/src/mkdir.c index d0c975f70..544392130 100644 --- a/src/mkdir.c +++ b/src/mkdir.c @@ -125,22 +125,24 @@ main (int argc, char **argv) } newmode = S_IRWXUGO; - if (specified_mode) - { - 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) - xalloc_die (); - 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); + + if (specified_mode) + { + struct mode_change *change = mode_compile (specified_mode); + if (!change) + error (EXIT_FAILURE, 0, _("invalid mode %s"), + quote (specified_mode)); + newmode = mode_adjust (S_IRWXUGO, change, umask_value); + mode_free (change); + } + else + umask (umask_value); } for (; optind < argc; ++optind) diff --git a/src/mkfifo.c b/src/mkfifo.c index a579dbe33..5a9b7efab 100644 --- a/src/mkfifo.c +++ b/src/mkfifo.c @@ -75,7 +75,6 @@ int main (int argc, char **argv) { mode_t newmode; - struct mode_change *change; const char *specified_mode; int exit_status = EXIT_SUCCESS; int optc; @@ -116,13 +115,11 @@ main (int argc, char **argv) newmode = (S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP | S_IROTH | S_IWOTH); if (specified_mode) { - change = mode_compile (specified_mode, MODE_MASK_ALL); - if (change == MODE_INVALID) + struct mode_change *change = mode_compile (specified_mode); + if (!change) error (EXIT_FAILURE, 0, _("invalid mode")); - else if (change == MODE_MEMORY_EXHAUSTED) - xalloc_die (); - newmode = mode_adjust (newmode, change); - umask (0); + newmode = mode_adjust (newmode, change, umask (0)); + mode_free (change); } for (; optind < argc; ++optind) diff --git a/src/mknod.c b/src/mknod.c index 4eacefb25..ce7dd9565 100644 --- a/src/mknod.c +++ b/src/mknod.c @@ -88,7 +88,6 @@ int main (int argc, char **argv) { mode_t newmode; - struct mode_change *change; const char *specified_mode; int optc; int expected_operands; @@ -121,13 +120,11 @@ main (int argc, char **argv) newmode = (S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP | S_IROTH | S_IWOTH); if (specified_mode) { - change = mode_compile (specified_mode, MODE_MASK_ALL); - if (change == MODE_INVALID) + struct mode_change *change = mode_compile (specified_mode); + if (!change) error (EXIT_FAILURE, 0, _("invalid mode")); - else if (change == MODE_MEMORY_EXHAUSTED) - xalloc_die (); - newmode = mode_adjust (newmode, change); - umask (0); + newmode = mode_adjust (newmode, change, umask (0)); + mode_free (change); } /* If the number of arguments is 0 or 1, |