mirror of
https://gitlab.com/apparmor/apparmor
synced 2025-09-03 15:55:46 +00:00
parser: unify capability name handling
There are currently two capability name tables the one that is autogenerated and an internal hardcoded name table. Now that the autogenerated table has been converted to a base static table we can drop the internal static table. This removes the chance of getting the tables getting out of sync. Signed-off-by: John Johansen <john.johansen@canonical.com>
This commit is contained in:
@@ -63,7 +63,7 @@ int is_blacklisted(const char *name, const char *path)
|
||||
|
||||
struct keyword_table {
|
||||
const char *keyword;
|
||||
int token;
|
||||
unsigned int token;
|
||||
};
|
||||
|
||||
static struct keyword_table keyword_table[] = {
|
||||
@@ -840,52 +840,16 @@ void debug_cod_entries(struct cod_entry *list)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
static const char *capnames[] = {
|
||||
"chown",
|
||||
"dac_override",
|
||||
"dac_read_search",
|
||||
"fowner",
|
||||
"fsetid",
|
||||
"kill",
|
||||
"setgid",
|
||||
"setuid",
|
||||
"setpcap",
|
||||
"linux_immutable",
|
||||
"net_bind_service",
|
||||
"net_broadcast",
|
||||
"net_admin",
|
||||
"net_raw",
|
||||
"ipc_lock",
|
||||
"ipc_owner",
|
||||
"sys_module",
|
||||
"sys_rawio",
|
||||
"sys_chroot",
|
||||
"sys_ptrace",
|
||||
"sys_pacct",
|
||||
"sys_admin",
|
||||
"sys_boot",
|
||||
"sys_nice",
|
||||
"sys_resource",
|
||||
"sys_time",
|
||||
"sys_tty_config",
|
||||
"mknod",
|
||||
"lease",
|
||||
"audit_write",
|
||||
"audit_control",
|
||||
"setfcap",
|
||||
"mac_override",
|
||||
"syslog",
|
||||
};
|
||||
|
||||
const char *capability_to_name(unsigned int cap)
|
||||
{
|
||||
const char *capname;
|
||||
int i;
|
||||
|
||||
capname = (cap < (sizeof(capnames) / sizeof(char *))
|
||||
? capnames[cap] : "invalid-capability");
|
||||
for (i = 0; capability_table[i].keyword; i++) {
|
||||
if (capability_table[i].token == cap)
|
||||
return capability_table[i].keyword;
|
||||
}
|
||||
|
||||
return capname;
|
||||
return "invalid-capability";
|
||||
}
|
||||
|
||||
void __debug_capabilities(uint64_t capset, const char *name)
|
||||
@@ -893,10 +857,10 @@ void __debug_capabilities(uint64_t capset, const char *name)
|
||||
unsigned int i;
|
||||
|
||||
printf("%s:", name);
|
||||
for (i = 0; i < (sizeof(capnames)/sizeof(char *)); i++) {
|
||||
if (((1ull << i) & capset) != 0) {
|
||||
printf (" %s", capability_to_name(i));
|
||||
}
|
||||
|
||||
for (i = 0; capability_table[i].keyword; i++) {
|
||||
if ((1ull << capability_table[i].token) & capset)
|
||||
printf (" %s", capability_table[i].keyword);
|
||||
}
|
||||
printf("\n");
|
||||
}
|
||||
|
Reference in New Issue
Block a user