[dovecot-cvs] dovecot/src/auth db-mysql.c,1.1,1.2

cras at procontrol.fi cras at procontrol.fi
Tue Jul 6 09:06:02 EEST 2004


Update of /home/cvs/dovecot/src/auth
In directory talvi:/tmp/cvs-serv20222/src/auth

Modified Files:
	db-mysql.c 
Log Message:
Added mysql description to example config file. Changed mysql default
settings.



Index: db-mysql.c
===================================================================
RCS file: /home/cvs/dovecot/src/auth/db-mysql.c,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -d -r1.1 -r1.2
--- db-mysql.c	10 May 2004 01:47:09 -0000	1.1
+++ db-mysql.c	6 Jul 2004 06:06:00 -0000	1.2
@@ -19,12 +19,12 @@
 
 static struct setting_def setting_defs[] = {
 	DEF(SET_STR, db_host),
-	DEF(SET_STR, db_port),
+	DEF(SET_INT, db_port),
 	DEF(SET_STR, db_unix_socket),
 	DEF(SET_STR, db),
 	DEF(SET_STR, db_user),
 	DEF(SET_STR, db_passwd),
-	DEF(SET_STR, db_client_flags),
+	DEF(SET_INT, db_client_flags),
 	DEF(SET_STR, password_query),
 	DEF(SET_STR, user_query),
 	DEF(SET_STR, default_pass_scheme)
@@ -32,12 +32,12 @@
 
 struct mysql_settings default_mysql_settings = {
 	MEMBER(db_host) "localhost",
-	MEMBER(db_port) "0",
-	MEMBER(db_unix_socket) "/var/tmp/mysql.sock",
-	MEMBER(db) "email_accounts",
-	MEMBER(db_user) "dovecot",
-	MEMBER(db_passwd) "changeme",
-	MEMBER(db_client_flags) "0",
+	MEMBER(db_port) 3306,
+	MEMBER(db_unix_socket) NULL,
+	MEMBER(db) NULL,
+	MEMBER(db_user) NULL,
+	MEMBER(db_passwd) NULL,
+	MEMBER(db_client_flags) 0,
 	MEMBER(password_query) "SELECT password FROM users WHERE userid = '%u'",
 	MEMBER(user_query) "SELECT home, uid, gid FROM users WHERE userid = '%u'",
 	MEMBER(default_pass_scheme) "PLAIN-MD5"
@@ -96,10 +96,9 @@
 		if (!mysql_real_connect(conn->mysql, conn->set.db_host,
 					conn->set.db_user, conn->set.db_passwd,
 					conn->set.db,
-					atoi(conn->set.db_port),
+					conn->set.db_port,
 					conn->set.db_unix_socket,
-					strtoul(conn->set.db_client_flags,
-						NULL, 10))) {
+					conn->set.db_client_flags)) {
 			i_error("MYSQL: Can't connect to database %s: %s",
 				conn->set.db, mysql_error(conn->mysql));
 			return FALSE;
@@ -163,6 +162,11 @@
 	if (!settings_read(config_path, NULL, parse_setting, NULL, conn))
 		exit(FATAL_DEFAULT);
 
+	if (conn->set.db == NULL)
+		i_fatal("MYSQL: db variable isn't set in config file");
+	if (conn->set.user == NULL)
+		i_fatal("MYSQL: user variable isn't set in config file");
+
 	(void)mysql_conn_open(conn);
 
 	conn->next = mysql_connections;



More information about the dovecot-cvs mailing list