]> git.ipfire.org Git - thirdparty/dovecot/core.git/commitdiff
auth: Rename service settings lookup functions/variables to protocol settings
authorTimo Sirainen <timo.sirainen@open-xchange.com>
Sat, 24 Jun 2023 20:09:50 +0000 (23:09 +0300)
committerAki Tuomi <aki.tuomi@open-xchange.com>
Wed, 12 Feb 2025 10:34:09 +0000 (12:34 +0200)
They already were using protocol name { .. } settings, so it's more correct
to call them "protocol" internally as well.

src/auth/auth-request-handler.c
src/auth/auth-request.c
src/auth/auth-settings.c
src/auth/auth-settings.h
src/auth/auth.c
src/auth/auth.h
src/auth/main.c
src/auth/test-auth-client.c
src/auth/test-auth-master-server.c
src/auth/test-mech.c

index 0a3f18a310bf614aa939d0fc29927dbe77910436..f4caf7faccfa98151eef0543790d1499dad5433f 100644 (file)
@@ -549,7 +549,7 @@ int auth_request_handler_auth_begin(struct auth_request_handler *handler,
                        return -1;
                }
        } else {
-               struct auth *auth_default = auth_default_service();
+               struct auth *auth_default = auth_default_protocol();
                mech = mech_register_find(auth_default->reg, args[1]);
                if (mech == NULL) {
                        /* unsupported mechanism */
index effa1b46af7d4992975fbae59ba800cb1fa41011..efa2a1b28bfc8e3f728eadc2be273d659a5a6eb4 100644 (file)
@@ -214,7 +214,7 @@ void auth_request_init(struct auth_request *request)
 
 struct auth *auth_request_get_auth(struct auth_request *request)
 {
-       return auth_find_service(request->fields.service);
+       return auth_find_protocol(request->fields.service);
 }
 
 void auth_request_success(struct auth_request *request,
@@ -2307,7 +2307,7 @@ auth_request_proxy_host_lookup(struct auth_request *request,
                               const char *host,
                               auth_request_proxy_cb_t *callback)
 {
-       struct auth *auth = auth_default_service();
+       struct auth *auth = auth_default_protocol();
        struct event *proxy_event;
        struct auth_request_proxy_dns_lookup_ctx *ctx;
        const char *value;
index 6fa2db2778d9700bf0d4c42e085e56d12f65cd52..348215653ca59d0d5f33b6be26fd446c02e21364 100644 (file)
@@ -573,10 +573,10 @@ void auth_settings_read(struct master_service_settings_output *output_r)
                i_fatal("%s", error);
 }
 
-const struct auth_settings *auth_settings_get(const char *service)
+const struct auth_settings *auth_settings_get(const char *protocol)
 {
        struct event *event = event_create(NULL);
-       event_add_str(event, "protocol", service);
+       event_add_str(event, "protocol", protocol);
        const struct auth_settings *set =
                settings_get_or_fatal(event, &auth_setting_parser_info);
        event_unref(&event);
index 5afbf976c835d6642a8b5771ae8e39cc88d35063..2b85c42e3d5b5e650db71d33c66d99785b8e4bed 100644 (file)
@@ -107,6 +107,6 @@ extern const struct setting_parser_info auth_setting_parser_info;
 extern const struct auth_settings *global_auth_settings;
 
 void auth_settings_read(struct master_service_settings_output *output_r);
-const struct auth_settings *auth_settings_get(const char *service);
+const struct auth_settings *auth_settings_get(const char *protocol);
 
 #endif
index 60882f9a307464d3c0c09a530aec22d44c0354ab..24181b10e8b1bef3896cca2416a48b2a4e3205b5 100644 (file)
@@ -253,7 +253,7 @@ static void auth_mech_list_verify_passdb(const struct auth *auth)
 }
 
 static struct auth * ATTR_NULL(2)
-auth_preinit(const struct auth_settings *set, const char *service,
+auth_preinit(const struct auth_settings *set, const char *protocol,
             const struct mechanisms_register *reg)
 {
        const struct auth_passdb_settings *const *passdbs;
@@ -264,7 +264,7 @@ auth_preinit(const struct auth_settings *set, const char *service,
        pool_t pool = pool_alloconly_create("auth", 128);
        auth = p_new(pool, struct auth, 1);
        auth->pool = pool;
-       auth->service = p_strdup(pool, service);
+       auth->protocol = p_strdup(pool, protocol);
        auth->set = set;
        pool_ref(set->pool);
        auth->reg = reg;
@@ -371,7 +371,7 @@ static void auth_deinit(struct auth *auth)
        dns_client_deinit(&auth->dns_client);
 }
 
-struct auth *auth_find_service(const char *name)
+struct auth *auth_find_protocol(const char *name)
 {
        struct auth *const *a;
        unsigned int i, count;
@@ -379,20 +379,20 @@ struct auth *auth_find_service(const char *name)
        a = array_get(&auths, &count);
        if (name != NULL) {
                for (i = 1; i < count; i++) {
-                       if (strcmp(a[i]->service, name) == 0)
+                       if (strcmp(a[i]->protocol, name) == 0)
                                return a[i];
                }
-               /* not found. maybe we can instead find a !service */
+               /* not found. maybe we can instead find a !protocol */
                for (i = 1; i < count; i++) {
-                       if (a[i]->service[0] == '!' &&
-                           strcmp(a[i]->service + 1, name) != 0)
+                       if (a[i]->protocol[0] == '!' &&
+                           strcmp(a[i]->protocol + 1, name) != 0)
                                return a[i];
                }
        }
        return a[0];
 }
 
-struct auth *auth_default_service(void)
+struct auth *auth_default_protocol(void)
 {
        struct auth *const *a;
        unsigned int count;
@@ -403,12 +403,12 @@ struct auth *auth_default_service(void)
 
 void auths_preinit(const struct auth_settings *set,
                   const struct mechanisms_register *reg,
-                  const char *const *services)
+                  const char *const *protocols)
 {
-       const struct auth_settings *service_set;
+       const struct auth_settings *protocol_set;
        struct auth *auth;
        unsigned int i;
-       const char *not_service = NULL;
+       const char *not_protocol = NULL;
        bool check_default = TRUE;
 
        auth_event = event_create(NULL);
@@ -419,26 +419,26 @@ void auths_preinit(const struct auth_settings *set,
        auth = auth_preinit(set, NULL, reg);
        array_push_back(&auths, &auth);
 
-       for (i = 0; services[i] != NULL; i++) {
-               if (services[i][0] == '!') {
-                       if (not_service != NULL) {
-                               i_fatal("Can't have multiple protocol "
-                                       "!services (seen %s and %s)",
-                                       not_service, services[i]);
+       for (i = 0; protocols[i] != NULL; i++) {
+               if (protocols[i][0] == '!') {
+                       if (not_protocol != NULL) {
+                               i_fatal("Can't have multiple !protocols "
+                                       "(seen %s and %s)",
+                                       not_protocol, protocols[i]);
                        }
-                       not_service = services[i];
+                       not_protocol = protocols[i];
                }
-               service_set = auth_settings_get(services[i]);
-               auth = auth_preinit(service_set, services[i], reg);
+               protocol_set = auth_settings_get(protocols[i]);
+               auth = auth_preinit(protocol_set, protocols[i], reg);
                array_push_back(&auths, &auth);
-               settings_free(service_set);
+               settings_free(protocol_set);
        }
 
-       if (not_service != NULL && str_array_find(services, not_service+1))
+       if (not_protocol != NULL && str_array_find(protocols, not_protocol+1))
                check_default = FALSE;
 
        array_foreach_elem(&auths, auth) {
-               if (auth->service != NULL || check_default)
+               if (auth->protocol != NULL || check_default)
                        auth_mech_list_verify_passdb(auth);
        }
 }
index 0af4038888f987682779fae1691f19fa5ae5aa01..963ee6ec040b4f44682de5aab4d886eba64ddd04 100644 (file)
@@ -72,7 +72,7 @@ struct auth_userdb {
 
 struct auth {
        pool_t pool;
-       const char *service;
+       const char *protocol;
        const struct auth_settings *set;
 
        const struct mechanisms_register *reg;
@@ -84,12 +84,12 @@ struct auth {
 };
 
 
-struct auth *auth_find_service(const char *name);
-struct auth *auth_default_service(void);
+struct auth *auth_find_protocol(const char *name);
+struct auth *auth_default_protocol(void);
 
 void auths_preinit(const struct auth_settings *set,
                   const struct mechanisms_register *reg,
-                  const char *const *services);
+                  const char *const *protocols);
 void auths_init(void);
 void auths_deinit(void);
 void auths_free(void);
index 9c12e16177908b30e3caf67624d4468a8ea05240..1020c9cda600016386df74d547bc7e8680d9c50b 100644 (file)
@@ -150,7 +150,7 @@ static bool auth_module_filter(const char *name, void *context ATTR_UNUSED)
 static void main_preinit(void)
 {
        struct module_dir_load_settings mod_set;
-       const char *const *services;
+       const char *const *protocols;
 
        /* Load built-in SQL drivers (if any) */
        sql_drivers_init();
@@ -163,7 +163,7 @@ static void main_preinit(void)
        /* init schemes before plugins are loaded */
        password_schemes_init();
 
-       services = read_global_settings();
+       protocols = read_global_settings();
 
        i_zero(&mod_set);
        mod_set.abi_version = DOVECOT_ABI_VERSION;
@@ -179,7 +179,7 @@ static void main_preinit(void)
        mech_init(global_auth_settings);
        mech_reg = mech_register_init(global_auth_settings);
        dict_drivers_register_builtin();
-       auths_preinit(global_auth_settings, mech_reg, services);
+       auths_preinit(global_auth_settings, mech_reg, protocols);
 
        listeners_init();
        if (!worker)
@@ -299,7 +299,7 @@ static void worker_connected(struct master_service_connection *conn)
        }
 
        master_service_client_connection_accept(conn);
-       (void)auth_worker_server_create(auth_default_service(), conn);
+       (void)auth_worker_server_create(auth_default_protocol(), conn);
 }
 
 static void client_connected(struct master_service_connection *conn)
@@ -313,7 +313,7 @@ static void client_connected(struct master_service_connection *conn)
                l->path = i_strdup(conn->name);
 
        type = master_service_connection_get_type(conn);
-       auth = auth_default_service();
+       auth = auth_default_protocol();
        switch (auth_socket_type_get(type)) {
        case AUTH_SOCKET_MASTER:
                (void)auth_master_connection_create(auth, conn->fd,
index 2254d208f2aa18876bbc697d375f3e71a353d27b..6229e4d6f3c7022dd58e26d2707e4c12a49a37f9 100644 (file)
@@ -12,7 +12,7 @@
 
 static void auth_client_connected(int *server_fd)
 {
-       struct auth *auth = auth_default_service();
+       struct auth *auth = auth_default_protocol();
        int fd = net_accept(*server_fd, NULL, NULL);
        auth_client_connection_create(auth, fd, TEST_AUTH_CLIENT_SOCKET, FALSE, FALSE);
 }
index d33a2a6afb988c155bb48816f949ebe10b883bd1..790bed705698d01184c54801fefffdcdfb1d7b7a 100644 (file)
@@ -12,7 +12,7 @@ void auth_master_server_connected(int *server_fd, const char *socket)
 {
        struct stat st;
        i_zero(&st);
-       struct auth *auth = auth_default_service();
+       struct auth *auth = auth_default_protocol();
        int fd = net_accept(*server_fd, NULL, NULL);
        i_assert(fd > 0);
        auth_master_connection_create(auth, fd, socket, &st, FALSE);
index 39d89c9bbff81ce116602cbdaf138de1957af186..bd78d0f2310610c23b9ab28441d3d2614f7d446f 100644 (file)
@@ -87,7 +87,7 @@ static void test_mech_prepare_request(struct auth_request **request_r,
                                      const struct test_case *test_case)
 {
        test_auth_set.ssl_username_from_cert = test_case->set_cert_username;
-       struct auth *auth = auth_default_service();
+       struct auth *auth = auth_default_protocol();
 
        struct auth_request *request = auth_request_new(mech,  NULL);
        request->handler = handler;