Bug 1309868 - sepolicy generate broken in rawhide.
sepolicy generate broken in rawhide.
Status: CLOSED ERRATA
Product: Fedora
Classification: Fedora
Component: policycoreutils (Show other bugs)
rawhide
Unspecified Unspecified
unspecified Severity unspecified
: ---
: ---
Assigned To: Petr Lautrbach
Fedora Extras Quality Assurance
:
Depends On:
Blocks:
  Show dependency treegraph
 
Reported: 2016-02-18 15:44 EST by Daniel Walsh
Modified: 2016-02-26 15:54 EST (History)
8 users (show)

See Also:
Fixed In Version: policycoreutils-2.4-20.fc23
Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of:
Environment:
Last Closed: 2016-02-23 14:21:49 EST
Type: Bug
Regression: ---
Mount Type: ---
Documentation: ---
CRM:
Verified Versions:
Category: ---
oVirt Team: ---
RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: ---


Attachments (Terms of Use)

  None (edit)
Description Daniel Walsh 2016-02-18 15:44:14 EST
# sepolicy generate --init /usr/bin/rkt 
Traceback (most recent call last):
  File "/bin/sepolicy", line 650, in <module>
    args.func(args)
  File "/bin/sepolicy", line 519, in generate
    mypolicy.gen_writeable()
  File "/usr/lib64/python3.5/site-packages/sepolicy/generate.py", line 1309, in gen_writeable
    self.__extract_rpms()
  File "/usr/lib64/python3.5/site-packages/sepolicy/generate.py", line 1281, in __extract_rpms
    pkg_basename = dnf.rpm.miscutils.splitFilename(pkg.sourcerpm)[0]
AttributeError: module 'dnf.rpm.miscutils' has no attribute 'splitFilename'
Comment 1 Petr Lautrbach 2016-02-18 16:08:38 EST
Note: /usr/bin/rkt needs to be installed to reproduce this issue.
Comment 2 Miroslav Grepl 2016-02-19 06:16:59 EST
Using

pkg_basename = rpmUtils.miscutils.splitFilename(pkg.sourcerpm)[0]

helps me to generate a new policy. Just a quick fix. I am not sure if there is a solution with dnf module.
Comment 3 Daniel Walsh 2016-02-20 05:58:24 EST
Is that available for python3?
Comment 4 Petr Lautrbach 2016-02-21 06:46:35 EST
We don't need to use dnf, the following patch fixes it for the moment:

--- /usr/lib64/python3.4/site-packages/sepolicy/generate.py.orig        2016-02-21 12:44:42.871125419 +0100
+++ /usr/lib64/python3.4/site-packages/sepolicy/generate.py     2016-02-21 12:45:06.238043729 +0100
@@ -1278,7 +1278,7 @@
                             else:
                                 self.add_dir(fname)
 
-                pkg_basename = dnf.rpm.miscutils.splitFilename(pkg.sourcerpm)[0]
+                pkg_basename = '-'.join(pkg.sourcerpm.split('-')[0:-2])
                 for bpkg in installed.filter(name=pkg_basena
Comment 6 Fedora Update System 2016-02-21 08:31:09 EST
policycoreutils-2.4-20.fc23 has been submitted as an update to Fedora 23. https://bodhi.fedoraproject.org/updates/FEDORA-2016-a7b86cd38e
Comment 7 Fedora Update System 2016-02-21 23:21:34 EST
policycoreutils-2.4-20.fc23 has been pushed to the Fedora 23 testing repository. If problems still persist, please make note of it in this bug report.
See https://fedoraproject.org/wiki/QA:Updates_Testing for
instructions on how to install test updates.
You can provide feedback for this update here: https://bodhi.fedoraproject.org/updates/FEDORA-2016-a7b86cd38e
Comment 8 Daniel Walsh 2016-02-22 17:11:02 EST
While this works it might hit some corner cases where a package name includes -1

But most likely this is fine.
Comment 9 Petr Lautrbach 2016-02-23 04:04:10 EST
I don't think there's a valid case it doesn't work. Package id consists of <name>-<version>-<release> and '-' is an illegal char in <version> and <release>:

error: line 9: Illegal char '-' (0x2d) in: Version: 2.5.-1
error: line 10: Illegal char '-' (0x2d) in: Release: 0.1.rc1.fc23.-1

$ python
>>> '-'.join("selinux-policy-targeted-3.13.1-158.7.fc23.noarch".split('-')[0:-2])
'selinux-policy-targeted'
Comment 10 Fedora Update System 2016-02-23 14:21:41 EST
policycoreutils-2.4-20.fc23 has been pushed to the Fedora 23 stable repository. If problems still persist, please make note of it in this bug report.
Comment 11 Daniel Walsh 2016-02-26 15:54:40 EST
SGTM Petr, nice work.

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