implicitly create a resource pools for ldap authdbs, if no resource is specified

Thu, 16 Mar 2023 19:59:11 +0100

author
Olaf Wintermann <olaf.wintermann@gmail.com>
date
Thu, 16 Mar 2023 19:59:11 +0100
changeset 473
102322b6f4ee
parent 472
d6bc67906c8c
child 474
eb7640c59e9b

implicitly create a resource pools for ldap authdbs, if no resource is specified

src/server/daemon/ldap_auth.c file | annotate | diff | comparison | revisions
--- a/src/server/daemon/ldap_auth.c	Thu Mar 16 19:38:18 2023 +0100
+++ b/src/server/daemon/ldap_auth.c	Thu Mar 16 19:59:11 2023 +0100
@@ -37,6 +37,7 @@
 
 #include <cx/utils.h>
 #include <cx/hash_map.h>
+#include <cx/printf.h>
 
 #include "../util/util.h"
 
@@ -160,7 +161,24 @@
     cxstring userNameIsDn = serverconfig_object_directive_value(node, cx_str("UserNameIsDn"));
     
     if(!resource.ptr) {
-        // TODO: create resource pool
+        // implicitly create a resource pool for this authdb
+        cxmutstr respool_name = cx_asprintf_a(cfg->a, "_authdb_%s", name);
+        if(!respool_name.ptr) {
+            return NULL;
+        }
+        log_ereport(
+                LOG_INFORM,
+                "ldap authdb %s: no resource specified: create resource pool %s",
+                name,
+                respool_name.ptr);
+        if(resourcepool_new(cfg, cx_str("ldap"), cx_strcast(respool_name), node)) {
+            log_ereport(
+                    LOG_FAILURE,
+                    "ldap authdb %s: cannot create ldap resource pool",
+                    name);
+            return NULL;
+        }
+        authdb->config.resource = respool_name.ptr;
     } else {
         authdb->config.resource = cx_strdup_a(cfg->a, resource).ptr;
         if(!authdb->config.resource) return NULL;

mercurial