bug-coreutils
[Top][All Lists]
Advanced

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

[patch 1/4] do not force suid color


From: Jan Engelhardt
Subject: [patch 1/4] do not force suid color
Date: Sat, 21 Jun 2008 12:47:57 +0200 (CEST)
User-agent: Alpine 1.10 (LNX 962 2008-03-14)


By default, ls highlights setuid/setgid/etc. files with a color, but
there is no way to restore the old (coreutils 5.x?) behavior, i.e.
that the setuid file gets the same color as it would when not having
suid.

Assume an /etc/DIR_COLORS of:
        NORMAL 0
        FILE 0
        EXEC 1;31 # bright red

Coreutils 5.x:
  -rw---S---  1 jengelh users    0 Oct 13 16:45 colorless
  -rwx--S---  1 jengelh users    0 Oct 13 16:45 brightred

Coreutils 6.x:
  -rw---S---  1 jengelh users    0 Oct 13 16:45 hardcoded-sgid-color
  -rwx--S---  1 jengelh users    0 Oct 13 16:45 hardcoded-sgid-color

Adding any of the following to /etc/DIR_COLORS:

  # Parse error
  SGID

  # -rw---S---  1 jengelh users    0 Oct 13 16:45 colorless
  # -rwx--S---  1 jengelh users    0 Oct 13 16:45 colorless
  SGID 0

In short, there is no way to get at the 5.x behavior with config
files only. This patch fixes the source code by removing any
hardcoded defaults and changing the logic.

Those who want that 6.x behavior shall use a DIR_COLORS file, such as
the shipped one.

Those who prefer the 5.x behavior can change their DIR_COLORS file to
not include any SUID/SGID/STICKY/OWR/OWT lines. (Which is sufficient
for me.)


Thanks,
Jan

---
 src/ls.c |   22 +++++++++++-----------
 1 file changed, 11 insertions(+), 11 deletions(-)

Index: coreutils-6.11/src/ls.c
===================================================================
--- coreutils-6.11.orig/src/ls.c
+++ coreutils-6.11/src/ls.c
@@ -550,11 +550,11 @@ static struct bin_str color_indicator[] 
     { 0, NULL },                       /* or: Orphaned symlink: undefined */
     { LEN_STR_PAIR ("01;32") },                /* ex: Executable: bright green 
*/
     { LEN_STR_PAIR ("01;35") },                /* do: Door: bright magenta */
-    { LEN_STR_PAIR ("37;41") },                /* su: setuid: white on red */
-    { LEN_STR_PAIR ("30;43") },                /* sg: setgid: black on yellow 
*/
-    { LEN_STR_PAIR ("37;44") },                /* st: sticky: black on blue */
-    { LEN_STR_PAIR ("34;42") },                /* ow: other-writable: blue on 
green */
-    { LEN_STR_PAIR ("30;42") },                /* tw: ow w/ sticky: black on 
green */
+    { 0, NULL },                       /* su: setuid: white on red */
+    { 0, NULL },                       /* sg: setgid: black on yellow */
+    { 0, NULL },                       /* st: sticky: black on blue */
+    { 0, NULL },                       /* ow: other-writable: blue on green */
+    { 0, NULL },                       /* tw: ow w/ sticky: black on green */
   };
 
 /* FIXME: comment  */
@@ -3923,20 +3923,20 @@ print_color_indicator (const char *name,
       if (S_ISREG (mode))
        {
          type = C_FILE;
-         if ((mode & S_ISUID) != 0)
+         if ((mode & S_ISUID) != 0 && color_indicator[C_SETUID].string != NULL)
            type = C_SETUID;
-         else if ((mode & S_ISGID) != 0)
+         else if ((mode & S_ISGID) != 0 && color_indicator[C_SETGID].string != 
NULL)
            type = C_SETGID;
-         else if ((mode & S_IXUGO) != 0)
+         else if ((mode & S_IXUGO) != 0 && color_indicator[C_EXEC].string != 
NULL)
            type = C_EXEC;
        }
       else if (S_ISDIR (mode))
        {
-         if ((mode & S_ISVTX) && (mode & S_IWOTH))
+         if ((mode & S_ISVTX) && (mode & S_IWOTH) && 
color_indicator[C_STICKY_OTHER_WRITABLE].string != NULL)
            type = C_STICKY_OTHER_WRITABLE;
-         else if ((mode & S_IWOTH) != 0)
+         else if ((mode & S_IWOTH) != 0 && 
color_indicator[C_OTHER_WRITABLE].string != NULL)
            type = C_OTHER_WRITABLE;
-         else if ((mode & S_ISVTX) != 0)
+         else if ((mode & S_ISVTX) != 0 && color_indicator[C_STICKY].string != 
NULL)
            type = C_STICKY;
          else
            type = C_DIR;




reply via email to

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