homepage

This issue tracker has been migrated to GitHub , and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

classification
Title: Inconsistent os.access os.X_OK on Solaris and AIX when running as root
Type: behavior Stage:
Components: Versions:
process
Status: closed Resolution: not a bug
Dependencies: Superseder:
Assigned To: Nosy List: adiroiban, pitrou
Priority: normal Keywords:

Created on 2012年05月02日 10:57 by adiroiban, last changed 2022年04月11日 14:57 by admin. This issue is now closed.

Messages (3)
msg159784 - (view) Author: Adi Roiban (adiroiban) Date: 2012年05月02日 10:57
The return value of os.access(FILE, os.X_OK) is not consistent across operating system when executed as "root"
I have tested with Python 2.5 on Linux and Solaris, but there is a bug in python-nose reporting the same behavior with Python 2.6 on Solaris and AIX.
http://code.google.com/p/python-nose/issues/detail?id=423
-------
On Solaris:
$ ls -al 
-rw-rw-r-- 1 buildslave other 1079 May 1 16:25 nose_runner.py
$ ./bin/python 
Python 2.5.6 (r256:88840, Nov 1 2011, 12:19:05) 
[GCC 3.4.3 (csl-sol210-3_4-branch+sol_rpath)] on sunos5
Type "help", "copyright", "credits" or "license" for more information.
>>> import os
>>> os.access('nose_runner.py', os.X_OK)
False
$ sudo ./bin/python 
Python 2.5.6 (r256:88840, Nov 1 2011, 12:19:05) 
[GCC 3.4.3 (csl-sol210-3_4-branch+sol_rpath)] on sunos5
Type "help", "copyright", "credits" or "license" for more information.
>>> import os
>>> os.access('nose_runner.py', os.X_OK)
True
------
On Linux:
$ ls -al 
-rw-rw-r-- 1 adi adi 1079 2012年05月02日 11:25 nose_runner.py
$ ./bin/python 
Python 2.5.5 (r255:77872, Sep 14 2010, 16:22:46) 
[GCC 4.4.5] on linux2
>>> import os
>>> os.access('nose_runner.py', os.X_OK)
False
$ sudo ./bin/python 
Python 2.5.5 (r255:77872, Sep 14 2010, 16:22:46) 
[GCC 4.4.5] on linux2
>>> import os
>>> os.access('nose_runner.py', os.X_OK)
False
msg159787 - (view) Author: Antoine Pitrou (pitrou) * (Python committer) Date: 2012年05月02日 11:36
This is not a Python bug. os.access() is just a wrapper around the POSIX access() function:
http://pubs.opengroup.org/onlinepubs/9699919799/functions/faccessat.html
"If any access permissions are checked, each shall be checked individually, as described in XBD File Access Permissions, except that where that description refers to execute permission for a process with appropriate privileges, an implementation may indicate success for X_OK even if execute permission is not granted to any user."
So this seems to be a well-known portability problem accross Unix implementations. If you want to test the executable bits, just use os.stat().
msg159790 - (view) Author: Adi Roiban (adiroiban) Date: 2012年05月02日 11:53
Many thanks for your comment!
Cheers,
Adi
History
Date User Action Args
2022年04月11日 14:57:29adminsetgithub: 58911
2012年05月02日 11:53:38adiroibansetmessages: + msg159790
2012年05月02日 11:36:10pitrousetstatus: open -> closed

nosy: + pitrou
messages: + msg159787

resolution: not a bug
2012年05月02日 10:57:25adiroibancreate

AltStyle によって変換されたページ (->オリジナル) /