]> git.ipfire.org Git - thirdparty/freeradius-server.git/commitdiff
Allow for SASL bind ctx in LDAP auth bind ctx
authorNick Porter <nick@portercomputing.co.uk>
Wed, 22 Mar 2023 14:52:19 +0000 (14:52 +0000)
committerNick Porter <nick@portercomputing.co.uk>
Tue, 4 Apr 2023 07:30:11 +0000 (08:30 +0100)
src/lib/ldap/base.h
src/lib/ldap/sasl.c

index f185fe1bf85e152ce1e64138ac52850773a333df..13bdd0d49e8c183fdf89e3d99fe6c9675960dfd9 100644 (file)
@@ -486,6 +486,29 @@ typedef struct {
        int                     msgid;
 } fr_ldap_bind_ctx_t;
 
+/** Holds arguments for the async SASL bind operation
+ *
+ */
+typedef struct {
+       fr_ldap_connection_t    *c;                     //!< to bind.
+       char const              *mechs;                 //!< SASL mechanisms to run
+       char const              *dn;                    //!< to bind as.
+       char const              *identity;              //!< of the user.
+       char const              *password;              //!< of the user, may be NULL if no password is specified.
+       char const              *proxy;                 //!< Proxy identity, may be NULL in which case identity is used.
+       char const              *realm;                 //!< SASL realm (may be NULL).
+       LDAPControl             **serverctrls;          //!< Controls to pass to the server.
+       LDAPControl             **clientctrls;          //!< Controls to pass to the client (library).
+
+       int                     msgid;                  //!< Last msgid.
+       LDAPMessage             *result;                //!< Previous result.
+       char const              *rmech;                 //!< Mech we're continuing with.
+} fr_ldap_sasl_ctx_t;
+
+typedef enum {
+       LDAP_BIND_SIMPLE                = 0,
+       LDAP_BIND_SASL
+} fr_ldap_bind_type_t;
 
 /** Holds arguments for async bind auth requests
  *
@@ -497,7 +520,11 @@ typedef struct {
        fr_ldap_thread_t        *thread;        //!< This bind is being run by.
        int                     msgid;          //!< libldap msgid for this bind.
        request_t               *request;       //!< this bind relates to.
-       fr_ldap_bind_ctx_t      *bind_ctx;      //!< Data relating to the user being bound.
+       fr_ldap_bind_type_t     type;           //!< type of bind.
+       union {
+               fr_ldap_bind_ctx_t      *bind_ctx;      //!< User data for simple binds.
+               fr_ldap_sasl_ctx_t      *sasl_ctx;      //!< User data for SASL binds.
+       };
        fr_ldap_result_code_t   ret;            //!< Return code of bind operation.
 } fr_ldap_bind_auth_ctx_t;
 
index 336046b345a55acfa0c5e494abc6e8bad808b542..5a491bda4eeca3b80d8b1521a4e17aadd0b55c90 100644 (file)
@@ -29,24 +29,6 @@ USES_APPLE_DEPRECATED_API
 #include <freeradius-devel/util/debug.h>
 #include <sasl/sasl.h>
 
-/** Holds arguments for the bind operation
- *
- */
-typedef struct {
-       fr_ldap_connection_t    *c;                     //!< to bind.
-       char const              *mechs;                 //!< SASL mechanisms to run
-       char const              *identity;              //!< of the user.
-       char const              *password;              //!< of the user, may be NULL if no password is specified.
-       char const              *proxy;                 //!< Proxy identity, may be NULL in which case identity is used.
-       char const              *realm;                 //!< SASL realm (may be NULL).
-       LDAPControl             **serverctrls;          //!< Controls to pass to the server.
-       LDAPControl             **clientctrls;          //!< Controls to pass to the client (library).
-
-       int                     msgid;                  //!< Last msgid.
-       LDAPMessage             *result;                //!< Previous result.
-       char const              *rmech;                 //!< Mech we're continuing with.
-} fr_ldap_sasl_ctx_t;
-
 static void _ldap_sasl_bind_io_write(fr_event_list_t *el, int fd, UNUSED int flags, void *uctx);
 
 /** Error reading from or writing to the file descriptor