Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 5d8779a5 authored by Andy Shevchenko's avatar Andy Shevchenko Committed by John Johansen
Browse files

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: default avatarAndy Shevchenko <andriy.shevchenko@linux.intel.com>
Reviewed-by: default avatarJay Freyensee <why2jjj.linux@gmail.com>
Signed-off-by: default avatarJohn Johansen <john.johansen@canonical.com>
parent 38125c2c
Loading
Loading
Loading
Loading
+11 −14
Original line number Diff line number Diff line
@@ -1391,15 +1391,13 @@ static int param_set_audit(const char *val, const struct kernel_param *kp)
	if (apparmor_initialized && !policy_admin_capable(NULL))
		return -EPERM;

	for (i = 0; i < AUDIT_MAX_INDEX; i++) {
		if (strcmp(val, audit_mode_names[i]) == 0) {
	i = match_string(audit_mode_names, AUDIT_MAX_INDEX, val);
	if (i < 0)
		return -EINVAL;

	aa_g_audit = i;
	return 0;
}
	}

	return -EINVAL;
}

static int param_get_mode(char *buffer, const struct kernel_param *kp)
{
@@ -1422,15 +1420,14 @@ static int param_set_mode(const char *val, const struct kernel_param *kp)
	if (apparmor_initialized && !policy_admin_capable(NULL))
		return -EPERM;

	for (i = 0; i < APPARMOR_MODE_NAMES_MAX_INDEX; i++) {
		if (strcmp(val, aa_profile_mode_names[i]) == 0) {
	i = match_string(aa_profile_mode_names, APPARMOR_MODE_NAMES_MAX_INDEX,
			 val);
	if (i < 0)
		return -EINVAL;

	aa_g_profile_mode = i;
	return 0;
}
	}

	return -EINVAL;
}

/*
 * AppArmor init functions