Module: wine Branch: master Commit: 449fae545c915f04c20cd3b6830e077ada8df3f2 URL: https://source.winehq.org/git/wine.git/?a=commit;h=449fae545c915f04c20cd3b68...
Author: Alexandre Julliard julliard@winehq.org Date: Wed Nov 3 12:10:00 2021 +0100
wldap32: Move the SASL callback to the Unix side.
Signed-off-by: Alexandre Julliard julliard@winehq.org
---
dlls/wldap32/bind.c | 32 -------------------------------- dlls/wldap32/libldap.c | 33 ++++++++++++++++++++++++++++----- dlls/wldap32/libldap.h | 30 ++++++++---------------------- dlls/wldap32/main.c | 6 +----- 4 files changed, 37 insertions(+), 64 deletions(-)
diff --git a/dlls/wldap32/bind.c b/dlls/wldap32/bind.c index d45ed5d60e0..837612bf75f 100644 --- a/dlls/wldap32/bind.c +++ b/dlls/wldap32/bind.c @@ -138,38 +138,6 @@ exit: return ret; }
-int CDECL sasl_interact_cb( void *ld, unsigned flags, void *defaults, void *interact ) -{ - SEC_WINNT_AUTH_IDENTITY_A *id = defaults; - struct sasl_interactU *sasl = interact; - - TRACE( "(%p, 0x%08x, %p, %p)\n", ld, flags, defaults, interact ); - - while (sasl->id != SASL_CB_LIST_END) - { - TRACE( "sasl->id = %04lx\n", sasl->id ); - - if (sasl->id == SASL_CB_GETREALM) - { - sasl->result = id->Domain; - sasl->len = id->DomainLength; - } - else if (sasl->id == SASL_CB_USER) - { - sasl->result = id->User; - sasl->len = id->UserLength; - } - else if (sasl->id == SASL_CB_PASS) - { - sasl->result = id->Password; - sasl->len = id->PasswordLength; - } - sasl++; - } - - return LDAP_SUCCESS; -} - /*********************************************************************** * ldap_bind_sW (WLDAP32.@) * diff --git a/dlls/wldap32/libldap.c b/dlls/wldap32/libldap.c index 495ea609059..d568c2daaae 100644 --- a/dlls/wldap32/libldap.c +++ b/dlls/wldap32/libldap.c @@ -59,8 +59,6 @@ C_ASSERT( sizeof(struct timevalU) == sizeof(struct timeval) );
static LDAPMod *nullmods[] = { NULL };
-static const struct ldap_callbacks *callbacks; - static void * CDECL wrap_ber_alloc_t( int options ) { return ber_alloc_t( options ); @@ -553,8 +551,34 @@ static int CDECL wrap_ldap_sasl_bind_s( void *ld, const char *dn, const char *me static int wrap_sasl_interact( LDAP *ld, unsigned int flags, void *defaults, void *interact ) { #ifdef HAVE_SASL_SASL_H - C_ASSERT( sizeof(struct sasl_interactU) == sizeof(struct sasl_interact) ); - return callbacks->sasl_interact( ld, flags, defaults, interact ); + struct sasl_interactive_bind_id *id = defaults; + struct sasl_interact *sasl = interact; + + TRACE( "(%p, 0x%08x, %p, %p)\n", ld, flags, defaults, interact ); + + while (sasl->id != SASL_CB_LIST_END) + { + TRACE( "sasl->id = %04lx\n", sasl->id ); + + if (sasl->id == SASL_CB_GETREALM) + { + sasl->result = id->domain; + sasl->len = id->domain_len; + } + else if (sasl->id == SASL_CB_USER) + { + sasl->result = id->user; + sasl->len = id->user_len; + } + else if (sasl->id == SASL_CB_PASS) + { + sasl->result = id->password; + sasl->len = id->password_len; + } + sasl++; + } + + return LDAP_SUCCESS; #endif return -1; } @@ -678,7 +702,6 @@ static const struct ldap_funcs funcs = NTSTATUS CDECL __wine_init_unix_lib( HMODULE module, DWORD reason, const void *ptr_in, void *ptr_out ) { if (reason != DLL_PROCESS_ATTACH) return STATUS_SUCCESS; - callbacks = ptr_in; *(const struct ldap_funcs **)ptr_out = &funcs; return STATUS_SUCCESS; } diff --git a/dlls/wldap32/libldap.h b/dlls/wldap32/libldap.h index d0c37ab498d..e9736fc757f 100644 --- a/dlls/wldap32/libldap.h +++ b/dlls/wldap32/libldap.h @@ -83,22 +83,15 @@ typedef struct timevalU LONG_PTR tv_usec; } LDAP_TIMEVALU;
-#ifndef SASL_CB_LIST_END -#define SASL_CB_LIST_END 0 -#define SASL_CB_USER 0x4001 -#define SASL_CB_PASS 0x4004 -#define SASL_CB_GETREALM 0x4008 -#endif - -typedef struct sasl_interactU +struct sasl_interactive_bind_id { - ULONG_PTR id; - const char *challenge; - const char *prompt; - const char *defresult; - const void *result; - unsigned int len; -} sasl_interact_tU; + unsigned char* user; + ULONG user_len; + unsigned char* domain; + ULONG domain_len; + unsigned char* password; + ULONG password_len; +};
struct ldap_funcs { @@ -179,11 +172,4 @@ struct ldap_funcs void (CDECL *fn_ldap_value_free_len)(struct bervalU **); };
-extern int CDECL sasl_interact_cb(void *, unsigned int, void *, void *) DECLSPEC_HIDDEN; - -struct ldap_callbacks -{ - int (CDECL *sasl_interact)(void *, unsigned int, void *, void *); -}; - extern const struct ldap_funcs *ldap_funcs; diff --git a/dlls/wldap32/main.c b/dlls/wldap32/main.c index c2fdf30f820..55a08c9bad5 100644 --- a/dlls/wldap32/main.c +++ b/dlls/wldap32/main.c @@ -31,10 +31,6 @@ HINSTANCE hwldap32; WINE_DEFAULT_DEBUG_CHANNEL(wldap32);
const struct ldap_funcs *ldap_funcs = NULL; -const struct ldap_callbacks ldap_callbacks = -{ - sasl_interact_cb -};
BOOL WINAPI DllMain( HINSTANCE hinst, DWORD reason, LPVOID reserved ) { @@ -45,7 +41,7 @@ BOOL WINAPI DllMain( HINSTANCE hinst, DWORD reason, LPVOID reserved ) case DLL_PROCESS_ATTACH: hwldap32 = hinst; DisableThreadLibraryCalls( hinst ); - if (__wine_init_unix_lib( hinst, reason, &ldap_callbacks, &ldap_funcs )) + if (__wine_init_unix_lib( hinst, reason, NULL, &ldap_funcs )) ERR( "No libldap support, expect problems\n" ); break; }