db-sql.c revision f93c833d644ecff0b0f80bee4f1cdde3e697b5c8
/* Copyright (c) 2003-2011 Dovecot authors, see the included COPYING file */
#include "auth-common.h"
#if defined(PASSDB_SQL) || defined(USERDB_SQL)
#include "settings.h"
#include "auth-request.h"
#include "auth-worker-client.h"
#include "db-sql.h"
#include <stddef.h>
#include <stdlib.h>
static struct setting_def setting_defs[] = {
{ 0, NULL, 0 }
};
static struct sql_settings default_sql_settings = {
.password_query = "SELECT username, domain, password FROM users WHERE username = '%n' AND domain = '%d'",
.user_query = "SELECT home, uid, gid FROM users WHERE username = '%n' AND domain = '%d'",
.update_query = "UPDATE users SET password = '%w' WHERE username = '%n' AND domain = '%d'",
.iterate_query = "SELECT username, domain FROM users",
.default_pass_scheme = "MD5",
};
{
struct sql_connection *conn;
return conn;
}
return NULL;
}
struct sql_connection *conn)
{
}
{
struct sql_connection *conn;
if (userdb)
return conn;
}
if (*config_path == '\0')
i_fatal("sql: Configuration file path not given");
i_fatal("sql: driver not set in configuration file %s",
}
i_fatal("sql: connect string not set in configuration file %s",
}
connections = conn;
return conn;
}
{
/* abort all pending auth requests before setting conn to NULL,
so that callbacks can still access it */
return;
}
{
/* auth worker's sql connection failed. we can't do anything
useful until the connection works. there's no point in
having tons of worker processes all logging failures,
so tell the auth master to stop creating new workers (and
maybe close old ones). this handling is especially useful if
we reach the max. number of connections for sql server. */
}
}
{
if (worker)
}
{
return;
default_sql_settings.user_query) != 0) {
i_warning("sql: Ignoring changed user_query in %s, "
"because userdb sql not used. "
"(If this is intentional, set userdb_warning_disable=yes)",
conn->config_path);
default_sql_settings.iterate_query) != 0) {
i_warning("sql: Ignoring changed iterate_query in %s, "
"because userdb sql not used. "
"(If this is intentional, set userdb_warning_disable=yes)",
conn->config_path);
}
}
#endif