On Sat, Jun 6, 2020 at 9:38 AM Ethan Gardener <[email protected]> wrote:
>
> On Fri, Jun 5, 2020, at 8:22 PM, Richard Miller wrote:
> > Looks to me like access(2) is not doing the right thing for directory
> > execute (=search) permission.
>
> thanks for the tip. access is a very simple function. it doesn't do the right 
> thing, but there's a reason:
>
>      BUGS
>           Since file permissions are checked by the server and group
>           information is not known to the client, access must open the
>           file to check permissions.  (It calls stat(2) to check sim-
>           ple existence.)
>
> 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.
>

In sysopen, there is a call to namec:
/sys/src/9/port/sysfile.c:272
c = namec((char*)arg[0], Aopen, arg[1], 0);

Namec would return an error when called to open a directory with
execute permissions:
/sys/src/9/port/chan.c:1453,1454
if(amode == Aopen && (omode&3) == OEXEC && (c->qid.type&QTDIR))
        error("cannot exec directory");

But I'm not sure if this is where the problem actually is, as I haven't seen
the 'cannot exec directory' message when running 'test -x dir' in
acid:

cpu% test -x ch7
cpu% echo $status
test 528: false

cpu% acid -l truss /bin/test
/bin/test:386 plan 9 executable
/sys/lib/acid/port
/sys/lib/acid/386
/sys/lib/acid/truss
acid: progargs = "-x ch7"
acid: new()
acid: truss()
open("ch7", 3)
return value: -1
open("#c/pid", 0)
return value: 3
pread(3, 0xdfffef08, 20, 4294967295)
return value: 12
data: "        533 "
close(3)
return value: 0
533: breakpoint _exits+0x5 INTB $0x40

------------------------------------------
9fans: 9fans
Permalink: 
https://9fans.topicbox.com/groups/9fans/Tdd7a9b1b32d01f54-Mb30227ca46f50cf45e98546c
Delivery options: https://9fans.topicbox.com/groups/9fans/subscription

Reply via email to