Add sudoers_debug_deregister() and use it instead of calling

sudo_debug_deregister() directly.
This commit is contained in:
Todd C. Miller
2014-10-27 16:06:20 -06:00
parent 0982f7838b
commit 9d6e1a57d5
6 changed files with 24 additions and 17 deletions

View File

@@ -602,7 +602,7 @@ sudoers_io_open(unsigned int version, sudo_conv_t conversation,
continue; continue;
} }
} }
sudoers_debug_register(&debug_files, plugin_path); sudoers_debug_register(plugin_path, &debug_files);
/* /*
* Pull iolog settings out of command_info. * 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); fclose(io_log_files[i].fd.f);
} }
sudo_debug_exit(__func__, __FILE__, __LINE__, sudo_debug_subsys); sudoers_debug_deregister();
if (sudoers_debug_instance != SUDO_DEBUG_INSTANCE_INITIALIZER) {
sudo_debug_deregister(sudoers_debug_instance);
sudoers_debug_instance = SUDO_DEBUG_INSTANCE_INITIALIZER;
}
return; return;
} }

View File

@@ -549,7 +549,7 @@ sudoers_policy_open(unsigned int version, sudo_conv_t conversation,
continue; continue;
} }
} }
sudoers_debug_register(&debug_files, plugin_path); sudoers_debug_register(plugin_path, &debug_files);
/* Call the sudoers init function. */ /* Call the sudoers init function. */
info.settings = settings; info.settings = settings;
@@ -593,11 +593,7 @@ sudoers_policy_close(int exit_status, int error_code)
sudo_efree(user_gids); sudo_efree(user_gids);
user_gids = NULL; user_gids = NULL;
sudo_debug_exit(__func__, __FILE__, __LINE__, sudo_debug_subsys); sudoers_debug_deregister();
if (sudoers_debug_instance != SUDO_DEBUG_INSTANCE_INITIALIZER) {
sudo_debug_deregister(sudoers_debug_instance);
sudoers_debug_instance = SUDO_DEBUG_INSTANCE_INITIALIZER;
}
return; return;
} }

View File

@@ -348,7 +348,8 @@ void sudoers_cleanup(void);
/* sudoers_debug.c */ /* sudoers_debug.c */
void sudoers_debug_parse_flags(struct sudo_conf_debug_file_list *debug_files, const char *entry); 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; extern int sudoers_debug_instance;
/* policy.c */ /* policy.c */

View File

@@ -110,8 +110,8 @@ sudoers_debug_parse_flags(struct sudo_conf_debug_file_list *debug_files,
* debug subsystem, freeing the debug list when done. * debug subsystem, freeing the debug list when done.
*/ */
void void
sudoers_debug_register(struct sudo_conf_debug_file_list *debug_files, sudoers_debug_register(const char *program,
const char *program) struct sudo_conf_debug_file_list *debug_files)
{ {
struct sudo_debug_file *debug_file, *debug_next; 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;
}
}

View File

@@ -140,7 +140,7 @@ main(int argc, char *argv[])
/* Initialize the debug subsystem. */ /* Initialize the debug subsystem. */
sudo_conf_read(NULL, SUDO_CONF_DEBUG); 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; dflag = 0;
grfile = pwfile = NULL; grfile = pwfile = NULL;

View File

@@ -171,7 +171,7 @@ main(int argc, char *argv[])
/* Initialize the debug subsystem. */ /* Initialize the debug subsystem. */
sudo_conf_read(NULL, SUDO_CONF_DEBUG); 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. * Arg handling.