[ python-Bugs-1117601 ] os.path.exists returns false negatives in MAC environments.

SourceForge.net noreply at sourceforge.net
Wed Feb 16 23:46:56 CET 2005


Bugs item #1117601, was opened at 2005-02-07 00:57
Message generated for change (Comment added) made by sbennett
You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=105470&aid=1117601&group_id=5470

Category: Python Library
Group: Platform-specific
Status: Open
Resolution: None
Priority: 5
Submitted By: Stephen Bennett (sbennett)
Assigned to: Nobody/Anonymous (nobody)
Summary: os.path.exists returns false negatives in MAC environments.

Initial Comment:
In Mandatory Access Control environments (such as
SELinux), it's quite possible for stat to fail with
permission denied. In this case, os.path.exists will
return False incorrectly. The simple(ish) fix is to
check for an access denied error (which would indicate
present, but not readable) when using stat to check for
existence of files.

----------------------------------------------------------------------

>Comment By: Stephen Bennett (sbennett)
Date: 2005-02-16 22:46

Message:
Logged In: YES 
user_id=817465

As far as I know (at least for SELinux), permission denied
on stat() always means that the file exists, but getattr
isn't allowed. As for a reproducible test case, probably the
simplest example is a vanilla Fedora Core 3 system with
SELinux enabled and strict policy. From a regular user
account, call os.path.exists("/etc/shadow"). It will return
False even though the file exists. For comparison, an `ls -l
/etc/shadow` from the command line will simply print
'Permission Denied'.

----------------------------------------------------------------------

Comment By: Terry J. Reedy (tjreedy)
Date: 2005-02-16 20:26

Message:
Logged In: YES 
user_id=593130

Does 'access denied' always mean 'present but not readable' 
in every environment that gives such messages?  I ask 
because I have vague memories of wasting time trying to 
get access to something that did not exist, because access 
denied (or something like that) meant that I was denied 
access even to info about whether it existed or not.

In any case, a reproducible example would help someone to 
verify, fix, and write a test case for this if it is deemed to be 
a fixable bug.

----------------------------------------------------------------------

You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=105470&aid=1117601&group_id=5470


More information about the Python-bugs-list mailing list