author | Frank Zschockelt <lm@freakysoft.de> |
Sat, 11 May 2019 22:25:15 +0200 | |
changeset 737 | ca896de7b10d |
parent 721 | c5d2f7bc8a18 |
permissions | -rw-r--r-- |
516
4dd3aa6b83e5
Change the tab width to 4 steps in the emacs headers
Mikael Hallendal <micke@imendio.com>
parents:
515
diff
changeset
|
1 |
/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ |
216
fab18da0956b
Added lm-sasl.[ch] from Senko
Mikael Hallendal <micke@imendio.com>
parents:
diff
changeset
|
2 |
/* |
fab18da0956b
Added lm-sasl.[ch] from Senko
Mikael Hallendal <micke@imendio.com>
parents:
diff
changeset
|
3 |
* Copyright (C) 2007 Collabora Ltd. |
fab18da0956b
Added lm-sasl.[ch] from Senko
Mikael Hallendal <micke@imendio.com>
parents:
diff
changeset
|
4 |
* |
fab18da0956b
Added lm-sasl.[ch] from Senko
Mikael Hallendal <micke@imendio.com>
parents:
diff
changeset
|
5 |
* This program is free software; you can redistribute it and/or |
fab18da0956b
Added lm-sasl.[ch] from Senko
Mikael Hallendal <micke@imendio.com>
parents:
diff
changeset
|
6 |
* modify it under the terms of the GNU Lesser General Public License as |
fab18da0956b
Added lm-sasl.[ch] from Senko
Mikael Hallendal <micke@imendio.com>
parents:
diff
changeset
|
7 |
* published by the Free Software Foundation; either version 2 of the |
fab18da0956b
Added lm-sasl.[ch] from Senko
Mikael Hallendal <micke@imendio.com>
parents:
diff
changeset
|
8 |
* License, or (at your option) any later version. |
fab18da0956b
Added lm-sasl.[ch] from Senko
Mikael Hallendal <micke@imendio.com>
parents:
diff
changeset
|
9 |
* |
fab18da0956b
Added lm-sasl.[ch] from Senko
Mikael Hallendal <micke@imendio.com>
parents:
diff
changeset
|
10 |
* This program is distributed in the hope that it will be useful, |
fab18da0956b
Added lm-sasl.[ch] from Senko
Mikael Hallendal <micke@imendio.com>
parents:
diff
changeset
|
11 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
fab18da0956b
Added lm-sasl.[ch] from Senko
Mikael Hallendal <micke@imendio.com>
parents:
diff
changeset
|
12 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
fab18da0956b
Added lm-sasl.[ch] from Senko
Mikael Hallendal <micke@imendio.com>
parents:
diff
changeset
|
13 |
* Lesser General Public License for more details. |
fab18da0956b
Added lm-sasl.[ch] from Senko
Mikael Hallendal <micke@imendio.com>
parents:
diff
changeset
|
14 |
* |
fab18da0956b
Added lm-sasl.[ch] from Senko
Mikael Hallendal <micke@imendio.com>
parents:
diff
changeset
|
15 |
* You should have received a copy of the GNU Lesser General Public |
690
7ccf2113ec5f
Update the postal address of the FSF
Frank Zschockelt <lm@freakysoft.de>
parents:
678
diff
changeset
|
16 |
* License along with this program; if not, see <https://www.gnu.org/licenses> |
216
fab18da0956b
Added lm-sasl.[ch] from Senko
Mikael Hallendal <micke@imendio.com>
parents:
diff
changeset
|
17 |
*/ |
fab18da0956b
Added lm-sasl.[ch] from Senko
Mikael Hallendal <micke@imendio.com>
parents:
diff
changeset
|
18 |
|
563
33ffbface103
Applied patch to add GSSAPI support to Loudmouth [#20]
Jelmer Vernooij <jelmer@samba.org>
parents:
540
diff
changeset
|
19 |
#include <config.h> |
33ffbface103
Applied patch to add GSSAPI support to Loudmouth [#20]
Jelmer Vernooij <jelmer@samba.org>
parents:
540
diff
changeset
|
20 |
|
216
fab18da0956b
Added lm-sasl.[ch] from Senko
Mikael Hallendal <micke@imendio.com>
parents:
diff
changeset
|
21 |
#include <stdio.h> |
fab18da0956b
Added lm-sasl.[ch] from Senko
Mikael Hallendal <micke@imendio.com>
parents:
diff
changeset
|
22 |
#include <string.h> |
fab18da0956b
Added lm-sasl.[ch] from Senko
Mikael Hallendal <micke@imendio.com>
parents:
diff
changeset
|
23 |
#include <glib.h> |
fab18da0956b
Added lm-sasl.[ch] from Senko
Mikael Hallendal <micke@imendio.com>
parents:
diff
changeset
|
24 |
|
563
33ffbface103
Applied patch to add GSSAPI support to Loudmouth [#20]
Jelmer Vernooij <jelmer@samba.org>
parents:
540
diff
changeset
|
25 |
#ifdef HAVE_GSSAPI |
678
66017d9f6187
include the right gssapi.h
Christoph Moench-Tegeder <cmt@burggraben.net>
parents:
664
diff
changeset
|
26 |
#include <gssapi/gssapi.h> |
563
33ffbface103
Applied patch to add GSSAPI support to Loudmouth [#20]
Jelmer Vernooij <jelmer@samba.org>
parents:
540
diff
changeset
|
27 |
#endif |
33ffbface103
Applied patch to add GSSAPI support to Loudmouth [#20]
Jelmer Vernooij <jelmer@samba.org>
parents:
540
diff
changeset
|
28 |
|
216
fab18da0956b
Added lm-sasl.[ch] from Senko
Mikael Hallendal <micke@imendio.com>
parents:
diff
changeset
|
29 |
#include "lm-sock.h" |
fab18da0956b
Added lm-sasl.[ch] from Senko
Mikael Hallendal <micke@imendio.com>
parents:
diff
changeset
|
30 |
#include "lm-debug.h" |
fab18da0956b
Added lm-sasl.[ch] from Senko
Mikael Hallendal <micke@imendio.com>
parents:
diff
changeset
|
31 |
#include "lm-error.h" |
fab18da0956b
Added lm-sasl.[ch] from Senko
Mikael Hallendal <micke@imendio.com>
parents:
diff
changeset
|
32 |
#include "lm-internals.h" |
fab18da0956b
Added lm-sasl.[ch] from Senko
Mikael Hallendal <micke@imendio.com>
parents:
diff
changeset
|
33 |
#include "lm-message-queue.h" |
fab18da0956b
Added lm-sasl.[ch] from Senko
Mikael Hallendal <micke@imendio.com>
parents:
diff
changeset
|
34 |
#include "lm-misc.h" |
fab18da0956b
Added lm-sasl.[ch] from Senko
Mikael Hallendal <micke@imendio.com>
parents:
diff
changeset
|
35 |
#include "lm-ssl-internals.h" |
fab18da0956b
Added lm-sasl.[ch] from Senko
Mikael Hallendal <micke@imendio.com>
parents:
diff
changeset
|
36 |
#include "lm-parser.h" |
fab18da0956b
Added lm-sasl.[ch] from Senko
Mikael Hallendal <micke@imendio.com>
parents:
diff
changeset
|
37 |
#include "lm-sha.h" |
fab18da0956b
Added lm-sasl.[ch] from Senko
Mikael Hallendal <micke@imendio.com>
parents:
diff
changeset
|
38 |
#include "lm-connection.h" |
fab18da0956b
Added lm-sasl.[ch] from Senko
Mikael Hallendal <micke@imendio.com>
parents:
diff
changeset
|
39 |
#include "lm-utils.h" |
431
04577a6b7ff7
Renamed LmSocket to LmOldSocket to make room for a new socket abstraction layer.
Mikael Hallendal <micke@imendio.com>
parents:
407
diff
changeset
|
40 |
#include "lm-old-socket.h" |
216
fab18da0956b
Added lm-sasl.[ch] from Senko
Mikael Hallendal <micke@imendio.com>
parents:
diff
changeset
|
41 |
#include "lm-sasl.h" |
fab18da0956b
Added lm-sasl.[ch] from Senko
Mikael Hallendal <micke@imendio.com>
parents:
diff
changeset
|
42 |
|
fab18da0956b
Added lm-sasl.[ch] from Senko
Mikael Hallendal <micke@imendio.com>
parents:
diff
changeset
|
43 |
#include "md5.h" |
fab18da0956b
Added lm-sasl.[ch] from Senko
Mikael Hallendal <micke@imendio.com>
parents:
diff
changeset
|
44 |
|
fab18da0956b
Added lm-sasl.[ch] from Senko
Mikael Hallendal <micke@imendio.com>
parents:
diff
changeset
|
45 |
typedef enum { |
518
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
516
diff
changeset
|
46 |
AUTH_TYPE_PLAIN = 1, |
563
33ffbface103
Applied patch to add GSSAPI support to Loudmouth [#20]
Jelmer Vernooij <jelmer@samba.org>
parents:
540
diff
changeset
|
47 |
AUTH_TYPE_DIGEST = 2, |
33ffbface103
Applied patch to add GSSAPI support to Loudmouth [#20]
Jelmer Vernooij <jelmer@samba.org>
parents:
540
diff
changeset
|
48 |
AUTH_TYPE_GSSAPI = 4, |
216
fab18da0956b
Added lm-sasl.[ch] from Senko
Mikael Hallendal <micke@imendio.com>
parents:
diff
changeset
|
49 |
} AuthType; |
fab18da0956b
Added lm-sasl.[ch] from Senko
Mikael Hallendal <micke@imendio.com>
parents:
diff
changeset
|
50 |
|
fab18da0956b
Added lm-sasl.[ch] from Senko
Mikael Hallendal <micke@imendio.com>
parents:
diff
changeset
|
51 |
typedef enum { |
518
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
516
diff
changeset
|
52 |
SASL_AUTH_STATE_NO_MECH, |
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
516
diff
changeset
|
53 |
SASL_AUTH_STATE_PLAIN_STARTED, |
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
516
diff
changeset
|
54 |
SASL_AUTH_STATE_DIGEST_MD5_STARTED, |
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
516
diff
changeset
|
55 |
SASL_AUTH_STATE_DIGEST_MD5_SENT_AUTH_RESPONSE, |
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
516
diff
changeset
|
56 |
SASL_AUTH_STATE_DIGEST_MD5_SENT_FINAL_RESPONSE, |
563
33ffbface103
Applied patch to add GSSAPI support to Loudmouth [#20]
Jelmer Vernooij <jelmer@samba.org>
parents:
540
diff
changeset
|
57 |
SASL_AUTH_STATE_GSSAPI_STARTED, |
33ffbface103
Applied patch to add GSSAPI support to Loudmouth [#20]
Jelmer Vernooij <jelmer@samba.org>
parents:
540
diff
changeset
|
58 |
SASL_AUTH_STATE_GSSAPI_SENT_AUTH_RESPONSE, |
33ffbface103
Applied patch to add GSSAPI support to Loudmouth [#20]
Jelmer Vernooij <jelmer@samba.org>
parents:
540
diff
changeset
|
59 |
SASL_AUTH_STATE_GSSAPI_SENT_FINAL_RESPONSE, |
216
fab18da0956b
Added lm-sasl.[ch] from Senko
Mikael Hallendal <micke@imendio.com>
parents:
diff
changeset
|
60 |
} SaslAuthState; |
fab18da0956b
Added lm-sasl.[ch] from Senko
Mikael Hallendal <micke@imendio.com>
parents:
diff
changeset
|
61 |
|
fab18da0956b
Added lm-sasl.[ch] from Senko
Mikael Hallendal <micke@imendio.com>
parents:
diff
changeset
|
62 |
struct _LmSASL { |
518
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
516
diff
changeset
|
63 |
LmConnection *connection; |
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
516
diff
changeset
|
64 |
AuthType auth_type; |
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
516
diff
changeset
|
65 |
SaslAuthState state; |
540
72acfccdec86
Switch to use LmAuthParameters instead of passing around username and password.
Mikael Hallendal <micke@imendio.com>
parents:
518
diff
changeset
|
66 |
LmAuthParameters *auth_params; |
518
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
516
diff
changeset
|
67 |
gchar *server; |
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
516
diff
changeset
|
68 |
gchar *digest_md5_rspauth; |
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
516
diff
changeset
|
69 |
LmMessageHandler *features_cb; |
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
516
diff
changeset
|
70 |
LmMessageHandler *challenge_cb; |
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
516
diff
changeset
|
71 |
LmMessageHandler *success_cb; |
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
516
diff
changeset
|
72 |
LmMessageHandler *failure_cb; |
216
fab18da0956b
Added lm-sasl.[ch] from Senko
Mikael Hallendal <micke@imendio.com>
parents:
diff
changeset
|
73 |
|
518
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
516
diff
changeset
|
74 |
gboolean features_received; |
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
516
diff
changeset
|
75 |
gboolean start_auth; |
255
704881ac7788
Fixed potential problem if auth was not called from the open callback.
Mikael Hallendal <micke@imendio.com>
parents:
227
diff
changeset
|
76 |
|
518
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
516
diff
changeset
|
77 |
LmSASLResultHandler handler; |
563
33ffbface103
Applied patch to add GSSAPI support to Loudmouth [#20]
Jelmer Vernooij <jelmer@samba.org>
parents:
540
diff
changeset
|
78 |
|
33ffbface103
Applied patch to add GSSAPI support to Loudmouth [#20]
Jelmer Vernooij <jelmer@samba.org>
parents:
540
diff
changeset
|
79 |
#ifdef HAVE_GSSAPI |
33ffbface103
Applied patch to add GSSAPI support to Loudmouth [#20]
Jelmer Vernooij <jelmer@samba.org>
parents:
540
diff
changeset
|
80 |
gss_ctx_id_t gss_ctx; |
33ffbface103
Applied patch to add GSSAPI support to Loudmouth [#20]
Jelmer Vernooij <jelmer@samba.org>
parents:
540
diff
changeset
|
81 |
gss_name_t gss_service; |
33ffbface103
Applied patch to add GSSAPI support to Loudmouth [#20]
Jelmer Vernooij <jelmer@samba.org>
parents:
540
diff
changeset
|
82 |
#endif |
216
fab18da0956b
Added lm-sasl.[ch] from Senko
Mikael Hallendal <micke@imendio.com>
parents:
diff
changeset
|
83 |
}; |
fab18da0956b
Added lm-sasl.[ch] from Senko
Mikael Hallendal <micke@imendio.com>
parents:
diff
changeset
|
84 |
|
fab18da0956b
Added lm-sasl.[ch] from Senko
Mikael Hallendal <micke@imendio.com>
parents:
diff
changeset
|
85 |
#define XMPP_NS_SASL_AUTH "urn:ietf:params:xml:ns:xmpp-sasl" |
fab18da0956b
Added lm-sasl.[ch] from Senko
Mikael Hallendal <micke@imendio.com>
parents:
diff
changeset
|
86 |
|
227
b8fa5635fb30
Conform with Loudmouth coding style
Mikael Hallendal <micke@imendio.com>
parents:
225
diff
changeset
|
87 |
static LmHandlerResult sasl_features_cb (LmMessageHandler *handler, |
518
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
516
diff
changeset
|
88 |
LmConnection *connection, |
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
516
diff
changeset
|
89 |
LmMessage *message, |
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
516
diff
changeset
|
90 |
gpointer user_data); |
216
fab18da0956b
Added lm-sasl.[ch] from Senko
Mikael Hallendal <micke@imendio.com>
parents:
diff
changeset
|
91 |
|
227
b8fa5635fb30
Conform with Loudmouth coding style
Mikael Hallendal <micke@imendio.com>
parents:
225
diff
changeset
|
92 |
static LmHandlerResult sasl_challenge_cb (LmMessageHandler *handler, |
518
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
516
diff
changeset
|
93 |
LmConnection *connection, |
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
516
diff
changeset
|
94 |
LmMessage *message, |
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
516
diff
changeset
|
95 |
gpointer user_data); |
216
fab18da0956b
Added lm-sasl.[ch] from Senko
Mikael Hallendal <micke@imendio.com>
parents:
diff
changeset
|
96 |
|
227
b8fa5635fb30
Conform with Loudmouth coding style
Mikael Hallendal <micke@imendio.com>
parents:
225
diff
changeset
|
97 |
static LmHandlerResult sasl_success_cb (LmMessageHandler *handler, |
518
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
516
diff
changeset
|
98 |
LmConnection *connection, |
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
516
diff
changeset
|
99 |
LmMessage *message, |
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
516
diff
changeset
|
100 |
gpointer user_data); |
216
fab18da0956b
Added lm-sasl.[ch] from Senko
Mikael Hallendal <micke@imendio.com>
parents:
diff
changeset
|
101 |
|
227
b8fa5635fb30
Conform with Loudmouth coding style
Mikael Hallendal <micke@imendio.com>
parents:
225
diff
changeset
|
102 |
static LmHandlerResult sasl_failure_cb (LmMessageHandler *handler, |
518
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
516
diff
changeset
|
103 |
LmConnection *connection, |
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
516
diff
changeset
|
104 |
LmMessage *message, |
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
516
diff
changeset
|
105 |
gpointer user_data); |
216
fab18da0956b
Added lm-sasl.[ch] from Senko
Mikael Hallendal <micke@imendio.com>
parents:
diff
changeset
|
106 |
|
fab18da0956b
Added lm-sasl.[ch] from Senko
Mikael Hallendal <micke@imendio.com>
parents:
diff
changeset
|
107 |
|
563
33ffbface103
Applied patch to add GSSAPI support to Loudmouth [#20]
Jelmer Vernooij <jelmer@samba.org>
parents:
540
diff
changeset
|
108 |
#ifdef HAVE_GSSAPI |
33ffbface103
Applied patch to add GSSAPI support to Loudmouth [#20]
Jelmer Vernooij <jelmer@samba.org>
parents:
540
diff
changeset
|
109 |
static gboolean |
33ffbface103
Applied patch to add GSSAPI support to Loudmouth [#20]
Jelmer Vernooij <jelmer@samba.org>
parents:
540
diff
changeset
|
110 |
sasl_gssapi_handle_challenge (LmSASL *sasl, LmMessageNode *node); |
33ffbface103
Applied patch to add GSSAPI support to Loudmouth [#20]
Jelmer Vernooij <jelmer@samba.org>
parents:
540
diff
changeset
|
111 |
|
33ffbface103
Applied patch to add GSSAPI support to Loudmouth [#20]
Jelmer Vernooij <jelmer@samba.org>
parents:
540
diff
changeset
|
112 |
static void |
607 | 113 |
sasl_gssapi_fail (LmSASL *sasl, |
563
33ffbface103
Applied patch to add GSSAPI support to Loudmouth [#20]
Jelmer Vernooij <jelmer@samba.org>
parents:
540
diff
changeset
|
114 |
const char *message, |
33ffbface103
Applied patch to add GSSAPI support to Loudmouth [#20]
Jelmer Vernooij <jelmer@samba.org>
parents:
540
diff
changeset
|
115 |
guint32 major_status, |
33ffbface103
Applied patch to add GSSAPI support to Loudmouth [#20]
Jelmer Vernooij <jelmer@samba.org>
parents:
540
diff
changeset
|
116 |
guint32 minor_status) |
33ffbface103
Applied patch to add GSSAPI support to Loudmouth [#20]
Jelmer Vernooij <jelmer@samba.org>
parents:
540
diff
changeset
|
117 |
{ |
564
db3e9ff448cb
Style fixes for GSSAPI changes [#20].
Mikael Hallendal <micke@imendio.com>
parents:
563
diff
changeset
|
118 |
guint32 err_major_status; |
db3e9ff448cb
Style fixes for GSSAPI changes [#20].
Mikael Hallendal <micke@imendio.com>
parents:
563
diff
changeset
|
119 |
guint32 err_minor_status; |
db3e9ff448cb
Style fixes for GSSAPI changes [#20].
Mikael Hallendal <micke@imendio.com>
parents:
563
diff
changeset
|
120 |
guint32 msg_ctx = 0; |
db3e9ff448cb
Style fixes for GSSAPI changes [#20].
Mikael Hallendal <micke@imendio.com>
parents:
563
diff
changeset
|
121 |
gss_buffer_desc major_status_string = GSS_C_EMPTY_BUFFER; |
db3e9ff448cb
Style fixes for GSSAPI changes [#20].
Mikael Hallendal <micke@imendio.com>
parents:
563
diff
changeset
|
122 |
gss_buffer_desc minor_status_string = GSS_C_EMPTY_BUFFER; |
563
33ffbface103
Applied patch to add GSSAPI support to Loudmouth [#20]
Jelmer Vernooij <jelmer@samba.org>
parents:
540
diff
changeset
|
123 |
|
33ffbface103
Applied patch to add GSSAPI support to Loudmouth [#20]
Jelmer Vernooij <jelmer@samba.org>
parents:
540
diff
changeset
|
124 |
err_major_status = gss_display_status (&err_minor_status, major_status, |
607 | 125 |
GSS_C_GSS_CODE, GSS_C_NO_OID, |
563
33ffbface103
Applied patch to add GSSAPI support to Loudmouth [#20]
Jelmer Vernooij <jelmer@samba.org>
parents:
540
diff
changeset
|
126 |
&msg_ctx, &major_status_string); |
33ffbface103
Applied patch to add GSSAPI support to Loudmouth [#20]
Jelmer Vernooij <jelmer@samba.org>
parents:
540
diff
changeset
|
127 |
|
564
db3e9ff448cb
Style fixes for GSSAPI changes [#20].
Mikael Hallendal <micke@imendio.com>
parents:
563
diff
changeset
|
128 |
if (!GSS_ERROR(err_major_status)) { |
563
33ffbface103
Applied patch to add GSSAPI support to Loudmouth [#20]
Jelmer Vernooij <jelmer@samba.org>
parents:
540
diff
changeset
|
129 |
err_major_status = gss_display_status (&err_minor_status, minor_status, |
33ffbface103
Applied patch to add GSSAPI support to Loudmouth [#20]
Jelmer Vernooij <jelmer@samba.org>
parents:
540
diff
changeset
|
130 |
GSS_C_MECH_CODE, GSS_C_NULL_OID, |
33ffbface103
Applied patch to add GSSAPI support to Loudmouth [#20]
Jelmer Vernooij <jelmer@samba.org>
parents:
540
diff
changeset
|
131 |
&msg_ctx, &minor_status_string); |
564
db3e9ff448cb
Style fixes for GSSAPI changes [#20].
Mikael Hallendal <micke@imendio.com>
parents:
563
diff
changeset
|
132 |
} |
563
33ffbface103
Applied patch to add GSSAPI support to Loudmouth [#20]
Jelmer Vernooij <jelmer@samba.org>
parents:
540
diff
changeset
|
133 |
|
33ffbface103
Applied patch to add GSSAPI support to Loudmouth [#20]
Jelmer Vernooij <jelmer@samba.org>
parents:
540
diff
changeset
|
134 |
g_log (LM_LOG_DOMAIN, LM_LOG_LEVEL_SASL, "GSSAPI: %s: %s, %s", message, |
33ffbface103
Applied patch to add GSSAPI support to Loudmouth [#20]
Jelmer Vernooij <jelmer@samba.org>
parents:
540
diff
changeset
|
135 |
(char *)major_status_string.value, |
33ffbface103
Applied patch to add GSSAPI support to Loudmouth [#20]
Jelmer Vernooij <jelmer@samba.org>
parents:
540
diff
changeset
|
136 |
(char *)minor_status_string.value); |
33ffbface103
Applied patch to add GSSAPI support to Loudmouth [#20]
Jelmer Vernooij <jelmer@samba.org>
parents:
540
diff
changeset
|
137 |
|
33ffbface103
Applied patch to add GSSAPI support to Loudmouth [#20]
Jelmer Vernooij <jelmer@samba.org>
parents:
540
diff
changeset
|
138 |
if (sasl->handler) { |
564
db3e9ff448cb
Style fixes for GSSAPI changes [#20].
Mikael Hallendal <micke@imendio.com>
parents:
563
diff
changeset
|
139 |
sasl->handler (sasl, sasl->connection, FALSE, "GSSAPI failure"); |
563
33ffbface103
Applied patch to add GSSAPI support to Loudmouth [#20]
Jelmer Vernooij <jelmer@samba.org>
parents:
540
diff
changeset
|
140 |
} |
33ffbface103
Applied patch to add GSSAPI support to Loudmouth [#20]
Jelmer Vernooij <jelmer@samba.org>
parents:
540
diff
changeset
|
141 |
|
564
db3e9ff448cb
Style fixes for GSSAPI changes [#20].
Mikael Hallendal <micke@imendio.com>
parents:
563
diff
changeset
|
142 |
gss_release_buffer (&err_minor_status, &major_status_string); |
db3e9ff448cb
Style fixes for GSSAPI changes [#20].
Mikael Hallendal <micke@imendio.com>
parents:
563
diff
changeset
|
143 |
gss_release_buffer (&err_minor_status, &minor_status_string); |
563
33ffbface103
Applied patch to add GSSAPI support to Loudmouth [#20]
Jelmer Vernooij <jelmer@samba.org>
parents:
540
diff
changeset
|
144 |
} |
33ffbface103
Applied patch to add GSSAPI support to Loudmouth [#20]
Jelmer Vernooij <jelmer@samba.org>
parents:
540
diff
changeset
|
145 |
|
33ffbface103
Applied patch to add GSSAPI support to Loudmouth [#20]
Jelmer Vernooij <jelmer@samba.org>
parents:
540
diff
changeset
|
146 |
static gss_name_t |
33ffbface103
Applied patch to add GSSAPI support to Loudmouth [#20]
Jelmer Vernooij <jelmer@samba.org>
parents:
540
diff
changeset
|
147 |
sasl_gssapi_get_creds (LmSASL *sasl) |
33ffbface103
Applied patch to add GSSAPI support to Loudmouth [#20]
Jelmer Vernooij <jelmer@samba.org>
parents:
540
diff
changeset
|
148 |
{ |
33ffbface103
Applied patch to add GSSAPI support to Loudmouth [#20]
Jelmer Vernooij <jelmer@samba.org>
parents:
540
diff
changeset
|
149 |
gss_buffer_desc token = GSS_C_EMPTY_BUFFER; |
564
db3e9ff448cb
Style fixes for GSSAPI changes [#20].
Mikael Hallendal <micke@imendio.com>
parents:
563
diff
changeset
|
150 |
gss_name_t service_name = GSS_C_NO_NAME; |
db3e9ff448cb
Style fixes for GSSAPI changes [#20].
Mikael Hallendal <micke@imendio.com>
parents:
563
diff
changeset
|
151 |
guint32 major_status; |
db3e9ff448cb
Style fixes for GSSAPI changes [#20].
Mikael Hallendal <micke@imendio.com>
parents:
563
diff
changeset
|
152 |
guint32 minor_status; |
563
33ffbface103
Applied patch to add GSSAPI support to Loudmouth [#20]
Jelmer Vernooij <jelmer@samba.org>
parents:
540
diff
changeset
|
153 |
|
664
f57b1b61e1fe
Remove trailing whitespace and mixed indenting
Till Maas <opensource@till.name>
parents:
624
diff
changeset
|
154 |
token.value = g_strdup_printf ("xmpp@%s", sasl->server); |
563
33ffbface103
Applied patch to add GSSAPI support to Loudmouth [#20]
Jelmer Vernooij <jelmer@samba.org>
parents:
540
diff
changeset
|
155 |
token.length = strlen ((char *)token.value); |
33ffbface103
Applied patch to add GSSAPI support to Loudmouth [#20]
Jelmer Vernooij <jelmer@samba.org>
parents:
540
diff
changeset
|
156 |
|
33ffbface103
Applied patch to add GSSAPI support to Loudmouth [#20]
Jelmer Vernooij <jelmer@samba.org>
parents:
540
diff
changeset
|
157 |
if (token.value == NULL) { |
33ffbface103
Applied patch to add GSSAPI support to Loudmouth [#20]
Jelmer Vernooij <jelmer@samba.org>
parents:
540
diff
changeset
|
158 |
return GSS_C_NO_NAME; |
33ffbface103
Applied patch to add GSSAPI support to Loudmouth [#20]
Jelmer Vernooij <jelmer@samba.org>
parents:
540
diff
changeset
|
159 |
} |
33ffbface103
Applied patch to add GSSAPI support to Loudmouth [#20]
Jelmer Vernooij <jelmer@samba.org>
parents:
540
diff
changeset
|
160 |
|
33ffbface103
Applied patch to add GSSAPI support to Loudmouth [#20]
Jelmer Vernooij <jelmer@samba.org>
parents:
540
diff
changeset
|
161 |
major_status = gss_import_name (&minor_status, &token, |
33ffbface103
Applied patch to add GSSAPI support to Loudmouth [#20]
Jelmer Vernooij <jelmer@samba.org>
parents:
540
diff
changeset
|
162 |
GSS_C_NT_HOSTBASED_SERVICE, |
33ffbface103
Applied patch to add GSSAPI support to Loudmouth [#20]
Jelmer Vernooij <jelmer@samba.org>
parents:
540
diff
changeset
|
163 |
&service_name); |
33ffbface103
Applied patch to add GSSAPI support to Loudmouth [#20]
Jelmer Vernooij <jelmer@samba.org>
parents:
540
diff
changeset
|
164 |
|
564
db3e9ff448cb
Style fixes for GSSAPI changes [#20].
Mikael Hallendal <micke@imendio.com>
parents:
563
diff
changeset
|
165 |
if (GSS_ERROR(major_status)) { |
563
33ffbface103
Applied patch to add GSSAPI support to Loudmouth [#20]
Jelmer Vernooij <jelmer@samba.org>
parents:
540
diff
changeset
|
166 |
sasl_gssapi_fail (sasl, "while obtaining service principal", |
33ffbface103
Applied patch to add GSSAPI support to Loudmouth [#20]
Jelmer Vernooij <jelmer@samba.org>
parents:
540
diff
changeset
|
167 |
major_status, minor_status); |
33ffbface103
Applied patch to add GSSAPI support to Loudmouth [#20]
Jelmer Vernooij <jelmer@samba.org>
parents:
540
diff
changeset
|
168 |
return GSS_C_NO_NAME; |
33ffbface103
Applied patch to add GSSAPI support to Loudmouth [#20]
Jelmer Vernooij <jelmer@samba.org>
parents:
540
diff
changeset
|
169 |
} |
33ffbface103
Applied patch to add GSSAPI support to Loudmouth [#20]
Jelmer Vernooij <jelmer@samba.org>
parents:
540
diff
changeset
|
170 |
|
33ffbface103
Applied patch to add GSSAPI support to Loudmouth [#20]
Jelmer Vernooij <jelmer@samba.org>
parents:
540
diff
changeset
|
171 |
return service_name; |
33ffbface103
Applied patch to add GSSAPI support to Loudmouth [#20]
Jelmer Vernooij <jelmer@samba.org>
parents:
540
diff
changeset
|
172 |
} |
33ffbface103
Applied patch to add GSSAPI support to Loudmouth [#20]
Jelmer Vernooij <jelmer@samba.org>
parents:
540
diff
changeset
|
173 |
|
33ffbface103
Applied patch to add GSSAPI support to Loudmouth [#20]
Jelmer Vernooij <jelmer@samba.org>
parents:
540
diff
changeset
|
174 |
static gboolean |
33ffbface103
Applied patch to add GSSAPI support to Loudmouth [#20]
Jelmer Vernooij <jelmer@samba.org>
parents:
540
diff
changeset
|
175 |
sasl_gssapi_start (LmSASL *sasl, LmMessageNode *node) |
33ffbface103
Applied patch to add GSSAPI support to Loudmouth [#20]
Jelmer Vernooij <jelmer@samba.org>
parents:
540
diff
changeset
|
176 |
{ |
564
db3e9ff448cb
Style fixes for GSSAPI changes [#20].
Mikael Hallendal <micke@imendio.com>
parents:
563
diff
changeset
|
177 |
gchar *response64; |
db3e9ff448cb
Style fixes for GSSAPI changes [#20].
Mikael Hallendal <micke@imendio.com>
parents:
563
diff
changeset
|
178 |
gss_buffer_desc input_buffer_desc; |
db3e9ff448cb
Style fixes for GSSAPI changes [#20].
Mikael Hallendal <micke@imendio.com>
parents:
563
diff
changeset
|
179 |
gss_buffer_t input_buffer; |
db3e9ff448cb
Style fixes for GSSAPI changes [#20].
Mikael Hallendal <micke@imendio.com>
parents:
563
diff
changeset
|
180 |
gss_buffer_desc output_buffer_desc; |
db3e9ff448cb
Style fixes for GSSAPI changes [#20].
Mikael Hallendal <micke@imendio.com>
parents:
563
diff
changeset
|
181 |
gss_buffer_t output_buffer; |
db3e9ff448cb
Style fixes for GSSAPI changes [#20].
Mikael Hallendal <micke@imendio.com>
parents:
563
diff
changeset
|
182 |
guint32 major_status; |
db3e9ff448cb
Style fixes for GSSAPI changes [#20].
Mikael Hallendal <micke@imendio.com>
parents:
563
diff
changeset
|
183 |
guint32 minor_status; |
563
33ffbface103
Applied patch to add GSSAPI support to Loudmouth [#20]
Jelmer Vernooij <jelmer@samba.org>
parents:
540
diff
changeset
|
184 |
|
33ffbface103
Applied patch to add GSSAPI support to Loudmouth [#20]
Jelmer Vernooij <jelmer@samba.org>
parents:
540
diff
changeset
|
185 |
sasl->gss_ctx = GSS_C_NO_CONTEXT; |
33ffbface103
Applied patch to add GSSAPI support to Loudmouth [#20]
Jelmer Vernooij <jelmer@samba.org>
parents:
540
diff
changeset
|
186 |
sasl->gss_service = sasl_gssapi_get_creds (sasl); |
33ffbface103
Applied patch to add GSSAPI support to Loudmouth [#20]
Jelmer Vernooij <jelmer@samba.org>
parents:
540
diff
changeset
|
187 |
if (sasl->gss_service == GSS_C_NO_NAME) { |
33ffbface103
Applied patch to add GSSAPI support to Loudmouth [#20]
Jelmer Vernooij <jelmer@samba.org>
parents:
540
diff
changeset
|
188 |
return FALSE; |
33ffbface103
Applied patch to add GSSAPI support to Loudmouth [#20]
Jelmer Vernooij <jelmer@samba.org>
parents:
540
diff
changeset
|
189 |
} |
33ffbface103
Applied patch to add GSSAPI support to Loudmouth [#20]
Jelmer Vernooij <jelmer@samba.org>
parents:
540
diff
changeset
|
190 |
|
33ffbface103
Applied patch to add GSSAPI support to Loudmouth [#20]
Jelmer Vernooij <jelmer@samba.org>
parents:
540
diff
changeset
|
191 |
sasl->state = SASL_AUTH_STATE_GSSAPI_STARTED; |
33ffbface103
Applied patch to add GSSAPI support to Loudmouth [#20]
Jelmer Vernooij <jelmer@samba.org>
parents:
540
diff
changeset
|
192 |
|
33ffbface103
Applied patch to add GSSAPI support to Loudmouth [#20]
Jelmer Vernooij <jelmer@samba.org>
parents:
540
diff
changeset
|
193 |
input_buffer_desc.value = NULL; |
33ffbface103
Applied patch to add GSSAPI support to Loudmouth [#20]
Jelmer Vernooij <jelmer@samba.org>
parents:
540
diff
changeset
|
194 |
input_buffer_desc.length = 0; |
33ffbface103
Applied patch to add GSSAPI support to Loudmouth [#20]
Jelmer Vernooij <jelmer@samba.org>
parents:
540
diff
changeset
|
195 |
|
33ffbface103
Applied patch to add GSSAPI support to Loudmouth [#20]
Jelmer Vernooij <jelmer@samba.org>
parents:
540
diff
changeset
|
196 |
input_buffer = &input_buffer_desc; |
33ffbface103
Applied patch to add GSSAPI support to Loudmouth [#20]
Jelmer Vernooij <jelmer@samba.org>
parents:
540
diff
changeset
|
197 |
|
33ffbface103
Applied patch to add GSSAPI support to Loudmouth [#20]
Jelmer Vernooij <jelmer@samba.org>
parents:
540
diff
changeset
|
198 |
output_buffer_desc.value = NULL; |
33ffbface103
Applied patch to add GSSAPI support to Loudmouth [#20]
Jelmer Vernooij <jelmer@samba.org>
parents:
540
diff
changeset
|
199 |
output_buffer_desc.length = 0; |
33ffbface103
Applied patch to add GSSAPI support to Loudmouth [#20]
Jelmer Vernooij <jelmer@samba.org>
parents:
540
diff
changeset
|
200 |
output_buffer = &output_buffer_desc; |
33ffbface103
Applied patch to add GSSAPI support to Loudmouth [#20]
Jelmer Vernooij <jelmer@samba.org>
parents:
540
diff
changeset
|
201 |
|
33ffbface103
Applied patch to add GSSAPI support to Loudmouth [#20]
Jelmer Vernooij <jelmer@samba.org>
parents:
540
diff
changeset
|
202 |
major_status = gss_init_sec_context (&minor_status, |
33ffbface103
Applied patch to add GSSAPI support to Loudmouth [#20]
Jelmer Vernooij <jelmer@samba.org>
parents:
540
diff
changeset
|
203 |
GSS_C_NO_CREDENTIAL, |
33ffbface103
Applied patch to add GSSAPI support to Loudmouth [#20]
Jelmer Vernooij <jelmer@samba.org>
parents:
540
diff
changeset
|
204 |
&sasl->gss_ctx, |
33ffbface103
Applied patch to add GSSAPI support to Loudmouth [#20]
Jelmer Vernooij <jelmer@samba.org>
parents:
540
diff
changeset
|
205 |
sasl->gss_service, |
33ffbface103
Applied patch to add GSSAPI support to Loudmouth [#20]
Jelmer Vernooij <jelmer@samba.org>
parents:
540
diff
changeset
|
206 |
GSS_C_NO_OID, |
33ffbface103
Applied patch to add GSSAPI support to Loudmouth [#20]
Jelmer Vernooij <jelmer@samba.org>
parents:
540
diff
changeset
|
207 |
GSS_C_MUTUAL_FLAG | |
33ffbface103
Applied patch to add GSSAPI support to Loudmouth [#20]
Jelmer Vernooij <jelmer@samba.org>
parents:
540
diff
changeset
|
208 |
GSS_C_REPLAY_FLAG | |
33ffbface103
Applied patch to add GSSAPI support to Loudmouth [#20]
Jelmer Vernooij <jelmer@samba.org>
parents:
540
diff
changeset
|
209 |
GSS_C_SEQUENCE_FLAG | |
33ffbface103
Applied patch to add GSSAPI support to Loudmouth [#20]
Jelmer Vernooij <jelmer@samba.org>
parents:
540
diff
changeset
|
210 |
GSS_C_INTEG_FLAG | |
33ffbface103
Applied patch to add GSSAPI support to Loudmouth [#20]
Jelmer Vernooij <jelmer@samba.org>
parents:
540
diff
changeset
|
211 |
GSS_C_CONF_FLAG, |
33ffbface103
Applied patch to add GSSAPI support to Loudmouth [#20]
Jelmer Vernooij <jelmer@samba.org>
parents:
540
diff
changeset
|
212 |
0, |
33ffbface103
Applied patch to add GSSAPI support to Loudmouth [#20]
Jelmer Vernooij <jelmer@samba.org>
parents:
540
diff
changeset
|
213 |
GSS_C_NO_CHANNEL_BINDINGS, |
33ffbface103
Applied patch to add GSSAPI support to Loudmouth [#20]
Jelmer Vernooij <jelmer@samba.org>
parents:
540
diff
changeset
|
214 |
input_buffer, NULL, output_buffer, NULL, NULL); |
33ffbface103
Applied patch to add GSSAPI support to Loudmouth [#20]
Jelmer Vernooij <jelmer@samba.org>
parents:
540
diff
changeset
|
215 |
|
33ffbface103
Applied patch to add GSSAPI support to Loudmouth [#20]
Jelmer Vernooij <jelmer@samba.org>
parents:
540
diff
changeset
|
216 |
if (GSS_ERROR(major_status)) { |
33ffbface103
Applied patch to add GSSAPI support to Loudmouth [#20]
Jelmer Vernooij <jelmer@samba.org>
parents:
540
diff
changeset
|
217 |
sasl_gssapi_fail (sasl, "during challenge/response", |
33ffbface103
Applied patch to add GSSAPI support to Loudmouth [#20]
Jelmer Vernooij <jelmer@samba.org>
parents:
540
diff
changeset
|
218 |
major_status, minor_status); |
33ffbface103
Applied patch to add GSSAPI support to Loudmouth [#20]
Jelmer Vernooij <jelmer@samba.org>
parents:
540
diff
changeset
|
219 |
return FALSE; |
33ffbface103
Applied patch to add GSSAPI support to Loudmouth [#20]
Jelmer Vernooij <jelmer@samba.org>
parents:
540
diff
changeset
|
220 |
} |
33ffbface103
Applied patch to add GSSAPI support to Loudmouth [#20]
Jelmer Vernooij <jelmer@samba.org>
parents:
540
diff
changeset
|
221 |
|
564
db3e9ff448cb
Style fixes for GSSAPI changes [#20].
Mikael Hallendal <micke@imendio.com>
parents:
563
diff
changeset
|
222 |
if (major_status != GSS_S_CONTINUE_NEEDED) { |
563
33ffbface103
Applied patch to add GSSAPI support to Loudmouth [#20]
Jelmer Vernooij <jelmer@samba.org>
parents:
540
diff
changeset
|
223 |
sasl->state = SASL_AUTH_STATE_GSSAPI_SENT_AUTH_RESPONSE; |
564
db3e9ff448cb
Style fixes for GSSAPI changes [#20].
Mikael Hallendal <micke@imendio.com>
parents:
563
diff
changeset
|
224 |
} |
563
33ffbface103
Applied patch to add GSSAPI support to Loudmouth [#20]
Jelmer Vernooij <jelmer@samba.org>
parents:
540
diff
changeset
|
225 |
|
33ffbface103
Applied patch to add GSSAPI support to Loudmouth [#20]
Jelmer Vernooij <jelmer@samba.org>
parents:
540
diff
changeset
|
226 |
response64 = g_base64_encode ((const guchar *) output_buffer_desc.value, |
33ffbface103
Applied patch to add GSSAPI support to Loudmouth [#20]
Jelmer Vernooij <jelmer@samba.org>
parents:
540
diff
changeset
|
227 |
(gsize) output_buffer_desc.length); |
33ffbface103
Applied patch to add GSSAPI support to Loudmouth [#20]
Jelmer Vernooij <jelmer@samba.org>
parents:
540
diff
changeset
|
228 |
|
33ffbface103
Applied patch to add GSSAPI support to Loudmouth [#20]
Jelmer Vernooij <jelmer@samba.org>
parents:
540
diff
changeset
|
229 |
lm_message_node_set_value (node, response64); |
33ffbface103
Applied patch to add GSSAPI support to Loudmouth [#20]
Jelmer Vernooij <jelmer@samba.org>
parents:
540
diff
changeset
|
230 |
|
33ffbface103
Applied patch to add GSSAPI support to Loudmouth [#20]
Jelmer Vernooij <jelmer@samba.org>
parents:
540
diff
changeset
|
231 |
g_free (response64); |
33ffbface103
Applied patch to add GSSAPI support to Loudmouth [#20]
Jelmer Vernooij <jelmer@samba.org>
parents:
540
diff
changeset
|
232 |
|
33ffbface103
Applied patch to add GSSAPI support to Loudmouth [#20]
Jelmer Vernooij <jelmer@samba.org>
parents:
540
diff
changeset
|
233 |
return TRUE; |
33ffbface103
Applied patch to add GSSAPI support to Loudmouth [#20]
Jelmer Vernooij <jelmer@samba.org>
parents:
540
diff
changeset
|
234 |
} |
33ffbface103
Applied patch to add GSSAPI support to Loudmouth [#20]
Jelmer Vernooij <jelmer@samba.org>
parents:
540
diff
changeset
|
235 |
|
33ffbface103
Applied patch to add GSSAPI support to Loudmouth [#20]
Jelmer Vernooij <jelmer@samba.org>
parents:
540
diff
changeset
|
236 |
static gboolean |
33ffbface103
Applied patch to add GSSAPI support to Loudmouth [#20]
Jelmer Vernooij <jelmer@samba.org>
parents:
540
diff
changeset
|
237 |
sasl_gssapi_handle_challenge (LmSASL *sasl, LmMessageNode *node) |
33ffbface103
Applied patch to add GSSAPI support to Loudmouth [#20]
Jelmer Vernooij <jelmer@samba.org>
parents:
540
diff
changeset
|
238 |
{ |
564
db3e9ff448cb
Style fixes for GSSAPI changes [#20].
Mikael Hallendal <micke@imendio.com>
parents:
563
diff
changeset
|
239 |
const gchar *encoded; |
db3e9ff448cb
Style fixes for GSSAPI changes [#20].
Mikael Hallendal <micke@imendio.com>
parents:
563
diff
changeset
|
240 |
gchar *response64; |
db3e9ff448cb
Style fixes for GSSAPI changes [#20].
Mikael Hallendal <micke@imendio.com>
parents:
563
diff
changeset
|
241 |
gss_buffer_t input_buffer; |
db3e9ff448cb
Style fixes for GSSAPI changes [#20].
Mikael Hallendal <micke@imendio.com>
parents:
563
diff
changeset
|
242 |
gss_buffer_desc input_buffer_desc; |
db3e9ff448cb
Style fixes for GSSAPI changes [#20].
Mikael Hallendal <micke@imendio.com>
parents:
563
diff
changeset
|
243 |
gss_buffer_t output_buffer; |
db3e9ff448cb
Style fixes for GSSAPI changes [#20].
Mikael Hallendal <micke@imendio.com>
parents:
563
diff
changeset
|
244 |
gss_buffer_desc output_buffer_desc; |
db3e9ff448cb
Style fixes for GSSAPI changes [#20].
Mikael Hallendal <micke@imendio.com>
parents:
563
diff
changeset
|
245 |
guint32 major_status; |
db3e9ff448cb
Style fixes for GSSAPI changes [#20].
Mikael Hallendal <micke@imendio.com>
parents:
563
diff
changeset
|
246 |
guint32 minor_status; |
db3e9ff448cb
Style fixes for GSSAPI changes [#20].
Mikael Hallendal <micke@imendio.com>
parents:
563
diff
changeset
|
247 |
gboolean result; |
db3e9ff448cb
Style fixes for GSSAPI changes [#20].
Mikael Hallendal <micke@imendio.com>
parents:
563
diff
changeset
|
248 |
LmMessage *msg; |
563
33ffbface103
Applied patch to add GSSAPI support to Loudmouth [#20]
Jelmer Vernooij <jelmer@samba.org>
parents:
540
diff
changeset
|
249 |
|
33ffbface103
Applied patch to add GSSAPI support to Loudmouth [#20]
Jelmer Vernooij <jelmer@samba.org>
parents:
540
diff
changeset
|
250 |
encoded = lm_message_node_get_value (node); |
33ffbface103
Applied patch to add GSSAPI support to Loudmouth [#20]
Jelmer Vernooij <jelmer@samba.org>
parents:
540
diff
changeset
|
251 |
if (encoded == NULL) { |
33ffbface103
Applied patch to add GSSAPI support to Loudmouth [#20]
Jelmer Vernooij <jelmer@samba.org>
parents:
540
diff
changeset
|
252 |
input_buffer_desc.value = NULL; |
33ffbface103
Applied patch to add GSSAPI support to Loudmouth [#20]
Jelmer Vernooij <jelmer@samba.org>
parents:
540
diff
changeset
|
253 |
input_buffer_desc.length = 0; |
33ffbface103
Applied patch to add GSSAPI support to Loudmouth [#20]
Jelmer Vernooij <jelmer@samba.org>
parents:
540
diff
changeset
|
254 |
} else { |
571
6fb1c4046db7
Fixed compile when GSSAPI support is enabled. [#20]
Jelmer Vernooij <jelmer@samba.org>
parents:
564
diff
changeset
|
255 |
input_buffer_desc.value = g_base64_decode (encoded, |
563
33ffbface103
Applied patch to add GSSAPI support to Loudmouth [#20]
Jelmer Vernooij <jelmer@samba.org>
parents:
540
diff
changeset
|
256 |
&input_buffer_desc.length); |
33ffbface103
Applied patch to add GSSAPI support to Loudmouth [#20]
Jelmer Vernooij <jelmer@samba.org>
parents:
540
diff
changeset
|
257 |
} |
564
db3e9ff448cb
Style fixes for GSSAPI changes [#20].
Mikael Hallendal <micke@imendio.com>
parents:
563
diff
changeset
|
258 |
|
563
33ffbface103
Applied patch to add GSSAPI support to Loudmouth [#20]
Jelmer Vernooij <jelmer@samba.org>
parents:
540
diff
changeset
|
259 |
input_buffer = &input_buffer_desc; |
33ffbface103
Applied patch to add GSSAPI support to Loudmouth [#20]
Jelmer Vernooij <jelmer@samba.org>
parents:
540
diff
changeset
|
260 |
|
33ffbface103
Applied patch to add GSSAPI support to Loudmouth [#20]
Jelmer Vernooij <jelmer@samba.org>
parents:
540
diff
changeset
|
261 |
output_buffer_desc.value = NULL; |
33ffbface103
Applied patch to add GSSAPI support to Loudmouth [#20]
Jelmer Vernooij <jelmer@samba.org>
parents:
540
diff
changeset
|
262 |
output_buffer_desc.length = 0; |
33ffbface103
Applied patch to add GSSAPI support to Loudmouth [#20]
Jelmer Vernooij <jelmer@samba.org>
parents:
540
diff
changeset
|
263 |
output_buffer = &output_buffer_desc; |
33ffbface103
Applied patch to add GSSAPI support to Loudmouth [#20]
Jelmer Vernooij <jelmer@samba.org>
parents:
540
diff
changeset
|
264 |
|
33ffbface103
Applied patch to add GSSAPI support to Loudmouth [#20]
Jelmer Vernooij <jelmer@samba.org>
parents:
540
diff
changeset
|
265 |
if (sasl->state == SASL_AUTH_STATE_GSSAPI_STARTED) { |
33ffbface103
Applied patch to add GSSAPI support to Loudmouth [#20]
Jelmer Vernooij <jelmer@samba.org>
parents:
540
diff
changeset
|
266 |
major_status = gss_init_sec_context (&minor_status, |
33ffbface103
Applied patch to add GSSAPI support to Loudmouth [#20]
Jelmer Vernooij <jelmer@samba.org>
parents:
540
diff
changeset
|
267 |
GSS_C_NO_CREDENTIAL, |
33ffbface103
Applied patch to add GSSAPI support to Loudmouth [#20]
Jelmer Vernooij <jelmer@samba.org>
parents:
540
diff
changeset
|
268 |
&sasl->gss_ctx, |
33ffbface103
Applied patch to add GSSAPI support to Loudmouth [#20]
Jelmer Vernooij <jelmer@samba.org>
parents:
540
diff
changeset
|
269 |
sasl->gss_service, |
33ffbface103
Applied patch to add GSSAPI support to Loudmouth [#20]
Jelmer Vernooij <jelmer@samba.org>
parents:
540
diff
changeset
|
270 |
GSS_C_NO_OID, |
33ffbface103
Applied patch to add GSSAPI support to Loudmouth [#20]
Jelmer Vernooij <jelmer@samba.org>
parents:
540
diff
changeset
|
271 |
GSS_C_MUTUAL_FLAG | |
33ffbface103
Applied patch to add GSSAPI support to Loudmouth [#20]
Jelmer Vernooij <jelmer@samba.org>
parents:
540
diff
changeset
|
272 |
GSS_C_REPLAY_FLAG | |
33ffbface103
Applied patch to add GSSAPI support to Loudmouth [#20]
Jelmer Vernooij <jelmer@samba.org>
parents:
540
diff
changeset
|
273 |
GSS_C_SEQUENCE_FLAG | |
33ffbface103
Applied patch to add GSSAPI support to Loudmouth [#20]
Jelmer Vernooij <jelmer@samba.org>
parents:
540
diff
changeset
|
274 |
GSS_C_INTEG_FLAG | |
33ffbface103
Applied patch to add GSSAPI support to Loudmouth [#20]
Jelmer Vernooij <jelmer@samba.org>
parents:
540
diff
changeset
|
275 |
GSS_C_CONF_FLAG, |
33ffbface103
Applied patch to add GSSAPI support to Loudmouth [#20]
Jelmer Vernooij <jelmer@samba.org>
parents:
540
diff
changeset
|
276 |
0, |
33ffbface103
Applied patch to add GSSAPI support to Loudmouth [#20]
Jelmer Vernooij <jelmer@samba.org>
parents:
540
diff
changeset
|
277 |
GSS_C_NO_CHANNEL_BINDINGS, |
33ffbface103
Applied patch to add GSSAPI support to Loudmouth [#20]
Jelmer Vernooij <jelmer@samba.org>
parents:
540
diff
changeset
|
278 |
input_buffer, NULL, output_buffer, NULL, NULL); |
33ffbface103
Applied patch to add GSSAPI support to Loudmouth [#20]
Jelmer Vernooij <jelmer@samba.org>
parents:
540
diff
changeset
|
279 |
|
33ffbface103
Applied patch to add GSSAPI support to Loudmouth [#20]
Jelmer Vernooij <jelmer@samba.org>
parents:
540
diff
changeset
|
280 |
if (GSS_ERROR(major_status)) { |
33ffbface103
Applied patch to add GSSAPI support to Loudmouth [#20]
Jelmer Vernooij <jelmer@samba.org>
parents:
540
diff
changeset
|
281 |
sasl_gssapi_fail (sasl, "during challenge/response", |
33ffbface103
Applied patch to add GSSAPI support to Loudmouth [#20]
Jelmer Vernooij <jelmer@samba.org>
parents:
540
diff
changeset
|
282 |
major_status, minor_status); |
33ffbface103
Applied patch to add GSSAPI support to Loudmouth [#20]
Jelmer Vernooij <jelmer@samba.org>
parents:
540
diff
changeset
|
283 |
return FALSE; |
33ffbface103
Applied patch to add GSSAPI support to Loudmouth [#20]
Jelmer Vernooij <jelmer@samba.org>
parents:
540
diff
changeset
|
284 |
} |
33ffbface103
Applied patch to add GSSAPI support to Loudmouth [#20]
Jelmer Vernooij <jelmer@samba.org>
parents:
540
diff
changeset
|
285 |
|
564
db3e9ff448cb
Style fixes for GSSAPI changes [#20].
Mikael Hallendal <micke@imendio.com>
parents:
563
diff
changeset
|
286 |
if (major_status != GSS_S_CONTINUE_NEEDED) { |
563
33ffbface103
Applied patch to add GSSAPI support to Loudmouth [#20]
Jelmer Vernooij <jelmer@samba.org>
parents:
540
diff
changeset
|
287 |
sasl->state = SASL_AUTH_STATE_GSSAPI_SENT_AUTH_RESPONSE; |
564
db3e9ff448cb
Style fixes for GSSAPI changes [#20].
Mikael Hallendal <micke@imendio.com>
parents:
563
diff
changeset
|
288 |
} |
563
33ffbface103
Applied patch to add GSSAPI support to Loudmouth [#20]
Jelmer Vernooij <jelmer@samba.org>
parents:
540
diff
changeset
|
289 |
|
33ffbface103
Applied patch to add GSSAPI support to Loudmouth [#20]
Jelmer Vernooij <jelmer@samba.org>
parents:
540
diff
changeset
|
290 |
major_status = gss_release_buffer (&minor_status, input_buffer); |
564
db3e9ff448cb
Style fixes for GSSAPI changes [#20].
Mikael Hallendal <micke@imendio.com>
parents:
563
diff
changeset
|
291 |
if (major_status != GSS_S_COMPLETE) { |
563
33ffbface103
Applied patch to add GSSAPI support to Loudmouth [#20]
Jelmer Vernooij <jelmer@samba.org>
parents:
540
diff
changeset
|
292 |
return FALSE; |
564
db3e9ff448cb
Style fixes for GSSAPI changes [#20].
Mikael Hallendal <micke@imendio.com>
parents:
563
diff
changeset
|
293 |
} |
563
33ffbface103
Applied patch to add GSSAPI support to Loudmouth [#20]
Jelmer Vernooij <jelmer@samba.org>
parents:
540
diff
changeset
|
294 |
} else if (sasl->state == SASL_AUTH_STATE_GSSAPI_SENT_AUTH_RESPONSE) { |
33ffbface103
Applied patch to add GSSAPI support to Loudmouth [#20]
Jelmer Vernooij <jelmer@samba.org>
parents:
540
diff
changeset
|
295 |
gchar *features; |
33ffbface103
Applied patch to add GSSAPI support to Loudmouth [#20]
Jelmer Vernooij <jelmer@samba.org>
parents:
540
diff
changeset
|
296 |
|
33ffbface103
Applied patch to add GSSAPI support to Loudmouth [#20]
Jelmer Vernooij <jelmer@samba.org>
parents:
540
diff
changeset
|
297 |
major_status = gss_unwrap (&minor_status, sasl->gss_ctx, |
33ffbface103
Applied patch to add GSSAPI support to Loudmouth [#20]
Jelmer Vernooij <jelmer@samba.org>
parents:
540
diff
changeset
|
298 |
input_buffer, output_buffer, |
33ffbface103
Applied patch to add GSSAPI support to Loudmouth [#20]
Jelmer Vernooij <jelmer@samba.org>
parents:
540
diff
changeset
|
299 |
NULL, NULL); |
33ffbface103
Applied patch to add GSSAPI support to Loudmouth [#20]
Jelmer Vernooij <jelmer@samba.org>
parents:
540
diff
changeset
|
300 |
|
33ffbface103
Applied patch to add GSSAPI support to Loudmouth [#20]
Jelmer Vernooij <jelmer@samba.org>
parents:
540
diff
changeset
|
301 |
if (GSS_ERROR(major_status)) { |
33ffbface103
Applied patch to add GSSAPI support to Loudmouth [#20]
Jelmer Vernooij <jelmer@samba.org>
parents:
540
diff
changeset
|
302 |
sasl_gssapi_fail (sasl, "while unwrapping server capabilities", |
33ffbface103
Applied patch to add GSSAPI support to Loudmouth [#20]
Jelmer Vernooij <jelmer@samba.org>
parents:
540
diff
changeset
|
303 |
major_status, minor_status); |
33ffbface103
Applied patch to add GSSAPI support to Loudmouth [#20]
Jelmer Vernooij <jelmer@samba.org>
parents:
540
diff
changeset
|
304 |
return FALSE; |
33ffbface103
Applied patch to add GSSAPI support to Loudmouth [#20]
Jelmer Vernooij <jelmer@samba.org>
parents:
540
diff
changeset
|
305 |
} |
33ffbface103
Applied patch to add GSSAPI support to Loudmouth [#20]
Jelmer Vernooij <jelmer@samba.org>
parents:
540
diff
changeset
|
306 |
|
33ffbface103
Applied patch to add GSSAPI support to Loudmouth [#20]
Jelmer Vernooij <jelmer@samba.org>
parents:
540
diff
changeset
|
307 |
major_status = gss_release_buffer (&minor_status, input_buffer); |
564
db3e9ff448cb
Style fixes for GSSAPI changes [#20].
Mikael Hallendal <micke@imendio.com>
parents:
563
diff
changeset
|
308 |
if (major_status != GSS_S_COMPLETE) { |
563
33ffbface103
Applied patch to add GSSAPI support to Loudmouth [#20]
Jelmer Vernooij <jelmer@samba.org>
parents:
540
diff
changeset
|
309 |
return FALSE; |
564
db3e9ff448cb
Style fixes for GSSAPI changes [#20].
Mikael Hallendal <micke@imendio.com>
parents:
563
diff
changeset
|
310 |
} |
563
33ffbface103
Applied patch to add GSSAPI support to Loudmouth [#20]
Jelmer Vernooij <jelmer@samba.org>
parents:
540
diff
changeset
|
311 |
|
33ffbface103
Applied patch to add GSSAPI support to Loudmouth [#20]
Jelmer Vernooij <jelmer@samba.org>
parents:
540
diff
changeset
|
312 |
major_status = gss_release_buffer (&minor_status, output_buffer); |
564
db3e9ff448cb
Style fixes for GSSAPI changes [#20].
Mikael Hallendal <micke@imendio.com>
parents:
563
diff
changeset
|
313 |
if (major_status != GSS_S_COMPLETE) { |
563
33ffbface103
Applied patch to add GSSAPI support to Loudmouth [#20]
Jelmer Vernooij <jelmer@samba.org>
parents:
540
diff
changeset
|
314 |
return FALSE; |
564
db3e9ff448cb
Style fixes for GSSAPI changes [#20].
Mikael Hallendal <micke@imendio.com>
parents:
563
diff
changeset
|
315 |
} |
563
33ffbface103
Applied patch to add GSSAPI support to Loudmouth [#20]
Jelmer Vernooij <jelmer@samba.org>
parents:
540
diff
changeset
|
316 |
|
571
6fb1c4046db7
Fixed compile when GSSAPI support is enabled. [#20]
Jelmer Vernooij <jelmer@samba.org>
parents:
564
diff
changeset
|
317 |
input_buffer_desc.length = 4 + strlen(lm_auth_parameters_get_username (sasl->auth_params)); |
563
33ffbface103
Applied patch to add GSSAPI support to Loudmouth [#20]
Jelmer Vernooij <jelmer@samba.org>
parents:
540
diff
changeset
|
318 |
features = g_malloc (input_buffer_desc.length); |
33ffbface103
Applied patch to add GSSAPI support to Loudmouth [#20]
Jelmer Vernooij <jelmer@samba.org>
parents:
540
diff
changeset
|
319 |
|
33ffbface103
Applied patch to add GSSAPI support to Loudmouth [#20]
Jelmer Vernooij <jelmer@samba.org>
parents:
540
diff
changeset
|
320 |
features[0] = 1; |
33ffbface103
Applied patch to add GSSAPI support to Loudmouth [#20]
Jelmer Vernooij <jelmer@samba.org>
parents:
540
diff
changeset
|
321 |
features[1] = 0xFF; |
33ffbface103
Applied patch to add GSSAPI support to Loudmouth [#20]
Jelmer Vernooij <jelmer@samba.org>
parents:
540
diff
changeset
|
322 |
features[2] = 0xFF; |
33ffbface103
Applied patch to add GSSAPI support to Loudmouth [#20]
Jelmer Vernooij <jelmer@samba.org>
parents:
540
diff
changeset
|
323 |
features[3] = 0xFF; |
571
6fb1c4046db7
Fixed compile when GSSAPI support is enabled. [#20]
Jelmer Vernooij <jelmer@samba.org>
parents:
564
diff
changeset
|
324 |
strcpy(features+4, lm_auth_parameters_get_username (sasl->auth_params)); |
563
33ffbface103
Applied patch to add GSSAPI support to Loudmouth [#20]
Jelmer Vernooij <jelmer@samba.org>
parents:
540
diff
changeset
|
325 |
|
33ffbface103
Applied patch to add GSSAPI support to Loudmouth [#20]
Jelmer Vernooij <jelmer@samba.org>
parents:
540
diff
changeset
|
326 |
input_buffer_desc.value = features; |
33ffbface103
Applied patch to add GSSAPI support to Loudmouth [#20]
Jelmer Vernooij <jelmer@samba.org>
parents:
540
diff
changeset
|
327 |
major_status = gss_wrap (&minor_status, sasl->gss_ctx, |
33ffbface103
Applied patch to add GSSAPI support to Loudmouth [#20]
Jelmer Vernooij <jelmer@samba.org>
parents:
540
diff
changeset
|
328 |
0, /* Just integrity checking here */ |
33ffbface103
Applied patch to add GSSAPI support to Loudmouth [#20]
Jelmer Vernooij <jelmer@samba.org>
parents:
540
diff
changeset
|
329 |
GSS_C_QOP_DEFAULT, |
33ffbface103
Applied patch to add GSSAPI support to Loudmouth [#20]
Jelmer Vernooij <jelmer@samba.org>
parents:
540
diff
changeset
|
330 |
input_buffer, |
33ffbface103
Applied patch to add GSSAPI support to Loudmouth [#20]
Jelmer Vernooij <jelmer@samba.org>
parents:
540
diff
changeset
|
331 |
NULL, |
33ffbface103
Applied patch to add GSSAPI support to Loudmouth [#20]
Jelmer Vernooij <jelmer@samba.org>
parents:
540
diff
changeset
|
332 |
output_buffer); |
33ffbface103
Applied patch to add GSSAPI support to Loudmouth [#20]
Jelmer Vernooij <jelmer@samba.org>
parents:
540
diff
changeset
|
333 |
g_free (features); |
33ffbface103
Applied patch to add GSSAPI support to Loudmouth [#20]
Jelmer Vernooij <jelmer@samba.org>
parents:
540
diff
changeset
|
334 |
if (GSS_ERROR(major_status)) { |
33ffbface103
Applied patch to add GSSAPI support to Loudmouth [#20]
Jelmer Vernooij <jelmer@samba.org>
parents:
540
diff
changeset
|
335 |
sasl_gssapi_fail (sasl, "while wrapping required features", |
33ffbface103
Applied patch to add GSSAPI support to Loudmouth [#20]
Jelmer Vernooij <jelmer@samba.org>
parents:
540
diff
changeset
|
336 |
major_status, minor_status); |
33ffbface103
Applied patch to add GSSAPI support to Loudmouth [#20]
Jelmer Vernooij <jelmer@samba.org>
parents:
540
diff
changeset
|
337 |
return FALSE; |
33ffbface103
Applied patch to add GSSAPI support to Loudmouth [#20]
Jelmer Vernooij <jelmer@samba.org>
parents:
540
diff
changeset
|
338 |
} |
33ffbface103
Applied patch to add GSSAPI support to Loudmouth [#20]
Jelmer Vernooij <jelmer@samba.org>
parents:
540
diff
changeset
|
339 |
} else { |
33ffbface103
Applied patch to add GSSAPI support to Loudmouth [#20]
Jelmer Vernooij <jelmer@samba.org>
parents:
540
diff
changeset
|
340 |
g_assert_not_reached (); |
33ffbface103
Applied patch to add GSSAPI support to Loudmouth [#20]
Jelmer Vernooij <jelmer@samba.org>
parents:
540
diff
changeset
|
341 |
} |
33ffbface103
Applied patch to add GSSAPI support to Loudmouth [#20]
Jelmer Vernooij <jelmer@samba.org>
parents:
540
diff
changeset
|
342 |
|
33ffbface103
Applied patch to add GSSAPI support to Loudmouth [#20]
Jelmer Vernooij <jelmer@samba.org>
parents:
540
diff
changeset
|
343 |
msg = lm_message_new (NULL, LM_MESSAGE_TYPE_RESPONSE); |
33ffbface103
Applied patch to add GSSAPI support to Loudmouth [#20]
Jelmer Vernooij <jelmer@samba.org>
parents:
540
diff
changeset
|
344 |
lm_message_node_set_attributes (msg->node, |
33ffbface103
Applied patch to add GSSAPI support to Loudmouth [#20]
Jelmer Vernooij <jelmer@samba.org>
parents:
540
diff
changeset
|
345 |
"xmlns", XMPP_NS_SASL_AUTH, |
33ffbface103
Applied patch to add GSSAPI support to Loudmouth [#20]
Jelmer Vernooij <jelmer@samba.org>
parents:
540
diff
changeset
|
346 |
NULL); |
33ffbface103
Applied patch to add GSSAPI support to Loudmouth [#20]
Jelmer Vernooij <jelmer@samba.org>
parents:
540
diff
changeset
|
347 |
|
33ffbface103
Applied patch to add GSSAPI support to Loudmouth [#20]
Jelmer Vernooij <jelmer@samba.org>
parents:
540
diff
changeset
|
348 |
if (output_buffer_desc.value != NULL) { |
607 | 349 |
response64 = g_base64_encode ((const guchar *) output_buffer_desc.value, |
563
33ffbface103
Applied patch to add GSSAPI support to Loudmouth [#20]
Jelmer Vernooij <jelmer@samba.org>
parents:
540
diff
changeset
|
350 |
(gsize) output_buffer_desc.length); |
33ffbface103
Applied patch to add GSSAPI support to Loudmouth [#20]
Jelmer Vernooij <jelmer@samba.org>
parents:
540
diff
changeset
|
351 |
|
33ffbface103
Applied patch to add GSSAPI support to Loudmouth [#20]
Jelmer Vernooij <jelmer@samba.org>
parents:
540
diff
changeset
|
352 |
} else { |
33ffbface103
Applied patch to add GSSAPI support to Loudmouth [#20]
Jelmer Vernooij <jelmer@samba.org>
parents:
540
diff
changeset
|
353 |
response64 = g_strdup (""); |
33ffbface103
Applied patch to add GSSAPI support to Loudmouth [#20]
Jelmer Vernooij <jelmer@samba.org>
parents:
540
diff
changeset
|
354 |
} |
33ffbface103
Applied patch to add GSSAPI support to Loudmouth [#20]
Jelmer Vernooij <jelmer@samba.org>
parents:
540
diff
changeset
|
355 |
|
33ffbface103
Applied patch to add GSSAPI support to Loudmouth [#20]
Jelmer Vernooij <jelmer@samba.org>
parents:
540
diff
changeset
|
356 |
major_status = gss_release_buffer (&minor_status, output_buffer); |
33ffbface103
Applied patch to add GSSAPI support to Loudmouth [#20]
Jelmer Vernooij <jelmer@samba.org>
parents:
540
diff
changeset
|
357 |
if (major_status != GSS_S_COMPLETE) { |
33ffbface103
Applied patch to add GSSAPI support to Loudmouth [#20]
Jelmer Vernooij <jelmer@samba.org>
parents:
540
diff
changeset
|
358 |
g_free (response64); |
33ffbface103
Applied patch to add GSSAPI support to Loudmouth [#20]
Jelmer Vernooij <jelmer@samba.org>
parents:
540
diff
changeset
|
359 |
lm_message_unref (msg); |
33ffbface103
Applied patch to add GSSAPI support to Loudmouth [#20]
Jelmer Vernooij <jelmer@samba.org>
parents:
540
diff
changeset
|
360 |
return FALSE; |
33ffbface103
Applied patch to add GSSAPI support to Loudmouth [#20]
Jelmer Vernooij <jelmer@samba.org>
parents:
540
diff
changeset
|
361 |
} |
33ffbface103
Applied patch to add GSSAPI support to Loudmouth [#20]
Jelmer Vernooij <jelmer@samba.org>
parents:
540
diff
changeset
|
362 |
|
33ffbface103
Applied patch to add GSSAPI support to Loudmouth [#20]
Jelmer Vernooij <jelmer@samba.org>
parents:
540
diff
changeset
|
363 |
lm_message_node_set_value (msg->node, response64); |
33ffbface103
Applied patch to add GSSAPI support to Loudmouth [#20]
Jelmer Vernooij <jelmer@samba.org>
parents:
540
diff
changeset
|
364 |
|
33ffbface103
Applied patch to add GSSAPI support to Loudmouth [#20]
Jelmer Vernooij <jelmer@samba.org>
parents:
540
diff
changeset
|
365 |
result = lm_connection_send (sasl->connection, msg, NULL); |
33ffbface103
Applied patch to add GSSAPI support to Loudmouth [#20]
Jelmer Vernooij <jelmer@samba.org>
parents:
540
diff
changeset
|
366 |
|
33ffbface103
Applied patch to add GSSAPI support to Loudmouth [#20]
Jelmer Vernooij <jelmer@samba.org>
parents:
540
diff
changeset
|
367 |
g_free (response64); |
33ffbface103
Applied patch to add GSSAPI support to Loudmouth [#20]
Jelmer Vernooij <jelmer@samba.org>
parents:
540
diff
changeset
|
368 |
lm_message_unref (msg); |
33ffbface103
Applied patch to add GSSAPI support to Loudmouth [#20]
Jelmer Vernooij <jelmer@samba.org>
parents:
540
diff
changeset
|
369 |
|
33ffbface103
Applied patch to add GSSAPI support to Loudmouth [#20]
Jelmer Vernooij <jelmer@samba.org>
parents:
540
diff
changeset
|
370 |
if (!result) { |
614
773201ca404c
Replaced every g_warning() with g_log()
Mikael Berthe <mikael@lilotux.net>
parents:
607
diff
changeset
|
371 |
g_log (LM_LOG_DOMAIN, LM_LOG_LEVEL_NET, |
773201ca404c
Replaced every g_warning() with g_log()
Mikael Berthe <mikael@lilotux.net>
parents:
607
diff
changeset
|
372 |
"Failed to send SASL response\n"); |
563
33ffbface103
Applied patch to add GSSAPI support to Loudmouth [#20]
Jelmer Vernooij <jelmer@samba.org>
parents:
540
diff
changeset
|
373 |
return FALSE; |
33ffbface103
Applied patch to add GSSAPI support to Loudmouth [#20]
Jelmer Vernooij <jelmer@samba.org>
parents:
540
diff
changeset
|
374 |
} |
33ffbface103
Applied patch to add GSSAPI support to Loudmouth [#20]
Jelmer Vernooij <jelmer@samba.org>
parents:
540
diff
changeset
|
375 |
|
33ffbface103
Applied patch to add GSSAPI support to Loudmouth [#20]
Jelmer Vernooij <jelmer@samba.org>
parents:
540
diff
changeset
|
376 |
return TRUE; |
33ffbface103
Applied patch to add GSSAPI support to Loudmouth [#20]
Jelmer Vernooij <jelmer@samba.org>
parents:
540
diff
changeset
|
377 |
} |
33ffbface103
Applied patch to add GSSAPI support to Loudmouth [#20]
Jelmer Vernooij <jelmer@samba.org>
parents:
540
diff
changeset
|
378 |
|
33ffbface103
Applied patch to add GSSAPI support to Loudmouth [#20]
Jelmer Vernooij <jelmer@samba.org>
parents:
540
diff
changeset
|
379 |
static gboolean |
33ffbface103
Applied patch to add GSSAPI support to Loudmouth [#20]
Jelmer Vernooij <jelmer@samba.org>
parents:
540
diff
changeset
|
380 |
sasl_gssapi_finish (LmSASL *sasl, LmMessageNode *node) |
33ffbface103
Applied patch to add GSSAPI support to Loudmouth [#20]
Jelmer Vernooij <jelmer@samba.org>
parents:
540
diff
changeset
|
381 |
{ |
624 | 382 |
OM_uint32 /* major_status, */ minor_status; |
563
33ffbface103
Applied patch to add GSSAPI support to Loudmouth [#20]
Jelmer Vernooij <jelmer@samba.org>
parents:
540
diff
changeset
|
383 |
|
564
db3e9ff448cb
Style fixes for GSSAPI changes [#20].
Mikael Hallendal <micke@imendio.com>
parents:
563
diff
changeset
|
384 |
if (sasl->gss_service != GSS_C_NO_NAME) { |
624 | 385 |
/* major_status = */ |
386 |
(void) gss_release_name (&minor_status, &sasl->gss_service); |
|
607 | 387 |
} |
564
db3e9ff448cb
Style fixes for GSSAPI changes [#20].
Mikael Hallendal <micke@imendio.com>
parents:
563
diff
changeset
|
388 |
|
db3e9ff448cb
Style fixes for GSSAPI changes [#20].
Mikael Hallendal <micke@imendio.com>
parents:
563
diff
changeset
|
389 |
if (sasl->gss_ctx != GSS_C_NO_CONTEXT) { |
624 | 390 |
/* major_status = */ |
391 |
(void) gss_delete_sec_context (&minor_status, &sasl->gss_ctx, |
|
392 |
GSS_C_NO_BUFFER); |
|
564
db3e9ff448cb
Style fixes for GSSAPI changes [#20].
Mikael Hallendal <micke@imendio.com>
parents:
563
diff
changeset
|
393 |
} |
563
33ffbface103
Applied patch to add GSSAPI support to Loudmouth [#20]
Jelmer Vernooij <jelmer@samba.org>
parents:
540
diff
changeset
|
394 |
|
33ffbface103
Applied patch to add GSSAPI support to Loudmouth [#20]
Jelmer Vernooij <jelmer@samba.org>
parents:
540
diff
changeset
|
395 |
return TRUE; |
33ffbface103
Applied patch to add GSSAPI support to Loudmouth [#20]
Jelmer Vernooij <jelmer@samba.org>
parents:
540
diff
changeset
|
396 |
} |
33ffbface103
Applied patch to add GSSAPI support to Loudmouth [#20]
Jelmer Vernooij <jelmer@samba.org>
parents:
540
diff
changeset
|
397 |
#endif |
33ffbface103
Applied patch to add GSSAPI support to Loudmouth [#20]
Jelmer Vernooij <jelmer@samba.org>
parents:
540
diff
changeset
|
398 |
|
33ffbface103
Applied patch to add GSSAPI support to Loudmouth [#20]
Jelmer Vernooij <jelmer@samba.org>
parents:
540
diff
changeset
|
399 |
|
216
fab18da0956b
Added lm-sasl.[ch] from Senko
Mikael Hallendal <micke@imendio.com>
parents:
diff
changeset
|
400 |
/* DIGEST-MD5 mechanism code from libgibber */ |
fab18da0956b
Added lm-sasl.[ch] from Senko
Mikael Hallendal <micke@imendio.com>
parents:
diff
changeset
|
401 |
|
fab18da0956b
Added lm-sasl.[ch] from Senko
Mikael Hallendal <micke@imendio.com>
parents:
diff
changeset
|
402 |
static gchar * |
607 | 403 |
sasl_strndup_unescaped (const gchar *str, gsize len) |
227
b8fa5635fb30
Conform with Loudmouth coding style
Mikael Hallendal <micke@imendio.com>
parents:
225
diff
changeset
|
404 |
{ |
518
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
516
diff
changeset
|
405 |
const gchar *s; |
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
516
diff
changeset
|
406 |
gchar *d; |
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
516
diff
changeset
|
407 |
gchar *ret; |
216
fab18da0956b
Added lm-sasl.[ch] from Senko
Mikael Hallendal <micke@imendio.com>
parents:
diff
changeset
|
408 |
|
518
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
516
diff
changeset
|
409 |
ret = g_malloc0 (len + 1); |
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
516
diff
changeset
|
410 |
for (s = str, d = ret ; s < (str + len) ; s++, d++) { |
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
516
diff
changeset
|
411 |
if (*s == '\\') s++; |
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
516
diff
changeset
|
412 |
*d = *s; |
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
516
diff
changeset
|
413 |
} |
216
fab18da0956b
Added lm-sasl.[ch] from Senko
Mikael Hallendal <micke@imendio.com>
parents:
diff
changeset
|
414 |
|
518
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
516
diff
changeset
|
415 |
return ret; |
216
fab18da0956b
Added lm-sasl.[ch] from Senko
Mikael Hallendal <micke@imendio.com>
parents:
diff
changeset
|
416 |
} |
fab18da0956b
Added lm-sasl.[ch] from Senko
Mikael Hallendal <micke@imendio.com>
parents:
diff
changeset
|
417 |
|
fab18da0956b
Added lm-sasl.[ch] from Senko
Mikael Hallendal <micke@imendio.com>
parents:
diff
changeset
|
418 |
static GHashTable * |
227
b8fa5635fb30
Conform with Loudmouth coding style
Mikael Hallendal <micke@imendio.com>
parents:
225
diff
changeset
|
419 |
sasl_digest_md5_challenge_to_hash (const gchar * challenge) |
b8fa5635fb30
Conform with Loudmouth coding style
Mikael Hallendal <micke@imendio.com>
parents:
225
diff
changeset
|
420 |
{ |
518
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
516
diff
changeset
|
421 |
const gchar *keystart, *keyend, *valstart; |
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
516
diff
changeset
|
422 |
const gchar *c = challenge; |
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
516
diff
changeset
|
423 |
gchar *key, *val; |
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
516
diff
changeset
|
424 |
GHashTable *result; |
607 | 425 |
|
426 |
result = g_hash_table_new_full (g_str_hash, g_str_equal, |
|
518
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
516
diff
changeset
|
427 |
g_free, g_free); |
216
fab18da0956b
Added lm-sasl.[ch] from Senko
Mikael Hallendal <micke@imendio.com>
parents:
diff
changeset
|
428 |
|
607 | 429 |
do { |
518
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
516
diff
changeset
|
430 |
while (g_ascii_isspace(*c)) c++; |
270
7247db75f528
Skip whitespace before SASL MD5 digest. Patch by Senko Rašić.
Dafydd Harries <daf@rhydd.org>
parents:
255
diff
changeset
|
431 |
|
518
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
516
diff
changeset
|
432 |
keystart = c; |
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
516
diff
changeset
|
433 |
for (; *c != '\0' && *c != '='; c++); |
216
fab18da0956b
Added lm-sasl.[ch] from Senko
Mikael Hallendal <micke@imendio.com>
parents:
diff
changeset
|
434 |
|
518
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
516
diff
changeset
|
435 |
if (*c == '\0' || c == keystart) goto error; |
216
fab18da0956b
Added lm-sasl.[ch] from Senko
Mikael Hallendal <micke@imendio.com>
parents:
diff
changeset
|
436 |
|
607 | 437 |
keyend = c; |
518
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
516
diff
changeset
|
438 |
c++; |
216
fab18da0956b
Added lm-sasl.[ch] from Senko
Mikael Hallendal <micke@imendio.com>
parents:
diff
changeset
|
439 |
|
518
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
516
diff
changeset
|
440 |
if (*c == '"') { |
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
516
diff
changeset
|
441 |
c++; |
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
516
diff
changeset
|
442 |
valstart = c; |
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
516
diff
changeset
|
443 |
for (; *c != '\0' && *c != '"'; c++); |
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
516
diff
changeset
|
444 |
if (*c == '\0' || c == valstart) goto error; |
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
516
diff
changeset
|
445 |
val = sasl_strndup_unescaped (valstart, c - valstart); |
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
516
diff
changeset
|
446 |
c++; |
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
516
diff
changeset
|
447 |
} else { |
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
516
diff
changeset
|
448 |
valstart = c; |
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
516
diff
changeset
|
449 |
for (; *c != '\0' && *c != ','; c++); |
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
516
diff
changeset
|
450 |
if (c == valstart) goto error; |
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
516
diff
changeset
|
451 |
val = g_strndup (valstart, c - valstart); |
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
516
diff
changeset
|
452 |
} |
216
fab18da0956b
Added lm-sasl.[ch] from Senko
Mikael Hallendal <micke@imendio.com>
parents:
diff
changeset
|
453 |
|
518
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
516
diff
changeset
|
454 |
key = g_strndup (keystart, keyend - keystart); |
216
fab18da0956b
Added lm-sasl.[ch] from Senko
Mikael Hallendal <micke@imendio.com>
parents:
diff
changeset
|
455 |
|
518
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
516
diff
changeset
|
456 |
g_hash_table_insert (result, key, val); |
216
fab18da0956b
Added lm-sasl.[ch] from Senko
Mikael Hallendal <micke@imendio.com>
parents:
diff
changeset
|
457 |
|
518
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
516
diff
changeset
|
458 |
if (*c == ',') c++; |
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
516
diff
changeset
|
459 |
} while (*c != '\0'); |
216
fab18da0956b
Added lm-sasl.[ch] from Senko
Mikael Hallendal <micke@imendio.com>
parents:
diff
changeset
|
460 |
|
518
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
516
diff
changeset
|
461 |
return result; |
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
516
diff
changeset
|
462 |
error: |
607 | 463 |
g_log (LM_LOG_DOMAIN, LM_LOG_LEVEL_SASL, |
518
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
516
diff
changeset
|
464 |
"Failed to parse challenge: %s", challenge); |
255
704881ac7788
Fixed potential problem if auth was not called from the open callback.
Mikael Hallendal <micke@imendio.com>
parents:
227
diff
changeset
|
465 |
|
518
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
516
diff
changeset
|
466 |
g_hash_table_destroy (result); |
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
516
diff
changeset
|
467 |
return NULL; |
216
fab18da0956b
Added lm-sasl.[ch] from Senko
Mikael Hallendal <micke@imendio.com>
parents:
diff
changeset
|
468 |
} |
fab18da0956b
Added lm-sasl.[ch] from Senko
Mikael Hallendal <micke@imendio.com>
parents:
diff
changeset
|
469 |
|
fab18da0956b
Added lm-sasl.[ch] from Senko
Mikael Hallendal <micke@imendio.com>
parents:
diff
changeset
|
470 |
static gchar * |
607 | 471 |
sasl_md5_hex_hash (gchar *value, gsize len) |
227
b8fa5635fb30
Conform with Loudmouth coding style
Mikael Hallendal <micke@imendio.com>
parents:
225
diff
changeset
|
472 |
{ |
518
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
516
diff
changeset
|
473 |
md5_byte_t digest_md5[16]; |
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
516
diff
changeset
|
474 |
md5_state_t md5_calc; |
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
516
diff
changeset
|
475 |
GString *str; |
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
516
diff
changeset
|
476 |
int i; |
227
b8fa5635fb30
Conform with Loudmouth coding style
Mikael Hallendal <micke@imendio.com>
parents:
225
diff
changeset
|
477 |
|
518
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
516
diff
changeset
|
478 |
str = g_string_sized_new (32); |
216
fab18da0956b
Added lm-sasl.[ch] from Senko
Mikael Hallendal <micke@imendio.com>
parents:
diff
changeset
|
479 |
|
518
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
516
diff
changeset
|
480 |
md5_init (&md5_calc); |
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
516
diff
changeset
|
481 |
md5_append (&md5_calc, (const md5_byte_t *)value, len); |
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
516
diff
changeset
|
482 |
md5_finish (&md5_calc, digest_md5); |
227
b8fa5635fb30
Conform with Loudmouth coding style
Mikael Hallendal <micke@imendio.com>
parents:
225
diff
changeset
|
483 |
|
518
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
516
diff
changeset
|
484 |
for (i = 0 ; i < 16 ; i++) { |
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
516
diff
changeset
|
485 |
g_string_append_printf (str, "%02x", digest_md5[i]); |
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
516
diff
changeset
|
486 |
} |
227
b8fa5635fb30
Conform with Loudmouth coding style
Mikael Hallendal <micke@imendio.com>
parents:
225
diff
changeset
|
487 |
|
518
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
516
diff
changeset
|
488 |
return g_string_free (str, FALSE); |
216
fab18da0956b
Added lm-sasl.[ch] from Senko
Mikael Hallendal <micke@imendio.com>
parents:
diff
changeset
|
489 |
} |
fab18da0956b
Added lm-sasl.[ch] from Senko
Mikael Hallendal <micke@imendio.com>
parents:
diff
changeset
|
490 |
|
fab18da0956b
Added lm-sasl.[ch] from Senko
Mikael Hallendal <micke@imendio.com>
parents:
diff
changeset
|
491 |
static gchar * |
227
b8fa5635fb30
Conform with Loudmouth coding style
Mikael Hallendal <micke@imendio.com>
parents:
225
diff
changeset
|
492 |
sasl_digest_md5_generate_cnonce(void) |
b8fa5635fb30
Conform with Loudmouth coding style
Mikael Hallendal <micke@imendio.com>
parents:
225
diff
changeset
|
493 |
{ |
518
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
516
diff
changeset
|
494 |
/* RFC 2831 recommends the the nonce to be either hexadecimal or base64 with |
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
516
diff
changeset
|
495 |
* at least 64 bits of entropy */ |
216
fab18da0956b
Added lm-sasl.[ch] from Senko
Mikael Hallendal <micke@imendio.com>
parents:
diff
changeset
|
496 |
#define NR 8 |
607 | 497 |
guint32 n[NR]; |
518
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
516
diff
changeset
|
498 |
int i; |
227
b8fa5635fb30
Conform with Loudmouth coding style
Mikael Hallendal <micke@imendio.com>
parents:
225
diff
changeset
|
499 |
|
518
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
516
diff
changeset
|
500 |
for (i = 0; i < NR; i++) { |
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
516
diff
changeset
|
501 |
n[i] = g_random_int(); |
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
516
diff
changeset
|
502 |
} |
227
b8fa5635fb30
Conform with Loudmouth coding style
Mikael Hallendal <micke@imendio.com>
parents:
225
diff
changeset
|
503 |
|
518
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
516
diff
changeset
|
504 |
return g_base64_encode ((const guchar *)n, (gsize)sizeof(n)); |
216
fab18da0956b
Added lm-sasl.[ch] from Senko
Mikael Hallendal <micke@imendio.com>
parents:
diff
changeset
|
505 |
} |
fab18da0956b
Added lm-sasl.[ch] from Senko
Mikael Hallendal <micke@imendio.com>
parents:
diff
changeset
|
506 |
|
fab18da0956b
Added lm-sasl.[ch] from Senko
Mikael Hallendal <micke@imendio.com>
parents:
diff
changeset
|
507 |
static gchar * |
227
b8fa5635fb30
Conform with Loudmouth coding style
Mikael Hallendal <micke@imendio.com>
parents:
225
diff
changeset
|
508 |
sasl_md5_prepare_response (LmSASL *sasl, GHashTable *challenge) |
b8fa5635fb30
Conform with Loudmouth coding style
Mikael Hallendal <micke@imendio.com>
parents:
225
diff
changeset
|
509 |
{ |
518
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
516
diff
changeset
|
510 |
GString *response; |
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
516
diff
changeset
|
511 |
const gchar *realm, *nonce; |
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
516
diff
changeset
|
512 |
gchar *a1, *a1h, *a2, *a2h, *kd, *kdh; |
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
516
diff
changeset
|
513 |
gchar *cnonce = NULL; |
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
516
diff
changeset
|
514 |
gchar *tmp; |
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
516
diff
changeset
|
515 |
md5_byte_t digest_md5[16]; |
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
516
diff
changeset
|
516 |
md5_state_t md5_calc; |
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
516
diff
changeset
|
517 |
gsize len; |
227
b8fa5635fb30
Conform with Loudmouth coding style
Mikael Hallendal <micke@imendio.com>
parents:
225
diff
changeset
|
518 |
|
518
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
516
diff
changeset
|
519 |
response = g_string_new (""); |
216
fab18da0956b
Added lm-sasl.[ch] from Senko
Mikael Hallendal <micke@imendio.com>
parents:
diff
changeset
|
520 |
|
540
72acfccdec86
Switch to use LmAuthParameters instead of passing around username and password.
Mikael Hallendal <micke@imendio.com>
parents:
518
diff
changeset
|
521 |
if (sasl->auth_params == NULL) { |
518
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
516
diff
changeset
|
522 |
g_log (LM_LOG_DOMAIN, LM_LOG_LEVEL_SASL, |
540
72acfccdec86
Switch to use LmAuthParameters instead of passing around username and password.
Mikael Hallendal <micke@imendio.com>
parents:
518
diff
changeset
|
523 |
"%s: no authentication parameters provided", G_STRFUNC); |
518
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
516
diff
changeset
|
524 |
if (sasl->handler) { |
607 | 525 |
sasl->handler (sasl, sasl->connection, |
518
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
516
diff
changeset
|
526 |
FALSE, "no username/password provided"); |
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
516
diff
changeset
|
527 |
} |
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
516
diff
changeset
|
528 |
goto error; |
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
516
diff
changeset
|
529 |
} |
216
fab18da0956b
Added lm-sasl.[ch] from Senko
Mikael Hallendal <micke@imendio.com>
parents:
diff
changeset
|
530 |
|
518
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
516
diff
changeset
|
531 |
nonce = g_hash_table_lookup (challenge, "nonce"); |
721 | 532 |
if (nonce == NULL || nonce[0] == '\0') { |
518
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
516
diff
changeset
|
533 |
g_log (LM_LOG_DOMAIN, LM_LOG_LEVEL_SASL, |
607 | 534 |
"%s: server didn't provide a nonce in the challenge", |
518
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
516
diff
changeset
|
535 |
G_STRFUNC); |
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
516
diff
changeset
|
536 |
if (sasl->handler) { |
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
516
diff
changeset
|
537 |
sasl->handler (sasl, sasl->connection, |
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
516
diff
changeset
|
538 |
FALSE, "server error"); |
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
516
diff
changeset
|
539 |
} |
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
516
diff
changeset
|
540 |
goto error; |
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
516
diff
changeset
|
541 |
} |
216
fab18da0956b
Added lm-sasl.[ch] from Senko
Mikael Hallendal <micke@imendio.com>
parents:
diff
changeset
|
542 |
|
518
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
516
diff
changeset
|
543 |
cnonce = sasl_digest_md5_generate_cnonce (); |
216
fab18da0956b
Added lm-sasl.[ch] from Senko
Mikael Hallendal <micke@imendio.com>
parents:
diff
changeset
|
544 |
|
518
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
516
diff
changeset
|
545 |
/* FIXME challenge can contain multiple realms */ |
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
516
diff
changeset
|
546 |
realm = g_hash_table_lookup (challenge, "realm"); |
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
516
diff
changeset
|
547 |
if (realm == NULL) { |
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
516
diff
changeset
|
548 |
realm = sasl->server; |
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
516
diff
changeset
|
549 |
} |
216
fab18da0956b
Added lm-sasl.[ch] from Senko
Mikael Hallendal <micke@imendio.com>
parents:
diff
changeset
|
550 |
|
518
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
516
diff
changeset
|
551 |
/* FIXME properly escape values */ |
540
72acfccdec86
Switch to use LmAuthParameters instead of passing around username and password.
Mikael Hallendal <micke@imendio.com>
parents:
518
diff
changeset
|
552 |
g_string_append_printf (response, "username=\"%s\"", lm_auth_parameters_get_username (sasl->auth_params)); |
518
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
516
diff
changeset
|
553 |
g_string_append_printf (response, ",realm=\"%s\"", realm); |
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
516
diff
changeset
|
554 |
g_string_append_printf (response, ",digest-uri=\"xmpp/%s\"", realm); |
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
516
diff
changeset
|
555 |
g_string_append_printf (response, ",nonce=\"%s\",nc=00000001", nonce); |
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
516
diff
changeset
|
556 |
g_string_append_printf (response, ",cnonce=\"%s\"", cnonce); |
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
516
diff
changeset
|
557 |
/* FIXME should check if auth is in the cop challenge val */ |
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
516
diff
changeset
|
558 |
g_string_append_printf (response, ",qop=auth,charset=utf-8"); |
216
fab18da0956b
Added lm-sasl.[ch] from Senko
Mikael Hallendal <micke@imendio.com>
parents:
diff
changeset
|
559 |
|
607 | 560 |
tmp = g_strdup_printf ("%s:%s:%s", |
561 |
lm_auth_parameters_get_username (sasl->auth_params), |
|
540
72acfccdec86
Switch to use LmAuthParameters instead of passing around username and password.
Mikael Hallendal <micke@imendio.com>
parents:
518
diff
changeset
|
562 |
realm, lm_auth_parameters_get_password (sasl->auth_params)); |
607 | 563 |
|
518
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
516
diff
changeset
|
564 |
md5_init (&md5_calc); |
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
516
diff
changeset
|
565 |
md5_append (&md5_calc, (const md5_byte_t *)tmp, strlen(tmp)); |
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
516
diff
changeset
|
566 |
md5_finish (&md5_calc, digest_md5); |
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
516
diff
changeset
|
567 |
g_free (tmp); |
216
fab18da0956b
Added lm-sasl.[ch] from Senko
Mikael Hallendal <micke@imendio.com>
parents:
diff
changeset
|
568 |
|
518
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
516
diff
changeset
|
569 |
a1 = g_strdup_printf ("0123456789012345:%s:%s", nonce, cnonce); |
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
516
diff
changeset
|
570 |
len = strlen (a1); |
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
516
diff
changeset
|
571 |
memcpy (a1, digest_md5, 16); |
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
516
diff
changeset
|
572 |
a1h = sasl_md5_hex_hash (a1, len); |
216
fab18da0956b
Added lm-sasl.[ch] from Senko
Mikael Hallendal <micke@imendio.com>
parents:
diff
changeset
|
573 |
|
518
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
516
diff
changeset
|
574 |
a2 = g_strdup_printf ("AUTHENTICATE:xmpp/%s", realm); |
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
516
diff
changeset
|
575 |
a2h = sasl_md5_hex_hash (a2, strlen(a2)); |
216
fab18da0956b
Added lm-sasl.[ch] from Senko
Mikael Hallendal <micke@imendio.com>
parents:
diff
changeset
|
576 |
|
518
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
516
diff
changeset
|
577 |
kd = g_strdup_printf ("%s:%s:00000001:%s:auth:%s", |
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
516
diff
changeset
|
578 |
a1h, nonce, cnonce, a2h); |
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
516
diff
changeset
|
579 |
kdh = sasl_md5_hex_hash (kd, strlen(kd)); |
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
516
diff
changeset
|
580 |
g_string_append_printf (response, ",response=%s", kdh); |
216
fab18da0956b
Added lm-sasl.[ch] from Senko
Mikael Hallendal <micke@imendio.com>
parents:
diff
changeset
|
581 |
|
518
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
516
diff
changeset
|
582 |
g_free (kd); |
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
516
diff
changeset
|
583 |
g_free (kdh); |
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
516
diff
changeset
|
584 |
g_free (a2); |
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
516
diff
changeset
|
585 |
g_free (a2h); |
216
fab18da0956b
Added lm-sasl.[ch] from Senko
Mikael Hallendal <micke@imendio.com>
parents:
diff
changeset
|
586 |
|
518
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
516
diff
changeset
|
587 |
/* Calculate the response we expect from the server */ |
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
516
diff
changeset
|
588 |
a2 = g_strdup_printf (":xmpp/%s", realm); |
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
516
diff
changeset
|
589 |
a2h = sasl_md5_hex_hash (a2, strlen(a2)); |
216
fab18da0956b
Added lm-sasl.[ch] from Senko
Mikael Hallendal <micke@imendio.com>
parents:
diff
changeset
|
590 |
|
518
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
516
diff
changeset
|
591 |
kd = g_strdup_printf ("%s:%s:00000001:%s:auth:%s", a1h, nonce, cnonce, a2h); |
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
516
diff
changeset
|
592 |
g_free (sasl->digest_md5_rspauth); |
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
516
diff
changeset
|
593 |
sasl->digest_md5_rspauth = sasl_md5_hex_hash (kd, strlen(kd)); |
216
fab18da0956b
Added lm-sasl.[ch] from Senko
Mikael Hallendal <micke@imendio.com>
parents:
diff
changeset
|
594 |
|
518
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
516
diff
changeset
|
595 |
g_free (a1); |
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
516
diff
changeset
|
596 |
g_free (a1h); |
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
516
diff
changeset
|
597 |
g_free (a2); |
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
516
diff
changeset
|
598 |
g_free (a2h); |
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
516
diff
changeset
|
599 |
g_free (kd); |
216
fab18da0956b
Added lm-sasl.[ch] from Senko
Mikael Hallendal <micke@imendio.com>
parents:
diff
changeset
|
600 |
|
518
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
516
diff
changeset
|
601 |
out: |
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
516
diff
changeset
|
602 |
g_free (cnonce); |
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
516
diff
changeset
|
603 |
if (response) { |
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
516
diff
changeset
|
604 |
return g_string_free (response, FALSE); |
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
516
diff
changeset
|
605 |
} else { |
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
516
diff
changeset
|
606 |
return NULL; |
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
516
diff
changeset
|
607 |
} |
216
fab18da0956b
Added lm-sasl.[ch] from Senko
Mikael Hallendal <micke@imendio.com>
parents:
diff
changeset
|
608 |
|
518
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
516
diff
changeset
|
609 |
error: |
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
516
diff
changeset
|
610 |
g_string_free (response, TRUE); |
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
516
diff
changeset
|
611 |
response = NULL; |
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
516
diff
changeset
|
612 |
goto out; |
216
fab18da0956b
Added lm-sasl.[ch] from Senko
Mikael Hallendal <micke@imendio.com>
parents:
diff
changeset
|
613 |
} |
fab18da0956b
Added lm-sasl.[ch] from Senko
Mikael Hallendal <micke@imendio.com>
parents:
diff
changeset
|
614 |
|
fab18da0956b
Added lm-sasl.[ch] from Senko
Mikael Hallendal <micke@imendio.com>
parents:
diff
changeset
|
615 |
static gboolean |
227
b8fa5635fb30
Conform with Loudmouth coding style
Mikael Hallendal <micke@imendio.com>
parents:
225
diff
changeset
|
616 |
sasl_digest_md5_send_initial_response (LmSASL *sasl, GHashTable *challenge) |
b8fa5635fb30
Conform with Loudmouth coding style
Mikael Hallendal <micke@imendio.com>
parents:
225
diff
changeset
|
617 |
{ |
518
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
516
diff
changeset
|
618 |
LmMessage *msg; |
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
516
diff
changeset
|
619 |
gchar *response; |
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
516
diff
changeset
|
620 |
gchar *response64; |
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
516
diff
changeset
|
621 |
int result; |
216
fab18da0956b
Added lm-sasl.[ch] from Senko
Mikael Hallendal <micke@imendio.com>
parents:
diff
changeset
|
622 |
|
540
72acfccdec86
Switch to use LmAuthParameters instead of passing around username and password.
Mikael Hallendal <micke@imendio.com>
parents:
518
diff
changeset
|
623 |
response = sasl_md5_prepare_response (sasl, challenge); |
518
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
516
diff
changeset
|
624 |
if (response == NULL) { |
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
516
diff
changeset
|
625 |
return FALSE; |
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
516
diff
changeset
|
626 |
} |
216
fab18da0956b
Added lm-sasl.[ch] from Senko
Mikael Hallendal <micke@imendio.com>
parents:
diff
changeset
|
627 |
|
607 | 628 |
response64 = g_base64_encode ((const guchar *) response, |
518
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
516
diff
changeset
|
629 |
(gsize) strlen(response)); |
216
fab18da0956b
Added lm-sasl.[ch] from Senko
Mikael Hallendal <micke@imendio.com>
parents:
diff
changeset
|
630 |
|
518
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
516
diff
changeset
|
631 |
msg = lm_message_new (NULL, LM_MESSAGE_TYPE_RESPONSE); |
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
516
diff
changeset
|
632 |
lm_message_node_set_attributes (msg->node, |
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
516
diff
changeset
|
633 |
"xmlns", XMPP_NS_SASL_AUTH, |
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
516
diff
changeset
|
634 |
NULL); |
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
516
diff
changeset
|
635 |
lm_message_node_set_value (msg->node, response64); |
216
fab18da0956b
Added lm-sasl.[ch] from Senko
Mikael Hallendal <micke@imendio.com>
parents:
diff
changeset
|
636 |
|
518
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
516
diff
changeset
|
637 |
result = lm_connection_send (sasl->connection, msg, NULL); |
216
fab18da0956b
Added lm-sasl.[ch] from Senko
Mikael Hallendal <micke@imendio.com>
parents:
diff
changeset
|
638 |
|
518
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
516
diff
changeset
|
639 |
g_free (response); |
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
516
diff
changeset
|
640 |
g_free (response64); |
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
516
diff
changeset
|
641 |
lm_message_unref (msg); |
216
fab18da0956b
Added lm-sasl.[ch] from Senko
Mikael Hallendal <micke@imendio.com>
parents:
diff
changeset
|
642 |
|
518
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
516
diff
changeset
|
643 |
if (!result) { |
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
516
diff
changeset
|
644 |
return FALSE; |
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
516
diff
changeset
|
645 |
} |
216
fab18da0956b
Added lm-sasl.[ch] from Senko
Mikael Hallendal <micke@imendio.com>
parents:
diff
changeset
|
646 |
|
518
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
516
diff
changeset
|
647 |
sasl->state = SASL_AUTH_STATE_DIGEST_MD5_SENT_AUTH_RESPONSE; |
216
fab18da0956b
Added lm-sasl.[ch] from Senko
Mikael Hallendal <micke@imendio.com>
parents:
diff
changeset
|
648 |
|
518
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
516
diff
changeset
|
649 |
return TRUE; |
216
fab18da0956b
Added lm-sasl.[ch] from Senko
Mikael Hallendal <micke@imendio.com>
parents:
diff
changeset
|
650 |
} |
fab18da0956b
Added lm-sasl.[ch] from Senko
Mikael Hallendal <micke@imendio.com>
parents:
diff
changeset
|
651 |
|
fab18da0956b
Added lm-sasl.[ch] from Senko
Mikael Hallendal <micke@imendio.com>
parents:
diff
changeset
|
652 |
static gboolean |
227
b8fa5635fb30
Conform with Loudmouth coding style
Mikael Hallendal <micke@imendio.com>
parents:
225
diff
changeset
|
653 |
sasl_digest_md5_check_server_response(LmSASL *sasl, GHashTable *challenge) |
b8fa5635fb30
Conform with Loudmouth coding style
Mikael Hallendal <micke@imendio.com>
parents:
225
diff
changeset
|
654 |
{ |
518
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
516
diff
changeset
|
655 |
LmMessage *msg; |
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
516
diff
changeset
|
656 |
const gchar *rspauth; |
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
516
diff
changeset
|
657 |
int result; |
216
fab18da0956b
Added lm-sasl.[ch] from Senko
Mikael Hallendal <micke@imendio.com>
parents:
diff
changeset
|
658 |
|
518
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
516
diff
changeset
|
659 |
rspauth = g_hash_table_lookup (challenge, "rspauth"); |
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
516
diff
changeset
|
660 |
if (rspauth == NULL) { |
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
516
diff
changeset
|
661 |
g_log (LM_LOG_DOMAIN, LM_LOG_LEVEL_SSL, |
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
516
diff
changeset
|
662 |
"%s: server sent an invalid reply (no rspauth)\n", |
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
516
diff
changeset
|
663 |
G_STRFUNC); |
224
447f16217278
Use g_log instead of g_debug
Mikael Hallendal <micke@imendio.com>
parents:
216
diff
changeset
|
664 |
|
518
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
516
diff
changeset
|
665 |
if (sasl->handler) { |
607 | 666 |
sasl->handler (sasl, sasl->connection, |
518
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
516
diff
changeset
|
667 |
TRUE, "server error"); |
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
516
diff
changeset
|
668 |
} |
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
516
diff
changeset
|
669 |
return FALSE; |
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
516
diff
changeset
|
670 |
} |
216
fab18da0956b
Added lm-sasl.[ch] from Senko
Mikael Hallendal <micke@imendio.com>
parents:
diff
changeset
|
671 |
|
518
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
516
diff
changeset
|
672 |
if (strcmp (sasl->digest_md5_rspauth, rspauth) != 0) { |
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
516
diff
changeset
|
673 |
g_log (LM_LOG_DOMAIN, LM_LOG_LEVEL_SSL, |
607 | 674 |
"%s: server sent an invalid reply (rspauth not matching)\n", |
518
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
516
diff
changeset
|
675 |
G_STRFUNC); |
224
447f16217278
Use g_log instead of g_debug
Mikael Hallendal <micke@imendio.com>
parents:
216
diff
changeset
|
676 |
|
518
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
516
diff
changeset
|
677 |
if (sasl->handler) { |
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
516
diff
changeset
|
678 |
sasl->handler (sasl, sasl->connection, |
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
516
diff
changeset
|
679 |
TRUE, "server error"); |
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
516
diff
changeset
|
680 |
} |
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
516
diff
changeset
|
681 |
return FALSE; |
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
516
diff
changeset
|
682 |
} |
216
fab18da0956b
Added lm-sasl.[ch] from Senko
Mikael Hallendal <micke@imendio.com>
parents:
diff
changeset
|
683 |
|
518
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
516
diff
changeset
|
684 |
msg = lm_message_new (NULL, LM_MESSAGE_TYPE_RESPONSE); |
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
516
diff
changeset
|
685 |
lm_message_node_set_attributes (msg->node, |
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
516
diff
changeset
|
686 |
"xmlns", XMPP_NS_SASL_AUTH, |
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
516
diff
changeset
|
687 |
NULL); |
216
fab18da0956b
Added lm-sasl.[ch] from Senko
Mikael Hallendal <micke@imendio.com>
parents:
diff
changeset
|
688 |
|
518
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
516
diff
changeset
|
689 |
result = lm_connection_send (sasl->connection, msg, NULL); |
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
516
diff
changeset
|
690 |
lm_message_unref (msg); |
216
fab18da0956b
Added lm-sasl.[ch] from Senko
Mikael Hallendal <micke@imendio.com>
parents:
diff
changeset
|
691 |
|
518
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
516
diff
changeset
|
692 |
if (!result) { |
614
773201ca404c
Replaced every g_warning() with g_log()
Mikael Berthe <mikael@lilotux.net>
parents:
607
diff
changeset
|
693 |
g_log (LM_LOG_DOMAIN, LM_LOG_LEVEL_NET, |
773201ca404c
Replaced every g_warning() with g_log()
Mikael Berthe <mikael@lilotux.net>
parents:
607
diff
changeset
|
694 |
"Failed to send SASL response\n"); |
518
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
516
diff
changeset
|
695 |
return FALSE; |
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
516
diff
changeset
|
696 |
} |
216
fab18da0956b
Added lm-sasl.[ch] from Senko
Mikael Hallendal <micke@imendio.com>
parents:
diff
changeset
|
697 |
|
518
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
516
diff
changeset
|
698 |
sasl->state = SASL_AUTH_STATE_DIGEST_MD5_SENT_FINAL_RESPONSE; |
216
fab18da0956b
Added lm-sasl.[ch] from Senko
Mikael Hallendal <micke@imendio.com>
parents:
diff
changeset
|
699 |
|
518
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
516
diff
changeset
|
700 |
return TRUE; |
216
fab18da0956b
Added lm-sasl.[ch] from Senko
Mikael Hallendal <micke@imendio.com>
parents:
diff
changeset
|
701 |
} |
fab18da0956b
Added lm-sasl.[ch] from Senko
Mikael Hallendal <micke@imendio.com>
parents:
diff
changeset
|
702 |
|
fab18da0956b
Added lm-sasl.[ch] from Senko
Mikael Hallendal <micke@imendio.com>
parents:
diff
changeset
|
703 |
static gboolean |
227
b8fa5635fb30
Conform with Loudmouth coding style
Mikael Hallendal <micke@imendio.com>
parents:
225
diff
changeset
|
704 |
sasl_digest_md5_handle_challenge (LmSASL *sasl, LmMessageNode *node) |
216
fab18da0956b
Added lm-sasl.[ch] from Senko
Mikael Hallendal <micke@imendio.com>
parents:
diff
changeset
|
705 |
{ |
518
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
516
diff
changeset
|
706 |
const gchar *encoded; |
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
516
diff
changeset
|
707 |
gchar *challenge; |
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
516
diff
changeset
|
708 |
gsize len; |
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
516
diff
changeset
|
709 |
GHashTable *h; |
216
fab18da0956b
Added lm-sasl.[ch] from Senko
Mikael Hallendal <micke@imendio.com>
parents:
diff
changeset
|
710 |
|
518
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
516
diff
changeset
|
711 |
encoded = lm_message_node_get_value (node); |
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
516
diff
changeset
|
712 |
if (!encoded) { |
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
516
diff
changeset
|
713 |
g_log (LM_LOG_DOMAIN, LM_LOG_LEVEL_SASL, |
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
516
diff
changeset
|
714 |
"%s: got empty challenge!", G_STRFUNC); |
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
516
diff
changeset
|
715 |
return FALSE; |
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
516
diff
changeset
|
716 |
} |
216
fab18da0956b
Added lm-sasl.[ch] from Senko
Mikael Hallendal <micke@imendio.com>
parents:
diff
changeset
|
717 |
|
518
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
516
diff
changeset
|
718 |
challenge = (gchar *) g_base64_decode (encoded, &len); |
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
516
diff
changeset
|
719 |
h = sasl_digest_md5_challenge_to_hash (challenge); |
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
516
diff
changeset
|
720 |
g_free(challenge); |
216
fab18da0956b
Added lm-sasl.[ch] from Senko
Mikael Hallendal <micke@imendio.com>
parents:
diff
changeset
|
721 |
|
518
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
516
diff
changeset
|
722 |
if (!h) { |
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
516
diff
changeset
|
723 |
g_log (LM_LOG_DOMAIN, LM_LOG_LEVEL_SASL, |
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
516
diff
changeset
|
724 |
"%s: server sent an invalid challenge", G_STRFUNC); |
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
516
diff
changeset
|
725 |
if (sasl->handler) { |
607 | 726 |
sasl->handler (sasl, sasl->connection, |
518
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
516
diff
changeset
|
727 |
FALSE, "server error"); |
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
516
diff
changeset
|
728 |
} |
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
516
diff
changeset
|
729 |
return FALSE; |
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
516
diff
changeset
|
730 |
} |
216
fab18da0956b
Added lm-sasl.[ch] from Senko
Mikael Hallendal <micke@imendio.com>
parents:
diff
changeset
|
731 |
|
518
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
516
diff
changeset
|
732 |
switch (sasl->state) { |
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
516
diff
changeset
|
733 |
case SASL_AUTH_STATE_DIGEST_MD5_STARTED: |
607 | 734 |
sasl_digest_md5_send_initial_response (sasl, h); |
518
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
516
diff
changeset
|
735 |
break; |
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
516
diff
changeset
|
736 |
case SASL_AUTH_STATE_DIGEST_MD5_SENT_AUTH_RESPONSE: |
607 | 737 |
sasl_digest_md5_check_server_response (sasl, h); |
518
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
516
diff
changeset
|
738 |
break; |
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
516
diff
changeset
|
739 |
default: |
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
516
diff
changeset
|
740 |
g_log (LM_LOG_DOMAIN, LM_LOG_LEVEL_SASL, |
607 | 741 |
"%s: server sent a challenge at the wrong time", |
518
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
516
diff
changeset
|
742 |
G_STRFUNC); |
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
516
diff
changeset
|
743 |
if (sasl->handler) { |
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
516
diff
changeset
|
744 |
sasl->handler (sasl, sasl->connection, |
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
516
diff
changeset
|
745 |
FALSE, "server error"); |
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
516
diff
changeset
|
746 |
} |
227
b8fa5635fb30
Conform with Loudmouth coding style
Mikael Hallendal <micke@imendio.com>
parents:
225
diff
changeset
|
747 |
|
518
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
516
diff
changeset
|
748 |
return FALSE; |
607 | 749 |
} |
227
b8fa5635fb30
Conform with Loudmouth coding style
Mikael Hallendal <micke@imendio.com>
parents:
225
diff
changeset
|
750 |
|
518
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
516
diff
changeset
|
751 |
g_hash_table_destroy(h); |
227
b8fa5635fb30
Conform with Loudmouth coding style
Mikael Hallendal <micke@imendio.com>
parents:
225
diff
changeset
|
752 |
|
518
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
516
diff
changeset
|
753 |
return TRUE; |
216
fab18da0956b
Added lm-sasl.[ch] from Senko
Mikael Hallendal <micke@imendio.com>
parents:
diff
changeset
|
754 |
} |
fab18da0956b
Added lm-sasl.[ch] from Senko
Mikael Hallendal <micke@imendio.com>
parents:
diff
changeset
|
755 |
|
fab18da0956b
Added lm-sasl.[ch] from Senko
Mikael Hallendal <micke@imendio.com>
parents:
diff
changeset
|
756 |
static LmHandlerResult |
227
b8fa5635fb30
Conform with Loudmouth coding style
Mikael Hallendal <micke@imendio.com>
parents:
225
diff
changeset
|
757 |
sasl_challenge_cb (LmMessageHandler *handler, |
518
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
516
diff
changeset
|
758 |
LmConnection *connection, |
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
516
diff
changeset
|
759 |
LmMessage *message, |
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
516
diff
changeset
|
760 |
gpointer user_data) |
216
fab18da0956b
Added lm-sasl.[ch] from Senko
Mikael Hallendal <micke@imendio.com>
parents:
diff
changeset
|
761 |
{ |
518
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
516
diff
changeset
|
762 |
LmSASL *sasl; |
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
516
diff
changeset
|
763 |
const gchar *ns; |
224
447f16217278
Use g_log instead of g_debug
Mikael Hallendal <micke@imendio.com>
parents:
216
diff
changeset
|
764 |
|
518
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
516
diff
changeset
|
765 |
ns = lm_message_node_get_attribute (message->node, "xmlns"); |
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
516
diff
changeset
|
766 |
if (!ns || strcmp (ns, XMPP_NS_SASL_AUTH) != 0) { |
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
516
diff
changeset
|
767 |
return LM_HANDLER_RESULT_ALLOW_MORE_HANDLERS; |
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
516
diff
changeset
|
768 |
} |
216
fab18da0956b
Added lm-sasl.[ch] from Senko
Mikael Hallendal <micke@imendio.com>
parents:
diff
changeset
|
769 |
|
518
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
516
diff
changeset
|
770 |
sasl = (LmSASL *) user_data; |
216
fab18da0956b
Added lm-sasl.[ch] from Senko
Mikael Hallendal <micke@imendio.com>
parents:
diff
changeset
|
771 |
|
518
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
516
diff
changeset
|
772 |
switch (sasl->auth_type) { |
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
516
diff
changeset
|
773 |
case AUTH_TYPE_PLAIN: |
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
516
diff
changeset
|
774 |
g_log (LM_LOG_DOMAIN, LM_LOG_LEVEL_SSL, |
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
516
diff
changeset
|
775 |
"%s: server sent challenge for PLAIN mechanism", |
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
516
diff
changeset
|
776 |
G_STRFUNC); |
224
447f16217278
Use g_log instead of g_debug
Mikael Hallendal <micke@imendio.com>
parents:
216
diff
changeset
|
777 |
|
518
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
516
diff
changeset
|
778 |
if (sasl->handler) { |
607 | 779 |
sasl->handler (sasl, sasl->connection, |
518
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
516
diff
changeset
|
780 |
FALSE, "server error"); |
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
516
diff
changeset
|
781 |
} |
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
516
diff
changeset
|
782 |
break; |
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
516
diff
changeset
|
783 |
case AUTH_TYPE_DIGEST: |
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
516
diff
changeset
|
784 |
sasl_digest_md5_handle_challenge (sasl, message->node); |
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
516
diff
changeset
|
785 |
break; |
563
33ffbface103
Applied patch to add GSSAPI support to Loudmouth [#20]
Jelmer Vernooij <jelmer@samba.org>
parents:
540
diff
changeset
|
786 |
#ifdef HAVE_GSSAPI |
33ffbface103
Applied patch to add GSSAPI support to Loudmouth [#20]
Jelmer Vernooij <jelmer@samba.org>
parents:
540
diff
changeset
|
787 |
case AUTH_TYPE_GSSAPI: |
33ffbface103
Applied patch to add GSSAPI support to Loudmouth [#20]
Jelmer Vernooij <jelmer@samba.org>
parents:
540
diff
changeset
|
788 |
sasl_gssapi_handle_challenge(sasl, message->node); |
33ffbface103
Applied patch to add GSSAPI support to Loudmouth [#20]
Jelmer Vernooij <jelmer@samba.org>
parents:
540
diff
changeset
|
789 |
break; |
33ffbface103
Applied patch to add GSSAPI support to Loudmouth [#20]
Jelmer Vernooij <jelmer@samba.org>
parents:
540
diff
changeset
|
790 |
#endif |
518
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
516
diff
changeset
|
791 |
default: |
614
773201ca404c
Replaced every g_warning() with g_log()
Mikael Berthe <mikael@lilotux.net>
parents:
607
diff
changeset
|
792 |
g_log (LM_LOG_DOMAIN, LM_LOG_LEVEL_NET, "Wrong auth type"); |
518
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
516
diff
changeset
|
793 |
break; |
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
516
diff
changeset
|
794 |
} |
216
fab18da0956b
Added lm-sasl.[ch] from Senko
Mikael Hallendal <micke@imendio.com>
parents:
diff
changeset
|
795 |
|
518
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
516
diff
changeset
|
796 |
return LM_HANDLER_RESULT_REMOVE_MESSAGE; |
216
fab18da0956b
Added lm-sasl.[ch] from Senko
Mikael Hallendal <micke@imendio.com>
parents:
diff
changeset
|
797 |
} |
fab18da0956b
Added lm-sasl.[ch] from Senko
Mikael Hallendal <micke@imendio.com>
parents:
diff
changeset
|
798 |
|
fab18da0956b
Added lm-sasl.[ch] from Senko
Mikael Hallendal <micke@imendio.com>
parents:
diff
changeset
|
799 |
static LmHandlerResult |
227
b8fa5635fb30
Conform with Loudmouth coding style
Mikael Hallendal <micke@imendio.com>
parents:
225
diff
changeset
|
800 |
sasl_success_cb (LmMessageHandler *handler, |
518
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
516
diff
changeset
|
801 |
LmConnection *connection, |
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
516
diff
changeset
|
802 |
LmMessage *message, |
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
516
diff
changeset
|
803 |
gpointer user_data) |
216
fab18da0956b
Added lm-sasl.[ch] from Senko
Mikael Hallendal <micke@imendio.com>
parents:
diff
changeset
|
804 |
{ |
518
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
516
diff
changeset
|
805 |
LmSASL *sasl; |
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
516
diff
changeset
|
806 |
const gchar *ns; |
607 | 807 |
|
518
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
516
diff
changeset
|
808 |
ns = lm_message_node_get_attribute (message->node, "xmlns"); |
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
516
diff
changeset
|
809 |
if (!ns || strcmp (ns, XMPP_NS_SASL_AUTH) != 0) { |
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
516
diff
changeset
|
810 |
return LM_HANDLER_RESULT_ALLOW_MORE_HANDLERS; |
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
516
diff
changeset
|
811 |
} |
216
fab18da0956b
Added lm-sasl.[ch] from Senko
Mikael Hallendal <micke@imendio.com>
parents:
diff
changeset
|
812 |
|
518
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
516
diff
changeset
|
813 |
sasl = (LmSASL *) user_data; |
216
fab18da0956b
Added lm-sasl.[ch] from Senko
Mikael Hallendal <micke@imendio.com>
parents:
diff
changeset
|
814 |
|
518
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
516
diff
changeset
|
815 |
switch (sasl->auth_type) { |
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
516
diff
changeset
|
816 |
case AUTH_TYPE_PLAIN: |
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
516
diff
changeset
|
817 |
if (sasl->state != SASL_AUTH_STATE_PLAIN_STARTED) { |
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
516
diff
changeset
|
818 |
g_log (LM_LOG_DOMAIN, LM_LOG_LEVEL_SASL, |
607 | 819 |
"%s: server sent success before finishing auth", |
518
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
516
diff
changeset
|
820 |
G_STRFUNC); |
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
516
diff
changeset
|
821 |
if (sasl->handler) { |
607 | 822 |
sasl->handler (sasl, sasl->connection, |
518
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
516
diff
changeset
|
823 |
FALSE, "server error"); |
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
516
diff
changeset
|
824 |
} |
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
516
diff
changeset
|
825 |
} |
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
516
diff
changeset
|
826 |
break; |
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
516
diff
changeset
|
827 |
case AUTH_TYPE_DIGEST: |
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
516
diff
changeset
|
828 |
if (sasl->state != SASL_AUTH_STATE_DIGEST_MD5_SENT_AUTH_RESPONSE && |
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
516
diff
changeset
|
829 |
sasl->state != SASL_AUTH_STATE_DIGEST_MD5_SENT_FINAL_RESPONSE) { |
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
516
diff
changeset
|
830 |
g_log (LM_LOG_DOMAIN, LM_LOG_LEVEL_SASL, |
607 | 831 |
"%s: server sent success before finishing auth", |
518
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
516
diff
changeset
|
832 |
G_STRFUNC); |
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
516
diff
changeset
|
833 |
if (sasl->handler) { |
607 | 834 |
sasl->handler (sasl, sasl->connection, |
518
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
516
diff
changeset
|
835 |
FALSE, "server error"); |
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
516
diff
changeset
|
836 |
} |
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
516
diff
changeset
|
837 |
} |
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
516
diff
changeset
|
838 |
break; |
563
33ffbface103
Applied patch to add GSSAPI support to Loudmouth [#20]
Jelmer Vernooij <jelmer@samba.org>
parents:
540
diff
changeset
|
839 |
#ifdef HAVE_GSSAPI |
33ffbface103
Applied patch to add GSSAPI support to Loudmouth [#20]
Jelmer Vernooij <jelmer@samba.org>
parents:
540
diff
changeset
|
840 |
case AUTH_TYPE_GSSAPI: |
33ffbface103
Applied patch to add GSSAPI support to Loudmouth [#20]
Jelmer Vernooij <jelmer@samba.org>
parents:
540
diff
changeset
|
841 |
if (sasl->state != SASL_AUTH_STATE_GSSAPI_SENT_AUTH_RESPONSE && |
33ffbface103
Applied patch to add GSSAPI support to Loudmouth [#20]
Jelmer Vernooij <jelmer@samba.org>
parents:
540
diff
changeset
|
842 |
sasl->state != SASL_AUTH_STATE_GSSAPI_SENT_FINAL_RESPONSE) { |
33ffbface103
Applied patch to add GSSAPI support to Loudmouth [#20]
Jelmer Vernooij <jelmer@samba.org>
parents:
540
diff
changeset
|
843 |
sasl_gssapi_finish(sasl, message->node); |
607 | 844 |
g_log (LM_LOG_DOMAIN, LM_LOG_LEVEL_SASL, |
563
33ffbface103
Applied patch to add GSSAPI support to Loudmouth [#20]
Jelmer Vernooij <jelmer@samba.org>
parents:
540
diff
changeset
|
845 |
"%s: server sent success before starting auth", |
33ffbface103
Applied patch to add GSSAPI support to Loudmouth [#20]
Jelmer Vernooij <jelmer@samba.org>
parents:
540
diff
changeset
|
846 |
G_STRFUNC); |
33ffbface103
Applied patch to add GSSAPI support to Loudmouth [#20]
Jelmer Vernooij <jelmer@samba.org>
parents:
540
diff
changeset
|
847 |
if (sasl->handler) { |
33ffbface103
Applied patch to add GSSAPI support to Loudmouth [#20]
Jelmer Vernooij <jelmer@samba.org>
parents:
540
diff
changeset
|
848 |
sasl->handler (sasl, sasl->connection, |
33ffbface103
Applied patch to add GSSAPI support to Loudmouth [#20]
Jelmer Vernooij <jelmer@samba.org>
parents:
540
diff
changeset
|
849 |
FALSE, "server error"); |
33ffbface103
Applied patch to add GSSAPI support to Loudmouth [#20]
Jelmer Vernooij <jelmer@samba.org>
parents:
540
diff
changeset
|
850 |
} |
33ffbface103
Applied patch to add GSSAPI support to Loudmouth [#20]
Jelmer Vernooij <jelmer@samba.org>
parents:
540
diff
changeset
|
851 |
} |
33ffbface103
Applied patch to add GSSAPI support to Loudmouth [#20]
Jelmer Vernooij <jelmer@samba.org>
parents:
540
diff
changeset
|
852 |
break; |
33ffbface103
Applied patch to add GSSAPI support to Loudmouth [#20]
Jelmer Vernooij <jelmer@samba.org>
parents:
540
diff
changeset
|
853 |
#endif |
518
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
516
diff
changeset
|
854 |
default: |
614
773201ca404c
Replaced every g_warning() with g_log()
Mikael Berthe <mikael@lilotux.net>
parents:
607
diff
changeset
|
855 |
g_log (LM_LOG_DOMAIN, LM_LOG_LEVEL_NET, "Wrong auth type"); |
518
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
516
diff
changeset
|
856 |
break; |
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
516
diff
changeset
|
857 |
} |
216
fab18da0956b
Added lm-sasl.[ch] from Senko
Mikael Hallendal <micke@imendio.com>
parents:
diff
changeset
|
858 |
|
518
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
516
diff
changeset
|
859 |
g_log (LM_LOG_DOMAIN, LM_LOG_LEVEL_SASL, |
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
516
diff
changeset
|
860 |
"%s: SASL authentication successful", G_STRFUNC); |
227
b8fa5635fb30
Conform with Loudmouth coding style
Mikael Hallendal <micke@imendio.com>
parents:
225
diff
changeset
|
861 |
|
518
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
516
diff
changeset
|
862 |
if (sasl->handler) { |
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
516
diff
changeset
|
863 |
sasl->handler (sasl, sasl->connection, TRUE, NULL); |
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
516
diff
changeset
|
864 |
} |
216
fab18da0956b
Added lm-sasl.[ch] from Senko
Mikael Hallendal <micke@imendio.com>
parents:
diff
changeset
|
865 |
|
518
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
516
diff
changeset
|
866 |
return LM_HANDLER_RESULT_REMOVE_MESSAGE; |
607 | 867 |
|
216
fab18da0956b
Added lm-sasl.[ch] from Senko
Mikael Hallendal <micke@imendio.com>
parents:
diff
changeset
|
868 |
} |
fab18da0956b
Added lm-sasl.[ch] from Senko
Mikael Hallendal <micke@imendio.com>
parents:
diff
changeset
|
869 |
|
fab18da0956b
Added lm-sasl.[ch] from Senko
Mikael Hallendal <micke@imendio.com>
parents:
diff
changeset
|
870 |
static LmHandlerResult |
227
b8fa5635fb30
Conform with Loudmouth coding style
Mikael Hallendal <micke@imendio.com>
parents:
225
diff
changeset
|
871 |
sasl_failure_cb (LmMessageHandler *handler, |
518
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
516
diff
changeset
|
872 |
LmConnection *connection, |
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
516
diff
changeset
|
873 |
LmMessage *message, |
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
516
diff
changeset
|
874 |
gpointer user_data) |
216
fab18da0956b
Added lm-sasl.[ch] from Senko
Mikael Hallendal <micke@imendio.com>
parents:
diff
changeset
|
875 |
{ |
518
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
516
diff
changeset
|
876 |
LmSASL *sasl; |
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
516
diff
changeset
|
877 |
const gchar *ns; |
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
516
diff
changeset
|
878 |
const gchar *reason = "unknown reason"; |
607 | 879 |
|
518
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
516
diff
changeset
|
880 |
ns = lm_message_node_get_attribute (message->node, "xmlns"); |
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
516
diff
changeset
|
881 |
if (!ns || strcmp (ns, XMPP_NS_SASL_AUTH) != 0) { |
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
516
diff
changeset
|
882 |
return LM_HANDLER_RESULT_ALLOW_MORE_HANDLERS; |
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
516
diff
changeset
|
883 |
} |
216
fab18da0956b
Added lm-sasl.[ch] from Senko
Mikael Hallendal <micke@imendio.com>
parents:
diff
changeset
|
884 |
|
518
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
516
diff
changeset
|
885 |
sasl = (LmSASL *) user_data; |
216
fab18da0956b
Added lm-sasl.[ch] from Senko
Mikael Hallendal <micke@imendio.com>
parents:
diff
changeset
|
886 |
|
518
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
516
diff
changeset
|
887 |
if (message->node->children) { |
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
516
diff
changeset
|
888 |
const gchar *r; |
607 | 889 |
|
518
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
516
diff
changeset
|
890 |
r = lm_message_node_get_value (message->node->children); |
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
516
diff
changeset
|
891 |
if (r) { |
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
516
diff
changeset
|
892 |
reason = r; |
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
516
diff
changeset
|
893 |
} |
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
516
diff
changeset
|
894 |
} |
607 | 895 |
|
518
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
516
diff
changeset
|
896 |
g_log (LM_LOG_DOMAIN, LM_LOG_LEVEL_SASL, |
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
516
diff
changeset
|
897 |
"%s: SASL authentication failed: %s", G_STRFUNC, reason); |
227
b8fa5635fb30
Conform with Loudmouth coding style
Mikael Hallendal <micke@imendio.com>
parents:
225
diff
changeset
|
898 |
|
518
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
516
diff
changeset
|
899 |
if (sasl->handler) { |
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
516
diff
changeset
|
900 |
sasl->handler (sasl, sasl->connection, FALSE, reason); |
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
516
diff
changeset
|
901 |
} |
216
fab18da0956b
Added lm-sasl.[ch] from Senko
Mikael Hallendal <micke@imendio.com>
parents:
diff
changeset
|
902 |
|
518
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
516
diff
changeset
|
903 |
return LM_HANDLER_RESULT_REMOVE_MESSAGE; |
216
fab18da0956b
Added lm-sasl.[ch] from Senko
Mikael Hallendal <micke@imendio.com>
parents:
diff
changeset
|
904 |
} |
fab18da0956b
Added lm-sasl.[ch] from Senko
Mikael Hallendal <micke@imendio.com>
parents:
diff
changeset
|
905 |
|
fab18da0956b
Added lm-sasl.[ch] from Senko
Mikael Hallendal <micke@imendio.com>
parents:
diff
changeset
|
906 |
|
fab18da0956b
Added lm-sasl.[ch] from Senko
Mikael Hallendal <micke@imendio.com>
parents:
diff
changeset
|
907 |
static gboolean |
227
b8fa5635fb30
Conform with Loudmouth coding style
Mikael Hallendal <micke@imendio.com>
parents:
225
diff
changeset
|
908 |
sasl_start (LmSASL *sasl) |
216
fab18da0956b
Added lm-sasl.[ch] from Senko
Mikael Hallendal <micke@imendio.com>
parents:
diff
changeset
|
909 |
{ |
518
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
516
diff
changeset
|
910 |
LmMessage *auth_msg; |
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
516
diff
changeset
|
911 |
gboolean result; |
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
516
diff
changeset
|
912 |
const char *mech = NULL; |
216
fab18da0956b
Added lm-sasl.[ch] from Senko
Mikael Hallendal <micke@imendio.com>
parents:
diff
changeset
|
913 |
|
518
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
516
diff
changeset
|
914 |
auth_msg = lm_message_new (NULL, LM_MESSAGE_TYPE_AUTH); |
216
fab18da0956b
Added lm-sasl.[ch] from Senko
Mikael Hallendal <micke@imendio.com>
parents:
diff
changeset
|
915 |
|
518
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
516
diff
changeset
|
916 |
if (sasl->auth_type == AUTH_TYPE_PLAIN) { |
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
516
diff
changeset
|
917 |
GString *str; |
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
516
diff
changeset
|
918 |
gchar *cstr; |
227
b8fa5635fb30
Conform with Loudmouth coding style
Mikael Hallendal <micke@imendio.com>
parents:
225
diff
changeset
|
919 |
|
518
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
516
diff
changeset
|
920 |
str = g_string_new (""); |
216
fab18da0956b
Added lm-sasl.[ch] from Senko
Mikael Hallendal <micke@imendio.com>
parents:
diff
changeset
|
921 |
|
518
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
516
diff
changeset
|
922 |
mech = "PLAIN"; |
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
516
diff
changeset
|
923 |
sasl->state = SASL_AUTH_STATE_PLAIN_STARTED; |
216
fab18da0956b
Added lm-sasl.[ch] from Senko
Mikael Hallendal <micke@imendio.com>
parents:
diff
changeset
|
924 |
|
540
72acfccdec86
Switch to use LmAuthParameters instead of passing around username and password.
Mikael Hallendal <micke@imendio.com>
parents:
518
diff
changeset
|
925 |
if (sasl->auth_params == NULL) { |
518
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
516
diff
changeset
|
926 |
g_log (LM_LOG_DOMAIN, LM_LOG_LEVEL_SASL, |
607 | 927 |
"%s: no authentication parameters provided", |
518
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
516
diff
changeset
|
928 |
G_STRFUNC); |
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
516
diff
changeset
|
929 |
if (sasl->handler) { |
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
516
diff
changeset
|
930 |
sasl->handler (sasl, sasl->connection, FALSE, "no username/password provided"); |
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
516
diff
changeset
|
931 |
} |
227
b8fa5635fb30
Conform with Loudmouth coding style
Mikael Hallendal <micke@imendio.com>
parents:
225
diff
changeset
|
932 |
|
518
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
516
diff
changeset
|
933 |
return FALSE; |
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
516
diff
changeset
|
934 |
} |
216
fab18da0956b
Added lm-sasl.[ch] from Senko
Mikael Hallendal <micke@imendio.com>
parents:
diff
changeset
|
935 |
|
518
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
516
diff
changeset
|
936 |
g_string_append_c (str, '\0'); |
540
72acfccdec86
Switch to use LmAuthParameters instead of passing around username and password.
Mikael Hallendal <micke@imendio.com>
parents:
518
diff
changeset
|
937 |
g_string_append (str, lm_auth_parameters_get_username (sasl->auth_params)); |
518
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
516
diff
changeset
|
938 |
g_string_append_c (str, '\0'); |
540
72acfccdec86
Switch to use LmAuthParameters instead of passing around username and password.
Mikael Hallendal <micke@imendio.com>
parents:
518
diff
changeset
|
939 |
g_string_append (str, lm_auth_parameters_get_password (sasl->auth_params)); |
607 | 940 |
cstr = g_base64_encode ((const guchar *) str->str, |
518
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
516
diff
changeset
|
941 |
(gsize) str->len); |
216
fab18da0956b
Added lm-sasl.[ch] from Senko
Mikael Hallendal <micke@imendio.com>
parents:
diff
changeset
|
942 |
|
518
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
516
diff
changeset
|
943 |
lm_message_node_set_value (auth_msg->node, cstr); |
216
fab18da0956b
Added lm-sasl.[ch] from Senko
Mikael Hallendal <micke@imendio.com>
parents:
diff
changeset
|
944 |
|
518
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
516
diff
changeset
|
945 |
g_string_free (str, TRUE); |
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
516
diff
changeset
|
946 |
g_free (cstr); |
216
fab18da0956b
Added lm-sasl.[ch] from Senko
Mikael Hallendal <micke@imendio.com>
parents:
diff
changeset
|
947 |
|
518
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
516
diff
changeset
|
948 |
/* Here we say the Google magic word. Bad Google. */ |
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
516
diff
changeset
|
949 |
lm_message_node_set_attributes (auth_msg->node, |
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
516
diff
changeset
|
950 |
"xmlns:ga", "http://www.google.com/talk/protocol/auth", |
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
516
diff
changeset
|
951 |
"ga:client-uses-full-bind-result", "true", |
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
516
diff
changeset
|
952 |
NULL); |
216
fab18da0956b
Added lm-sasl.[ch] from Senko
Mikael Hallendal <micke@imendio.com>
parents:
diff
changeset
|
953 |
|
607 | 954 |
} |
518
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
516
diff
changeset
|
955 |
else if (sasl->auth_type == AUTH_TYPE_DIGEST) { |
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
516
diff
changeset
|
956 |
mech = "DIGEST-MD5"; |
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
516
diff
changeset
|
957 |
sasl->state = SASL_AUTH_STATE_DIGEST_MD5_STARTED; |
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
516
diff
changeset
|
958 |
} |
563
33ffbface103
Applied patch to add GSSAPI support to Loudmouth [#20]
Jelmer Vernooij <jelmer@samba.org>
parents:
540
diff
changeset
|
959 |
#ifdef HAVE_GSSAPI |
33ffbface103
Applied patch to add GSSAPI support to Loudmouth [#20]
Jelmer Vernooij <jelmer@samba.org>
parents:
540
diff
changeset
|
960 |
else if (sasl->auth_type == AUTH_TYPE_GSSAPI) { |
33ffbface103
Applied patch to add GSSAPI support to Loudmouth [#20]
Jelmer Vernooij <jelmer@samba.org>
parents:
540
diff
changeset
|
961 |
mech = "GSSAPI"; |
564
db3e9ff448cb
Style fixes for GSSAPI changes [#20].
Mikael Hallendal <micke@imendio.com>
parents:
563
diff
changeset
|
962 |
sasl_gssapi_start (sasl, auth_msg->node); |
563
33ffbface103
Applied patch to add GSSAPI support to Loudmouth [#20]
Jelmer Vernooij <jelmer@samba.org>
parents:
540
diff
changeset
|
963 |
} |
33ffbface103
Applied patch to add GSSAPI support to Loudmouth [#20]
Jelmer Vernooij <jelmer@samba.org>
parents:
540
diff
changeset
|
964 |
#endif |
216
fab18da0956b
Added lm-sasl.[ch] from Senko
Mikael Hallendal <micke@imendio.com>
parents:
diff
changeset
|
965 |
|
518
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
516
diff
changeset
|
966 |
lm_message_node_set_attributes (auth_msg->node, |
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
516
diff
changeset
|
967 |
"xmlns", XMPP_NS_SASL_AUTH, |
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
516
diff
changeset
|
968 |
"mechanism", mech, |
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
516
diff
changeset
|
969 |
NULL); |
216
fab18da0956b
Added lm-sasl.[ch] from Senko
Mikael Hallendal <micke@imendio.com>
parents:
diff
changeset
|
970 |
|
518
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
516
diff
changeset
|
971 |
result = lm_connection_send (sasl->connection, auth_msg, NULL); |
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
516
diff
changeset
|
972 |
lm_message_unref (auth_msg); |
227
b8fa5635fb30
Conform with Loudmouth coding style
Mikael Hallendal <micke@imendio.com>
parents:
225
diff
changeset
|
973 |
|
518
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
516
diff
changeset
|
974 |
if (!result) { |
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
516
diff
changeset
|
975 |
return FALSE; |
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
516
diff
changeset
|
976 |
} |
216
fab18da0956b
Added lm-sasl.[ch] from Senko
Mikael Hallendal <micke@imendio.com>
parents:
diff
changeset
|
977 |
|
518
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
516
diff
changeset
|
978 |
return TRUE; |
216
fab18da0956b
Added lm-sasl.[ch] from Senko
Mikael Hallendal <micke@imendio.com>
parents:
diff
changeset
|
979 |
} |
fab18da0956b
Added lm-sasl.[ch] from Senko
Mikael Hallendal <micke@imendio.com>
parents:
diff
changeset
|
980 |
|
fab18da0956b
Added lm-sasl.[ch] from Senko
Mikael Hallendal <micke@imendio.com>
parents:
diff
changeset
|
981 |
static gboolean |
255
704881ac7788
Fixed potential problem if auth was not called from the open callback.
Mikael Hallendal <micke@imendio.com>
parents:
227
diff
changeset
|
982 |
sasl_set_auth_type (LmSASL *sasl, LmMessageNode *mechanisms) |
216
fab18da0956b
Added lm-sasl.[ch] from Senko
Mikael Hallendal <micke@imendio.com>
parents:
diff
changeset
|
983 |
{ |
518
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
516
diff
changeset
|
984 |
LmMessageNode *m; |
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
516
diff
changeset
|
985 |
const gchar *ns; |
216
fab18da0956b
Added lm-sasl.[ch] from Senko
Mikael Hallendal <micke@imendio.com>
parents:
diff
changeset
|
986 |
|
518
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
516
diff
changeset
|
987 |
sasl->auth_type = 0; |
255
704881ac7788
Fixed potential problem if auth was not called from the open callback.
Mikael Hallendal <micke@imendio.com>
parents:
227
diff
changeset
|
988 |
|
518
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
516
diff
changeset
|
989 |
ns = lm_message_node_get_attribute (mechanisms, "xmlns"); |
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
516
diff
changeset
|
990 |
if (!ns || strcmp (ns, XMPP_NS_SASL_AUTH) != 0) { |
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
516
diff
changeset
|
991 |
return FALSE; |
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
516
diff
changeset
|
992 |
} |
216
fab18da0956b
Added lm-sasl.[ch] from Senko
Mikael Hallendal <micke@imendio.com>
parents:
diff
changeset
|
993 |
|
518
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
516
diff
changeset
|
994 |
for (m = mechanisms->children; m; m = m->next) { |
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
516
diff
changeset
|
995 |
const gchar *name; |
563
33ffbface103
Applied patch to add GSSAPI support to Loudmouth [#20]
Jelmer Vernooij <jelmer@samba.org>
parents:
540
diff
changeset
|
996 |
|
518
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
516
diff
changeset
|
997 |
name = lm_message_node_get_value (m); |
227
b8fa5635fb30
Conform with Loudmouth coding style
Mikael Hallendal <micke@imendio.com>
parents:
225
diff
changeset
|
998 |
|
518
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
516
diff
changeset
|
999 |
if (!name) { |
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
516
diff
changeset
|
1000 |
continue; |
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
516
diff
changeset
|
1001 |
} |
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
516
diff
changeset
|
1002 |
if (strcmp (name, "PLAIN") == 0) { |
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
516
diff
changeset
|
1003 |
sasl->auth_type |= AUTH_TYPE_PLAIN; |
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
516
diff
changeset
|
1004 |
continue; |
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
516
diff
changeset
|
1005 |
} |
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
516
diff
changeset
|
1006 |
if (strcmp (name, "DIGEST-MD5") == 0) { |
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
516
diff
changeset
|
1007 |
sasl->auth_type |= AUTH_TYPE_DIGEST; |
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
516
diff
changeset
|
1008 |
continue; |
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
516
diff
changeset
|
1009 |
} |
563
33ffbface103
Applied patch to add GSSAPI support to Loudmouth [#20]
Jelmer Vernooij <jelmer@samba.org>
parents:
540
diff
changeset
|
1010 |
if (strcmp (name, "GSSAPI") == 0) { |
33ffbface103
Applied patch to add GSSAPI support to Loudmouth [#20]
Jelmer Vernooij <jelmer@samba.org>
parents:
540
diff
changeset
|
1011 |
sasl->auth_type |= AUTH_TYPE_GSSAPI; |
33ffbface103
Applied patch to add GSSAPI support to Loudmouth [#20]
Jelmer Vernooij <jelmer@samba.org>
parents:
540
diff
changeset
|
1012 |
continue; |
33ffbface103
Applied patch to add GSSAPI support to Loudmouth [#20]
Jelmer Vernooij <jelmer@samba.org>
parents:
540
diff
changeset
|
1013 |
} |
607 | 1014 |
|
518
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
516
diff
changeset
|
1015 |
g_log (LM_LOG_DOMAIN, LM_LOG_LEVEL_SASL, |
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
516
diff
changeset
|
1016 |
"%s: unknown SASL auth mechanism: %s", G_STRFUNC, name); |
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
516
diff
changeset
|
1017 |
} |
255
704881ac7788
Fixed potential problem if auth was not called from the open callback.
Mikael Hallendal <micke@imendio.com>
parents:
227
diff
changeset
|
1018 |
|
518
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
516
diff
changeset
|
1019 |
return TRUE; |
255
704881ac7788
Fixed potential problem if auth was not called from the open callback.
Mikael Hallendal <micke@imendio.com>
parents:
227
diff
changeset
|
1020 |
} |
704881ac7788
Fixed potential problem if auth was not called from the open callback.
Mikael Hallendal <micke@imendio.com>
parents:
227
diff
changeset
|
1021 |
|
704881ac7788
Fixed potential problem if auth was not called from the open callback.
Mikael Hallendal <micke@imendio.com>
parents:
227
diff
changeset
|
1022 |
static gboolean |
704881ac7788
Fixed potential problem if auth was not called from the open callback.
Mikael Hallendal <micke@imendio.com>
parents:
227
diff
changeset
|
1023 |
sasl_authenticate (LmSASL *sasl) |
704881ac7788
Fixed potential problem if auth was not called from the open callback.
Mikael Hallendal <micke@imendio.com>
parents:
227
diff
changeset
|
1024 |
{ |
518
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
516
diff
changeset
|
1025 |
if (sasl->auth_type == 0) { |
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
516
diff
changeset
|
1026 |
g_log (LM_LOG_DOMAIN, LM_LOG_LEVEL_SASL, |
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
516
diff
changeset
|
1027 |
"%s: no supported SASL auth mechanisms found", |
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
516
diff
changeset
|
1028 |
G_STRFUNC); |
255
704881ac7788
Fixed potential problem if auth was not called from the open callback.
Mikael Hallendal <micke@imendio.com>
parents:
227
diff
changeset
|
1029 |
|
518
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
516
diff
changeset
|
1030 |
return FALSE; |
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
516
diff
changeset
|
1031 |
} |
255
704881ac7788
Fixed potential problem if auth was not called from the open callback.
Mikael Hallendal <micke@imendio.com>
parents:
227
diff
changeset
|
1032 |
|
563
33ffbface103
Applied patch to add GSSAPI support to Loudmouth [#20]
Jelmer Vernooij <jelmer@samba.org>
parents:
540
diff
changeset
|
1033 |
/* Prefer GSSAPI if available */ |
33ffbface103
Applied patch to add GSSAPI support to Loudmouth [#20]
Jelmer Vernooij <jelmer@samba.org>
parents:
540
diff
changeset
|
1034 |
#ifdef HAVE_GSSAPI |
33ffbface103
Applied patch to add GSSAPI support to Loudmouth [#20]
Jelmer Vernooij <jelmer@samba.org>
parents:
540
diff
changeset
|
1035 |
if (sasl->auth_type & AUTH_TYPE_GSSAPI) { |
33ffbface103
Applied patch to add GSSAPI support to Loudmouth [#20]
Jelmer Vernooij <jelmer@samba.org>
parents:
540
diff
changeset
|
1036 |
sasl->auth_type = AUTH_TYPE_GSSAPI; |
33ffbface103
Applied patch to add GSSAPI support to Loudmouth [#20]
Jelmer Vernooij <jelmer@samba.org>
parents:
540
diff
changeset
|
1037 |
return sasl_start (sasl); |
33ffbface103
Applied patch to add GSSAPI support to Loudmouth [#20]
Jelmer Vernooij <jelmer@samba.org>
parents:
540
diff
changeset
|
1038 |
} |
33ffbface103
Applied patch to add GSSAPI support to Loudmouth [#20]
Jelmer Vernooij <jelmer@samba.org>
parents:
540
diff
changeset
|
1039 |
#endif |
33ffbface103
Applied patch to add GSSAPI support to Loudmouth [#20]
Jelmer Vernooij <jelmer@samba.org>
parents:
540
diff
changeset
|
1040 |
/* Otherwise prefer DIGEST */ |
33ffbface103
Applied patch to add GSSAPI support to Loudmouth [#20]
Jelmer Vernooij <jelmer@samba.org>
parents:
540
diff
changeset
|
1041 |
else if (sasl->auth_type & AUTH_TYPE_DIGEST) { |
518
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
516
diff
changeset
|
1042 |
sasl->auth_type = AUTH_TYPE_DIGEST; |
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
516
diff
changeset
|
1043 |
return sasl_start (sasl); |
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
516
diff
changeset
|
1044 |
} |
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
516
diff
changeset
|
1045 |
else if (sasl->auth_type & AUTH_TYPE_PLAIN) { |
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
516
diff
changeset
|
1046 |
sasl->auth_type = AUTH_TYPE_PLAIN; |
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
516
diff
changeset
|
1047 |
return sasl_start (sasl); |
607 | 1048 |
} |
216
fab18da0956b
Added lm-sasl.[ch] from Senko
Mikael Hallendal <micke@imendio.com>
parents:
diff
changeset
|
1049 |
|
518
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
516
diff
changeset
|
1050 |
return FALSE; |
216
fab18da0956b
Added lm-sasl.[ch] from Senko
Mikael Hallendal <micke@imendio.com>
parents:
diff
changeset
|
1051 |
} |
fab18da0956b
Added lm-sasl.[ch] from Senko
Mikael Hallendal <micke@imendio.com>
parents:
diff
changeset
|
1052 |
|
fab18da0956b
Added lm-sasl.[ch] from Senko
Mikael Hallendal <micke@imendio.com>
parents:
diff
changeset
|
1053 |
static LmHandlerResult |
227
b8fa5635fb30
Conform with Loudmouth coding style
Mikael Hallendal <micke@imendio.com>
parents:
225
diff
changeset
|
1054 |
sasl_features_cb (LmMessageHandler *handler, |
518
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
516
diff
changeset
|
1055 |
LmConnection *connection, |
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
516
diff
changeset
|
1056 |
LmMessage *message, |
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
516
diff
changeset
|
1057 |
gpointer user_data) |
216
fab18da0956b
Added lm-sasl.[ch] from Senko
Mikael Hallendal <micke@imendio.com>
parents:
diff
changeset
|
1058 |
{ |
518
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
516
diff
changeset
|
1059 |
LmMessageNode *mechanisms; |
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
516
diff
changeset
|
1060 |
LmSASL *sasl; |
216
fab18da0956b
Added lm-sasl.[ch] from Senko
Mikael Hallendal <micke@imendio.com>
parents:
diff
changeset
|
1061 |
|
518
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
516
diff
changeset
|
1062 |
g_log (LM_LOG_DOMAIN, LM_LOG_LEVEL_SASL, "Stream features received\n"); |
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
516
diff
changeset
|
1063 |
mechanisms = lm_message_node_find_child (message->node, "mechanisms"); |
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
516
diff
changeset
|
1064 |
if (!mechanisms) { |
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
516
diff
changeset
|
1065 |
return LM_HANDLER_RESULT_ALLOW_MORE_HANDLERS; |
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
516
diff
changeset
|
1066 |
} |
216
fab18da0956b
Added lm-sasl.[ch] from Senko
Mikael Hallendal <micke@imendio.com>
parents:
diff
changeset
|
1067 |
|
518
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
516
diff
changeset
|
1068 |
sasl = (LmSASL *) user_data; |
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
516
diff
changeset
|
1069 |
sasl->features_received = TRUE; |
216
fab18da0956b
Added lm-sasl.[ch] from Senko
Mikael Hallendal <micke@imendio.com>
parents:
diff
changeset
|
1070 |
|
518
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
516
diff
changeset
|
1071 |
sasl_set_auth_type (sasl, mechanisms); |
255
704881ac7788
Fixed potential problem if auth was not called from the open callback.
Mikael Hallendal <micke@imendio.com>
parents:
227
diff
changeset
|
1072 |
|
518
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
516
diff
changeset
|
1073 |
if (sasl->start_auth) { |
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
516
diff
changeset
|
1074 |
sasl_authenticate (sasl); |
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
516
diff
changeset
|
1075 |
} |
216
fab18da0956b
Added lm-sasl.[ch] from Senko
Mikael Hallendal <micke@imendio.com>
parents:
diff
changeset
|
1076 |
|
518
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
516
diff
changeset
|
1077 |
return LM_HANDLER_RESULT_ALLOW_MORE_HANDLERS; |
216
fab18da0956b
Added lm-sasl.[ch] from Senko
Mikael Hallendal <micke@imendio.com>
parents:
diff
changeset
|
1078 |
} |
fab18da0956b
Added lm-sasl.[ch] from Senko
Mikael Hallendal <micke@imendio.com>
parents:
diff
changeset
|
1079 |
|
227
b8fa5635fb30
Conform with Loudmouth coding style
Mikael Hallendal <micke@imendio.com>
parents:
225
diff
changeset
|
1080 |
LmSASL * |
255
704881ac7788
Fixed potential problem if auth was not called from the open callback.
Mikael Hallendal <micke@imendio.com>
parents:
227
diff
changeset
|
1081 |
lm_sasl_new (LmConnection *connection) |
227
b8fa5635fb30
Conform with Loudmouth coding style
Mikael Hallendal <micke@imendio.com>
parents:
225
diff
changeset
|
1082 |
{ |
518
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
516
diff
changeset
|
1083 |
LmSASL *sasl; |
607 | 1084 |
|
518
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
516
diff
changeset
|
1085 |
sasl = g_new0 (LmSASL, 1); |
216
fab18da0956b
Added lm-sasl.[ch] from Senko
Mikael Hallendal <micke@imendio.com>
parents:
diff
changeset
|
1086 |
|
518
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
516
diff
changeset
|
1087 |
sasl->connection = connection; |
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
516
diff
changeset
|
1088 |
sasl->features_received = FALSE; |
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
516
diff
changeset
|
1089 |
sasl->start_auth = FALSE; |
255
704881ac7788
Fixed potential problem if auth was not called from the open callback.
Mikael Hallendal <micke@imendio.com>
parents:
227
diff
changeset
|
1090 |
|
518
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
516
diff
changeset
|
1091 |
sasl->features_cb = lm_message_handler_new (sasl_features_cb, |
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
516
diff
changeset
|
1092 |
sasl, |
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
516
diff
changeset
|
1093 |
NULL); |
255
704881ac7788
Fixed potential problem if auth was not called from the open callback.
Mikael Hallendal <micke@imendio.com>
parents:
227
diff
changeset
|
1094 |
|
518
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
516
diff
changeset
|
1095 |
lm_connection_register_message_handler (connection, |
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
516
diff
changeset
|
1096 |
sasl->features_cb, |
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
516
diff
changeset
|
1097 |
LM_MESSAGE_TYPE_STREAM_FEATURES, |
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
516
diff
changeset
|
1098 |
LM_HANDLER_PRIORITY_LAST); |
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
516
diff
changeset
|
1099 |
return sasl; |
255
704881ac7788
Fixed potential problem if auth was not called from the open callback.
Mikael Hallendal <micke@imendio.com>
parents:
227
diff
changeset
|
1100 |
} |
704881ac7788
Fixed potential problem if auth was not called from the open callback.
Mikael Hallendal <micke@imendio.com>
parents:
227
diff
changeset
|
1101 |
|
704881ac7788
Fixed potential problem if auth was not called from the open callback.
Mikael Hallendal <micke@imendio.com>
parents:
227
diff
changeset
|
1102 |
void |
704881ac7788
Fixed potential problem if auth was not called from the open callback.
Mikael Hallendal <micke@imendio.com>
parents:
227
diff
changeset
|
1103 |
lm_sasl_authenticate (LmSASL *sasl, |
540
72acfccdec86
Switch to use LmAuthParameters instead of passing around username and password.
Mikael Hallendal <micke@imendio.com>
parents:
518
diff
changeset
|
1104 |
LmAuthParameters *auth_params, |
518
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
516
diff
changeset
|
1105 |
const gchar *server, |
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
516
diff
changeset
|
1106 |
LmSASLResultHandler handler) |
255
704881ac7788
Fixed potential problem if auth was not called from the open callback.
Mikael Hallendal <micke@imendio.com>
parents:
227
diff
changeset
|
1107 |
{ |
540
72acfccdec86
Switch to use LmAuthParameters instead of passing around username and password.
Mikael Hallendal <micke@imendio.com>
parents:
518
diff
changeset
|
1108 |
sasl->auth_params = lm_auth_parameters_ref (auth_params); |
72acfccdec86
Switch to use LmAuthParameters instead of passing around username and password.
Mikael Hallendal <micke@imendio.com>
parents:
518
diff
changeset
|
1109 |
sasl->server = g_strdup (server); |
72acfccdec86
Switch to use LmAuthParameters instead of passing around username and password.
Mikael Hallendal <micke@imendio.com>
parents:
518
diff
changeset
|
1110 |
sasl->handler = handler; |
227
b8fa5635fb30
Conform with Loudmouth coding style
Mikael Hallendal <micke@imendio.com>
parents:
225
diff
changeset
|
1111 |
|
518
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
516
diff
changeset
|
1112 |
sasl->challenge_cb = lm_message_handler_new (sasl_challenge_cb, |
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
516
diff
changeset
|
1113 |
sasl, |
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
516
diff
changeset
|
1114 |
NULL); |
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
516
diff
changeset
|
1115 |
lm_connection_register_message_handler (sasl->connection, |
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
516
diff
changeset
|
1116 |
sasl->challenge_cb, |
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
516
diff
changeset
|
1117 |
LM_MESSAGE_TYPE_CHALLENGE, |
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
516
diff
changeset
|
1118 |
LM_HANDLER_PRIORITY_FIRST); |
607 | 1119 |
|
518
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
516
diff
changeset
|
1120 |
sasl->success_cb = lm_message_handler_new (sasl_success_cb, |
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
516
diff
changeset
|
1121 |
sasl, |
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
516
diff
changeset
|
1122 |
NULL); |
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
516
diff
changeset
|
1123 |
lm_connection_register_message_handler (sasl->connection, |
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
516
diff
changeset
|
1124 |
sasl->success_cb, |
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
516
diff
changeset
|
1125 |
LM_MESSAGE_TYPE_SUCCESS, |
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
516
diff
changeset
|
1126 |
LM_HANDLER_PRIORITY_FIRST); |
227
b8fa5635fb30
Conform with Loudmouth coding style
Mikael Hallendal <micke@imendio.com>
parents:
225
diff
changeset
|
1127 |
|
518
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
516
diff
changeset
|
1128 |
sasl->failure_cb = lm_message_handler_new (sasl_failure_cb, |
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
516
diff
changeset
|
1129 |
sasl, |
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
516
diff
changeset
|
1130 |
NULL); |
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
516
diff
changeset
|
1131 |
lm_connection_register_message_handler (sasl->connection, |
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
516
diff
changeset
|
1132 |
sasl->failure_cb, |
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
516
diff
changeset
|
1133 |
LM_MESSAGE_TYPE_FAILURE, |
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
516
diff
changeset
|
1134 |
LM_HANDLER_PRIORITY_FIRST); |
255
704881ac7788
Fixed potential problem if auth was not called from the open callback.
Mikael Hallendal <micke@imendio.com>
parents:
227
diff
changeset
|
1135 |
|
518
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
516
diff
changeset
|
1136 |
if (sasl->features_received) { |
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
516
diff
changeset
|
1137 |
sasl_authenticate (sasl); |
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
516
diff
changeset
|
1138 |
} else { |
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
516
diff
changeset
|
1139 |
sasl->start_auth = TRUE; |
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
516
diff
changeset
|
1140 |
} |
227
b8fa5635fb30
Conform with Loudmouth coding style
Mikael Hallendal <micke@imendio.com>
parents:
225
diff
changeset
|
1141 |
} |
b8fa5635fb30
Conform with Loudmouth coding style
Mikael Hallendal <micke@imendio.com>
parents:
225
diff
changeset
|
1142 |
|
b8fa5635fb30
Conform with Loudmouth coding style
Mikael Hallendal <micke@imendio.com>
parents:
225
diff
changeset
|
1143 |
void |
b8fa5635fb30
Conform with Loudmouth coding style
Mikael Hallendal <micke@imendio.com>
parents:
225
diff
changeset
|
1144 |
lm_sasl_free (LmSASL *sasl) |
b8fa5635fb30
Conform with Loudmouth coding style
Mikael Hallendal <micke@imendio.com>
parents:
225
diff
changeset
|
1145 |
{ |
518
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
516
diff
changeset
|
1146 |
g_return_if_fail (sasl != NULL); |
607 | 1147 |
|
540
72acfccdec86
Switch to use LmAuthParameters instead of passing around username and password.
Mikael Hallendal <micke@imendio.com>
parents:
518
diff
changeset
|
1148 |
if (sasl->auth_params) { |
72acfccdec86
Switch to use LmAuthParameters instead of passing around username and password.
Mikael Hallendal <micke@imendio.com>
parents:
518
diff
changeset
|
1149 |
lm_auth_parameters_unref (sasl->auth_params); |
72acfccdec86
Switch to use LmAuthParameters instead of passing around username and password.
Mikael Hallendal <micke@imendio.com>
parents:
518
diff
changeset
|
1150 |
} |
227
b8fa5635fb30
Conform with Loudmouth coding style
Mikael Hallendal <micke@imendio.com>
parents:
225
diff
changeset
|
1151 |
|
518
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
516
diff
changeset
|
1152 |
g_free (sasl->server); |
227
b8fa5635fb30
Conform with Loudmouth coding style
Mikael Hallendal <micke@imendio.com>
parents:
225
diff
changeset
|
1153 |
|
518
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
516
diff
changeset
|
1154 |
if (sasl->features_cb) { |
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
516
diff
changeset
|
1155 |
lm_connection_unregister_message_handler (sasl->connection, |
607 | 1156 |
sasl->features_cb, |
518
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
516
diff
changeset
|
1157 |
LM_MESSAGE_TYPE_STREAM_FEATURES); |
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
516
diff
changeset
|
1158 |
} |
227
b8fa5635fb30
Conform with Loudmouth coding style
Mikael Hallendal <micke@imendio.com>
parents:
225
diff
changeset
|
1159 |
|
518
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
516
diff
changeset
|
1160 |
if (sasl->challenge_cb) { |
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
516
diff
changeset
|
1161 |
lm_connection_unregister_message_handler (sasl->connection, |
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
516
diff
changeset
|
1162 |
sasl->challenge_cb, |
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
516
diff
changeset
|
1163 |
LM_MESSAGE_TYPE_CHALLENGE); |
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
516
diff
changeset
|
1164 |
} |
227
b8fa5635fb30
Conform with Loudmouth coding style
Mikael Hallendal <micke@imendio.com>
parents:
225
diff
changeset
|
1165 |
|
518
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
516
diff
changeset
|
1166 |
if (sasl->success_cb) { |
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
516
diff
changeset
|
1167 |
lm_connection_unregister_message_handler (sasl->connection, |
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
516
diff
changeset
|
1168 |
sasl->success_cb, |
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
516
diff
changeset
|
1169 |
LM_MESSAGE_TYPE_SUCCESS); |
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
516
diff
changeset
|
1170 |
} |
227
b8fa5635fb30
Conform with Loudmouth coding style
Mikael Hallendal <micke@imendio.com>
parents:
225
diff
changeset
|
1171 |
|
518
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
516
diff
changeset
|
1172 |
if (sasl->failure_cb) { |
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
516
diff
changeset
|
1173 |
lm_connection_unregister_message_handler (sasl->connection, |
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
516
diff
changeset
|
1174 |
sasl->failure_cb, |
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
516
diff
changeset
|
1175 |
LM_MESSAGE_TYPE_FAILURE); |
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
516
diff
changeset
|
1176 |
} |
227
b8fa5635fb30
Conform with Loudmouth coding style
Mikael Hallendal <micke@imendio.com>
parents:
225
diff
changeset
|
1177 |
|
518
cdd6a0c5b439
Went over all of the files and made sure they all were indented the same way.
Mikael Hallendal <micke@imendio.com>
parents:
516
diff
changeset
|
1178 |
g_free (sasl); |
227
b8fa5635fb30
Conform with Loudmouth coding style
Mikael Hallendal <micke@imendio.com>
parents:
225
diff
changeset
|
1179 |
} |
b8fa5635fb30
Conform with Loudmouth coding style
Mikael Hallendal <micke@imendio.com>
parents:
225
diff
changeset
|
1180 |
|
b8fa5635fb30
Conform with Loudmouth coding style
Mikael Hallendal <micke@imendio.com>
parents:
225
diff
changeset
|
1181 |
|
540
72acfccdec86
Switch to use LmAuthParameters instead of passing around username and password.
Mikael Hallendal <micke@imendio.com>
parents:
518
diff
changeset
|
1182 |
LmAuthParameters * |
72acfccdec86
Switch to use LmAuthParameters instead of passing around username and password.
Mikael Hallendal <micke@imendio.com>
parents:
518
diff
changeset
|
1183 |
lm_sasl_get_auth_params (LmSASL *sasl) |
332
6b6ad42cd508
Support obsolete XEP-0078 (old-style jabber auth for XMPP1.0).
Senko Rasic <senko@phyrexia.lan>
parents:
321
diff
changeset
|
1184 |
{ |
540
72acfccdec86
Switch to use LmAuthParameters instead of passing around username and password.
Mikael Hallendal <micke@imendio.com>
parents:
518
diff
changeset
|
1185 |
return sasl->auth_params; |
332
6b6ad42cd508
Support obsolete XEP-0078 (old-style jabber auth for XMPP1.0).
Senko Rasic <senko@phyrexia.lan>
parents:
321
diff
changeset
|
1186 |
} |
6b6ad42cd508
Support obsolete XEP-0078 (old-style jabber auth for XMPP1.0).
Senko Rasic <senko@phyrexia.lan>
parents:
321
diff
changeset
|
1187 |