Nagios 4: Commands are unescaped twice

Andreas Ericsson ae at op5.se
Tue Jan 8 11:12:18 CET 2013


On 01/07/2013 11:00 PM, Adam James wrote:
> Hello,
> 
> Whilst doing some testing on Nagios 4 I noticed that check commands with
> arguments containing sequential backslashes are unescaped twice.
> 
> In Nagios 3, the following check_command:
> 
> check_nrpe!CheckCounter!ShowAll "Counter:Processor Time
> (%)=\\\\Processor(_Total)\\% Processor Time"
> 
> is executed as:
> 
> check_nrpe -H foobar -a CheckCounter -c 'ShowAll "Counter:Processor Time
> (%)=\\Processor(_Total)\% Processor Time"'
> 
> However in Nagios 4 it is executed as:
> 
> check_nrpe -H foobar -a CheckCounter -c 'ShowAll "Counter:Processor Time
> (%)=\Processor(_Total)% Processor Time"'
> 
> This is due to the backslash being unescaped in base/utils.c around line
> 638 [1] and again in lib/runcmd.c around line 153 [2].
> 
> I fixed this by removing the escape code in lib/runcmd.c, but I have my
> doubts about whether it is the correct solution.
> 

lib/runcmd.c is the library code which shouldn't change its behaviour. The
code in utils.c should be removed instead.

On the other hand, the runcmd.c code should have a flag argument one can
use to tell it to ignore certain characters, with "ignore everything" to
be taken as "split on every whitespace-sequence and disregard quoting and
escaping entirely".

Good catch though.

-- 
Andreas Ericsson                   andreas.ericsson at op5.se
OP5 AB                             www.op5.se
Tel: +46 8-230225                  Fax: +46 8-230231

Considering the successes of the wars on alcohol, poverty, drugs and
terror, I think we should give some serious thought to declaring war
on peace.

------------------------------------------------------------------------------
Master SQL Server Development, Administration, T-SQL, SSAS, SSIS, SSRS
and more. Get SQL Server skills now (including 2012) with LearnDevNow -
200+ hours of step-by-step video tutorials by Microsoft MVPs and experts.
SALE $99.99 this month only - learn more at:
http://p.sf.net/sfu/learnmore_122512




More information about the Developers mailing list