mirror of
https://github.com/SELinuxProject/selinux
synced 2025-04-10 03:31:44 +00:00
sepolgen: Make sepolgen-ifgen output deterministic with Python>=3.3
Since Python 3.3, dictionary hashes are randomized and iterating over them is no longer deterministic. This makes it difficult to compare outputs of sepolgen-ifgen command. Make sepolgen-ifgen deterministic again with Python>=3.3 by always sorting the dictonaries and sets which are used to produce output. Signed-off-by: Nicolas Iooss <nicolas.iooss@m4x.org>
This commit is contained in:
parent
033ea27c09
commit
211baf74ef
@ -128,7 +128,7 @@ class AccessVector(util.Comparison):
|
|||||||
is represented in a list.
|
is represented in a list.
|
||||||
"""
|
"""
|
||||||
l = [self.src_type, self.tgt_type, self.obj_class]
|
l = [self.src_type, self.tgt_type, self.obj_class]
|
||||||
l.extend(self.perms)
|
l.extend(sorted(self.perms))
|
||||||
return l
|
return l
|
||||||
|
|
||||||
def __str__(self):
|
def __str__(self):
|
||||||
|
@ -341,12 +341,12 @@ class InterfaceSet:
|
|||||||
self.output.write(str + "\n")
|
self.output.write(str + "\n")
|
||||||
|
|
||||||
def to_file(self, fd):
|
def to_file(self, fd):
|
||||||
for iv in self.interfaces.values():
|
for iv in sorted(self.interfaces.values(), key=lambda x: x.name):
|
||||||
fd.write("[InterfaceVector %s " % iv.name)
|
fd.write("[InterfaceVector %s " % iv.name)
|
||||||
for param in iv.params.values():
|
for param in sorted(iv.params.values(), key=lambda x: x.name):
|
||||||
fd.write("%s:%s " % (param.name, refpolicy.field_to_str[param.type]))
|
fd.write("%s:%s " % (param.name, refpolicy.field_to_str[param.type]))
|
||||||
fd.write("]\n")
|
fd.write("]\n")
|
||||||
avl = iv.access.to_list()
|
avl = sorted(iv.access.to_list())
|
||||||
for av in avl:
|
for av in avl:
|
||||||
fd.write(",".join(av))
|
fd.write(",".join(av))
|
||||||
fd.write("\n")
|
fd.write("\n")
|
||||||
|
@ -251,10 +251,10 @@ class IdSet(set):
|
|||||||
self.compliment = False
|
self.compliment = False
|
||||||
|
|
||||||
def to_space_str(self):
|
def to_space_str(self):
|
||||||
return list_to_space_str(self)
|
return list_to_space_str(sorted(self))
|
||||||
|
|
||||||
def to_comma_str(self):
|
def to_comma_str(self):
|
||||||
return list_to_comma_str(self)
|
return list_to_comma_str(sorted(self))
|
||||||
|
|
||||||
class SecurityContext(Leaf):
|
class SecurityContext(Leaf):
|
||||||
"""An SELinux security context with optional MCS / MLS fields."""
|
"""An SELinux security context with optional MCS / MLS fields."""
|
||||||
|
Loading…
Reference in New Issue
Block a user