Mercurial > dovecot > core-2.2
changeset 13539:1ff636720b9f
login: Added -R <dir> parameter to write pre-login rawlogs to given directory.
author | Timo Sirainen <tss@iki.fi> |
---|---|
date | Thu, 22 Sep 2011 12:54:27 +0300 |
parents | e19a3a2d554d |
children | 00b6848a5a63 |
files | src/login-common/client-common.c src/login-common/login-common.h src/login-common/main.c |
diffstat | 3 files changed, 21 insertions(+), 1 deletions(-) [+] |
line wrap: on
line diff
--- a/src/login-common/client-common.c Thu Sep 22 01:38:34 2011 +0300 +++ b/src/login-common/client-common.c Thu Sep 22 12:54:27 2011 +0300 @@ -5,6 +5,7 @@ #include "llist.h" #include "istream.h" #include "ostream.h" +#include "iostream-rawlog.h" #include "process-title.h" #include "str.h" #include "str-sanitize.h" @@ -36,6 +37,12 @@ i_stream_create_fd(client->fd, LOGIN_MAX_INBUF_SIZE, FALSE); client->output = o_stream_create_fd(client->fd, LOGIN_MAX_OUTBUF_SIZE, FALSE); + + if (login_rawlog_dir != NULL) { + if (iostream_rawlog_create(login_rawlog_dir, &client->input, + &client->output) < 0) + login_rawlog_dir = NULL; + } } struct client *
--- a/src/login-common/login-common.h Thu Sep 22 01:38:34 2011 +0300 +++ b/src/login-common/login-common.h Thu Sep 22 12:54:27 2011 +0300 @@ -34,6 +34,7 @@ extern struct master_auth *master_auth; extern bool closing_down; extern struct anvil_client *anvil; +extern const char *login_rawlog_dir; extern const struct login_settings *global_login_settings; extern void **global_other_settings;
--- a/src/login-common/main.c Thu Sep 22 01:38:34 2011 +0300 +++ b/src/login-common/main.c Thu Sep 22 12:54:27 2011 +0300 @@ -36,6 +36,7 @@ struct master_auth *master_auth; bool closing_down; struct anvil_client *anvil; +const char *login_rawlog_dir = NULL; const struct login_settings *global_login_settings; void **global_other_settings; @@ -297,6 +298,13 @@ i_fatal("chdir(login) failed: %m"); } + if (login_rawlog_dir != NULL && + access(login_rawlog_dir, W_OK | X_OK) < 0) { + i_error("access(%s, wx) failed: %m - disabling rawlog", + login_rawlog_dir); + login_rawlog_dir = NULL; + } + master_service_set_avail_overflow_callback(master_service, client_destroy_oldest); master_service_set_die_callback(master_service, login_die); @@ -340,7 +348,8 @@ login_binary = binary; master_service = master_service_init(login_binary->process_name, - service_flags, &argc, &argv, "DS"); + service_flags, &argc, &argv, + "DR:S"); master_service_init_log(master_service, t_strconcat( login_binary->process_name, ": ", NULL)); @@ -349,6 +358,9 @@ case 'D': allow_core_dumps = TRUE; break; + case 'R': + login_rawlog_dir = optarg; + break; case 'S': ssl_connections = TRUE; break;