[dovecot-cvs] dovecot/src/auth db-mysql.c, 1.8, 1.9 db-mysql.h, 1.2, 1.3

cras at dovecot.org cras at dovecot.org
Mon Jul 26 20:06:37 EEST 2004


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

Modified Files:
	db-mysql.c db-mysql.h 
Log Message:
Added MySQL SSL support.



Index: db-mysql.c
===================================================================
RCS file: /home/cvs/dovecot/src/auth/db-mysql.c,v
retrieving revision 1.8
retrieving revision 1.9
diff -u -d -r1.8 -r1.9
--- db-mysql.c	23 Jul 2004 18:50:18 -0000	1.8
+++ db-mysql.c	26 Jul 2004 17:06:35 -0000	1.9
@@ -3,7 +3,8 @@
 #include "config.h"
 #undef HAVE_CONFIG_H
 
-#if defined(PASSDB_MYSQL) || defined(USERDB_MYSQL)
+//#if defined(PASSDB_MYSQL) || defined(USERDB_MYSQL)
+#if 1
 #include "common.h"
 #include "network.h"
 #include "str.h"
@@ -24,6 +25,11 @@
 	DEF(SET_STR, db_user),
 	DEF(SET_STR, db_passwd),
 	DEF(SET_INT, db_client_flags),
+	DEF(SET_STR, ssl_key),
+	DEF(SET_STR, ssl_cert),
+	DEF(SET_STR, ssl_ca),
+	DEF(SET_STR, ssl_ca_path),
+	DEF(SET_STR, ssl_cipher),
 	DEF(SET_STR, password_query),
 	DEF(SET_STR, user_query),
 	DEF(SET_STR, default_pass_scheme)
@@ -37,6 +43,11 @@
 	MEMBER(db_user) NULL,
 	MEMBER(db_passwd) NULL,
 	MEMBER(db_client_flags) 0,
+	MEMBER(ssl_key) NULL,
+	MEMBER(ssl_cert) NULL,
+	MEMBER(ssl_ca) NULL,
+	MEMBER(ssl_ca_path) NULL,
+	MEMBER(ssl_cipher) "HIGH",
 	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"
@@ -102,6 +113,8 @@
 
 static int mysql_conn_open(struct mysql_connection *conn)
 {
+	int use_ssl = FALSE;
+
 	if (conn->connected)
 		return TRUE;
 
@@ -113,6 +126,20 @@
 		}
 	}
 
+#ifdef HAVE_MYSQL_SSL
+	if (conn->set.ssl_ca != NULL || conn->set.ssl_ca_path != NULL) {
+		mysql_ssl_set(conn->mysql, conn->set.ssl_key,
+			      conn->set.ssl_cert,
+			      conn->set.ssl_ca,
+			      conn->set.ssl_ca_path
+#ifdef HAVE_MYSQL_SSL_CIPHER
+			      ,conn->set.ssl_cipher
+#endif
+			     );
+		use_ssl = TRUE;
+	}
+#endif
+
 	if (mysql_real_connect(conn->mysql, conn->set.db_host,
 			       conn->set.db_user, conn->set.db_passwd,
 			       conn->set.db,
@@ -123,7 +150,8 @@
 			conn->set.db, mysql_error(conn->mysql));
 	} else {
 		conn->connected = TRUE;
-		i_info("MySQL: connected to %s", conn->set.db_host);
+		i_info("MySQL: connected to %s%s", conn->set.db_host,
+		       use_ssl ? "using SSL" : "");
 	}
 	
 	return conn->connected;

Index: db-mysql.h
===================================================================
RCS file: /home/cvs/dovecot/src/auth/db-mysql.h,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -d -r1.2 -r1.3
--- db-mysql.h	23 Jul 2004 18:50:18 -0000	1.2
+++ db-mysql.h	26 Jul 2004 17:06:35 -0000	1.3
@@ -24,6 +24,11 @@
 	const char *db_user;
 	const char *db_passwd;
 	unsigned int db_client_flags;
+	const char *ssl_key;
+	const char *ssl_cert;
+	const char *ssl_ca;
+	const char *ssl_ca_path;
+	const char *ssl_cipher;
 	const char *password_query;
 	const char *user_query;
 	const char *default_pass_scheme;



More information about the dovecot-cvs mailing list