diff options
author | Paul Eggert <eggert@cs.ucla.edu> | 2006-10-18 20:56:38 +0000 |
---|---|---|
committer | Paul Eggert <eggert@cs.ucla.edu> | 2006-10-18 20:56:38 +0000 |
commit | 11cf1d39f2fbe2dcfb6d268fd3e2a56334f1d224 (patch) | |
tree | 88f4a779b2d653dea98df29655bbc33eb50a7b6f /src/cp.c | |
parent | f594f1fb387da55159e7591c97e17b76366730c8 (diff) | |
download | coreutils-11cf1d39f2fbe2dcfb6d268fd3e2a56334f1d224.tar.xz |
* src/copy.c (copy_internal): Don't pass mkdir a mode greater than
7777. This matches historical 'cp' behavior and avoids some
(though not all) implementation-defined behavior of mkdir.
* src/cp.c (make_dir_parents_private): Likewise.
* src/copy.c (copy_internal): Don't pass 'open' a mode greater
than 777. This is required by POSIX. It doesn't make any difference
in actual behavior on any host that I know of.
Diffstat (limited to 'src/cp.c')
-rw-r--r-- | src/cp.c | 6 |
1 files changed, 5 insertions, 1 deletions
@@ -428,7 +428,11 @@ make_dir_parents_private (char const *const_dir, size_t src_offset, } src_mode = stats.st_mode; - if (mkdir (dir, src_mode)) + /* POSIX says mkdir's behavior is implementation-defined when + (src_mode & ~S_IRWXUGO) != 0. However, common practice is + to ask mkdir to copy all the CHMOD_MODE_BITS, letting mkdir + decide what to do with S_ISUID | S_ISGID | S_ISVTX. */ + if (mkdir (dir, src_mode & CHMOD_MODE_BITS) != 0) { error (0, errno, _("cannot make directory %s"), quote (dir)); |