[icinga-checkins] icinga.org: icinga-core/master: idoutils: fix ido2db does not cleanly exit the client on wrong schema version check in db_hello refs #3419

git at icinga.org git at icinga.org
Fri Nov 9 18:21:21 CET 2012


Module: icinga-core
Branch: master
Commit: 7a9ff720b3c251e7420637630ff5e52d30ed8a31
URL:    https://git.icinga.org/?p=icinga-core.git;a=commit;h=7a9ff720b3c251e7420637630ff5e52d30ed8a31

Author: Michael Friedrich <michael.friedrich at gmail.com>
Date:   Sat Nov  3 00:24:55 2012 +0100

idoutils: fix ido2db does not cleanly exit the client on wrong schema version check in db_hello refs #3419

---

 Changelog                    |    1 +
 module/idoutils/src/db.c     |    6 ++----
 module/idoutils/src/ido2db.c |    9 +++++++--
 3 files changed, 10 insertions(+), 6 deletions(-)

diff --git a/Changelog b/Changelog
index ca8b8ff..cf8015e 100644
--- a/Changelog
+++ b/Changelog
@@ -24,6 +24,7 @@ FIXES
 * idoutils: fix ido2db crashes when Oracle queries fail #3324 - GB
 * idoutils: fix ORA-1461 writing data to varchar2 exceeding field size limit output, command_arg and commandline data written to Oracle #3324 #3325 - TD
 * idoutils: fix unsafe handling of dbi_conn_sequence_last, rewrite last_insert_id/sequence fetching #3408 - MF
+* idoutils: fix ido2db does not cleanly exit the client on wrong schema version check in db_hello #3419 - MF
 
 * install: drop unused daemon-init-readhat script (spec uses daemon-init) #3402 - MF
 
diff --git a/module/idoutils/src/db.c b/module/idoutils/src/db.c
index 0bb1669..69acd4a 100644
--- a/module/idoutils/src/db.c
+++ b/module/idoutils/src/db.c
@@ -1419,12 +1419,12 @@ int ido2db_db_version_check(ido2db_idi *idi) {
 	/* check dbversion against program version */
 	if (idi->dbinfo.dbversion == NULL) {
 		ido2db_log_debug_info(IDO2DB_DEBUGL_PROCESSINFO, 2, "ido2db_db_version_check() dbversion is NULL\n");
-		syslog(LOG_ERR, "Error: DB Version cannot be retrieved. Please check the upgrade docs and verify the db schema!");
+		syslog(LOG_USER | LOG_INFO, "Error: DB Version cannot be retrieved. Please check the upgrade docs and verify the db schema!");
 		return IDO_ERROR;
 	}
 	if (strcmp(idi->dbinfo.dbversion, IDO_SCHEMA_VERSION) != 0) {
 		ido2db_log_debug_info(IDO2DB_DEBUGL_PROCESSINFO, 2, "ido2db_db_version_check() db version %s does not match schema version %s\n", idi->dbinfo.dbversion, IDO_SCHEMA_VERSION);
-		syslog(LOG_ERR, "Error: DB Version %s does not match needed schema version %s. Please check the upgrade docs!", idi->dbinfo.dbversion, IDO_SCHEMA_VERSION);
+		syslog(LOG_USER | LOG_INFO, "Error: DB Version %s does not match needed schema version %s. Please check the upgrade docs!", idi->dbinfo.dbversion, IDO_SCHEMA_VERSION);
 		return IDO_ERROR;
 	}
 
@@ -1459,8 +1459,6 @@ int ido2db_db_hello(ido2db_idi *idi) {
 
 	if (result == IDO_ERROR) {
                 syslog(LOG_USER | LOG_INFO, "Error: DB Version Check against %s database query failed! Please check %s database configuration and schema!", ido2db_db_settings.dbserver, ido2db_db_settings.dbserver);
-                syslog(LOG_USER | LOG_INFO, "Exiting ...");
-
                 ido2db_log_debug_info(IDO2DB_DEBUGL_PROCESSINFO, 2, "ido2db_db_version_check() query against existing instance not possible, cleaning up and exiting\n");
 
 		return IDO_ERROR;
diff --git a/module/idoutils/src/ido2db.c b/module/idoutils/src/ido2db.c
index 02da5e3..b6b5e7b 100644
--- a/module/idoutils/src/ido2db.c
+++ b/module/idoutils/src/ido2db.c
@@ -1603,8 +1603,13 @@ int ido2db_handle_client_input(ido2db_idi *idi, char *buf) {
 
 			idi->current_input_section = IDO2DB_INPUT_SECTION_DATA;
 
-			/* save connection info to DB */
-			ido2db_db_hello(idi);
+			/* save connection info to DB , bail out if dbversion check was not ok*/
+			if(ido2db_db_hello(idi) == IDO_ERROR) {
+				syslog(LOG_USER | LOG_INFO, "Error: Initial DB Handshake failed.  Disconnecting client...");
+				idi->disconnect_client = IDO_TRUE;
+				idi->ignore_client_data = IDO_TRUE;
+				return IDO_ERROR;
+			}
 
 		}
 





More information about the icinga-checkins mailing list