passdb-blocking.c revision 5d4855d7b4dcffb6975ed8e3c9c376dac74e5c8a
7cb128dc4cae2a03a742f63ba7afee23c78e3af0Phil Carmody/* Copyright (C) 2005 Timo Sirainen */
ecc81625167ed96c04c02aa190a1ea5baa65b474Timo Sirainenauth_worker_reply_parse_args(struct auth_request *request,
ecc81625167ed96c04c02aa190a1ea5baa65b474Timo Sirainen const char *const *args)
ecc81625167ed96c04c02aa190a1ea5baa65b474Timo Sirainen request->passdb_password = p_strdup(request->pool, *args);
ecc81625167ed96c04c02aa190a1ea5baa65b474Timo Sirainen i_assert(auth_stream_is_empty(request->extra_fields) ||
ecc81625167ed96c04c02aa190a1ea5baa65b474Timo Sirainenauth_worker_reply_parse(struct auth_request *request, const char *reply)
09801f106cd531a28b4e03ec665e44c421264560Timo Sirainen const char *const *args;
09801f106cd531a28b4e03ec665e44c421264560Timo Sirainen if (strcmp(*args, "OK") == 0 && args[1] != NULL && args[2] != NULL) {
1c6f6f5bef70f16546b3bc8f4cd5f93f373e82a2Timo Sirainen /* OK \t user \t password [\t extra] */
1c6f6f5bef70f16546b3bc8f4cd5f93f373e82a2Timo Sirainen auth_request_set_field(request, "user", args[1], NULL);
09801f106cd531a28b4e03ec665e44c421264560Timo Sirainen auth_worker_reply_parse_args(request, args + 2);
09801f106cd531a28b4e03ec665e44c421264560Timo Sirainen if (strcmp(*args, "FAIL") == 0 && args[1] != NULL && args[2] != NULL) {
09801f106cd531a28b4e03ec665e44c421264560Timo Sirainen /* FAIL \t result \t password [\t extra] */
c0435c854a0e7246373b9752d163095cc4fbe985Timo Sirainen auth_worker_reply_parse_args(request, args + 2);
14175321ddb88619015866978c05a27786ca4814Timo Sirainen "Received invalid reply from worker: %s", reply);
09801f106cd531a28b4e03ec665e44c421264560Timo Sirainenverify_plain_callback(struct auth_request *request, const char *reply)
c06f4017027263cf3a08becc551f5126409e2a83Timo Sirainen result = auth_worker_reply_parse(request, reply);
1060afdc2fcdf647dbb3bc11647401f1b44a3a8aTimo Sirainen auth_request_verify_plain_callback(result, request);
8edc373587d75f8040e3c4416e50638aa2a32188Timo Sirainenvoid passdb_blocking_verify_plain(struct auth_request *request)
c06f4017027263cf3a08becc551f5126409e2a83Timo Sirainen i_assert(auth_stream_is_empty(request->extra_fields) ||
c9bf63e9094761767a63ac6b189bcf60bcffdc44Timo Sirainen str_printfa(str, "PASSV\t%u\t", request->passdb->id);
8edc373587d75f8040e3c4416e50638aa2a32188Timo Sirainen auth_worker_call(request, str_c(str), verify_plain_callback);
c9bf63e9094761767a63ac6b189bcf60bcffdc44Timo Sirainenlookup_credentials_callback(struct auth_request *request, const char *reply)
c09f9f95db314e7482c95e502e1c56ed6c555797Timo Sirainen result = auth_worker_reply_parse(request, reply);
9f131c8b6d88ffc65d94eae63e0b3c11d7c24cb9Timo Sirainen if (result == PASSDB_RESULT_OK && request->passdb_password != NULL) {
5024c4799b324ea15270152b775c67ccfc72d5bcTimo Sirainen "Received reply from worker without "
5024c4799b324ea15270152b775c67ccfc72d5bcTimo Sirainen "password scheme");
5024c4799b324ea15270152b775c67ccfc72d5bcTimo Sirainen passdb_handle_credentials(result, password, scheme,
2767104d81e97a109f0aa9758792bfa1da325a97Timo Sirainenvoid passdb_blocking_lookup_credentials(struct auth_request *request)
2767104d81e97a109f0aa9758792bfa1da325a97Timo Sirainen i_assert(auth_stream_is_empty(request->extra_fields) ||
2767104d81e97a109f0aa9758792bfa1da325a97Timo Sirainen request->passdb->id, request->credentials_scheme);
2767104d81e97a109f0aa9758792bfa1da325a97Timo Sirainen auth_worker_call(request, str_c(str), lookup_credentials_callback);
ecc81625167ed96c04c02aa190a1ea5baa65b474Timo Sirainenset_credentials_callback(struct auth_request *request, const char *reply)
ecc81625167ed96c04c02aa190a1ea5baa65b474Timo Sirainen success = strcmp(reply, "OK") == 0 || strncmp(reply, "OK\t", 3) == 0;
ecc81625167ed96c04c02aa190a1ea5baa65b474Timo Sirainen request->private_callback.set_credentials(success, request);
a94936bafd127680184da114c6a177b37ff656e5Timo Sirainenvoid passdb_blocking_set_credentials(struct auth_request *request,