Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 25 Oct 2000 11:49:01 +0200
From:      "Jose M. Alcaide" <jose@we.lc.ehu.es>
To:        Sean Lutner <sean@rentul.net>, hackers@FreeBSD.org
Subject:   Re: Who broke "ls" in FreeBSD? and why?
Message-ID:  <39F6AC8D.542149FC@we.lc.ehu.es>
References:  <Pine.BSF.4.21.0010241956520.16878-100000@lowrider.lewman.org>

next in thread | previous in thread | raw e-mail | index | archive | help
Sean Lutner wrote:
> 
> I may just be being naive here, which is why I took this off the list. I
> don't understand how a directory that is a-x will not let you run ls -l on
> it.
> 
> (48) sean@h0050dab9d058: ~ $ ls test
> one     three   two
> (49) sean@h0050dab9d058: ~ $ ls -l test/
> total 0
> -rw-r--r--  1 sean  sean  0 Oct 24 19:59 one
> -rw-r--r--  1 sean  sean  0 Oct 24 19:59 three
> -rw-r--r--  1 sean  sean  0 Oct 24 19:59 two
> (50) sean@h0050dab9d058: ~ $ chmod a-x test/
> (51) sean@h0050dab9d058: ~ $ ls test/
> one     three   two
> (52) sean@h0050dab9d058: ~ $ ls -l test/
> (53) sean@h0050dab9d058: ~ $
> 
> As you can see, after changing the permissions, you cannot run ls -l as
> you could before. Perhaps I don't have the broken version, or there is
> something I am missing. At any rate, a better understanding would be nice.
> 

If a directory does not have search permission, the i-node contents of
each of its entries cannot be examined. Under these circumstances,
the directory listing "per se" does not fail, but the information
requested cannot be shown. For example, in Solaris (and in SunOS 4.x):

$ ls -ld Test/
drw-r-----   2 jose     lsi          512 oct 25 11:13 Test/
$ ls Test  
1  2  3
$ ls -i Test
288799 1 288800 2 288801 3
$ ls -l Test
Test/1: Permission denied
Test/2: Permission denied
Test/3: Permission denied
total 0
$

Anyway, I found something interesting: the bash shell is involved
in some way:

Using bash:

$ mkdir Test
$ touch Test/{1,2,3}
$ chmod a-x Test
$ ls Test && echo SUCCESS
SUCCESS                          <------ WRONG!!
$ /bin/ls Test && echo SUCCESS
1       2       3                <------ This works as expected (?!?!??)
SUCCESS
$ type ls
ls is hashed (/bin/ls)

Using [t]csh:

$ csh
%ls -ld Test
drw-------  2 jose  lsi  512 25 oct 10:49 Test
%ls Test
1       2       3                <------ This works as expected
%ls -i Test                      <------ WRONG!!
%which ls
/bin/ls
%

Using both bash and csh, 'ls -i' and 'ls -l' give nothing and
don't return any error when the directory does not have search permission.
"ls -i" should work, since getdirentries(2) only requires that
the directory must be opened for reading. The behavior of "ls -l" may
be a subject for discussion.

Cheers,
-- JMA
****** Jose M. Alcaide  //  jose@we.lc.ehu.es  //  jmas@FreeBSD.org ******
** "Beware of Programmers who carry screwdrivers" --  Leonard Brandwein **


To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe freebsd-hackers" in the body of the message




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?39F6AC8D.542149FC>