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 */
|
/* sudo_nss implementation */
|
||||||
struct sudo_nss sudo_nss_file = {
|
struct sudo_nss sudo_nss_file = {
|
||||||
{ NULL, NULL },
|
{ NULL, NULL },
|
||||||
|
"sudoers",
|
||||||
sudo_file_open,
|
sudo_file_open,
|
||||||
sudo_file_close,
|
sudo_file_close,
|
||||||
sudo_file_parse,
|
sudo_file_parse,
|
||||||
|
@@ -2143,6 +2143,7 @@ sudo_ldap_result_from_search(LDAP *ldap, LDAPMessage *searchresult)
|
|||||||
/* sudo_nss implementation */
|
/* sudo_nss implementation */
|
||||||
struct sudo_nss sudo_nss_ldap = {
|
struct sudo_nss sudo_nss_ldap = {
|
||||||
{ NULL, NULL },
|
{ NULL, NULL },
|
||||||
|
"ldap",
|
||||||
sudo_ldap_open,
|
sudo_ldap_open,
|
||||||
sudo_ldap_close,
|
sudo_ldap_close,
|
||||||
sudo_ldap_parse,
|
sudo_ldap_parse,
|
||||||
|
@@ -660,6 +660,7 @@ sudo_file_getdefs(struct sudo_nss *nss)
|
|||||||
|
|
||||||
static struct sudo_nss sudo_nss_file = {
|
static struct sudo_nss sudo_nss_file = {
|
||||||
{ NULL, NULL },
|
{ NULL, NULL },
|
||||||
|
"sudoers",
|
||||||
sudo_file_open,
|
sudo_file_open,
|
||||||
sudo_file_close,
|
sudo_file_close,
|
||||||
sudo_file_parse,
|
sudo_file_parse,
|
||||||
|
@@ -1,4 +1,3 @@
|
|||||||
Problem with defaults entries
|
|
||||||
|
|
||||||
Defaults command_timeout=2d8h10m59ss
|
Defaults command_timeout=2d8h10m59ss
|
||||||
Defaults:root command_timeout=15f
|
Defaults:root command_timeout=15f
|
||||||
|
@@ -802,6 +802,7 @@ bad:
|
|||||||
/* sudo_nss implementation */
|
/* sudo_nss implementation */
|
||||||
struct sudo_nss sudo_nss_sss = {
|
struct sudo_nss sudo_nss_sss = {
|
||||||
{ NULL, NULL },
|
{ NULL, NULL },
|
||||||
|
"sss",
|
||||||
sudo_sss_open,
|
sudo_sss_open,
|
||||||
sudo_sss_close,
|
sudo_sss_close,
|
||||||
sudo_sss_parse,
|
sudo_sss_parse,
|
||||||
|
@@ -27,6 +27,7 @@ struct defaults_list;
|
|||||||
/* XXX - parse_tree, ret_if_found and ret_if_notfound should be private */
|
/* XXX - parse_tree, ret_if_found and ret_if_notfound should be private */
|
||||||
struct sudo_nss {
|
struct sudo_nss {
|
||||||
TAILQ_ENTRY(sudo_nss) entries;
|
TAILQ_ENTRY(sudo_nss) entries;
|
||||||
|
const char *source;
|
||||||
int (*open)(struct sudo_nss *nss);
|
int (*open)(struct sudo_nss *nss);
|
||||||
int (*close)(struct sudo_nss *nss);
|
int (*close)(struct sudo_nss *nss);
|
||||||
struct sudoers_parse_tree *(*parse)(struct sudo_nss *nss);
|
struct sudoers_parse_tree *(*parse)(struct sudo_nss *nss);
|
||||||
|
@@ -168,7 +168,11 @@ sudoers_reinit_defaults(void)
|
|||||||
}
|
}
|
||||||
|
|
||||||
TAILQ_FOREACH_SAFE(nss, snl, entries, nss_next) {
|
TAILQ_FOREACH_SAFE(nss, snl, entries, nss_next) {
|
||||||
if (nss->getdefs(nss) == -1 || !update_defaults(nss->parse_tree, NULL,
|
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)) {
|
SETDEF_GENERIC|SETDEF_HOST|SETDEF_USER|SETDEF_RUNAS, false)) {
|
||||||
log_warningx(SLOG_SEND_MAIL|SLOG_NO_STDERR,
|
log_warningx(SLOG_SEND_MAIL|SLOG_NO_STDERR,
|
||||||
N_("problem with defaults entries"));
|
N_("problem with defaults entries"));
|
||||||
@@ -243,7 +247,11 @@ sudoers_init(void *info, char * const envp[])
|
|||||||
}
|
}
|
||||||
|
|
||||||
sources++;
|
sources++;
|
||||||
if (nss->getdefs(nss) == -1 || !update_defaults(nss->parse_tree, NULL,
|
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)) {
|
SETDEF_GENERIC|SETDEF_HOST|SETDEF_USER|SETDEF_RUNAS, false)) {
|
||||||
log_warningx(SLOG_SEND_MAIL|SLOG_NO_STDERR,
|
log_warningx(SLOG_SEND_MAIL|SLOG_NO_STDERR,
|
||||||
N_("problem with defaults entries"));
|
N_("problem with defaults entries"));
|
||||||
|
@@ -292,18 +292,18 @@ main(int argc, char *argv[])
|
|||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case format_sudoers:
|
case format_sudoers:
|
||||||
if (sudoersparse() != 0 || parse_error)
|
if (sudoersparse() != 0)
|
||||||
parse_error = true;
|
parse_error = true;
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
sudo_fatalx("error: unhandled input %d", input_format);
|
sudo_fatalx("error: unhandled input %d", input_format);
|
||||||
}
|
}
|
||||||
|
if (!update_defaults(&parsed_policy, NULL, SETDEF_ALL, false))
|
||||||
|
parse_error = true;
|
||||||
|
|
||||||
if (!parse_error)
|
if (!parse_error)
|
||||||
(void) puts("Parses OK");
|
(void) puts("Parses OK");
|
||||||
|
|
||||||
if (!update_defaults(&parsed_policy, NULL, SETDEF_ALL, false))
|
|
||||||
(void) puts("Problem with defaults entries");
|
|
||||||
|
|
||||||
if (dflag) {
|
if (dflag) {
|
||||||
(void) putchar('\n');
|
(void) putchar('\n');
|
||||||
dump_sudoers(&lbuf);
|
dump_sudoers(&lbuf);
|
||||||
|
Reference in New Issue
Block a user