Set debug instance for standalone programs.

This commit is contained in:
Todd C. Miller
2014-10-23 09:40:36 -06:00
parent 1ca52382a4
commit fe9e035ccf
4 changed files with 30 additions and 14 deletions

View File

@@ -51,6 +51,8 @@
__dso_public int main(int argc, char *argv[], char *envp[]);
int sudo_debug_instance = SUDO_DEBUG_INSTANCE_INITIALIZER;
static int sesh_sudoedit(int argc, char *argv[]);
/*
@@ -66,7 +68,7 @@ int
main(int argc, char *argv[], char *envp[])
{
int ret;
debug_decl(main, SUDO_DEBUG_MAIN, sudo_debug_instance, SUDO_DEBUG_INSTANCE_DEFAULT)
debug_decl(main, SUDO_DEBUG_MAIN, sudo_debug_instance)
initprogname(argc > 0 ? argv[0] : "sesh");
@@ -80,6 +82,9 @@ main(int argc, char *argv[], char *envp[])
/* Read sudo.conf. */
sudo_conf_read(NULL);
/* Set debug instance to use (if configured). */
sudo_debug_instance = sudo_debug_get_instance(getprogname());
if (strcmp(argv[1], "-e") == 0) {
ret = sesh_sudoedit(argc, argv);
} else {
@@ -121,7 +126,7 @@ sesh_sudoedit(int argc, char *argv[])
struct stat sb;
struct timeval times[2];
char buf[BUFSIZ];
debug_decl(sesh_sudoedit, SUDO_DEBUG_MAIN)
debug_decl(sesh_sudoedit, SUDO_DEBUG_EDIT, sudo_debug_instance)
if (argc < 3)
debug_return_int(SESH_ERR_FAILURE);