mirror of
git://git.sv.gnu.org/coreutils.git
synced 2026-03-15 17:34:51 +02:00
(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.
This commit is contained in:
26
src/mkfifo.c
26
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);
|
||||
|
||||
Reference in New Issue
Block a user