From unknown Thu Sep 11 13:55:23 2025 X-Loop: help-debbugs@gnu.org Subject: bug#9634: Coreutils 8.13 - Orphaned symlinks start with 'argetm' when using dircolors Resent-From: Jason Glassey Original-Sender: debbugs-submit-bounces@debbugs.gnu.org Resent-CC: bug-coreutils@gnu.org Resent-Date: Thu, 29 Sep 2011 21:13:03 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: report 9634 X-GNU-PR-Package: coreutils X-GNU-PR-Keywords: To: 9634@debbugs.gnu.org X-Debbugs-Original-To: bug-coreutils@gnu.org Received: via spool by submit@debbugs.gnu.org id=B.131733073932044 (code B ref -1); Thu, 29 Sep 2011 21:13:03 +0000 Received: (at submit) by debbugs.gnu.org; 29 Sep 2011 21:12:19 +0000 Received: from localhost ([127.0.0.1] helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1R9Nty-0008Ki-FI for submit@debbugs.gnu.org; Thu, 29 Sep 2011 17:12:19 -0400 Received: from eggs.gnu.org ([140.186.70.92]) by debbugs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1R9NXp-0007oY-2P for submit@debbugs.gnu.org; Thu, 29 Sep 2011 16:49:26 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1R9NWn-0001R9-UQ for submit@debbugs.gnu.org; Thu, 29 Sep 2011 16:48:22 -0400 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on eggs.gnu.org X-Spam-Level: X-Spam-Status: No, score=-2.5 required=5.0 tests=BAYES_00, FREEMAIL_ENVFROM_END_DIGIT, FREEMAIL_FROM, RCVD_IN_DNSWL_LOW, T_DKIM_INVALID, T_TO_NO_BRKTS_FREEMAIL autolearn=unavailable version=3.3.1 Received: from lists.gnu.org ([140.186.70.17]:34576) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1R9NWn-0001R5-So for submit@debbugs.gnu.org; Thu, 29 Sep 2011 16:48:21 -0400 Received: from eggs.gnu.org ([140.186.70.92]:39762) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1R9NWn-0003tg-1e for bug-coreutils@gnu.org; Thu, 29 Sep 2011 16:48:21 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1R9NWl-0001Ql-Ll for bug-coreutils@gnu.org; Thu, 29 Sep 2011 16:48:21 -0400 Received: from mail-yw0-f41.google.com ([209.85.213.41]:64134) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1R9NWl-0001Qf-Dj for bug-coreutils@gnu.org; Thu, 29 Sep 2011 16:48:19 -0400 Received: by ywe9 with SMTP id 9so1113805ywe.0 for ; Thu, 29 Sep 2011 13:48:17 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=mime-version:date:message-id:subject:from:to:content-type; bh=2kUulljxmKZXgeIEbvAYdlNIrSZVrzkm8Nr6UzbOjfg=; b=JsZiIzl7VV526hHvQkDVRT2I1uRXWk/qM+7Upisds/H9uvR/q1JpB9+QdtHsk8YRiZ fa+XHkfQSkpc+7gvMvFypdl04N3oGfLtQF/+gJDsdH6T6i5RVp3wcmY7JptVjcRWIzzY u9gOA0ch8Xb+WY9Y3j6QzcaUfHo+EU100280c= MIME-Version: 1.0 Received: by 10.150.207.13 with SMTP id e13mr1614174ybg.303.1317329297350; Thu, 29 Sep 2011 13:48:17 -0700 (PDT) Received: by 10.150.203.1 with HTTP; Thu, 29 Sep 2011 13:48:17 -0700 (PDT) Date: Thu, 29 Sep 2011 16:48:17 -0400 Message-ID: From: Jason Glassey Content-Type: text/plain; charset=ISO-8859-1 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6 (newer, 2) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6 (newer, 3) X-Received-From: 140.186.70.17 X-Spam-Score: -5.9 (-----) X-Mailman-Approved-At: Thu, 29 Sep 2011 17:10:54 -0400 X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.11 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: debbugs-submit-bounces@debbugs.gnu.org Errors-To: debbugs-submit-bounces@debbugs.gnu.org X-Spam-Score: -5.9 (-----) I had seen this was a bug supposed to be fixed in Coreutils 8.3, but I can still replicate this bug in Coreutils 8.13 In my .bashrc file, I have this alias: alias ls='ls -Lp --color=auto --group-directories-first' Symlinks appear fine when the target exist, but when the symlink becomes orphaned (such as a symlink to a removable drive), the symlink starts with 'argetm' I only get this problem when I use the '--dereference' option, and when the target does not exist when using dircolors. From unknown Thu Sep 11 13:55:23 2025 X-Loop: help-debbugs@gnu.org Subject: bug#9634: Coreutils 8.13 - Orphaned symlinks start with 'argetm' when using dircolors Resent-From: =?UTF-8?Q?P=C3=A1draig?= Brady Original-Sender: debbugs-submit-bounces@debbugs.gnu.org Resent-CC: bug-coreutils@gnu.org Resent-Date: Fri, 30 Sep 2011 20:41:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 9634 X-GNU-PR-Package: coreutils X-GNU-PR-Keywords: To: Jason Glassey Cc: 9634@debbugs.gnu.org Received: via spool by 9634-submit@debbugs.gnu.org id=B9634.131741520531019 (code B ref 9634); Fri, 30 Sep 2011 20:41:01 +0000 Received: (at 9634) by debbugs.gnu.org; 30 Sep 2011 20:40:05 +0000 Received: from localhost ([127.0.0.1] helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1R9jsK-00084G-0x for submit@debbugs.gnu.org; Fri, 30 Sep 2011 16:40:04 -0400 Received: from mail3.vodafone.ie ([213.233.128.45]) by debbugs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1R9jsF-00083i-Ln for 9634@debbugs.gnu.org; Fri, 30 Sep 2011 16:40:00 -0400 X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: ApcBADEohk5tThgX/2dsb2JhbAAMNaY9hEwBAQEEJwsBRhALDQEKCSUPAkYGDQEHAQHAHYMZhAcEmSCLeg Received: from unknown (HELO [192.168.1.79]) ([109.78.24.23]) by mail3.vodafone.ie with ESMTP; 30 Sep 2011 21:38:50 +0100 Message-ID: <4E8628D9.30609@draigBrady.com> Date: Fri, 30 Sep 2011 21:38:49 +0100 From: =?UTF-8?Q?P=C3=A1draig?= Brady User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:6.0) Gecko/20110816 Thunderbird/6.0 MIME-Version: 1.0 References: In-Reply-To: X-Enigmail-Version: 1.3.1 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 8bit X-Spam-Score: -2.6 (--) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.11 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: debbugs-submit-bounces@debbugs.gnu.org Errors-To: debbugs-submit-bounces@debbugs.gnu.org X-Spam-Score: -2.6 (--) On 09/29/2011 09:48 PM, Jason Glassey wrote: > I had seen this was a bug supposed to be fixed in Coreutils 8.3, but I > can still replicate this bug in > Coreutils 8.13 > > In my .bashrc file, I have this alias: > > alias ls='ls -Lp --color=auto --group-directories-first' > > Symlinks appear fine when the target exist, but when the symlink > becomes orphaned (such as a > symlink to a removable drive), the symlink starts with 'argetm' > > I only get this problem when I use the '--dereference' option, and > when the target does not exist > when using dircolors. Confirmed. I'll fix it with something like the following, and I'll add a test too. cheers, Pádraig. diff --git a/src/ls.c b/src/ls.c index 680a7c3..e7d0a5c 100644 --- a/src/ls.c +++ b/src/ls.c @@ -4203,10 +4203,7 @@ print_color_indicator (const struct fileinfo *f, bool symlink_target) type = C_STICKY; } else if (S_ISLNK (mode)) - type = ((!linkok - && (!STRNCMP_LIT (color_indicator[C_LINK].string, "target") - || color_indicator[C_ORPHAN].string)) - ? C_ORPHAN : C_LINK); + type = C_LINK; else if (S_ISFIFO (mode)) type = C_FIFO; else if (S_ISSOCK (mode)) @@ -4241,6 +4238,14 @@ print_color_indicator (const struct fileinfo *f, bool symlink_target) } } + /* Adjust the color for orphaned symlinks. */ + if (type == C_LINK && !linkok) + { + if (!STRNCMP_LIT (color_indicator[C_LINK].string, "target") + || color_indicator[C_ORPHAN].string) + type = C_ORPHAN; + } + { const struct bin_str *const s = ext ? &(ext->seq) : &color_indicator[type]; From unknown Thu Sep 11 13:55:23 2025 X-Loop: help-debbugs@gnu.org Subject: bug#9634: Coreutils 8.13 - Orphaned symlinks start with 'argetm' when using dircolors Resent-From: Jim Meyering Original-Sender: debbugs-submit-bounces@debbugs.gnu.org Resent-CC: bug-coreutils@gnu.org Resent-Date: Fri, 30 Sep 2011 20:51:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 9634 X-GNU-PR-Package: coreutils X-GNU-PR-Keywords: To: Jason Glassey Cc: 9634@debbugs.gnu.org Received: via spool by 9634-submit@debbugs.gnu.org id=B9634.131741583331931 (code B ref 9634); Fri, 30 Sep 2011 20:51:02 +0000 Received: (at 9634) by debbugs.gnu.org; 30 Sep 2011 20:50:33 +0000 Received: from localhost ([127.0.0.1] helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1R9k2T-0008Iy-HV for submit@debbugs.gnu.org; Fri, 30 Sep 2011 16:50:33 -0400 Received: from mx.meyering.net ([88.168.87.75]) by debbugs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1R9k2Q-0008Ip-6L for 9634@debbugs.gnu.org; Fri, 30 Sep 2011 16:50:32 -0400 Received: from rho.meyering.net (localhost.localdomain [127.0.0.1]) by rho.meyering.net (Acme Bit-Twister) with ESMTP id 157AC60097; Fri, 30 Sep 2011 22:49:21 +0200 (CEST) From: Jim Meyering In-Reply-To: (Jason Glassey's message of "Thu, 29 Sep 2011 16:48:17 -0400") References: Date: Fri, 30 Sep 2011 22:49:20 +0200 Message-ID: <87d3ehu567.fsf@rho.meyering.net> Lines: 79 MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Transfer-Encoding: quoted-printable X-Spam-Score: -3.0 (---) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.11 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: debbugs-submit-bounces@debbugs.gnu.org Errors-To: debbugs-submit-bounces@debbugs.gnu.org X-Spam-Score: -3.0 (---) Jason Glassey wrote: > I had seen this was a bug supposed to be fixed in Coreutils 8.3, but I > can still replicate this bug in > Coreutils 8.13 > > In my .bashrc file, I have this alias: > > alias ls=3D'ls -Lp --color=3Dauto --group-directories-first' > > Symlinks appear fine when the target exist, but when the symlink > becomes orphaned (such as a > symlink to a removable drive), the symlink starts with 'argetm' > > I only get this problem when I use the '--dereference' option, and > when the target does not exist > when using dircolors. Thanks for the report. Between yours and the one in http://bugs.debian.org/586765, I was able to create a stand-alone reproducer. The trick was to realize that you have customized your LS_COLORS envvar to include ln=3Dtarget. Do this in an empty directory: $ ln -s /no-such dangle $ env LS_COLORS=3Dln=3Dtarget ls --dereference --color ls: cannot access dangle: No such file or directory argetmdangle While looking at that, I noticed two minor problems, fixed by this. P=E1draig, I expect to push this before your fix. It looks like it will be easy for you to adjust your patch accordingly. >From 4f38e9f24971762540da9d5457dfa9e5e03d53ee Mon Sep 17 00:00:00 2001 From: Jim Meyering Date: Fri, 30 Sep 2011 20:13:01 +0200 Subject: [PATCH] ls: avoid reading beyond end of color indicator At first this looked like a buffer overrun, since there was no test to ensure that the buffer length was 6. However, since the LS_COLORS string is NUL-terminated and since settings within it are separated by ":" there was neither the risk of reading beyond end of buffer nor risk of a false-positive match. * src/ls.c (print_color_indicator): Use color_symlink_as_referent rather than manually comparing against "target" again. * src/system.h (STRNCMP_LIT): Correct description in comment. --- src/ls.c | 2 +- src/system.h | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/ls.c b/src/ls.c index 680a7c3..c1b1918 100644 --- a/src/ls.c +++ b/src/ls.c @@ -4204,7 +4204,7 @@ print_color_indicator (const struct fileinfo *f, bool= symlink_target) } else if (S_ISLNK (mode)) type =3D ((!linkok - && (!STRNCMP_LIT (color_indicator[C_LINK].string, "target= ") + && (color_symlink_as_referent || color_indicator[C_ORPHAN].string)) ? C_ORPHAN : C_LINK); else if (S_ISFIFO (mode)) diff --git a/src/system.h b/src/system.h index 107dbd5..ec64cd0 100644 --- a/src/system.h +++ b/src/system.h @@ -188,7 +188,7 @@ select_plural (uintmax_t n) #define STREQ_LEN(a, b, n) (strncmp (a, b, n) =3D=3D 0) #define STRPREFIX(a, b) (strncmp(a, b, strlen (b)) =3D=3D 0) -/* Just like strncmp, but the first argument must be a literal string +/* Just like strncmp, but the second argument must be a literal string and you don't specify the length. */ #define STRNCMP_LIT(s, literal) \ strncmp (s, "" literal "", sizeof (literal) - 1) -- 1.7.7.rc0.362.g5a14 From unknown Thu Sep 11 13:55:23 2025 X-Loop: help-debbugs@gnu.org Subject: bug#9634: Coreutils 8.13 - Orphaned symlinks start with 'argetm' when using dircolors Resent-From: =?UTF-8?Q?P=C3=A1draig?= Brady Original-Sender: debbugs-submit-bounces@debbugs.gnu.org Resent-CC: bug-coreutils@gnu.org Resent-Date: Fri, 30 Sep 2011 21:51:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 9634 X-GNU-PR-Package: coreutils X-GNU-PR-Keywords: To: Jim Meyering Cc: Jason Glassey , 9634@debbugs.gnu.org Received: via spool by 9634-submit@debbugs.gnu.org id=B9634.13174194204595 (code B ref 9634); Fri, 30 Sep 2011 21:51:02 +0000 Received: (at 9634) by debbugs.gnu.org; 30 Sep 2011 21:50:20 +0000 Received: from localhost ([127.0.0.1] helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1R9kyK-0001C4-Jo for submit@debbugs.gnu.org; Fri, 30 Sep 2011 17:50:20 -0400 Received: from mail3.vodafone.ie ([213.233.128.45]) by debbugs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1R9kyJ-0001Bw-9R for 9634@debbugs.gnu.org; Fri, 30 Sep 2011 17:50:20 -0400 X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: ApIBAJs4hk5tThgX/2dsb2JhbAAMNasJAQEBBDIBRhALDQsJJQ8CRgYNAQcBAcAFhyAEmSCEW4cf Received: from unknown (HELO [192.168.1.79]) ([109.78.24.23]) by mail3.vodafone.ie with ESMTP; 30 Sep 2011 22:49:09 +0100 Message-ID: <4E863955.30905@draigBrady.com> Date: Fri, 30 Sep 2011 22:49:09 +0100 From: =?UTF-8?Q?P=C3=A1draig?= Brady User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:6.0) Gecko/20110816 Thunderbird/6.0 MIME-Version: 1.0 References: <87d3ehu567.fsf@rho.meyering.net> In-Reply-To: <87d3ehu567.fsf@rho.meyering.net> X-Enigmail-Version: 1.3.1 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 8bit X-Spam-Score: -2.6 (--) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.11 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: debbugs-submit-bounces@debbugs.gnu.org Errors-To: debbugs-submit-bounces@debbugs.gnu.org X-Spam-Score: -2.6 (--) On 09/30/2011 09:49 PM, Jim Meyering wrote: > Jason Glassey wrote: >> I had seen this was a bug supposed to be fixed in Coreutils 8.3, but I >> can still replicate this bug in >> Coreutils 8.13 >> >> In my .bashrc file, I have this alias: >> >> alias ls='ls -Lp --color=auto --group-directories-first' >> >> Symlinks appear fine when the target exist, but when the symlink >> becomes orphaned (such as a >> symlink to a removable drive), the symlink starts with 'argetm' >> >> I only get this problem when I use the '--dereference' option, and >> when the target does not exist >> when using dircolors. > > Thanks for the report. > Between yours and the one in http://bugs.debian.org/586765, > I was able to create a stand-alone reproducer. > The trick was to realize that you have customized your > LS_COLORS envvar to include ln=target. > Do this in an empty directory: > > $ ln -s /no-such dangle > $ env LS_COLORS=ln=target ls --dereference --color > ls: cannot access dangle: No such file or directory > argetmdangle > > While looking at that, I noticed two minor problems, fixed by this. > Pádraig, I expect to push this before your fix. It looks like it > will be easy for you to adjust your patch accordingly. Heh, of course we picked the same time to handle this :) Your fixes look good, and I'll adjust mine mentioning the debian bug too. thanks, Pádraig. From unknown Thu Sep 11 13:55:23 2025 X-Loop: help-debbugs@gnu.org Subject: bug#9634: Coreutils 8.13 - Orphaned symlinks start with 'argetm' when using dircolors Resent-From: Jim Meyering Original-Sender: debbugs-submit-bounces@debbugs.gnu.org Resent-CC: bug-coreutils@gnu.org Resent-Date: Fri, 30 Sep 2011 21:53:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 9634 X-GNU-PR-Package: coreutils X-GNU-PR-Keywords: To: =?UTF-8?Q?P=C3=A1draig?= Brady Cc: Jason Glassey , 9634@debbugs.gnu.org Received: via spool by 9634-submit@debbugs.gnu.org id=B9634.13174195614804 (code B ref 9634); Fri, 30 Sep 2011 21:53:02 +0000 Received: (at 9634) by debbugs.gnu.org; 30 Sep 2011 21:52:41 +0000 Received: from localhost ([127.0.0.1] helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1R9l0a-0001FQ-VH for submit@debbugs.gnu.org; Fri, 30 Sep 2011 17:52:41 -0400 Received: from mx.meyering.net ([88.168.87.75]) by debbugs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1R9l0Y-0001FJ-Lw for 9634@debbugs.gnu.org; Fri, 30 Sep 2011 17:52:39 -0400 Received: from rho.meyering.net (localhost.localdomain [127.0.0.1]) by rho.meyering.net (Acme Bit-Twister) with ESMTP id 494346002D; Fri, 30 Sep 2011 23:51:29 +0200 (CEST) From: Jim Meyering In-Reply-To: <4E863955.30905@draigBrady.com> ("=?UTF-8?Q?P=C3=A1draig?= Brady"'s message of "Fri, 30 Sep 2011 22:49:09 +0100") References: <87d3ehu567.fsf@rho.meyering.net> <4E863955.30905@draigBrady.com> Date: Fri, 30 Sep 2011 23:51:29 +0200 Message-ID: <87sjndsnq6.fsf@rho.meyering.net> Lines: 41 MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Transfer-Encoding: quoted-printable X-Spam-Score: -3.0 (---) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.11 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: debbugs-submit-bounces@debbugs.gnu.org Errors-To: debbugs-submit-bounces@debbugs.gnu.org X-Spam-Score: -3.0 (---) P=E1draig Brady wrote: > On 09/30/2011 09:49 PM, Jim Meyering wrote: >> Jason Glassey wrote: >>> I had seen this was a bug supposed to be fixed in Coreutils 8.3, but I >>> can still replicate this bug in >>> Coreutils 8.13 >>> >>> In my .bashrc file, I have this alias: >>> >>> alias ls=3D'ls -Lp --color=3Dauto --group-directories-first' >>> >>> Symlinks appear fine when the target exist, but when the symlink >>> becomes orphaned (such as a >>> symlink to a removable drive), the symlink starts with 'argetm' >>> >>> I only get this problem when I use the '--dereference' option, and >>> when the target does not exist >>> when using dircolors. >> >> Thanks for the report. >> Between yours and the one in http://bugs.debian.org/586765, >> I was able to create a stand-alone reproducer. >> The trick was to realize that you have customized your >> LS_COLORS envvar to include ln=3Dtarget. >> Do this in an empty directory: >> >> $ ln -s /no-such dangle >> $ env LS_COLORS=3Dln=3Dtarget ls --dereference --color >> ls: cannot access dangle: No such file or directory >> argetmdangle >> >> While looking at that, I noticed two minor problems, fixed by this. >> P=E1draig, I expect to push this before your fix. It looks like it >> will be easy for you to adjust your patch accordingly. > > Heh, of course we picked the same time to handle this :) > Your fixes look good, and I'll adjust mine mentioning > the debian bug too. Thanks for the review. Pushed. From unknown Thu Sep 11 13:55:23 2025 MIME-Version: 1.0 X-Mailer: MIME-tools 5.427 (Entity 5.427) X-Loop: help-debbugs@gnu.org From: help-debbugs@gnu.org (GNU bug Tracking System) To: Jason Glassey Subject: bug#9634: closed (Re: bug#9634: Coreutils 8.13 - Orphaned symlinks start with 'argetm' when using dircolors) Message-ID: References: <4E866A65.3010307@draigBrady.com> X-Gnu-PR-Message: they-closed 9634 X-Gnu-PR-Package: coreutils Reply-To: 9634@debbugs.gnu.org Date: Sat, 01 Oct 2011 01:20:03 +0000 Content-Type: multipart/mixed; boundary="----------=_1317432003-23003-1" This is a multi-part message in MIME format... ------------=_1317432003-23003-1 Content-Disposition: inline Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Your bug report #9634: Coreutils 8.13 - Orphaned symlinks start with 'argetm' when using di= rcolors which was filed against the coreutils package, has been closed. The explanation is attached below, along with your original report. If you require more details, please reply to 9634@debbugs.gnu.org. --=20 9634: http://debbugs.gnu.org/cgi/bugreport.cgi?bug=3D9634 GNU Bug Tracking System Contact help-debbugs@gnu.org with problems ------------=_1317432003-23003-1 Content-Type: message/rfc822 Content-Disposition: inline Content-Transfer-Encoding: 7bit Received: (at 9634-done) by debbugs.gnu.org; 1 Oct 2011 01:19:45 +0000 Received: from localhost ([127.0.0.1] helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1R9oEy-0005yU-A1 for submit@debbugs.gnu.org; Fri, 30 Sep 2011 21:19:45 -0400 Received: from mail3.vodafone.ie ([213.233.128.45]) by debbugs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1R9oEu-0005yL-NM for 9634-done@debbugs.gnu.org; Fri, 30 Sep 2011 21:19:42 -0400 X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: ApMBANFphk5tThgX/2dsb2JhbAAMNasLAQEBBCdSEAsNBAMBAgEJFg8JAwIBAgE9CAYNAQUCAQG/C4MZhAcEmSCEW4cf Received: from unknown (HELO [192.168.1.79]) ([109.78.24.23]) by mail3.vodafone.ie with ESMTP; 01 Oct 2011 02:18:30 +0100 Message-ID: <4E866A65.3010307@draigBrady.com> Date: Sat, 01 Oct 2011 02:18:29 +0100 From: =?ISO-8859-1?Q?P=E1draig_Brady?= User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:6.0) Gecko/20110816 Thunderbird/6.0 MIME-Version: 1.0 To: Jim Meyering Subject: Re: bug#9634: Coreutils 8.13 - Orphaned symlinks start with 'argetm' when using dircolors References: <87d3ehu567.fsf@rho.meyering.net> <4E863955.30905@draigBrady.com> <87sjndsnq6.fsf@rho.meyering.net> In-Reply-To: <87sjndsnq6.fsf@rho.meyering.net> X-Enigmail-Version: 1.3.1 Content-Type: multipart/mixed; boundary="------------080709010608030209090309" X-Spam-Score: -2.6 (--) X-Debbugs-Envelope-To: 9634-done Cc: 9634-done@debbugs.gnu.org, Jason Glassey X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.11 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: debbugs-submit-bounces@debbugs.gnu.org Errors-To: debbugs-submit-bounces@debbugs.gnu.org X-Spam-Score: -2.6 (--) This is a multi-part message in MIME format. --------------080709010608030209090309 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 8bit On 09/30/2011 10:51 PM, Jim Meyering wrote: > Pádraig Brady wrote: >> >> Your fixes look good, and I'll adjust mine mentioning >> the debian bug too. > > Thanks for the review. Pushed. > And I applied the attached. cheers, Pádraig. --------------080709010608030209090309 Content-Type: text/plain; name="ls-L-argetm.diff" Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename="ls-L-argetm.diff" >From 84457c491e775f664a1c33274cd2c5acadb5be73 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?P=C3=A1draig=20Brady?= Date: Sat, 1 Oct 2011 01:47:53 +0100 Subject: [PATCH] ls: fix output of dangling symlinks colored as target This is related to commit b7f2b51c, 2010-01-01, "ls: fix color of broken symlinks colored as target" which didn't handle the --dereference case. The simplest way to reproduce the resultant erroneous "argetm" is as follows: $ ln -s /no-such dangle $ env LS_COLORS=ln=target ls --dereference --color ls: cannot access dangle: No such file or directory argetmdangle This is also an issue with the `tree` utility, reported here: http://bugs.debian.org/586765 * src/ls.c (print_color_indicator): Move the handling of 'ln=target' in $LS_COLORS (color_symlink_as_referent == true) to a higher scope, to handle all cases where type == C_LINK. * tests/misc/ls-misc: Add a test case for the specific issue, and 2 further test cases to verify other code paths in this area. Reported by Jason Glassey. --- src/ls.c | 13 +++++++++---- tests/misc/ls-misc | 41 +++++++++++++++++++++++++++++++++++++++++ 2 files changed, 50 insertions(+), 4 deletions(-) diff --git a/src/ls.c b/src/ls.c index c1b1918..1b0c250 100644 --- a/src/ls.c +++ b/src/ls.c @@ -4203,10 +4203,7 @@ print_color_indicator (const struct fileinfo *f, bool symlink_target) type = C_STICKY; } else if (S_ISLNK (mode)) - type = ((!linkok - && (color_symlink_as_referent - || color_indicator[C_ORPHAN].string)) - ? C_ORPHAN : C_LINK); + type = C_LINK; else if (S_ISFIFO (mode)) type = C_FIFO; else if (S_ISSOCK (mode)) @@ -4241,6 +4238,14 @@ print_color_indicator (const struct fileinfo *f, bool symlink_target) } } + /* Adjust the color for orphaned symlinks. */ + if (type == C_LINK && !linkok) + { + if (color_symlink_as_referent + || color_indicator[C_ORPHAN].string) + type = C_ORPHAN; + } + { const struct bin_str *const s = ext ? &(ext->seq) : &color_indicator[type]; diff --git a/tests/misc/ls-misc b/tests/misc/ls-misc index 8b356d4..b159bbf 100755 --- a/tests/misc/ls-misc +++ b/tests/misc/ls-misc @@ -223,6 +223,47 @@ my @Tests = restore_ls_colors; }}, ], + # Test for a bug fixed after coreutils-8.13 + # where 'argetm' was errenously printed for dangling links + # when ln=target was used in LS_COLORS + ['sl-dangle6', '-L --color=always d', + {OUT => "s\n"}, + {PRE => sub {mkdir 'd',0755 or die "d: $!\n"; + symlink 'dangle', 'd/s' or die "d/s: $!\n"; + push_ls_colors('ln=target') + }}, + {POST => sub {unlink 'd/s' or die "d/s: $!\n"; + rmdir 'd' or die "d: $!\n"; + restore_ls_colors; }}, + {ERR => "ls: cannot access d/s: No such file or directory\n"}, + {EXIT => 1} + ], + # Related to the above fix, is this case where + # the code simulates "linkok". In this case "linkmode" + # should always be zero, and hence not trigger any + # issues with type being set to C_LINK + ['sl-dangle7', '--color=always d', + {OUT => "$e\e[ms$e\n"}, + {PRE => sub {mkdir 'd',0755 or die "d: $!\n"; + symlink 'dangle', 'd/s' or die "d/s: $!\n"; + push_ls_colors('ln=target:or=:ex=:') + }}, + {POST => sub {unlink 'd/s' or die "d/s: $!\n"; + rmdir 'd' or die "d: $!\n"; + restore_ls_colors; }}, + ], + # Another case with simulated "linkok", that does + # actually use the value of 'ln' from $LS_COLORS. + # This path is not taken though when 'ln=target'. + ['sl-dangle8', '--color=always s', + {OUT => "$e\e[1;36ms$e\n"}, + {PRE => sub {symlink 'dangle', 's' or die "s: $!\n"; + push_ls_colors('ln=1;36:or=:') + }}, + {POST => sub {unlink 's' or die "s: $!\n"; + restore_ls_colors; }}, + ], + # Test for a bug that was introduced in coreutils-4.5.4; fixed in 4.5.5. # To demonstrate it, the file in question (with executable bit set) # must not be a command line argument. -- 1.7.6 --------------080709010608030209090309-- ------------=_1317432003-23003-1 Content-Type: message/rfc822 Content-Disposition: inline Content-Transfer-Encoding: 7bit Received: (at submit) by debbugs.gnu.org; 29 Sep 2011 21:12:19 +0000 Received: from localhost ([127.0.0.1] helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1R9Nty-0008Ki-FI for submit@debbugs.gnu.org; Thu, 29 Sep 2011 17:12:19 -0400 Received: from eggs.gnu.org ([140.186.70.92]) by debbugs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1R9NXp-0007oY-2P for submit@debbugs.gnu.org; Thu, 29 Sep 2011 16:49:26 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1R9NWn-0001R9-UQ for submit@debbugs.gnu.org; Thu, 29 Sep 2011 16:48:22 -0400 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on eggs.gnu.org X-Spam-Level: X-Spam-Status: No, score=-2.5 required=5.0 tests=BAYES_00, FREEMAIL_ENVFROM_END_DIGIT, FREEMAIL_FROM, RCVD_IN_DNSWL_LOW, T_DKIM_INVALID, T_TO_NO_BRKTS_FREEMAIL autolearn=unavailable version=3.3.1 Received: from lists.gnu.org ([140.186.70.17]:34576) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1R9NWn-0001R5-So for submit@debbugs.gnu.org; Thu, 29 Sep 2011 16:48:21 -0400 Received: from eggs.gnu.org ([140.186.70.92]:39762) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1R9NWn-0003tg-1e for bug-coreutils@gnu.org; Thu, 29 Sep 2011 16:48:21 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1R9NWl-0001Ql-Ll for bug-coreutils@gnu.org; Thu, 29 Sep 2011 16:48:21 -0400 Received: from mail-yw0-f41.google.com ([209.85.213.41]:64134) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1R9NWl-0001Qf-Dj for bug-coreutils@gnu.org; Thu, 29 Sep 2011 16:48:19 -0400 Received: by ywe9 with SMTP id 9so1113805ywe.0 for ; Thu, 29 Sep 2011 13:48:17 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=mime-version:date:message-id:subject:from:to:content-type; bh=2kUulljxmKZXgeIEbvAYdlNIrSZVrzkm8Nr6UzbOjfg=; b=JsZiIzl7VV526hHvQkDVRT2I1uRXWk/qM+7Upisds/H9uvR/q1JpB9+QdtHsk8YRiZ fa+XHkfQSkpc+7gvMvFypdl04N3oGfLtQF/+gJDsdH6T6i5RVp3wcmY7JptVjcRWIzzY u9gOA0ch8Xb+WY9Y3j6QzcaUfHo+EU100280c= MIME-Version: 1.0 Received: by 10.150.207.13 with SMTP id e13mr1614174ybg.303.1317329297350; Thu, 29 Sep 2011 13:48:17 -0700 (PDT) Received: by 10.150.203.1 with HTTP; Thu, 29 Sep 2011 13:48:17 -0700 (PDT) Date: Thu, 29 Sep 2011 16:48:17 -0400 Message-ID: Subject: Coreutils 8.13 - Orphaned symlinks start with 'argetm' when using dircolors From: Jason Glassey To: bug-coreutils@gnu.org Content-Type: text/plain; charset=ISO-8859-1 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6 (newer, 2) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6 (newer, 3) X-Received-From: 140.186.70.17 X-Spam-Score: -5.9 (-----) X-Debbugs-Envelope-To: submit X-Mailman-Approved-At: Thu, 29 Sep 2011 17:10:54 -0400 X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.11 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: debbugs-submit-bounces@debbugs.gnu.org Errors-To: debbugs-submit-bounces@debbugs.gnu.org X-Spam-Score: -5.9 (-----) I had seen this was a bug supposed to be fixed in Coreutils 8.3, but I can still replicate this bug in Coreutils 8.13 In my .bashrc file, I have this alias: alias ls='ls -Lp --color=auto --group-directories-first' Symlinks appear fine when the target exist, but when the symlink becomes orphaned (such as a symlink to a removable drive), the symlink starts with 'argetm' I only get this problem when I use the '--dereference' option, and when the target does not exist when using dircolors. ------------=_1317432003-23003-1-- From unknown Thu Sep 11 13:55:23 2025 X-Loop: help-debbugs@gnu.org Subject: bug#9634: Coreutils 8.13 - Orphaned symlinks start with 'argetm' when using dircolors Resent-From: =?UTF-8?Q?P=C3=A1draig?= Brady Original-Sender: debbugs-submit-bounces@debbugs.gnu.org Resent-CC: bug-coreutils@gnu.org Resent-Date: Sat, 01 Oct 2011 01:40:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 9634 X-GNU-PR-Package: coreutils X-GNU-PR-Keywords: To: 9634@debbugs.gnu.org Received: via spool by 9634-submit@debbugs.gnu.org id=B9634.131743315824673 (code B ref 9634); Sat, 01 Oct 2011 01:40:02 +0000 Received: (at 9634) by debbugs.gnu.org; 1 Oct 2011 01:39:18 +0000 Received: from localhost ([127.0.0.1] helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1R9oXt-0006Pu-KG for submit@debbugs.gnu.org; Fri, 30 Sep 2011 21:39:18 -0400 Received: from mail3.vodafone.ie ([213.233.128.45]) by debbugs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1R9oXr-0006Pl-6R for 9634@debbugs.gnu.org; Fri, 30 Sep 2011 21:39:16 -0400 X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: AoACAHxuhk5tThgX/2dsb2JhbAAMNZlmjFmETAEBAQQyAVYLDQsJFg8JAwIBAgFFEwgBARa+Y4cgBJkgi3o Received: from unknown (HELO [192.168.1.79]) ([109.78.24.23]) by mail3.vodafone.ie with ESMTP; 01 Oct 2011 02:38:04 +0100 Message-ID: <4E866EFC.1090700@draigBrady.com> Date: Sat, 01 Oct 2011 02:38:04 +0100 From: =?UTF-8?Q?P=C3=A1draig?= Brady User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:6.0) Gecko/20110816 Thunderbird/6.0 MIME-Version: 1.0 References: <87d3ehu567.fsf@rho.meyering.net> <4E863955.30905@draigBrady.com> <87sjndsnq6.fsf@rho.meyering.net> <4E866A65.3010307@draigBrady.com> In-Reply-To: <4E866A65.3010307@draigBrady.com> X-Enigmail-Version: 1.3.1 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 8bit X-Spam-Score: -2.6 (--) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.11 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: debbugs-submit-bounces@debbugs.gnu.org Errors-To: debbugs-submit-bounces@debbugs.gnu.org X-Spam-Score: -2.6 (--) On 10/01/2011 02:18 AM, Pádraig Brady wrote: > On 09/30/2011 10:51 PM, Jim Meyering wrote: >> Pádraig Brady wrote: >>> >>> Your fixes look good, and I'll adjust mine mentioning >>> the debian bug too. >> >> Thanks for the review. Pushed. >> > > And I applied the attached. Actually that deserves a NEWS entry, which I've just applied. cheers, Pádraig.