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

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