[icinga-checkins] icinga.org: icinga-core/master: fix ssl feature

git at icinga.org git at icinga.org
Sun Oct 11 08:53:54 CEST 2009


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

Author: Hendrik Baecker <andurin at process-zero.de>
Date:   Fri Oct  9 18:43:32 2009 +0200

fix ssl feature

now it should run better...

---

 module/idoutils/src/ido2db.c |   68 ++++++++++++++++++++++-------------------
 module/idoutils/src/idomod.c |    2 +-
 2 files changed, 37 insertions(+), 33 deletions(-)

diff --git a/module/idoutils/src/ido2db.c b/module/idoutils/src/ido2db.c
index 0546366..c08b8c4 100644
--- a/module/idoutils/src/ido2db.c
+++ b/module/idoutils/src/ido2db.c
@@ -127,6 +127,15 @@ int main(int argc, char **argv){
 		exit(1);
 	        }
 
+        /* initialize variables */
+        ndo2db_initialize_variables();
+
+        /* process config file */
+        if(ndo2db_process_config_file(ndo2db_config_file)!=NDO_OK){
+		printf("Error processing config file '%s'.\n",ndo2db_config_file);
+		exit(1);
+        }
+
 #ifdef HAVE_SSL
 	        /* initialize SSL */
 	        if(use_ssl==NDO_TRUE){
@@ -175,15 +184,6 @@ int main(int argc, char **argv){
 	        /*Fin Hack SSL*/
 #endif
 
-	/* initialize variables */
-	ndo2db_initialize_variables();
-
-	/* process config file */
-	if(ndo2db_process_config_file(ndo2db_config_file)!=NDO_OK){
-		printf("Error processing config file '%s'.\n",ndo2db_config_file);
-		exit(1);
-	        }
-
 	/* make sure we're good to go */
 	if(ndo2db_check_init_reqs()!=NDO_OK){
 		printf("One or more required parameters is missing or incorrect.\n");
@@ -472,8 +472,8 @@ int ndo2db_process_config_var(char *arg){
 		ndo2db_db_settings.max_externalcommands_age=strtoul(val,NULL,0)*60;
 
 	else if(!strcmp(var,"trim_db_interval"))
-		ndo2db_db_settings.trim_db_interval=strtoul(val,NULL,0); 
-	
+		ndo2db_db_settings.trim_db_interval=strtoul(val,NULL,0);
+
 	else if(!strcmp(var,"ndo2db_user"))
 		ndo2db_user=strdup(val);
 	else if(!strcmp(var,"ndo2db_group"))
@@ -491,7 +491,7 @@ int ndo2db_process_config_var(char *arg){
 		ndo2db_max_debug_file_size=strtoul(val,NULL,0);
 	else if(!strcmp(var,"use_ssl")){
 		if (strlen(val) == 1) {
-			if (isdigit((int)val[strlen(val)-1]) == NDO_TRUE)
+			if (isdigit((int)val[strlen(val)-1]) != NDO_FALSE)
 				use_ssl = atoi(val);
 			else
 				use_ssl = 0;
@@ -964,28 +964,32 @@ int ndo2db_wait_for_connections(void){
 
 	/* accept connections... */
 	while(1){
-		new_sd=accept(ndo2db_sd,(ndo2db_socket_type==NDO_SINK_TCPSOCKET)?(struct sockaddr *)&client_address_i:(struct sockaddr *)&client_address_u,(socklen_t *)&client_address_length);
-
-		/* ToDo:  Hendrik 08/12/2009
-		 * If both ends think differently about SSL encryption, data from a ndomod will
-		 * be lost forever (likewise on database errors/misconfiguration)
-		 * This seems a good place to output some information from which client
-		 * a possible misconfiguration comes from.
-		 * Logging the ip address together with the ndomod instance name might be
-		 * a great hint for further error hunting
-		 */
-
-		if(new_sd>=0)
-			/* data available */
-			break;
-		if(errno == EINTR) {
-			/* continue */
+
+		while(1){
+
+			new_sd=accept(ndo2db_sd,(ndo2db_socket_type==NDO_SINK_TCPSOCKET)?(struct sockaddr *)&client_address_i:(struct sockaddr *)&client_address_u,(socklen_t *)&client_address_length);
+
+			/* ToDo:  Hendrik 08/12/2009
+			 * If both ends think differently about SSL encryption, data from a ndomod will
+			 * be lost forever (likewise on database errors/misconfiguration)
+			 * This seems a good place to output some information from which client
+			 * a possible misconfiguration comes from.
+			 * Logging the ip address together with the ndomod instance name might be
+			 * a great hint for further error hunting
+			 */
+
+			if(new_sd>=0)
+				/* data available */
+				break;
+			if(errno == EINTR) {
+				/* continue */
 			}
-		else {
- 			perror("Accept error");
- 			ndo2db_cleanup_socket();
-			return NDO_ERROR;
+			else {
+				perror("Accept error");
+				ndo2db_cleanup_socket();
+				return NDO_ERROR;
 			}
+		}
 
 		if(ido2db_run_foreground == NDO_FALSE) {
 			/* fork... */
diff --git a/module/idoutils/src/idomod.c b/module/idoutils/src/idomod.c
index 130e750..1d698e8 100644
--- a/module/idoutils/src/idomod.c
+++ b/module/idoutils/src/idomod.c
@@ -415,7 +415,7 @@ int ndomod_process_config_var(char *arg){
 
 	else if(!strcmp(var,"use_ssl")){
 		if (strlen(val) == 1) {
-			if (isdigit((int)val[strlen(val)-1]) == NDO_TRUE)
+			if (isdigit((int)val[strlen(val)-1]) != NDO_FALSE)
 				use_ssl = atoi(val);
 			else
 				use_ssl = 0;





More information about the icinga-checkins mailing list