summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorPádraig Brady <P@draigBrady.com>2009-09-14 13:37:37 +0100
committerPádraig Brady <P@draigBrady.com>2009-09-21 13:16:44 +0100
commit3a169f4c5d9159283548178668d2fae6fced3030 (patch)
treef604d725323a55ca480e3eeb49421bc91048fe35 /src
parent29ec834c3b076dbc1bd160ef780a58f5b086ce13 (diff)
downloadcoreutils-3a169f4c5d9159283548178668d2fae6fced3030.tar.xz
ls: handle disabling of colors consistently for all tile types
* src/ls.c (print_color_indicator): Use consistent syntax for all file and directory subtypes, and fall back to the color of the base type if there is no enabled color for the subtype. This allows turning off specific colors for o+w dirs for example. * tests/ls/color-dtype-dir: Add a case to test that turning off coloring for o+w directories, falls back to standard dir color. * NEWS: Mention the fix Introduced by commit ac467814, 2005-09-05, "Colorize set-user-ID ... files and sticky ... directories."
Diffstat (limited to 'src')
-rw-r--r--src/ls.c24
1 files changed, 13 insertions, 11 deletions
diff --git a/src/ls.c b/src/ls.c
index 6d81dab0e..10d024bac 100644
--- a/src/ls.c
+++ b/src/ls.c
@@ -4103,7 +4103,7 @@ print_color_indicator (const char *name, mode_t mode, int linkok,
bool stat_ok, enum filetype filetype,
nlink_t nlink)
{
- int type;
+ enum indicator_no type;
struct color_ext_type *ext; /* Color extension */
size_t len; /* Length of name */
@@ -4121,27 +4121,29 @@ print_color_indicator (const char *name, mode_t mode, int linkok,
if (S_ISREG (mode))
{
type = C_FILE;
- if ((mode & S_ISUID) != 0)
+
+ if ((mode & S_ISUID) != 0 && is_colored (C_SETUID))
type = C_SETUID;
- else if ((mode & S_ISGID) != 0)
+ else if ((mode & S_ISGID) != 0 && is_colored (C_SETGID))
type = C_SETGID;
- else if (is_colored (C_CAP) && has_capability (name))
+ else if (has_capability (name) && is_colored (C_CAP))
type = C_CAP;
- else if ((mode & S_IXUGO) != 0)
+ else if ((mode & S_IXUGO) != 0 && is_colored (C_EXEC))
type = C_EXEC;
- else if (is_colored (C_MULTIHARDLINK) && (1 < nlink))
+ else if ((1 < nlink) && is_colored (C_MULTIHARDLINK))
type = C_MULTIHARDLINK;
}
else if (S_ISDIR (mode))
{
- if ((mode & S_ISVTX) && (mode & S_IWOTH))
+ type = C_DIR;
+
+ if ((mode & S_ISVTX) && (mode & S_IWOTH)
+ && is_colored (C_STICKY_OTHER_WRITABLE))
type = C_STICKY_OTHER_WRITABLE;
- else if ((mode & S_IWOTH) != 0)
+ else if ((mode & S_IWOTH) != 0 && is_colored (C_OTHER_WRITABLE))
type = C_OTHER_WRITABLE;
- else if ((mode & S_ISVTX) != 0)
+ else if ((mode & S_ISVTX) != 0 && is_colored (C_STICKY))
type = C_STICKY;
- else
- type = C_DIR;
}
else if (S_ISLNK (mode))
type = ((!linkok && color_indicator[C_ORPHAN].string)