Mercurial > dovecot > original-hg > dovecot-1.2
annotate src/auth/auth-worker-client.c @ 9008:fc4f65a4ca60 HEAD
virtual: Don't show mailboxes as \Noselect.
author | Timo Sirainen <tss@iki.fi> |
---|---|
date | Fri, 01 May 2009 14:56:52 -0400 |
parents | d69763bee853 |
children | 00cd9aacd03c |
rev | line source |
---|---|
8590
b9faf4db2a9f
Updated copyright notices to include year 2009.
Timo Sirainen <tss@iki.fi>
parents:
8560
diff
changeset
|
1 /* Copyright (c) 2005-2009 Dovecot authors, see the included COPYING file */ |
3168
62f8366cb89c
Forgot to add for blocking passdb/userdb workers..
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
2 |
62f8366cb89c
Forgot to add for blocking passdb/userdb workers..
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
3 #include "common.h" |
5598
971050640e3b
All password schemes can now be encoded with base64 or hex. The encoding is
Timo Sirainen <tss@iki.fi>
parents:
5593
diff
changeset
|
4 #include "base64.h" |
3168
62f8366cb89c
Forgot to add for blocking passdb/userdb workers..
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
5 #include "ioloop.h" |
62f8366cb89c
Forgot to add for blocking passdb/userdb workers..
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
6 #include "network.h" |
62f8366cb89c
Forgot to add for blocking passdb/userdb workers..
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
7 #include "istream.h" |
62f8366cb89c
Forgot to add for blocking passdb/userdb workers..
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
8 #include "ostream.h" |
62f8366cb89c
Forgot to add for blocking passdb/userdb workers..
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
9 #include "str.h" |
62f8366cb89c
Forgot to add for blocking passdb/userdb workers..
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
10 #include "auth-request.h" |
62f8366cb89c
Forgot to add for blocking passdb/userdb workers..
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
11 #include "auth-worker-client.h" |
62f8366cb89c
Forgot to add for blocking passdb/userdb workers..
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
12 |
62f8366cb89c
Forgot to add for blocking passdb/userdb workers..
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
13 #include <stdlib.h> |
62f8366cb89c
Forgot to add for blocking passdb/userdb workers..
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
14 |
62f8366cb89c
Forgot to add for blocking passdb/userdb workers..
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
15 #define OUTBUF_THROTTLE_SIZE (1024*10) |
62f8366cb89c
Forgot to add for blocking passdb/userdb workers..
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
16 |
62f8366cb89c
Forgot to add for blocking passdb/userdb workers..
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
17 struct auth_worker_client { |
62f8366cb89c
Forgot to add for blocking passdb/userdb workers..
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
18 int refcount; |
62f8366cb89c
Forgot to add for blocking passdb/userdb workers..
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
19 |
62f8366cb89c
Forgot to add for blocking passdb/userdb workers..
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
20 struct auth *auth; |
62f8366cb89c
Forgot to add for blocking passdb/userdb workers..
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
21 int fd; |
62f8366cb89c
Forgot to add for blocking passdb/userdb workers..
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
22 struct io *io; |
62f8366cb89c
Forgot to add for blocking passdb/userdb workers..
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
23 struct istream *input; |
62f8366cb89c
Forgot to add for blocking passdb/userdb workers..
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
24 struct ostream *output; |
62f8366cb89c
Forgot to add for blocking passdb/userdb workers..
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
25 }; |
62f8366cb89c
Forgot to add for blocking passdb/userdb workers..
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
26 |
62f8366cb89c
Forgot to add for blocking passdb/userdb workers..
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
27 static void |
62f8366cb89c
Forgot to add for blocking passdb/userdb workers..
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
28 auth_worker_client_check_throttle(struct auth_worker_client *client) |
62f8366cb89c
Forgot to add for blocking passdb/userdb workers..
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
29 { |
62f8366cb89c
Forgot to add for blocking passdb/userdb workers..
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
30 if (o_stream_get_buffer_used_size(client->output) >= |
62f8366cb89c
Forgot to add for blocking passdb/userdb workers..
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
31 OUTBUF_THROTTLE_SIZE) { |
62f8366cb89c
Forgot to add for blocking passdb/userdb workers..
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
32 /* stop reading new requests until client has read the pending |
62f8366cb89c
Forgot to add for blocking passdb/userdb workers..
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
33 replies. */ |
3879
928229f8b3e6
deinit, unref, destroy, close, free, etc. functions now take a pointer to
Timo Sirainen <tss@iki.fi>
parents:
3863
diff
changeset
|
34 if (client->io != NULL) |
928229f8b3e6
deinit, unref, destroy, close, free, etc. functions now take a pointer to
Timo Sirainen <tss@iki.fi>
parents:
3863
diff
changeset
|
35 io_remove(&client->io); |
3168
62f8366cb89c
Forgot to add for blocking passdb/userdb workers..
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
36 } |
62f8366cb89c
Forgot to add for blocking passdb/userdb workers..
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
37 } |
62f8366cb89c
Forgot to add for blocking passdb/userdb workers..
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
38 |
62f8366cb89c
Forgot to add for blocking passdb/userdb workers..
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
39 static struct auth_request * |
62f8366cb89c
Forgot to add for blocking passdb/userdb workers..
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
40 worker_auth_request_new(struct auth_worker_client *client, unsigned int id, |
62f8366cb89c
Forgot to add for blocking passdb/userdb workers..
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
41 const char *args) |
62f8366cb89c
Forgot to add for blocking passdb/userdb workers..
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
42 { |
62f8366cb89c
Forgot to add for blocking passdb/userdb workers..
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
43 struct auth_request *auth_request; |
62f8366cb89c
Forgot to add for blocking passdb/userdb workers..
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
44 const char *key, *value, *const *tmp; |
62f8366cb89c
Forgot to add for blocking passdb/userdb workers..
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
45 |
3185
3089083e1d47
Handle USER requests from master connections.
Timo Sirainen <tss@iki.fi>
parents:
3184
diff
changeset
|
46 auth_request = auth_request_new_dummy(client->auth); |
3168
62f8366cb89c
Forgot to add for blocking passdb/userdb workers..
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
47 |
62f8366cb89c
Forgot to add for blocking passdb/userdb workers..
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
48 client->refcount++; |
62f8366cb89c
Forgot to add for blocking passdb/userdb workers..
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
49 auth_request->context = client; |
62f8366cb89c
Forgot to add for blocking passdb/userdb workers..
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
50 auth_request->id = id; |
62f8366cb89c
Forgot to add for blocking passdb/userdb workers..
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
51 |
4185
8cc6595a9b43
Don't crash if no extra arguments were given to auth worker request.
Timo Sirainen <tss@iki.fi>
parents:
4040
diff
changeset
|
52 if (args != NULL) { |
8cc6595a9b43
Don't crash if no extra arguments were given to auth worker request.
Timo Sirainen <tss@iki.fi>
parents:
4040
diff
changeset
|
53 for (tmp = t_strsplit(args, "\t"); *tmp != NULL; tmp++) { |
8cc6595a9b43
Don't crash if no extra arguments were given to auth worker request.
Timo Sirainen <tss@iki.fi>
parents:
4040
diff
changeset
|
54 value = strchr(*tmp, '='); |
8cc6595a9b43
Don't crash if no extra arguments were given to auth worker request.
Timo Sirainen <tss@iki.fi>
parents:
4040
diff
changeset
|
55 if (value == NULL) |
8cc6595a9b43
Don't crash if no extra arguments were given to auth worker request.
Timo Sirainen <tss@iki.fi>
parents:
4040
diff
changeset
|
56 continue; |
3168
62f8366cb89c
Forgot to add for blocking passdb/userdb workers..
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
57 |
4185
8cc6595a9b43
Don't crash if no extra arguments were given to auth worker request.
Timo Sirainen <tss@iki.fi>
parents:
4040
diff
changeset
|
58 key = t_strdup_until(*tmp, value); |
8cc6595a9b43
Don't crash if no extra arguments were given to auth worker request.
Timo Sirainen <tss@iki.fi>
parents:
4040
diff
changeset
|
59 value++; |
3168
62f8366cb89c
Forgot to add for blocking passdb/userdb workers..
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
60 |
4185
8cc6595a9b43
Don't crash if no extra arguments were given to auth worker request.
Timo Sirainen <tss@iki.fi>
parents:
4040
diff
changeset
|
61 (void)auth_request_import(auth_request, key, value); |
8cc6595a9b43
Don't crash if no extra arguments were given to auth worker request.
Timo Sirainen <tss@iki.fi>
parents:
4040
diff
changeset
|
62 } |
3168
62f8366cb89c
Forgot to add for blocking passdb/userdb workers..
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
63 } |
62f8366cb89c
Forgot to add for blocking passdb/userdb workers..
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
64 |
62f8366cb89c
Forgot to add for blocking passdb/userdb workers..
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
65 return auth_request; |
62f8366cb89c
Forgot to add for blocking passdb/userdb workers..
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
66 } |
62f8366cb89c
Forgot to add for blocking passdb/userdb workers..
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
67 |
8560
b6a7bc10c19a
Replaced auth_worker_max_request_count setting with passdb pam { args = max_requests=n }
Timo Sirainen <tss@iki.fi>
parents:
8311
diff
changeset
|
68 static void auth_worker_send_reply(struct auth_worker_client *client, |
b6a7bc10c19a
Replaced auth_worker_max_request_count setting with passdb pam { args = max_requests=n }
Timo Sirainen <tss@iki.fi>
parents:
8311
diff
changeset
|
69 string_t *str) |
b6a7bc10c19a
Replaced auth_worker_max_request_count setting with passdb pam { args = max_requests=n }
Timo Sirainen <tss@iki.fi>
parents:
8311
diff
changeset
|
70 { |
b6a7bc10c19a
Replaced auth_worker_max_request_count setting with passdb pam { args = max_requests=n }
Timo Sirainen <tss@iki.fi>
parents:
8311
diff
changeset
|
71 if (shutdown_request) |
b6a7bc10c19a
Replaced auth_worker_max_request_count setting with passdb pam { args = max_requests=n }
Timo Sirainen <tss@iki.fi>
parents:
8311
diff
changeset
|
72 o_stream_send_str(client->output, "SHUTDOWN\n"); |
b6a7bc10c19a
Replaced auth_worker_max_request_count setting with passdb pam { args = max_requests=n }
Timo Sirainen <tss@iki.fi>
parents:
8311
diff
changeset
|
73 o_stream_send(client->output, str_data(str), str_len(str)); |
b6a7bc10c19a
Replaced auth_worker_max_request_count setting with passdb pam { args = max_requests=n }
Timo Sirainen <tss@iki.fi>
parents:
8311
diff
changeset
|
74 } |
b6a7bc10c19a
Replaced auth_worker_max_request_count setting with passdb pam { args = max_requests=n }
Timo Sirainen <tss@iki.fi>
parents:
8311
diff
changeset
|
75 |
3168
62f8366cb89c
Forgot to add for blocking passdb/userdb workers..
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
76 static void verify_plain_callback(enum passdb_result result, |
62f8366cb89c
Forgot to add for blocking passdb/userdb workers..
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
77 struct auth_request *request) |
62f8366cb89c
Forgot to add for blocking passdb/userdb workers..
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
78 { |
62f8366cb89c
Forgot to add for blocking passdb/userdb workers..
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
79 struct auth_worker_client *client = request->context; |
7388
08d31d752893
Use auth-stream API to build all TAB-delimited strings to make sure strings
Timo Sirainen <tss@iki.fi>
parents:
7276
diff
changeset
|
80 struct auth_stream_reply *reply; |
3168
62f8366cb89c
Forgot to add for blocking passdb/userdb workers..
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
81 string_t *str; |
62f8366cb89c
Forgot to add for blocking passdb/userdb workers..
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
82 |
4704
3bfd724bb37a
Fixes to handling blocking passdb (ie. MySQL) failures. It ignored any
Timo Sirainen <tss@iki.fi>
parents:
4255
diff
changeset
|
83 if (request->passdb_failure && result == PASSDB_RESULT_OK) |
3bfd724bb37a
Fixes to handling blocking passdb (ie. MySQL) failures. It ignored any
Timo Sirainen <tss@iki.fi>
parents:
4255
diff
changeset
|
84 result = PASSDB_RESULT_PASSWORD_MISMATCH; |
3bfd724bb37a
Fixes to handling blocking passdb (ie. MySQL) failures. It ignored any
Timo Sirainen <tss@iki.fi>
parents:
4255
diff
changeset
|
85 |
7388
08d31d752893
Use auth-stream API to build all TAB-delimited strings to make sure strings
Timo Sirainen <tss@iki.fi>
parents:
7276
diff
changeset
|
86 reply = auth_stream_reply_init(pool_datastack_create()); |
08d31d752893
Use auth-stream API to build all TAB-delimited strings to make sure strings
Timo Sirainen <tss@iki.fi>
parents:
7276
diff
changeset
|
87 auth_stream_reply_add(reply, NULL, dec2str(request->id)); |
3168
62f8366cb89c
Forgot to add for blocking passdb/userdb workers..
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
88 |
7388
08d31d752893
Use auth-stream API to build all TAB-delimited strings to make sure strings
Timo Sirainen <tss@iki.fi>
parents:
7276
diff
changeset
|
89 if (result == PASSDB_RESULT_OK) |
08d31d752893
Use auth-stream API to build all TAB-delimited strings to make sure strings
Timo Sirainen <tss@iki.fi>
parents:
7276
diff
changeset
|
90 auth_stream_reply_add(reply, "OK", NULL); |
6436
fd7ffed49763
Transfer also userdb information from blocking passdb workers, so prefetch
Timo Sirainen <tss@iki.fi>
parents:
6429
diff
changeset
|
91 else { |
7388
08d31d752893
Use auth-stream API to build all TAB-delimited strings to make sure strings
Timo Sirainen <tss@iki.fi>
parents:
7276
diff
changeset
|
92 auth_stream_reply_add(reply, "FAIL", NULL); |
08d31d752893
Use auth-stream API to build all TAB-delimited strings to make sure strings
Timo Sirainen <tss@iki.fi>
parents:
7276
diff
changeset
|
93 auth_stream_reply_add(reply, NULL, |
08d31d752893
Use auth-stream API to build all TAB-delimited strings to make sure strings
Timo Sirainen <tss@iki.fi>
parents:
7276
diff
changeset
|
94 t_strdup_printf("%d", result)); |
08d31d752893
Use auth-stream API to build all TAB-delimited strings to make sure strings
Timo Sirainen <tss@iki.fi>
parents:
7276
diff
changeset
|
95 } |
08d31d752893
Use auth-stream API to build all TAB-delimited strings to make sure strings
Timo Sirainen <tss@iki.fi>
parents:
7276
diff
changeset
|
96 if (result != PASSDB_RESULT_INTERNAL_FAILURE) { |
08d31d752893
Use auth-stream API to build all TAB-delimited strings to make sure strings
Timo Sirainen <tss@iki.fi>
parents:
7276
diff
changeset
|
97 auth_stream_reply_add(reply, NULL, request->user); |
08d31d752893
Use auth-stream API to build all TAB-delimited strings to make sure strings
Timo Sirainen <tss@iki.fi>
parents:
7276
diff
changeset
|
98 auth_stream_reply_add(reply, NULL, |
08d31d752893
Use auth-stream API to build all TAB-delimited strings to make sure strings
Timo Sirainen <tss@iki.fi>
parents:
7276
diff
changeset
|
99 request->passdb_password == NULL ? "" : |
08d31d752893
Use auth-stream API to build all TAB-delimited strings to make sure strings
Timo Sirainen <tss@iki.fi>
parents:
7276
diff
changeset
|
100 request->passdb_password); |
6436
fd7ffed49763
Transfer also userdb information from blocking passdb workers, so prefetch
Timo Sirainen <tss@iki.fi>
parents:
6429
diff
changeset
|
101 if (request->extra_fields != NULL) { |
7388
08d31d752893
Use auth-stream API to build all TAB-delimited strings to make sure strings
Timo Sirainen <tss@iki.fi>
parents:
7276
diff
changeset
|
102 const char *fields = |
6436
fd7ffed49763
Transfer also userdb information from blocking passdb workers, so prefetch
Timo Sirainen <tss@iki.fi>
parents:
6429
diff
changeset
|
103 auth_stream_reply_export(request->extra_fields); |
7388
08d31d752893
Use auth-stream API to build all TAB-delimited strings to make sure strings
Timo Sirainen <tss@iki.fi>
parents:
7276
diff
changeset
|
104 auth_stream_reply_import(reply, fields); |
6436
fd7ffed49763
Transfer also userdb information from blocking passdb workers, so prefetch
Timo Sirainen <tss@iki.fi>
parents:
6429
diff
changeset
|
105 } |
8598
2778cd717f22
auth cache wasn't working correctly for all fields (e.g. allow_nets) with blocking passdbs.
Timo Sirainen <tss@iki.fi>
parents:
8590
diff
changeset
|
106 if (request->extra_cache_fields != NULL) { |
2778cd717f22
auth cache wasn't working correctly for all fields (e.g. allow_nets) with blocking passdbs.
Timo Sirainen <tss@iki.fi>
parents:
8590
diff
changeset
|
107 const char *fields = |
2778cd717f22
auth cache wasn't working correctly for all fields (e.g. allow_nets) with blocking passdbs.
Timo Sirainen <tss@iki.fi>
parents:
8590
diff
changeset
|
108 auth_stream_reply_export(request->extra_cache_fields); |
2778cd717f22
auth cache wasn't working correctly for all fields (e.g. allow_nets) with blocking passdbs.
Timo Sirainen <tss@iki.fi>
parents:
8590
diff
changeset
|
109 auth_stream_reply_import(reply, fields); |
2778cd717f22
auth cache wasn't working correctly for all fields (e.g. allow_nets) with blocking passdbs.
Timo Sirainen <tss@iki.fi>
parents:
8590
diff
changeset
|
110 } |
6214
974066ba68a3
Pass extra_fields from auth worker to server also if authentication failed.
Timo Sirainen <tss@iki.fi>
parents:
6213
diff
changeset
|
111 } |
7388
08d31d752893
Use auth-stream API to build all TAB-delimited strings to make sure strings
Timo Sirainen <tss@iki.fi>
parents:
7276
diff
changeset
|
112 str = auth_stream_reply_get_str(reply); |
3168
62f8366cb89c
Forgot to add for blocking passdb/userdb workers..
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
113 str_append_c(str, '\n'); |
8560
b6a7bc10c19a
Replaced auth_worker_max_request_count setting with passdb pam { args = max_requests=n }
Timo Sirainen <tss@iki.fi>
parents:
8311
diff
changeset
|
114 auth_worker_send_reply(client, str); |
3168
62f8366cb89c
Forgot to add for blocking passdb/userdb workers..
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
115 |
3879
928229f8b3e6
deinit, unref, destroy, close, free, etc. functions now take a pointer to
Timo Sirainen <tss@iki.fi>
parents:
3863
diff
changeset
|
116 auth_request_unref(&request); |
3414
c2497d4c60c9
Auth workers were leaking memory for each request. Fixed also a few invalid
Timo Sirainen <tss@iki.fi>
parents:
3398
diff
changeset
|
117 auth_worker_client_check_throttle(client); |
3879
928229f8b3e6
deinit, unref, destroy, close, free, etc. functions now take a pointer to
Timo Sirainen <tss@iki.fi>
parents:
3863
diff
changeset
|
118 auth_worker_client_unref(&client); |
3168
62f8366cb89c
Forgot to add for blocking passdb/userdb workers..
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
119 } |
62f8366cb89c
Forgot to add for blocking passdb/userdb workers..
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
120 |
62f8366cb89c
Forgot to add for blocking passdb/userdb workers..
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
121 static void |
62f8366cb89c
Forgot to add for blocking passdb/userdb workers..
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
122 auth_worker_handle_passv(struct auth_worker_client *client, |
62f8366cb89c
Forgot to add for blocking passdb/userdb workers..
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
123 unsigned int id, const char *args) |
62f8366cb89c
Forgot to add for blocking passdb/userdb workers..
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
124 { |
62f8366cb89c
Forgot to add for blocking passdb/userdb workers..
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
125 /* verify plaintext password */ |
62f8366cb89c
Forgot to add for blocking passdb/userdb workers..
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
126 struct auth_request *auth_request; |
5146
7cf93253317d
Blocking passdbs didn't work as masterdbs.
Timo Sirainen <tss@iki.fi>
parents:
4914
diff
changeset
|
127 struct auth_passdb *passdb; |
3168
62f8366cb89c
Forgot to add for blocking passdb/userdb workers..
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
128 const char *password; |
4030
faf83f3e19b5
Added support for "master users" who can log in as other people. Currently works only with SASL PLAIN authentication by giving it authorization ID string.
Timo Sirainen <timo.sirainen@movial.fi>
parents:
3879
diff
changeset
|
129 unsigned int passdb_id; |
3183
16ea551957ed
Replaced userdb/passdb settings with blocks so it's possible to give
Timo Sirainen <tss@iki.fi>
parents:
3168
diff
changeset
|
130 |
4030
faf83f3e19b5
Added support for "master users" who can log in as other people. Currently works only with SASL PLAIN authentication by giving it authorization ID string.
Timo Sirainen <timo.sirainen@movial.fi>
parents:
3879
diff
changeset
|
131 passdb_id = atoi(t_strcut(args, '\t')); |
3183
16ea551957ed
Replaced userdb/passdb settings with blocks so it's possible to give
Timo Sirainen <tss@iki.fi>
parents:
3168
diff
changeset
|
132 args = strchr(args, '\t'); |
16ea551957ed
Replaced userdb/passdb settings with blocks so it's possible to give
Timo Sirainen <tss@iki.fi>
parents:
3168
diff
changeset
|
133 if (args == NULL) { |
16ea551957ed
Replaced userdb/passdb settings with blocks so it's possible to give
Timo Sirainen <tss@iki.fi>
parents:
3168
diff
changeset
|
134 i_error("BUG: Auth worker server sent us invalid PASSV"); |
16ea551957ed
Replaced userdb/passdb settings with blocks so it's possible to give
Timo Sirainen <tss@iki.fi>
parents:
3168
diff
changeset
|
135 return; |
16ea551957ed
Replaced userdb/passdb settings with blocks so it's possible to give
Timo Sirainen <tss@iki.fi>
parents:
3168
diff
changeset
|
136 } |
16ea551957ed
Replaced userdb/passdb settings with blocks so it's possible to give
Timo Sirainen <tss@iki.fi>
parents:
3168
diff
changeset
|
137 args++; |
3168
62f8366cb89c
Forgot to add for blocking passdb/userdb workers..
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
138 |
62f8366cb89c
Forgot to add for blocking passdb/userdb workers..
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
139 password = t_strcut(args, '\t'); |
62f8366cb89c
Forgot to add for blocking passdb/userdb workers..
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
140 args = strchr(args, '\t'); |
62f8366cb89c
Forgot to add for blocking passdb/userdb workers..
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
141 if (args != NULL) args++; |
62f8366cb89c
Forgot to add for blocking passdb/userdb workers..
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
142 |
62f8366cb89c
Forgot to add for blocking passdb/userdb workers..
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
143 auth_request = worker_auth_request_new(client, id, args); |
62f8366cb89c
Forgot to add for blocking passdb/userdb workers..
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
144 auth_request->mech_password = |
62f8366cb89c
Forgot to add for blocking passdb/userdb workers..
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
145 p_strdup(auth_request->pool, password); |
62f8366cb89c
Forgot to add for blocking passdb/userdb workers..
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
146 |
3338
e5ce49c8524a
USER auth command requires now service parameter and supports also others
Timo Sirainen <tss@iki.fi>
parents:
3311
diff
changeset
|
147 if (auth_request->user == NULL || auth_request->service == NULL) { |
e5ce49c8524a
USER auth command requires now service parameter and supports also others
Timo Sirainen <tss@iki.fi>
parents:
3311
diff
changeset
|
148 i_error("BUG: PASSV had missing parameters"); |
3879
928229f8b3e6
deinit, unref, destroy, close, free, etc. functions now take a pointer to
Timo Sirainen <tss@iki.fi>
parents:
3863
diff
changeset
|
149 auth_request_unref(&auth_request); |
3338
e5ce49c8524a
USER auth command requires now service parameter and supports also others
Timo Sirainen <tss@iki.fi>
parents:
3311
diff
changeset
|
150 return; |
e5ce49c8524a
USER auth command requires now service parameter and supports also others
Timo Sirainen <tss@iki.fi>
parents:
3311
diff
changeset
|
151 } |
e5ce49c8524a
USER auth command requires now service parameter and supports also others
Timo Sirainen <tss@iki.fi>
parents:
3311
diff
changeset
|
152 |
5146
7cf93253317d
Blocking passdbs didn't work as masterdbs.
Timo Sirainen <tss@iki.fi>
parents:
4914
diff
changeset
|
153 passdb = auth_request->passdb; |
7cf93253317d
Blocking passdbs didn't work as masterdbs.
Timo Sirainen <tss@iki.fi>
parents:
4914
diff
changeset
|
154 while (passdb != NULL && passdb->id != passdb_id) |
7cf93253317d
Blocking passdbs didn't work as masterdbs.
Timo Sirainen <tss@iki.fi>
parents:
4914
diff
changeset
|
155 passdb = passdb->next; |
7cf93253317d
Blocking passdbs didn't work as masterdbs.
Timo Sirainen <tss@iki.fi>
parents:
4914
diff
changeset
|
156 |
7cf93253317d
Blocking passdbs didn't work as masterdbs.
Timo Sirainen <tss@iki.fi>
parents:
4914
diff
changeset
|
157 if (passdb == NULL) { |
7cf93253317d
Blocking passdbs didn't work as masterdbs.
Timo Sirainen <tss@iki.fi>
parents:
4914
diff
changeset
|
158 /* could be a masterdb */ |
7cf93253317d
Blocking passdbs didn't work as masterdbs.
Timo Sirainen <tss@iki.fi>
parents:
4914
diff
changeset
|
159 passdb = auth_request->auth->masterdbs; |
7cf93253317d
Blocking passdbs didn't work as masterdbs.
Timo Sirainen <tss@iki.fi>
parents:
4914
diff
changeset
|
160 while (passdb != NULL && passdb->id != passdb_id) |
7cf93253317d
Blocking passdbs didn't work as masterdbs.
Timo Sirainen <tss@iki.fi>
parents:
4914
diff
changeset
|
161 passdb = passdb->next; |
7cf93253317d
Blocking passdbs didn't work as masterdbs.
Timo Sirainen <tss@iki.fi>
parents:
4914
diff
changeset
|
162 |
7cf93253317d
Blocking passdbs didn't work as masterdbs.
Timo Sirainen <tss@iki.fi>
parents:
4914
diff
changeset
|
163 if (passdb == NULL) { |
4030
faf83f3e19b5
Added support for "master users" who can log in as other people. Currently works only with SASL PLAIN authentication by giving it authorization ID string.
Timo Sirainen <timo.sirainen@movial.fi>
parents:
3879
diff
changeset
|
164 i_error("BUG: PASSV had invalid passdb ID"); |
3879
928229f8b3e6
deinit, unref, destroy, close, free, etc. functions now take a pointer to
Timo Sirainen <tss@iki.fi>
parents:
3863
diff
changeset
|
165 auth_request_unref(&auth_request); |
3183
16ea551957ed
Replaced userdb/passdb settings with blocks so it's possible to give
Timo Sirainen <tss@iki.fi>
parents:
3168
diff
changeset
|
166 return; |
16ea551957ed
Replaced userdb/passdb settings with blocks so it's possible to give
Timo Sirainen <tss@iki.fi>
parents:
3168
diff
changeset
|
167 } |
16ea551957ed
Replaced userdb/passdb settings with blocks so it's possible to give
Timo Sirainen <tss@iki.fi>
parents:
3168
diff
changeset
|
168 } |
16ea551957ed
Replaced userdb/passdb settings with blocks so it's possible to give
Timo Sirainen <tss@iki.fi>
parents:
3168
diff
changeset
|
169 |
5146
7cf93253317d
Blocking passdbs didn't work as masterdbs.
Timo Sirainen <tss@iki.fi>
parents:
4914
diff
changeset
|
170 auth_request->passdb = passdb; |
7cf93253317d
Blocking passdbs didn't work as masterdbs.
Timo Sirainen <tss@iki.fi>
parents:
4914
diff
changeset
|
171 passdb->passdb->iface. |
3657
0c10475d9968
Separated passdb_module's interface and the actual data struct. Now it's
Timo Sirainen <tss@iki.fi>
parents:
3655
diff
changeset
|
172 verify_plain(auth_request, password, verify_plain_callback); |
3168
62f8366cb89c
Forgot to add for blocking passdb/userdb workers..
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
173 } |
62f8366cb89c
Forgot to add for blocking passdb/userdb workers..
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
174 |
5475
769aaaee6821
Reverted accidental commit. This code isn't ready yet.
Timo Sirainen <tss@iki.fi>
parents:
5462
diff
changeset
|
175 static void |
5598
971050640e3b
All password schemes can now be encoded with base64 or hex. The encoding is
Timo Sirainen <tss@iki.fi>
parents:
5593
diff
changeset
|
176 lookup_credentials_callback(enum passdb_result result, |
971050640e3b
All password schemes can now be encoded with base64 or hex. The encoding is
Timo Sirainen <tss@iki.fi>
parents:
5593
diff
changeset
|
177 const unsigned char *credentials, size_t size, |
3168
62f8366cb89c
Forgot to add for blocking passdb/userdb workers..
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
178 struct auth_request *request) |
62f8366cb89c
Forgot to add for blocking passdb/userdb workers..
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
179 { |
62f8366cb89c
Forgot to add for blocking passdb/userdb workers..
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
180 struct auth_worker_client *client = request->context; |
7388
08d31d752893
Use auth-stream API to build all TAB-delimited strings to make sure strings
Timo Sirainen <tss@iki.fi>
parents:
7276
diff
changeset
|
181 struct auth_stream_reply *reply; |
3168
62f8366cb89c
Forgot to add for blocking passdb/userdb workers..
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
182 string_t *str; |
62f8366cb89c
Forgot to add for blocking passdb/userdb workers..
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
183 |
4704
3bfd724bb37a
Fixes to handling blocking passdb (ie. MySQL) failures. It ignored any
Timo Sirainen <tss@iki.fi>
parents:
4255
diff
changeset
|
184 if (request->passdb_failure && result == PASSDB_RESULT_OK) |
3bfd724bb37a
Fixes to handling blocking passdb (ie. MySQL) failures. It ignored any
Timo Sirainen <tss@iki.fi>
parents:
4255
diff
changeset
|
185 result = PASSDB_RESULT_PASSWORD_MISMATCH; |
3bfd724bb37a
Fixes to handling blocking passdb (ie. MySQL) failures. It ignored any
Timo Sirainen <tss@iki.fi>
parents:
4255
diff
changeset
|
186 |
7388
08d31d752893
Use auth-stream API to build all TAB-delimited strings to make sure strings
Timo Sirainen <tss@iki.fi>
parents:
7276
diff
changeset
|
187 reply = auth_stream_reply_init(pool_datastack_create()); |
08d31d752893
Use auth-stream API to build all TAB-delimited strings to make sure strings
Timo Sirainen <tss@iki.fi>
parents:
7276
diff
changeset
|
188 auth_stream_reply_add(reply, NULL, dec2str(request->id)); |
3168
62f8366cb89c
Forgot to add for blocking passdb/userdb workers..
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
189 |
7388
08d31d752893
Use auth-stream API to build all TAB-delimited strings to make sure strings
Timo Sirainen <tss@iki.fi>
parents:
7276
diff
changeset
|
190 if (result != PASSDB_RESULT_OK) { |
08d31d752893
Use auth-stream API to build all TAB-delimited strings to make sure strings
Timo Sirainen <tss@iki.fi>
parents:
7276
diff
changeset
|
191 auth_stream_reply_add(reply, "FAIL", NULL); |
08d31d752893
Use auth-stream API to build all TAB-delimited strings to make sure strings
Timo Sirainen <tss@iki.fi>
parents:
7276
diff
changeset
|
192 auth_stream_reply_add(reply, NULL, |
08d31d752893
Use auth-stream API to build all TAB-delimited strings to make sure strings
Timo Sirainen <tss@iki.fi>
parents:
7276
diff
changeset
|
193 t_strdup_printf("%d", result)); |
08d31d752893
Use auth-stream API to build all TAB-delimited strings to make sure strings
Timo Sirainen <tss@iki.fi>
parents:
7276
diff
changeset
|
194 } else { |
08d31d752893
Use auth-stream API to build all TAB-delimited strings to make sure strings
Timo Sirainen <tss@iki.fi>
parents:
7276
diff
changeset
|
195 auth_stream_reply_add(reply, "OK", NULL); |
08d31d752893
Use auth-stream API to build all TAB-delimited strings to make sure strings
Timo Sirainen <tss@iki.fi>
parents:
7276
diff
changeset
|
196 auth_stream_reply_add(reply, NULL, request->user); |
08d31d752893
Use auth-stream API to build all TAB-delimited strings to make sure strings
Timo Sirainen <tss@iki.fi>
parents:
7276
diff
changeset
|
197 |
08d31d752893
Use auth-stream API to build all TAB-delimited strings to make sure strings
Timo Sirainen <tss@iki.fi>
parents:
7276
diff
changeset
|
198 str = t_str_new(64); |
08d31d752893
Use auth-stream API to build all TAB-delimited strings to make sure strings
Timo Sirainen <tss@iki.fi>
parents:
7276
diff
changeset
|
199 str_printfa(str, "{%s.b64}", request->credentials_scheme); |
5598
971050640e3b
All password schemes can now be encoded with base64 or hex. The encoding is
Timo Sirainen <tss@iki.fi>
parents:
5593
diff
changeset
|
200 base64_encode(credentials, size, str); |
7388
08d31d752893
Use auth-stream API to build all TAB-delimited strings to make sure strings
Timo Sirainen <tss@iki.fi>
parents:
7276
diff
changeset
|
201 auth_stream_reply_add(reply, NULL, str_c(str)); |
08d31d752893
Use auth-stream API to build all TAB-delimited strings to make sure strings
Timo Sirainen <tss@iki.fi>
parents:
7276
diff
changeset
|
202 |
3520 | 203 if (request->extra_fields != NULL) { |
7388
08d31d752893
Use auth-stream API to build all TAB-delimited strings to make sure strings
Timo Sirainen <tss@iki.fi>
parents:
7276
diff
changeset
|
204 const char *fields = |
3520 | 205 auth_stream_reply_export(request->extra_fields); |
7388
08d31d752893
Use auth-stream API to build all TAB-delimited strings to make sure strings
Timo Sirainen <tss@iki.fi>
parents:
7276
diff
changeset
|
206 auth_stream_reply_import(reply, fields); |
3520 | 207 } |
8688
4b25c3e326a4
Another caching fix to blocking passdbs when using non-plaintext auth.
Timo Sirainen <tss@iki.fi>
parents:
8687
diff
changeset
|
208 if (request->extra_cache_fields != NULL) { |
4b25c3e326a4
Another caching fix to blocking passdbs when using non-plaintext auth.
Timo Sirainen <tss@iki.fi>
parents:
8687
diff
changeset
|
209 const char *fields = |
4b25c3e326a4
Another caching fix to blocking passdbs when using non-plaintext auth.
Timo Sirainen <tss@iki.fi>
parents:
8687
diff
changeset
|
210 auth_stream_reply_export(request->extra_cache_fields); |
4b25c3e326a4
Another caching fix to blocking passdbs when using non-plaintext auth.
Timo Sirainen <tss@iki.fi>
parents:
8687
diff
changeset
|
211 auth_stream_reply_import(reply, fields); |
4b25c3e326a4
Another caching fix to blocking passdbs when using non-plaintext auth.
Timo Sirainen <tss@iki.fi>
parents:
8687
diff
changeset
|
212 } |
3168
62f8366cb89c
Forgot to add for blocking passdb/userdb workers..
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
213 } |
7388
08d31d752893
Use auth-stream API to build all TAB-delimited strings to make sure strings
Timo Sirainen <tss@iki.fi>
parents:
7276
diff
changeset
|
214 str = auth_stream_reply_get_str(reply); |
3168
62f8366cb89c
Forgot to add for blocking passdb/userdb workers..
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
215 str_append_c(str, '\n'); |
8560
b6a7bc10c19a
Replaced auth_worker_max_request_count setting with passdb pam { args = max_requests=n }
Timo Sirainen <tss@iki.fi>
parents:
8311
diff
changeset
|
216 auth_worker_send_reply(client, str); |
3168
62f8366cb89c
Forgot to add for blocking passdb/userdb workers..
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
217 |
3879
928229f8b3e6
deinit, unref, destroy, close, free, etc. functions now take a pointer to
Timo Sirainen <tss@iki.fi>
parents:
3863
diff
changeset
|
218 auth_request_unref(&request); |
3414
c2497d4c60c9
Auth workers were leaking memory for each request. Fixed also a few invalid
Timo Sirainen <tss@iki.fi>
parents:
3398
diff
changeset
|
219 auth_worker_client_check_throttle(client); |
3879
928229f8b3e6
deinit, unref, destroy, close, free, etc. functions now take a pointer to
Timo Sirainen <tss@iki.fi>
parents:
3863
diff
changeset
|
220 auth_worker_client_unref(&client); |
3168
62f8366cb89c
Forgot to add for blocking passdb/userdb workers..
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
221 } |
62f8366cb89c
Forgot to add for blocking passdb/userdb workers..
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
222 |
62f8366cb89c
Forgot to add for blocking passdb/userdb workers..
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
223 static void |
62f8366cb89c
Forgot to add for blocking passdb/userdb workers..
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
224 auth_worker_handle_passl(struct auth_worker_client *client, |
62f8366cb89c
Forgot to add for blocking passdb/userdb workers..
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
225 unsigned int id, const char *args) |
62f8366cb89c
Forgot to add for blocking passdb/userdb workers..
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
226 { |
62f8366cb89c
Forgot to add for blocking passdb/userdb workers..
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
227 /* lookup credentials */ |
62f8366cb89c
Forgot to add for blocking passdb/userdb workers..
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
228 struct auth_request *auth_request; |
5593
f8dc0bdb06a7
Removed enum passdb_credentials. Use scheme strings directly instead. This
Timo Sirainen <tss@iki.fi>
parents:
5475
diff
changeset
|
229 const char *scheme; |
4040
c0d093d8b8e5
Fixed passdb credential lookups to work again with blocking passdbs.
Timo Sirainen <timo.sirainen@movial.fi>
parents:
4030
diff
changeset
|
230 unsigned int passdb_id; |
3183
16ea551957ed
Replaced userdb/passdb settings with blocks so it's possible to give
Timo Sirainen <tss@iki.fi>
parents:
3168
diff
changeset
|
231 |
4040
c0d093d8b8e5
Fixed passdb credential lookups to work again with blocking passdbs.
Timo Sirainen <timo.sirainen@movial.fi>
parents:
4030
diff
changeset
|
232 passdb_id = atoi(t_strcut(args, '\t')); |
3183
16ea551957ed
Replaced userdb/passdb settings with blocks so it's possible to give
Timo Sirainen <tss@iki.fi>
parents:
3168
diff
changeset
|
233 args = strchr(args, '\t'); |
16ea551957ed
Replaced userdb/passdb settings with blocks so it's possible to give
Timo Sirainen <tss@iki.fi>
parents:
3168
diff
changeset
|
234 if (args == NULL) { |
16ea551957ed
Replaced userdb/passdb settings with blocks so it's possible to give
Timo Sirainen <tss@iki.fi>
parents:
3168
diff
changeset
|
235 i_error("BUG: Auth worker server sent us invalid PASSL"); |
16ea551957ed
Replaced userdb/passdb settings with blocks so it's possible to give
Timo Sirainen <tss@iki.fi>
parents:
3168
diff
changeset
|
236 return; |
16ea551957ed
Replaced userdb/passdb settings with blocks so it's possible to give
Timo Sirainen <tss@iki.fi>
parents:
3168
diff
changeset
|
237 } |
16ea551957ed
Replaced userdb/passdb settings with blocks so it's possible to give
Timo Sirainen <tss@iki.fi>
parents:
3168
diff
changeset
|
238 args++; |
3168
62f8366cb89c
Forgot to add for blocking passdb/userdb workers..
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
239 |
5593
f8dc0bdb06a7
Removed enum passdb_credentials. Use scheme strings directly instead. This
Timo Sirainen <tss@iki.fi>
parents:
5475
diff
changeset
|
240 scheme = t_strcut(args, '\t'); |
3168
62f8366cb89c
Forgot to add for blocking passdb/userdb workers..
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
241 args = strchr(args, '\t'); |
62f8366cb89c
Forgot to add for blocking passdb/userdb workers..
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
242 if (args != NULL) args++; |
62f8366cb89c
Forgot to add for blocking passdb/userdb workers..
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
243 |
62f8366cb89c
Forgot to add for blocking passdb/userdb workers..
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
244 auth_request = worker_auth_request_new(client, id, args); |
5593
f8dc0bdb06a7
Removed enum passdb_credentials. Use scheme strings directly instead. This
Timo Sirainen <tss@iki.fi>
parents:
5475
diff
changeset
|
245 auth_request->credentials_scheme = p_strdup(auth_request->pool, scheme); |
3183
16ea551957ed
Replaced userdb/passdb settings with blocks so it's possible to give
Timo Sirainen <tss@iki.fi>
parents:
3168
diff
changeset
|
246 |
3338
e5ce49c8524a
USER auth command requires now service parameter and supports also others
Timo Sirainen <tss@iki.fi>
parents:
3311
diff
changeset
|
247 if (auth_request->user == NULL || auth_request->service == NULL) { |
e5ce49c8524a
USER auth command requires now service parameter and supports also others
Timo Sirainen <tss@iki.fi>
parents:
3311
diff
changeset
|
248 i_error("BUG: PASSL had missing parameters"); |
3879
928229f8b3e6
deinit, unref, destroy, close, free, etc. functions now take a pointer to
Timo Sirainen <tss@iki.fi>
parents:
3863
diff
changeset
|
249 auth_request_unref(&auth_request); |
3338
e5ce49c8524a
USER auth command requires now service parameter and supports also others
Timo Sirainen <tss@iki.fi>
parents:
3311
diff
changeset
|
250 return; |
e5ce49c8524a
USER auth command requires now service parameter and supports also others
Timo Sirainen <tss@iki.fi>
parents:
3311
diff
changeset
|
251 } |
e5ce49c8524a
USER auth command requires now service parameter and supports also others
Timo Sirainen <tss@iki.fi>
parents:
3311
diff
changeset
|
252 |
4040
c0d093d8b8e5
Fixed passdb credential lookups to work again with blocking passdbs.
Timo Sirainen <timo.sirainen@movial.fi>
parents:
4030
diff
changeset
|
253 while (auth_request->passdb->id != passdb_id) { |
3183
16ea551957ed
Replaced userdb/passdb settings with blocks so it's possible to give
Timo Sirainen <tss@iki.fi>
parents:
3168
diff
changeset
|
254 auth_request->passdb = auth_request->passdb->next; |
16ea551957ed
Replaced userdb/passdb settings with blocks so it's possible to give
Timo Sirainen <tss@iki.fi>
parents:
3168
diff
changeset
|
255 if (auth_request->passdb == NULL) { |
4040
c0d093d8b8e5
Fixed passdb credential lookups to work again with blocking passdbs.
Timo Sirainen <timo.sirainen@movial.fi>
parents:
4030
diff
changeset
|
256 i_error("BUG: PASSL had invalid passdb ID"); |
3879
928229f8b3e6
deinit, unref, destroy, close, free, etc. functions now take a pointer to
Timo Sirainen <tss@iki.fi>
parents:
3863
diff
changeset
|
257 auth_request_unref(&auth_request); |
3183
16ea551957ed
Replaced userdb/passdb settings with blocks so it's possible to give
Timo Sirainen <tss@iki.fi>
parents:
3168
diff
changeset
|
258 return; |
16ea551957ed
Replaced userdb/passdb settings with blocks so it's possible to give
Timo Sirainen <tss@iki.fi>
parents:
3168
diff
changeset
|
259 } |
16ea551957ed
Replaced userdb/passdb settings with blocks so it's possible to give
Timo Sirainen <tss@iki.fi>
parents:
3168
diff
changeset
|
260 } |
16ea551957ed
Replaced userdb/passdb settings with blocks so it's possible to give
Timo Sirainen <tss@iki.fi>
parents:
3168
diff
changeset
|
261 |
6243
f4739631ce87
Don't crash if blocking passdb doesn't support credential lookups.
Timo Sirainen <tss@iki.fi>
parents:
6214
diff
changeset
|
262 if (auth_request->passdb->passdb->iface.lookup_credentials == NULL) { |
f4739631ce87
Don't crash if blocking passdb doesn't support credential lookups.
Timo Sirainen <tss@iki.fi>
parents:
6214
diff
changeset
|
263 i_error("BUG: PASSL lookup not supported by given passdb"); |
f4739631ce87
Don't crash if blocking passdb doesn't support credential lookups.
Timo Sirainen <tss@iki.fi>
parents:
6214
diff
changeset
|
264 auth_request_unref(&auth_request); |
f4739631ce87
Don't crash if blocking passdb doesn't support credential lookups.
Timo Sirainen <tss@iki.fi>
parents:
6214
diff
changeset
|
265 return; |
f4739631ce87
Don't crash if blocking passdb doesn't support credential lookups.
Timo Sirainen <tss@iki.fi>
parents:
6214
diff
changeset
|
266 } |
f4739631ce87
Don't crash if blocking passdb doesn't support credential lookups.
Timo Sirainen <tss@iki.fi>
parents:
6214
diff
changeset
|
267 |
8765
d69763bee853
auth workers: Return plaintext credentials to parent process if possible, so it gets cached instead of some other scheme.
Timo Sirainen <tss@iki.fi>
parents:
8762
diff
changeset
|
268 auth_request->prefer_plain_credentials = TRUE; |
3771
4b6d962485b9
Added authentication bind support. Patch by J.M. Maurer.
Timo Sirainen <tss@iki.fi>
parents:
3669
diff
changeset
|
269 auth_request->passdb->passdb->iface. |
3655
62fc6883faeb
Fixes and cleanups to credentials handling. Also fixed auth caching to work
Timo Sirainen <tss@iki.fi>
parents:
3520
diff
changeset
|
270 lookup_credentials(auth_request, lookup_credentials_callback); |
3168
62f8366cb89c
Forgot to add for blocking passdb/userdb workers..
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
271 } |
62f8366cb89c
Forgot to add for blocking passdb/userdb workers..
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
272 |
62f8366cb89c
Forgot to add for blocking passdb/userdb workers..
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
273 static void |
6213
e33a87152c41
Changed set_credentials() callback to take a bool success instead of
Timo Sirainen <tss@iki.fi>
parents:
6173
diff
changeset
|
274 set_credentials_callback(bool success, struct auth_request *request) |
4782
2c1cc5bbc260
Added auth_request_set_credentials() to modify credentials in passdb and
Timo Sirainen <tss@iki.fi>
parents:
4704
diff
changeset
|
275 { |
2c1cc5bbc260
Added auth_request_set_credentials() to modify credentials in passdb and
Timo Sirainen <tss@iki.fi>
parents:
4704
diff
changeset
|
276 struct auth_worker_client *client = request->context; |
2c1cc5bbc260
Added auth_request_set_credentials() to modify credentials in passdb and
Timo Sirainen <tss@iki.fi>
parents:
4704
diff
changeset
|
277 |
2c1cc5bbc260
Added auth_request_set_credentials() to modify credentials in passdb and
Timo Sirainen <tss@iki.fi>
parents:
4704
diff
changeset
|
278 string_t *str; |
2c1cc5bbc260
Added auth_request_set_credentials() to modify credentials in passdb and
Timo Sirainen <tss@iki.fi>
parents:
4704
diff
changeset
|
279 |
2c1cc5bbc260
Added auth_request_set_credentials() to modify credentials in passdb and
Timo Sirainen <tss@iki.fi>
parents:
4704
diff
changeset
|
280 str = t_str_new(64); |
6213
e33a87152c41
Changed set_credentials() callback to take a bool success instead of
Timo Sirainen <tss@iki.fi>
parents:
6173
diff
changeset
|
281 str_printfa(str, "%u\t%s\n", request->id, success ? "OK" : "FAIL"); |
8560
b6a7bc10c19a
Replaced auth_worker_max_request_count setting with passdb pam { args = max_requests=n }
Timo Sirainen <tss@iki.fi>
parents:
8311
diff
changeset
|
282 auth_worker_send_reply(client, str); |
4782
2c1cc5bbc260
Added auth_request_set_credentials() to modify credentials in passdb and
Timo Sirainen <tss@iki.fi>
parents:
4704
diff
changeset
|
283 |
2c1cc5bbc260
Added auth_request_set_credentials() to modify credentials in passdb and
Timo Sirainen <tss@iki.fi>
parents:
4704
diff
changeset
|
284 auth_request_unref(&request); |
2c1cc5bbc260
Added auth_request_set_credentials() to modify credentials in passdb and
Timo Sirainen <tss@iki.fi>
parents:
4704
diff
changeset
|
285 auth_worker_client_check_throttle(client); |
2c1cc5bbc260
Added auth_request_set_credentials() to modify credentials in passdb and
Timo Sirainen <tss@iki.fi>
parents:
4704
diff
changeset
|
286 auth_worker_client_unref(&client); |
2c1cc5bbc260
Added auth_request_set_credentials() to modify credentials in passdb and
Timo Sirainen <tss@iki.fi>
parents:
4704
diff
changeset
|
287 } |
2c1cc5bbc260
Added auth_request_set_credentials() to modify credentials in passdb and
Timo Sirainen <tss@iki.fi>
parents:
4704
diff
changeset
|
288 |
2c1cc5bbc260
Added auth_request_set_credentials() to modify credentials in passdb and
Timo Sirainen <tss@iki.fi>
parents:
4704
diff
changeset
|
289 static void |
2c1cc5bbc260
Added auth_request_set_credentials() to modify credentials in passdb and
Timo Sirainen <tss@iki.fi>
parents:
4704
diff
changeset
|
290 auth_worker_handle_setcred(struct auth_worker_client *client, |
2c1cc5bbc260
Added auth_request_set_credentials() to modify credentials in passdb and
Timo Sirainen <tss@iki.fi>
parents:
4704
diff
changeset
|
291 unsigned int id, const char *args) |
2c1cc5bbc260
Added auth_request_set_credentials() to modify credentials in passdb and
Timo Sirainen <tss@iki.fi>
parents:
4704
diff
changeset
|
292 { |
2c1cc5bbc260
Added auth_request_set_credentials() to modify credentials in passdb and
Timo Sirainen <tss@iki.fi>
parents:
4704
diff
changeset
|
293 struct auth_request *auth_request; |
2c1cc5bbc260
Added auth_request_set_credentials() to modify credentials in passdb and
Timo Sirainen <tss@iki.fi>
parents:
4704
diff
changeset
|
294 unsigned int passdb_id; |
2c1cc5bbc260
Added auth_request_set_credentials() to modify credentials in passdb and
Timo Sirainen <tss@iki.fi>
parents:
4704
diff
changeset
|
295 const char *data; |
2c1cc5bbc260
Added auth_request_set_credentials() to modify credentials in passdb and
Timo Sirainen <tss@iki.fi>
parents:
4704
diff
changeset
|
296 |
2c1cc5bbc260
Added auth_request_set_credentials() to modify credentials in passdb and
Timo Sirainen <tss@iki.fi>
parents:
4704
diff
changeset
|
297 passdb_id = atoi(t_strcut(args, '\t')); |
2c1cc5bbc260
Added auth_request_set_credentials() to modify credentials in passdb and
Timo Sirainen <tss@iki.fi>
parents:
4704
diff
changeset
|
298 args = strchr(args, '\t'); |
2c1cc5bbc260
Added auth_request_set_credentials() to modify credentials in passdb and
Timo Sirainen <tss@iki.fi>
parents:
4704
diff
changeset
|
299 if (args == NULL) { |
2c1cc5bbc260
Added auth_request_set_credentials() to modify credentials in passdb and
Timo Sirainen <tss@iki.fi>
parents:
4704
diff
changeset
|
300 i_error("BUG: Auth worker server sent us invalid SETCRED"); |
2c1cc5bbc260
Added auth_request_set_credentials() to modify credentials in passdb and
Timo Sirainen <tss@iki.fi>
parents:
4704
diff
changeset
|
301 return; |
2c1cc5bbc260
Added auth_request_set_credentials() to modify credentials in passdb and
Timo Sirainen <tss@iki.fi>
parents:
4704
diff
changeset
|
302 } |
2c1cc5bbc260
Added auth_request_set_credentials() to modify credentials in passdb and
Timo Sirainen <tss@iki.fi>
parents:
4704
diff
changeset
|
303 args++; |
2c1cc5bbc260
Added auth_request_set_credentials() to modify credentials in passdb and
Timo Sirainen <tss@iki.fi>
parents:
4704
diff
changeset
|
304 |
2c1cc5bbc260
Added auth_request_set_credentials() to modify credentials in passdb and
Timo Sirainen <tss@iki.fi>
parents:
4704
diff
changeset
|
305 data = t_strcut(args, '\t'); |
2c1cc5bbc260
Added auth_request_set_credentials() to modify credentials in passdb and
Timo Sirainen <tss@iki.fi>
parents:
4704
diff
changeset
|
306 args = strchr(args, '\t'); |
2c1cc5bbc260
Added auth_request_set_credentials() to modify credentials in passdb and
Timo Sirainen <tss@iki.fi>
parents:
4704
diff
changeset
|
307 if (args != NULL) args++; |
2c1cc5bbc260
Added auth_request_set_credentials() to modify credentials in passdb and
Timo Sirainen <tss@iki.fi>
parents:
4704
diff
changeset
|
308 |
2c1cc5bbc260
Added auth_request_set_credentials() to modify credentials in passdb and
Timo Sirainen <tss@iki.fi>
parents:
4704
diff
changeset
|
309 auth_request = worker_auth_request_new(client, id, args); |
2c1cc5bbc260
Added auth_request_set_credentials() to modify credentials in passdb and
Timo Sirainen <tss@iki.fi>
parents:
4704
diff
changeset
|
310 |
2c1cc5bbc260
Added auth_request_set_credentials() to modify credentials in passdb and
Timo Sirainen <tss@iki.fi>
parents:
4704
diff
changeset
|
311 if (auth_request->user == NULL || auth_request->service == NULL) { |
2c1cc5bbc260
Added auth_request_set_credentials() to modify credentials in passdb and
Timo Sirainen <tss@iki.fi>
parents:
4704
diff
changeset
|
312 i_error("BUG: SETCRED had missing parameters"); |
2c1cc5bbc260
Added auth_request_set_credentials() to modify credentials in passdb and
Timo Sirainen <tss@iki.fi>
parents:
4704
diff
changeset
|
313 auth_request_unref(&auth_request); |
2c1cc5bbc260
Added auth_request_set_credentials() to modify credentials in passdb and
Timo Sirainen <tss@iki.fi>
parents:
4704
diff
changeset
|
314 return; |
2c1cc5bbc260
Added auth_request_set_credentials() to modify credentials in passdb and
Timo Sirainen <tss@iki.fi>
parents:
4704
diff
changeset
|
315 } |
2c1cc5bbc260
Added auth_request_set_credentials() to modify credentials in passdb and
Timo Sirainen <tss@iki.fi>
parents:
4704
diff
changeset
|
316 |
2c1cc5bbc260
Added auth_request_set_credentials() to modify credentials in passdb and
Timo Sirainen <tss@iki.fi>
parents:
4704
diff
changeset
|
317 while (auth_request->passdb->id != passdb_id) { |
2c1cc5bbc260
Added auth_request_set_credentials() to modify credentials in passdb and
Timo Sirainen <tss@iki.fi>
parents:
4704
diff
changeset
|
318 auth_request->passdb = auth_request->passdb->next; |
2c1cc5bbc260
Added auth_request_set_credentials() to modify credentials in passdb and
Timo Sirainen <tss@iki.fi>
parents:
4704
diff
changeset
|
319 if (auth_request->passdb == NULL) { |
2c1cc5bbc260
Added auth_request_set_credentials() to modify credentials in passdb and
Timo Sirainen <tss@iki.fi>
parents:
4704
diff
changeset
|
320 i_error("BUG: SETCRED had invalid passdb ID"); |
2c1cc5bbc260
Added auth_request_set_credentials() to modify credentials in passdb and
Timo Sirainen <tss@iki.fi>
parents:
4704
diff
changeset
|
321 auth_request_unref(&auth_request); |
2c1cc5bbc260
Added auth_request_set_credentials() to modify credentials in passdb and
Timo Sirainen <tss@iki.fi>
parents:
4704
diff
changeset
|
322 return; |
2c1cc5bbc260
Added auth_request_set_credentials() to modify credentials in passdb and
Timo Sirainen <tss@iki.fi>
parents:
4704
diff
changeset
|
323 } |
2c1cc5bbc260
Added auth_request_set_credentials() to modify credentials in passdb and
Timo Sirainen <tss@iki.fi>
parents:
4704
diff
changeset
|
324 } |
2c1cc5bbc260
Added auth_request_set_credentials() to modify credentials in passdb and
Timo Sirainen <tss@iki.fi>
parents:
4704
diff
changeset
|
325 |
2c1cc5bbc260
Added auth_request_set_credentials() to modify credentials in passdb and
Timo Sirainen <tss@iki.fi>
parents:
4704
diff
changeset
|
326 auth_request->passdb->passdb->iface. |
2c1cc5bbc260
Added auth_request_set_credentials() to modify credentials in passdb and
Timo Sirainen <tss@iki.fi>
parents:
4704
diff
changeset
|
327 set_credentials(auth_request, data, set_credentials_callback); |
2c1cc5bbc260
Added auth_request_set_credentials() to modify credentials in passdb and
Timo Sirainen <tss@iki.fi>
parents:
4704
diff
changeset
|
328 } |
2c1cc5bbc260
Added auth_request_set_credentials() to modify credentials in passdb and
Timo Sirainen <tss@iki.fi>
parents:
4704
diff
changeset
|
329 |
2c1cc5bbc260
Added auth_request_set_credentials() to modify credentials in passdb and
Timo Sirainen <tss@iki.fi>
parents:
4704
diff
changeset
|
330 static void |
4880
4ec6a4def05b
We treated internal userdb lookup errors as "user unknown" errors. In such
Timo Sirainen <tss@iki.fi>
parents:
4782
diff
changeset
|
331 lookup_user_callback(enum userdb_result result, |
3520 | 332 struct auth_request *auth_request) |
3168
62f8366cb89c
Forgot to add for blocking passdb/userdb workers..
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
333 { |
62f8366cb89c
Forgot to add for blocking passdb/userdb workers..
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
334 struct auth_worker_client *client = auth_request->context; |
5872
93bd157917ca
Changed userdb callback API. Don't require uid/gid to be returned by userdb.
Timo Sirainen <tss@iki.fi>
parents:
5598
diff
changeset
|
335 struct auth_stream_reply *reply = auth_request->userdb_reply; |
3168
62f8366cb89c
Forgot to add for blocking passdb/userdb workers..
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
336 string_t *str; |
62f8366cb89c
Forgot to add for blocking passdb/userdb workers..
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
337 |
5872
93bd157917ca
Changed userdb callback API. Don't require uid/gid to be returned by userdb.
Timo Sirainen <tss@iki.fi>
parents:
5598
diff
changeset
|
338 if (auth_request->userdb_lookup_failed) |
93bd157917ca
Changed userdb callback API. Don't require uid/gid to be returned by userdb.
Timo Sirainen <tss@iki.fi>
parents:
5598
diff
changeset
|
339 result = USERDB_RESULT_INTERNAL_FAILURE; |
93bd157917ca
Changed userdb callback API. Don't require uid/gid to be returned by userdb.
Timo Sirainen <tss@iki.fi>
parents:
5598
diff
changeset
|
340 |
4880
4ec6a4def05b
We treated internal userdb lookup errors as "user unknown" errors. In such
Timo Sirainen <tss@iki.fi>
parents:
4782
diff
changeset
|
341 str = t_str_new(128); |
3168
62f8366cb89c
Forgot to add for blocking passdb/userdb workers..
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
342 str_printfa(str, "%u\t", auth_request->id); |
4880
4ec6a4def05b
We treated internal userdb lookup errors as "user unknown" errors. In such
Timo Sirainen <tss@iki.fi>
parents:
4782
diff
changeset
|
343 switch (result) { |
4ec6a4def05b
We treated internal userdb lookup errors as "user unknown" errors. In such
Timo Sirainen <tss@iki.fi>
parents:
4782
diff
changeset
|
344 case USERDB_RESULT_INTERNAL_FAILURE: |
4ec6a4def05b
We treated internal userdb lookup errors as "user unknown" errors. In such
Timo Sirainen <tss@iki.fi>
parents:
4782
diff
changeset
|
345 str_append(str, "FAIL\t"); |
4ec6a4def05b
We treated internal userdb lookup errors as "user unknown" errors. In such
Timo Sirainen <tss@iki.fi>
parents:
4782
diff
changeset
|
346 break; |
4ec6a4def05b
We treated internal userdb lookup errors as "user unknown" errors. In such
Timo Sirainen <tss@iki.fi>
parents:
4782
diff
changeset
|
347 case USERDB_RESULT_USER_UNKNOWN: |
4ec6a4def05b
We treated internal userdb lookup errors as "user unknown" errors. In such
Timo Sirainen <tss@iki.fi>
parents:
4782
diff
changeset
|
348 str_append(str, "NOTFOUND\t"); |
4ec6a4def05b
We treated internal userdb lookup errors as "user unknown" errors. In such
Timo Sirainen <tss@iki.fi>
parents:
4782
diff
changeset
|
349 break; |
4ec6a4def05b
We treated internal userdb lookup errors as "user unknown" errors. In such
Timo Sirainen <tss@iki.fi>
parents:
4782
diff
changeset
|
350 case USERDB_RESULT_OK: |
4ec6a4def05b
We treated internal userdb lookup errors as "user unknown" errors. In such
Timo Sirainen <tss@iki.fi>
parents:
4782
diff
changeset
|
351 str_append(str, "OK\t"); |
3520 | 352 str_append(str, auth_stream_reply_export(reply)); |
4880
4ec6a4def05b
We treated internal userdb lookup errors as "user unknown" errors. In such
Timo Sirainen <tss@iki.fi>
parents:
4782
diff
changeset
|
353 break; |
4ec6a4def05b
We treated internal userdb lookup errors as "user unknown" errors. In such
Timo Sirainen <tss@iki.fi>
parents:
4782
diff
changeset
|
354 } |
3168
62f8366cb89c
Forgot to add for blocking passdb/userdb workers..
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
355 str_append_c(str, '\n'); |
62f8366cb89c
Forgot to add for blocking passdb/userdb workers..
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
356 |
8560
b6a7bc10c19a
Replaced auth_worker_max_request_count setting with passdb pam { args = max_requests=n }
Timo Sirainen <tss@iki.fi>
parents:
8311
diff
changeset
|
357 auth_worker_send_reply(client, str); |
3414
c2497d4c60c9
Auth workers were leaking memory for each request. Fixed also a few invalid
Timo Sirainen <tss@iki.fi>
parents:
3398
diff
changeset
|
358 |
3879
928229f8b3e6
deinit, unref, destroy, close, free, etc. functions now take a pointer to
Timo Sirainen <tss@iki.fi>
parents:
3863
diff
changeset
|
359 auth_request_unref(&auth_request); |
3414
c2497d4c60c9
Auth workers were leaking memory for each request. Fixed also a few invalid
Timo Sirainen <tss@iki.fi>
parents:
3398
diff
changeset
|
360 auth_worker_client_check_throttle(client); |
3879
928229f8b3e6
deinit, unref, destroy, close, free, etc. functions now take a pointer to
Timo Sirainen <tss@iki.fi>
parents:
3863
diff
changeset
|
361 auth_worker_client_unref(&client); |
3168
62f8366cb89c
Forgot to add for blocking passdb/userdb workers..
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
362 } |
62f8366cb89c
Forgot to add for blocking passdb/userdb workers..
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
363 |
62f8366cb89c
Forgot to add for blocking passdb/userdb workers..
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
364 static void |
62f8366cb89c
Forgot to add for blocking passdb/userdb workers..
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
365 auth_worker_handle_user(struct auth_worker_client *client, |
62f8366cb89c
Forgot to add for blocking passdb/userdb workers..
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
366 unsigned int id, const char *args) |
62f8366cb89c
Forgot to add for blocking passdb/userdb workers..
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
367 { |
62f8366cb89c
Forgot to add for blocking passdb/userdb workers..
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
368 /* lookup user */ |
62f8366cb89c
Forgot to add for blocking passdb/userdb workers..
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
369 struct auth_request *auth_request; |
3183
16ea551957ed
Replaced userdb/passdb settings with blocks so it's possible to give
Timo Sirainen <tss@iki.fi>
parents:
3168
diff
changeset
|
370 unsigned int num; |
16ea551957ed
Replaced userdb/passdb settings with blocks so it's possible to give
Timo Sirainen <tss@iki.fi>
parents:
3168
diff
changeset
|
371 |
16ea551957ed
Replaced userdb/passdb settings with blocks so it's possible to give
Timo Sirainen <tss@iki.fi>
parents:
3168
diff
changeset
|
372 num = atoi(t_strcut(args, '\t')); |
16ea551957ed
Replaced userdb/passdb settings with blocks so it's possible to give
Timo Sirainen <tss@iki.fi>
parents:
3168
diff
changeset
|
373 args = strchr(args, '\t'); |
16ea551957ed
Replaced userdb/passdb settings with blocks so it's possible to give
Timo Sirainen <tss@iki.fi>
parents:
3168
diff
changeset
|
374 if (args != NULL) args++; |
3168
62f8366cb89c
Forgot to add for blocking passdb/userdb workers..
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
375 |
62f8366cb89c
Forgot to add for blocking passdb/userdb workers..
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
376 auth_request = worker_auth_request_new(client, id, args); |
3183
16ea551957ed
Replaced userdb/passdb settings with blocks so it's possible to give
Timo Sirainen <tss@iki.fi>
parents:
3168
diff
changeset
|
377 |
3338
e5ce49c8524a
USER auth command requires now service parameter and supports also others
Timo Sirainen <tss@iki.fi>
parents:
3311
diff
changeset
|
378 if (auth_request->user == NULL || auth_request->service == NULL) { |
e5ce49c8524a
USER auth command requires now service parameter and supports also others
Timo Sirainen <tss@iki.fi>
parents:
3311
diff
changeset
|
379 i_error("BUG: USER had missing parameters"); |
3879
928229f8b3e6
deinit, unref, destroy, close, free, etc. functions now take a pointer to
Timo Sirainen <tss@iki.fi>
parents:
3863
diff
changeset
|
380 auth_request_unref(&auth_request); |
3338
e5ce49c8524a
USER auth command requires now service parameter and supports also others
Timo Sirainen <tss@iki.fi>
parents:
3311
diff
changeset
|
381 return; |
e5ce49c8524a
USER auth command requires now service parameter and supports also others
Timo Sirainen <tss@iki.fi>
parents:
3311
diff
changeset
|
382 } |
e5ce49c8524a
USER auth command requires now service parameter and supports also others
Timo Sirainen <tss@iki.fi>
parents:
3311
diff
changeset
|
383 |
3256
c18ab708f71c
Auth workers weren't working correctly with more than one passdb/userdb.
Timo Sirainen <tss@iki.fi>
parents:
3227
diff
changeset
|
384 for (; num > 0; num--) { |
3183
16ea551957ed
Replaced userdb/passdb settings with blocks so it's possible to give
Timo Sirainen <tss@iki.fi>
parents:
3168
diff
changeset
|
385 auth_request->userdb = auth_request->userdb->next; |
16ea551957ed
Replaced userdb/passdb settings with blocks so it's possible to give
Timo Sirainen <tss@iki.fi>
parents:
3168
diff
changeset
|
386 if (auth_request->userdb == NULL) { |
16ea551957ed
Replaced userdb/passdb settings with blocks so it's possible to give
Timo Sirainen <tss@iki.fi>
parents:
3168
diff
changeset
|
387 i_error("BUG: USER had invalid userdb num"); |
3879
928229f8b3e6
deinit, unref, destroy, close, free, etc. functions now take a pointer to
Timo Sirainen <tss@iki.fi>
parents:
3863
diff
changeset
|
388 auth_request_unref(&auth_request); |
3183
16ea551957ed
Replaced userdb/passdb settings with blocks so it's possible to give
Timo Sirainen <tss@iki.fi>
parents:
3168
diff
changeset
|
389 return; |
16ea551957ed
Replaced userdb/passdb settings with blocks so it's possible to give
Timo Sirainen <tss@iki.fi>
parents:
3168
diff
changeset
|
390 } |
16ea551957ed
Replaced userdb/passdb settings with blocks so it's possible to give
Timo Sirainen <tss@iki.fi>
parents:
3168
diff
changeset
|
391 } |
16ea551957ed
Replaced userdb/passdb settings with blocks so it's possible to give
Timo Sirainen <tss@iki.fi>
parents:
3168
diff
changeset
|
392 |
3658
fc4622b1c1ef
Separated userdb_module's interface and the actual data struct.
Timo Sirainen <tss@iki.fi>
parents:
3657
diff
changeset
|
393 auth_request->userdb->userdb->iface-> |
3183
16ea551957ed
Replaced userdb/passdb settings with blocks so it's possible to give
Timo Sirainen <tss@iki.fi>
parents:
3168
diff
changeset
|
394 lookup(auth_request, lookup_user_callback); |
3168
62f8366cb89c
Forgot to add for blocking passdb/userdb workers..
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
395 } |
62f8366cb89c
Forgot to add for blocking passdb/userdb workers..
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
396 |
3863
55df57c028d4
Added "bool" type and changed all ints that were used as booleans to bool.
Timo Sirainen <tss@iki.fi>
parents:
3771
diff
changeset
|
397 static bool |
3168
62f8366cb89c
Forgot to add for blocking passdb/userdb workers..
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
398 auth_worker_handle_line(struct auth_worker_client *client, const char *line) |
62f8366cb89c
Forgot to add for blocking passdb/userdb workers..
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
399 { |
62f8366cb89c
Forgot to add for blocking passdb/userdb workers..
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
400 const char *p; |
62f8366cb89c
Forgot to add for blocking passdb/userdb workers..
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
401 unsigned int id; |
62f8366cb89c
Forgot to add for blocking passdb/userdb workers..
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
402 |
62f8366cb89c
Forgot to add for blocking passdb/userdb workers..
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
403 p = strchr(line, '\t'); |
62f8366cb89c
Forgot to add for blocking passdb/userdb workers..
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
404 if (p == NULL) |
62f8366cb89c
Forgot to add for blocking passdb/userdb workers..
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
405 return FALSE; |
62f8366cb89c
Forgot to add for blocking passdb/userdb workers..
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
406 |
62f8366cb89c
Forgot to add for blocking passdb/userdb workers..
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
407 id = (unsigned int)strtoul(t_strdup_until(line, p), NULL, 10); |
62f8366cb89c
Forgot to add for blocking passdb/userdb workers..
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
408 line = p + 1; |
62f8366cb89c
Forgot to add for blocking passdb/userdb workers..
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
409 |
62f8366cb89c
Forgot to add for blocking passdb/userdb workers..
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
410 if (strncmp(line, "PASSV\t", 6) == 0) |
62f8366cb89c
Forgot to add for blocking passdb/userdb workers..
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
411 auth_worker_handle_passv(client, id, line + 6); |
62f8366cb89c
Forgot to add for blocking passdb/userdb workers..
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
412 else if (strncmp(line, "PASSL\t", 6) == 0) |
62f8366cb89c
Forgot to add for blocking passdb/userdb workers..
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
413 auth_worker_handle_passl(client, id, line + 6); |
4782
2c1cc5bbc260
Added auth_request_set_credentials() to modify credentials in passdb and
Timo Sirainen <tss@iki.fi>
parents:
4704
diff
changeset
|
414 else if (strncmp(line, "SETCRED\t", 8) == 0) |
2c1cc5bbc260
Added auth_request_set_credentials() to modify credentials in passdb and
Timo Sirainen <tss@iki.fi>
parents:
4704
diff
changeset
|
415 auth_worker_handle_setcred(client, id, line + 8); |
3168
62f8366cb89c
Forgot to add for blocking passdb/userdb workers..
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
416 else if (strncmp(line, "USER\t", 5) == 0) |
62f8366cb89c
Forgot to add for blocking passdb/userdb workers..
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
417 auth_worker_handle_user(client, id, line + 5); |
62f8366cb89c
Forgot to add for blocking passdb/userdb workers..
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
418 |
62f8366cb89c
Forgot to add for blocking passdb/userdb workers..
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
419 return TRUE; |
62f8366cb89c
Forgot to add for blocking passdb/userdb workers..
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
420 } |
62f8366cb89c
Forgot to add for blocking passdb/userdb workers..
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
421 |
4907
5b4c9b20eba0
Replaced void *context from a lot of callbacks with the actual context
Timo Sirainen <tss@iki.fi>
parents:
4880
diff
changeset
|
422 static void auth_worker_input(struct auth_worker_client *client) |
3168
62f8366cb89c
Forgot to add for blocking passdb/userdb workers..
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
423 { |
62f8366cb89c
Forgot to add for blocking passdb/userdb workers..
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
424 char *line; |
3863
55df57c028d4
Added "bool" type and changed all ints that were used as booleans to bool.
Timo Sirainen <tss@iki.fi>
parents:
3771
diff
changeset
|
425 bool ret; |
3168
62f8366cb89c
Forgot to add for blocking passdb/userdb workers..
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
426 |
62f8366cb89c
Forgot to add for blocking passdb/userdb workers..
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
427 switch (i_stream_read(client->input)) { |
62f8366cb89c
Forgot to add for blocking passdb/userdb workers..
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
428 case 0: |
62f8366cb89c
Forgot to add for blocking passdb/userdb workers..
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
429 return; |
62f8366cb89c
Forgot to add for blocking passdb/userdb workers..
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
430 case -1: |
62f8366cb89c
Forgot to add for blocking passdb/userdb workers..
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
431 /* disconnected */ |
3879
928229f8b3e6
deinit, unref, destroy, close, free, etc. functions now take a pointer to
Timo Sirainen <tss@iki.fi>
parents:
3863
diff
changeset
|
432 auth_worker_client_destroy(&client); |
3168
62f8366cb89c
Forgot to add for blocking passdb/userdb workers..
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
433 return; |
62f8366cb89c
Forgot to add for blocking passdb/userdb workers..
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
434 case -2: |
62f8366cb89c
Forgot to add for blocking passdb/userdb workers..
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
435 /* buffer full */ |
62f8366cb89c
Forgot to add for blocking passdb/userdb workers..
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
436 i_error("BUG: Auth worker server sent us more than %d bytes", |
62f8366cb89c
Forgot to add for blocking passdb/userdb workers..
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
437 (int)AUTH_WORKER_MAX_LINE_LENGTH); |
3879
928229f8b3e6
deinit, unref, destroy, close, free, etc. functions now take a pointer to
Timo Sirainen <tss@iki.fi>
parents:
3863
diff
changeset
|
438 auth_worker_client_destroy(&client); |
3168
62f8366cb89c
Forgot to add for blocking passdb/userdb workers..
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
439 return; |
62f8366cb89c
Forgot to add for blocking passdb/userdb workers..
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
440 } |
62f8366cb89c
Forgot to add for blocking passdb/userdb workers..
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
441 |
62f8366cb89c
Forgot to add for blocking passdb/userdb workers..
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
442 client->refcount++; |
62f8366cb89c
Forgot to add for blocking passdb/userdb workers..
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
443 while ((line = i_stream_next_line(client->input)) != NULL) { |
7226
e6693a0ec8e1
Renamed T_FRAME_BEGIN/END to T_BEGIN/END. Removed T_FRAME() macro and
Timo Sirainen <tss@iki.fi>
parents:
7086
diff
changeset
|
444 T_BEGIN { |
6940
414c9d631a81
Replaced t_push/t_pop calls with T_FRAME*() macros.
Timo Sirainen <tss@iki.fi>
parents:
6436
diff
changeset
|
445 ret = auth_worker_handle_line(client, line); |
7226
e6693a0ec8e1
Renamed T_FRAME_BEGIN/END to T_BEGIN/END. Removed T_FRAME() macro and
Timo Sirainen <tss@iki.fi>
parents:
7086
diff
changeset
|
446 } T_END; |
3168
62f8366cb89c
Forgot to add for blocking passdb/userdb workers..
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
447 |
62f8366cb89c
Forgot to add for blocking passdb/userdb workers..
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
448 if (!ret) { |
3879
928229f8b3e6
deinit, unref, destroy, close, free, etc. functions now take a pointer to
Timo Sirainen <tss@iki.fi>
parents:
3863
diff
changeset
|
449 auth_worker_client_destroy(&client); |
3168
62f8366cb89c
Forgot to add for blocking passdb/userdb workers..
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
450 break; |
62f8366cb89c
Forgot to add for blocking passdb/userdb workers..
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
451 } |
62f8366cb89c
Forgot to add for blocking passdb/userdb workers..
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
452 } |
3879
928229f8b3e6
deinit, unref, destroy, close, free, etc. functions now take a pointer to
Timo Sirainen <tss@iki.fi>
parents:
3863
diff
changeset
|
453 auth_worker_client_unref(&client); |
3168
62f8366cb89c
Forgot to add for blocking passdb/userdb workers..
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
454 } |
62f8366cb89c
Forgot to add for blocking passdb/userdb workers..
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
455 |
4907
5b4c9b20eba0
Replaced void *context from a lot of callbacks with the actual context
Timo Sirainen <tss@iki.fi>
parents:
4880
diff
changeset
|
456 static int auth_worker_output(struct auth_worker_client *client) |
3168
62f8366cb89c
Forgot to add for blocking passdb/userdb workers..
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
457 { |
62f8366cb89c
Forgot to add for blocking passdb/userdb workers..
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
458 if (o_stream_flush(client->output) < 0) { |
3879
928229f8b3e6
deinit, unref, destroy, close, free, etc. functions now take a pointer to
Timo Sirainen <tss@iki.fi>
parents:
3863
diff
changeset
|
459 auth_worker_client_destroy(&client); |
3168
62f8366cb89c
Forgot to add for blocking passdb/userdb workers..
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
460 return 1; |
62f8366cb89c
Forgot to add for blocking passdb/userdb workers..
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
461 } |
62f8366cb89c
Forgot to add for blocking passdb/userdb workers..
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
462 |
62f8366cb89c
Forgot to add for blocking passdb/userdb workers..
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
463 if (o_stream_get_buffer_used_size(client->output) <= |
62f8366cb89c
Forgot to add for blocking passdb/userdb workers..
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
464 OUTBUF_THROTTLE_SIZE/3 && client->io == NULL) { |
62f8366cb89c
Forgot to add for blocking passdb/userdb workers..
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
465 /* allow input again */ |
62f8366cb89c
Forgot to add for blocking passdb/userdb workers..
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
466 client->io = io_add(client->fd, IO_READ, |
62f8366cb89c
Forgot to add for blocking passdb/userdb workers..
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
467 auth_worker_input, client); |
62f8366cb89c
Forgot to add for blocking passdb/userdb workers..
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
468 } |
62f8366cb89c
Forgot to add for blocking passdb/userdb workers..
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
469 return 1; |
62f8366cb89c
Forgot to add for blocking passdb/userdb workers..
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
470 } |
62f8366cb89c
Forgot to add for blocking passdb/userdb workers..
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
471 |
62f8366cb89c
Forgot to add for blocking passdb/userdb workers..
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
472 struct auth_worker_client * |
62f8366cb89c
Forgot to add for blocking passdb/userdb workers..
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
473 auth_worker_client_create(struct auth *auth, int fd) |
62f8366cb89c
Forgot to add for blocking passdb/userdb workers..
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
474 { |
62f8366cb89c
Forgot to add for blocking passdb/userdb workers..
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
475 struct auth_worker_client *client; |
62f8366cb89c
Forgot to add for blocking passdb/userdb workers..
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
476 |
62f8366cb89c
Forgot to add for blocking passdb/userdb workers..
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
477 client = i_new(struct auth_worker_client, 1); |
62f8366cb89c
Forgot to add for blocking passdb/userdb workers..
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
478 client->refcount = 1; |
62f8366cb89c
Forgot to add for blocking passdb/userdb workers..
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
479 |
62f8366cb89c
Forgot to add for blocking passdb/userdb workers..
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
480 client->auth = auth; |
62f8366cb89c
Forgot to add for blocking passdb/userdb workers..
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
481 client->fd = fd; |
6162
896cc473c1f0
Renamed i_stream_create_file() to i_stream_create_fd().
Timo Sirainen <tss@iki.fi>
parents:
6161
diff
changeset
|
482 client->input = i_stream_create_fd(fd, AUTH_WORKER_MAX_LINE_LENGTH, |
896cc473c1f0
Renamed i_stream_create_file() to i_stream_create_fd().
Timo Sirainen <tss@iki.fi>
parents:
6161
diff
changeset
|
483 FALSE); |
6161
c62f7ee79446
Split o_stream_create_file() to _create_fd() and _create_fd_file().
Timo Sirainen <tss@iki.fi>
parents:
6142
diff
changeset
|
484 client->output = o_stream_create_fd(fd, (size_t)-1, FALSE); |
3168
62f8366cb89c
Forgot to add for blocking passdb/userdb workers..
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
485 o_stream_set_flush_callback(client->output, auth_worker_output, client); |
62f8366cb89c
Forgot to add for blocking passdb/userdb workers..
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
486 client->io = io_add(fd, IO_READ, auth_worker_input, client); |
62f8366cb89c
Forgot to add for blocking passdb/userdb workers..
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
487 return client; |
62f8366cb89c
Forgot to add for blocking passdb/userdb workers..
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
488 } |
62f8366cb89c
Forgot to add for blocking passdb/userdb workers..
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
489 |
3879
928229f8b3e6
deinit, unref, destroy, close, free, etc. functions now take a pointer to
Timo Sirainen <tss@iki.fi>
parents:
3863
diff
changeset
|
490 void auth_worker_client_destroy(struct auth_worker_client **_client) |
3168
62f8366cb89c
Forgot to add for blocking passdb/userdb workers..
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
491 { |
3879
928229f8b3e6
deinit, unref, destroy, close, free, etc. functions now take a pointer to
Timo Sirainen <tss@iki.fi>
parents:
3863
diff
changeset
|
492 struct auth_worker_client *client = *_client; |
928229f8b3e6
deinit, unref, destroy, close, free, etc. functions now take a pointer to
Timo Sirainen <tss@iki.fi>
parents:
3863
diff
changeset
|
493 |
928229f8b3e6
deinit, unref, destroy, close, free, etc. functions now take a pointer to
Timo Sirainen <tss@iki.fi>
parents:
3863
diff
changeset
|
494 *_client = NULL; |
3168
62f8366cb89c
Forgot to add for blocking passdb/userdb workers..
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
495 if (client->fd == -1) |
62f8366cb89c
Forgot to add for blocking passdb/userdb workers..
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
496 return; |
62f8366cb89c
Forgot to add for blocking passdb/userdb workers..
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
497 |
62f8366cb89c
Forgot to add for blocking passdb/userdb workers..
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
498 i_stream_close(client->input); |
62f8366cb89c
Forgot to add for blocking passdb/userdb workers..
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
499 o_stream_close(client->output); |
62f8366cb89c
Forgot to add for blocking passdb/userdb workers..
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
500 |
3879
928229f8b3e6
deinit, unref, destroy, close, free, etc. functions now take a pointer to
Timo Sirainen <tss@iki.fi>
parents:
3863
diff
changeset
|
501 if (client->io != NULL) |
928229f8b3e6
deinit, unref, destroy, close, free, etc. functions now take a pointer to
Timo Sirainen <tss@iki.fi>
parents:
3863
diff
changeset
|
502 io_remove(&client->io); |
3168
62f8366cb89c
Forgot to add for blocking passdb/userdb workers..
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
503 |
62f8366cb89c
Forgot to add for blocking passdb/userdb workers..
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
504 net_disconnect(client->fd); |
62f8366cb89c
Forgot to add for blocking passdb/userdb workers..
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
505 client->fd = -1; |
62f8366cb89c
Forgot to add for blocking passdb/userdb workers..
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
506 |
62f8366cb89c
Forgot to add for blocking passdb/userdb workers..
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
507 io_loop_stop(ioloop); |
62f8366cb89c
Forgot to add for blocking passdb/userdb workers..
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
508 } |
62f8366cb89c
Forgot to add for blocking passdb/userdb workers..
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
509 |
3879
928229f8b3e6
deinit, unref, destroy, close, free, etc. functions now take a pointer to
Timo Sirainen <tss@iki.fi>
parents:
3863
diff
changeset
|
510 void auth_worker_client_unref(struct auth_worker_client **_client) |
3168
62f8366cb89c
Forgot to add for blocking passdb/userdb workers..
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
511 { |
3879
928229f8b3e6
deinit, unref, destroy, close, free, etc. functions now take a pointer to
Timo Sirainen <tss@iki.fi>
parents:
3863
diff
changeset
|
512 struct auth_worker_client *client = *_client; |
928229f8b3e6
deinit, unref, destroy, close, free, etc. functions now take a pointer to
Timo Sirainen <tss@iki.fi>
parents:
3863
diff
changeset
|
513 |
928229f8b3e6
deinit, unref, destroy, close, free, etc. functions now take a pointer to
Timo Sirainen <tss@iki.fi>
parents:
3863
diff
changeset
|
514 if (--client->refcount > 0) { |
928229f8b3e6
deinit, unref, destroy, close, free, etc. functions now take a pointer to
Timo Sirainen <tss@iki.fi>
parents:
3863
diff
changeset
|
515 *_client = NULL; |
3168
62f8366cb89c
Forgot to add for blocking passdb/userdb workers..
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
516 return; |
3879
928229f8b3e6
deinit, unref, destroy, close, free, etc. functions now take a pointer to
Timo Sirainen <tss@iki.fi>
parents:
3863
diff
changeset
|
517 } |
3168
62f8366cb89c
Forgot to add for blocking passdb/userdb workers..
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
518 |
3414
c2497d4c60c9
Auth workers were leaking memory for each request. Fixed also a few invalid
Timo Sirainen <tss@iki.fi>
parents:
3398
diff
changeset
|
519 if (client->fd != -1) |
3879
928229f8b3e6
deinit, unref, destroy, close, free, etc. functions now take a pointer to
Timo Sirainen <tss@iki.fi>
parents:
3863
diff
changeset
|
520 auth_worker_client_destroy(_client); |
3414
c2497d4c60c9
Auth workers were leaking memory for each request. Fixed also a few invalid
Timo Sirainen <tss@iki.fi>
parents:
3398
diff
changeset
|
521 |
3879
928229f8b3e6
deinit, unref, destroy, close, free, etc. functions now take a pointer to
Timo Sirainen <tss@iki.fi>
parents:
3863
diff
changeset
|
522 i_stream_unref(&client->input); |
928229f8b3e6
deinit, unref, destroy, close, free, etc. functions now take a pointer to
Timo Sirainen <tss@iki.fi>
parents:
3863
diff
changeset
|
523 o_stream_unref(&client->output); |
3168
62f8366cb89c
Forgot to add for blocking passdb/userdb workers..
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
524 i_free(client); |
62f8366cb89c
Forgot to add for blocking passdb/userdb workers..
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
525 } |