[Nagios-devel] [Patch for 2.4] make "cfg_dir=" ignore hidden files

Support forum for Nagios Core, Nagios Plugins, NCPA, NRPE, NSCA, NDOUtils and more. Engage with the community of users including those using the open source solutions.
Locked
Guest

[Nagios-devel] [Patch for 2.4] make "cfg_dir=" ignore hidden files

Post by Guest »

Hello,

when editing my Nagios configuration using Emacs, I sometimes can't restart=
Nagios
because it reports an error about an ill-formed .cfg file.

The reason is that Emacs creates a lock for each file that has been changed=
=20
but not yet saved. For example, the lock for "dir/my_file.cfg" is a symboli=
c link=20
named "dir/.#my_file.cfg". When "dir" is included by "cfg_dir=3D", Nagios t=
ries=20
to read the symbolic link, complains and exits.=20

The patch below solves the problem by making "cfg_dir=3D" ignore hidden fil=
es.

Bj=F6rn Beutel


diff -Naur nagios-2.4/xdata/xodtemplate.c nagios-2.4.new/xdata/xodtemplate.c
=2D-- nagios-2.4/xdata/xodtemplate.c 2006-01-12 16:13:08.000000000 +0000
+++ nagios-2.4.new/xdata/xodtemplate.c 2006-06-08 10:39:13.000000000 +0000
@@ -385,9 +385,9 @@
snprintf(file,sizeof(file),"%s/%s",dirname,dirfile->d_name);
file[sizeof(file)-1]=3D'\x0';
=20
=2D /* process this if it's a config file... */
+ /* process this if it's a non-hidden config file... */
x=3Dstrlen(dirfile->d_name);
=2D if(x>4 && !strcmp(dirfile->d_name+(x-4),".cfg")){
+ if(x>4 && dirfile->d_name[0] !=3D '.' && !strcmp(dirfile->d_name+(x-4),"=
=2Ecfg")){
=20
#ifdef _DIRENT_HAVE_D_TYPE
/* only process normal files and symlinks */





This post was automatically imported from historical nagios-devel mailing list archives
Original poster: [email protected]
Locked