Blame SOURCES/0002-Make-seinfo-output-predictable.patch

30936f
From 4e6f6c95cfe7ca4a3a9d9e0dbd6e23e4bac2449c Mon Sep 17 00:00:00 2001
30936f
From: Petr Lautrbach <plautrba@redhat.com>
30936f
Date: Thu, 18 Nov 2021 13:59:08 +0100
30936f
Subject: [PATCH] Make seinfo output predictable
30936f
30936f
There are few places where frozenset is used. Given that frozenset is an unordered
30936f
collection the output generated from this is unpredictable.
30936f
30936f
The following command outputs are fixed using sorted() on frozensets:
30936f
30936f
    seinfo --constrain
30936f
    seinfo --common
30936f
    seinfo -c -x
30936f
    seinfo -r -x
30936f
    seinfo -u -x
30936f
30936f
Fixes: https://github.com/SELinuxProject/setools/issues/65
30936f
30936f
Signed-off-by: Petr Lautrbach <plautrba@redhat.com>
30936f
---
30936f
 setools/policyrep/constraint.pxi | 2 +-
30936f
 setools/policyrep/objclass.pxi   | 4 ++--
30936f
 setools/policyrep/role.pxi       | 2 +-
30936f
 setools/policyrep/user.pxi       | 2 +-
30936f
 4 files changed, 5 insertions(+), 5 deletions(-)
30936f
30936f
diff --git a/setools/policyrep/constraint.pxi b/setools/policyrep/constraint.pxi
30936f
index d5221a1..77c3e2e 100644
30936f
--- a/setools/policyrep/constraint.pxi
30936f
+++ b/setools/policyrep/constraint.pxi
30936f
@@ -66,7 +66,7 @@ cdef class Constraint(BaseConstraint):
30936f
 
30936f
     def statement(self):
30936f
         if len(self.perms) > 1:
30936f
-            perms = "{{ {0} }}".format(' '.join(self.perms))
30936f
+            perms = "{{ {0} }}".format(' '.join(sorted(self.perms)))
30936f
         else:
30936f
             # convert to list since sets cannot be indexed
30936f
             perms = list(self.perms)[0]
30936f
diff --git a/setools/policyrep/objclass.pxi b/setools/policyrep/objclass.pxi
30936f
index b7ec7b7..8ed2be5 100644
30936f
--- a/setools/policyrep/objclass.pxi
30936f
+++ b/setools/policyrep/objclass.pxi
30936f
@@ -75,7 +75,7 @@ cdef class Common(PolicySymbol):
30936f
         return other in self.perms
30936f
 
30936f
     def statement(self):
30936f
-        return "common {0}\n{{\n\t{1}\n}}".format(self, '\n\t'.join(self.perms))
30936f
+        return "common {0}\n{{\n\t{1}\n}}".format(self, '\n\t'.join(sorted(self.perms)))
30936f
 
30936f
 
30936f
 cdef class ObjClass(PolicySymbol):
30936f
@@ -204,7 +204,7 @@ cdef class ObjClass(PolicySymbol):
30936f
 
30936f
         # a class that inherits may not have additional permissions
30936f
         if len(self.perms) > 0:
30936f
-            stmt += "{{\n\t{0}\n}}".format('\n\t'.join(self.perms))
30936f
+            stmt += "{{\n\t{0}\n}}".format('\n\t'.join(sorted(self.perms)))
30936f
 
30936f
         return stmt
30936f
 
30936f
diff --git a/setools/policyrep/role.pxi b/setools/policyrep/role.pxi
30936f
index 9a0dd39..3af8a3f 100644
30936f
--- a/setools/policyrep/role.pxi
30936f
+++ b/setools/policyrep/role.pxi
30936f
@@ -58,7 +58,7 @@ cdef class Role(PolicySymbol):
30936f
         if count == 1:
30936f
             stmt += " types {0}".format(types[0])
30936f
         else:
30936f
-            stmt += " types {{ {0} }}".format(' '.join(types))
30936f
+            stmt += " types {{ {0} }}".format(' '.join(sorted(types)))
30936f
 
30936f
         stmt += ";"
30936f
         return stmt
30936f
diff --git a/setools/policyrep/user.pxi b/setools/policyrep/user.pxi
30936f
index 9c82aa9..e37af29 100644
30936f
--- a/setools/policyrep/user.pxi
30936f
+++ b/setools/policyrep/user.pxi
30936f
@@ -81,7 +81,7 @@ cdef class User(PolicySymbol):
30936f
         if count == 1:
30936f
             stmt += roles[0]
30936f
         else:
30936f
-            stmt += "{{ {0} }}".format(' '.join(roles))
30936f
+            stmt += "{{ {0} }}".format(' '.join(sorted(roles)))
30936f
 
30936f
         if self._level:
30936f
             stmt += " level {0.mls_level} range {0.mls_range};".format(self)
30936f
-- 
30936f
2.30.2
30936f