diff -r 99a34860c105 -r d938228c382e src/server/daemon/ldap_auth.c --- a/src/server/daemon/ldap_auth.c Wed Nov 02 19:19:01 2022 +0100 +++ b/src/server/daemon/ldap_auth.c Sun Nov 06 15:53:32 2022 +0100 @@ -35,7 +35,8 @@ #include #include -#include +#include +#include #include "ldap_auth.h" @@ -48,7 +49,7 @@ } AuthDB* create_ldap_authdb(ServerConfiguration *cfg, const char *name, LDAPConfig *conf) { - LDAPAuthDB *authdb = almalloc(cfg->a, sizeof(LDAPAuthDB)); + LDAPAuthDB *authdb = cxMalloc(cfg->a, sizeof(LDAPAuthDB)); authdb->authdb.name = pool_strdup(cfg->pool, name); authdb->authdb.get_user = ldap_get_user; authdb->authdb.use_cache = 1; @@ -64,7 +65,7 @@ // initialize group cache authdb->groups.first = NULL; authdb->groups.last = NULL; - authdb->groups.map = ucx_map_new_a(cfg->a, 32); + authdb->groups.map = cxHashMapCreate(cfg->a, 32); return (AuthDB*) authdb; } @@ -113,7 +114,7 @@ return ld; } -User* ldap_get_user(AuthDB *db, char *username) { +User* ldap_get_user(AuthDB *db, const char *username) { LDAPAuthDB *authdb = (LDAPAuthDB*) db; LDAPConfig *config = &authdb->config; @@ -161,7 +162,7 @@ user->user.verify_password = ldap_user_verify_password; user->user.check_group = ldap_user_check_group; user->user.free = ldap_user_free; - user->user.name = username; // must not be freed + user->user.name = (char*)username; // must not be freed TODO: maybe copy // TODO: get uid/gid from ldap user->user.uid = -1; @@ -180,7 +181,7 @@ return NULL; } -LDAPGroup* ldap_get_group(LDAPAuthDB *authdb, char *group) { +LDAPGroup* ldap_get_group(LDAPAuthDB *authdb, const char *group) { printf("ldap_get_group: %s\n", group); LDAPConfig *config = &authdb->config; @@ -246,10 +247,10 @@ wsgroup->members = calloc(count, sizeof(LDAPMember)); wsgroup->nmembers = count; for(int i=0;ibv_val, values[i]->bv_len); - wsgroup->members[i].name = sstrdup(member).ptr; + wsgroup->members[i].name = cx_strdup(member).ptr; // TODO: uid? printf("added member: %.*s\n", (int)member.length, member.ptr); } @@ -271,12 +272,12 @@ return wsgroup; } -int ldap_user_verify_password(User *u, char *password) { +int ldap_user_verify_password(User *u, const char *password) { LDAPUser *user = (LDAPUser*)u; //int r = ldap_simple_bind_s(user->ldap, user->userdn, password); struct berval cred; - cred.bv_val = password; + cred.bv_val = (char*)password; cred.bv_len = strlen(password); struct berval *server_cred; int r = ldap_sasl_bind_s( @@ -296,7 +297,7 @@ } } -int ldap_user_check_group(User *u, char *group_str) { +int ldap_user_check_group(User *u, const char *group_str) { LDAPUser *user = (LDAPUser*)u; int ret = 0;