From b821345cd78e0b4f08026ea9c9eff4b4a90acaa1 Mon Sep 17 00:00:00 2001 From: Ben Kibbey Date: Fri, 3 Jul 2009 17:17:57 -0400 Subject: [PATCH] Added the "debug_file" configuration parameter to log all protocol IO to the specified file. --- doc/config.example | 4 ++++ doc/pwmd.1.in | 7 ++++++- src/commands.c | 2 +- src/pwmd.c | 19 +++++++++++++++++++ 4 files changed, 30 insertions(+), 2 deletions(-) diff --git a/doc/config.example b/doc/config.example index 577dfbc0..e25a7570 100644 --- a/doc/config.example +++ b/doc/config.example @@ -32,6 +32,10 @@ # commands with any command arguments. #log_level=0 +# When set, enable protocol debugging to the specified file. Note that this +# logs all protocol IO so it may also log sensitive data. +#debug_file=~/pwmd.log + # Set to false to call mlockall(2) after a client connects. Uses alot more # memory but is also more secure. Most will probably find it overkill since # the contents of all memory is cleared before being freed. Note that this diff --git a/doc/pwmd.1.in b/doc/pwmd.1.in index 9429861b..0ec4edb3 100644 --- a/doc/pwmd.1.in +++ b/doc/pwmd.1.in @@ -15,7 +15,7 @@ \\$2 \(laURL: \\$1 \(ra\\$3 .. .if \n[.g] .mso www.tmac -.TH PWMD 1 "27 Jun 2009" "Password Manager Daemon" "Password Manager Daemon" +.TH PWMD 1 "3 Jul 2009" "Password Manager Daemon" "Password Manager Daemon" .SH NAME pwmd \- a universal data server @@ -144,6 +144,11 @@ The logging level. When \fB0\fP, only connections and errors are logged. When are also logged. The default is \fB0\fP. .TP +.I "debug_file=" +When set, enable protocol debugging to the specified file. Note that this +logs all protocol IO so it may also log sensitive data. + +.TP .I "disable_list_and_dump=" When \fBtrue\fP, the \fBXPATH\fP, \fBLIST\fP and \fBDUMP\fP protocol commands will be disabled and will return an error code. diff --git a/src/commands.c b/src/commands.c index 998fad2a..863ba1fd 100644 --- a/src/commands.c +++ b/src/commands.c @@ -1301,7 +1301,7 @@ static gint save_command(assuan_context_t ctx, gchar *line) memset(client->crypto->key, '!', hashlen); - if (get_key_file_double(client->filename, "iterations") <= 0ULL) + if (get_key_file_double(client->filename, "iterations") <= 0) goto done; if (!line || !*line) { diff --git a/src/pwmd.c b/src/pwmd.c index 14f78ef7..96f2d6d7 100644 --- a/src/pwmd.c +++ b/src/pwmd.c @@ -336,6 +336,25 @@ static gint new_connection(struct client_s *cl) if (rc) goto fail; + { + FILE *fp; + gchar *str = get_key_file_string("global", "debug_file"); + + if (str) { + gchar *f = expand_homedir(str); + + g_free(str); + fp = fopen(f, "w"); + + if (!fp) + log_write("%s: %s", f, pwmd_strerror(gpg_error_from_errno(errno))); + else + assuan_set_log_stream(cl->ctx, fp); + + g_free(f); + } + } + return 0; fail: -- 2.11.4.GIT