~ubuntu-branches/ubuntu/raring/autofs5/raring

« back to all changes in this revision

Viewing changes to debian/patches/01UPSTREAM_autofs-5.0.2-init-cb-on-load.patch

  • Committer: Bazaar Package Importer
  • Author(s): Jan Christoph Nordholz
  • Date: 2008-04-28 15:55:37 UTC
  • Revision ID: james.westby@ubuntu.com-20080428155537-6rr98jw7khwdeuqo
Tags: 5.0.3-1
* Upload to unstable.
* New upstream version 5.0.3 plus current patchset (as of 2008/04/27).
* Bump Standards to 3.7.3, debhelper to v6.
* Add build-dependency on libxml2-dev.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
#! /bin/sh /usr/share/dpatch/dpatch-run
 
2
## 01UPSTREAM_autofs-5.0.2-init-cb-on-load.patch
 
3
## DP: Supplied by upstream.
 
4
 
 
5
@DPATCH@
 
6
 
 
7
diff --git a/CHANGELOG b/CHANGELOG
 
8
index c221c13..af5a1b0 100644
 
9
--- a/CHANGELOG
 
10
+++ b/CHANGELOG
 
11
@@ -11,6 +11,7 @@
 
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.
 
16
  
 
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);
 
25
 
 
26
 /* cyrus-sasl.c */
 
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);
 
34
 #endif
 
35
 
 
36
 #endif
 
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;
 
44
 
 
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)
 
50
 {
 
51
        sasl_conn_t *conn;
 
52
 
 
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");
 
56
-               return -1;
 
57
-       }
 
58
-       init_callbacks = 0;
 
59
-
 
60
        sasl_auth_id = ctxt->user;
 
61
        sasl_auth_secret = ctxt->secret;
 
62
 
 
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
 
65
  *  session.
 
66
  */
 
67
-void
 
68
-autofs_sasl_done(struct lookup_context *ctxt)
 
69
+void autofs_sasl_dispose(struct lookup_context *ctxt)
 
70
 {
 
71
        int status, ret;
 
72
 
 
73
@@ -953,3 +944,28 @@ autofs_sasl_done(struct lookup_context *ctxt)
 
74
                ctxt->kinit_successful = 0;
 
75
        }
 
76
 }
 
77
+
 
78
+/*
 
79
+ * Initialize the sasl callbacks, which increments the global
 
80
+ * use counter.
 
81
+ */
 
82
+int autofs_sasl_client_init(unsigned logopt)
 
83
+{
 
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");
 
87
+               return 0;
 
88
+       }
 
89
+       return 1;
 
90
+}
 
91
+
 
92
+/*
 
93
+ * Decrement the library reference count and free resources if
 
94
+ * we are the last to close the library.
 
95
+ */
 
96
+void autofs_sasl_done(void)
 
97
+{
 
98
+       sasl_done();
 
99
+       return;
 
100
+}
 
101
+
 
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
 
107
 
 
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");
 
113
                        return NULL;
 
114
                }
 
115
@@ -672,7 +672,7 @@ static LDAP *do_reconnect(unsigned logopt, struct lookup_context *ctxt)
 
116
        list_add_tail(&this->list, ctxt->uri);
 
117
 
 
118
 #ifdef WITH_SASL
 
119
-       autofs_sasl_done(ctxt);
 
120
+       autofs_sasl_dispose(ctxt);
 
121
 #endif
 
122
 
 
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
 
125
                free_context(ctxt);
 
126
                return 1;
 
127
        }
 
128
+
 
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);
 
133
+               return 1;
 
134
+       }
 
135
 #endif
 
136
 
 
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);
 
141
 #ifdef WITH_SASL
 
142
-       autofs_sasl_done(ctxt);
 
143
+       autofs_sasl_dispose(ctxt);
 
144
+       autofs_sasl_done();
 
145
 #endif
 
146
        free_context(ctxt);
 
147
        return rv;