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

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

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

Post by Guest »

Bjoern Beutel wrote:
> 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
> but not yet saved. For example, the lock for "dir/my_file.cfg" is a symbolic link
> named "dir/.#my_file.cfg". When "dir" is included by "cfg_dir=", Nagios tries
> to read the symbolic link, complains and exits.
>
> The patch below solves the problem by making "cfg_dir=" ignore hidden files.
>
> Björn Beutel
>
>
> diff -Naur nagios-2.4/xdata/xodtemplate.c nagios-2.4.new/xdata/xodtemplate.c
> --- 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]='\x0';
>
> - /* process this if it's a config file... */
> + /* process this if it's a non-hidden config file... */
> x=strlen(dirfile->d_name);
> - if(x>4 && !strcmp(dirfile->d_name+(x-4),".cfg")){
> + if(x>4 && dirfile->d_name[0] != '.' && !strcmp(dirfile->d_name+(x-4),".cfg")){
>
> #ifdef _DIRENT_HAVE_D_TYPE
> /* only process normal files and symlinks */

Thanks! Patch will be in CVS shortly.


Ethan Galstad,
Nagios Developer
---
Email: [email protected]
Website: http://www.nagios.org





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