[docs] [issue9311] os.access can return bogus values when run as superuser

Garrett Cooper report at bugs.python.org
Tue Jul 20 20:26:08 CEST 2010


Garrett Cooper <yanegomi at gmail.com> added the comment:

Well, bash screws up in this dept:

$ ls -l typescript
-rw-r--r--  1 gcooper  gcooper  37875 Jul 12 22:19 typescript
$ sudo sh -c 'test -x typescript; echo $?'
1
$ sudo bash -c 'test -x typescript; echo $?'
0
$ csh
%if (-x typescript) then
if? echo "executable"
if? endif
%

test(1) is a built-in in bash; on FreeBSD/NetBSD(/OpenBSD?) it's a standalone app (which uses eaccess(2)). csh does some tricky code for testing file access in sh.exp.c (see sh_access).

perl does some tricky stuff in pp_sys.c (look for pp_ftrread), where it 
uses eaccess(2) if it's present, else falls back to access(2) to do its bidding. So maybe os.access should use eaccess(2) if it's present on the OS instead of access(2), and note that the item is OS implementation dependent (beware!)?

----------

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue9311>
_______________________________________


More information about the docs mailing list