[icinga-checkins] icinga.org: icinga-core/master: idoutils: add check for configuration file availability for idomod and ido2db ( idea from Ricardo Maraschini) #1087

git at icinga.org git at icinga.org
Mon Jan 10 16:19:18 CET 2011


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

Author: Michael Friedrich <michael.friedrich at univie.ac.at>
Date:   Fri Jan  7 10:05:28 2011 +0100

idoutils: add check for configuration file availability for idomod and ido2db (idea from Ricardo Maraschini) #1087

fixes #1087

---

 Changelog                        |    1 +
 module/idoutils/include/ido2db.h |    2 ++
 module/idoutils/src/ido2db.c     |    5 ++++-
 module/idoutils/src/idomod.c     |    7 ++++++-
 4 files changed, 13 insertions(+), 2 deletions(-)

diff --git a/Changelog b/Changelog
index 7f6e836..272c3ea 100644
--- a/Changelog
+++ b/Changelog
@@ -30,6 +30,7 @@ ENHANCEMENTS
 * install: set -Wall gcc flags based on os/compiler #959
 
 * idoutils: add index to table icinga_statehistory for usage in reporting module #957
+* idoutils: add check for configuration file availability for idomod and ido2db (idea from Ricardo Maraschini) #1087
 
 * contrib: bring daemonchk.cgi building into shape (Elan Ruusamäe) #1051
 
diff --git a/module/idoutils/include/ido2db.h b/module/idoutils/include/ido2db.h
index 52b6fa2..e64c036 100644
--- a/module/idoutils/include/ido2db.h
+++ b/module/idoutils/include/ido2db.h
@@ -56,6 +56,8 @@
 
 #define IDO2DB_MAX_MBUF_ITEMS                           14
 
+#define IDO2DB_MAX_BUFLEN				16384
+
 
 /***************** structures *****************/
 
diff --git a/module/idoutils/src/ido2db.c b/module/idoutils/src/ido2db.c
index 49ac68a..7e3601f 100644
--- a/module/idoutils/src/ido2db.c
+++ b/module/idoutils/src/ido2db.c
@@ -393,11 +393,14 @@ int ido2db_process_arguments(int argc, char **argv){
 int ido2db_process_config_file(char *filename){
 	ido_mmapfile *thefile=NULL;
 	char *buf=NULL;
+        char *temp_buffer[IDO2DB_MAX_BUFLEN];
 	int result=IDO_OK;
 
 	/* open the file */
-	if((thefile=ido_mmap_fopen(filename))==NULL)
+	if((thefile=ido_mmap_fopen(filename))==NULL){
+		syslog(LOG_ERR, "Error: Unable to open configuration file, please check permissions on %s\n", filename);
 		return IDO_ERROR;
+	}
 
 	/* process each line of the file */
 	while((buf=ido_mmap_fgets(thefile))){
diff --git a/module/idoutils/src/idomod.c b/module/idoutils/src/idomod.c
index 33cab46..7568d54 100644
--- a/module/idoutils/src/idomod.c
+++ b/module/idoutils/src/idomod.c
@@ -329,11 +329,16 @@ int idomod_process_module_args(char *args){
 int idomod_process_config_file(char *filename){
 	ido_mmapfile *thefile=NULL;
 	char *buf=NULL;
+	char temp_buffer[IDOMOD_MAX_BUFLEN];
 	int result=IDO_OK;
 
 	/* open the file */
-	if((thefile=ido_mmap_fopen(filename))==NULL)
+	if((thefile=ido_mmap_fopen(filename))==NULL){
+		snprintf(temp_buffer,sizeof(temp_buffer)-1,"idomod: Unable to open configuration file, please check permissions on %s\n", filename);
+		temp_buffer[sizeof(temp_buffer)-1]='\x0';
+		idomod_write_to_logs(temp_buffer,NSLOG_INFO_MESSAGE);
 		return IDO_ERROR;
+	}
 
 	/* process each line of the file */
 	while((buf=ido_mmap_fgets(thefile))){





More information about the icinga-checkins mailing list