Commit 171acca8 authored by Pavel Emelyanov's avatar Pavel Emelyanov Committed by Andrei Vagin

lsm: Make get_type() switch-able call

This is to remove the function pointer and have only "type"
variable left.
Signed-off-by: 's avatarPavel Emelyanov <xemul@virtuozzo.com>
Signed-off-by: 's avatarAndrei Vagin <avagin@virtuozzo.com>
parent 09c131c8
......@@ -20,7 +20,6 @@
#endif
static Lsmtype lsmtype;
static int (*get_label)(pid_t, char **) = NULL;
static int apparmor_get_label(pid_t pid, char **profile_name)
{
......@@ -109,7 +108,6 @@ static int selinux_get_label(pid_t pid, char **output)
void kerndat_lsm(void)
{
if (access(AA_SECURITYFS_PATH, F_OK) == 0) {
get_label = apparmor_get_label;
lsmtype = LSMTYPE__APPARMOR;
return;
}
......@@ -121,13 +119,11 @@ void kerndat_lsm(void)
* well.
*/
if (access("/sys/fs/selinux", F_OK) == 0) {
get_label = selinux_get_label;
lsmtype = LSMTYPE__SELINUX;
return;
}
#endif
get_label = NULL;
lsmtype = LSMTYPE__NO_LSM;
}
......@@ -138,18 +134,32 @@ Lsmtype host_lsm_type(void)
int collect_lsm_profile(pid_t pid, CredsEntry *ce)
{
ce->lsm_profile = NULL;
int ret;
if (lsmtype == LSMTYPE__NO_LSM)
return 0;
ce->lsm_profile = NULL;
if (get_label(pid, &ce->lsm_profile) < 0)
return -1;
switch (lsmtype) {
case LSMTYPE__NO_LSM:
ret = 0;
break;
case LSMTYPE__APPARMOR:
ret = apparmor_get_label(pid, &ce->lsm_profile);
break;
#ifdef CONFIG_HAS_SELINUX
case LSMTYPE__SELINUX:
ret = selinux_get_label(pid, &ce->lsm_profile);
break;
#endif
default:
BUG();
ret = -1;
break;
}
if (ce->lsm_profile)
pr_info("%d has lsm profile %s\n", pid, ce->lsm_profile);
return 0;
return ret;
}
// in inventory.c
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment