diff --git a/plugins/sudoers/file.c b/plugins/sudoers/file.c index 11626b122..e20f545d2 100644 --- a/plugins/sudoers/file.c +++ b/plugins/sudoers/file.c @@ -146,6 +146,7 @@ sudo_file_getdefs(struct sudo_nss *nss) /* sudo_nss implementation */ struct sudo_nss sudo_nss_file = { { NULL, NULL }, + "sudoers", sudo_file_open, sudo_file_close, sudo_file_parse, diff --git a/plugins/sudoers/ldap.c b/plugins/sudoers/ldap.c index 13e74160b..4f0192265 100644 --- a/plugins/sudoers/ldap.c +++ b/plugins/sudoers/ldap.c @@ -2143,6 +2143,7 @@ sudo_ldap_result_from_search(LDAP *ldap, LDAPMessage *searchresult) /* sudo_nss implementation */ struct sudo_nss sudo_nss_ldap = { { NULL, NULL }, + "ldap", sudo_ldap_open, sudo_ldap_close, sudo_ldap_parse, diff --git a/plugins/sudoers/regress/fuzz/fuzz_policy.c b/plugins/sudoers/regress/fuzz/fuzz_policy.c index 047b81597..d8feec60f 100644 --- a/plugins/sudoers/regress/fuzz/fuzz_policy.c +++ b/plugins/sudoers/regress/fuzz/fuzz_policy.c @@ -660,6 +660,7 @@ sudo_file_getdefs(struct sudo_nss *nss) static struct sudo_nss sudo_nss_file = { { NULL, NULL }, + "sudoers", sudo_file_open, sudo_file_close, sudo_file_parse, diff --git a/plugins/sudoers/regress/sudoers/test18.out.ok b/plugins/sudoers/regress/sudoers/test18.out.ok index eefdc3a2c..03f9ef6f4 100644 --- a/plugins/sudoers/regress/sudoers/test18.out.ok +++ b/plugins/sudoers/regress/sudoers/test18.out.ok @@ -1,4 +1,3 @@ -Problem with defaults entries Defaults command_timeout=2d8h10m59ss Defaults:root command_timeout=15f diff --git a/plugins/sudoers/sssd.c b/plugins/sudoers/sssd.c index 37b4c1d38..d4c70b92a 100644 --- a/plugins/sudoers/sssd.c +++ b/plugins/sudoers/sssd.c @@ -802,6 +802,7 @@ bad: /* sudo_nss implementation */ struct sudo_nss sudo_nss_sss = { { NULL, NULL }, + "sss", sudo_sss_open, sudo_sss_close, sudo_sss_parse, diff --git a/plugins/sudoers/sudo_nss.h b/plugins/sudoers/sudo_nss.h index bb0c49a96..a7487cb68 100644 --- a/plugins/sudoers/sudo_nss.h +++ b/plugins/sudoers/sudo_nss.h @@ -27,6 +27,7 @@ struct defaults_list; /* XXX - parse_tree, ret_if_found and ret_if_notfound should be private */ struct sudo_nss { TAILQ_ENTRY(sudo_nss) entries; + const char *source; int (*open)(struct sudo_nss *nss); int (*close)(struct sudo_nss *nss); struct sudoers_parse_tree *(*parse)(struct sudo_nss *nss); diff --git a/plugins/sudoers/sudoers.c b/plugins/sudoers/sudoers.c index dd0708abd..854dde7da 100644 --- a/plugins/sudoers/sudoers.c +++ b/plugins/sudoers/sudoers.c @@ -161,15 +161,19 @@ sudoers_reinit_defaults(void) } if (!update_defaults(NULL, &initial_defaults, - SETDEF_GENERIC|SETDEF_HOST|SETDEF_USER|SETDEF_RUNAS, false)) { + SETDEF_GENERIC|SETDEF_HOST|SETDEF_USER|SETDEF_RUNAS, false)) { log_warningx(SLOG_SEND_MAIL|SLOG_NO_STDERR, N_("problem with defaults entries")); debug_return_bool(false); } TAILQ_FOREACH_SAFE(nss, snl, entries, nss_next) { - if (nss->getdefs(nss) == -1 || !update_defaults(nss->parse_tree, NULL, - SETDEF_GENERIC|SETDEF_HOST|SETDEF_USER|SETDEF_RUNAS, false)) { + if (nss->getdefs(nss) == -1) { + log_warningx(SLOG_SEND_MAIL|SLOG_NO_STDERR, + N_("unable to get defaults from %s"), nss->source); + } + if (!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")); /* not a fatal error */ @@ -223,7 +227,7 @@ sudoers_init(void *info, char * const envp[]) /* Update defaults set by front-end. */ if (!update_defaults(NULL, &initial_defaults, - SETDEF_GENERIC|SETDEF_HOST|SETDEF_USER|SETDEF_RUNAS, false)) { + SETDEF_GENERIC|SETDEF_HOST|SETDEF_USER|SETDEF_RUNAS, false)) { log_warningx(SLOG_SEND_MAIL|SLOG_NO_STDERR, N_("problem with defaults entries")); debug_return_int(-1); @@ -243,8 +247,12 @@ sudoers_init(void *info, char * const envp[]) } sources++; - if (nss->getdefs(nss) == -1 || !update_defaults(nss->parse_tree, NULL, - SETDEF_GENERIC|SETDEF_HOST|SETDEF_USER|SETDEF_RUNAS, false)) { + if (nss->getdefs(nss) == -1) { + log_warningx(SLOG_SEND_MAIL|SLOG_NO_STDERR, + N_("unable to get defaults from %s"), nss->source); + } + if (!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")); } diff --git a/plugins/sudoers/testsudoers.c b/plugins/sudoers/testsudoers.c index 1aa8aafbd..26c0d7b43 100644 --- a/plugins/sudoers/testsudoers.c +++ b/plugins/sudoers/testsudoers.c @@ -292,18 +292,18 @@ main(int argc, char *argv[]) } break; case format_sudoers: - if (sudoersparse() != 0 || parse_error) + if (sudoersparse() != 0) parse_error = true; break; default: sudo_fatalx("error: unhandled input %d", input_format); } + if (!update_defaults(&parsed_policy, NULL, SETDEF_ALL, false)) + parse_error = true; + if (!parse_error) (void) puts("Parses OK"); - if (!update_defaults(&parsed_policy, NULL, SETDEF_ALL, false)) - (void) puts("Problem with defaults entries"); - if (dflag) { (void) putchar('\n'); dump_sudoers(&lbuf);