mirror of
https://gitlab.com/apparmor/apparmor
synced 2025-08-22 18:17:09 +00:00
Rework the definition of ID and POST_VAR_ID to use a define for the charset
ID and POST_VAR_ID define a set of characters that is reused, pull this out to avoid making mistakes when updating the character set. Signed-off-by: John Johansen <john.johansen@canonical.com> Acked-by: Kees Cook <kees@ubuntu.com>
This commit is contained in:
parent
e7c550243c
commit
ac6c7dd37f
@ -179,12 +179,18 @@ MODE_CHARS ([RrWwaLlMmkXx])|(([Pp]|[Cc])[Xx])|(([Pp]|[Cc])?([IiUu])[Xx])
|
|||||||
MODES {MODE_CHARS}+
|
MODES {MODE_CHARS}+
|
||||||
WS [[:blank:]]
|
WS [[:blank:]]
|
||||||
NUMBER [[:digit:]]+
|
NUMBER [[:digit:]]+
|
||||||
ID [^ \t\n"!,]|(,[^ \t\n"!])
|
|
||||||
POST_VAR_ID [^ =\+\t\n"!,]|(,[^ =\+\t\n"!])
|
ID_CHARS [^ \t\n"!,]
|
||||||
IP {NUMBER}\.{NUMBER}\.{NUMBER}\.{NUMBER}
|
ID {ID_CHARS}|(,{ID_CHARS})
|
||||||
|
IDS {ID}+
|
||||||
|
POST_VAR_ID_CHARS [^ \t\n"!,]{-}[=\+]
|
||||||
|
POST_VAR_ID {POST_VAR_ID_CHARS}|(,{POST_VAR_ID_CHARS})
|
||||||
|
|
||||||
ALLOWED_QUOTED_ID [^\0"]|\\\"
|
ALLOWED_QUOTED_ID [^\0"]|\\\"
|
||||||
QUOTED_ID \"{ALLOWED_QUOTED_ID}*\"
|
QUOTED_ID \"{ALLOWED_QUOTED_ID}*\"
|
||||||
|
|
||||||
|
IP {NUMBER}\.{NUMBER}\.{NUMBER}\.{NUMBER}
|
||||||
|
|
||||||
HAT hat{WS}*
|
HAT hat{WS}*
|
||||||
PROFILE profile{WS}*
|
PROFILE profile{WS}*
|
||||||
KEYWORD [[:alpha:]_]+
|
KEYWORD [[:alpha:]_]+
|
||||||
@ -246,9 +252,9 @@ LT_EQUAL <=
|
|||||||
}
|
}
|
||||||
|
|
||||||
<SUB_NAME>{
|
<SUB_NAME>{
|
||||||
({ID}+|{QUOTED_ID}) {
|
({IDS}|{QUOTED_ID}) {
|
||||||
/* Ugh, this is a gross hack. I used to use
|
/* Ugh, this is a gross hack. I used to use
|
||||||
* {ID}+ to match all TOK_IDs, but that would
|
* {IDS} to match all TOK_IDs, but that would
|
||||||
* also match TOK_MODE + TOK_END_OF_RULE
|
* also match TOK_MODE + TOK_END_OF_RULE
|
||||||
* without any spaces in between (because it's
|
* without any spaces in between (because it's
|
||||||
* a longer match). So now, when I want to
|
* a longer match). So now, when I want to
|
||||||
@ -311,7 +317,7 @@ LT_EQUAL <=
|
|||||||
<ASSIGN_MODE>{
|
<ASSIGN_MODE>{
|
||||||
{WS}+ { DUMP_PREPROCESS; /* Eat whitespace */ }
|
{WS}+ { DUMP_PREPROCESS; /* Eat whitespace */ }
|
||||||
|
|
||||||
({ID}+|{QUOTED_ID}) {
|
({IDS}|{QUOTED_ID}) {
|
||||||
DUMP_PREPROCESS;
|
DUMP_PREPROCESS;
|
||||||
yylval.var_val = processid(yytext, yyleng);
|
yylval.var_val = processid(yytext, yyleng);
|
||||||
PDEBUG("Found assignment value: \"%s\"\n", yylval.var_val);
|
PDEBUG("Found assignment value: \"%s\"\n", yylval.var_val);
|
||||||
@ -341,7 +347,7 @@ LT_EQUAL <=
|
|||||||
<NETWORK_MODE>{
|
<NETWORK_MODE>{
|
||||||
{WS}+ { DUMP_PREPROCESS; /* Eat whitespace */ }
|
{WS}+ { DUMP_PREPROCESS; /* Eat whitespace */ }
|
||||||
|
|
||||||
{ID}+ {
|
{IDS} {
|
||||||
DUMP_PREPROCESS;
|
DUMP_PREPROCESS;
|
||||||
yylval.id = strdup(yytext);
|
yylval.id = strdup(yytext);
|
||||||
return TOK_ID;
|
return TOK_ID;
|
||||||
@ -371,9 +377,9 @@ LT_EQUAL <=
|
|||||||
return TOK_ARROW;
|
return TOK_ARROW;
|
||||||
}
|
}
|
||||||
|
|
||||||
({ID}+|{QUOTED_ID}) {
|
({IDS}|{QUOTED_ID}) {
|
||||||
/* Ugh, this is a gross hack. I used to use
|
/* Ugh, this is a gross hack. I used to use
|
||||||
* {ID}+ to match all TOK_IDs, but that would
|
* {IDS} to match all TOK_IDs, but that would
|
||||||
* also match TOK_MODE + TOK_END_OF_RULE
|
* also match TOK_MODE + TOK_END_OF_RULE
|
||||||
* without any spaces in between (because it's
|
* without any spaces in between (because it's
|
||||||
* a longer match). So now, when I want to
|
* a longer match). So now, when I want to
|
||||||
|
Loading…
x
Reference in New Issue
Block a user