From: Timo Sirainen Date: Sat, 24 Jun 2023 20:09:50 +0000 (+0300) Subject: auth: Rename service settings lookup functions/variables to protocol settings X-Git-Tag: 2.4.1~1550 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=91bbea38bdb84168dcb0469e662e0cd2e605993e;p=thirdparty%2Fdovecot%2Fcore.git auth: Rename service settings lookup functions/variables to protocol settings They already were using protocol name { .. } settings, so it's more correct to call them "protocol" internally as well. --- diff --git a/src/auth/auth-request-handler.c b/src/auth/auth-request-handler.c index 0a3f18a310..f4caf7facc 100644 --- a/src/auth/auth-request-handler.c +++ b/src/auth/auth-request-handler.c @@ -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 */ diff --git a/src/auth/auth-request.c b/src/auth/auth-request.c index effa1b46af..efa2a1b28b 100644 --- a/src/auth/auth-request.c +++ b/src/auth/auth-request.c @@ -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; diff --git a/src/auth/auth-settings.c b/src/auth/auth-settings.c index 6fa2db2778..348215653c 100644 --- a/src/auth/auth-settings.c +++ b/src/auth/auth-settings.c @@ -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); diff --git a/src/auth/auth-settings.h b/src/auth/auth-settings.h index 5afbf976c8..2b85c42e3d 100644 --- a/src/auth/auth-settings.h +++ b/src/auth/auth-settings.h @@ -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 diff --git a/src/auth/auth.c b/src/auth/auth.c index 60882f9a30..24181b10e8 100644 --- a/src/auth/auth.c +++ b/src/auth/auth.c @@ -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); } } diff --git a/src/auth/auth.h b/src/auth/auth.h index 0af4038888..963ee6ec04 100644 --- a/src/auth/auth.h +++ b/src/auth/auth.h @@ -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); diff --git a/src/auth/main.c b/src/auth/main.c index 9c12e16177..1020c9cda6 100644 --- a/src/auth/main.c +++ b/src/auth/main.c @@ -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, diff --git a/src/auth/test-auth-client.c b/src/auth/test-auth-client.c index 2254d208f2..6229e4d6f3 100644 --- a/src/auth/test-auth-client.c +++ b/src/auth/test-auth-client.c @@ -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); } diff --git a/src/auth/test-auth-master-server.c b/src/auth/test-auth-master-server.c index d33a2a6afb..790bed7056 100644 --- a/src/auth/test-auth-master-server.c +++ b/src/auth/test-auth-master-server.c @@ -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); diff --git a/src/auth/test-mech.c b/src/auth/test-mech.c index 39d89c9bbf..bd78d0f231 100644 --- a/src/auth/test-mech.c +++ b/src/auth/test-mech.c @@ -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;