mirror of
https://github.com/SELinuxProject/selinux
synced 2025-03-06 10:17:32 +00:00
CIL's in-statement is resolved before block inheritance. This has the advantage of allowing an in-statement to add rules to a base block (say for a new permission) and having those rules also be added everywhere that base block is inherited. But the disadvantage of this behavior is that it is not possible to use an in-statement on a block that is inherited for the simple reason that that block does not exist when the in-statment is resolved. Change the syntax of the in-statement to allow specifying whether the rules should be added before or after inheritance. If neither is specified, then the behavior remains the same. All current in-statements will work as before. Either the old syntax (in container_id cil_statement ... ) or the new syntax (in before|after container_id cil_statement ... ) may be used for in-statements. But only "(in after ..." will have the new behavior. Using "(in before ..." will give the same behavior as before. Macro Example ; (block b1 (macro m1 ((type ARG1)) (allow ARG1 self (C1 (P1a))) ) ) (in after b1.m1 (allow ARG1 self (C1 (P1c))) ) (type t1a) (call b1.m1 (t1a)) (blockinherit b1) (in after m1 (allow ARG1 self (C1 (P1b))) ) (type t1b) (call m1 (t1b)) ; This results in the following rules: (allow t1a self (C1 (P1a))) (allow t1a self (C1 (P1c))) (allow t1b self (C1 (P1a))) (allow t1b self (C1 (P1b))) Block Example ; (block b2 (block b (type ta) (allow ta self (C2 (P2a))) ) ) (in before b2.b (type tb) (allow tb self (C2 (P2b))) ) (block c2 (blockinherit b2) (in after b (type tc) (allow tc self (C2 (P2c))) ) ) ; This results in the following rules: (allow b2.b.ta self (C2 (P2a))) (allow b2.b.tb self (C2 (P2b))) (allow c2.b.ta self (C2 (P2a))) (allow c2.b.tb self (C2 (P2b))) (allow c2.b.tc self (C2 (P2c))) Using in-statements on optionals also works as expected. One additional change is that blockabstract and blockinherit rules are not allowed when using an after in-statement. This is because both of those are resolved before an after in-statement would be resolved. Signed-off-by: James Carter <jwcart2@gmail.com> |
||
---|---|---|
.. | ||
cil | ||
fuzz | ||
include | ||
man | ||
src | ||
tests | ||
utils | ||
.gitignore | ||
COPYING | ||
Makefile | ||
VERSION |