mirror of
https://gitlab.com/apparmor/apparmor.git
synced 2025-03-04 08:24:42 +01:00
Convert FLAGS_MODE start condition to a generic list of values start cond
Signed-off-by: John Johansen <john.johansen@canonical.com> jj@ortho:~/apparmor/aa-test/parser$ guilt header Convert FLAGS_MODE start condition to a generic list of values start cond Signed-off-by: John Johansen <john.johansen@canonical.com> Acked-by: Kees Cook <kees@ubuntu.com>
This commit is contained in:
parent
ac6c7dd37f
commit
eabeb4f7b3
3 changed files with 33 additions and 44 deletions
|
@ -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);
|
||||
|
@ -534,8 +531,8 @@ LT_EQUAL <=
|
|||
|
||||
{OPEN_PAREN} {
|
||||
DUMP_PREPROCESS;
|
||||
PDEBUG("FLag (\n");
|
||||
yy_push_state(FLAGS_MODE);
|
||||
PDEBUG("listval (\n");
|
||||
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;
|
||||
|
|
|
@ -54,8 +54,6 @@ struct keyword_table {
|
|||
};
|
||||
|
||||
static struct keyword_table keyword_table[] = {
|
||||
/* flags */
|
||||
{"flags", TOK_FLAGS},
|
||||
/* network */
|
||||
{"network", TOK_NETWORK},
|
||||
/* misc keywords */
|
||||
|
|
|
@ -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
|
||||
opt_flags: { /* nothing */ $$ = 0; }
|
||||
| TOK_FLAGS { $$ = 1; }
|
||||
|
||||
flags: opt_flags TOK_OPENPAREN flagvals TOK_CLOSEPAREN
|
||||
{
|
||||
$$ = $4;
|
||||
$$ = $3;
|
||||
};
|
||||
|
||||
flags: TOK_OPENPAREN flagvals TOK_CLOSEPAREN
|
||||
flagvals: flagvals flagval
|
||||
{
|
||||
$$ = $2;
|
||||
}
|
||||
|
||||
flagvals: flagvals TOK_FLAG_SEP 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) {
|
||||
|
|
Loading…
Add table
Reference in a new issue