1
#! /bin/sh /usr/share/dpatch/dpatch-run
2
## 01UPSTREAM_autofs-5.0.2-init-cb-on-load.patch
3
## DP: Supplied by upstream.
7
diff --git a/CHANGELOG b/CHANGELOG
8
index c221c13..af5a1b0 100644
12
- update kernel header file linux/auto_fs4.h.
13
- update fix expire working harder than needed.
14
- add missing check for zero length NIS key (Wengang Wang).
15
+- init SASL callbacks on every ldap lookup library load.
17
14/01/2008 autofs-5.0.3
18
-----------------------
19
diff --git a/include/lookup_ldap.h b/include/lookup_ldap.h
20
index d6a754d..908ed09 100644
21
--- a/include/lookup_ldap.h
22
+++ b/include/lookup_ldap.h
23
@@ -99,10 +99,12 @@ int unbind_ldap_connection(unsigned logopt, LDAP *ldap, struct lookup_context *c
24
int authtype_requires_creds(const char *authtype);
27
+int autofs_sasl_client_init(unsigned logopt);
28
int autofs_sasl_init(unsigned logopt, LDAP *ldap, struct lookup_context *ctxt);
29
int autofs_sasl_bind(unsigned logopt, LDAP *ldap, struct lookup_context *ctxt);
30
void autofs_sasl_unbind(struct lookup_context *ctxt);
31
-void autofs_sasl_done(struct lookup_context *ctxt);
32
+void autofs_sasl_dispose(struct lookup_context *ctxt);
33
+void autofs_sasl_done(void);
37
diff --git a/modules/cyrus-sasl.c b/modules/cyrus-sasl.c
38
index f24f46b..902d9aa 100644
39
--- a/modules/cyrus-sasl.c
40
+++ b/modules/cyrus-sasl.c
41
@@ -76,7 +76,6 @@ static const char *default_client = "autofsclient";
42
static pthread_mutex_t krb5cc_mutex = PTHREAD_MUTEX_INITIALIZER;
43
static unsigned int krb5cc_in_use = 0;
45
-static unsigned int init_callbacks = 1;
46
static int sasl_log_func(void *, int, const char *);
47
static int getpass_func(sasl_conn_t *, void *, int, sasl_secret_t **);
48
static int getuser_func(void *, int, const char **, unsigned *);
49
@@ -878,13 +877,6 @@ autofs_sasl_init(unsigned logopt, LDAP *ldap, struct lookup_context *ctxt)
53
- /* Start up Cyrus SASL--only needs to be done once. */
54
- if (init_callbacks && sasl_client_init(callbacks) != SASL_OK) {
55
- error(logopt, "sasl_client_init failed");
60
sasl_auth_id = ctxt->user;
61
sasl_auth_secret = ctxt->secret;
63
@@ -916,8 +908,7 @@ autofs_sasl_init(unsigned logopt, LDAP *ldap, struct lookup_context *ctxt)
64
* Destructor routine. This should be called when finished with an ldap
68
-autofs_sasl_done(struct lookup_context *ctxt)
69
+void autofs_sasl_dispose(struct lookup_context *ctxt)
73
@@ -953,3 +944,28 @@ autofs_sasl_done(struct lookup_context *ctxt)
74
ctxt->kinit_successful = 0;
79
+ * Initialize the sasl callbacks, which increments the global
82
+int autofs_sasl_client_init(unsigned logopt)
84
+ /* Start up Cyrus SASL--only needs to be done at library load. */
85
+ if (sasl_client_init(callbacks) != SASL_OK) {
86
+ error(logopt, "sasl_client_init failed");
93
+ * Decrement the library reference count and free resources if
94
+ * we are the last to close the library.
96
+void autofs_sasl_done(void)
102
diff --git a/modules/lookup_ldap.c b/modules/lookup_ldap.c
103
index e8530f6..ded26f7 100644
104
--- a/modules/lookup_ldap.c
105
+++ b/modules/lookup_ldap.c
106
@@ -599,7 +599,7 @@ static LDAP *connect_to_server(unsigned logopt, const char *uri, struct lookup_c
108
if (!do_bind(logopt, ldap, ctxt)) {
109
unbind_ldap_connection(logopt, ldap, ctxt);
110
- autofs_sasl_done(ctxt);
111
+ autofs_sasl_dispose(ctxt);
112
error(logopt, MODPREFIX "cannot bind to server");
115
@@ -672,7 +672,7 @@ static LDAP *do_reconnect(unsigned logopt, struct lookup_context *ctxt)
116
list_add_tail(&this->list, ctxt->uri);
119
- autofs_sasl_done(ctxt);
120
+ autofs_sasl_dispose(ctxt);
123
/* Current server failed connect, try the rest */
124
@@ -1330,6 +1330,13 @@ int lookup_init(const char *mapfmt, int argc, const char *const *argv, void **co
129
+ /* Init the sasl callbacks */
130
+ if (!autofs_sasl_client_init(LOGOPT_NONE)) {
131
+ error(LOGOPT_ANY, "failed to init sasl client");
132
+ free_context(ctxt);
137
if (ctxt->server || !ctxt->uri) {
138
@@ -2640,7 +2647,8 @@ int lookup_done(void *context)
139
struct lookup_context *ctxt = (struct lookup_context *) context;
140
int rv = close_parse(ctxt->parse);
142
- autofs_sasl_done(ctxt);
143
+ autofs_sasl_dispose(ctxt);
144
+ autofs_sasl_done();