Date: Tue, 31 Oct 2000 12:08:34 +0100 From: "Jose M. Alcaide" <jose@we.lc.ehu.es> To: Ryan Thompson <ryan@sasknow.com> Cc: freebsd-hackers@FreeBSD.ORG, Sean Lutner <sean@rentul.net> Subject: Re: Who broke "ls" in FreeBSD? and why? Message-ID: <39FEA832.7EFD61E7@we.lc.ehu.es> References: <Pine.BSF.4.21.0010310353110.14845-100000@ren.sasknow.com>
next in thread | previous in thread | raw e-mail | index | archive | help
Ryan Thompson wrote: > > "Search" (i.e., execute) permission on a directory implies that the > directory can be included as part of a directory search. In other words, > mapping to inodes is provided, but obtaining a list of files in the > directory is NOT. This is used by system administrators to "hide" a > directory of files, but still grant access to them if they are named > explicitly. > > [...] > You don't need to explain the semantics of UNIX permissions :-) I am working with UNIX systems since 1983. The read permission *must* be enough for listing the names and numbers of each entry of a directory. The read permission guarantees that the directory can be opened for reading; remember that the directory is only a table of entries. The search ("x") permission is needed for accesing the contents of the i-nodes pointed to by each directory entry. This is the semantics of the read and search directory permissions for all UNIX flavors. But this is what happens when using FreeBSD's ls(1): %which ls /bin/ls %mkdir Test %touch Test/{1,2,3} %ls -ai Test 31748 . 7936 .. 31749 1 31750 2 31754 3 %chmod -x Test %ls -ai Test % <------- WRONG!!!! The "ls -ai" command *must* work even without the search permission, since it does not ask for the i-node contents of each directory entry. As demonstration, I wrote a small and ugly program which uses getdents(2) for simulating an "ls -ai Test", and it *works*, of course: %ls -ld Test drw------- 2 jose lsi 512 31 oct 11:44 Test %./almost_ls 512 bytes read from directory inode=31748 name=. inode=7936 name=.. inode=31749 name=1 inode=31750 name=2 inode=31754 name=3 % The conclusion is clear: FreeBSD's ls(1) is broken. In fact, I am going to submit a PR. 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?39FEA832.7EFD61E7>