2
0
mirror of https://github.com/sudo-project/sudo.git synced 2025-08-22 09:57:41 +00:00

Use C99 designated struct initializers.

This is less error-prone and would have avoided GitHub issue #325.
This commit is contained in:
Todd C. Miller 2023-11-07 14:47:48 -07:00
parent 45aeeddcbe
commit e0d912d1db

View File

@ -78,7 +78,6 @@ struct group_list {
/* /*
* Parse configuration settings. * Parse configuration settings.
* Do not change the order without updating SUDOERS_PARSER_CONFIG_INITIALIZER.
*/ */
struct sudoers_parser_config { struct sudoers_parser_config {
const char *sudoers_path; const char *sudoers_path;
@ -91,19 +90,18 @@ struct sudoers_parser_config {
gid_t sudoers_gid; gid_t sudoers_gid;
}; };
#define SUDOERS_PARSER_CONFIG_INITIALIZER { \ #define SUDOERS_PARSER_CONFIG_INITIALIZER { \
NULL, /* sudoers_path */ \ .sudoers_path = NULL, \
false, /* strict */ \ .strict = false, \
1, /* verbose level 1 */ \ .verbose = 1, \
true, /* recovery */ \ .recovery = true, \
false, /* ignore_perms */ \ .ignore_perms = false, \
SUDOERS_MODE, \ .sudoers_mode = SUDOERS_MODE, \
SUDOERS_UID, \ .sudoers_uid = SUDOERS_UID, \
SUDOERS_GID \ .sudoers_gid = SUDOERS_GID \
} }
/* /*
* Settings passed in from the sudo front-end. * Settings passed in from the sudo front-end.
* Do not change the order without updating SUDOERS_CONTEXT_INITIALIZER.
*/ */
struct sudoers_plugin_settings { struct sudoers_plugin_settings {
const char *plugin_dir; const char *plugin_dir;
@ -111,6 +109,11 @@ struct sudoers_plugin_settings {
const char *ldap_secret; const char *ldap_secret;
unsigned int flags; unsigned int flags;
}; };
#define SUDOERS_PLUGIN_SETTINGS_INITIALIZER { \
.plugin_dir = _PATH_SUDO_PLUGIN_DIR, \
.ldap_conf = _PATH_LDAP_CONF, \
.ldap_secret = _PATH_LDAP_SECRET \
}
/* /*
* Info pertaining to the invoking user. * Info pertaining to the invoking user.
@ -183,11 +186,6 @@ struct sudoers_runas_context {
#endif #endif
}; };
#define SUDOERS_CONTEXT_INITIALIZER { \
SUDOERS_PARSER_CONFIG_INITIALIZER, \
{ _PATH_SUDO_PLUGIN_DIR, _PATH_LDAP_CONF, _PATH_LDAP_SECRET } \
}
/* /*
* Global configuration for the sudoers module. * Global configuration for the sudoers module.
*/ */
@ -205,6 +203,10 @@ struct sudoers_context {
unsigned int mode; unsigned int mode;
char uuid_str[37]; char uuid_str[37];
}; };
#define SUDOERS_CONTEXT_INITIALIZER { \
SUDOERS_PARSER_CONFIG_INITIALIZER, \
SUDOERS_PLUGIN_SETTINGS_INITIALIZER, \
}
/* /*
* sudo_get_gidlist() type values * sudo_get_gidlist() type values