RHEL Engineering is moving the tracking of its product development work on RHEL 6 through RHEL 9 to Red Hat Jira (issues.redhat.com). If you're a Red Hat customer, please continue to file support cases via the Red Hat customer portal. If you're not, please head to the "RHEL project" in Red Hat Jira and file new tickets here. Individual Bugzilla bugs in the statuses "NEW", "ASSIGNED", and "POST" are being migrated throughout September 2023. Bugs of Red Hat partners with an assigned Engineering Partner Manager (EPM) are migrated in late September as per pre-agreed dates. Bugs against components "kernel", "kernel-rt", and "kpatch" are only migrated if still in "NEW" or "ASSIGNED". If you cannot log in to RH Jira, please consult article #7032570. That failing, please send an e-mail to the RH Jira admins at rh-issues@redhat.com to troubleshoot your issue as a user management inquiry. The email creates a ServiceNow ticket with Red Hat. Individual Bugzilla bugs that are migrated will be moved to status "CLOSED", resolution "MIGRATED", and set with "MigratedToJIRA" in "Keywords". The link to the successor Jira issue will be found under "Links", have a little "two-footprint" icon next to it, and direct you to the "RHEL project" in Red Hat Jira (issue links are of type "https://issues.redhat.com/browse/RHEL-XXXX", where "X" is a digit). This same link will be available in a blue banner at the top of the page informing you that that bug has been migrated.
Bug 698583 - restorecon from libselinux-python fails on relative paths
Summary: restorecon from libselinux-python fails on relative paths
Keywords:
Status: CLOSED ERRATA
Alias: None
Product: Red Hat Enterprise Linux 6
Classification: Red Hat
Component: libselinux
Version: 6.1
Hardware: All
OS: Linux
medium
medium
Target Milestone: rc
: ---
Assignee: Daniel Walsh
QA Contact: Milos Malik
URL:
Whiteboard:
Depends On: 695760
Blocks:
TreeView+ depends on / blocked
 
Reported: 2011-04-21 10:06 UTC by Milos Malik
Modified: 2017-01-06 14:50 UTC (History)
4 users (show)

Fixed In Version: libselinux-2.0.94-5.1.el6
Doc Type: Bug Fix
Doc Text:
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.
Clone Of: 695760
Environment:
Last Closed: 2011-12-06 10:02:16 UTC
Target Upstream Version:
Embargoed:


Attachments (Terms of Use)


Links
System ID Private Priority Status Summary Last Updated
Red Hat Product Errata RHBA-2011:1559 0 normal SHIPPED_LIVE libselinux bug fix update 2011-12-06 00:39:20 UTC

Description Milos Malik 2011-04-21 10:06:47 UTC
+++ 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

Comment 1 Milos Malik 2011-04-21 10:13:12 UTC
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

Comment 2 Daniel Walsh 2011-05-25 17:24:24 UTC
Fixed in libselinux-2.0.94-5.1.el6

Comment 7 Milos Malik 2011-07-29 13:25:05 UTC
# 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.

Comment 9 Jaromir Hradilek 2011-10-26 15:12:55 UTC
    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.

Comment 10 errata-xmlrpc 2011-12-06 10:02:16 UTC
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


Note You need to log in before you can comment on or make changes to this bug.