Skip site navigation (1)Skip section navigation (2)
Date:      Sun,  2 Nov 2008 20:14:51 +0100 (CET)
From:      Jilles Tjoelker <jilles@stack.nl>
To:        FreeBSD-gnats-submit@FreeBSD.org
Subject:   standards/128546: ls -p does not follow symlinks
Message-ID:  <20081102191451.0466D22899@snail.stack.nl>
Resent-Message-ID: <200811021920.mA2JK6W0065281@freefall.freebsd.org>

next in thread | raw e-mail | index | archive | help

>Number:         128546
>Category:       standards
>Synopsis:       ls -p does not follow symlinks
>Confidential:   no
>Severity:       non-critical
>Priority:       medium
>Responsible:    freebsd-standards
>State:          open
>Quarter:        
>Keywords:       
>Date-Required:
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Sun Nov 02 19:20:06 UTC 2008
>Closed-Date:
>Last-Modified:
>Originator:     Jilles Tjoelker
>Release:        FreeBSD 7.1-PRERELEASE i386
>Organization:
MCGV Stack
>Environment:
System: FreeBSD snail.stack.nl 7.1-PRERELEASE FreeBSD 7.1-PRERELEASE #7: Fri Sep 5 08:57:44 CEST 2008 dean@snail.stack.nl:/sabretooth.mnt/sources/7.x/i386/obj/sabretooth.mnt/sources/7.x/src/sys/STACK-SMP i386


>Description:
According to the man page, when neither -H/-L nor -F/-d/-l are given, -H is
implied. This agrees with POSIX, GNU ls and Solaris ls. This means that -p,
although it is very similar to -F, does not prevent the implicit following
of symlinks.
>How-To-Repeat:
Suppose we have /sys -> usr/src/sys symlink (as usual).

Input:
ls -p /sys

Expected result: directory listing of /usr/src/sys, could look like
Makefile        ddb/            libkern/        netncp/         powerpc/
amd64/          dev/            modules/        netsmb/         rpc/
arm/            fs/             net/            nfs/            security/
boot/           gdb/            net80211/       nfs4client/     sparc64/
bsm/            geom/           netatalk/       nfsclient/      sun4v/
cam/            gnu/            netgraph/       nfsserver/      sys/
cddl/           i386/           netinet/        nlm/            tools/
compat/         i4b/            netinet6/       opencrypto/     ufs/
conf/           ia64/           netipsec/       pc98/           vm/
contrib/        isa/            netipx/         pccard/         xdr/
crypto/         kern/           netnatm/        pci/

Actual result:
/sys

Colour ls (-G/CLICOLOR) does not affect this (this is good).

ls /sys follows the symlink, and ls -F /sys, ls -d /sys and ls -l /sys do
not follow the symlink (this is good).

>Fix:

Patch included.

The comment in the code is already correct, too :)

--- ls-p-symlinks.patch begins here ---
--- src/bin/ls/ls.c.orig	2006-03-24 18:09:03.000000000 +0100
+++ src/bin/ls/ls.c	2008-10-19 15:12:22.000000000 +0200
@@ -395,7 +395,7 @@
 	 * If not -F, -d or -l options, follow any symbolic links listed on
 	 * the command line.
 	 */
-	if (!f_longform && !f_listdir && !f_type)
+	if (!f_longform && !f_listdir && (!f_type || f_slash))
 		fts_options |= FTS_COMFOLLOW;
 
 	/*
--- ls-p-symlinks.patch ends here ---


>Release-Note:
>Audit-Trail:
>Unformatted:



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20081102191451.0466D22899>