Check sudo_conf_read() return value and exit on fatal error (a

warning was already printed by sudo_conf_read()).
This commit is contained in:
Todd C. Miller
2015-07-07 13:17:50 -06:00
parent 4620bc31c8
commit 445e6f2e9a
6 changed files with 14 additions and 8 deletions

View File

@@ -51,12 +51,13 @@ main(int argc, char *argv[])
initprogname(argc > 0 ? argv[0] : "conf_test"); initprogname(argc > 0 ? argv[0] : "conf_test");
if (argc != 2) { if (argc != 2) {
fprintf(stderr, "usage: %s conf_file\n", getprogname()); fprintf(stderr, "usage: %s conf_file\n", getprogname());
exit(1); exit(EXIT_FAILURE);
} }
sudo_conf_read(argv[1], SUDO_CONF_ALL); if (sudo_conf_read(argv[1], SUDO_CONF_ALL) == -1)
exit(EXIT_FAILURE);
sudo_conf_dump(); sudo_conf_dump();
exit(0); exit(EXIT_SUCCESS);
} }
static void static void

View File

@@ -211,7 +211,8 @@ main(int argc, char *argv[])
sudo_fatal_callback_register(sudoreplay_cleanup); sudo_fatal_callback_register(sudoreplay_cleanup);
/* Read sudo.conf and initialize the debug subsystem. */ /* Read sudo.conf and initialize the debug subsystem. */
sudo_conf_read(NULL, SUDO_CONF_DEBUG); if (sudo_conf_read(NULL, SUDO_CONF_DEBUG) == -1)
exit(EXIT_FAILURE);
sudo_debug_register(getprogname(), NULL, NULL, sudo_debug_register(getprogname(), NULL, NULL,
sudo_conf_debug_files(getprogname())); sudo_conf_debug_files(getprogname()));

View File

@@ -132,7 +132,8 @@ main(int argc, char *argv[])
textdomain("sudoers"); textdomain("sudoers");
/* Initialize the debug subsystem. */ /* Initialize the debug subsystem. */
sudo_conf_read(NULL, SUDO_CONF_DEBUG); if (sudo_conf_read(NULL, SUDO_CONF_DEBUG) == -1)
exit(EXIT_FAILURE);
sudoers_debug_register(getprogname(), sudo_conf_debug_files(getprogname())); sudoers_debug_register(getprogname(), sudo_conf_debug_files(getprogname()));
dflag = 0; dflag = 0;

View File

@@ -163,7 +163,8 @@ main(int argc, char *argv[])
sudo_fatal_callback_register(visudo_cleanup); sudo_fatal_callback_register(visudo_cleanup);
/* Read debug and plugin sections of sudo.conf. */ /* Read debug and plugin sections of sudo.conf. */
sudo_conf_read(NULL, SUDO_CONF_DEBUG|SUDO_CONF_PLUGINS); if (sudo_conf_read(NULL, SUDO_CONF_DEBUG|SUDO_CONF_PLUGINS) == -1)
exit(EXIT_FAILURE);
/* Initialize the debug subsystem. */ /* Initialize the debug subsystem. */
sudoers_debug_register(getprogname(), sudo_conf_debug_files(getprogname())); sudoers_debug_register(getprogname(), sudo_conf_debug_files(getprogname()));

View File

@@ -77,7 +77,8 @@ main(int argc, char *argv[], char *envp[])
sudo_fatalx(U_("requires at least one argument")); sudo_fatalx(U_("requires at least one argument"));
/* Read sudo.conf and initialize the debug subsystem. */ /* Read sudo.conf and initialize the debug subsystem. */
sudo_conf_read(NULL, SUDO_CONF_DEBUG); if (sudo_conf_read(NULL, SUDO_CONF_DEBUG) == -1)
exit(EXIT_FAILURE);
sudo_debug_register(getprogname(), NULL, NULL, sudo_debug_register(getprogname(), NULL, NULL,
sudo_conf_debug_files(getprogname())); sudo_conf_debug_files(getprogname()));

View File

@@ -161,7 +161,8 @@ main(int argc, char *argv[], char *envp[])
#endif /* HAVE_GETPRPWNAM && HAVE_SET_AUTH_PARAMETERS */ #endif /* HAVE_GETPRPWNAM && HAVE_SET_AUTH_PARAMETERS */
/* Initialize the debug subsystem. */ /* Initialize the debug subsystem. */
sudo_conf_read(NULL, SUDO_CONF_DEBUG); if (sudo_conf_read(NULL, SUDO_CONF_DEBUG) == -1)
exit(EXIT_FAILURE);
sudo_debug_instance = sudo_debug_register(getprogname(), sudo_debug_instance = sudo_debug_register(getprogname(),
NULL, NULL, sudo_conf_debug_files(getprogname())); NULL, NULL, sudo_conf_debug_files(getprogname()));