userdb-blocking.c revision f3c4f76a22b71b3c76c7f586db40b04e75564c2c
a8c5a86d183db25a57bf193c06b41e092ec2e151Timo Sirainen/* Copyright (c) 2005-2014 Dovecot authors, see the included COPYING file */
43d3ea2780b5f8557ede7b4c039e8f56cb8d357dTimo Sirainenstatic bool user_callback(const char *reply, void *context)
3313a51ef9b245248d672c20f930c52a577a42f7Timo Sirainen } else if (strncmp(reply, "NOTFOUND\t", 9) == 0) {
0f39a57760d93cddbce3ca43096d78e0fe2f42fdTimo Sirainen i_error("BUG: auth-worker sent invalid user reply");
5c253723e8ef84cb71a80ced19efe597e8a90ea6Timo Sirainen request->userdb_reply = auth_fields_init(request->pool);
ee6df9526e9716b3f1734d85b566e00fc41208bcTimo Sirainen auth_fields_import(request->userdb_reply, args, 0);
ee6df9526e9716b3f1734d85b566e00fc41208bcTimo Sirainen if (auth_fields_exists(request->userdb_reply, "tempfail"))
6fabfb7bbfd88d0c1de66981e52850f26067623bTimo Sirainen auth_request_userdb_callback(result, request);
e9503210d3521a6833ed62dc332fc42ffb0e7a13Timo Sirainenvoid userdb_blocking_lookup(struct auth_request *request)
b0e9375a1ff97c9c7d40655922af5ccc73ecaa76Timo Sirainen str_printfa(str, "USER\t%u\t", request->userdb->userdb->id);
f08c6da58d4cffc5b4777485ebc475dff614e491Timo Sirainen auth_worker_call(request->pool, request->user,
43d3ea2780b5f8557ede7b4c039e8f56cb8d357dTimo Sirainenstatic bool iter_callback(const char *reply, void *context)
43d3ea2780b5f8557ede7b4c039e8f56cb8d357dTimo Sirainen struct blocking_userdb_iterate_context *ctx = context;
43d3ea2780b5f8557ede7b4c039e8f56cb8d357dTimo Sirainen ctx->ctx.callback(reply + 2, ctx->ctx.context);
e9371f899a3d4207a0ffd3923ea5ec7250cf5e75Timo Sirainenuserdb_blocking_iter_init(struct auth_request *request,
43d3ea2780b5f8557ede7b4c039e8f56cb8d357dTimo Sirainen userdb_iter_callback_t *callback, void *context)
b0e9375a1ff97c9c7d40655922af5ccc73ecaa76Timo Sirainen str_printfa(str, "LIST\t%u\t", request->userdb->userdb->id);
e9371f899a3d4207a0ffd3923ea5ec7250cf5e75Timo Sirainen ctx = p_new(request->pool, struct blocking_userdb_iterate_context, 1);
f08c6da58d4cffc5b4777485ebc475dff614e491Timo Sirainen ctx->conn = auth_worker_call(request->pool, "*",
43d3ea2780b5f8557ede7b4c039e8f56cb8d357dTimo Sirainenvoid userdb_blocking_iter_next(struct userdb_iterate_context *_ctx)
43d3ea2780b5f8557ede7b4c039e8f56cb8d357dTimo Sirainen (struct blocking_userdb_iterate_context *)_ctx;
43d3ea2780b5f8557ede7b4c039e8f56cb8d357dTimo Sirainenint userdb_blocking_iter_deinit(struct userdb_iterate_context **_ctx)
43d3ea2780b5f8557ede7b4c039e8f56cb8d357dTimo Sirainen (struct blocking_userdb_iterate_context *)*_ctx;
e9371f899a3d4207a0ffd3923ea5ec7250cf5e75Timo Sirainen /* iter_callback() may still be called */