Only deregister the sudoers debug instance on last close.
Reference count calls to sudoers_debug_register and only deregister sudoers_debug_instance when refcnt reaches 0. Fixes a problem where the debug system was deregistered when the sudoers policy is closed even though the iolog plugin is active.
This commit is contained in:
@@ -43,6 +43,7 @@
|
|||||||
#include "sudoers.h"
|
#include "sudoers.h"
|
||||||
|
|
||||||
static int sudoers_debug_instance = SUDO_DEBUG_INSTANCE_INITIALIZER;
|
static int sudoers_debug_instance = SUDO_DEBUG_INSTANCE_INITIALIZER;
|
||||||
|
static unsigned int sudoers_debug_refcnt;
|
||||||
|
|
||||||
static const char *const sudoers_subsystem_names[] = {
|
static const char *const sudoers_subsystem_names[] = {
|
||||||
"alias",
|
"alias",
|
||||||
@@ -127,9 +128,8 @@ sudoers_debug_register(const char *program,
|
|||||||
struct sudo_debug_file *debug_file, *debug_next;
|
struct sudo_debug_file *debug_file, *debug_next;
|
||||||
|
|
||||||
/* Already initialized? */
|
/* Already initialized? */
|
||||||
if (sudoers_debug_instance != SUDO_DEBUG_INSTANCE_INITIALIZER) {
|
if (sudoers_debug_instance != SUDO_DEBUG_INSTANCE_INITIALIZER)
|
||||||
sudo_debug_set_active_instance(sudoers_debug_instance);
|
sudo_debug_set_active_instance(sudoers_debug_instance);
|
||||||
}
|
|
||||||
|
|
||||||
/* Setup debugging if indicated. */
|
/* Setup debugging if indicated. */
|
||||||
if (debug_files != NULL && !TAILQ_EMPTY(debug_files)) {
|
if (debug_files != NULL && !TAILQ_EMPTY(debug_files)) {
|
||||||
@@ -146,6 +146,7 @@ sudoers_debug_register(const char *program,
|
|||||||
free(debug_file);
|
free(debug_file);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
sudoers_debug_refcnt++;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -156,9 +157,12 @@ void
|
|||||||
sudoers_debug_deregister(void)
|
sudoers_debug_deregister(void)
|
||||||
{
|
{
|
||||||
debug_decl(sudoers_debug_deregister, SUDOERS_DEBUG_PLUGIN)
|
debug_decl(sudoers_debug_deregister, SUDOERS_DEBUG_PLUGIN)
|
||||||
if (sudoers_debug_instance != SUDO_DEBUG_INSTANCE_INITIALIZER) {
|
|
||||||
|
if (sudoers_debug_refcnt != 0) {
|
||||||
sudo_debug_exit(__func__, __FILE__, __LINE__, sudo_debug_subsys);
|
sudo_debug_exit(__func__, __FILE__, __LINE__, sudo_debug_subsys);
|
||||||
sudo_debug_deregister(sudoers_debug_instance);
|
if (--sudoers_debug_refcnt == 0) {
|
||||||
sudoers_debug_instance = SUDO_DEBUG_INSTANCE_INITIALIZER;
|
if (sudo_debug_deregister(sudoers_debug_instance) < 1)
|
||||||
|
sudoers_debug_instance = SUDO_DEBUG_INSTANCE_INITIALIZER;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user