mirror of
https://gitlab.com/apparmor/apparmor
synced 2025-08-22 10:07:12 +00:00
parser: Honor the --namespace-string commandline option
https://launchpad.net/bugs/1526085 Revno 2934 'Add fns to handle profile removal to the kernel interface' introduced a regression in the parser's namespace support by causing the --namespace-string option to be ignored. This resulted in the profile(s) being loaded into the global namespace rather than the namespace specified on the command line. This patch fixes the bug by setting the Profile object's ns member, if the --namespace-string option was specified, immediately after the Profile object is allocated. Signed-off-by: Tyler Hicks <tyhicks@canonical.com> Acked-by: Seth Arnold <seth.arnold@canonical.com>
This commit is contained in:
parent
e51ad3c632
commit
67eb25939d
@ -318,6 +318,13 @@ profile_base: TOK_ID opt_id_or_var flags TOK_OPEN rules TOK_CLOSE
|
|||||||
yyerror(_("Memory allocation error."));
|
yyerror(_("Memory allocation error."));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Honor the --namespace-string command line option */
|
||||||
|
if (profile_ns) {
|
||||||
|
prof->ns = strdup(profile_ns);
|
||||||
|
if (!prof->ns)
|
||||||
|
yyerror(_("Memory allocation error."));
|
||||||
|
}
|
||||||
|
|
||||||
prof->name = $1;
|
prof->name = $1;
|
||||||
prof->attachment = $2;
|
prof->attachment = $2;
|
||||||
if ($2 && !($2[0] == '/' || strncmp($2, "@{", 2) == 0))
|
if ($2 && !($2[0] == '/' || strncmp($2, "@{", 2) == 0))
|
||||||
@ -351,12 +358,17 @@ profile: opt_profile_flag opt_ns profile_base
|
|||||||
if ($3->name[0] != '/' && !($1 || $2))
|
if ($3->name[0] != '/' && !($1 || $2))
|
||||||
yyerror(_("Profile names must begin with a '/', namespace or keyword 'profile' or 'hat'."));
|
yyerror(_("Profile names must begin with a '/', namespace or keyword 'profile' or 'hat'."));
|
||||||
|
|
||||||
if ($2 && profile_ns) {
|
if (prof->ns) {
|
||||||
pwarn("%s: -n %s overriding policy specified namespace :%s:\n", progname, profile_ns, $2);
|
/**
|
||||||
|
* Print warning if the profile specified a namespace
|
||||||
|
* different than the one specified with the
|
||||||
|
* --namespace-string command line option
|
||||||
|
*/
|
||||||
|
if ($2 && strcmp(prof->ns, $2)) {
|
||||||
|
pwarn("%s: -n %s overriding policy specified namespace :%s:\n",
|
||||||
|
progname, prof->ns, $2);
|
||||||
|
}
|
||||||
free($2);
|
free($2);
|
||||||
prof->ns = strdup(profile_ns);
|
|
||||||
if (!prof->ns)
|
|
||||||
yyerror(_("Memory allocation error."));
|
|
||||||
} else
|
} else
|
||||||
prof->ns = $2;
|
prof->ns = $2;
|
||||||
if ($1 == 2)
|
if ($1 == 2)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user