]> git.ipfire.org Git - thirdparty/dovecot/core.git/commitdiff
auth: Pass local_name to auth-request
authorAki Tuomi <aki.tuomi@dovecot.fi>
Mon, 17 Oct 2016 21:37:32 +0000 (00:37 +0300)
committerTimo Sirainen <timo.sirainen@dovecot.fi>
Thu, 20 Oct 2016 20:04:40 +0000 (23:04 +0300)
This allows using local_name in various places,
such as passdb/userdb queries.

src/auth/auth-request-var-expand.c
src/auth/auth-request-var-expand.h
src/auth/auth-request.c
src/auth/auth-request.h
src/lib-auth/auth-client-request.c
src/lib-auth/auth-client.h
src/login-common/client-common.h
src/login-common/login-settings.c
src/login-common/sasl-server.c
src/login-common/ssl-proxy-openssl.c

index b805b02b98218668aa2473fafcad1cc29083804f..4f256c06850ade4559d10e80a6df5bf011a88295 100644 (file)
@@ -45,6 +45,7 @@ auth_request_var_expand_static_tab[AUTH_REQUEST_VAR_TAB_COUNT+1] = {
        { '\0', NULL, "auth_user" },
        { '\0', NULL, "auth_username" },
        { '\0', NULL, "auth_domain" },
+       { '\0', NULL, "local_name" },
        /* be sure to update AUTH_REQUEST_VAR_TAB_COUNT */
        { '\0', NULL, NULL }
 };
@@ -167,6 +168,10 @@ auth_request_get_var_expand_table_full(const struct auth_request *auth_request,
        tab[32].value = strchr(auth_user, '@');
        if (tab[32].value != NULL)
                tab[32].value = escape_func(tab[32].value+1, auth_request);
+       if (auth_request->local_name != NULL)
+               tab[33].value = escape_func(auth_request->local_name, auth_request);
+       else
+               tab[33].value = "";
        return ret_tab;
 }
 
index a7cafdd8028498ebff5d3b036e2a480146fef7bd..0d228daad2fa4308636aa248b4fc5360abd6ead3 100644 (file)
@@ -8,7 +8,7 @@ auth_request_escape_func_t(const char *string,
 #define AUTH_REQUEST_VAR_TAB_USER_IDX 0
 #define AUTH_REQUEST_VAR_TAB_USERNAME_IDX 1
 #define AUTH_REQUEST_VAR_TAB_DOMAIN_IDX 2
-#define AUTH_REQUEST_VAR_TAB_COUNT 33
+#define AUTH_REQUEST_VAR_TAB_COUNT 34
 extern const struct var_expand_table
 auth_request_var_expand_static_tab[AUTH_REQUEST_VAR_TAB_COUNT+1];
 
index e170da0c2b5ffcf475d3c9a0b3f54a858d7b8800..64fa69167860b006e3d5a8b18983c8a0eb107584 100644 (file)
@@ -319,6 +319,8 @@ void auth_request_export(struct auth_request *request, string_t *dest)
                str_printfa(dest, "\treal_lport=%u", request->real_local_port);
        if (request->real_remote_port != 0)
                str_printfa(dest, "\treal_rport=%u", request->real_remote_port);
+       if (request->local_name != 0)
+               str_printfa(dest, "\tlocal_name=%s", request->local_name);
        if (request->session_id != NULL)
                str_printfa(dest, "\tsession=%s", request->session_id);
        if (request->debug)
@@ -377,6 +379,8 @@ bool auth_request_import_info(struct auth_request *request,
                (void)net_str2port(value, &request->real_local_port);
        else if (strcmp(key, "real_rport") == 0)
                (void)net_str2port(value, &request->real_remote_port);
+       else if (strcmp(key, "local_name") == 0)
+               request->local_name = p_strdup(request->pool, value);
        else if (strcmp(key, "session") == 0)
                request->session_id = p_strdup(request->pool, value);
        else if (strcmp(key, "debug") == 0)
index 51f34c245b913236fb8414d3bc2ee9c727ea11d9..3d053f58a4b005b474a07d7eaf602c36b82e97e0 100644 (file)
@@ -74,7 +74,7 @@ struct auth_request {
        time_t delay_until;
        pid_t session_pid;
 
-       const char *service, *mech_name, *session_id;
+       const char *service, *mech_name, *session_id, *local_name;
        struct ip_addr local_ip, remote_ip, real_local_ip, real_remote_ip;
        in_port_t local_port, remote_port, real_local_port, real_remote_port;
 
index fde65bf5a8b1125395a9209faf9232af09ec1997..968dc98e8f58e5ec018551ef7276282b3389ece6 100644 (file)
@@ -80,7 +80,9 @@ static void auth_server_send_new_request(struct auth_server_connection *conn,
        if (info->real_remote_port != 0 &&
            info->real_remote_port != info->remote_port)
                str_printfa(str, "\treal_rport=%u", info->real_remote_port);
-
+       if (info->local_name != NULL &&
+           *info->local_name != '\0')
+               str_printfa(str, "\tlocal_name=%s", info->local_name);
        if (info->initial_resp_base64 != NULL) {
                str_append(str, "\tresp=");
                str_append_tabescaped(str, info->initial_resp_base64);
index 59cf3d46d93f84d3be36235f67475e3adc295cf8..45b346bb016e99146bb758244b243ea399b97ee9 100644 (file)
@@ -41,6 +41,7 @@ struct auth_request_info {
        const char *service;
        const char *session_id;
        const char *cert_username;
+       const char *local_name;
        enum auth_request_flags flags;
 
        struct ip_addr local_ip, remote_ip, real_local_ip, real_remote_ip;
index 2978adcbae4578a7b3dde490deaf0fe4bb4f616a..d37ca917c130455864677a43191272f759991ec6 100644 (file)
@@ -117,6 +117,7 @@ struct client {
        const struct login_settings *set;
        const struct master_service_ssl_settings *ssl_set;
        const char *session_id, *listener_name, *postlogin_socket_path;
+       const char *local_name;
 
        int fd;
        struct istream *input;
index f8945f1694e8898b424a88141588155cbd3ce8c9..73a8a7270e1d0e21b9df13a7fd9a18b7e2bbbd09 100644 (file)
@@ -120,6 +120,7 @@ login_set_var_expand_table(const struct master_service_settings_input *input)
                { 'r', NULL, "rip" },
                { 'p', NULL, "pid" },
                { 's', NULL, "service" },
+               { '\0', NULL, "local_name" },
                { '\0', NULL, NULL }
        };
        struct var_expand_table *tab;
@@ -131,6 +132,7 @@ login_set_var_expand_table(const struct master_service_settings_input *input)
        tab[1].value = net_ip2addr(&input->remote_ip);
        tab[2].value = my_pid;
        tab[3].value = input->service;
+       tab[4].value = input->local_name;
        return tab;
 }
 
index 49a3c59aed415d0594451881d639b575e07e5c30..5f1ffcd8790cb6072ee54364d35db5716bd44aef 100644 (file)
@@ -364,6 +364,7 @@ void sasl_server_auth_begin(struct client *client,
        info.local_ip = client->local_ip;
        info.remote_ip = client->ip;
        info.local_port = client->local_port;
+       info.local_name = client->local_name;
        info.remote_port = client->remote_port;
        info.real_local_ip = client->real_local_ip;
        info.real_remote_ip = client->real_remote_ip;
index bd521cccad5a4d489943e8a3cde28f23512a63c1..577053f308a9ae34856f4640d39a992c40c466f2 100644 (file)
@@ -1226,6 +1226,7 @@ static void ssl_servername_callback(SSL *ssl, int *al ATTR_UNUSED,
                                                  &client->ssl_set,
                                                  &other_sets);
        }
+       client->local_name = p_strdup(client->pool, host);
        ctx = ssl_server_context_get(client->set, client->ssl_set);
        SSL_set_SSL_CTX(ssl, ctx->ctx);
 }