From: Timo Sirainen Date: Mon, 3 Feb 2025 08:00:00 +0000 (+0200) Subject: auth: auth_client_connection_create() - Change boolean parameters to enum X-Git-Tag: 2.4.1~245 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=113815ad40dd503c463309cc8a79d8cf68661f26;p=thirdparty%2Fdovecot%2Fcore.git auth: auth_client_connection_create() - Change boolean parameters to enum --- diff --git a/src/auth/auth-client-connection.c b/src/auth/auth-client-connection.c index b328634830..b890ba3537 100644 --- a/src/auth/auth-client-connection.c +++ b/src/auth/auth-client-connection.c @@ -321,7 +321,7 @@ static const struct connection_settings auth_client_connection_set = { }; void auth_client_connection_create(struct auth *auth, int fd, const char *name, - bool login_requests, bool token_auth) + enum auth_client_connection_flags flags) { static unsigned int connect_uid_counter = 0; struct auth_client_connection *conn; @@ -337,8 +337,10 @@ void auth_client_connection_create(struct auth *auth, int fd, const char *name, conn->auth = auth; conn->refcount = 1; conn->connect_uid = ++connect_uid_counter; - conn->login_requests = login_requests; - conn->token_auth = token_auth; + conn->login_requests = + (flags & AUTH_CLIENT_CONNECTION_FLAG_LOGIN_REQUESTS) != 0; + conn->token_auth = + (flags & AUTH_CLIENT_CONNECTION_FLAG_TOKEN_AUTH) != 0; conn->conn.event_parent = auth_event; random_fill(conn->cookie, sizeof(conn->cookie)); diff --git a/src/auth/auth-client-connection.h b/src/auth/auth-client-connection.h index f0d5c5c6c5..463eb36fef 100644 --- a/src/auth/auth-client-connection.h +++ b/src/auth/auth-client-connection.h @@ -5,6 +5,11 @@ #define AUTH_CLIENT_MINOR_VERSION_CHANNEL_BINDING 3 +enum auth_client_connection_flags { + AUTH_CLIENT_CONNECTION_FLAG_LOGIN_REQUESTS = BIT(0), + AUTH_CLIENT_CONNECTION_FLAG_TOKEN_AUTH = BIT(1), +}; + struct auth_client_connection { struct connection conn; struct auth *auth; @@ -20,9 +25,8 @@ struct auth_client_connection { bool version_received:1; bool token_auth:1; }; - void auth_client_connection_create(struct auth *auth, int fd, const char *name, - bool login_requests, bool token_auth); + enum auth_client_connection_flags flags); struct auth_client_connection * auth_client_connection_lookup(unsigned int pid); diff --git a/src/auth/main.c b/src/auth/main.c index 7db2fa543f..5338ff6b49 100644 --- a/src/auth/main.c +++ b/src/auth/main.c @@ -326,19 +326,19 @@ static void client_connected(struct master_service_connection *conn) break; case AUTH_SOCKET_LOGIN: auth_client_connection_create(auth, conn->fd, conn->name, - TRUE, FALSE); + AUTH_CLIENT_CONNECTION_FLAG_LOGIN_REQUESTS); break; case AUTH_SOCKET_AUTH: - auth_client_connection_create(auth, conn->fd, conn->name, - FALSE, FALSE); + auth_client_connection_create(auth, conn->fd, conn->name, 0); break; case AUTH_SOCKET_TOKEN_LOGIN: auth_client_connection_create(auth, conn->fd, conn->name, - TRUE, TRUE); + AUTH_CLIENT_CONNECTION_FLAG_LOGIN_REQUESTS | + AUTH_CLIENT_CONNECTION_FLAG_TOKEN_AUTH); break; case AUTH_SOCKET_TOKEN: auth_client_connection_create(auth, conn->fd, conn->name, - FALSE, TRUE); + AUTH_CLIENT_CONNECTION_FLAG_TOKEN_AUTH); break; default: i_unreached(); diff --git a/src/auth/test-auth-client.c b/src/auth/test-auth-client.c index 4d3fd8784e..00b0f69058 100644 --- a/src/auth/test-auth-client.c +++ b/src/auth/test-auth-client.c @@ -14,7 +14,7 @@ static void auth_client_connected(int *server_fd) { 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); + auth_client_connection_create(auth, fd, TEST_AUTH_CLIENT_SOCKET, 0); } static void