diff options
author | Jim Meyering <jim@meyering.net> | 2000-04-26 12:36:43 +0000 |
---|---|---|
committer | Jim Meyering <jim@meyering.net> | 2000-04-26 12:36:43 +0000 |
commit | eddd846acbdb06d111abb30feb690d7124ee7643 (patch) | |
tree | 1354bba5b4d40e83d880c2c5a65b2936dbbd0654 /lib/makepath.c | |
parent | 84013f9573b9560160a7d67c366fb079b6e63d0a (diff) | |
download | coreutils-eddd846acbdb06d111abb30feb690d7124ee7643.tar.xz |
(S_IRWXUGO): Define.
(make_path): Always perform explicit chmod if MODE specifies any
of the `special' permission bits.
Diffstat (limited to 'lib/makepath.c')
-rw-r--r-- | lib/makepath.c | 24 |
1 files changed, 16 insertions, 8 deletions
diff --git a/lib/makepath.c b/lib/makepath.c index bf3528eb4..ea1b40731 100644 --- a/lib/makepath.c +++ b/lib/makepath.c @@ -1,5 +1,5 @@ /* makepath.c -- Ensure that a directory path exists. - Copyright (C) 1990, 1997, 1998, 1999 Free Software Foundation, Inc. + Copyright (C) 1990, 1997, 1998, 1999, 2000 Free Software Foundation, Inc. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -50,6 +50,10 @@ char *alloca (); # define S_ISDIR(m) (((m) & S_IFMT) == S_IFDIR) #endif +#ifndef S_IRWXUGO +# define S_IRWXUGO (S_IRWXU | S_IRWXG | S_IRWXO) +#endif + #if STDC_HEADERS # include <stdlib.h> #endif @@ -380,13 +384,17 @@ make_path (const char *argpath, error (0, errno, _("cannot chown %s"), dirpath); retval = 1; } - /* chown may have turned off some permission bits we wanted. */ - if ((mode & (S_ISUID | S_ISGID | S_ISVTX)) - && chmod (basename_dir, mode)) - { - error (0, errno, _("cannot chmod %s"), dirpath); - retval = 1; - } + } + + /* The above chown may have turned off some permission bits in MODE. + Another reason we may have to use chmod here is that mkdir(2) is + required to honor only the file permission bits. In particular, + it may not have honored the `special' bits. */ + if ((mode & ~S_IRWXUGO) + && chmod (basename_dir, mode)) + { + error (0, errno, _("cannot chmod %s"), dirpath); + retval = 1; } CLEANUP_CWD; |