Bug 1195004

Summary: libselinux-python3 calls os.path.walk
Product: [Fedora] Fedora Reporter: Miro Hrončok <mhroncok>
Component: libselinuxAssignee: Daniel Walsh <dwalsh>
Status: CLOSED ERRATA QA Contact: Fedora Extras Quality Assurance <extras-qa>
Severity: unspecified Docs Contact:
Priority: unspecified    
Version: rawhideCC: dwalsh, mgrepl, plautrba
Target Milestone: ---   
Target Release: ---   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: libselinux-2.3-9.fc21 Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2015-04-28 13:10:09 UTC Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:
Bug Depends On:    
Bug Blocks: 1024357    
Attachments:
Description Flags
Patch to fix this, so it works on both Pythons none

Description Miro Hrončok 2015-02-21 22:02:36 UTC
Description of problem:
There is a Python 3 not compatible code in libselinux-python3

Version-Release number of selected component (if applicable):
libselinux-python3-2.3-5.fc21.x86_64
libselinux-python3-2.3-6.fc22

How reproducible:
Always


Actual results:
When running that part of code, exception occurs:

    File "/usr/lib64/python3.4/site-packages/selinux/__init__.py", line 95, in restorecon
    os.path.walk(path, lambda arg, dirname, fnames:
    AttributeError: 'module' object has no attribute 'walk'

Expected results:
 Should use os.walk on Python 3.

Additional info:
In here: https://github.com/SELinuxProject/selinux/blob/master/libselinux/src/selinuxswig_python.i#L34

Comment 1 Miro Hrončok 2015-02-21 22:37:08 UTC
Should be replaced by https://docs.python.org/2/library/os.html#os.walk

Comment 2 Miro Hrončok 2015-02-21 22:49:05 UTC
If I understand the call correctly, it could be replaced by:

        if recursive:
            for root, dirs, files in os.walk(path):
                for fname in files + dirs:
                   restorecon(os.path.join(root,fname))

Comment 3 Miro Hrončok 2015-02-21 23:40:34 UTC
Here is a scratch build with proposed fix.

http://koji.fedoraproject.org/koji/taskinfo?taskID=9020684

Comment 4 Miro Hrončok 2015-02-22 21:35:54 UTC
Created attachment 994296 [details]
Patch to fix this, so it works on both Pythons

Comment 6 Fedora Update System 2015-04-23 09:20:39 UTC
libselinux-2.3-9.fc22 has been submitted as an update for Fedora 22.
https://admin.fedoraproject.org/updates/libselinux-2.3-9.fc22

Comment 7 Fedora Update System 2015-04-23 09:21:44 UTC
libselinux-2.3-9.fc21 has been submitted as an update for Fedora 21.
https://admin.fedoraproject.org/updates/libselinux-2.3-9.fc21

Comment 8 Fedora Update System 2015-04-24 22:47:36 UTC
Package libselinux-2.3-9.fc21:
* should fix your issue,
* was pushed to the Fedora 21 testing repository,
* should be available at your local mirror within two days.
Update it with:
# su -c 'yum update --enablerepo=updates-testing libselinux-2.3-9.fc21'
as soon as you are able to.
Please go to the following url:
https://admin.fedoraproject.org/updates/FEDORA-2015-6771/libselinux-2.3-9.fc21
then log in and leave karma (feedback).

Comment 9 Fedora Update System 2015-04-28 13:10:09 UTC
libselinux-2.3-9.fc22 has been pushed to the Fedora 22 stable repository.  If problems still persist, please make note of it in this bug report.

Comment 10 Fedora Update System 2015-05-10 23:59:27 UTC
libselinux-2.3-9.fc21 has been pushed to the Fedora 21 stable repository.  If problems still persist, please make note of it in this bug report.