On Tue, Sep 17, 2024 at 03:22:58PM +0200, Otto Moerbeek wrote:
> On Tue, Sep 17, 2024 at 10:40:23AM +0100, Zé Loff wrote:
> 
> > On Tue, Sep 17, 2024 at 10:56:27AM +0200, Denis Bodor wrote:
> > > On Tue, Sep 17, 2024 at 09:43:27AM +0200, [email protected] wrote:
> > > > I would expect that without the 'x' bit, the directory is not searchable
> > > > and I won't be able to list its contents. But in fact I can, unless I
> > > > use a long format (-l, -g or -n).
> > > >
> > > > Can someone please explain the above behaviour? Thank you. Tom
> > > 
> > > Very roughly...
> > > The list of files in a directory is information about the directory.
> > > If you chmod -r my-test-dir, this information will no longer be available,
> > > for example.
> > > The file size is information about the files themselves; to read it, you
> > > need to be in the directory. But as you can't, it's unreadable.
> > > 
> > > -- 
> > > Denis
> > > 
> > 
> > It's a bit more complicated than that AFAICT.  Although I can reproduce
> > this inside /tmp, the behaviour is not consistent.  If I try to ls the
> > folder on a different shell -- e.g. a different terminal, or after
> > exiting script(1) -- the files aren't shown.  Also, if I rm -rf the
> > folder and recreate it (i.e. reuse the name) the files also aren't shown
> > the second time around.
> > 
> > -- 
> >  
> > 
> 
> Please take great care when testing this, it is easy to fool yourself.
> For example, often ls is aliased to add some flags. I have 
> 
> alias ls='ls -F'
> 
> which fails because it needs to look inside the dir.
> 
> For proper testing, use \ls i.e. the non-aliased version.
> 
>       -Otto
> 

You're right, apologies.  I have ls aliased to "/usr/local/bin/colorls
-G".  Things get consistent using /bin/ls:

    $ cd /tmp
    $ mkdir foobar
    $ touch foobar/a foobar/b
    $ chmod 600 foobar
    $ /bin/ls foobar
    a b
    $ /bin/ls -l foobar
    total 0
    $ doas rm -rf foobar
    $ mkdir foobar
    $ touch foobar/a foobar/b
    $ chmod 600 foobar
    $ /bin/ls foobar
    a b
    $ /bin/ls -l foobar
    total 0
    
with the same result on a separate shell:

    $ /bin/ls /tmp/foobar
    a b
    $ /bin/ls -l /tmp/foobar
    total 0

and the same result also is observed outside of /tmp, contradicting my
first message.

Nevertheless, I still can reproduce the OPs issue with /bin/ls.

Further testing:

-i comes back empty, -m lists the files, -R lists the files, but
complains about permissions when (I assume) searches for directories to
descend into:

    $ /bin/ls -R /tmp/foobar
    /tmp/foobar:
    a b
    ls: foobar: Permission denied

-- 
 

Reply via email to