From 4e3c4c0478e6e1e81f093b80d8272840a39ca2bd Mon Sep 17 00:00:00 2001 From: Paul Eggert Date: Fri, 28 Jul 2006 07:39:27 +0000 Subject: [PATCH] * modechange.c (mode_compile): Numeric modes now affect setuid and setgid on directories only if they set these bits. * modechange.h: Remove obsolete comment about masks. --- lib/ChangeLog | 6 ++++++ lib/modechange.c | 12 +++++++----- lib/modechange.h | 2 -- 3 files changed, 13 insertions(+), 7 deletions(-) diff --git a/lib/ChangeLog b/lib/ChangeLog index 5f475c5eef..fbca6af5dc 100644 --- a/lib/ChangeLog +++ b/lib/ChangeLog @@ -1,3 +1,9 @@ +2006-07-28 Paul Eggert + + * modechange.c (mode_compile): Numeric modes now affect setuid and + setgid on directories only if they set these bits. + * modechange.h: Remove obsolete comment about masks. + 2006-07-27 Bruno Haible * stdint_.h (INT*_C, UINT*_C) [C++]: Define these if diff --git a/lib/modechange.c b/lib/modechange.c index 51684a4eb0..80e06710ac 100644 --- a/lib/modechange.c +++ b/lib/modechange.c @@ -143,12 +143,12 @@ mode_compile (char const *mode_string) if ('0' <= *mode_string && *mode_string < '8') { unsigned int octal_mode = 0; - unsigned int octal_mentioned = 0; + mode_t mode; + mode_t mentioned; do { octal_mode = 8 * octal_mode + *mode_string++ - '0'; - octal_mentioned = 8 * octal_mentioned + 7; if (ALLM < octal_mode) return NULL; } @@ -157,8 +157,9 @@ mode_compile (char const *mode_string) if (*mode_string) return NULL; - return make_node_op_equals (octal_to_mode (octal_mode), - octal_to_mode (octal_mentioned & ALLM)); + mode = octal_to_mode (octal_mode); + mentioned = (mode & (S_ISUID | S_ISGID)) | S_ISVTX | S_IRWXUGO; + return make_node_op_equals (mode, mentioned); } /* Allocate enough space to hold the result. */ @@ -299,7 +300,8 @@ mode_create_from_ref (const char *ref_file) directory if DIR), assuming the umask is UMASK_VALUE, adjusted as indicated by the list of change operations CHANGES. If DIR, the type 'X' change affects the returned value even if no execute bits - were set in OLDMODE. If PMODE_BITS is not null, store into + were set in OLDMODE, and set user and group ID bits are preserved + unless CHANGES mentioned them. If PMODE_BITS is not null, store into *PMODE_BITS a mask denoting file mode bits that are affected by CHANGES. diff --git a/lib/modechange.h b/lib/modechange.h index 30a45943fa..76e0178de2 100644 --- a/lib/modechange.h +++ b/lib/modechange.h @@ -17,8 +17,6 @@ along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ -/* Masks for the `flags' field in a `struct mode_change'. */ - #if ! defined MODECHANGE_H_ # define MODECHANGE_H_ -- 2.30.2