mirror of
https://git.tartarus.org/simon/putty.git
synced 2025-06-30 19:12:48 -05:00
Put proper logging into Pageant.
Now it actually logs all its requests and responses, the fingerprints of keys mentioned in all messages, and so on. I've also added the -v option, which causes Pageant in any mode to direct that logging information to standard error. In --debug mode, however, the logging output goes to standard output instead (because when debugging, that information changes from a side effect to the thing you actually wanted in the first place :-). An internal tweak: the logging functions now take a va_list rather than an actual variadic argument list, so that I can pass it through several functions.
This commit is contained in:
@ -71,18 +71,15 @@ void cmdline_error(char *p, ...)
|
||||
exit(1);
|
||||
}
|
||||
|
||||
int pageant_logging = FALSE;
|
||||
void pageant_log(void *ctx, const char *fmt, ...)
|
||||
FILE *pageant_logfp = NULL;
|
||||
void pageant_log(void *ctx, const char *fmt, va_list ap)
|
||||
{
|
||||
va_list ap;
|
||||
|
||||
if (!pageant_logging)
|
||||
if (!pageant_logfp)
|
||||
return;
|
||||
|
||||
va_start(ap, fmt);
|
||||
vfprintf(stderr, fmt, ap);
|
||||
fprintf(stderr, "\n");
|
||||
va_end(ap);
|
||||
fprintf(pageant_logfp, "pageant: ");
|
||||
vfprintf(pageant_logfp, fmt, ap);
|
||||
fprintf(pageant_logfp, "\n");
|
||||
}
|
||||
|
||||
/*
|
||||
@ -243,6 +240,8 @@ int main(int argc, char **argv)
|
||||
} else if (!strcmp(p, "--help")) {
|
||||
usage();
|
||||
exit(0);
|
||||
} else if (!strcmp(p, "-v")) {
|
||||
pageant_logfp = stderr;
|
||||
} else if (!strcmp(p, "-X")) {
|
||||
life = LIFE_X11;
|
||||
} else if (!strcmp(p, "--debug")) {
|
||||
@ -299,15 +298,6 @@ int main(int argc, char **argv)
|
||||
}
|
||||
socketname = dupprintf("%s/pageant.%d", socketdir, (int)getpid());
|
||||
|
||||
pageant_init();
|
||||
pl = pageant_listener_new(NULL, pageant_log);
|
||||
sock = new_unix_listener(unix_sock_addr(socketname), (Plug)pl);
|
||||
if ((err = sk_socket_error(sock)) != NULL) {
|
||||
fprintf(stderr, "pageant: %s: %s\n", socketname, err);
|
||||
exit(1);
|
||||
}
|
||||
pageant_listener_got_socket(pl, sock);
|
||||
|
||||
conf = conf_new();
|
||||
conf_set_int(conf, CONF_proxy_type, PROXY_NONE);
|
||||
|
||||
@ -360,7 +350,7 @@ int main(int argc, char **argv)
|
||||
pageant_fork_and_print_env();
|
||||
} else if (life == LIFE_DEBUG) {
|
||||
pageant_print_env(getpid());
|
||||
pageant_logging = TRUE;
|
||||
pageant_logfp = stdout;
|
||||
} else if (life == LIFE_EXEC) {
|
||||
pid_t agentpid, pid;
|
||||
|
||||
@ -390,6 +380,15 @@ int main(int argc, char **argv)
|
||||
}
|
||||
}
|
||||
|
||||
pageant_init();
|
||||
pl = pageant_listener_new(NULL, pageant_logfp ? pageant_log : NULL);
|
||||
sock = new_unix_listener(unix_sock_addr(socketname), (Plug)pl);
|
||||
if ((err = sk_socket_error(sock)) != NULL) {
|
||||
fprintf(stderr, "pageant: %s: %s\n", socketname, err);
|
||||
exit(1);
|
||||
}
|
||||
pageant_listener_got_socket(pl, sock);
|
||||
|
||||
now = GETTICKCOUNT();
|
||||
|
||||
while (1) {
|
||||
|
Reference in New Issue
Block a user