bug-coreutils
[Top][All Lists]
Advanced

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

Re: [ANNOUNCEMENT] Updated: coreutils-6.10-1


From: Eric Blake
Subject: Re: [ANNOUNCEMENT] Updated: coreutils-6.10-1
Date: Mon, 14 Apr 2008 17:31:56 +0000 (UTC)
User-agent: Loom/3.14 (http://gmane.org/)

Eric Blake <ebb9 <at> byu.net> writes:

> It looks like this commit is the culprit:
> http://git.sv.gnu.org/gitweb/?p=coreutils.git;a=commitdiff;h=0a74437
> 
> It looks like a true regression.  The change was introduced because of this 
> thread:
> http://lists.gnu.org/archive/html/bug-coreutils/2007-06/msg00004.html
> http://lists.gnu.org/archive/html/bug-coreutils/2007-07/msg00079.html
> 
> It looks like when -l is NOT in effect, you should not stat the result of a 
> symlink.  But when -l IS in effect, and C_EXEC is enabled, then the result of 
> stat'ing the symling IS used, in order to color the symlink target 
differently 
> than the color of the symlink.
> 

And I believe this patch fixes things.  I don't know if Corinna wants to be 
mentioned in THANKS (she's been generally reluctant to expose her email address 
on the cygwin lists); hence the obfuscated address in the log message for now.

>From ff17266b281a93adafd9ac2484d9836e8d1c97a1 Mon Sep 17 00:00:00 2001
From: Eric Blake <address@hidden>
Date: Mon, 14 Apr 2008 11:14:00 -0600
Subject: [PATCH] Fix ls -l coloring regression from 2007-07-15.

* src/ls.c (main): Stat symlinks for long format if the target
might need to be colored as an executable.
* tests/ls/stat-free-symlinks (LS_COLORS): Enhance test.
* NEWS: Mention the fix.
Reported by Corinna Vinschen <corinna-cygwin AT cygwin DOT com>.

Signed-off-by: Eric Blake <address@hidden>
---
 NEWS                        |    3 +++
 src/ls.c                    |    3 ++-
 tests/ls/stat-free-symlinks |   21 +++++++++++++++++++--
 3 files changed, 24 insertions(+), 3 deletions(-)

diff --git a/NEWS b/NEWS
index e208b30..e86503e 100644
--- a/NEWS
+++ b/NEWS
@@ -20,6 +20,9 @@ GNU coreutils NEWS                                    -*- 
outline -*-
   ls no longer segfaults on files in /proc when linked with an older version
   of libselinux.  E.g., ls -l /proc/sys would dereference a NULL pointer.
 
+  ls -l --color would mistakenly fail to color the target of a symlink.
+  [introduced in coreutils-6.9]
+
   "mkdir -Z x dir" no longer segfaults when diagnosing invalid context "x"
   mkfifo and mknod would fail similarly.  Now they're fixed.
 
diff --git a/src/ls.c b/src/ls.c
index e029fe0..d474ecc 100644
--- a/src/ls.c
+++ b/src/ls.c
@@ -1177,7 +1177,8 @@ main (int argc, char **argv)
     {
       /* Avoid following symbolic links when possible.  */
       if (is_colored (C_ORPHAN)
-         || (is_colored (C_EXEC) && color_symlink_as_referent)
+         || (is_colored (C_EXEC)
+              && (color_symlink_as_referent || format == long_format))
          || (is_colored (C_MISSING) && format == long_format))
        check_symlink_color = true;
 
diff --git a/tests/ls/stat-free-symlinks b/tests/ls/stat-free-symlinks
index 07fb38e..f419410 100755
--- a/tests/ls/stat-free-symlinks
+++ b/tests/ls/stat-free-symlinks
@@ -32,8 +32,8 @@ fail=0
 
 # ls from coreutils 6.9 would unnecessarily stat a symlink in an unusual case:
 # When not coloring orphan and missing entries, and without ln=target,
-# ensure that ls -F (or -d, or -l: i.e., when not dereferencing)
-# does not stat a symlink to directory, and does still color that
+# ensure that ls -F (or -d: i.e., when not dereferencing)
+# does not stat a symlink, and does still color that
 # symlink and an executable file properly.
 
 LS_COLORS='or=0:mi=0:ex=01;32:ln=01;35' \
@@ -52,4 +52,21 @@ grep '^stat("x"' err && fail=1
 
 compare out exp || fail=1
 
+# ls from coreutils 6.10 would mistakenly not stat a symlink in a counter
+# case: When coloring executable files and without ln=target, ensure that
+# ls -l correctly colors both halves of the link listing.
+
+LS_COLORS='or=0:mi=0:ex=01;32:ln=01;35' \
+  ls -l --color=always link-to-x > out 2> err || fail=1
+
+# Check that output is colorized as requested.
+{
+  ls -l link-to-x | sed 's/link-to-x -> x//' | tr -d '\n'
+  printf '\033[0m\033[01;35mlink-to-x\033[0m -> \033[01;32mx\033[0m\n'
+  printf '\033[m'
+} > exp 2> err || fail=1
+
+test -s err || fail=1
+compare out exp || fail=1
+
 (exit $fail); exit $fail
-- 
1.5.5








reply via email to

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