dovecot-2.0: imap, pop3: Added -u <username> parameter to do use...
dovecot at dovecot.org
dovecot at dovecot.org
Thu Mar 25 19:29:00 EET 2010
details: http://hg.dovecot.org/dovecot-2.0/rev/93be85bb9db8
changeset: 10985:93be85bb9db8
user: Timo Sirainen <tss at iki.fi>
date: Thu Mar 25 19:28:56 2010 +0200
description:
imap, pop3: Added -u <username> parameter to do userdb lookup.
diffstat:
src/imap/main.c | 24 +++++++++++++++++-------
src/pop3/main.c | 24 +++++++++++++++++-------
2 files changed, 34 insertions(+), 14 deletions(-)
diffs (124 lines):
diff -r 2d7b7fb99693 -r 93be85bb9db8 src/imap/main.c
--- 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",
diff -r 2d7b7fb99693 -r 93be85bb9db8 src/pop3/main.c
--- 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",
More information about the dovecot-cvs
mailing list