From: Todd C. Miller Date: Mon, 27 Oct 2014 22:06:20 +0000 (-0600) Subject: Add sudoers_debug_deregister() and use it instead of calling X-Git-Tag: SUDO_1_8_12^2~106 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=9d6e1a57d5d8f50cc95cc0f368f3b9351a22fc99;p=sudo Add sudoers_debug_deregister() and use it instead of calling sudo_debug_deregister() directly. --- diff --git a/plugins/sudoers/iolog.c b/plugins/sudoers/iolog.c index bd6281e40..e29baa21b 100644 --- a/plugins/sudoers/iolog.c +++ b/plugins/sudoers/iolog.c @@ -602,7 +602,7 @@ sudoers_io_open(unsigned int version, sudo_conv_t conversation, continue; } } - sudoers_debug_register(&debug_files, plugin_path); + sudoers_debug_register(plugin_path, &debug_files); /* * Pull iolog settings out of command_info. @@ -690,11 +690,7 @@ sudoers_io_close(int exit_status, int error) fclose(io_log_files[i].fd.f); } - sudo_debug_exit(__func__, __FILE__, __LINE__, sudo_debug_subsys); - if (sudoers_debug_instance != SUDO_DEBUG_INSTANCE_INITIALIZER) { - sudo_debug_deregister(sudoers_debug_instance); - sudoers_debug_instance = SUDO_DEBUG_INSTANCE_INITIALIZER; - } + sudoers_debug_deregister(); return; } diff --git a/plugins/sudoers/policy.c b/plugins/sudoers/policy.c index 2a31d7068..a1a9f8ed7 100644 --- a/plugins/sudoers/policy.c +++ b/plugins/sudoers/policy.c @@ -549,7 +549,7 @@ sudoers_policy_open(unsigned int version, sudo_conv_t conversation, continue; } } - sudoers_debug_register(&debug_files, plugin_path); + sudoers_debug_register(plugin_path, &debug_files); /* Call the sudoers init function. */ info.settings = settings; @@ -593,11 +593,7 @@ sudoers_policy_close(int exit_status, int error_code) sudo_efree(user_gids); user_gids = NULL; - sudo_debug_exit(__func__, __FILE__, __LINE__, sudo_debug_subsys); - if (sudoers_debug_instance != SUDO_DEBUG_INSTANCE_INITIALIZER) { - sudo_debug_deregister(sudoers_debug_instance); - sudoers_debug_instance = SUDO_DEBUG_INSTANCE_INITIALIZER; - } + sudoers_debug_deregister(); return; } diff --git a/plugins/sudoers/sudoers.h b/plugins/sudoers/sudoers.h index f815b6ff7..a957c90ff 100644 --- a/plugins/sudoers/sudoers.h +++ b/plugins/sudoers/sudoers.h @@ -348,7 +348,8 @@ void sudoers_cleanup(void); /* sudoers_debug.c */ void sudoers_debug_parse_flags(struct sudo_conf_debug_file_list *debug_files, const char *entry); -void sudoers_debug_register(struct sudo_conf_debug_file_list *debug_files, const char *plugin_path); +void sudoers_debug_register(const char *plugin_path, struct sudo_conf_debug_file_list *debug_files); +void sudoers_debug_deregister(void); extern int sudoers_debug_instance; /* policy.c */ diff --git a/plugins/sudoers/sudoers_debug.c b/plugins/sudoers/sudoers_debug.c index 6734a5875..549f670f3 100644 --- a/plugins/sudoers/sudoers_debug.c +++ b/plugins/sudoers/sudoers_debug.c @@ -110,8 +110,8 @@ sudoers_debug_parse_flags(struct sudo_conf_debug_file_list *debug_files, * debug subsystem, freeing the debug list when done. */ void -sudoers_debug_register(struct sudo_conf_debug_file_list *debug_files, - const char *program) +sudoers_debug_register(const char *program, + struct sudo_conf_debug_file_list *debug_files) { struct sudo_debug_file *debug_file, *debug_next; @@ -129,3 +129,17 @@ sudoers_debug_register(struct sudo_conf_debug_file_list *debug_files, } } } + +/* + * Deregister sudoers_debug_instance if it is registered. + */ +void +sudoers_debug_deregister(void) +{ + debug_decl(sudoers_debug_deregister, SUDOERS_DEBUG_PLUGIN, sudoers_debug_instance) + if (sudoers_debug_instance != SUDO_DEBUG_INSTANCE_INITIALIZER) { + sudo_debug_exit(__func__, __FILE__, __LINE__, sudo_debug_subsys); + sudo_debug_deregister(sudoers_debug_instance); + sudoers_debug_instance = SUDO_DEBUG_INSTANCE_INITIALIZER; + } +} diff --git a/plugins/sudoers/testsudoers.c b/plugins/sudoers/testsudoers.c index 10ab05afa..e13a30836 100644 --- a/plugins/sudoers/testsudoers.c +++ b/plugins/sudoers/testsudoers.c @@ -140,7 +140,7 @@ main(int argc, char *argv[]) /* Initialize the debug subsystem. */ sudo_conf_read(NULL, SUDO_CONF_DEBUG); - sudoers_debug_register(sudo_conf_debug_files(getprogname()), getprogname()); + sudoers_debug_register(getprogname(), sudo_conf_debug_files(getprogname())); dflag = 0; grfile = pwfile = NULL; diff --git a/plugins/sudoers/visudo.c b/plugins/sudoers/visudo.c index 7e44be610..e6e5014f6 100644 --- a/plugins/sudoers/visudo.c +++ b/plugins/sudoers/visudo.c @@ -171,7 +171,7 @@ main(int argc, char *argv[]) /* Initialize the debug subsystem. */ sudo_conf_read(NULL, SUDO_CONF_DEBUG); - sudoers_debug_register(sudo_conf_debug_files(getprogname()), getprogname()); + sudoers_debug_register(getprogname(), sudo_conf_debug_files(getprogname())); /* * Arg handling.