mirror of
https://gitlab.com/apparmor/apparmor
synced 2025-08-22 10:07:12 +00:00
parser: Clean up pivot_root target parsing
Instead of reusing opt_named_transition and be forced to reconstruct the target path when is looks like ":odd:target", create simpler grammer rules that have nothing to do with named transitions and namespaces. Signed-off-by: Tyler Hicks <tyhicks@canonical.com> Acked-by: John Johansen <john.johansen@canonical.com>
This commit is contained in:
parent
885cd1f7b8
commit
4ae6ad03ba
@ -276,6 +276,7 @@ void add_local_entry(Profile *prof);
|
|||||||
%type <fmode> net_perms
|
%type <fmode> net_perms
|
||||||
%type <fmode> opt_net_perm
|
%type <fmode> opt_net_perm
|
||||||
%type <unix_entry> unix_rule
|
%type <unix_entry> unix_rule
|
||||||
|
%type <id> opt_target
|
||||||
%type <transition> opt_named_transition
|
%type <transition> opt_named_transition
|
||||||
%type <boolean> opt_unsafe
|
%type <boolean> opt_unsafe
|
||||||
%type <boolean> opt_file
|
%type <boolean> opt_file
|
||||||
@ -1044,6 +1045,9 @@ expr: TOK_DEFINED TOK_BOOL_VAR
|
|||||||
id_or_var: TOK_ID { $$ = $1; }
|
id_or_var: TOK_ID { $$ = $1; }
|
||||||
id_or_var: TOK_SET_VAR { $$ = $1; };
|
id_or_var: TOK_SET_VAR { $$ = $1; };
|
||||||
|
|
||||||
|
opt_target: /* nothing */ { $$ = NULL; }
|
||||||
|
opt_target: TOK_ARROW id_or_var { $$ = $2; };
|
||||||
|
|
||||||
opt_named_transition:
|
opt_named_transition:
|
||||||
{ /* nothing */
|
{ /* nothing */
|
||||||
parse_named_transition_target(&$$, NULL);
|
parse_named_transition_target(&$$, NULL);
|
||||||
@ -1242,23 +1246,9 @@ mnt_rule: TOK_UMOUNT opt_conds opt_id TOK_END_OF_RULE
|
|||||||
$$ = do_mnt_rule($2, NULL, NULL, $3, AA_MAY_UMOUNT);
|
$$ = do_mnt_rule($2, NULL, NULL, $3, AA_MAY_UMOUNT);
|
||||||
}
|
}
|
||||||
|
|
||||||
mnt_rule: TOK_PIVOTROOT opt_conds opt_id opt_named_transition TOK_END_OF_RULE
|
mnt_rule: TOK_PIVOTROOT opt_conds opt_id opt_target TOK_END_OF_RULE
|
||||||
{
|
{
|
||||||
char *name = NULL;
|
$$ = do_pivot_rule($2, $3, $4);
|
||||||
if ($4.present && $4.ns) {
|
|
||||||
name = (char *) malloc(strlen($4.ns) +
|
|
||||||
strlen($4.name) + 3);
|
|
||||||
if (!name) {
|
|
||||||
PERROR("Memory allocation error\n");
|
|
||||||
exit(1);
|
|
||||||
}
|
|
||||||
sprintf(name, ":%s:%s", $4.ns, $4.name);
|
|
||||||
free($4.ns);
|
|
||||||
free($4.name);
|
|
||||||
} else if ($4.present)
|
|
||||||
name = $4.name;
|
|
||||||
|
|
||||||
$$ = do_pivot_rule($2, $3, name);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
dbus_perm: TOK_VALUE
|
dbus_perm: TOK_VALUE
|
||||||
|
Loading…
x
Reference in New Issue
Block a user