another [patch] Solaris fix for cfg_dir Re: Bug: cfg_dir doesn't work on solaris..?

Jan Grant jan.grant at bristol.ac.uk
Wed Jan 23 13:09:37 CET 2008


Attached is a patch against nagios-2.10 which carefully cuts out the 
uses of d_type in dirent, if that's missing, and just falls back to 
using stat (which follows symlinks).

This makes recursive cfg_dir structures work on Solaris 10.

Excuse the hackery: I've just carefully inserted additional checks for 
_DIRENT_HAVE_D_TYPE around block ends.

Cheers,
jan


PS. I'm reasonably certain that what nagios tries to do in the cfg_dir 
handling is unnecessarily clever; since stat() follows symlinks anyway, 
just checking for file or directory types with a single stat() call 
should be sufficient.



-- 
jan grant, ISYS, University of Bristol. http://www.bris.ac.uk/
Tel +44 (0)117 3317661   http://ioctl.org/jan/
Spreadsheet through network. Oh yeah.
-------------- next part --------------
--- xdata/xodtemplate.c	Fri Jan 19 22:02:01 2007
+++ xdata/xodtemplate.c	Wed Jan 23 11:57:29 2008
@@ -392,11 +392,13 @@
 #ifdef _DIRENT_HAVE_D_TYPE
 			/* only process normal files and symlinks */
 			if(dirfile->d_type==DT_UNKNOWN){
+#endif
 				x=stat(file,&stat_buf);
 				if(x==0){
 					if(!S_ISREG(stat_buf.st_mode) && !S_ISLNK(stat_buf.st_mode))
 						continue;
 				        }
+#ifdef _DIRENT_HAVE_D_TYPE
 			        }
 			else{
 				if(dirfile->d_type!=DT_REG && dirfile->d_type!=DT_LNK)
@@ -417,6 +419,7 @@
 		if(dirfile->d_type==DT_UNKNOWN || dirfile->d_type==DT_DIR || dirfile->d_type==DT_LNK){
 
 			if(dirfile->d_type==DT_UNKNOWN){
+#endif
 				x=stat(file,&stat_buf);
 				if(x==0){
 					if(!S_ISDIR(stat_buf.st_mode) && !S_ISLNK(stat_buf.st_mode))
@@ -424,12 +427,15 @@
 				        }
 				else
 					continue;
+#ifdef _DIRENT_HAVE_D_TYPE
 			        }
+#endif
 
 			/* ignore current, parent and hidden directory entries */
 			if(dirfile->d_name[0]=='.')
 				continue;
 
+#ifdef _DIRENT_HAVE_D_TYPE
 			/* check that a symlink points to a dir */
 
 			if(dirfile->d_type==DT_LNK || (dirfile->d_type==DT_UNKNOWN && S_ISLNK(stat_buf.st_mode))){
@@ -505,6 +511,7 @@
 
 				/* Otherwise, we may proceed! */
 			        }
+#endif
 
 			/* process the config directory */
 			result=xodtemplate_process_config_dir(file,options);
@@ -512,6 +519,7 @@
 			/* break out if we encountered an error */
 			if(result==ERROR)
 				break;
+#ifdef _DIRENT_HAVE_D_TYPE
 		        }
 #endif
 		}
-------------- next part --------------
-------------------------------------------------------------------------
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2008.
http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
-------------- next part --------------
_______________________________________________
Nagios-devel mailing list
Nagios-devel at lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/nagios-devel


More information about the Developers mailing list