Double escaping in $ARGx$

Andreas Ericsson ae at op5.se
Tue Aug 11 11:40:16 CEST 2009


Ton Voon wrote:
> On 11 Aug 2009, at 09:30, Andreas Ericsson wrote:
> 
>> Ton Voon wrote:
>>> On 31 Jul 2009, at 16:10, Ethan Galstad wrote:
>>>
>>> Andreas writes:
>>>> Why use the exclamation mark at all? It's quite straightforward to  
>>>> parse
>>>> shell-style quoting into arguments, and that way users can just
>>>> cut-n-paste
>>>> the commands to verify that they work (assuming they replace the  
>>>> macros,
>>>> that is).
>>> That's wrong. You use execve to avoid the shell quoting and to pass  
>>> in
>>> arguments "as-is" to the plugin without interpretation at the shell
>>> level.
>> I'm well aware of that, but hand-parsing it inside Nagios would not be
>> difficult, assuming we can still pass commands with sub-shells to the
>> shell for execution.
> 
> I'm not sure what you mean here. Can you give an example?
> 

I mean that we can get rid of roughly 35-40% of the load from Nagios by
avoiding the extra fork()+execve() the shell causes by simply parsing
the command ourselves. However, we shouldn't bother with commands that
include sub-shells or pipes, so a command such as this:

check_http -H example.com -p $(cat example.com.port) | grep -e expr

had better be handed over to the shell instead of us adding bidirectional
communication pipes and subcommand argument substitution inside Nagios.

-- 
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.

------------------------------------------------------------------------------
Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day 
trial. Simplify your report design, integration and deployment - and focus on 
what you do best, core application coding. Discover what's new with 
Crystal Reports now.  http://p.sf.net/sfu/bobj-july




More information about the Developers mailing list