bug-gnulib
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

modechange sync from coreutils


From: Paul Eggert
Subject: modechange sync from coreutils
Date: Fri, 28 Jul 2006 03:41:31 -0400
User-agent: Gnus/5.1008 (Gnus v5.10.8) Emacs/21.4 (gnu/linux)

I installed this to sync from coreutils.
This follows up on the discussion rooted at
<http://lists.gnu.org/archive/html/bug-coreutils/2006-07/msg00124.html>.

2006-07-28  Paul Eggert  <address@hidden>

        * 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.

Index: lib/modechange.c
===================================================================
RCS file: /cvsroot/gnulib/gnulib/lib/modechange.c,v
retrieving revision 1.33
diff -p -u -r1.33 modechange.c
--- lib/modechange.c    17 Jul 2006 06:06:48 -0000      1.33
+++ lib/modechange.c    28 Jul 2006 07:38:55 -0000
@@ -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_fi
    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.
 
Index: lib/modechange.h
===================================================================
RCS file: /cvsroot/gnulib/gnulib/lib/modechange.h,v
retrieving revision 1.16
diff -p -u -r1.16 modechange.h
--- lib/modechange.h    17 Jul 2006 06:06:48 -0000      1.16
+++ lib/modechange.h    28 Jul 2006 07:38:55 -0000
@@ -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_
 




reply via email to

[Prev in Thread] Current Thread [Next in Thread]