|
Ian Kent |
72b169 |
autofs-5.0.5 - add sasl mutex callbacks
|
|
Ian Kent |
72b169 |
|
|
Ian Kent |
72b169 |
From: Ian Kent <raven@themaw.net>
|
|
Ian Kent |
72b169 |
|
|
Ian Kent |
72b169 |
We missed the fact that Cyrus SASL requires the user to provide mutex
|
|
Ian Kent |
72b169 |
handling functions when being used in a threaded environment.
|
|
Ian Kent |
72b169 |
|
|
Ian Kent |
72b169 |
Original patch contributed by Kazuhiro Kikuchi (of Fujitsu), slightly
|
|
Ian Kent |
72b169 |
modified by myself.
|
|
Ian Kent |
72b169 |
---
|
|
Ian Kent |
72b169 |
|
|
Ian Kent |
72b169 |
CHANGELOG | 1
|
|
Ian Kent |
72b169 |
modules/cyrus-sasl.c | 57 +++++++++++++++++++++++++++++++++++++++++++++++++++
|
|
Ian Kent |
72b169 |
2 files changed, 58 insertions(+)
|
|
Ian Kent |
72b169 |
|
|
Ian Kent |
72b169 |
|
|
Ian Kent |
72b169 |
--- autofs-5.0.5.orig/CHANGELOG
|
|
Ian Kent |
72b169 |
+++ autofs-5.0.5/CHANGELOG
|
|
Ian Kent |
72b169 |
@@ -22,6 +22,7 @@
|
|
Ian Kent |
72b169 |
- fix disable timeout.
|
|
Ian Kent |
72b169 |
- fix strdup() return value check (Leonardo Chiquitto).
|
|
Ian Kent |
72b169 |
- fix reconnect get base dn.
|
|
Ian Kent |
72b169 |
+- add missing sasl mutex callbacks.
|
|
Ian Kent |
72b169 |
|
|
Ian Kent |
72b169 |
03/09/2009 autofs-5.0.5
|
|
Ian Kent |
72b169 |
-----------------------
|
|
Ian Kent |
72b169 |
--- autofs-5.0.5.orig/modules/cyrus-sasl.c
|
|
Ian Kent |
72b169 |
+++ autofs-5.0.5/modules/cyrus-sasl.c
|
|
Ian Kent |
72b169 |
@@ -944,12 +944,69 @@ void autofs_sasl_dispose(struct lookup_c
|
|
Ian Kent |
72b169 |
}
|
|
Ian Kent |
72b169 |
}
|
|
Ian Kent |
72b169 |
|
|
Ian Kent |
72b169 |
+static void *sasl_mutex_new(void)
|
|
Ian Kent |
72b169 |
+{
|
|
Ian Kent |
72b169 |
+ pthread_mutex_t* mutex;
|
|
Ian Kent |
72b169 |
+
|
|
Ian Kent |
72b169 |
+ mutex = malloc(sizeof(pthread_mutex_t));
|
|
Ian Kent |
72b169 |
+ if (!mutex)
|
|
Ian Kent |
72b169 |
+ return 0;
|
|
Ian Kent |
72b169 |
+
|
|
Ian Kent |
72b169 |
+ pthread_mutex_init(mutex, NULL);
|
|
Ian Kent |
72b169 |
+
|
|
Ian Kent |
72b169 |
+ return (void *) mutex;
|
|
Ian Kent |
72b169 |
+}
|
|
Ian Kent |
72b169 |
+
|
|
Ian Kent |
72b169 |
+static int sasl_mutex_lock(void *mutex __attribute__((unused)))
|
|
Ian Kent |
72b169 |
+{
|
|
Ian Kent |
72b169 |
+ int rc;
|
|
Ian Kent |
72b169 |
+
|
|
Ian Kent |
72b169 |
+ if (!mutex)
|
|
Ian Kent |
72b169 |
+ return SASL_FAIL;
|
|
Ian Kent |
72b169 |
+
|
|
Ian Kent |
72b169 |
+ rc = pthread_mutex_lock((pthread_mutex_t *) mutex);
|
|
Ian Kent |
72b169 |
+
|
|
Ian Kent |
72b169 |
+ return (rc==0 ? SASL_OK : SASL_FAIL);
|
|
Ian Kent |
72b169 |
+}
|
|
Ian Kent |
72b169 |
+
|
|
Ian Kent |
72b169 |
+static int sasl_mutex_unlock(void *mutex __attribute__((unused)))
|
|
Ian Kent |
72b169 |
+{
|
|
Ian Kent |
72b169 |
+ int rc;
|
|
Ian Kent |
72b169 |
+
|
|
Ian Kent |
72b169 |
+ if (!mutex)
|
|
Ian Kent |
72b169 |
+ return SASL_FAIL;
|
|
Ian Kent |
72b169 |
+
|
|
Ian Kent |
72b169 |
+ rc = pthread_mutex_unlock((pthread_mutex_t *) mutex);
|
|
Ian Kent |
72b169 |
+
|
|
Ian Kent |
72b169 |
+ return (rc==0 ? SASL_OK : SASL_FAIL);
|
|
Ian Kent |
72b169 |
+}
|
|
Ian Kent |
72b169 |
+
|
|
Ian Kent |
72b169 |
+static void sasl_mutex_dispose(void *mutex __attribute__((unused)))
|
|
Ian Kent |
72b169 |
+{
|
|
Ian Kent |
72b169 |
+ int rc;
|
|
Ian Kent |
72b169 |
+
|
|
Ian Kent |
72b169 |
+ if (!mutex)
|
|
Ian Kent |
72b169 |
+ return;
|
|
Ian Kent |
72b169 |
+
|
|
Ian Kent |
72b169 |
+ rc = pthread_mutex_destroy((pthread_mutex_t *) mutex);
|
|
Ian Kent |
72b169 |
+ if (rc == 0)
|
|
Ian Kent |
72b169 |
+ free(mutex);
|
|
Ian Kent |
72b169 |
+
|
|
Ian Kent |
72b169 |
+ return;
|
|
Ian Kent |
72b169 |
+}
|
|
Ian Kent |
72b169 |
+
|
|
Ian Kent |
72b169 |
/*
|
|
Ian Kent |
72b169 |
* Initialize the sasl callbacks, which increments the global
|
|
Ian Kent |
72b169 |
* use counter.
|
|
Ian Kent |
72b169 |
*/
|
|
Ian Kent |
72b169 |
int autofs_sasl_client_init(unsigned logopt)
|
|
Ian Kent |
72b169 |
{
|
|
Ian Kent |
72b169 |
+
|
|
Ian Kent |
72b169 |
+ sasl_set_mutex(sasl_mutex_new,
|
|
Ian Kent |
72b169 |
+ sasl_mutex_lock,
|
|
Ian Kent |
72b169 |
+ sasl_mutex_unlock,
|
|
Ian Kent |
72b169 |
+ sasl_mutex_dispose);
|
|
Ian Kent |
72b169 |
+
|
|
Ian Kent |
72b169 |
/* Start up Cyrus SASL--only needs to be done at library load. */
|
|
Ian Kent |
72b169 |
if (sasl_client_init(callbacks) != SASL_OK) {
|
|
Ian Kent |
72b169 |
error(logopt, "sasl_client_init failed");
|