summaryrefslogtreecommitdiff
path: root/src/mknod.c
diff options
context:
space:
mode:
authorPaul Eggert <eggert@cs.ucla.edu>2013-05-11 19:17:10 -0700
committerPaul Eggert <eggert@cs.ucla.edu>2013-05-11 19:22:54 -0700
commite7198a67b8dd7f23925dfa40b7a90342e185f729 (patch)
tree783abb446c0b54bb34e1770442e1a5f824904341 /src/mknod.c
parent7b65f8e92888ffe3ea7d0b3824affa1dfc76b8c5 (diff)
downloadcoreutils-e7198a67b8dd7f23925dfa40b7a90342e185f729.tar.xz
mkdir: don't assume umask equals POSIX default ACL mask
This fixes Bug#14371, reported by Killer Bassist. * NEWS: Document this. * src/mkdir.c (struct mkdir_options): Remove member ancestor_mode. New member umask_value. All uses changed. * src/mkdir.c (make_ancestor): Fix umask assumption. * src/mkdir.c, src/mkfifo.c, src/mknod.c (main): Leave umask alone. This requires invoking lchmod after creating the file, which introduces a race condition, but this can't be avoided on hosts with "POSIX" default ACLs, and there's no easy way with network file systems to tell what kind of host the directory is on. * tests/local.mk (all_tests): Add tests/mkdir/p-acl.sh. * tests/mkdir/p-acl.sh: New file.
Diffstat (limited to 'src/mknod.c')
-rw-r--r--src/mknod.c9
1 files changed, 8 insertions, 1 deletions
diff --git a/src/mknod.c b/src/mknod.c
index 7cfc708d3..a384ad35c 100644
--- a/src/mknod.c
+++ b/src/mknod.c
@@ -122,10 +122,13 @@ main (int argc, char **argv)
newmode = MODE_RW_UGO;
if (specified_mode)
{
+ mode_t umask_value;
struct mode_change *change = mode_compile (specified_mode);
if (!change)
error (EXIT_FAILURE, 0, _("invalid mode"));
- newmode = mode_adjust (newmode, false, umask (0), change, NULL);
+ umask_value = umask (0);
+ umask (umask_value);
+ newmode = mode_adjust (newmode, false, umask_value, change, NULL);
free (change);
if (newmode & ~S_IRWXUGO)
error (EXIT_FAILURE, 0,
@@ -226,5 +229,9 @@ main (int argc, char **argv)
usage (EXIT_FAILURE);
}
+ if (specified_mode && lchmod (argv[optind], newmode) != 0)
+ error (EXIT_FAILURE, errno, _("cannot set permissions of `%s'"),
+ quote (argv[optind]));
+
exit (EXIT_SUCCESS);
}