mirror of
https://gitlab.com/apparmor/apparmor.git
synced 2025-03-04 08:24:42 +01:00
Fix aliases so that aliases are applied to the profile name as well as
the entries Add rewrite as an alternative alias keyword
This commit is contained in:
parent
5a2b875b81
commit
3850ede5cf
4 changed files with 32 additions and 7 deletions
|
@ -260,7 +260,7 @@ extern void dump_expanded_symtab(void);
|
|||
|
||||
/* parser_alias.c */
|
||||
extern int new_alias(const char *from, const char *to);
|
||||
extern void replace_aliases(void *list);
|
||||
extern void replace_aliases(struct codomain *cod);
|
||||
extern void free_aliases(void);
|
||||
|
||||
/* parser_merge.c */
|
||||
|
|
|
@ -114,7 +114,6 @@ static char *do_alias(struct alias_rule *alias, const char *target)
|
|||
}
|
||||
|
||||
static struct cod_entry *target_list;
|
||||
|
||||
static void process_entries(const void *nodep, VISIT value, int __unused level)
|
||||
{
|
||||
struct alias_rule **t = (struct alias_rule **) nodep;
|
||||
|
@ -147,10 +146,36 @@ static void process_entries(const void *nodep, VISIT value, int __unused level)
|
|||
}
|
||||
}
|
||||
|
||||
void replace_aliases(void *list)
|
||||
static struct codomain *target_cod;
|
||||
static void process_name(const void *nodep, VISIT value, int __unused level)
|
||||
{
|
||||
target_list = list;
|
||||
twalk(alias_table, process_entries);
|
||||
struct alias_rule **t = (struct alias_rule **) nodep;
|
||||
struct codomain *cod = target_cod;
|
||||
int len;
|
||||
|
||||
if (value == preorder || value == endorder)
|
||||
return;
|
||||
|
||||
len = strlen((*t)->from);
|
||||
|
||||
if (cod->name && strncmp((*t)->from, cod->name, len) == 0) {
|
||||
char *new = do_alias(*t, cod->name);
|
||||
if (!new)
|
||||
return;
|
||||
free(cod->name);
|
||||
cod->name = new;
|
||||
}
|
||||
}
|
||||
|
||||
void replace_aliases(struct codomain *cod)
|
||||
{
|
||||
target_cod = cod;
|
||||
twalk(alias_table, process_name);
|
||||
|
||||
if (cod->entries) {
|
||||
target_list = cod->entries;
|
||||
twalk(alias_table, process_entries);
|
||||
}
|
||||
}
|
||||
|
||||
static void free_alias(void *nodep)
|
||||
|
|
|
@ -71,6 +71,7 @@ static struct keyword_table keyword_table[] = {
|
|||
{"set", TOK_SET},
|
||||
{"rlimit", TOK_RLIMIT},
|
||||
{"alias", TOK_ALIAS},
|
||||
{"rewrite", TOK_ALIAS},
|
||||
{"ptrace", TOK_PTRACE},
|
||||
/* terminate */
|
||||
{NULL, 0}
|
||||
|
|
|
@ -328,8 +328,7 @@ static void __process_alias(const void *nodep, const VISIT value,
|
|||
if (value == preorder || value == endorder)
|
||||
return;
|
||||
|
||||
if ((*t)->entries)
|
||||
replace_aliases((*t)->entries);
|
||||
replace_aliases((*t));
|
||||
|
||||
if ((*t)->hat_table)
|
||||
twalk((*t)->hat_table, __process_alias);
|
||||
|
|
Loading…
Add table
Reference in a new issue