[Date Prev][Date Next] [Chronological] [Thread] [Top]

Custom SASL path (ITS#2721)



Full_Name: Roland Bauerschmidt
Version: 2.1.22
OS: Debian GNU/Linux unstable
URL: ftp://ftp.openldap.org/incoming/
Submission from: (NULL) (213.168.198.111)


SASL uses /usr/lib/sasl(2) as default path for configuration files. The Debian
Policy requires that all configuration files are located under /etc. Therefore,
I'd like to propose the attached patch that overrides SASL's default location,
so that /etc/openldap/sasl/slapd.conf could be used instead of
/usr/lib/sasl2/slapd.conf.

Index: include/ldap_defaults.h
===================================================================
--- include/ldap_defaults.h     (revision 222)
+++ include/ldap_defaults.h     (working copy)
@@ -90,4 +90,6 @@
        /* dn of the default "monitor" subentry */
 #define SLAPD_MONITOR_DN               "cn=Monitor"

+#define SASL_CONFIGPATH                        LDAP_SYSCONFDIR LDAP_DIRSEP
"sasl"
+
 #endif /* _LDAP_CONFIG_H */
Index: servers/slapd/sasl.c
===================================================================
--- servers/slapd/sasl.c        (revision 222)
+++ servers/slapd/sasl.c        (working copy)
@@ -946,12 +946,38 @@
 }
 #endif

+static int
+slap_sasl_getpath( 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_log, NULL },
+               { SASL_CB_GETPATH, &slap_sasl_getpath, NULL },
                { SASL_CB_LIST_END, NULL, NULL }
        };