Subject: | parse() ignores cfgfile and cfg dir and is no able to follow recursive includes |
Date: | Fri, 16 Sep 2011 13:51:04 +0200 |
To: | bug-Nagios-Object [...] rt.cpan.org |
From: | Michael Fladischer <michael [...] fladi.at> |
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
Hi!
With Nagios 3, configuration files are included through either
cfg_file=... directly or cfg_dir=... as a whole traversed directory
containing .cfg files.
As Nagios::Object::Config did not correctly support this behavior, I
patched it to behave similar to the Nagios config parser.
This is what the patch does:
First, it honors the dirname with which the files are passed to parse(),
thus no longer enforcing a chdir() before parsing configurations with
includes.
Second, it allows both include_file/cfg_file and include_dir/cfg_dir
directives to pull in other files into the configuration.
Third, it uses File::Find to traverse directories denoted by
include_dir/cfg_dir and parses all found files matching /\.cfg$/.
With this patch one should by able to parse a complete configuration
tree by simply feeding a single starting file to parse().
One shortcoming is the lack of error handling for files and directories
that are refereed to in the configuration but do not exist on the
filesystem. At the moment such errors are simply ignored.
Cheers,
- --
Michael Fladischer
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.11 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/
iEYEARECAAYFAk5zOCUACgkQeJ3z1zFMUGZ+6gCfU7/ccl/B2jO1vOFeoLMFrQ8D
T18AnjabtTTmxYCNoDA9xBb67GovVsZb
=dXKs
-----END PGP SIGNATURE-----
Message body is not shown because sender requested not to inline it.