diff options
author | Nathan Kinder <nkinder@redhat.com> | 2007-06-08 23:19:20 +0000 |
---|---|---|
committer | Nathan Kinder <nkinder@redhat.com> | 2007-06-08 23:19:20 +0000 |
commit | 85eefc580b0dc619292325319a7bb261dd698e15 (patch) | |
tree | 9cb86c2de3097d356db3b34d2b970c16971d3635 /ldap/servers/slapd/saslbind.c | |
parent | d9b8787008e72e696b2b92f20e18b4c3f5f0a38c (diff) | |
download | ds-85eefc580b0dc619292325319a7bb261dd698e15.tar.gz ds-85eefc580b0dc619292325319a7bb261dd698e15.tar.xz ds-85eefc580b0dc619292325319a7bb261dd698e15.zip |
Resolves: 240583
Summary: Added SASL support to ldclt as well as some thread-safety fixes for ns-slapd when using SASL.
Diffstat (limited to 'ldap/servers/slapd/saslbind.c')
-rw-r--r-- | ldap/servers/slapd/saslbind.c | 37 |
1 files changed, 23 insertions, 14 deletions
diff --git a/ldap/servers/slapd/saslbind.c b/ldap/servers/slapd/saslbind.c index d91cd69b..f7435ce4 100644 --- a/ldap/servers/slapd/saslbind.c +++ b/ldap/servers/slapd/saslbind.c @@ -54,38 +54,33 @@ static char *serverfqdn; /* * utility functions needed by the sasl library */ - -int sasl_os_gethost(char *buf, int len) -{ - int rc; - - rc = gethostname(buf, len); - LDAPDebug(LDAP_DEBUG_TRACE, "sasl_os_gethost %s\n", buf, 0, 0); - return ( rc == 0 ? SASL_OK : SASL_FAIL ); -} - -void *sasl_mutex_alloc(void) +void *nssasl_mutex_alloc(void) { return PR_NewLock(); } -int sasl_mutex_lock(void *mutex) +int nssasl_mutex_lock(void *mutex) { PR_Lock(mutex); return SASL_OK; } -int sasl_mutex_unlock(void *mutex) +int nssasl_mutex_unlock(void *mutex) { if (PR_Unlock(mutex) == PR_SUCCESS) return SASL_OK; return SASL_FAIL; } -void sasl_mutex_free(void *mutex) +void nssasl_mutex_free(void *mutex) { PR_DestroyLock(mutex); } +void nssasl_free(void *ptr) +{ + slapi_ch_free(&ptr); +} + /* * sasl library callbacks */ @@ -603,6 +598,20 @@ int ids_sasl_init(void) LDAPDebug(LDAP_DEBUG_TRACE, "sasl service fqdn is: %s\n", serverfqdn, 0, 0); + /* Set SASL memory allocation callbacks */ + sasl_set_alloc( + (sasl_malloc_t *)slapi_ch_malloc, + (sasl_calloc_t *)slapi_ch_calloc, + (sasl_realloc_t *)slapi_ch_realloc, + (sasl_free_t *)nssasl_free ); + + /* Set SASL mutex callbacks */ + sasl_set_mutex( + (sasl_mutex_alloc_t *)nssasl_mutex_alloc, + (sasl_mutex_lock_t *)nssasl_mutex_lock, + (sasl_mutex_unlock_t *)nssasl_mutex_unlock, + (sasl_mutex_free_t *)nssasl_mutex_free); + result = sasl_server_init(ids_sasl_callbacks, "iDS"); if (result != SASL_OK) { |