From: Timo Sirainen Date: Fri, 9 Feb 2024 21:04:20 +0000 (+0200) Subject: lib-sql: mysql - Handle missing MySQL SSL support without dying X-Git-Tag: 2.4.1~982 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=bad5a8afa0ca76bab4b3ba3649a7ea61b8e7cf73;p=thirdparty%2Fdovecot%2Fcore.git lib-sql: mysql - Handle missing MySQL SSL support without dying --- diff --git a/src/lib-sql/driver-mysql.c b/src/lib-sql/driver-mysql.c index 9aff15fabd..cb7eef8e08 100644 --- a/src/lib-sql/driver-mysql.c +++ b/src/lib-sql/driver-mysql.c @@ -89,8 +89,6 @@ static int driver_mysql_connect(struct sql_db *_db) i_assert(db->api.state == SQL_DB_STATE_DISCONNECTED); - sql_db_set_state(&db->api, SQL_DB_STATE_CONNECTING); - if (db->host == NULL) { /* assume option_file overrides the host, or if not we'll just connect to localhost */ @@ -112,8 +110,6 @@ static int driver_mysql_connect(struct sql_db *_db) if (db->host != NULL) event_set_append_log_prefix(_db->event, t_strdup_printf("mysql(%s): ", db->host)); - e_debug(_db->event, "Connecting"); - mysql_options(db->mysql, MYSQL_OPT_CONNECT_TIMEOUT, &db->connect_timeout); mysql_options(db->mysql, MYSQL_OPT_READ_TIMEOUT, &db->read_timeout); mysql_options(db->mysql, MYSQL_OPT_WRITE_TIMEOUT, &db->write_timeout); @@ -134,11 +130,18 @@ static int driver_mysql_connect(struct sql_db *_db) #endif db->ssl_set = TRUE; #else - i_fatal("mysql: SSL support not compiled in " - "(remove ssl_ca and ssl_ca_path settings)"); + const char *error = "SSL support not compiled in " + "(remove ssl_ca and ssl_ca_path settings)"; + i_free(_db->last_connect_error); + _db->last_connect_error = i_strdup(error); + e_error(_db->event, "%s", error); + return -1; #endif } + sql_db_set_state(&db->api, SQL_DB_STATE_CONNECTING); + e_debug(_db->event, "Connecting"); + #ifdef CLIENT_MULTI_RESULTS client_flags |= CLIENT_MULTI_RESULTS; #endif