sasl-default-path
authorDebian OpenLDAP Maintainers <pkg-openldap-devel@lists.alioth.debian.org>
Tue, 17 Nov 2020 01:23:45 +0000 (01:23 +0000)
committerRyan Tandy <ryan@nardis.ca>
Tue, 17 Nov 2020 01:23:45 +0000 (01:23 +0000)
Add /etc/ldap/sasl2 to the SASL configuration search path.

Not submitted upstream.  Somewhat Debian-specific and probably not of
interest upstream.

Gbp-Pq: Name sasl-default-path

include/ldap_defaults.h
servers/slapd/sasl.c

index 9efa733b7ade7df7c5b345fb0bd94c5dcbb54d55..4e685d0d80f52f12eccb11a328c89c2f11e87a6c 100644 (file)
@@ -63,4 +63,6 @@
        /* dn of the default "monitor" subentry */
 #define SLAPD_MONITOR_DN               "cn=Monitor"
 
+#define SASL_CONFIGPATH                        LDAP_SYSCONFDIR LDAP_DIRSEP "sasl2"
+
 #endif /* _LDAP_CONFIG_H */
index 64e64d1d9abc392ca21007f4b808a54aa2ee0d5c..1598ec3f4e453f64e9d5324cd6375553c7262ba6 100644 (file)
@@ -1116,12 +1116,38 @@ static const rewrite_mapper slapd_mapper = {
 };
 #endif
 
+static int
+slap_sasl_getconfpath( void * context, char ** path )
+{
+       char * sasl_default_configpath;
+       size_t len;
+
+#if SASL_VERSION_MAJOR >= 2
+       sasl_default_configpath = "/usr/lib/sasl2";
+#else
+       sasl_default_configpath = "/usr/lib/sasl";
+#endif
+
+       len = strlen(SASL_CONFIGPATH) + 1 /* colon */ +
+               strlen(sasl_default_configpath) + 1 /* \0 */;
+       *path = malloc( len );
+       if ( *path == NULL )
+               return SASL_FAIL;
+
+       if (snprintf( *path, len, "%s:%s", SASL_CONFIGPATH,
+                               sasl_default_configpath ) != len-1 )
+               return SASL_FAIL;
+
+       return SASL_OK;
+}
+
 int slap_sasl_init( void )
 {
 #ifdef HAVE_CYRUS_SASL
        int rc;
        static sasl_callback_t server_callbacks[] = {
                { SASL_CB_LOG, (slap_sasl_cb_ft)&slap_sasl_log, NULL },
+               { SASL_CB_GETCONFPATH, (slap_sasl_cb_ft)&slap_sasl_getconfpath, NULL },
                { SASL_CB_GETOPT, (slap_sasl_cb_ft)&slap_sasl_getopt, NULL },
                { SASL_CB_LIST_END, NULL, NULL }
        };