On Wednesday 31 August 2005 02:27 am, Jim Meyering wrote:
> and a patch to add a few test cases.

i'm not too familiar with perl, so i'll just cheat and include the way to 
reproduce:
touch setuid && chmod u+s setuid
touch setgid && chmod g+s setgid
mkdir sticky && chmod +t sticky
mkdir owt && chmod +t,o+w owt
mkdir owr && chmod o+w owr
ls --color=always -d setuid setgid sticky owt owr

> Finally, I don't like the names, WRITEOTHERS or WRITEOTHERSSTICKY.
> How about OTHER_WRITABLE and STICKY_OTHER_WRITABLE, instead?

doesnt really matter to me what they're called ;)

> Do you feel like finishing the job and submitting a better patch?
> If you do, please make the patch relative to coreutils CVS:

done, find attached ... thanks for all the pointers
-mike
2005-08-31  Mike Frysinger  <[EMAIL PROTECTED]>

	* src/dircolors.c: Define setuid, setgid, sticky, other-writable,
	and sticky-other-writable color types.
	* src/dircolors.hin: Setup default colors for above types.
	* src/ls.c: Likewise.

Index: src/dircolors.c
===================================================================
RCS file: /cvsroot/coreutils/coreutils/src/dircolors.c,v
retrieving revision 1.90
diff -u -p -r1.90 src/dircolors.c
--- src/dircolors.c
+++ src/dircolors.c
@@ -67,13 +67,15 @@ static const char *const slack_codes[] =
   "NORMAL", "NORM", "FILE", "DIR", "LNK", "LINK",
   "SYMLINK", "ORPHAN", "MISSING", "FIFO", "PIPE", "SOCK", "BLK", "BLOCK",
   "CHR", "CHAR", "DOOR", "EXEC", "LEFT", "LEFTCODE", "RIGHT", "RIGHTCODE",
-  "END", "ENDCODE", NULL
+  "END", "ENDCODE", "SUID", "SETUID", "SGID", "SETGID", "STICKY", 
+  "OTHER_WRITABLE", "OWR", "STICKY_OTHER_WRITABLE", "OWT", NULL
 };
 
 static const char *const ls_codes[] =
 {
   "no", "no", "fi", "di", "ln", "ln", "ln", "or", "mi", "pi", "pi",
   "so", "bd", "bd", "cd", "cd", "do", "ex", "lc", "lc", "rc", "rc", "ec", "ec"
+  "su", "su", "sg", "sg", "st", "ow", "ow", "tw", "tw", NULL
 };
 
 static struct option const long_options[] =
Index: src/dircolors.hin
===================================================================
RCS file: /cvsroot/coreutils/coreutils/src/dircolors.hin,v
retrieving revision 1.19
diff -u -p -r1.19 src/dircolors.hin
--- src/dircolors.hin
+++ src/dircolors.hin
@@ -51,6 +51,11 @@ DOOR 01;35	# door
 BLK 40;33;01	# block device driver
 CHR 40;33;01	# character device driver
 ORPHAN 40;31;01 # symlink to nonexistent file
+SETUID 37;41	# file that is setuid (u+s)
+SETGID 30;43	# file that is setgid (g+s)
+OWT 30;42	# dir that is sticky other writable (+t,o+w)
+OWR 34;42	# dir that is other writable (o+w)
+STICKY 37;44	# dir with the sticky bit set (+t)
 
 # This is for files with execute permission:
 EXEC 01;32
Index: src/ls.c
===================================================================
RCS file: /cvsroot/coreutils/coreutils/src/ls.c,v
retrieving revision 1.397
diff -u -p -r1.397 src/ls.c
--- src/ls.c
+++ src/ls.c
@@ -518,13 +518,15 @@ enum Dereference_symlink
 enum indicator_no
   {
     C_LEFT, C_RIGHT, C_END, C_NORM, C_FILE, C_DIR, C_LINK, C_FIFO, C_SOCK,
-    C_BLK, C_CHR, C_MISSING, C_ORPHAN, C_EXEC, C_DOOR
+    C_BLK, C_CHR, C_MISSING, C_ORPHAN, C_EXEC, C_DOOR, C_UID, C_GID, C_STICKY,
+    C_OWR, C_OWT
   };
 
 static const char *const indicator_name[]=
   {
     "lc", "rc", "ec", "no", "fi", "di", "ln", "pi", "so",
-    "bd", "cd", "mi", "or", "ex", "do", NULL
+    "bd", "cd", "mi", "or", "ex", "do", "su", "sg", "st",
+    "ow", "tw", NULL
   };
 
 struct color_ext_type
@@ -550,7 +552,12 @@ static struct bin_str color_indicator[] 
     { 0, NULL },			/* mi: Missing file: undefined */
     { 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 ("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 */
   };
 
 /* FIXME: comment  */
@@ -3687,7 +3694,16 @@ print_color_indicator (const char *name,
   else
     {
       if (S_ISDIR (mode))
-	type = C_DIR;
+	{
+	  if ((mode & (S_ISVTX|S_IWOTH)) == (S_ISVTX|S_IWOTH))
+	    type = C_OWT;
+	  else if ((mode & S_IWOTH) != 0)
+	    type = C_OWR;
+	  else if ((mode & S_ISVTX) != 0)
+	    type = C_STICKY;
+	  else
+	    type = C_DIR;
+	}
       else if (S_ISLNK (mode))
 	type = ((!linkok && color_indicator[C_ORPHAN].string)
 		? C_ORPHAN : C_LINK);
@@ -3702,8 +3718,15 @@ print_color_indicator (const char *name,
       else if (S_ISDOOR (mode))
 	type = C_DOOR;
 
-      if (type == C_FILE && (mode & S_IXUGO) != 0)
-	type = C_EXEC;
+      if (type == C_FILE)
+	{
+	  if ((mode & S_ISUID) != 0)
+	    type = C_UID;
+	  else if ((mode & S_ISGID) != 0)
+	    type = C_GID;
+	  else if ((mode & S_IXUGO) != 0)
+	    type = C_EXEC;
+	}
 
       /* Check the file's suffix only if still classified as C_FILE.  */
       ext = NULL;
_______________________________________________
Bug-coreutils mailing list
[email protected]
http://lists.gnu.org/mailman/listinfo/bug-coreutils

Reply via email to