Skip to contentSkip to conversation

sepolgen: initialize gen_cil

PATCH In review [email protected] 2 participants 4 messages Aug 1, 2024 – Aug 14, 2024 SELinux security module

lore
Share & tools
lore
#0 lore raw

PATCH 1/2 sepolgen: initialize gen_cil

From: Dmitry Sharshakov <[email protected]>

Avoid errors when adding comments to CIL output like in audit2allow

---
 python/sepolgen/src/sepolgen/refpolicy.py | 1 +
 1 file changed, 1 insertion(+)
python/sepolgen/src/sepolgen/refpolicy.py +1 -0
index 2ec75fba..32278896 100644
@@ -1217,6 +1217,7 @@ class Comment:
             self.lines = l
         else:
             self.lines = []
+        self.gen_cil = False
 
     def to_string(self):
         # If there are no lines, treat this as a spacer between
Signature · 1 line
2.45.2
#1 lore raw

PATCH 2/2 policygen: respect CIL option when generating comments

From: Dmitry Sharshakov <[email protected]>

Make explanatory comments follow the common style of comments (Classic language / CIL)

---
 python/sepolgen/src/sepolgen/policygen.py | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
python/sepolgen/src/sepolgen/policygen.py +3 -1
index 5d59dad7..7715bed5 100644
@@ -179,7 +179,9 @@ class PolicyGenerator:
             rule.rule_type = rule.DONTAUDIT
         rule.comment = ""
         if self.explain:
-            rule.comment = str(refpolicy.Comment(explain_access(av, verbosity=self.explain)))
+            comment = refpolicy.Comment(explain_access(av, verbosity=self.explain))
+            comment.set_gen_cil(self.gen_cil)
+            rule.comment = str(comment)
 
         if av.type == audit2why.ALLOW:
             rule.comment += "\n%s!!!! This avc is allowed in the current policy" % self.comment_start
Signature · 1 line
2.45.2
Acked-by on v1 1/2
#2 lore raw
In reply to [email protected]
Quoted 6 lines · On Thu, Aug 1, 2024 at 3:35 PM <[email protected]> wrote:

From: Dmitry Sharshakov <[email protected]>

Avoid errors when adding comments to CIL output like in audit2allow

For these two patches:

Quoted 20 lines
---
 python/sepolgen/src/sepolgen/refpolicy.py | 1 +
 1 file changed, 1 insertion(+)
python/sepolgen/src/sepolgen/refpolicy.py +1 -1
index 2ec75fba..32278896 100644
@@ -1217,6 +1217,7 @@ class Comment:
             self.lines = l
         else:
             self.lines = []
+        self.gen_cil = False
 
     def to_string(self):
         # If there are no lines, treat this as a spacer between
--

2.45.2

#3 lore raw
Quoted 12 lines · James Carter
Quoted 6 lines · On Thu, Aug 1, 2024 at 3:35 PM <[email protected]> wrote:

From: Dmitry Sharshakov <[email protected]>

Avoid errors when adding comments to CIL output like in audit2allow

For these two patches:

These two patches have been merged.
Thanks,
Jim

Quoted 20 lines
Quoted 20 lines
---
 python/sepolgen/src/sepolgen/refpolicy.py | 1 +
 1 file changed, 1 insertion(+)
python/sepolgen/src/sepolgen/refpolicy.py +1 -1
index 2ec75fba..32278896 100644
@@ -1217,6 +1217,7 @@ class Comment:
             self.lines = l
         else:
             self.lines = []
+        self.gen_cil = False
 
     def to_string(self):
         # If there are no lines, treat this as a spacer between
--

2.45.2