mirror of
https://gitlab.com/apparmor/apparmor.git
synced 2025-03-06 09:21:00 +01: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
51a0d5d863
commit
cfbc1a2a79
1 changed files with 17 additions and 5 deletions
|
@ -318,6 +318,13 @@ profile_base: TOK_ID opt_id_or_var flags TOK_OPEN rules TOK_CLOSE
|
|||
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->attachment = $2;
|
||||
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))
|
||||
yyerror(_("Profile names must begin with a '/', namespace or keyword 'profile' or 'hat'."));
|
||||
|
||||
if ($2 && profile_ns) {
|
||||
pwarn("%s: -n %s overriding policy specified namespace :%s:\n", progname, profile_ns, $2);
|
||||
if (prof->ns) {
|
||||
/**
|
||||
* 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);
|
||||
prof->ns = strdup(profile_ns);
|
||||
if (!prof->ns)
|
||||
yyerror(_("Memory allocation error."));
|
||||
} else
|
||||
prof->ns = $2;
|
||||
if ($1 == 2)
|
||||
|
|
Loading…
Add table
Reference in a new issue