]> git.ipfire.org Git - thirdparty/openldap.git/commitdiff
Permit lloadd to share slapd TLS context
authorOndřej Kuzník <okuznik@symas.com>
Thu, 3 May 2018 14:02:02 +0000 (15:02 +0100)
committerOndřej Kuzník <okuznik@symas.com>
Tue, 17 Nov 2020 17:58:15 +0000 (17:58 +0000)
doc/man/man5/lloadd.conf.5
servers/lloadd/client.c
servers/lloadd/config.c
servers/lloadd/extended.c
servers/lloadd/lload.h
servers/lloadd/proto-lload.h

index c34ab6b18fab5399b6a7eb4deb2f33126c2adc9a..bf325ada3e6618774b3c216daff3ddf084885e61 100644 (file)
@@ -70,9 +70,11 @@ interpretation wins and the
 option mentioned is unavailable through
 .BR slapd.conf (5)
 directly, instead, it would have to be configured via a dedicated attribute in
-cn=config. In particular,
+cn=config. In particular, unless the
+.B TLSShareSlapdCTX
+option is set,
 .B lloadd
-keeps its own TLS context and serving TLS to clients is not available except
+keeps its own TLS context which cannot be configured except
 through the dynamic configuration.
 
 An additional option is available when running as a
@@ -337,9 +339,32 @@ The default is 10000.
 If
 .B lloadd
 is built with support for Transport Layer Security, there are more options
-you can specify. None of these are available when compiled as a
+you can specify.
+
+.TP
+.B TLSShareSlapdCTX { on | off }
+If set to no (the default),
+.B lloadd
+will use its own TLS context (needs to be configured via
+.B cn=config
+unless
+.B lloadd
+is run as a standalone daemon). If enabled, the options for
+.B slapd
+apply instead, since the
+.BR slapd 's
+TLS context is used then.
+
+.LP
+
+The following options are available only when compiled as a standalone daemon.
+When compiled as a
 .BR slapd (8)
-module except through cn=config.
+module, the cn=config equivalents need to be used if a separate TLS context for
+the module is needed, otherwise use the
+.B TLSShareSlapdCTX
+option.
+
 .TP
 .B TLSCipherSuite <cipher-suite-spec>
 Permits configuring what ciphers will be accepted and the preference order.
index b7903d3d45960d32e3bd3bf047370ec72dc47ba5..bc1248488fc9c79d7290cd61a20a6ed86552d444 100644 (file)
@@ -294,7 +294,7 @@ client_tls_handshake_cb( evutil_socket_t s, short what, void *arg )
     }
     ldap_pvt_thread_mutex_unlock( &c->c_io_mutex );
 
-    rc = ldap_pvt_tls_accept( c->c_sb, lload_tls_ctx );
+    rc = ldap_pvt_tls_accept( c->c_sb, LLOAD_TLS_CTX );
     if ( rc < 0 ) {
         goto fail;
     }
@@ -374,7 +374,7 @@ client_init(
 
         c->c_is_tls = LLOAD_LDAPS;
 
-        rc = ldap_pvt_tls_accept( c->c_sb, lload_tls_ctx );
+        rc = ldap_pvt_tls_accept( c->c_sb, LLOAD_TLS_CTX );
         if ( rc < 0 ) {
             Debug( LDAP_DEBUG_CONNS, "client_init: "
                     "connid=%lu failed initial TLS accept rc=%d\n",
index 701eddc328285fb15afcf609227fe098f6e312d4..5b173ce493e844a4b7f8acdac25b7af940010fce 100644 (file)
@@ -126,6 +126,7 @@ static ConfigDriver config_tls_option;
 static ConfigDriver config_tls_config;
 #endif
 #ifdef BALANCER_MODULE
+static ConfigDriver config_share_tls_ctx;
 static ConfigDriver backend_cf_gen;
 #endif /* BALANCER_MODULE */
 
@@ -153,6 +154,7 @@ enum {
     CFG_TLS_VERIFY,
     CFG_TLS_CRLCHECK,
     CFG_TLS_CRL_FILE,
+    CFG_TLS_SHARE_CTX,
     CFG_CONCUR,
     CFG_THREADS,
     CFG_LOGFILE,
@@ -587,6 +589,22 @@ static ConfigTable config_back_cf_table[] = {
             "SINGLE-VALUE )",
         NULL, NULL
     },
+    { "TLSShareSlapdCTX", NULL, 2, 2, 0,
+#if defined(HAVE_TLS) && defined(BALANCER_MODULE)
+        CFG_TLS_SHARE_CTX|ARG_ON_OFF|ARG_MAGIC,
+        &config_share_tls_ctx,
+#else
+        ARG_IGNORED,
+        NULL,
+#endif
+        "( OLcfgBkAt:13.33 "
+            "NAME 'olcBkLloadTLSShareSlapdCTX' "
+            "DESC 'Share slapd TLS context (all other lloadd TLS options cease to take effect)' "
+            "EQUALITY booleanMatch "
+            "SYNTAX OMsBoolean "
+            "SINGLE-VALUE )",
+        NULL, NULL
+    },
     { "iotimeout", "ms timeout", 2, 2, 0,
         ARG_UINT|ARG_MAGIC|CFG_IOTIMEOUT,
         &config_generic,
@@ -716,6 +734,7 @@ static ConfigOCs lloadocs[] = {
             "$ olcBkLloadTLSECName "
             "$ olcBkLloadTLSProtocolMin "
             "$ olcBkLloadTLSCRLFile "
+            "$ olcBkLloadTLSShareSlapdCTX "
         ") )",
         Cft_Backend, config_back_cf_table,
         NULL,
@@ -2008,6 +2027,31 @@ config_tls_config( ConfigArgs *c )
 }
 #endif
 
+#ifdef BALANCER_MODULE
+static int
+config_share_tls_ctx( ConfigArgs *c )
+{
+    int rc = LDAP_SUCCESS;
+
+    if ( c->op == SLAP_CONFIG_EMIT ) {
+        c->value_int = lload_use_slap_tls_ctx;
+        return rc;
+    }
+
+    lload_change.type = LLOAD_CHANGE_MODIFY;
+    lload_change.object = LLOAD_DAEMON;
+    lload_change.flags.daemon |= LLOAD_DAEMON_MOD_TLS;
+
+    if ( c->op == LDAP_MOD_DELETE ) {
+        lload_use_slap_tls_ctx = 0;
+        return rc;
+    }
+
+    lload_use_slap_tls_ctx = c->value_int;
+    return rc;
+}
+#endif /* BALANCER_MODULE */
+
 void
 lload_init_config_argv( ConfigArgs *c )
 {
index b7a230ebc4ad3d758175e21414feab555330e4fe..74ffcdf38c2d73efbe3ab8ed16128d26bcec0fbd 100644 (file)
@@ -24,6 +24,9 @@ Avlnode *lload_exop_handlers = NULL;
 
 void *lload_tls_ctx;
 LDAP *lload_tls_ld, *lload_tls_backend_ld;
+#ifdef BALANCER_MODULE
+int lload_use_slap_tls_ctx = 0;
+#endif
 
 int
 handle_starttls( LloadConnection *c, LloadOperation *op )
@@ -44,7 +47,7 @@ handle_starttls( LloadConnection *c, LloadOperation *op )
     } else if ( c->c_ops ) {
         rc = LDAP_OPERATIONS_ERROR;
         msg = "cannot start TLS when operations are outstanding";
-    } else if ( !lload_tls_ctx ) {
+    } else if ( !LLOAD_TLS_CTX ) {
         rc = LDAP_UNAVAILABLE;
         msg = "Could not initialize TLS";
     }
index 7b045bf582e1c2d64f4ab4f4dc69bc7b43b48725..6a35bfdd279aec7a168f256ce030ec9383e84de1 100644 (file)
@@ -154,6 +154,12 @@ typedef enum {
     LLOAD_FEATURE_PROXYAUTHZ = 1 << 1,
 } lload_features_t;
 
+#ifdef BALANCER_MODULE
+#define LLOAD_TLS_CTX ( lload_use_slap_tls_ctx ? slap_tls_ctx : lload_tls_ctx )
+#else
+#define LLOAD_TLS_CTX ( lload_tls_ctx )
+#endif
+
 enum lload_tls_type {
     LLOAD_CLEARTEXT = 0,
     LLOAD_LDAPS,
index 21885319e233e513ba0bc3c69bd00fd7ae17b545..f95419e991265fad24eabe461f87bd373e20ae34 100644 (file)
@@ -128,6 +128,9 @@ LDAP_SLAPD_V (struct event *) lload_timeout_event;
 LDAP_SLAPD_V (LDAP *) lload_tls_backend_ld;
 LDAP_SLAPD_V (LDAP *) lload_tls_ld;
 LDAP_SLAPD_V (void *) lload_tls_ctx;
+#ifdef BALANCER_MODULE
+LDAP_SLAPD_V (int) lload_use_slap_tls_ctx;
+#endif /* BALANCER_MODULE */
 
 /*
  * extended.c