Add a source to struct sudo_nss and use it if getdefs() fails.
Also remove useless "Problem with defaults entries" warning in testsudoers.
This commit is contained in:
@@ -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,
|
||||
|
@@ -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,
|
||||
|
@@ -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,
|
||||
|
@@ -1,4 +1,3 @@
|
||||
Problem with defaults entries
|
||||
|
||||
Defaults command_timeout=2d8h10m59ss
|
||||
Defaults:root command_timeout=15f
|
||||
|
@@ -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,
|
||||
|
@@ -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);
|
||||
|
@@ -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"));
|
||||
}
|
||||
|
@@ -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);
|
||||
|
Reference in New Issue
Block a user