Hide Forgot
+++ This bug was initially created as a clone of Bug #695760 +++ Created attachment 491521 [details] python test case Description of problem: restorecon from libselinux-python fails on relative paths. Version-Release number of selected component (if applicable): libselinux-2.0.94-5.el6 libselinux-python-2.0.94-5 libselinux-utils-2.0.94-5 How reproducible: Always Steps to Reproduce: 1. run the attached reproducer 2. 3. Actual results: Traceback (most recent call last): File "/tmp/s.py", line 11, in <module> selinux.restorecon(path, True) File "/usr/lib64/python2.7/site-packages/selinux/__init__.py", line 74, in restorecon status, context = matchpathcon(path, mode) OSError: [Errno 2] No such file or directory Expected results: restored context
I forgot to update the "Actual results" section. # python s.py Traceback (most recent call last): File "s.py", line 11, in <module> selinux.restorecon(path, True) File "/usr/lib/python2.6/site-packages/selinux/__init__.py", line 74, in restorecon status, context = matchpathcon(path, mode) OSError: [Errno 2] No such file or directory # echo $? 1
Fixed in libselinux-2.0.94-5.1.el6
# matchpathcon /mnt/testarea/tests/libselinux/Regression/bz698583-relative-paths/ /mnt/testarea/tests/libselinux/Regression/bz698583-relative-paths <<none>> # OK, I will modify the automated test.
Technical note added. If any revisions are required, please edit the "Technical Notes" field accordingly. All revisions will be proofread by the Engineering Content Services team. New Contents: Prior to this update, Python bindings for the restorecon command required a user to specify the entire path. Consequent to this, an attempt to use the selinux.restorecon() function with a relative path failed with the following error message: OSError: [Errno 2] No such file or directory This update corrects the Python bindings to allow the use of the selinux.restorecon() function with a relative path or just a file name.
Since the problem described in this bug report should be resolved in a recent advisory, it has been closed with a resolution of ERRATA. For information on the advisory, and where to find the updated files, follow the link below. If the solution does not work for you, open a new bug report. http://rhn.redhat.com/errata/RHBA-2011-1559.html