annotate src/lib-sasl/mech-external.c @ 22656:1789bf2a1e01

director: Make sure HOST-RESET-USERS isn't used with max_moving_users=0 The reset command would just hang in that case. doveadm would never have sent this, so this is just an extra sanity check.
author Timo Sirainen <timo.sirainen@dovecot.fi>
date Sun, 05 Nov 2017 23:51:56 +0200
parents 2e2563132d5f
children cb108f786fb4
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
21390
2e2563132d5f Updated copyright notices to include the year 2017.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents: 19703
diff changeset
1 /* Copyright (c) 2016-2017 Dovecot authors, see the included COPYING file */
19701
72f2a1b6f6ae lib-sasl: Added support for EXTERNAL SASL mechanism
Timo Sirainen <timo.sirainen@dovecot.fi>
parents:
diff changeset
2
72f2a1b6f6ae lib-sasl: Added support for EXTERNAL SASL mechanism
Timo Sirainen <timo.sirainen@dovecot.fi>
parents:
diff changeset
3 #include "lib.h"
72f2a1b6f6ae lib-sasl: Added support for EXTERNAL SASL mechanism
Timo Sirainen <timo.sirainen@dovecot.fi>
parents:
diff changeset
4 #include "dsasl-client-private.h"
72f2a1b6f6ae lib-sasl: Added support for EXTERNAL SASL mechanism
Timo Sirainen <timo.sirainen@dovecot.fi>
parents:
diff changeset
5
72f2a1b6f6ae lib-sasl: Added support for EXTERNAL SASL mechanism
Timo Sirainen <timo.sirainen@dovecot.fi>
parents:
diff changeset
6 struct external_dsasl_client {
72f2a1b6f6ae lib-sasl: Added support for EXTERNAL SASL mechanism
Timo Sirainen <timo.sirainen@dovecot.fi>
parents:
diff changeset
7 struct dsasl_client client;
72f2a1b6f6ae lib-sasl: Added support for EXTERNAL SASL mechanism
Timo Sirainen <timo.sirainen@dovecot.fi>
parents:
diff changeset
8 bool output_sent;
72f2a1b6f6ae lib-sasl: Added support for EXTERNAL SASL mechanism
Timo Sirainen <timo.sirainen@dovecot.fi>
parents:
diff changeset
9 };
72f2a1b6f6ae lib-sasl: Added support for EXTERNAL SASL mechanism
Timo Sirainen <timo.sirainen@dovecot.fi>
parents:
diff changeset
10
72f2a1b6f6ae lib-sasl: Added support for EXTERNAL SASL mechanism
Timo Sirainen <timo.sirainen@dovecot.fi>
parents:
diff changeset
11 static int
72f2a1b6f6ae lib-sasl: Added support for EXTERNAL SASL mechanism
Timo Sirainen <timo.sirainen@dovecot.fi>
parents:
diff changeset
12 mech_external_input(struct dsasl_client *_client,
72f2a1b6f6ae lib-sasl: Added support for EXTERNAL SASL mechanism
Timo Sirainen <timo.sirainen@dovecot.fi>
parents:
diff changeset
13 const unsigned char *input ATTR_UNUSED, unsigned int input_len,
72f2a1b6f6ae lib-sasl: Added support for EXTERNAL SASL mechanism
Timo Sirainen <timo.sirainen@dovecot.fi>
parents:
diff changeset
14 const char **error_r)
72f2a1b6f6ae lib-sasl: Added support for EXTERNAL SASL mechanism
Timo Sirainen <timo.sirainen@dovecot.fi>
parents:
diff changeset
15 {
72f2a1b6f6ae lib-sasl: Added support for EXTERNAL SASL mechanism
Timo Sirainen <timo.sirainen@dovecot.fi>
parents:
diff changeset
16 struct external_dsasl_client *client =
72f2a1b6f6ae lib-sasl: Added support for EXTERNAL SASL mechanism
Timo Sirainen <timo.sirainen@dovecot.fi>
parents:
diff changeset
17 (struct external_dsasl_client *)_client;
72f2a1b6f6ae lib-sasl: Added support for EXTERNAL SASL mechanism
Timo Sirainen <timo.sirainen@dovecot.fi>
parents:
diff changeset
18
72f2a1b6f6ae lib-sasl: Added support for EXTERNAL SASL mechanism
Timo Sirainen <timo.sirainen@dovecot.fi>
parents:
diff changeset
19 if (!client->output_sent) {
72f2a1b6f6ae lib-sasl: Added support for EXTERNAL SASL mechanism
Timo Sirainen <timo.sirainen@dovecot.fi>
parents:
diff changeset
20 if (input_len > 0) {
72f2a1b6f6ae lib-sasl: Added support for EXTERNAL SASL mechanism
Timo Sirainen <timo.sirainen@dovecot.fi>
parents:
diff changeset
21 *error_r = "Server sent non-empty initial response";
72f2a1b6f6ae lib-sasl: Added support for EXTERNAL SASL mechanism
Timo Sirainen <timo.sirainen@dovecot.fi>
parents:
diff changeset
22 return -1;
72f2a1b6f6ae lib-sasl: Added support for EXTERNAL SASL mechanism
Timo Sirainen <timo.sirainen@dovecot.fi>
parents:
diff changeset
23 }
72f2a1b6f6ae lib-sasl: Added support for EXTERNAL SASL mechanism
Timo Sirainen <timo.sirainen@dovecot.fi>
parents:
diff changeset
24 } else {
72f2a1b6f6ae lib-sasl: Added support for EXTERNAL SASL mechanism
Timo Sirainen <timo.sirainen@dovecot.fi>
parents:
diff changeset
25 *error_r = "Server didn't finish authentication";
72f2a1b6f6ae lib-sasl: Added support for EXTERNAL SASL mechanism
Timo Sirainen <timo.sirainen@dovecot.fi>
parents:
diff changeset
26 return -1;
72f2a1b6f6ae lib-sasl: Added support for EXTERNAL SASL mechanism
Timo Sirainen <timo.sirainen@dovecot.fi>
parents:
diff changeset
27 }
72f2a1b6f6ae lib-sasl: Added support for EXTERNAL SASL mechanism
Timo Sirainen <timo.sirainen@dovecot.fi>
parents:
diff changeset
28 return 0;
72f2a1b6f6ae lib-sasl: Added support for EXTERNAL SASL mechanism
Timo Sirainen <timo.sirainen@dovecot.fi>
parents:
diff changeset
29 }
72f2a1b6f6ae lib-sasl: Added support for EXTERNAL SASL mechanism
Timo Sirainen <timo.sirainen@dovecot.fi>
parents:
diff changeset
30
72f2a1b6f6ae lib-sasl: Added support for EXTERNAL SASL mechanism
Timo Sirainen <timo.sirainen@dovecot.fi>
parents:
diff changeset
31 static int
72f2a1b6f6ae lib-sasl: Added support for EXTERNAL SASL mechanism
Timo Sirainen <timo.sirainen@dovecot.fi>
parents:
diff changeset
32 mech_external_output(struct dsasl_client *_client,
72f2a1b6f6ae lib-sasl: Added support for EXTERNAL SASL mechanism
Timo Sirainen <timo.sirainen@dovecot.fi>
parents:
diff changeset
33 const unsigned char **output_r, unsigned int *output_len_r,
19703
508490be0db3 lib-sasl: Compiler warning fix for previous EXTERNAL change..
Timo Sirainen <timo.sirainen@dovecot.fi>
parents: 19702
diff changeset
34 const char **error_r ATTR_UNUSED)
19701
72f2a1b6f6ae lib-sasl: Added support for EXTERNAL SASL mechanism
Timo Sirainen <timo.sirainen@dovecot.fi>
parents:
diff changeset
35 {
72f2a1b6f6ae lib-sasl: Added support for EXTERNAL SASL mechanism
Timo Sirainen <timo.sirainen@dovecot.fi>
parents:
diff changeset
36 struct external_dsasl_client *client =
72f2a1b6f6ae lib-sasl: Added support for EXTERNAL SASL mechanism
Timo Sirainen <timo.sirainen@dovecot.fi>
parents:
diff changeset
37 (struct external_dsasl_client *)_client;
72f2a1b6f6ae lib-sasl: Added support for EXTERNAL SASL mechanism
Timo Sirainen <timo.sirainen@dovecot.fi>
parents:
diff changeset
38 const char *username;
72f2a1b6f6ae lib-sasl: Added support for EXTERNAL SASL mechanism
Timo Sirainen <timo.sirainen@dovecot.fi>
parents:
diff changeset
39
72f2a1b6f6ae lib-sasl: Added support for EXTERNAL SASL mechanism
Timo Sirainen <timo.sirainen@dovecot.fi>
parents:
diff changeset
40 if (_client->set.authzid != NULL)
72f2a1b6f6ae lib-sasl: Added support for EXTERNAL SASL mechanism
Timo Sirainen <timo.sirainen@dovecot.fi>
parents:
diff changeset
41 username = _client->set.authzid;
72f2a1b6f6ae lib-sasl: Added support for EXTERNAL SASL mechanism
Timo Sirainen <timo.sirainen@dovecot.fi>
parents:
diff changeset
42 else if (_client->set.authid != NULL)
72f2a1b6f6ae lib-sasl: Added support for EXTERNAL SASL mechanism
Timo Sirainen <timo.sirainen@dovecot.fi>
parents:
diff changeset
43 username = _client->set.authid;
72f2a1b6f6ae lib-sasl: Added support for EXTERNAL SASL mechanism
Timo Sirainen <timo.sirainen@dovecot.fi>
parents:
diff changeset
44 else
72f2a1b6f6ae lib-sasl: Added support for EXTERNAL SASL mechanism
Timo Sirainen <timo.sirainen@dovecot.fi>
parents:
diff changeset
45 username = "";
72f2a1b6f6ae lib-sasl: Added support for EXTERNAL SASL mechanism
Timo Sirainen <timo.sirainen@dovecot.fi>
parents:
diff changeset
46
72f2a1b6f6ae lib-sasl: Added support for EXTERNAL SASL mechanism
Timo Sirainen <timo.sirainen@dovecot.fi>
parents:
diff changeset
47 *output_r = (const void *)username;
72f2a1b6f6ae lib-sasl: Added support for EXTERNAL SASL mechanism
Timo Sirainen <timo.sirainen@dovecot.fi>
parents:
diff changeset
48 *output_len_r = strlen(username);
72f2a1b6f6ae lib-sasl: Added support for EXTERNAL SASL mechanism
Timo Sirainen <timo.sirainen@dovecot.fi>
parents:
diff changeset
49 client->output_sent = TRUE;
72f2a1b6f6ae lib-sasl: Added support for EXTERNAL SASL mechanism
Timo Sirainen <timo.sirainen@dovecot.fi>
parents:
diff changeset
50 return 0;
72f2a1b6f6ae lib-sasl: Added support for EXTERNAL SASL mechanism
Timo Sirainen <timo.sirainen@dovecot.fi>
parents:
diff changeset
51 }
72f2a1b6f6ae lib-sasl: Added support for EXTERNAL SASL mechanism
Timo Sirainen <timo.sirainen@dovecot.fi>
parents:
diff changeset
52
72f2a1b6f6ae lib-sasl: Added support for EXTERNAL SASL mechanism
Timo Sirainen <timo.sirainen@dovecot.fi>
parents:
diff changeset
53 const struct dsasl_client_mech dsasl_client_mech_external = {
72f2a1b6f6ae lib-sasl: Added support for EXTERNAL SASL mechanism
Timo Sirainen <timo.sirainen@dovecot.fi>
parents:
diff changeset
54 .name = "EXTERNAL",
72f2a1b6f6ae lib-sasl: Added support for EXTERNAL SASL mechanism
Timo Sirainen <timo.sirainen@dovecot.fi>
parents:
diff changeset
55 .struct_size = sizeof(struct external_dsasl_client),
72f2a1b6f6ae lib-sasl: Added support for EXTERNAL SASL mechanism
Timo Sirainen <timo.sirainen@dovecot.fi>
parents:
diff changeset
56
72f2a1b6f6ae lib-sasl: Added support for EXTERNAL SASL mechanism
Timo Sirainen <timo.sirainen@dovecot.fi>
parents:
diff changeset
57 .input = mech_external_input,
72f2a1b6f6ae lib-sasl: Added support for EXTERNAL SASL mechanism
Timo Sirainen <timo.sirainen@dovecot.fi>
parents:
diff changeset
58 .output = mech_external_output
72f2a1b6f6ae lib-sasl: Added support for EXTERNAL SASL mechanism
Timo Sirainen <timo.sirainen@dovecot.fi>
parents:
diff changeset
59 };