userdb-sql.c revision 7af2a19a89c1c9da8848c570190d36570afd09e6
/* Copyright (c) 2004-2010 Dovecot authors, see the included COPYING file */
#include "auth-common.h"
#include "userdb.h"
#ifdef USERDB_SQL
#include "str.h"
#include "strescape.h"
#include "var-expand.h"
#include "auth-cache.h"
#include "db-sql.h"
#include <stdlib.h>
#include <string.h>
struct sql_userdb_module {
struct userdb_module module;
struct sql_connection *conn;
};
struct userdb_sql_request {
struct auth_request *auth_request;
};
struct sql_userdb_iterate_context {
struct userdb_iterate_context ctx;
struct sql_result *result;
unsigned int freed:1;
unsigned int call_iter:1;
};
static void
struct auth_request *auth_request)
{
unsigned int i, fields_count;
for (i = 0; i < fields_count; i++) {
}
}
}
struct userdb_sql_request *sql_request)
{
struct sql_userdb_module *module =
(struct sql_userdb_module *)_module;
int ret;
if (ret < 0) {
"User query failed: %s",
} else {
"User query failed: %s "
"(using built-in default user_query: %s)",
}
} else if (ret == 0) {
} else {
}
}
static const char *
{
struct sql_userdb_module *module =
(struct sql_userdb_module *)_module;
}
{
struct sql_userdb_module *module =
(struct sql_userdb_module *)_module;
struct userdb_sql_request *sql_request;
}
struct sql_userdb_iterate_context *ctx)
{
}
static struct userdb_iterate_context *
{
static struct var_expand_table static_tab[] = {
/* nothing for now, but e.g. %{hostname} can be used */
};
struct sql_userdb_module *module =
(struct sql_userdb_module *)userdb;
struct sql_userdb_iterate_context *ctx;
}
const char **user_r)
{
const char *domain;
int idx;
/* try user first */
if (idx == 0) {
return 0;
}
/* username [+ domain]? */
if (idx < 0) {
/* no user or username, fail */
return -1;
}
return 0;
return 0;
}
{
struct sql_userdb_iterate_context *ctx =
(struct sql_userdb_iterate_context *)_ctx;
const char *user;
int ret;
/* query not finished yet */
return;
}
if (ret > 0) {
i_error("sql: Iterate query didn't return 'user' field");
i_error("sql: Iterate query returned NULL user");
else {
return;
}
} else if (ret < 0) {
i_error("sql: Iterate query failed: %s",
} else {
i_error("sql: Iterate query failed: %s "
"(using built-in default iterate_query: %s)",
}
}
}
{
struct sql_userdb_iterate_context *ctx =
(struct sql_userdb_iterate_context *)_ctx;
/* sql query hasn't finished yet */
} else {
}
return ret;
}
static struct userdb_module *
{
struct sql_userdb_module *module;
}
{
struct sql_userdb_module *module =
(struct sql_userdb_module *)_module;
enum sql_db_flags flags;
}
{
struct sql_userdb_module *module =
(struct sql_userdb_module *)_module;
}
struct userdb_module_interface userdb_sql = {
"sql",
};
#else
struct userdb_module_interface userdb_sql = {
.name = "sql"
};
#endif