standards/128546: ls -p does not follow symlinks
Jilles Tjoelker
jilles at stack.nl
Sun Nov 2 11:20:07 PST 2008
>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 at 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:
More information about the freebsd-standards
mailing list