Fix a few whitespace issues.

This commit is contained in:
Todd C. Miller
2022-07-09 11:21:17 -06:00
parent e7b7fbaf6e
commit a2b0a8330c
11 changed files with 58 additions and 56 deletions

View File

@@ -597,7 +597,7 @@ print_cmndspec_csv(FILE *fp, struct sudoers_parse_tree *parse_tree,
|| cs->role != next->role || cs->type != next->type || cs->role != next->role || cs->type != next->type
#endif /* HAVE_SELINUX */ #endif /* HAVE_SELINUX */
#ifdef HAVE_APPARMOR #ifdef HAVE_APPARMOR
|| cs->apparmor_profile != next->apparmor_profile || cs->apparmor_profile != next->apparmor_profile
#endif /* HAVE_APPARMOR */ #endif /* HAVE_APPARMOR */
|| cs->runchroot != next->runchroot || cs->runcwd != next->runcwd; || cs->runchroot != next->runchroot || cs->runcwd != next->runcwd;

View File

@@ -759,13 +759,13 @@ print_cmndspec_json(struct json_container *jsonc,
#endif /* HAVE_SELINUX */ #endif /* HAVE_SELINUX */
#ifdef HAVE_APPARMOR #ifdef HAVE_APPARMOR
if (cs->apparmor_profile != NULL) { if (cs->apparmor_profile != NULL) {
sudo_json_open_array(jsonc, "AppArmor_Spec"); sudo_json_open_array(jsonc, "AppArmor_Spec");
value.type = JSON_STRING; value.type = JSON_STRING;
value.u.string = cs->apparmor_profile; value.u.string = cs->apparmor_profile;
sudo_json_add_value(jsonc, "apparmor_profile", &value); sudo_json_add_value(jsonc, "apparmor_profile", &value);
sudo_json_close_array(jsonc); sudo_json_close_array(jsonc);
} }
#endif /* HAVE_APPARMOR */ #endif /* HAVE_APPARMOR */
#ifdef HAVE_PRIV_SET #ifdef HAVE_PRIV_SET

View File

@@ -461,15 +461,15 @@ print_cmndspec_ldif(FILE *fp, struct sudoers_parse_tree *parse_tree,
#endif /* HAVE_SELINUX */ #endif /* HAVE_SELINUX */
#ifdef HAVE_APPARMOR #ifdef HAVE_APPARMOR
/* Print AppArmor profile */ /* Print AppArmor profile */
if (cs->apparmor_profile != NULL) { if (cs->apparmor_profile != NULL) {
if (asprintf(&attr_val, "apparmor_profile=%s", cs->apparmor_profile) == -1) { if (asprintf(&attr_val, "apparmor_profile=%s", cs->apparmor_profile) == -1) {
sudo_fatalx(U_("%s: %s"), __func__, sudo_fatalx(U_("%s: %s"), __func__,
U_("unable to allocate memory")); U_("unable to allocate memory"));
}
print_attribute_ldif(fp, "sudoOption", attr_val);
free(attr_val);
} }
print_attribute_ldif(fp, "sudoOption", attr_val);
free(attr_val);
}
#endif /* HAVE_APPARMOR */ #endif /* HAVE_APPARMOR */
#ifdef HAVE_PRIV_SET #ifdef HAVE_PRIV_SET

View File

@@ -978,11 +978,11 @@ cmndspec_equivalent(struct cmndspec *cs1, struct cmndspec *cs2, bool check_negat
#endif #endif
#ifdef HAVE_APPARMOR #ifdef HAVE_APPARMOR
if (cs1->apparmor_profile != NULL && cs2->apparmor_profile != NULL) { if (cs1->apparmor_profile != NULL && cs2->apparmor_profile != NULL) {
if (strcmp(cs1->apparmor_profile, cs2->apparmor_profile) != 0) if (strcmp(cs1->apparmor_profile, cs2->apparmor_profile) != 0)
debug_return_bool(false); debug_return_bool(false);
} else if (cs1->apparmor_profile != cs2->apparmor_profile) { } else if (cs1->apparmor_profile != cs2->apparmor_profile) {
debug_return_bool(false); debug_return_bool(false);
} }
#endif #endif
#ifdef HAVE_PRIV_SET #ifdef HAVE_PRIV_SET
if (cs1->privs != NULL && cs2->privs != NULL) { if (cs1->privs != NULL && cs2->privs != NULL) {

View File

@@ -481,4 +481,4 @@ intercept_type
dso trace dso trace
apparmor_profile apparmor_profile
T_STR T_STR
"AppArmor profile to use in the new security context: %s" "AppArmor profile to use in the new security context: %s"

View File

@@ -2139,8 +2139,8 @@ yyreduce:
parser_leak_remove(LEAK_PTR, (yyvsp[-2].options).type); parser_leak_remove(LEAK_PTR, (yyvsp[-2].options).type);
#endif #endif
#ifdef HAVE_APPARMOR #ifdef HAVE_APPARMOR
cs->apparmor_profile = (yyvsp[-2].options).apparmor_profile; cs->apparmor_profile = (yyvsp[-2].options).apparmor_profile;
parser_leak_remove(LEAK_PTR, (yyvsp[-2].options).apparmor_profile); parser_leak_remove(LEAK_PTR, (yyvsp[-2].options).apparmor_profile);
#endif #endif
#ifdef HAVE_PRIV_SET #ifdef HAVE_PRIV_SET
cs->privs = (yyvsp[-2].options).privs; cs->privs = (yyvsp[-2].options).privs;
@@ -2662,9 +2662,9 @@ yyreduce:
#line 864 "gram.y" #line 864 "gram.y"
{ {
#ifdef HAVE_APPARMOR #ifdef HAVE_APPARMOR
parser_leak_remove(LEAK_PTR, (yyval.options).apparmor_profile); parser_leak_remove(LEAK_PTR, (yyval.options).apparmor_profile);
free((yyval.options).apparmor_profile); free((yyval.options).apparmor_profile);
(yyval.options).apparmor_profile = (yyvsp[0].string); (yyval.options).apparmor_profile = (yyvsp[0].string);
#endif #endif
} }
#line 2665 "gram.c" #line 2665 "gram.c"

View File

@@ -145,7 +145,7 @@ static void alias_error(const char *name, int errnum);
%token <tok> CWD /* working directory for command */ %token <tok> CWD /* working directory for command */
%token <tok> TYPE /* SELinux type */ %token <tok> TYPE /* SELinux type */
%token <tok> ROLE /* SELinux role */ %token <tok> ROLE /* SELinux role */
%token <tok> APPARMOR_PROFILE /* AppArmor profile */ %token <tok> APPARMOR_PROFILE /* AppArmor profile */
%token <tok> PRIVS /* Solaris privileges */ %token <tok> PRIVS /* Solaris privileges */
%token <tok> LIMITPRIVS /* Solaris limit privileges */ %token <tok> LIMITPRIVS /* Solaris limit privileges */
%token <tok> CMND_TIMEOUT /* command timeout */ %token <tok> CMND_TIMEOUT /* command timeout */
@@ -538,8 +538,8 @@ cmndspec : runasspec options cmndtag digcmnd {
parser_leak_remove(LEAK_PTR, $2.type); parser_leak_remove(LEAK_PTR, $2.type);
#endif #endif
#ifdef HAVE_APPARMOR #ifdef HAVE_APPARMOR
cs->apparmor_profile = $2.apparmor_profile; cs->apparmor_profile = $2.apparmor_profile;
parser_leak_remove(LEAK_PTR, $2.apparmor_profile); parser_leak_remove(LEAK_PTR, $2.apparmor_profile);
#endif #endif
#ifdef HAVE_PRIV_SET #ifdef HAVE_PRIV_SET
cs->privs = $2.privs; cs->privs = $2.privs;
@@ -863,9 +863,9 @@ options : /* empty */ {
} }
| options apparmor_profilespec { | options apparmor_profilespec {
#ifdef HAVE_APPARMOR #ifdef HAVE_APPARMOR
parser_leak_remove(LEAK_PTR, $$.apparmor_profile); parser_leak_remove(LEAK_PTR, $$.apparmor_profile);
free($$.apparmor_profile); free($$.apparmor_profile);
$$.apparmor_profile = $2; $$.apparmor_profile = $2;
#endif #endif
} }
| options privsspec { | options privsspec {

View File

@@ -257,18 +257,18 @@ apply_cmndspec(struct cmndspec *cs)
#ifdef HAVE_APPARMOR #ifdef HAVE_APPARMOR
/* Set AppArmor profile, if specified */ /* Set AppArmor profile, if specified */
if (cs->apparmor_profile != NULL) { if (cs->apparmor_profile != NULL) {
user_apparmor_profile = strdup(cs->apparmor_profile); user_apparmor_profile = strdup(cs->apparmor_profile);
if (user_apparmor_profile == NULL) { if (user_apparmor_profile == NULL) {
sudo_warnx(U_("%s: %s"), __func__, sudo_warnx(U_("%s: %s"), __func__,
U_("unable to allocate memory")); U_("unable to allocate memory"));
debug_return_bool(false); debug_return_bool(false);
} }
} else { } else {
user_apparmor_profile = def_apparmor_profile; user_apparmor_profile = def_apparmor_profile;
def_apparmor_profile = NULL; def_apparmor_profile = NULL;
} }
if (user_apparmor_profile != NULL) { if (user_apparmor_profile != NULL) {
sudo_debug_printf(SUDO_DEBUG_INFO|SUDO_DEBUG_LINENO, sudo_debug_printf(SUDO_DEBUG_INFO|SUDO_DEBUG_LINENO,
"user_apparmor_profile -> %s", user_apparmor_profile); "user_apparmor_profile -> %s", user_apparmor_profile);
} }
#endif #endif

View File

@@ -150,7 +150,7 @@ struct command_options {
char *role, *type; /* SELinux role and type */ char *role, *type; /* SELinux role and type */
#endif #endif
#ifdef HAVE_APPARMOR #ifdef HAVE_APPARMOR
char *apparmor_profile; /* AppArmor profile */ char *apparmor_profile; /* AppArmor profile */
#endif #endif
#ifdef HAVE_PRIV_SET #ifdef HAVE_PRIV_SET
char *privs, *limitprivs; /* Solaris privilege sets */ char *privs, *limitprivs; /* Solaris privilege sets */
@@ -237,7 +237,7 @@ struct cmndspec {
char *role, *type; /* SELinux role and type */ char *role, *type; /* SELinux role and type */
#endif #endif
#ifdef HAVE_APPARMOR #ifdef HAVE_APPARMOR
char *apparmor_profile; /* AppArmor profile */ char *apparmor_profile; /* AppArmor profile */
#endif #endif
#ifdef HAVE_PRIV_SET #ifdef HAVE_PRIV_SET
char *privs, *limitprivs; /* Solaris privilege sets */ char *privs, *limitprivs; /* Solaris privilege sets */

View File

@@ -331,12 +331,12 @@ sudoers_policy_deserialize_info(void *v, struct defaults_list *defaults)
#endif /* HAVE_SELINUX */ #endif /* HAVE_SELINUX */
#ifdef HAVE_APPARMOR #ifdef HAVE_APPARMOR
if (MATCHES(*cur, "apparmor_profile=")) { if (MATCHES(*cur, "apparmor_profile=")) {
CHECK(*cur, "apparmor_profile="); CHECK(*cur, "apparmor_profile=");
free(user_apparmor_profile); free(user_apparmor_profile);
user_apparmor_profile = strdup(*cur + sizeof("apparmor_profile=") - 1); user_apparmor_profile = strdup(*cur + sizeof("apparmor_profile=") - 1);
if (user_apparmor_profile == NULL) if (user_apparmor_profile == NULL)
goto oom; goto oom;
continue; continue;
} }
#endif /* HAVE_APPARMOR */ #endif /* HAVE_APPARMOR */
#ifdef HAVE_BSD_AUTH_H #ifdef HAVE_BSD_AUTH_H
@@ -970,7 +970,7 @@ sudoers_policy_store_result(bool accepted, char *argv[], char *envp[],
#endif /* HAVE_SELINUX */ #endif /* HAVE_SELINUX */
#ifdef HAVE_APPARMOR #ifdef HAVE_APPARMOR
if (user_apparmor_profile != NULL) { if (user_apparmor_profile != NULL) {
if ((command_info[info_len++] = sudo_new_key_val("apparmor_profile", user_apparmor_profile)) == NULL) if ((command_info[info_len++] = sudo_new_key_val("apparmor_profile", user_apparmor_profile)) == NULL)
goto oom; goto oom;
} }
#endif /* HAVE_APPARMOR */ #endif /* HAVE_APPARMOR */

View File

@@ -44,7 +44,8 @@ apparmor_is_enabled(void)
FILE *fd; FILE *fd;
debug_decl(apparmor_is_enabled, SUDO_DEBUG_APPARMOR); debug_decl(apparmor_is_enabled, SUDO_DEBUG_APPARMOR);
/* Check whether AppArmor is enabled by reading /*
* Check whether AppArmor is enabled by reading
* /sys/module/apparmor/parameters/enabled * /sys/module/apparmor/parameters/enabled
* *
* When this file exists and its contents are equal to "Y", AppArmor * When this file exists and its contents are equal to "Y", AppArmor
@@ -93,20 +94,21 @@ apparmor_prepare(const char *new_profile)
goto done; goto done;
} }
if (mode == NULL) if (mode == NULL) {
sudo_debug_printf(SUDO_DEBUG_INFO, sudo_debug_printf(SUDO_DEBUG_INFO,
"%s: changing AppArmor profile: %s -> %s", __func__, "%s: changing AppArmor profile: %s -> %s", __func__,
old_profile, new_profile ? new_profile : "?" old_profile, new_profile ? new_profile : "?");
); } else {
else
sudo_debug_printf(SUDO_DEBUG_INFO, sudo_debug_printf(SUDO_DEBUG_INFO,
"%s: changing AppArmor profile: %s (%s) -> %s", __func__, "%s: changing AppArmor profile: %s (%s) -> %s", __func__,
old_profile, mode, new_profile ? new_profile : "?" old_profile, mode, new_profile ? new_profile : "?");
); }
done: done:
/* The profile string returned by aa_getcon must be free'd, while the /*
* mode string must _not_ be free'd */ * The profile string returned by aa_getcon must be free'd, while the
* mode string must _not_ be free'd.
*/
if (old_profile != NULL) if (old_profile != NULL)
free(old_profile); free(old_profile);