]> git.ipfire.org Git - thirdparty/dovecot/core.git/commitdiff
login: Keep binary-specific defaults in a struct.
authorTimo Sirainen <tss@iki.fi>
Wed, 14 Apr 2010 16:27:26 +0000 (19:27 +0300)
committerTimo Sirainen <tss@iki.fi>
Wed, 14 Apr 2010 16:27:26 +0000 (19:27 +0300)
--HG--
branch : HEAD

src/imap-login/client.c
src/login-common/client-common-auth.c
src/login-common/client-common.c
src/login-common/login-common.h
src/login-common/login-settings.c
src/login-common/main.c
src/login-common/sasl-server.c
src/pop3-login/client.c

index 1f1ca319700d9b854862b839f6da111318a90fc3..85a8becde834be2f73e50aeca786c6fe94090d13 100644 (file)
 /* Disconnect client when it sends too many bad commands */
 #define CLIENT_MAX_BAD_COMMANDS 10
 
-const char *login_protocol = "imap";
-const char *login_process_name = "imap-login";
-unsigned int login_default_port = 143, login_default_ssl_port = 993;
+const struct login_binary login_binary = {
+       .protocol = "imap",
+       .process_name = "imap-login",
+       .default_port = 143,
+       .default_ssl_port = 993
+};
 
 void login_process_preinit(void)
 {
index 918b750fa33a554086cf3fa29b12d01f9ecb1146..515bed4f4cbcabee346598aee112fa9999b6590b 100644 (file)
@@ -92,8 +92,10 @@ static void client_auth_parse_args(struct client *client,
                else if (strcmp(key, "ssl") == 0) {
                        if (strcmp(value, "yes") == 0) {
                                reply_r->ssl_flags |= PROXY_SSL_FLAG_YES;
-                               if (reply_r->port == 0)
-                                       reply_r->port = login_default_ssl_port;
+                               if (reply_r->port == 0) {
+                                       reply_r->port =
+                                               login_binary.default_ssl_port;
+                               }
                        } else if (strcmp(value, "any-cert") == 0) {
                                reply_r->ssl_flags |= PROXY_SSL_FLAG_YES |
                                        PROXY_SSL_FLAG_ANY_CERT;
@@ -106,7 +108,7 @@ static void client_auth_parse_args(struct client *client,
                        i_debug("Ignoring unknown passdb extra field: %s", key);
        }
        if (reply_r->port == 0)
-               reply_r->port = login_default_port;
+               reply_r->port = login_binary.default_port;
 
        if (reply_r->destuser == NULL)
                reply_r->destuser = client->virtual_user;
@@ -472,7 +474,7 @@ int client_auth_begin(struct client *client, const char *mech_name,
 
        client_ref(client);
        client->auth_initializing = TRUE;
-       sasl_server_auth_begin(client, login_protocol, mech_name,
+       sasl_server_auth_begin(client, login_binary.protocol, mech_name,
                               init_resp, sasl_callback);
        client->auth_initializing = FALSE;
        if (!client->authenticating)
index 2cce52e73a1525f9dfccc3d491399192bbf646b3..d045d82d803f3c45087dae7c7284658011b81c74 100644 (file)
@@ -369,7 +369,7 @@ get_var_expand_table(struct client *client)
                for (i = 0; i < 3; i++)
                        tab[i].value = str_sanitize(tab[i].value, 80);
        }
-       tab[3].value = login_protocol;
+       tab[3].value = login_binary.protocol;
        tab[4].value = getenv("HOME");
        tab[5].value = net_ip2addr(&client->local_ip);
        tab[6].value = net_ip2addr(&client->ip);
index e2601fe5a2ee4dfd74b02be96843bf60cc876086..6e6caddaebb2f6961134cc6d69b2ffa7095a25ec 100644 (file)
 #define AUTH_PLAINTEXT_DISABLED_MSG \
        "Plaintext authentication disallowed on non-secure (SSL/TLS) connections."
 
-extern const char *login_protocol, *login_process_name;
-extern unsigned int login_default_port, login_default_ssl_port;
-
+struct login_binary {
+       /* e.g. imap, pop3 */
+       const char *protocol;
+       /* e.g. imap-login, pop3-login */
+       const char *process_name;
+
+       /* e.g. 143, 110 */
+       unsigned int default_port;
+       /* e.g. 993, 995. if there is no ssl port, use 0. */
+       unsigned int default_ssl_port;
+};
+
+extern const struct login_binary login_binary;
 extern struct auth_client *auth_client;
 extern struct master_auth *master_auth;
 extern bool closing_down;
index 163189e59818fd0aec567e6e288479df10eda73d..ea98414930e33ba3125119d3c4a197534520c59c 100644 (file)
@@ -192,8 +192,8 @@ login_settings_read(pool_t pool,
 
        memset(&input, 0, sizeof(input));
        input.roots = login_set_roots;
-       input.module = login_process_name;
-       input.service = login_protocol;
+       input.module = login_binary.process_name;
+       input.service = login_binary.protocol;
        input.local_host = local_host;
 
        if (local_ip != NULL)
index ae73873c6a117509ddbeb1854c6007c06fc7c5a3..e93cea09af4a96d96dc714ceb25c4fdd990a34f9 100644 (file)
@@ -182,8 +182,8 @@ static void login_access_lookup_next(struct login_access_lookup *lookup)
                return;
        }
        lookup->access = access_lookup(*lookup->next_socket, lookup->conn.fd,
-                                      login_protocol, login_access_callback,
-                                      lookup);
+                                      login_binary.protocol,
+                                      login_access_callback, lookup);
        if (lookup->access == NULL)
                login_access_lookup_free(lookup);
 }
@@ -299,7 +299,7 @@ static void main_init(void)
 
        auth_client = auth_client_init("auth", (unsigned int)getpid(), FALSE);
         auth_client_set_connect_notify(auth_client, auth_connect_notify, NULL);
-       master_auth = master_auth_init(master_service, login_protocol);
+       master_auth = master_auth_init(master_service, login_binary.protocol);
 
        clients_init();
        login_proxy_init();
@@ -330,10 +330,10 @@ int main(int argc, char *argv[])
        bool allow_core_dumps = FALSE;
        int c;
 
-       master_service = master_service_init(login_process_name, service_flags,
-                                            &argc, &argv, "DS");
+       master_service = master_service_init(login_binary.process_name,
+                                            service_flags, &argc, &argv, "DS");
        master_service_init_log(master_service, t_strconcat(
-               login_process_name, ": ", NULL));
+               login_binary.process_name, ": ", NULL));
 
        while ((c = master_getopt(master_service)) > 0) {
                switch (c) {
index 7ea18e9ea4e55080097deeac32cc6ff4ce844721..2c4c49a23f816db7fba052c45b1fd449bf10df29 100644 (file)
@@ -183,7 +183,7 @@ anvil_check_too_many_connections(struct client *client,
                return;
        }
 
-       query = t_strconcat("LOOKUP\t", login_protocol, "/",
+       query = t_strconcat("LOOKUP\t", login_binary.protocol, "/",
                            net_ip2addr(&client->ip), "/",
                            str_tabescape(client->virtual_user), NULL);
        anvil_client_query(anvil, query, anvil_lookup_callback, req);
index 025ff305de528095be45504dbd8c492cc5040104..1968659d18c884d468c3312524fb1b34bf317ec3 100644 (file)
 /* Disconnect client when it sends too many bad commands */
 #define CLIENT_MAX_BAD_COMMANDS 10
 
-const char *login_protocol = "pop3";
-const char *login_process_name = "pop3-login";
-unsigned int login_default_port = 110, login_default_ssl_port = 995;
+const struct login_binary login_binary = {
+       .protocol = "pop3",
+       .process_name = "pop3-login",
+       .default_port = 110,
+       .default_ssl_port = 995
+};
 
 void login_process_preinit(void)
 {