Re: [Nagios-devel] Nagios fails on empty config file
Posted: Wed Aug 23, 2006 12:42 am
Ethan Galstad wrote:
> Marc Haber wrote:
>> Hi,
>>
>> this is a forward from the Debian BTS, http://bugs.debian.org/354007.
>>
>> If Nagios 2 encounters an empty config file, it exits with "invalid
>> argument":
>>
>> |Reading configuration data...
>> |
>> |Error: Cannot open config file '/etc/nagios-plugins/config/imap.cfg' for
>> |reading: Invalid argument
>> |
>> |***> One or more problems was encountered while processing the config files...
>> |
>> | Check your configuration file(s) to ensure that they contain valid
>> | directives and data defintions. If you are upgrading from a previous
>> | version of Nagios, you should be aware that some variables/definitions
>> | may have been removed or modified in this version. Make sure to read
>> | the HTML documentation regarding the config files, as well as the
>> | 'Whats New' section to find out what has changed.
>> |
>> |* errors in config!
>> | failed!
>> |invoke-rc.d: initscript nagios2, action "start" failed.
>> |root@debian:/etc/nagios-plugins/config#
>>
>> This has been verified to be still present in nagios 2.5.
>>
>> Greetings
>> Marc
>>
>
> I believe this is proper behavior. The "Invalid argument" string is
> coming from the system via the strerror() function.
>
I'm not sure what filesystem this happens on, but all filesystems I've
ever worked with allows opening a zero-length file for reading.
Unless the code goes something like this, strerror() should never spit
out that error string
----
int fd;
fd = open(config_file, O_RDONLY)
fstat(config_file, &st);
if (st.st_size == 0)
close(fd);
read(fd, buf, size);
----
in which case the "invalid argument" comes from the read() call, and not
the open() call (I can't imagine the options being wrong for the open()
call, but I haven't checked it).
--
Andreas Ericsson [email protected]
OP5 AB www.op5.se
Tel: +46 8-230225 Fax: +46 8-230231
This post was automatically imported from historical nagios-devel mailing list archives
Original poster: [email protected]
> Marc Haber wrote:
>> Hi,
>>
>> this is a forward from the Debian BTS, http://bugs.debian.org/354007.
>>
>> If Nagios 2 encounters an empty config file, it exits with "invalid
>> argument":
>>
>> |Reading configuration data...
>> |
>> |Error: Cannot open config file '/etc/nagios-plugins/config/imap.cfg' for
>> |reading: Invalid argument
>> |
>> |***> One or more problems was encountered while processing the config files...
>> |
>> | Check your configuration file(s) to ensure that they contain valid
>> | directives and data defintions. If you are upgrading from a previous
>> | version of Nagios, you should be aware that some variables/definitions
>> | may have been removed or modified in this version. Make sure to read
>> | the HTML documentation regarding the config files, as well as the
>> | 'Whats New' section to find out what has changed.
>> |
>> |* errors in config!
>> | failed!
>> |invoke-rc.d: initscript nagios2, action "start" failed.
>> |root@debian:/etc/nagios-plugins/config#
>>
>> This has been verified to be still present in nagios 2.5.
>>
>> Greetings
>> Marc
>>
>
> I believe this is proper behavior. The "Invalid argument" string is
> coming from the system via the strerror() function.
>
I'm not sure what filesystem this happens on, but all filesystems I've
ever worked with allows opening a zero-length file for reading.
Unless the code goes something like this, strerror() should never spit
out that error string
----
int fd;
fd = open(config_file, O_RDONLY)
fstat(config_file, &st);
if (st.st_size == 0)
close(fd);
read(fd, buf, size);
----
in which case the "invalid argument" comes from the read() call, and not
the open() call (I can't imagine the options being wrong for the open()
call, but I haven't checked it).
--
Andreas Ericsson [email protected]
OP5 AB www.op5.se
Tel: +46 8-230225 Fax: +46 8-230231
This post was automatically imported from historical nagios-devel mailing list archives
Original poster: [email protected]