Currently, mount rule preprocessor output is incorrect:

$ echo '/t { mount options=ro /s -> /d, }' | apparmor_parser -p
/t { mountmount =ro /s -> /d, }
$ echo '/t { mount options in (ro) /s -> /d, }' | apparmor_parser -p
/t { mountmount  in (ro) /s -> /d, }

This is due to incorrect placement of DUMP_PREPROCESS in parser_lex.l.
With this patch, the output is correct:

$ echo '/t { mount options=ro /s -> /d, }' | apparmor_parser -p
/t { mount options=ro /s -> /d, }
$ echo '/t { mount options in (ro) /s -> /d, }' | apparmor_parser -p
/t { mount options in (ro) /s -> /d,

Signed-off-by: Tyler Hicks <[email protected]>
---

* Changes since v2:
  - Add DUMP_PREPROCESS to second MOUNT_MODE branch
  - Simplify examples in commit message to avoid line wrapping
  - Add examples to the commit message showing the usage of the second
    MOUNT_MODE branch

 parser/parser_lex.l | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/parser/parser_lex.l b/parser/parser_lex.l
index 1258b01..539e16a 100644
--- a/parser/parser_lex.l
+++ b/parser/parser_lex.l
@@ -286,6 +286,7 @@ LT_EQUAL    <=
                                 * as bison may have requested the next
                                 * token from the scanner
                                 */
+                               DUMP_PREPROCESS;
                                PDEBUG("conditional %s=\n", yytext);
                                yylval.id = processid(yytext, yyleng);
                                yy_push_state(EXTCOND_MODE);
@@ -298,6 +299,7 @@ LT_EQUAL    <=
                                 * as bison may have requested the next
                                 * token from the scanner
                                 */
+                               DUMP_PREPROCESS;
                                PDEBUG("conditional %s=\n", yytext);
                                yylval.id = processid(yytext, yyleng);
                                yy_push_state(EXTCOND_MODE);
@@ -704,7 +706,6 @@ LT_EQUAL    <=
                        case TOK_MOUNT:
                        case TOK_REMOUNT:
                        case TOK_UMOUNT:
-                               DUMP_PREPROCESS;
                                PDEBUG("Entering mount\n");
                                yy_push_state(MOUNT_MODE);
                                break;
-- 
1.8.1.2


-- 
AppArmor mailing list
[email protected]
Modify settings or unsubscribe at: 
https://lists.ubuntu.com/mailman/listinfo/apparmor

Reply via email to