Note: This bug is displayed in read-only format because
the product is no longer active in Red Hat Bugzilla.
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.
Description of problem:
"seinfo --constrain" doesn't produce the same output when the command is executed multiple times:
# seinfo --constrain > 1
# seinfo --constrain > 2
# diff -q 1 2
Files 1 and 2 differ
# rpm -qf $(which seinfo)
setools-console-4.3.0-2.el8.x86_64
#
Since the output is different every time, it's not easily usable for searching for differences in SELinux policies.
Version-Release number of selected component (if applicable):
setools-console-4.3.0-2.el8
How reproducible:
Always
Steps to Reproduce:
1. run "seinfo --constrain" several time and compare the outputs
Actual results:
Outputs differ.
Expected results:
Outputs are the same every time (unless the constraints really change).
Not only the list of constraints is affected:
# seinfo -c service -x > 1.txt
# seinfo -c service -x > 2.txt
# diff 1.txt 2.txt
7d6
< status
9d7
< stop
10a9,10
> status
> stop
#
The problem is that setools uses frozenset() internally which is an unordered collection, see this:
sh-5.1$ python3 -c 's = ("1","2","3","4","5"); print(",".join(frozenset(s)));'
5,3,1,2,4
sh-5.1$ python3 -c 's = ("1","2","3","4","5"); print(",".join(frozenset(s)));'
4,2,3,1,5
sh-5.1$ python3 -c 's = ("1","2","3","4","5"); print(",".join(frozenset(s)));'
4,3,5,1,2
The following path would fix the problem for `seinfo -c service -c`:
diff --git a/setools/policyrep/objclass.pxi b/setools/policyrep/objclass.pxi
index b7ec7b7de5c3..5ee751b7b2b4 100644
--- a/setools/policyrep/objclass.pxi
+++ b/setools/policyrep/objclass.pxi
@@ -204,7 +204,7 @@ cdef class ObjClass(PolicySymbol):
# a class that inherits may not have additional permissions
if len(self.perms) > 0:
- stmt += "{{\n\t{0}\n}}".format('\n\t'.join(self.perms))
+ stmt += "{{\n\t{0}\n}}".format('\n\t'.join(sorted(self.perms)))
return stmt
I'm not sure about the performance impact. Lets report this upstream
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 (setools bug fix and enhancement update), and where to find the updated
files, follow the link below.
If the solution does not work for you, open a new bug report.
https://access.redhat.com/errata/RHBA-2022:2079