[PATCH] NDO - Check for configuration file availability

Ricardo Maraschini ricardo.maraschini at opservices.com.br
Fri Jan 7 12:43:37 CET 2011


----- "Stephen Gran" <steve at lobefin.net> escreveu:
> I'd be quite happy to see this display the actual error instead of
> hardcoding a suggestion that may be inaccurate.
> 
> Something like:
> snprintf(temp_buffer,sizeof(temp_buffer)-1,"ndomod: Unable to open
> configuration file %s: %s\n", filename, strerror(errno))


--- ndomod.c	2009-10-27 01:08:29.000000000 -0700
+++ modified-ndomod.c	2011-01-07 03:38:39.000000000 -0800
@@ -330,10 +330,15 @@
 	ndo_mmapfile *thefile=NULL;
 	char *buf=NULL;
 	int result=NDO_OK;
+	char temp_buffer[NDOMOD_MAX_BUFLEN];
 
 	/* open the file */
-	if((thefile=ndo_mmap_fopen(filename))==NULL)
+	if((thefile=ndo_mmap_fopen(filename))==NULL) {
+		snprintf(temp_buffer,sizeof(temp_buffer)-1,"ndomod: Unable to open configuration file %s: %s\n", filename, strerror(errno));
+		temp_buffer[sizeof(temp_buffer)-1]='\x0';
+		ndomod_write_to_logs(temp_buffer,NSLOG_INFO_MESSAGE);
 		return NDO_ERROR;
+	        }
 
 	/* process each line of the file */
 	while((buf=ndo_mmap_fgets(thefile))){

------------------------------------------------------------------------------
Gaining the trust of online customers is vital for the success of any company
that requires sensitive data to be transmitted over the Web.   Learn how to 
best implement a security strategy that keeps consumers' information secure 
and instills the confidence they need to proceed with transactions.
http://p.sf.net/sfu/oracle-sfdevnl 




More information about the Developers mailing list