Signed-off-by: John Johansen <john.johan...@canonical.com> --- parser/parser_lex.l | 46 ++++++++++++++++++++-------------------------- parser/parser_misc.c | 2 -- parser/parser_yacc.y | 27 ++++++++++++--------------- 3 files changed, 32 insertions(+), 43 deletions(-)
diff --git a/parser/parser_lex.l b/parser/parser_lex.l index a246d9f..52f207e 100644 --- a/parser/parser_lex.l +++ b/parser/parser_lex.l @@ -185,12 +185,14 @@ ID {ID_CHARS}|(,{ID_CHARS}) IDS {ID}+ POST_VAR_ID_CHARS [^ \t\n"!,]{-}[=\+] POST_VAR_ID {POST_VAR_ID_CHARS}|(,{POST_VAR_ID_CHARS}) - +LIST_VALUE_ID_CHARS [^ \t\n"!,]{-}[()] +LIST_VALUE_ID {LIST_VALUE_ID_CHARS}+ ALLOWED_QUOTED_ID [^\0"]|\\\" QUOTED_ID \"{ALLOWED_QUOTED_ID}*\" IP {NUMBER}\.{NUMBER}\.{NUMBER}\.{NUMBER} +FLAGS flags{WS}*=?{WS}* HAT hat{WS}* PROFILE profile{WS}* KEYWORD [[:alpha:]_]+ @@ -204,7 +206,7 @@ QPATHNAME \"(\/|{SET_VAR_PREFIX})([^\0"]|\\\")*\" OPEN_PAREN \( CLOSE_PAREN \) -FLAGSEP \, +COMMA \, EQUALS = ADD_ASSIGN \+= ARROW -> @@ -212,7 +214,7 @@ LT_EQUAL <= %x SUB_NAME %x NETWORK_MODE -%x FLAGS_MODE +%x LIST_VAL_MODE %x ASSIGN_MODE %x RLIMIT_MODE %x CHANGE_PROFILE_MODE @@ -274,37 +276,27 @@ LT_EQUAL <= } } -<FLAGS_MODE>{ - {OPEN_PAREN} { - DUMP_PREPROCESS; - PDEBUG("FLag (\n"); - return TOK_OPENPAREN; - } +<LIST_VAL_MODE>{ {CLOSE_PAREN} { DUMP_PREPROCESS; - PDEBUG("Flag )\n"); + PDEBUG("listval: )\n"); yy_pop_state(); return TOK_CLOSEPAREN; } {WS}+ { DUMP_PREPROCESS; /* Eat whitespace */ } - {FLAGSEP} { + {COMMA} { DUMP_PREPROCESS; - PDEBUG("Flag , \n"); - return TOK_FLAG_SEP; + PDEBUG("listval: , \n"); + /* East comma, its an optional separator */ } - {EQUALS} { + ({LIST_VALUE_ID}|{QUOTED_ID}) { DUMP_PREPROCESS; - PDEBUG("Flag = \n"); - return TOK_EQUALS; - } - {KEYWORD} { - DUMP_PREPROCESS; - yylval.flag_id = strdup(yytext); - PDEBUG("Found flag: \"%s\"\n", yylval.flag_id); - return TOK_FLAG_ID; + yylval.id = processid(yytext, yyleng); + PDEBUG("listval: \"%s\"\n", yylval.id); + return TOK_VALUE; } [^\n] { @@ -514,6 +506,11 @@ LT_EQUAL <= return TOK_MODE; } +{FLAGS} { + DUMP_PREPROCESS; + return TOK_FLAGS; + } + {HAT} { DUMP_PREPROCESS; yy_push_state(SUB_NAME); @@ -535,7 +532,7 @@ LT_EQUAL <= {OPEN_PAREN} { DUMP_PREPROCESS; PDEBUG("FLag (\n"); - yy_push_state(FLAGS_MODE); + yy_push_state(LIST_VAL_MODE); return TOK_OPENPAREN; } @@ -551,9 +548,6 @@ LT_EQUAL <= PDEBUG("Found (var) id: \"%s\"\n", yylval.id); return TOK_ID; break; - case TOK_FLAGS: - yy_push_state(FLAGS_MODE); - break; case TOK_RLIMIT: yy_push_state(RLIMIT_MODE); break; diff --git a/parser/parser_misc.c b/parser/parser_misc.c index 64030ab..ebaa887 100644 --- a/parser/parser_misc.c +++ b/parser/parser_misc.c @@ -54,8 +54,6 @@ struct keyword_table { }; static struct keyword_table keyword_table[] = { - /* flags */ - {"flags", TOK_FLAGS}, /* network */ {"network", TOK_NETWORK}, /* misc keywords */ diff --git a/parser/parser_yacc.y b/parser/parser_yacc.y index 1b169f0..4e68321 100644 --- a/parser/parser_yacc.y +++ b/parser/parser_yacc.y @@ -112,6 +112,7 @@ void add_local_entry(struct codomain *cod); %token TOK_PTRACE %token TOK_OPENPAREN %token TOK_CLOSEPAREN +%token TOK_COMMA /* rlimits */ %token TOK_RLIMIT @@ -138,8 +139,6 @@ void add_local_entry(struct codomain *cod); /* debug flag values */ %token TOK_FLAGS -%token TOK_FLAG_SEP -%token TOK_FLAG_ID %union { char *id; @@ -176,7 +175,6 @@ void add_local_entry(struct codomain *cod); %type <flags> flags %type <flags> flagvals %type <flags> flagval -%type <flag_id> TOK_FLAG_ID %type <cap> caps %type <cap> capability %type <cap> set_caps @@ -191,6 +189,7 @@ void add_local_entry(struct codomain *cod); %type <boolean> opt_audit_flag %type <boolean> opt_owner_flag %type <boolean> opt_profile_flag +%type <boolean> opt_flags %type <id> opt_namespace %type <id> opt_id %type <transition> opt_named_transition @@ -397,21 +396,19 @@ flags: { /* nothing */ $$ = fv; }; -flags: TOK_FLAGS TOK_EQUALS TOK_OPENPAREN flagvals TOK_CLOSEPAREN - { - $$ = $4; - }; +opt_flags: { /* nothing */ $$ = 0; } + | TOK_FLAGS { $$ = 1; } -flags: TOK_OPENPAREN flagvals TOK_CLOSEPAREN +flags: opt_flags TOK_OPENPAREN flagvals TOK_CLOSEPAREN { - $$ = $2; - } + $$ = $3; + }; -flagvals: flagvals TOK_FLAG_SEP flagval +flagvals: flagvals flagval { - $1.complain = $1.complain || $3.complain; - $1.audit = $1.audit || $3.audit; - $1.path = $1.path | $3.path; + $1.complain = $1.complain || $2.complain; + $1.audit = $1.audit || $2.audit; + $1.path = $1.path | $2.path; if (($1.path & (PATH_CHROOT_REL | PATH_NS_REL)) == (PATH_CHROOT_REL | PATH_NS_REL)) yyerror(_("Profile flag chroot_relative conflicts with namespace_relative")); @@ -434,7 +431,7 @@ flagvals: flagval $$ = $1; }; -flagval: TOK_FLAG_ID +flagval: TOK_VALUE { struct flagval fv = { 0, 0, 0, 0 }; if (strcmp($1, "debug") == 0) { -- 1.7.9 -- AppArmor mailing list AppArmor@lists.ubuntu.com Modify settings or unsubscribe at: https://lists.ubuntu.com/mailman/listinfo/apparmor