]> git.ipfire.org Git - thirdparty/dovecot/core.git/commitdiff
auth: sasl-server - Add mechanism parameter to auth_new() mechanism function
authorStephan Bosch <stephan.bosch@open-xchange.com>
Tue, 24 Oct 2023 02:59:39 +0000 (04:59 +0200)
committertimo.sirainen <timo.sirainen@open-xchange.com>
Thu, 9 Oct 2025 08:41:22 +0000 (08:41 +0000)
src/auth/auth-sasl-mech-apop.c
src/auth/sasl-server-mech-cram-md5.c
src/auth/sasl-server-mech-digest-md5.c
src/auth/sasl-server-mech-gssapi.c
src/auth/sasl-server-mech-oauth2.c
src/auth/sasl-server-mech-otp.c
src/auth/sasl-server-mech-scram.c
src/auth/sasl-server-mech-scram.h
src/auth/sasl-server-mech-winbind.c
src/auth/sasl-server-protected.h
src/auth/sasl-server-request.c

index e7d12269c41b3000adca5a60119004d368b738bf..6a7b4ad8836694e9bf4bd2b31ee6bbdba6584cf0 100644 (file)
@@ -148,7 +148,8 @@ mech_apop_auth_initial(struct sasl_server_mech_request *req,
                                               apop_credentials_callback);
 }
 
-static struct sasl_server_mech_request *mech_apop_auth_new(pool_t pool)
+static struct sasl_server_mech_request *
+mech_apop_auth_new(const struct sasl_server_mech *mech ATTR_UNUSED, pool_t pool)
 {
        struct apop_auth_request *request;
 
index f609b46293dfbfd19e14afef4e6a4b89fa25513c..a1701aa279f8f65b7c7b54da086171ec26d386df 100644 (file)
@@ -164,7 +164,9 @@ mech_cram_md5_auth_initial(struct sasl_server_mech_request *auth_request,
                                   strlen(request->challenge));
 }
 
-static struct sasl_server_mech_request *mech_cram_md5_auth_new(pool_t pool)
+static struct sasl_server_mech_request *
+mech_cram_md5_auth_new(const struct sasl_server_mech *mech ATTR_UNUSED,
+                      pool_t pool)
 {
        struct cram_auth_request *request;
 
index f014bec840c4c1347ce170a2ece106256af5f583..b5f70e0eadfd0181711b6099f295adc328032d2d 100644 (file)
@@ -594,7 +594,9 @@ mech_digest_md5_auth_initial(struct sasl_server_mech_request *auth_request,
                                   str_len(challenge));
 }
 
-static struct sasl_server_mech_request *mech_digest_md5_auth_new(pool_t pool)
+static struct sasl_server_mech_request *
+mech_digest_md5_auth_new(const struct sasl_server_mech *mech ATTR_UNUSED,
+                        pool_t pool)
 {
        struct digest_auth_request *request;
 
index aea09c8206547826c28ad01a8822f90210910630..405c0f898412bb167ae9f2fb674ae563dbe0ed4c 100644 (file)
@@ -96,7 +96,9 @@ mech_gssapi_log_error(struct gssapi_auth_request *request,
        } while (message_context != 0);
 }
 
-static struct sasl_server_mech_request *mech_gssapi_auth_new(pool_t pool)
+static struct sasl_server_mech_request *
+mech_gssapi_auth_new(const struct sasl_server_mech *mech ATTR_UNUSED,
+                    pool_t pool)
 {
        struct gssapi_auth_request *request;
 
index c8b6b3b7de9b88bf2835328d6d8bfe5a098a9053..624b297e6bb6dd16a9b39b1398d213426c0aa09c 100644 (file)
@@ -302,7 +302,9 @@ mech_xoauth2_auth_continue(struct sasl_server_mech_request *request,
        }
 }
 
-static struct sasl_server_mech_request *mech_oauth2_auth_new(pool_t pool)
+static struct sasl_server_mech_request *
+mech_oauth2_auth_new(const struct sasl_server_mech *mech ATTR_UNUSED,
+                    pool_t pool)
 {
        struct oauth2_auth_request *request;
 
index c726d6f5f3db23252be02d9628fea86bbb02fab2..3d5551249b5e0fb7e145d888a994cf98ef92d343 100644 (file)
@@ -286,7 +286,8 @@ mech_otp_auth_continue(struct sasl_server_mech_request *auth_request,
                mech_otp_auth_phase2(request, data, data_size);
 }
 
-static struct sasl_server_mech_request *mech_otp_auth_new(pool_t pool)
+static struct sasl_server_mech_request *
+mech_otp_auth_new(const struct sasl_server_mech *mech ATTR_UNUSED, pool_t pool)
 {
        struct otp_auth_request *request;
 
index b350b1271104b3ce8e219ec64cbaf0b7d7641170..4df5b8cdfa6277321c8ff452a60c7a1b3af982a6 100644 (file)
@@ -178,7 +178,8 @@ void mech_scram_auth_continue(struct sasl_server_mech_request *auth_request,
 }
 
 struct sasl_server_mech_request *
-mech_scram_auth_new(pool_t pool, const struct hash_method *hash_method,
+mech_scram_auth_new(const struct sasl_server_mech *mech ATTR_UNUSED,
+                   pool_t pool, const struct hash_method *hash_method,
                    const char *password_scheme)
 {
        struct scram_auth_request *request;
@@ -213,14 +214,18 @@ mech_scram_auth_new(pool_t pool, const struct hash_method *hash_method,
        return &request->auth_request;
 }
 
-static struct sasl_server_mech_request *mech_scram_sha1_auth_new(pool_t pool)
+static struct sasl_server_mech_request *
+mech_scram_sha1_auth_new(const struct sasl_server_mech *mech, pool_t pool)
 {
-       return mech_scram_auth_new(pool, &hash_method_sha1, "SCRAM-SHA-1");
+       return mech_scram_auth_new(
+               mech, pool, &hash_method_sha1, "SCRAM-SHA-1");
 }
 
-static struct sasl_server_mech_request *mech_scram_sha256_auth_new(pool_t pool)
+static struct sasl_server_mech_request *
+mech_scram_sha256_auth_new(const struct sasl_server_mech *mech, pool_t pool)
 {
-       return mech_scram_auth_new(pool, &hash_method_sha256, "SCRAM-SHA-256");
+       return mech_scram_auth_new(
+               mech, pool, &hash_method_sha256, "SCRAM-SHA-256");
 }
 
 static void mech_scram_auth_free(struct sasl_server_mech_request *auth_request)
index 3c00f2804ef2aa59b84aed258dddbacaf65f1494..d7348fbeda013d05b7b2335ac2c41d55ff200350 100644 (file)
@@ -2,7 +2,8 @@
 #define SASL_SERVER_MECH_SCRAM_H
 
 struct sasl_server_mech_request *
-mech_scram_auth_new(pool_t pool, const struct hash_method *hash_method,
+mech_scram_auth_new(const struct sasl_server_mech *mech ATTR_UNUSED,
+                   pool_t pool, const struct hash_method *hash_method,
                    const char *password_scheme);
 void mech_scram_auth_continue(struct sasl_server_mech_request *auth_request,
                              const unsigned char *input, size_t input_len);
index e157480a95245c7759a46f717a7436759c9174a5..6afadc837678d945e3236228e511c2500fca12e0 100644 (file)
@@ -327,13 +327,15 @@ do_auth_new(pool_t pool, struct winbind_helper *winbind)
 }
 
 static struct sasl_server_mech_request *
-mech_winbind_ntlm_auth_new(pool_t pool)
+mech_winbind_ntlm_auth_new(const struct sasl_server_mech *mech ATTR_UNUSED,
+                          pool_t pool)
 {
        return do_auth_new(pool, &winbind_ntlm_context);
 }
 
 static struct sasl_server_mech_request *
-mech_winbind_spnego_auth_new(pool_t pool)
+mech_winbind_spnego_auth_new(const struct sasl_server_mech *mech ATTR_UNUSED,
+                            pool_t pool)
 {
        return do_auth_new(pool, &winbind_spnego_context);
 }
index 5abe4cd9341bb75339d3745fa0261cb06c65d7e8..5cfb9600c7c235b1cd67ae55061e91f32bad5fe8 100644 (file)
@@ -16,7 +16,8 @@ sasl_server_mech_passdb_callback_t(struct sasl_server_mech_request *req,
                                   const struct sasl_passdb_result *result);
 
 struct sasl_server_mech_funcs {
-       struct sasl_server_mech_request *(*auth_new)(pool_t pool);
+       struct sasl_server_mech_request *
+       (*auth_new)(const struct sasl_server_mech *mech, pool_t pool);
        void (*auth_initial)(struct sasl_server_mech_request *req,
                             const unsigned char *data, size_t data_size);
        void (*auth_continue)(struct sasl_server_mech_request *req,
index 54bc29b889521220418ba644a79f37a336cde06d..58b34419a63b13f1d3d276e8b893619257a2b85e 100644 (file)
@@ -50,7 +50,7 @@ void sasl_server_request_create(struct sasl_server_req_ctx *rctx,
        struct sasl_server_mech_request *mreq;
 
        if (mech->def->funcs->auth_new != NULL)
-               mreq = mech->def->funcs->auth_new(pool);
+               mreq = mech->def->funcs->auth_new(mech, pool);
        else
                mreq = p_new(pool, struct sasl_server_mech_request, 1);
        mreq->pool = pool;