diff options
author | Jim Meyering <jim@meyering.net> | 2000-09-30 08:53:10 +0000 |
---|---|---|
committer | Jim Meyering <jim@meyering.net> | 2000-09-30 08:53:10 +0000 |
commit | beebc6916806d148b3e38a4f61d4455fd6486aa2 (patch) | |
tree | e120f5dc7e11c661f0ef703adef25ce260628511 | |
parent | daf9d4191822a6fe0f05e0d634133e179225e8a2 (diff) | |
download | coreutils-beebc6916806d148b3e38a4f61d4455fd6486aa2.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 mknod 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.
-rw-r--r-- | src/mknod.c | 15 |
1 files changed, 13 insertions, 2 deletions
diff --git a/src/mknod.c b/src/mknod.c index c17b9fdda..19167fa41 100644 --- a/src/mknod.c +++ b/src/mknod.c @@ -117,10 +117,10 @@ main (int argc, char **argv) } } - 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")); @@ -223,5 +223,16 @@ major and minor device numbers may not be specified for fifo files")); usage (1); } + /* Perform an explicit chmod to ensure the file mode permission bits + are set as specified. This extra step is necessary in some cases + when the containing directory has a default ACL. */ + + if (symbolic_mode) + { + if (chmod (argv[optind], newmode)) + error (0, errno, _("cannot set permissions of `%s'"), + quote (argv[optind])); + } + exit (0); } |