From jose@we.lc.ehu.es  Mon Nov 25 09:36:46 2002
Return-Path: <jose@we.lc.ehu.es>
Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125])
	by hub.freebsd.org (Postfix) with ESMTP id 9469937B401
	for <FreeBSD-gnats-submit@freebsd.org>; Mon, 25 Nov 2002 09:36:46 -0800 (PST)
Received: from polaris.we.lc.ehu.es (polaris.we.lc.ehu.es [158.227.6.43])
	by mx1.FreeBSD.org (Postfix) with ESMTP id 2CE1E43ECD
	for <FreeBSD-gnats-submit@freebsd.org>; Mon, 25 Nov 2002 09:36:42 -0800 (PST)
	(envelope-from jose@we.lc.ehu.es)
Received: from v-ger.we.lc.ehu.es (v-ger.we.lc.ehu.es [158.227.6.51])
	by polaris.we.lc.ehu.es (8.11.6/8.11.6) with ESMTP id gAPHaRD15353;
	Mon, 25 Nov 2002 18:36:27 +0100 (MET)
Received: from v-ger.we.lc.ehu.es (localhost [127.0.0.1])
	by v-ger.we.lc.ehu.es (8.12.6/8.12.6) with ESMTP id gAPHbKq1004970;
	Mon, 25 Nov 2002 18:37:20 +0100 (CET)
	(envelope-from jose@v-ger.we.lc.ehu.es)
Received: (from jose@localhost)
	by v-ger.we.lc.ehu.es (8.12.6/8.12.6/Submit) id gAPHbK1j004969;
	Mon, 25 Nov 2002 18:37:20 +0100 (CET)
Message-Id: <200211251737.gAPHbK1j004969@v-ger.we.lc.ehu.es>
Date: Mon, 25 Nov 2002 18:37:20 +0100 (CET)
From: "Jose M. Alcaide" <jose@we.lc.ehu.es>
Reply-To: "Jose M. Alcaide" <jose@we.lc.ehu.es>
To: FreeBSD-gnats-submit@freebsd.org
Cc: jose@we.lc.ehu.es
Subject: ls(1)'s wrong behaviour with not searchable directories
X-Send-Pr-Version: 3.113
X-GNATS-Notify:

>Number:         45723
>Category:       bin
>Synopsis:       ls(1)'s wrong behaviour with not searchable directories
>Confidential:   no
>Severity:       serious
>Priority:       medium
>Responsible:    das
>State:          closed
>Quarter:        
>Keywords:       
>Date-Required:  
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Mon Nov 25 09:40:01 PST 2002
>Closed-Date:    Tue Jun 08 09:32:54 GMT 2004
>Last-Modified:  Tue Jun 08 09:32:54 GMT 2004
>Originator:     Jose M. Alcaide
>Release:        FreeBSD 4.7-RELEASE i386
>Organization:
Universidad del Pais Vasco - Dept de Electricidad y Electronica
>Environment:
System: FreeBSD v-ger.we.lc.ehu.es 4.7-RELEASE FreeBSD 4.7-RELEASE #12: Thu Nov 21 18:56:49 CET 2002 root@v-ger.we.lc.ehu.es:/usr/obj/usr/src/sys/V-GER i386

>Description:
When a directory does not have search (x) permission, but it still have read
permission, its contents must be visible with "ls" (even "ls -i" should show
the inode numbers). However, FreeBSD's ls(1) does not show anything. Besides
that, a "ls -l" should fail, because search permission is required in order
to access the inode contents of the files in the directory; however, "ls -l"
gives nothing: no listing, no error message, nothing.

>How-To-Repeat:
$ mkdir FOOBAR
$ cd FOOBAR
$ touch a b c d e
$ cd ..
$ chmod -x FOOBAR
$ ls FOOBAR
  <no output, no errors>
$ ls -l FOOBAR
  <no output, no errors>

>Fix:
I tried to fix this problem, but ls(1) uses the fts(3) functions, and after
an hour or so trying to figure how it actually works, I only got a headache.
:-(
>Release-Note:
>Audit-Trail:

From: David Schultz <dschultz@uclink.Berkeley.EDU>
To: "Jose M. Alcaide" <jose@we.lc.ehu.es>
Cc: FreeBSD-gnats-submit@FreeBSD.ORG
Subject: Re: bin/45723: ls(1)'s wrong behaviour with not searchable directories
Date: Sun, 1 Dec 2002 21:52:40 -0800

 > When a directory does not have search (x) permission, but it still have read
 > permission, its contents must be visible with "ls" (even "ls -i" should show
 > the inode numbers). However, FreeBSD's ls(1) does not show anything. Besides
 > that, a "ls -l" should fail, because search permission is required in order
 > to access the inode contents of the files in the directory; however, "ls -l"
 > gives nothing: no listing, no error message, nothing.
 > 
 > >How-To-Repeat:
 > $ mkdir FOOBAR
 > $ cd FOOBAR
 > $ touch a b c d e
 > $ cd ..
 > $ chmod -x FOOBAR
 > $ ls FOOBAR
 >   <no output, no errors>
 
 This one seems to be fixed in -CURRENT.
 
 > $ ls -l FOOBAR
 >   <no output, no errors>
 
 Yes, this is still broken.  I get the following in Solaris 8:
 
 dschultz@nova:~> ls -l foo | sed 's/^/*/'
 ls: foo/a: Permission denied
 ls: foo/b: Permission denied
 ls: foo/c: Permission denied
 ls: foo/d: Permission denied
 ls: foo/e: Permission denied
 *total 0
 
 The problem appears to be in the fts_children() implementation.
 If a chdir fails, the routine does not retry with FTS_NOCHDIR as
 it should.  There is also a bug in ls whereby it fails to print
 the total if stat() fails on each directory entry.  Technically it
 should print 0 for consistency's sake.
 
 BTW, tcsh's globbing (but not autocompletion) is also affected by
 the fts bug.  Ash, which does not use fts, works fine.
State-Changed-From-To: open->analyzed 
State-Changed-By: das 
State-Changed-When: Tue Jun 8 06:26:53 GMT 2004 
State-Changed-Why:  
The outstanding problem reported in the PR has been fixed in  
src/lib/libc/gen/fts.c,v 1.27.  However, the `total' bug in 
ls(1) mentioned in the audit trail persists. 


Responsible-Changed-From-To: freebsd-bugs->das 
Responsible-Changed-By: das 
Responsible-Changed-When: Tue Jun 8 06:26:53 GMT 2004 
Responsible-Changed-Why:  
Over to me. 

http://www.freebsd.org/cgi/query-pr.cgi?pr=45723 
State-Changed-From-To: analyzed->closed 
State-Changed-By: das 
State-Changed-When: Tue Jun 8 09:31:44 GMT 2004 
State-Changed-Why:  
The other bug was fixed in: 
src/bin/ls/print.c,v 1.73 
src/bin/ls/ls.c,v 1.78 

http://www.freebsd.org/cgi/query-pr.cgi?pr=45723 
>Unformatted:
