auth-worker-client.c revision cac0f62d29025e5493c53c1d26c6b00c88b089eb
02c335c23bf5fa225a467c19f2c063fb0dc7b8c3Timo Sirainen/* Copyright (c) 2005-2009 Dovecot authors, see the included COPYING file */
25757faf029c369a8318349dafe952e2358df1d8Timo Sirainenauth_worker_client_check_throttle(struct auth_worker_client *client)
25757faf029c369a8318349dafe952e2358df1d8Timo Sirainen if (o_stream_get_buffer_used_size(client->output) >=
25757faf029c369a8318349dafe952e2358df1d8Timo Sirainen /* stop reading new requests until client has read the pending
d1414c09cf0d58ac983054e2f4e1a1f329272dcfTimo Sirainenworker_auth_request_new(struct auth_worker_client *client, unsigned int id,
d1414c09cf0d58ac983054e2f4e1a1f329272dcfTimo Sirainen auth_request = auth_request_new_dummy(client->auth);
5965eaa2d972e6264cecaf54091cd43019bc7d1fTimo Sirainen for (tmp = t_strsplit(args, "\t"); *tmp != NULL; tmp++) {
e70d5895795732b8247ab9abb045b438e954bc46Timo Sirainen (void)auth_request_import(auth_request, key, value);
1ddec6312bc6882aeb17d4d46d19cbca1723b68bTimo Sirainenstatic void auth_worker_send_reply(struct auth_worker_client *client,
1ddec6312bc6882aeb17d4d46d19cbca1723b68bTimo Sirainen o_stream_send_str(client->output, "SHUTDOWN\n");
15cb9549422ccee416b21d26fec97a556ad0fa36Florian Zeitz o_stream_send(client->output, str_data(str), str_len(str));
1ddec6312bc6882aeb17d4d46d19cbca1723b68bTimo Sirainenstatic void verify_plain_callback(enum passdb_result result,
0469ed17dafcc56589ce00960a23f4f06817dfb5Timo Sirainen struct auth_worker_client *client = request->context;
2c38504860da8a8de915f8e0f5f39d7e7bd00cf8Timo Sirainen if (request->passdb_failure && result == PASSDB_RESULT_OK)
21c317a20c4c3784b54fb3e90ee3751870afdcc3Timo Sirainen reply = auth_stream_reply_init(pool_datastack_create());
21c317a20c4c3784b54fb3e90ee3751870afdcc3Timo Sirainen auth_stream_reply_add(reply, NULL, dec2str(request->id));
21c317a20c4c3784b54fb3e90ee3751870afdcc3Timo Sirainen if (result != PASSDB_RESULT_INTERNAL_FAILURE) {
21c317a20c4c3784b54fb3e90ee3751870afdcc3Timo Sirainen auth_stream_reply_add(reply, NULL, request->user);
21c317a20c4c3784b54fb3e90ee3751870afdcc3Timo Sirainen const char *fields =
21c317a20c4c3784b54fb3e90ee3751870afdcc3Timo Sirainen auth_stream_reply_export(request->extra_fields);
21c317a20c4c3784b54fb3e90ee3751870afdcc3Timo Sirainen const char *fields =
21c317a20c4c3784b54fb3e90ee3751870afdcc3Timo Sirainen auth_stream_reply_export(request->extra_cache_fields);
0cc875d28852d15005cff2a77252e7836c862a01Timo Sirainenauth_worker_handle_passv(struct auth_worker_client *client,
0cc875d28852d15005cff2a77252e7836c862a01Timo Sirainen /* verify plaintext password */
21c317a20c4c3784b54fb3e90ee3751870afdcc3Timo Sirainen i_error("BUG: Auth worker server sent us invalid PASSV");
21c317a20c4c3784b54fb3e90ee3751870afdcc3Timo Sirainen auth_request = worker_auth_request_new(client, id, args);
966cb0c1aa58578339cea6f79b4a423a851ab074Timo Sirainen if (auth_request->user == NULL || auth_request->service == NULL) {
21c317a20c4c3784b54fb3e90ee3751870afdcc3Timo Sirainen while (passdb != NULL && passdb->id != passdb_id)
21c317a20c4c3784b54fb3e90ee3751870afdcc3Timo Sirainen /* could be a masterdb */
966cb0c1aa58578339cea6f79b4a423a851ab074Timo Sirainen while (passdb != NULL && passdb->id != passdb_id)
21c317a20c4c3784b54fb3e90ee3751870afdcc3Timo Sirainen verify_plain(auth_request, password, verify_plain_callback);
21c317a20c4c3784b54fb3e90ee3751870afdcc3Timo Sirainenlookup_credentials_callback(enum passdb_result result,
4ac2e38bdb450d13b62be41638b12df9e0658009Stephan Bosch const unsigned char *credentials, size_t size,
4ac2e38bdb450d13b62be41638b12df9e0658009Stephan Bosch struct auth_worker_client *client = request->context;
4ac2e38bdb450d13b62be41638b12df9e0658009Stephan Bosch if (request->passdb_failure && result == PASSDB_RESULT_OK)
4ac2e38bdb450d13b62be41638b12df9e0658009Stephan Bosch reply = auth_stream_reply_init(pool_datastack_create());
4ac2e38bdb450d13b62be41638b12df9e0658009Stephan Bosch auth_stream_reply_add(reply, NULL, dec2str(request->id));
59beb411159176b39e48a52d60dd3239732e67b4Timo Sirainen auth_stream_reply_add(reply, NULL, request->user);
6e873f135368bcfdd1de4458dded791d0c4d00cdTimo Sirainen str_printfa(str, "{%s.b64}", request->credentials_scheme);
2c38504860da8a8de915f8e0f5f39d7e7bd00cf8Timo Sirainen auth_stream_reply_add(reply, NULL, str_c(str));
6e873f135368bcfdd1de4458dded791d0c4d00cdTimo Sirainen const char *fields =
6e873f135368bcfdd1de4458dded791d0c4d00cdTimo Sirainen auth_stream_reply_export(request->extra_fields);
97c339398f1aba6f315b55a9b6ee6b020e33bea4Timo Sirainen const char *fields =
97c339398f1aba6f315b55a9b6ee6b020e33bea4Timo Sirainen auth_stream_reply_export(request->extra_cache_fields);
a64adf62fa33f2463a86f990217b0c9078531a40Timo Sirainenauth_worker_handle_passl(struct auth_worker_client *client,
6e873f135368bcfdd1de4458dded791d0c4d00cdTimo Sirainen /* lookup credentials */
e9e2d23e1ea5a149a7d8828d2a45b9f2313c3785Timo Sirainen i_error("BUG: Auth worker server sent us invalid PASSL");
unsigned int passdb_id;
const char *data;
args++;
switch (result) {
case USERDB_RESULT_OK:
unsigned int num;
unsigned int id;
if (p == NULL)
return FALSE;
return TRUE;
char *line;
bool ret;
(int)AUTH_WORKER_MAX_LINE_LENGTH);
T_BEGIN {
} T_END;
if (!ret) {
struct auth_worker_client *
FALSE);
return client;