static void command_info_to_details(char * const info[],
struct command_details *details);
static bool gc_add(enum sudo_gc_types type, void *ptr);
-static void gc_exit(int exit_code) __attribute__((__noreturn__));
+static void gc_init(void);
/* Policy plugin convenience functions. */
static int policy_open(struct plugin_container *plugin,
case MODE_VALIDATE:
case MODE_VALIDATE|MODE_INVALIDATE:
ok = policy_validate(&policy_plugin);
- gc_exit(ok != 1);
+ exit(ok != 1);
case MODE_KILL:
case MODE_INVALIDATE:
policy_invalidate(&policy_plugin, sudo_mode == MODE_KILL);
- gc_exit(0);
+ exit(0);
break;
case MODE_CHECK:
case MODE_CHECK|MODE_INVALIDATE:
case MODE_LIST|MODE_INVALIDATE:
ok = policy_list(&policy_plugin, nargc, nargv,
ISSET(sudo_mode, MODE_LONG_LIST), list_user);
- gc_exit(ok != 1);
+ exit(ok != 1);
case MODE_EDIT:
case MODE_RUN:
ok = policy_check(&policy_plugin, nargc, nargv, env_add,
if (ok != 1) {
if (ok == -2)
usage(1);
- gc_exit(1); /* plugin printed error message */
+ exit(1); /* plugin printed error message */
}
/* Reset nargv/nargc based on argv_out. */
/* XXX - leaks old nargv in shell mode */
}
sudo_debug_exit_int(__func__, __FILE__, __LINE__, sudo_debug_subsys,
WEXITSTATUS(status));
- gc_exit(WEXITSTATUS(status));
+ exit(WEXITSTATUS(status));
}
int
#ifdef STATIC_SUDOERS_PLUGIN
preload_static_symbols();
#endif
+ gc_init();
return 0;
}
}
static void
-gc_exit(int exit_code)
+gc_cleanup(void)
{
#ifdef NO_LEAKS
struct plugin_container *plugin;
free(plugin);
}
- sudo_debug_exit_int(__func__, __FILE__, __LINE__, sudo_debug_subsys,
- exit_code);
+ debug_return;
#endif /* NO_LEAKS */
- exit(exit_code);
+}
+
+static void
+gc_init(void)
+{
+#ifdef NO_LEAKS
+ atexit(gc_cleanup);
+#endif
}