Bug 1392154

Summary: semodule -l lost policy versioning listing
Product: Red Hat Enterprise Linux 7 Reporter: Andrea Veri <andrea.veri>
Component: policycoreutilsAssignee: Petr Lautrbach <plautrba>
Status: CLOSED DUPLICATE QA Contact: BaseOS QE Security Team <qe-baseos-security>
Severity: medium Docs Contact:
Priority: high    
Version: 7.3CC: aperotti, christian.kaenzig, dwalsh, lvrabec, mgrepl, mmalik, plautrba, sreber, ssekidde
Target Milestone: rc   
Target Release: ---   
Hardware: All   
OS: Linux   
Whiteboard:
Fixed In Version: Doc Type: If docs needed, set a value
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2016-11-11 09:39:35 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: 1391886    

Description Andrea Veri 2016-11-05 11:38:28 UTC
Description of problem:

semodule -l is not showing up policy modules versions anymore as it was used to do since the time I recall about using the semodule command:

With RHEL 7.3 this fails:

semodule -l | head -n 5
abrt
accountsd
acct
afs
aiccu

With RHEL 6 or RHEL 7.2 it works as expected:

semodule -l | head -n 5
abrt	1.2.0	
accountsd	1.0.0	
ada	1.4.0	
afs	1.5.3	
aiccu	1.0.0

Version-Release number of selected component (if applicable):
policycoreutils-2.5-8.el7.x86_64

How reproducible:
Always

Steps to Reproduce:
1. Run semodule -l

Actual results:

semodule -l | head -n 5
abrt
accountsd
acct
afs
aiccu

Expected results:

semodule -l | head -n 5
abrt	1.2.0	
accountsd	1.0.0	
ada	1.4.0	
afs	1.5.3	
aiccu	1.0.0

Additional info:

Comment 2 Christian Kaenzig 2016-11-08 07:52:05 UTC
Hello, this bug also affects RHEL 7.2 when the policycoreutils package is upgraded to 2.5-8.

I opened as support case with Red Hat, here is the answer I got:

---
The new SELinux userspace uses SELinux Common Intermediate Language (CIL) in the module store. CIL treats files as modules and does not have a separate module statement, the module is named after the file name. 

Unfortunately CIL doesn't support policy_module() statement. It means that modules don't have versions anymore. Now we have namespaces for policy rules. So all the current rules are in the global namespace and we don't identify them using policy modules as before.
---

I don't currently understand what this means exactly as I lack knowledge about how selinux modules work exactly.

Comment 4 Petr Lautrbach 2016-11-10 22:41:12 UTC
SELinux userspace 2.4 and higher uses CIL and CIL doesn't have any component which would represent a module name or version. Therefore a module name is derived from a filename and a version completely dropped from semodule output.

However, original .pp files are stored together with cil files as hll files. It means that a version could be extracted from that file.

I prepared a patch and srpms [1] with libsemanage patched to look to try to extract a version from hll files if an original module was installed from .pp file. And semodule patched to accept another list option - legacy - which tries to provide same output as pre-2.4 releases, e.g.:

# semodule -l | tail -n 3    
zarafa
zebra
zoneminder

# semodule -lfull | tail -n 3
100 zebra             pp         
100 zoneminder        cil         
100 zosremote         pp disabled

# semodule -llegacy | tail -n 3
zebra   1.13.0
zoneminder      (null)
zosremote       1.2.0   Disabled



(null) at zoneminder means that the module was not installed from .pp file and there's no version available.


[1] https://plautrba.fedorapeople.org/copr/selinux-semodule-llegacy/

Comment 6 Petr Lautrbach 2016-11-11 09:39:35 UTC
Let's move the discussion to one place.

*** This bug has been marked as a duplicate of bug 1392573 ***