Mercurial > dovecot > core-2.2
changeset 10985:93be85bb9db8 HEAD
imap, pop3: Added -u <username> parameter to do userdb lookup.
author | Timo Sirainen <tss@iki.fi> |
---|---|
date | Thu, 25 Mar 2010 19:28:56 +0200 |
parents | 2d7b7fb99693 |
children | b218d4ec6996 |
files | src/imap/main.c src/pop3/main.c |
diffstat | 2 files changed, 34 insertions(+), 14 deletions(-) [+] |
line wrap: on
line diff
--- a/src/imap/main.c Thu Mar 25 19:25:45 2010 +0200 +++ b/src/imap/main.c Thu Mar 25 19:28:56 2010 +0200 @@ -189,7 +189,7 @@ return 0; } -static void main_stdio_run(void) +static void main_stdio_run(const char *username) { struct mail_storage_service_input input; const char *value, *error, *input_base64; @@ -197,7 +197,7 @@ memset(&input, 0, sizeof(input)); input.module = input.service = "imap"; - input.username = getenv("USER"); + input.username = username != NULL ? username : getenv("USER"); if (input.username == NULL && IS_STANDALONE()) input.username = getlogin(); if (input.username == NULL) @@ -259,7 +259,8 @@ }; enum master_service_flags service_flags = 0; enum mail_storage_service_flags storage_service_flags = 0; - const char *postlogin_socket_path; + const char *postlogin_socket_path, *username = NULL; + int c; if (IS_STANDALONE() && getuid() == 0 && net_getpeername(1, NULL, NULL) == 0) { @@ -278,9 +279,18 @@ } master_service = master_service_init("imap", service_flags, - &argc, &argv, NULL); - if (master_getopt(master_service) > 0) - return FATAL_DEFAULT; + &argc, &argv, "u:"); + while ((c = master_getopt(master_service)) > 0) { + switch (c) { + case 'u': + storage_service_flags |= + MAIL_STORAGE_SERVICE_FLAG_USERDB_LOOKUP; + username = optarg; + break; + default: + return FATAL_DEFAULT; + } + } postlogin_socket_path = argv[1] == NULL ? NULL : t_abspath(argv[1]); master_service_init_finish(master_service); @@ -300,7 +310,7 @@ if (IS_STANDALONE()) { T_BEGIN { - main_stdio_run(); + main_stdio_run(username); } T_END; } else { master_login = master_login_init(master_service, "auth-master",
--- a/src/pop3/main.c Thu Mar 25 19:25:45 2010 +0200 +++ b/src/pop3/main.c Thu Mar 25 19:28:56 2010 +0200 @@ -109,7 +109,7 @@ return 0; } -static void main_stdio_run(void) +static void main_stdio_run(const char *username) { struct mail_storage_service_input input; buffer_t *input_buf; @@ -117,7 +117,7 @@ memset(&input, 0, sizeof(input)); input.module = input.service = "pop3"; - input.username = getenv("USER"); + input.username = username != NULL ? username : getenv("USER"); if (input.username == NULL && IS_STANDALONE()) input.username = getlogin(); if (input.username == NULL) @@ -179,7 +179,8 @@ }; enum master_service_flags service_flags = 0; enum mail_storage_service_flags storage_service_flags = 0; - const char *postlogin_socket_path; + const char *postlogin_socket_path, *username = NULL; + int c; if (IS_STANDALONE() && getuid() == 0 && net_getpeername(1, NULL, NULL) == 0) { @@ -198,9 +199,18 @@ } master_service = master_service_init("pop3", service_flags, - &argc, &argv, NULL); - if (master_getopt(master_service) > 0) - return FATAL_DEFAULT; + &argc, &argv, "u:"); + while ((c = master_getopt(master_service)) > 0) { + switch (c) { + case 'u': + storage_service_flags |= + MAIL_STORAGE_SERVICE_FLAG_USERDB_LOOKUP; + username = optarg; + break; + default: + return FATAL_DEFAULT; + } + } postlogin_socket_path = argv[1] == NULL ? NULL : t_abspath(argv[1]); master_service_init_finish(master_service); @@ -216,7 +226,7 @@ if (IS_STANDALONE()) { T_BEGIN { - main_stdio_run(); + main_stdio_run(username); } T_END; } else { master_login = master_login_init(master_service, "auth-master",