Bug 1309868 - sepolicy generate broken in rawhide.
Summary: sepolicy generate broken in rawhide.
Keywords:
Status: CLOSED ERRATA
Alias: None
Product: Fedora
Classification: Fedora
Component: policycoreutils
Version: rawhide
Hardware: Unspecified
OS: Unspecified
unspecified
unspecified
Target Milestone: ---
Assignee: Petr Lautrbach
QA Contact: Fedora Extras Quality Assurance
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2016-02-18 20:44 UTC by Daniel Walsh
Modified: 2016-02-26 20:54 UTC (History)
8 users (show)

Fixed In Version: policycoreutils-2.4-20.fc23
Doc Type: Bug Fix
Doc Text:
Clone Of:
Environment:
Last Closed: 2016-02-23 19:21:49 UTC


Attachments (Terms of Use)

Description Daniel Walsh 2016-02-18 20:44:14 UTC
# 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 21:08:38 UTC
Note: /usr/bin/rkt needs to be installed to reproduce this issue.

Comment 2 Miroslav Grepl 2016-02-19 11:16:59 UTC
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 10:58:24 UTC
Is that available for python3?

Comment 4 Petr Lautrbach 2016-02-21 11:46:35 UTC
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 13:31:09 UTC
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-22 04:21:34 UTC
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 22:11:02 UTC
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 09:04:10 UTC
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 19:21:41 UTC
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 20:54:40 UTC
SGTM Petr, nice work.


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