9fans - fans of the OS Plan 9 from Bell Labs
 help / color / mirror / Atom feed
From: "Ethan Gardener" <eekee57@fastmail.fm>
To: ori <ori@eigenstate.org>, "g_patrickb via 9fans" <9fans@9fans.net>
Subject: Re: [9fans] `test -x` returns wrong results for directories
Date: Sun, 07 Jun 2020 15:48:33 +0100	[thread overview]
Message-ID: <309c60a4-29cb-4789-ae18-9388bd8b60b3@www.fastmail.com> (raw)
In-Reply-To: <58181689FAB504813F509082A0F70248@eigenstate.org>

On Sat, Jun 6, 2020, at 10:13 PM, ori@eigenstate.org wrote:
> > it's open() which is failing. i suppose it should.
> > 
> > if the open fails, maybe access should stat the file, and if it's a
> > directory, try dirread(2). or maybe just opening it for reading will
> > work. i don't know, i'm new to this bit of plan 9 & i haven't slept.
> 
> This is a bit subtle, though -- if you want
> to check if *you* can traverse the directory,
> then simply checking for an execute bit isn't
> enough -- you need to check that you belong to
> a group that has the execute bit.
> 
> On a related note, execute permission seems
> to behave strangely in general. You can create
> a directory and list it:
> 
> 
> Even without execute permission it's listable.
> Makes sense.

sarcasm? i've been confused about search permission since my earliest linux use where i experimented with permissions to see what, exactly, they did. it made no sense then, even without plan 9 leaving permission checks up to the individual filesystems. (this would have been linux 2.0.0)

> 
> 	cpu% mkdir -p d/a/b
> 	cpu% touch d/x
> 	cpu% chmod -x d
> 	cpu% ls -ld d
> 	d-rw-r--r-- M 81 ori ori 0 Jun  5 07:53 d
> 	cpu% ls d
> 	d/a
> 	d/x
> 
> As expected, it can't be traversed:
> 
> 	cpu% ls d/x
> 	ls: d/x: 'd/x' does not exist
> 
> But, you can cd into it:
> 
> 	cpu% cd d
> 
> And list '.':
> 
> 	cpu% ls
> 	a
> 	x
> 	cpu% ls .
> 	a
> 	x
> 
> Can't traverse it to list subdirectories,
> though:
> 
> 	ls a
> 	ls: a: 'a' access permission denied
> 	cd a
> 	Can't cd a: 'a' access permission denied
> 	cpu% cd ..
> 	Can't cd ..: '..' access permission denied
> 
> So, cd'ing into a directory withut +x leads
> to an inescapabler trap.
> 
> Perhaps 'cd' should prevent entering that
> directory.

thanks for your analysis too, although you didn't say what filesystem you're using. i had to laugh at that trap; doesn't software get ridiculous sometimes? but it made me think, because charles said fossil doesn't handle the execute bit properly. perhaps once plan 9 went open source & had a public contrib, someone made just such a trap in contrib and fossil's permission handling was changed to stop it happening again. regardless of the cause, fossil just moved up another notch in my estimation because directory search restriction is so broken.

i just checked linux 2.6.30. (old vm i had handy.) it's much like you describe except there is no trap. cd is indeed prevented and if you're in the directory when "search" permission is revoked, you can't list it but you can `cd ..`.

"search" is exactly the wrong word for what this bit does, because if you don't have "search" permission, the one thing you can still do is look at the names... which lets you search them! it's more like "permission to open the display case and touch the things inside" or "permission to step over the museum's rope barriers".

  reply	other threads:[~2020-06-07 14:48 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-06-05 12:45 Ethan Gardener
2020-06-05 19:22 ` [9fans] " Richard Miller
2020-06-06  6:36   ` Ethan Gardener
2020-06-06 12:11     ` Alexander Kapshuk
2020-06-06 13:25     ` Charles Forsyth
2020-06-07 13:56       ` Ethan Gardener
2020-06-06 21:13     ` ori
2020-06-07 14:48       ` Ethan Gardener [this message]
2020-06-07 15:41         ` Richard Miller
2020-06-08  2:04           ` ori
2020-06-08  2:13             ` Charles Forsyth
2020-06-08  2:20               ` Charles Forsyth
2020-06-09 10:50               ` Ethan Gardener

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=309c60a4-29cb-4789-ae18-9388bd8b60b3@www.fastmail.com \
    --to=eekee57@fastmail.fm \
    --cc=9fans@9fans.net \
    --cc=ori@eigenstate.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).