mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
synced 2025-01-18 02:46:06 +00:00
apparmor: Convert to use match_string() helper
The new helper returns index of the matching string in an array. We are going to use it here. Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com> Reviewed-by: Jay Freyensee <why2jjj.linux@gmail.com> Signed-off-by: John Johansen <john.johansen@canonical.com>
This commit is contained in:
parent
38125c2c2b
commit
5d8779a5cd
@ -1391,14 +1391,12 @@ static int param_set_audit(const char *val, const struct kernel_param *kp)
|
|||||||
if (apparmor_initialized && !policy_admin_capable(NULL))
|
if (apparmor_initialized && !policy_admin_capable(NULL))
|
||||||
return -EPERM;
|
return -EPERM;
|
||||||
|
|
||||||
for (i = 0; i < AUDIT_MAX_INDEX; i++) {
|
i = match_string(audit_mode_names, AUDIT_MAX_INDEX, val);
|
||||||
if (strcmp(val, audit_mode_names[i]) == 0) {
|
if (i < 0)
|
||||||
aa_g_audit = i;
|
return -EINVAL;
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return -EINVAL;
|
aa_g_audit = i;
|
||||||
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int param_get_mode(char *buffer, const struct kernel_param *kp)
|
static int param_get_mode(char *buffer, const struct kernel_param *kp)
|
||||||
@ -1422,14 +1420,13 @@ static int param_set_mode(const char *val, const struct kernel_param *kp)
|
|||||||
if (apparmor_initialized && !policy_admin_capable(NULL))
|
if (apparmor_initialized && !policy_admin_capable(NULL))
|
||||||
return -EPERM;
|
return -EPERM;
|
||||||
|
|
||||||
for (i = 0; i < APPARMOR_MODE_NAMES_MAX_INDEX; i++) {
|
i = match_string(aa_profile_mode_names, APPARMOR_MODE_NAMES_MAX_INDEX,
|
||||||
if (strcmp(val, aa_profile_mode_names[i]) == 0) {
|
val);
|
||||||
aa_g_profile_mode = i;
|
if (i < 0)
|
||||||
return 0;
|
return -EINVAL;
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return -EINVAL;
|
aa_g_profile_mode = i;
|
||||||
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
Loading…
x
Reference in New Issue
Block a user