Skip to contentSkip to conversation

sepolgen: better match refpolicy style in output

PATCH New Karl MacMillan 1 participant 1 message Mar 1, 2007 SELinux security module

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 sepolgen: better match refpolicy style in output

This patch makes the output of sepolgen better match the reference policy by:

* removing the space between target types and object classes (e.g., allow foo bar:file read).
* using self when the source and target match.

sepolgen/src/sepolgen/refpolicy.py +5 -2
diff -r 614125805eda sepolgen/src/sepolgen/refpolicy.py
@@ -427,7 +427,10 @@ class AVRule(Leaf):
         rule.
         """
         self.src_types.add(av.src_type)
-        self.tgt_types.add(av.tgt_type)
+        if av.src_type == av.tgt_type:
+            self.tgt_types.add("self")
+        else:
+            self.tgt_types.add(av.tgt_type)
         self.obj_classes.add(av.obj_class)
         self.perms.update(av.perms)
 
@@ -436,7 +439,7 @@ class AVRule(Leaf):
         that is a valid policy language representation (assuming
         that the types, object class, etc. are valie).
         """
-        return "%s %s %s : %s %s;" % (self.__rule_type_str(),
+        return "%s %s %s:%s %s;" % (self.__rule_type_str(),
                                      self.src_types.to_space_str(),
                                      self.tgt_types.to_space_str(),
                                      self.obj_classes.to_space_str(),

--
This message was distributed to subscribers of the selinux mailing list. If you no longer wish to subscribe, send mail to [email protected] with the words "unsubscribe selinux" without quotes as the message.