passdb-sql.c revision f93c833d644ecff0b0f80bee4f1cdde3e697b5c8
bcb4e51a409d94ae670de96afb8483a4f7855294Stephan Bosch/* Copyright (c) 2004-2011 Dovecot authors, see the included COPYING file */
678d0463849ba777106eb7875f27db07a5d8e3dfTimo Sirainen lookup_credentials_callback_t *lookup_credentials;
bd4e36a8cd7257cca7d1434c49a1e343ed7c5100Timo Sirainenstatic void sql_query_save_results(struct sql_result *result,
bd4e36a8cd7257cca7d1434c49a1e343ed7c5100Timo Sirainen struct auth_request *auth_request = sql_request->auth_request;
bd4e36a8cd7257cca7d1434c49a1e343ed7c5100Timo Sirainen struct passdb_module *_module = auth_request->passdb->passdb;
bd4e36a8cd7257cca7d1434c49a1e343ed7c5100Timo Sirainen struct sql_passdb_module *module = (struct sql_passdb_module *)_module;
bd4e36a8cd7257cca7d1434c49a1e343ed7c5100Timo Sirainen unsigned int i, fields_count;
bd4e36a8cd7257cca7d1434c49a1e343ed7c5100Timo Sirainen fields_count = sql_result_get_fields_count(result);
bd4e36a8cd7257cca7d1434c49a1e343ed7c5100Timo Sirainen for (i = 0; i < fields_count; i++) {
bd4e36a8cd7257cca7d1434c49a1e343ed7c5100Timo Sirainen value = sql_result_get_field_value(result, i);
678d0463849ba777106eb7875f27db07a5d8e3dfTimo Sirainen auth_request_set_field(auth_request, name, value,
bd4e36a8cd7257cca7d1434c49a1e343ed7c5100Timo Sirainenstatic void sql_query_callback(struct sql_result *result,
d6499957ea59e6d9729d3350d9ac5eae992635f6Timo Sirainen struct auth_request *auth_request = sql_request->auth_request;
4c0aff96fc7e6d779be43458f96cbf015849a3deTimo Sirainen struct passdb_module *_module = auth_request->passdb->passdb;
bd4e36a8cd7257cca7d1434c49a1e343ed7c5100Timo Sirainen struct sql_passdb_module *module = (struct sql_passdb_module *)_module;
bd4e36a8cd7257cca7d1434c49a1e343ed7c5100Timo Sirainen passdb_result = PASSDB_RESULT_INTERNAL_FAILURE;
bf7dc750b95039981c0e9d728f313d50cf38a156Martti Rannanjärvi "Password query failed: %s",
2a6c02a5e7e5cdf4980befbfaf372603ce338a25Timo Sirainen "Password query failed: %s "
2a6c02a5e7e5cdf4980befbfaf372603ce338a25Timo Sirainen "(using built-in default password_query: %s)",
bd4e36a8cd7257cca7d1434c49a1e343ed7c5100Timo Sirainen } else if (ret == 0) {
bd4e36a8cd7257cca7d1434c49a1e343ed7c5100Timo Sirainen auth_request_log_info(auth_request, "sql", "unknown user");
bd4e36a8cd7257cca7d1434c49a1e343ed7c5100Timo Sirainen /* Note that we really want to check if the password field is
bd4e36a8cd7257cca7d1434c49a1e343ed7c5100Timo Sirainen found. Just checking if password is set isn't enough,
bd4e36a8cd7257cca7d1434c49a1e343ed7c5100Timo Sirainen because with proxies we might want to return NULL as
bd4e36a8cd7257cca7d1434c49a1e343ed7c5100Timo Sirainen if (sql_result_find_field(result, "password") < 0 &&
const char *new_credentials,
static struct passdb_module *