Mercurial > dovecot > original-hg > dovecot-1.2
annotate src/auth/passdb-blocking.c @ 8999:afc1b0ef120d HEAD
When :MAILBOXDIR= was empty, we might have appended extra '/' to it, which caused problems.
author | Timo Sirainen <tss@iki.fi> |
---|---|
date | Thu, 30 Apr 2009 20:00:09 -0400 |
parents | b9faf4db2a9f |
children | 00cd9aacd03c |
rev | line source |
---|---|
8590
b9faf4db2a9f
Updated copyright notices to include year 2009.
Timo Sirainen <tss@iki.fi>
parents:
7388
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" |
62f8366cb89c
Forgot to add for blocking passdb/userdb workers..
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
4 #include "str.h" |
62f8366cb89c
Forgot to add for blocking passdb/userdb workers..
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
5 #include "auth-worker-server.h" |
62f8366cb89c
Forgot to add for blocking passdb/userdb workers..
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
6 #include "password-scheme.h" |
62f8366cb89c
Forgot to add for blocking passdb/userdb workers..
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
7 #include "passdb.h" |
62f8366cb89c
Forgot to add for blocking passdb/userdb workers..
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
8 #include "passdb-blocking.h" |
62f8366cb89c
Forgot to add for blocking passdb/userdb workers..
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
9 |
62f8366cb89c
Forgot to add for blocking passdb/userdb workers..
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
10 #include <stdlib.h> |
62f8366cb89c
Forgot to add for blocking passdb/userdb workers..
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
11 |
6214
974066ba68a3
Pass extra_fields from auth worker to server also if authentication failed.
Timo Sirainen <tss@iki.fi>
parents:
6213
diff
changeset
|
12 static void |
974066ba68a3
Pass extra_fields from auth worker to server also if authentication failed.
Timo Sirainen <tss@iki.fi>
parents:
6213
diff
changeset
|
13 auth_worker_reply_parse_args(struct auth_request *request, |
974066ba68a3
Pass extra_fields from auth worker to server also if authentication failed.
Timo Sirainen <tss@iki.fi>
parents:
6213
diff
changeset
|
14 const char *const *args) |
3168
62f8366cb89c
Forgot to add for blocking passdb/userdb workers..
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
15 { |
6214
974066ba68a3
Pass extra_fields from auth worker to server also if authentication failed.
Timo Sirainen <tss@iki.fi>
parents:
6213
diff
changeset
|
16 if (**args != '\0') |
974066ba68a3
Pass extra_fields from auth worker to server also if authentication failed.
Timo Sirainen <tss@iki.fi>
parents:
6213
diff
changeset
|
17 request->passdb_password = p_strdup(request->pool, *args); |
974066ba68a3
Pass extra_fields from auth worker to server also if authentication failed.
Timo Sirainen <tss@iki.fi>
parents:
6213
diff
changeset
|
18 args++; |
3168
62f8366cb89c
Forgot to add for blocking passdb/userdb workers..
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
19 |
6214
974066ba68a3
Pass extra_fields from auth worker to server also if authentication failed.
Timo Sirainen <tss@iki.fi>
parents:
6213
diff
changeset
|
20 if (*args != NULL) { |
974066ba68a3
Pass extra_fields from auth worker to server also if authentication failed.
Timo Sirainen <tss@iki.fi>
parents:
6213
diff
changeset
|
21 i_assert(auth_stream_is_empty(request->extra_fields) || |
974066ba68a3
Pass extra_fields from auth worker to server also if authentication failed.
Timo Sirainen <tss@iki.fi>
parents:
6213
diff
changeset
|
22 request->master_user != NULL); |
974066ba68a3
Pass extra_fields from auth worker to server also if authentication failed.
Timo Sirainen <tss@iki.fi>
parents:
6213
diff
changeset
|
23 auth_request_set_fields(request, args, NULL); |
3168
62f8366cb89c
Forgot to add for blocking passdb/userdb workers..
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
24 } |
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 |
6214
974066ba68a3
Pass extra_fields from auth worker to server also if authentication failed.
Timo Sirainen <tss@iki.fi>
parents:
6213
diff
changeset
|
27 static enum passdb_result |
974066ba68a3
Pass extra_fields from auth worker to server also if authentication failed.
Timo Sirainen <tss@iki.fi>
parents:
6213
diff
changeset
|
28 auth_worker_reply_parse(struct auth_request *request, const char *reply) |
3168
62f8366cb89c
Forgot to add for blocking passdb/userdb workers..
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
29 { |
6214
974066ba68a3
Pass extra_fields from auth worker to server also if authentication failed.
Timo Sirainen <tss@iki.fi>
parents:
6213
diff
changeset
|
30 enum passdb_result ret; |
974066ba68a3
Pass extra_fields from auth worker to server also if authentication failed.
Timo Sirainen <tss@iki.fi>
parents:
6213
diff
changeset
|
31 const char *const *args; |
4692
7728291a7f52
If blocking passdb (ie. MySQL) didn't return any extra fields, we didn't
Timo Sirainen <tss@iki.fi>
parents:
4030
diff
changeset
|
32 |
6214
974066ba68a3
Pass extra_fields from auth worker to server also if authentication failed.
Timo Sirainen <tss@iki.fi>
parents:
6213
diff
changeset
|
33 args = t_strsplit(reply, "\t"); |
974066ba68a3
Pass extra_fields from auth worker to server also if authentication failed.
Timo Sirainen <tss@iki.fi>
parents:
6213
diff
changeset
|
34 |
974066ba68a3
Pass extra_fields from auth worker to server also if authentication failed.
Timo Sirainen <tss@iki.fi>
parents:
6213
diff
changeset
|
35 if (strcmp(*args, "OK") == 0 && args[1] != NULL && args[2] != NULL) { |
974066ba68a3
Pass extra_fields from auth worker to server also if authentication failed.
Timo Sirainen <tss@iki.fi>
parents:
6213
diff
changeset
|
36 /* OK \t user \t password [\t extra] */ |
974066ba68a3
Pass extra_fields from auth worker to server also if authentication failed.
Timo Sirainen <tss@iki.fi>
parents:
6213
diff
changeset
|
37 auth_request_set_field(request, "user", args[1], NULL); |
974066ba68a3
Pass extra_fields from auth worker to server also if authentication failed.
Timo Sirainen <tss@iki.fi>
parents:
6213
diff
changeset
|
38 auth_worker_reply_parse_args(request, args + 2); |
974066ba68a3
Pass extra_fields from auth worker to server also if authentication failed.
Timo Sirainen <tss@iki.fi>
parents:
6213
diff
changeset
|
39 return PASSDB_RESULT_OK; |
4692
7728291a7f52
If blocking passdb (ie. MySQL) didn't return any extra fields, we didn't
Timo Sirainen <tss@iki.fi>
parents:
4030
diff
changeset
|
40 } |
3168
62f8366cb89c
Forgot to add for blocking passdb/userdb workers..
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
41 |
6436
fd7ffed49763
Transfer also userdb information from blocking passdb workers, so prefetch
Timo Sirainen <tss@iki.fi>
parents:
6429
diff
changeset
|
42 if (strcmp(*args, "FAIL") == 0 && args[1] != NULL) { |
fd7ffed49763
Transfer also userdb information from blocking passdb workers, so prefetch
Timo Sirainen <tss@iki.fi>
parents:
6429
diff
changeset
|
43 /* FAIL \t result [\t user \t password [\t extra]] */ |
6214
974066ba68a3
Pass extra_fields from auth worker to server also if authentication failed.
Timo Sirainen <tss@iki.fi>
parents:
6213
diff
changeset
|
44 ret = atoi(args[1]); |
6436
fd7ffed49763
Transfer also userdb information from blocking passdb workers, so prefetch
Timo Sirainen <tss@iki.fi>
parents:
6429
diff
changeset
|
45 if (ret == PASSDB_RESULT_OK) { |
fd7ffed49763
Transfer also userdb information from blocking passdb workers, so prefetch
Timo Sirainen <tss@iki.fi>
parents:
6429
diff
changeset
|
46 /* shouldn't happen */ |
fd7ffed49763
Transfer also userdb information from blocking passdb workers, so prefetch
Timo Sirainen <tss@iki.fi>
parents:
6429
diff
changeset
|
47 } else if (args[2] == NULL) { |
fd7ffed49763
Transfer also userdb information from blocking passdb workers, so prefetch
Timo Sirainen <tss@iki.fi>
parents:
6429
diff
changeset
|
48 /* internal failure most likely */ |
fd7ffed49763
Transfer also userdb information from blocking passdb workers, so prefetch
Timo Sirainen <tss@iki.fi>
parents:
6429
diff
changeset
|
49 return ret; |
fd7ffed49763
Transfer also userdb information from blocking passdb workers, so prefetch
Timo Sirainen <tss@iki.fi>
parents:
6429
diff
changeset
|
50 } else if (args[3] != NULL) { |
fd7ffed49763
Transfer also userdb information from blocking passdb workers, so prefetch
Timo Sirainen <tss@iki.fi>
parents:
6429
diff
changeset
|
51 auth_request_set_field(request, "user", args[2], NULL); |
fd7ffed49763
Transfer also userdb information from blocking passdb workers, so prefetch
Timo Sirainen <tss@iki.fi>
parents:
6429
diff
changeset
|
52 auth_worker_reply_parse_args(request, args + 3); |
6214
974066ba68a3
Pass extra_fields from auth worker to server also if authentication failed.
Timo Sirainen <tss@iki.fi>
parents:
6213
diff
changeset
|
53 return ret; |
3168
62f8366cb89c
Forgot to add for blocking passdb/userdb workers..
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
54 } |
62f8366cb89c
Forgot to add for blocking passdb/userdb workers..
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
55 } |
62f8366cb89c
Forgot to add for blocking passdb/userdb workers..
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
56 |
6214
974066ba68a3
Pass extra_fields from auth worker to server also if authentication failed.
Timo Sirainen <tss@iki.fi>
parents:
6213
diff
changeset
|
57 auth_request_log_error(request, "blocking", |
974066ba68a3
Pass extra_fields from auth worker to server also if authentication failed.
Timo Sirainen <tss@iki.fi>
parents:
6213
diff
changeset
|
58 "Received invalid reply from worker: %s", reply); |
974066ba68a3
Pass extra_fields from auth worker to server also if authentication failed.
Timo Sirainen <tss@iki.fi>
parents:
6213
diff
changeset
|
59 return PASSDB_RESULT_INTERNAL_FAILURE; |
3168
62f8366cb89c
Forgot to add for blocking passdb/userdb workers..
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
60 } |
62f8366cb89c
Forgot to add for blocking passdb/userdb workers..
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
61 |
62f8366cb89c
Forgot to add for blocking passdb/userdb workers..
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
62 static void |
62f8366cb89c
Forgot to add for blocking passdb/userdb workers..
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
63 verify_plain_callback(struct auth_request *request, const char *reply) |
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 enum passdb_result result; |
62f8366cb89c
Forgot to add for blocking passdb/userdb workers..
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
66 |
6214
974066ba68a3
Pass extra_fields from auth worker to server also if authentication failed.
Timo Sirainen <tss@iki.fi>
parents:
6213
diff
changeset
|
67 result = auth_worker_reply_parse(request, reply); |
3168
62f8366cb89c
Forgot to add for blocking passdb/userdb workers..
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
68 auth_request_verify_plain_callback(result, request); |
62f8366cb89c
Forgot to add for blocking passdb/userdb workers..
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
69 } |
62f8366cb89c
Forgot to add for blocking passdb/userdb workers..
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
70 |
62f8366cb89c
Forgot to add for blocking passdb/userdb workers..
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
71 void passdb_blocking_verify_plain(struct auth_request *request) |
62f8366cb89c
Forgot to add for blocking passdb/userdb workers..
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
72 { |
7388
08d31d752893
Use auth-stream API to build all TAB-delimited strings to make sure strings
Timo Sirainen <tss@iki.fi>
parents:
7086
diff
changeset
|
73 struct auth_stream_reply *reply; |
3168
62f8366cb89c
Forgot to add for blocking passdb/userdb workers..
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
74 |
5105 | 75 i_assert(auth_stream_is_empty(request->extra_fields) || |
76 request->master_user != NULL); | |
3171
8a3b57385eca
Added state variable for auth_request and several assertions to make sure
Timo Sirainen <tss@iki.fi>
parents:
3168
diff
changeset
|
77 |
7388
08d31d752893
Use auth-stream API to build all TAB-delimited strings to make sure strings
Timo Sirainen <tss@iki.fi>
parents:
7086
diff
changeset
|
78 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:
7086
diff
changeset
|
79 auth_stream_reply_add(reply, "PASSV", NULL); |
08d31d752893
Use auth-stream API to build all TAB-delimited strings to make sure strings
Timo Sirainen <tss@iki.fi>
parents:
7086
diff
changeset
|
80 auth_stream_reply_add(reply, NULL, dec2str(request->passdb->id)); |
08d31d752893
Use auth-stream API to build all TAB-delimited strings to make sure strings
Timo Sirainen <tss@iki.fi>
parents:
7086
diff
changeset
|
81 auth_stream_reply_add(reply, NULL, request->mech_password); |
08d31d752893
Use auth-stream API to build all TAB-delimited strings to make sure strings
Timo Sirainen <tss@iki.fi>
parents:
7086
diff
changeset
|
82 auth_request_export(request, reply); |
3168
62f8366cb89c
Forgot to add for blocking passdb/userdb workers..
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
83 |
7388
08d31d752893
Use auth-stream API to build all TAB-delimited strings to make sure strings
Timo Sirainen <tss@iki.fi>
parents:
7086
diff
changeset
|
84 auth_worker_call(request, reply, verify_plain_callback); |
3168
62f8366cb89c
Forgot to add for blocking passdb/userdb workers..
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
85 } |
62f8366cb89c
Forgot to add for blocking passdb/userdb workers..
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
86 |
62f8366cb89c
Forgot to add for blocking passdb/userdb workers..
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
87 static void |
62f8366cb89c
Forgot to add for blocking passdb/userdb workers..
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
88 lookup_credentials_callback(struct auth_request *request, const char *reply) |
62f8366cb89c
Forgot to add for blocking passdb/userdb workers..
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
89 { |
62f8366cb89c
Forgot to add for blocking passdb/userdb workers..
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
90 enum passdb_result result; |
4704
3bfd724bb37a
Fixes to handling blocking passdb (ie. MySQL) failures. It ignored any
Timo Sirainen <tss@iki.fi>
parents:
4692
diff
changeset
|
91 const char *password = NULL, *scheme = NULL; |
3168
62f8366cb89c
Forgot to add for blocking passdb/userdb workers..
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
92 |
6214
974066ba68a3
Pass extra_fields from auth worker to server also if authentication failed.
Timo Sirainen <tss@iki.fi>
parents:
6213
diff
changeset
|
93 result = auth_worker_reply_parse(request, reply); |
974066ba68a3
Pass extra_fields from auth worker to server also if authentication failed.
Timo Sirainen <tss@iki.fi>
parents:
6213
diff
changeset
|
94 if (result == PASSDB_RESULT_OK && request->passdb_password != NULL) { |
974066ba68a3
Pass extra_fields from auth worker to server also if authentication failed.
Timo Sirainen <tss@iki.fi>
parents:
6213
diff
changeset
|
95 password = request->passdb_password; |
974066ba68a3
Pass extra_fields from auth worker to server also if authentication failed.
Timo Sirainen <tss@iki.fi>
parents:
6213
diff
changeset
|
96 scheme = password_get_scheme(&password); |
974066ba68a3
Pass extra_fields from auth worker to server also if authentication failed.
Timo Sirainen <tss@iki.fi>
parents:
6213
diff
changeset
|
97 if (scheme == NULL) { |
974066ba68a3
Pass extra_fields from auth worker to server also if authentication failed.
Timo Sirainen <tss@iki.fi>
parents:
6213
diff
changeset
|
98 auth_request_log_error(request, "blocking", |
974066ba68a3
Pass extra_fields from auth worker to server also if authentication failed.
Timo Sirainen <tss@iki.fi>
parents:
6213
diff
changeset
|
99 "Received reply from worker without " |
974066ba68a3
Pass extra_fields from auth worker to server also if authentication failed.
Timo Sirainen <tss@iki.fi>
parents:
6213
diff
changeset
|
100 "password scheme"); |
3168
62f8366cb89c
Forgot to add for blocking passdb/userdb workers..
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
101 result = PASSDB_RESULT_INTERNAL_FAILURE; |
6214
974066ba68a3
Pass extra_fields from auth worker to server also if authentication failed.
Timo Sirainen <tss@iki.fi>
parents:
6213
diff
changeset
|
102 } |
3168
62f8366cb89c
Forgot to add for blocking passdb/userdb workers..
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
103 } |
62f8366cb89c
Forgot to add for blocking passdb/userdb workers..
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
104 |
3655
62fc6883faeb
Fixes and cleanups to credentials handling. Also fixed auth caching to work
Timo Sirainen <tss@iki.fi>
parents:
3635
diff
changeset
|
105 passdb_handle_credentials(result, password, scheme, |
3168
62f8366cb89c
Forgot to add for blocking passdb/userdb workers..
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
106 auth_request_lookup_credentials_callback, |
62f8366cb89c
Forgot to add for blocking passdb/userdb workers..
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
107 request); |
62f8366cb89c
Forgot to add for blocking passdb/userdb workers..
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
108 } |
62f8366cb89c
Forgot to add for blocking passdb/userdb workers..
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
109 |
62f8366cb89c
Forgot to add for blocking passdb/userdb workers..
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
110 void passdb_blocking_lookup_credentials(struct auth_request *request) |
62f8366cb89c
Forgot to add for blocking passdb/userdb workers..
Timo Sirainen <tss@iki.fi>
parents:
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:
7086
diff
changeset
|
112 struct auth_stream_reply *reply; |
3168
62f8366cb89c
Forgot to add for blocking passdb/userdb workers..
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
113 |
5105 | 114 i_assert(auth_stream_is_empty(request->extra_fields) || |
115 request->master_user != NULL); | |
3171
8a3b57385eca
Added state variable for auth_request and several assertions to make sure
Timo Sirainen <tss@iki.fi>
parents:
3168
diff
changeset
|
116 |
7388
08d31d752893
Use auth-stream API to build all TAB-delimited strings to make sure strings
Timo Sirainen <tss@iki.fi>
parents:
7086
diff
changeset
|
117 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:
7086
diff
changeset
|
118 auth_stream_reply_add(reply, "PASSL", NULL); |
08d31d752893
Use auth-stream API to build all TAB-delimited strings to make sure strings
Timo Sirainen <tss@iki.fi>
parents:
7086
diff
changeset
|
119 auth_stream_reply_add(reply, NULL, dec2str(request->passdb->id)); |
08d31d752893
Use auth-stream API to build all TAB-delimited strings to make sure strings
Timo Sirainen <tss@iki.fi>
parents:
7086
diff
changeset
|
120 auth_stream_reply_add(reply, NULL, request->credentials_scheme); |
08d31d752893
Use auth-stream API to build all TAB-delimited strings to make sure strings
Timo Sirainen <tss@iki.fi>
parents:
7086
diff
changeset
|
121 auth_request_export(request, reply); |
3168
62f8366cb89c
Forgot to add for blocking passdb/userdb workers..
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
122 |
7388
08d31d752893
Use auth-stream API to build all TAB-delimited strings to make sure strings
Timo Sirainen <tss@iki.fi>
parents:
7086
diff
changeset
|
123 auth_worker_call(request, reply, lookup_credentials_callback); |
3168
62f8366cb89c
Forgot to add for blocking passdb/userdb workers..
Timo Sirainen <tss@iki.fi>
parents:
diff
changeset
|
124 } |
4782
2c1cc5bbc260
Added auth_request_set_credentials() to modify credentials in passdb and
Timo Sirainen <tss@iki.fi>
parents:
4704
diff
changeset
|
125 |
2c1cc5bbc260
Added auth_request_set_credentials() to modify credentials in passdb and
Timo Sirainen <tss@iki.fi>
parents:
4704
diff
changeset
|
126 static void |
2c1cc5bbc260
Added auth_request_set_credentials() to modify credentials in passdb and
Timo Sirainen <tss@iki.fi>
parents:
4704
diff
changeset
|
127 set_credentials_callback(struct auth_request *request, const char *reply) |
2c1cc5bbc260
Added auth_request_set_credentials() to modify credentials in passdb and
Timo Sirainen <tss@iki.fi>
parents:
4704
diff
changeset
|
128 { |
6213
e33a87152c41
Changed set_credentials() callback to take a bool success instead of
Timo Sirainen <tss@iki.fi>
parents:
5593
diff
changeset
|
129 bool success; |
4782
2c1cc5bbc260
Added auth_request_set_credentials() to modify credentials in passdb and
Timo Sirainen <tss@iki.fi>
parents:
4704
diff
changeset
|
130 |
6213
e33a87152c41
Changed set_credentials() callback to take a bool success instead of
Timo Sirainen <tss@iki.fi>
parents:
5593
diff
changeset
|
131 success = strcmp(reply, "OK") == 0 || strncmp(reply, "OK\t", 3) == 0; |
e33a87152c41
Changed set_credentials() callback to take a bool success instead of
Timo Sirainen <tss@iki.fi>
parents:
5593
diff
changeset
|
132 request->private_callback.set_credentials(success, request); |
4782
2c1cc5bbc260
Added auth_request_set_credentials() to modify credentials in passdb and
Timo Sirainen <tss@iki.fi>
parents:
4704
diff
changeset
|
133 } |
2c1cc5bbc260
Added auth_request_set_credentials() to modify credentials in passdb and
Timo Sirainen <tss@iki.fi>
parents:
4704
diff
changeset
|
134 |
2c1cc5bbc260
Added auth_request_set_credentials() to modify credentials in passdb and
Timo Sirainen <tss@iki.fi>
parents:
4704
diff
changeset
|
135 void passdb_blocking_set_credentials(struct auth_request *request, |
2c1cc5bbc260
Added auth_request_set_credentials() to modify credentials in passdb and
Timo Sirainen <tss@iki.fi>
parents:
4704
diff
changeset
|
136 const char *new_credentials) |
2c1cc5bbc260
Added auth_request_set_credentials() to modify credentials in passdb and
Timo Sirainen <tss@iki.fi>
parents:
4704
diff
changeset
|
137 { |
7388
08d31d752893
Use auth-stream API to build all TAB-delimited strings to make sure strings
Timo Sirainen <tss@iki.fi>
parents:
7086
diff
changeset
|
138 struct auth_stream_reply *reply; |
4782
2c1cc5bbc260
Added auth_request_set_credentials() to modify credentials in passdb and
Timo Sirainen <tss@iki.fi>
parents:
4704
diff
changeset
|
139 |
7388
08d31d752893
Use auth-stream API to build all TAB-delimited strings to make sure strings
Timo Sirainen <tss@iki.fi>
parents:
7086
diff
changeset
|
140 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:
7086
diff
changeset
|
141 auth_stream_reply_add(reply, "SETCRED", NULL); |
08d31d752893
Use auth-stream API to build all TAB-delimited strings to make sure strings
Timo Sirainen <tss@iki.fi>
parents:
7086
diff
changeset
|
142 auth_stream_reply_add(reply, NULL, dec2str(request->passdb->id)); |
08d31d752893
Use auth-stream API to build all TAB-delimited strings to make sure strings
Timo Sirainen <tss@iki.fi>
parents:
7086
diff
changeset
|
143 auth_stream_reply_add(reply, NULL, new_credentials); |
08d31d752893
Use auth-stream API to build all TAB-delimited strings to make sure strings
Timo Sirainen <tss@iki.fi>
parents:
7086
diff
changeset
|
144 auth_request_export(request, reply); |
4782
2c1cc5bbc260
Added auth_request_set_credentials() to modify credentials in passdb and
Timo Sirainen <tss@iki.fi>
parents:
4704
diff
changeset
|
145 |
7388
08d31d752893
Use auth-stream API to build all TAB-delimited strings to make sure strings
Timo Sirainen <tss@iki.fi>
parents:
7086
diff
changeset
|
146 auth_worker_call(request, reply, set_credentials_callback); |
4782
2c1cc5bbc260
Added auth_request_set_credentials() to modify credentials in passdb and
Timo Sirainen <tss@iki.fi>
parents:
4704
diff
changeset
|
147 } |