]> granicus.if.org Git - sudo/commitdiff
sudoers_debug_register() was not setting the active debug instance
authorTodd C. Miller <Todd.Miller@courtesan.com>
Mon, 31 Oct 2016 19:36:35 +0000 (13:36 -0600)
committerTodd C. Miller <Todd.Miller@courtesan.com>
Mon, 31 Oct 2016 19:36:35 +0000 (13:36 -0600)
to sudoers_debug_instance when called from the I/O log plugin.  This
is because it relied on sudo_debug_register to do that but
sudoers_debug_parse_flags() doesn't set debug_files[]
sudoers_debug_instance is already set (we can only init sudoers
debug once).

To work around this, just make sudoers_debug_instance the active
debug instance in sudoers_debug_register() when it is already set.

plugins/sudoers/sudoers_debug.c

index 3fbae4710fab589140e550f2c186070727f111f5..9de8df2fc116cd3bb3a9bbe842c15e364e1ce2ae 100644 (file)
@@ -111,6 +111,7 @@ oom:
 /*
  * Register the specified debug files and program with the
  * debug subsystem, freeing the debug list when done.
+ * Sets the active debug instance as a side effect.
  */
 void
 sudoers_debug_register(const char *program,
@@ -118,6 +119,11 @@ sudoers_debug_register(const char *program,
 {
     struct sudo_debug_file *debug_file, *debug_next;
 
+    /* Already initialized? */
+    if (sudoers_debug_instance != SUDO_DEBUG_INSTANCE_INITIALIZER) {
+       sudo_debug_set_active_instance(sudoers_debug_instance);
+    }
+
     /* Setup debugging if indicated. */
     if (debug_files != NULL && !TAILQ_EMPTY(debug_files)) {
        if (program != NULL) {