diff options
author | Jim Meyering <jim@meyering.net> | 2000-09-30 08:56:06 +0000 |
---|---|---|
committer | Jim Meyering <jim@meyering.net> | 2000-09-30 08:56:06 +0000 |
commit | e2b45cb9fee871284cf3eb52f6152a6727e390ec (patch) | |
tree | f03bcd9c40123607e82f7ce8b0dfe5fecc1611d7 /src | |
parent | 2170a489569b46071132723c49b81efe56f5f544 (diff) | |
download | coreutils-e2b45cb9fee871284cf3eb52f6152a6727e390ec.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 mkfifo 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.
(main): Rename local `symbolic_mode' to `specified_mode'.
Also, when MODE is specified, call chmod to ensure that the
permission bits are set as specified even when the containing
directory has a default ACL.
Diffstat (limited to 'src')
-rw-r--r-- | src/mkfifo.c | 26 |
1 files changed, 19 insertions, 7 deletions
diff --git a/src/mkfifo.c b/src/mkfifo.c index ec933ee8a..3d360a54e 100644 --- a/src/mkfifo.c +++ b/src/mkfifo.c @@ -114,10 +114,10 @@ main (int argc, char **argv) usage (1); } - newmode = ((S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP | S_IROTH | S_IWOTH) - & ~ umask (0)); + newmode = (S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP | S_IROTH | S_IWOTH); if (symbolic_mode) { + newmode &= ~ umask (0); change = mode_compile (symbolic_mode, 0); if (change == MODE_INVALID) error (1, 0, _("invalid mode")); @@ -128,11 +128,23 @@ main (int argc, char **argv) for (; optind < argc; ++optind) { - if (mkfifo (argv[optind], newmode)) - { - error (0, errno, _("cannot make fifo %s"), quote (argv[optind])); - errors = 1; - } + int fail = mkfifo (argv[optind], newmode); + if (fail) + error (0, errno, _("cannot create fifo `%s'"), quote (argv[optind])); + + /* If the containing directory happens to have a default ACL, chmod + ensures the file mode permission bits are still set as desired. */ + + if (fail == 0 && symbolic_mode) + { + fail = chmod (argv[optind], newmode); + if (fail) + error (0, errno, _("cannot set permissions of fifo `%s'"), + quote (argv[optind])); + } + + if (fail) + errors = 1; } exit (errors); |