[Bug 480747] New: Nagios Control Script Incorrectly Extracts Values from the Nagios Configuration File
https://bugzilla.novell.com/show_bug.cgi?id=480747 Summary: Nagios Control Script Incorrectly Extracts Values from the Nagios Configuration File Classification: openSUSE Product: openSUSE 11.1 Version: Final Platform: x86-64 OS/Version: openSUSE 11.1 Status: NEW Severity: Minor Priority: P5 - None Component: Other AssignedTo: bnc-team-screening@forge.provo.novell.com ReportedBy: marc@mccoombe.net QAContact: qa@suse.de Found By: --- User-Agent: Mozilla/5.0 (X11; U; Linux x86_64; en-US; rv:1.9.0.6) Gecko/2009012700 SUSE/3.0.6-0.1.2 Firefox/3.0.6 During system shutdown, I noticed two error messages (one from chmod and another from chown) when the Nagios service was being stopped. The same problem also happens when the service is being started, or restarted (see Actual Results). It appears that the get_var function in the /etc/init.d/nagios script does not remove the trailing carriage return (\r) from the lines it extracts from the /etc/nagios/nagios.cfg file. Note: Nagios still appears to run without issue. Reproducible: Always Steps to Reproduce: Run /etc/init.d/nagios restart as root user. Actual Results: Shutting down nagios Warning: nagios killedchmod: cannot access `/etc/nagios/resource.cfg\r': No such file or directory chown: invalid user: `nagios\r:nagcmd' done Starting nagios - Error: looks like nagios is still running with PID 11338 - trying to kill previous nagios processchmod: cannot access `/etc/nagios/resource.cfg\r': No such file or directory chown: invalid user: `nagios\r:nagcmd' done Expected Results: Shutting down nagios done Starting nagios done Workaround - Modify the get_var function in the /etc/init.d/nagios script as follows (i.e., change the sed command to also strip-out the carriage return character): # grab a config option function get_var() { if [ -n "$2" ]; then set -- `grep ^$1 $2 | sed 's@=@ @ ; s@\r@@'` else set -- `grep ^$1 $NAGIOS_CFG | sed 's@=@ @ ; s@\r@@'` fi shift # remove first ARG => search-string echo $* } -- Configure bugmail: https://bugzilla.novell.com/userprefs.cgi?tab=email ------- You are receiving this mail because: ------- You are on the CC list for the bug.
https://bugzilla.novell.com/show_bug.cgi?id=480747 Pavol Rusnak <prusnak@novell.com> changed: What |Removed |Added ---------------------------------------------------------------------------- AssignedTo|bnc-team-screening@forge.pr |cschneemann@novell.com |ovo.novell.com | -- Configure bugmail: https://bugzilla.novell.com/userprefs.cgi?tab=email ------- You are receiving this mail because: ------- You are on the CC list for the bug.
https://bugzilla.novell.com/show_bug.cgi?id=480747 User cschneemann@novell.com added comment https://bugzilla.novell.com/show_bug.cgi?id=480747#c1 Christian Schneemann <cschneemann@novell.com> changed: What |Removed |Added ---------------------------------------------------------------------------- Status|NEW |NEEDINFO Info Provider| |marc@mccoombe.net --- Comment #1 from Christian Schneemann <cschneemann@novell.com> 2009-03-02 09:20:38 MST --- Have you edited your config-files with any strange editor? Maybe on windows? How comes that you have an \r in your config file? If the sign is visible in the file it is correctly that it is extracted to the variable. So no bug. -- Configure bugmail: https://bugzilla.novell.com/userprefs.cgi?tab=email ------- You are receiving this mail because: ------- You are on the CC list for the bug.
https://bugzilla.novell.com/show_bug.cgi?id=480747 User marc@mccoombe.net added comment https://bugzilla.novell.com/show_bug.cgi?id=480747#c2 Marc McCoombe <marc@mccoombe.net> changed: What |Removed |Added ---------------------------------------------------------------------------- Status|NEEDINFO |NEW Info Provider|marc@mccoombe.net | --- Comment #2 from Marc McCoombe <marc@mccoombe.net> 2009-03-02 11:21:01 MST --- I didn't think to look at the file itself! I definitely haven't edited the file on a Windows machine, but I am using NagiosQL (http://www.nagiosql.org), and I'm certain I've used its built-in nagios.cfg editor. Running hexdump -C /etc/nagios/nagios.cfg, I can see that there are carriage return / line feeds (0D 0A) at the end of each line, which explains where the "\r" are coming from. So I would certainly consider that to be the real problem, and will be sure contact the NagiosQL folks. That said, I would still recommend the above change be rolled-in as a robustness enhancement when/if it is convenient. -- Configure bugmail: https://bugzilla.novell.com/userprefs.cgi?tab=email ------- You are receiving this mail because: ------- You are on the CC list for the bug.
https://bugzilla.novell.com/show_bug.cgi?id=480747 User cschneemann@novell.com added comment https://bugzilla.novell.com/show_bug.cgi?id=480747#c3 Christian Schneemann <cschneemann@novell.com> changed: What |Removed |Added ---------------------------------------------------------------------------- Status|NEW |RESOLVED Resolution| |INVALID --- Comment #3 from Christian Schneemann <cschneemann@novell.com> 2009-03-02 14:56:41 MST --- I think it is not good to exclude signs from a configuration. Even #nagios -v <config-file> to verify the config would claimed about it with a warning. So I will not change the /etc/init.d/nagios file. -- Configure bugmail: https://bugzilla.novell.com/userprefs.cgi?tab=email ------- You are receiving this mail because: ------- You are on the CC list for the bug.
https://bugzilla.novell.com/show_bug.cgi?id=480747 User marc@mccoombe.net added comment https://bugzilla.novell.com/show_bug.cgi?id=480747#c4 --- Comment #4 from Marc McCoombe <marc@mccoombe.net> 2009-03-02 18:46:22 MST --- I don't quite understand what you meant by "exclude signs", but making the change to the init script was only a recommendation, and I certainly don't wish to make more work for anyone. At least now I have a better handle on the problem and how to resolve (or at least work around) it, so thank you for pointing me in the right direction. It's so easy to jump to conclusions sometimes, but at least I learned a little more in the process! PS: For the record, the "pre-flight" check you mentioned completes without any complaints with regards to the configuration file, so I guess the nagios executable must parse the file differently than the init script (since NagiosQL lets me do it with a single click, I run that command every time I make a configuration change before I restart Nagios). -- Configure bugmail: https://bugzilla.novell.com/userprefs.cgi?tab=email ------- You are receiving this mail because: ------- You are on the CC list for the bug.
https://bugzilla.novell.com/show_bug.cgi?id=480747 User cschneemann@novell.com added comment https://bugzilla.novell.com/show_bug.cgi?id=480747#c5 Christian Schneemann <cschneemann@novell.com> changed: What |Removed |Added ---------------------------------------------------------------------------- Status|RESOLVED |REOPENED CC| |cschneemann@novell.com Resolution|INVALID | --- Comment #5 from Christian Schneemann <cschneemann@novell.com> 2009-03-03 03:27:34 MST --- I had a look in the sources, nagios does a strip for each value. I wrote "exclude signs" because I thaught they were visible. (So I closed it as invalid) Maybe we should do the same in the rcfile of nagios too. And then not just \r. -- Configure bugmail: https://bugzilla.novell.com/userprefs.cgi?tab=email ------- You are receiving this mail because: ------- You are on the CC list for the bug.
https://bugzilla.novell.com/show_bug.cgi?id=480747 User cschneemann@novell.com added comment https://bugzilla.novell.com/show_bug.cgi?id=480747#c6 --- Comment #6 from Christian Schneemann <cschneemann@novell.com> 2009-03-03 03:58:29 MST --- Created an attachment (id=276668) --> (https://bugzilla.novell.com/attachment.cgi?id=276668) patched rcnagios to ignore control signs in config files I changed your patch to remove all controll signs. I have tested it and it works. Can you validate that? # grab a config option function get_var() { if [ -n "$2" ]; then set -- `grep ^$1 $2 | sed 's@=@ @' | tr -d '[:cntrl:]'` else set -- `grep ^$1 $NAGIOS_CFG | sed 's@=@ @' | tr -d '[:cntrl:]'` fi shift # remove first ARG => search-string echo $* } -- Configure bugmail: https://bugzilla.novell.com/userprefs.cgi?tab=email ------- You are receiving this mail because: ------- You are on the CC list for the bug.
https://bugzilla.novell.com/show_bug.cgi?id=480747 User marc@mccoombe.net added comment https://bugzilla.novell.com/show_bug.cgi?id=480747#c7 --- Comment #7 from Marc McCoombe <marc@mccoombe.net> 2009-03-03 05:16:12 MST --- I can confirm that your modified patch appears to work fine for me. Please let me know if there's anything else I can do to assist. -- Configure bugmail: https://bugzilla.novell.com/userprefs.cgi?tab=email ------- You are receiving this mail because: ------- You are on the CC list for the bug.
https://bugzilla.novell.com/show_bug.cgi?id=480747 User cschneemann@novell.com added comment https://bugzilla.novell.com/show_bug.cgi?id=480747#c8 Christian Schneemann <cschneemann@novell.com> changed: What |Removed |Added ---------------------------------------------------------------------------- Status|REOPENED |RESOLVED Resolution| |FIXED --- Comment #8 from Christian Schneemann <cschneemann@novell.com> 2009-03-04 03:43:22 MST --- Thanks, the fixed version is submitted to factory. You can get the patched version from the server:monitoring repository in the openSUSE Buildservice. http://download.opensuse.org/repositories/server:/monitoring/ -- Configure bugmail: https://bugzilla.novell.com/userprefs.cgi?tab=email ------- You are receiving this mail because: ------- You are on the CC list for the bug.
https://bugzilla.novell.com/show_bug.cgi?id=480747 User marc@mccoombe.net added comment https://bugzilla.novell.com/show_bug.cgi?id=480747#c9 --- Comment #9 from Marc McCoombe <marc@mccoombe.net> 2009-03-04 05:01:23 MST --- And thank you too! So will a change like this eventually show up in the Updater Applet at some point as well? -- Configure bugmail: https://bugzilla.novell.com/userprefs.cgi?tab=email ------- You are receiving this mail because: ------- You are on the CC list for the bug.
participants (1)
-
bugzilla_noreply@novell.com