Date: Sun, 24 Aug 1997 14:44:49 -0400 From: Keith Mitchell <kmitch@guru.org> To: bmc@WillsCreek.COM, hpa@nwu.edu, ports@freebsd.org Subject: Patches for linuxls (gnuls) Message-ID: <19970824144449.58209@guru.org>
next in thread | raw e-mail | index | archive | help
Scott Gasch (scott@acm.vt.edu) and I (kmitch@acm.org) created some patches for the linuxls (gnuls) port that add support for the following: setgid programs setuid programs other writeable dirs other writeable sticky dirs (the goal being to optionally visially flag these file/dir types with a color in your ls listing...) The patches apply fine over top of a pristine fileutils/colorls patch or through the FreeBSD port. Any comments/suggestions welcome. *** src/dircolors.c.orig Sun Aug 24 13:43:56 1997 --- src/dircolors.c Sun Aug 24 13:44:35 1997 *************** *** 142,152 **** const char *slack_codes[] = {"NORMAL", "NORM", "FILE", "DIR", "LNK", "LINK", "SYMLINK", "ORPHAN", "MISSING", "FIFO", "PIPE", "SOCK", "BLK", "BLOCK", "CHR", "CHAR", "EXEC", "LEFT", "LEFTCODE", "RIGHT", "RIGHTCODE", "END", ! "ENDCODE", NULL}; const char *ls_codes[] = {"no", "no", "fi", "di", "ln", "ln", "ln", "or", "mi", "pi", "pi", "so", "bd", "bd", "cd", "cd", "ex", "lc", "lc", "rc", ! "rc", "ec", "ec"}; enum color_opts { col_yes, col_no, col_tty }; --- 142,154 ---- const char *slack_codes[] = {"NORMAL", "NORM", "FILE", "DIR", "LNK", "LINK", "SYMLINK", "ORPHAN", "MISSING", "FIFO", "PIPE", "SOCK", "BLK", "BLOCK", "CHR", "CHAR", "EXEC", "LEFT", "LEFTCODE", "RIGHT", "RIGHTCODE", "END", ! "ENDCODE", "SUID", "SETUID", "SGID", "SETGID", "WRO", "WRITEOTHERS", ! "WT", "WROT", "WRITEOTHERSSTICKY", NULL}; const char *ls_codes[] = {"no", "no", "fi", "di", "ln", "ln", "ln", "or", "mi", "pi", "pi", "so", "bd", "bd", "cd", "cd", "ex", "lc", "lc", "rc", ! "rc", "ec", "ec", "su", "su", "sg", "sg", "wo", "wo", "wo", "wt", "wt", "wt", ! NULL}; enum color_opts { col_yes, col_no, col_tty }; *** src/ls.c.orig Sun Aug 24 13:43:55 1997 --- src/ls.c Sun Aug 24 13:44:35 1997 *************** *** 340,351 **** 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 }; char *indicator_name[]= { "lc","rc","ec","no","fi","di","ln","pi","so","bd","cd","mi","or", ! "ex",NULL }; /* Null is a valid character in a color indicator (think about Epson --- 340,351 ---- 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_UID, C_GID, C_WRO, C_WT }; char *indicator_name[]= { "lc","rc","ec","no","fi","di","ln","pi","so","bd","cd","mi","or", ! "ex","su","sg","wo","wt",NULL }; /* Null is a valid character in a color indicator (think about Epson *************** *** 373,379 **** { 5, "44;37" }, /* cd: Char device: white on blue */ { 0, NULL }, /* mi: Missing file: undefined */ { 0, NULL }, /* or: Orphanned symlink: undefined */ ! { 2, "35" } /* ex: Executable: purple */ }; struct col_ext_type --- 373,383 ---- { 5, "44;37" }, /* cd: Char device: white on blue */ { 0, NULL }, /* mi: Missing file: undefined */ { 0, NULL }, /* or: Orphanned symlink: undefined */ ! { 2, "35" }, /* ex: Executable: purple */ ! { 5, "37;41" }, /* su: setuid: white on red */ ! { 4, "0;43" }, /* sg: setgid: black on yellow */ ! { 5, "37;41" }, /* wo: writeable-other: white on red */ ! { 5, "37;42" } /* wt: wo w/ sticky set: white on green */ }; struct col_ext_type *************** *** 1163,1173 **** case 1: /* First label character */ switch ( *p ) { ! case ':': p++; break; ! case '*': /* Allocate new extension block and add to head of linked list (this way a later definition will override an earlier one, which can be useful for --- 1167,1179 ---- case 1: /* First label character */ switch ( *p ) { ! ! case ':': /* advance ptr, same state, next char */ p++; break; ! case '*': /* this is an extension mapping */ ! /* Allocate new extension block and add to head of linked list (this way a later definition will override an earlier one, which can be useful for *************** *** 1213,1219 **** for ( ind_no = 0 ; indicator_name[ind_no] != NULL ; ind_no++ ) { ! if ( strcmp(label,indicator_name[ind_no]) == 0 ) { color_indicator[ind_no].string = buf; state = (color_indicator[ind_no].len = --- 1219,1225 ---- for ( ind_no = 0 ; indicator_name[ind_no] != NULL ; ind_no++ ) { ! if ( !strcmp(label, indicator_name[ind_no]) ) { color_indicator[ind_no].string = buf; state = (color_indicator[ind_no].len = *************** *** 2454,2463 **** break; } ! if ( !ext ) ! { ! if (S_ISDIR (mode)) ! type = C_DIR; #ifdef S_ISLNK else if (S_ISLNK (mode)) --- 2460,2478 ---- break; } ! if ( !ext ) { ! ! if (S_ISDIR (mode)) { ! ! if (( mode & MODE_WT ) == MODE_WT ) ! type = C_WT; ! ! else if (( mode & MODE_WRO ) == MODE_WRO ) ! type = C_WRO; ! ! else type = C_DIR; ! } ! #ifdef S_ISLNK else if (S_ISLNK (mode)) *************** *** 2484,2493 **** else if (S_ISCHR (mode)) type = C_CHR; #endif ! if ( type == C_FILE && (mode & (S_IEXEC|S_IEXEC>>3|S_IEXEC>>6)) ) ! type = C_EXEC; ! } } put_indicator(&color_indicator[C_LEFT]); --- 2499,2517 ---- else if (S_ISCHR (mode)) type = C_CHR; #endif + ! /* now check if it's suid, guid and lastly executable only */ ! if (( type == C_FILE ) && (mode & (S_ISUID) )) ! type = C_UID; ! ! else if (( type == C_FILE ) && (mode & (S_ISGID) )) ! type = C_GID; ! ! else if ( type == C_FILE && (mode & (S_IEXEC|S_IEXEC>>3|S_IEXEC>>6)) ) ! type = C_EXEC; ! ! } } put_indicator(&color_indicator[C_LEFT]); *** src/ls.h.orig Wed May 26 00:15:06 1993 --- src/ls.h Sun Aug 24 13:44:35 1997 *************** *** 7,10 **** --- 7,16 ---- /* This is for the `vdir' program. */ #define LS_LONG_FORMAT 3 + #define MODE_WT 01002 + + #define MODE_WRO 02 + extern int ls_mode; + + *** man/ls.1.orig Sun Aug 24 14:23:42 1997 --- man/ls.1 Sun Aug 24 14:25:19 1997 *************** *** 280,285 **** --- 280,289 ---- \fBlc\fR \ee[ Left code \fBrc\fR m Right code \fBec\fR (none) End code (replaces lc+no+rc) + \fBsu\fR 37;41 setuid file + \fBsg\fR 30;43 setgid file + \fBwo\fR 37;41 dir writable by others + \fBwt\fR 37;42 dir writable by others w/ sticky bit .fi .RE .sp *** man/dircolors.1.in.orig Sun Aug 24 14:24:01 1997 --- man/dircolors.1.in Sun Aug 24 14:24:55 1997 *************** *** 212,217 **** --- 212,230 ---- .I "end code" for non-ISO\ 6429 terminals (see below). .TP + .B SUID \fIcolor-sequence\fR + Specifies the color used for all files with SUID bit set. + .TP + .B SGID \fIcolor-sequence\fR + Specifies the color used for all files with SGID bit set. + .TP + .B WRO \fIcolor-sequence\fR + Specifies the color used for directories writable by "other". + .TP + .B WROT \fIcolor-sequence\fR + Specifies the color used for directories writable by other with the + sticky bit turned on. (e.g. /tmp) + .TP \fB*\fIextension\fR \fIcolor-sequence\fR Specifies the color used for any file that ends in \fIextension\fR. .TP -- Keith Mitchell Head Administrator: acm.vt.edu Email: kmitch@weenix.guru.org PGP key available upon request http://weenix.guru.org/~kmitch Address and URL (c) 1997 Keith Mitchell - All Rights Reserved Unauthorized use or duplication prohibited
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?19970824144449.58209>