the ldap/sssd backends which support per-role defaults.
* Pass in an OR'd list of which default types to update.
*/
bool
-update_defaults(struct sudoers_parse_tree *parse_tree, int what, bool quiet)
+update_defaults(struct sudoers_parse_tree *parse_tree,
+ struct defaults_list *defs, int what, bool quiet)
{
struct defaults *d;
bool ret = true;
sudo_debug_printf(SUDO_DEBUG_INFO|SUDO_DEBUG_LINENO,
"what: 0x%02x", what);
+ /* If no defaults list specified, use the global one in the parse tree. */
+ if (defs == NULL)
+ defs = &parse_tree->defaults;
+
/*
* First apply Defaults values marked as early.
*/
- TAILQ_FOREACH(d, &parse_tree->defaults, entries) {
+ TAILQ_FOREACH(d, defs, entries) {
struct early_default *early = is_early_default(d->var);
if (early == NULL)
continue;
/*
* Then set the rest of the defaults.
*/
- TAILQ_FOREACH(d, &parse_tree->defaults, entries) {
+ TAILQ_FOREACH(d, defs, entries) {
/* Skip Defaults marked as early, we already did them. */
if (is_early_default(d->var))
continue;
/*
* Prototypes
*/
+struct defaults_list;
struct sudoers_parse_tree;
void dump_default(void);
bool init_defaults(void);
bool run_early_defaults(void);
bool set_early_default(const char *var, const char *val, int op, const char *file, int lineno, bool quiet, struct early_default *early);
bool set_default(const char *var, const char *val, int op, const char *file, int lineno, bool quiet);
-bool update_defaults(struct sudoers_parse_tree *parse_tree, int what, bool quiet);
+bool update_defaults(struct sudoers_parse_tree *parse_tree, struct defaults_list *defs, int what, bool quiet);
bool check_defaults(struct sudoers_parse_tree *parse_tree, bool quiet);
extern struct sudo_defs_types sudo_defs_table[];
}
if (match != UNSPEC) {
if (defs != NULL)
- update_defaults(parse_tree, SETDEF_GENERIC, false);
+ update_defaults(parse_tree, defs, SETDEF_GENERIC, false);
if (!apply_cmndspec(cs))
SET(validated, VALIDATE_ERROR);
else if (match == ALLOW)
}
sources++;
- if (nss->getdefs(nss) == -1 || !update_defaults(nss->parse_tree,
+ if (nss->getdefs(nss) == -1 || !update_defaults(nss->parse_tree, NULL,
SETDEF_GENERIC|SETDEF_HOST|SETDEF_USER|SETDEF_RUNAS, false)) {
log_warningx(SLOG_SEND_MAIL|SLOG_NO_STDERR,
N_("problem with defaults entries"));
user_base = user_cmnd;
TAILQ_FOREACH(nss, snl, entries) {
- if (!update_defaults(nss->parse_tree, SETDEF_CMND, false)) {
+ if (!update_defaults(nss->parse_tree, NULL, SETDEF_CMND, false)) {
log_warningx(SLOG_SEND_MAIL|SLOG_NO_STDERR,
N_("problem with defaults entries"));
}
(void) fputs("Parses OK", stdout);
}
- if (!update_defaults(&parsed_policy, SETDEF_ALL, false))
+ if (!update_defaults(&parsed_policy, NULL, SETDEF_ALL, false))
(void) fputs(" (problem with defaults entries)", stdout);
puts(".");
init_parser(sudoers_file, quiet);
sudoers_setlocale(SUDOERS_LOCALE_SUDOERS, &oldlocale);
(void) sudoersparse();
- (void) update_defaults(&parsed_policy,
+ (void) update_defaults(&parsed_policy, NULL,
SETDEF_GENERIC|SETDEF_HOST|SETDEF_USER, quiet);
sudoers_setlocale(oldlocale, NULL);
}
fclose(sudoersin);
if (!parse_error) {
- (void) update_defaults(&parsed_policy,
+ (void) update_defaults(&parsed_policy, NULL,
SETDEF_GENERIC|SETDEF_HOST|SETDEF_USER, true);
check_defaults_and_aliases(strict, quiet);
}
sudo_fatalx(U_("%s: %s"), __func__, U_("unable to allocate memory"));
}
if (!parse_error) {
- (void) update_defaults(&parsed_policy,
+ (void) update_defaults(&parsed_policy, NULL,
SETDEF_GENERIC|SETDEF_HOST|SETDEF_USER, true);
check_defaults_and_aliases(strict, quiet);
}