Lines 1-67
Link Here
|
1 |
=== modified file 'sx/sasl_gsasl.c' |
|
|
2 |
--- sx/sasl_gsasl.c 2011-10-08 22:08:29 +0000 |
3 |
+++ sx/sasl_gsasl.c 2011-12-06 19:50:30 +0000 |
4 |
@@ -138,7 +138,7 @@ |
5 |
typedef struct _Gsasl_digest_md5_server_state _Gsasl_digest_md5_server_state; |
6 |
|
7 |
/** utility: generate a success nad */ |
8 |
-static nad_t _sx_sasl_success(sx_t s) { |
9 |
+static nad_t _sx_sasl_success(sx_t s, char *data, int dlen) { |
10 |
nad_t nad; |
11 |
int ns; |
12 |
|
13 |
@@ -146,6 +146,8 @@ |
14 |
ns = nad_add_namespace(nad, uri_SASL, NULL); |
15 |
|
16 |
nad_append_elem(nad, ns, "success", 0); |
17 |
+ if(data != NULL) |
18 |
+ nad_append_cdata(nad, data, dlen, 1); |
19 |
|
20 |
return nad; |
21 |
} |
22 |
@@ -533,15 +535,25 @@ |
23 |
if(ret == GSASL_OK) { |
24 |
_sx_debug(ZONE, "sasl handshake completed"); |
25 |
|
26 |
+ /* encode the leftover response */ |
27 |
+ ret = gsasl_base64_to(out, outlen, &buf, &buflen); |
28 |
+ if (ret == GSASL_OK) { |
29 |
+ /* send success */ |
30 |
+ _sx_nad_write(s, _sx_sasl_success(s, buf, buflen), 0); |
31 |
+ free(buf); |
32 |
+ |
33 |
+ /* set a notify on the success nad buffer */ |
34 |
+ ((sx_buf_t) s->wbufq->front->data)->notify = _sx_sasl_notify_success; |
35 |
+ ((sx_buf_t) s->wbufq->front->data)->notify_arg = (void *) p; |
36 |
+ } |
37 |
+ else { |
38 |
+ _sx_debug(ZONE, "gsasl_base64_to failed, no sasl for this conn; (%d): %s", ret, gsasl_strerror(ret)); |
39 |
+ _sx_nad_write(s, _sx_sasl_failure(s, _sasl_err_INCORRECT_ENCODING), 0); |
40 |
+ if(buf != NULL) free(buf); |
41 |
+ } |
42 |
+ |
43 |
if(out != NULL) free(out); |
44 |
|
45 |
- /* send success */ |
46 |
- _sx_nad_write(s, _sx_sasl_success(s), 0); |
47 |
- |
48 |
- /* set a notify on the success nad buffer */ |
49 |
- ((sx_buf_t) s->wbufq->front->data)->notify = _sx_sasl_notify_success; |
50 |
- ((sx_buf_t) s->wbufq->front->data)->notify_arg = (void *) p; |
51 |
- |
52 |
return; |
53 |
} |
54 |
|
55 |
@@ -555,6 +567,11 @@ |
56 |
_sx_nad_write(s, _sx_sasl_challenge(s, buf, buflen), 0); |
57 |
free(buf); |
58 |
} |
59 |
+ else { |
60 |
+ _sx_debug(ZONE, "gsasl_base64_to failed, no sasl for this conn; (%d): %s", ret, gsasl_strerror(ret)); |
61 |
+ _sx_nad_write(s, _sx_sasl_failure(s, _sasl_err_INCORRECT_ENCODING), 0); |
62 |
+ if(buf != NULL) free(buf); |
63 |
+ } |
64 |
|
65 |
if(out != NULL) free(out); |
66 |
|
67 |
|