Mercurial > dovecot > original-hg > dovecot-1.2
changeset 2674:857f5f7b512b HEAD
Added login_greeting and login_greeting_capability settings.
author | Timo Sirainen <tss@iki.fi> |
---|---|
date | Mon, 27 Sep 2004 18:58:56 +0300 |
parents | 5f2c5b65b0cd |
children | 60d33cf81c8e |
files | dovecot-example.conf src/imap-login/client.c src/login-common/common.h src/login-common/main.c src/master/login-process.c src/master/master-settings.c src/master/master-settings.h src/pop3-login/client.c |
diffstat | 8 files changed, 48 insertions(+), 13 deletions(-) [+] |
line wrap: on
line diff
--- a/dovecot-example.conf Mon Sep 27 14:58:49 2004 +0300 +++ b/dovecot-example.conf Mon Sep 27 18:58:56 2004 +0300 @@ -122,6 +122,8 @@ # logging in actually login_processes_count * max_logging_users. #login_max_logging_users = 256 +# Greeting message for clients. +#login_greeting = Dovecot ready. ## ## Mail processes @@ -388,6 +390,11 @@ #mail_use_modules = no #mail_modules = /usr/lib/dovecot/imap + # Send IMAP capabilities in greeting message. This makes it unnecessary for + # clients to request it with CAPABILITY command, so it saves one round-trip. + # Many clients however don't understand it and ask the CAPABILITY anyway. + #login_greeting_capability = no + # Workarounds for various client bugs: # oe6-fetch-no-newmail: # Never send EXISTS/RECENT when replying to FETCH command. Outlook Express
--- a/src/imap-login/client.c Mon Sep 27 14:58:49 2004 +0300 +++ b/src/imap-login/client.c Mon Sep 27 18:58:56 2004 +0300 @@ -8,6 +8,7 @@ #include "ostream.h" #include "process-title.h" #include "safe-memset.h" +#include "str.h" #include "strescape.h" #include "imap-parser.h" #include "client.h" @@ -88,17 +89,21 @@ return FALSE; } -static int cmd_capability(struct imap_client *client) +static const char *get_capability(struct imap_client *client) { - const char *capability, *auths; + const char *auths; auths = client_authenticate_get_capabilities(client->secured); - capability = t_strconcat("* CAPABILITY " CAPABILITY_STRING, - (ssl_initialized && !client->tls) ? - " STARTTLS" : "", - disable_plaintext_auth && !client->secured ? - " LOGINDISABLED" : "", auths, NULL); - client_send_line(client, capability); + return t_strconcat(CAPABILITY_STRING, + (ssl_initialized && !client->tls) ? " STARTTLS" : "", + disable_plaintext_auth && !client->secured ? + " LOGINDISABLED" : "", auths, NULL); +} + +static int cmd_capability(struct imap_client *client) +{ + client_send_line(client, t_strconcat("* CAPABILITY ", + get_capability(client), NULL)); client_send_tagline(client, "OK Capability completed."); return TRUE; } @@ -377,6 +382,7 @@ { struct imap_client *client; const char *addr; + string_t *greet; if (max_logging_users > CLIENT_DESTROY_OLDEST_COUNT && hash_size(clients) >= max_logging_users) { @@ -410,7 +416,13 @@ main_ref(); - client_send_line(client, "* OK " PACKAGE " ready."); + greet = t_str_new(128); + str_append(greet, "* OK "); + if (greeting_capability) + str_printfa(greet, "[CAPABILITY %s] ", get_capability(client)); + str_append(greet, greeting); + + client_send_line(client, str_c(greet)); client_set_title(client); return &client->common; }
--- a/src/login-common/common.h Mon Sep 27 14:58:49 2004 +0300 +++ b/src/login-common/common.h Mon Sep 27 18:58:56 2004 +0300 @@ -4,7 +4,8 @@ #include "lib.h" extern int disable_plaintext_auth, process_per_connection, verbose_proctitle; -extern int verbose_ssl; +extern int verbose_ssl, greeting_capability; +char *greeting; extern unsigned int max_logging_users; extern unsigned int login_process_uid; extern struct auth_client *auth_client;
--- a/src/login-common/main.c Mon Sep 27 14:58:49 2004 +0300 +++ b/src/login-common/main.c Mon Sep 27 18:58:56 2004 +0300 @@ -18,7 +18,8 @@ #include <syslog.h> int disable_plaintext_auth, process_per_connection, verbose_proctitle; -int verbose_ssl; +int verbose_ssl, greeting_capability; +char *greeting; unsigned int max_logging_users; unsigned int login_process_uid; struct auth_client *auth_client; @@ -162,6 +163,11 @@ value = getenv("MAX_LOGGING_USERS"); max_logging_users = value == NULL ? 0 : strtoul(value, NULL, 10); + greeting = getenv("GREETING"); + if (greeting == NULL) + greeting = PACKAGE" ready."; + greeting_capability = getenv("GREETING_CAPABILITY") != NULL; + value = getenv("PROCESS_UID"); if (value == NULL) i_fatal("BUG: PROCESS_UID environment not given");
--- a/src/master/login-process.c Mon Sep 27 14:58:49 2004 +0300 +++ b/src/master/login-process.c Mon Sep 27 18:58:56 2004 +0300 @@ -428,7 +428,10 @@ set->login_max_logging_users)); } - env_put(t_strdup_printf("PROCESS_UID=%s", dec2str(pid))); + env_put(t_strconcat("PROCESS_UID=", dec2str(pid), NULL)); + env_put(t_strconcat("GREETING=", set->login_greeting, NULL)); + if (set->login_greeting_capability) + env_put("GREETING_CAPABILITY=1"); } static pid_t create_login_process(struct login_group *group)
--- a/src/master/master-settings.c Mon Sep 27 14:58:49 2004 +0300 +++ b/src/master/master-settings.c Mon Sep 27 18:58:56 2004 +0300 @@ -64,9 +64,11 @@ DEF(SET_STR, login_dir), DEF(SET_STR, login_executable), DEF(SET_STR, login_user), + DEF(SET_STR, login_greeting), DEF(SET_BOOL, login_process_per_connection), DEF(SET_BOOL, login_chroot), + DEF(SET_BOOL, login_greeting_capability), DEF(SET_INT, login_process_size), DEF(SET_INT, login_processes_count), @@ -227,9 +229,11 @@ MEMBER(login_dir) "login", MEMBER(login_executable) NULL, MEMBER(login_user) "dovecot", + MEMBER(login_greeting) "Dovecot ready.", MEMBER(login_process_per_connection) TRUE, MEMBER(login_chroot) TRUE, + MEMBER(login_greeting_capability) FALSE, MEMBER(login_process_size) 32, MEMBER(login_processes_count) 3,
--- a/src/master/master-settings.h Mon Sep 27 14:58:49 2004 +0300 +++ b/src/master/master-settings.h Mon Sep 27 18:58:56 2004 +0300 @@ -37,9 +37,11 @@ const char *login_dir; const char *login_executable; const char *login_user; + const char *login_greeting; int login_process_per_connection; int login_chroot; + int login_greeting_capability; unsigned int login_process_size; unsigned int login_processes_count;
--- a/src/pop3-login/client.c Mon Sep 27 14:58:49 2004 +0300 +++ b/src/pop3-login/client.c Mon Sep 27 18:58:56 2004 +0300 @@ -286,7 +286,7 @@ io_add(client->common.fd, IO_READ, client_input, client); client->apop_challenge = get_apop_challenge(client); - client_send_line(client, t_strconcat("+OK " PACKAGE " ready.", + client_send_line(client, t_strconcat("+OK ", greeting, client->apop_challenge, NULL)); }