Re: [Nagios-devel] Double escaping in $ARGx$

Support forum for Nagios Core, Nagios Plugins, NCPA, NRPE, NSCA, NDOUtils and more. Engage with the community of users including those using the open source solutions.
Locked
Guest

Re: [Nagios-devel] Double escaping in $ARGx$

Post by Guest »

Ton Voon wrote:
> On 11 Aug 2009, at 10:40, Andreas Ericsson wrote:
>
>> 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.
>
> I see. perl does something like that. You call system() with a string
> (like "/bin/echo here I am") and it works out if there are any shell
> meta characters in there. If so, it invokes via the shell, otherwise
> it splits it based on spaces and then calls execve().
>
> So the usual definitions of "$USER1$/check_icmp -H hostname" will
> speed up, but something like "$USER1$/check_http -H hostname -s
> 'string'" won't.
>

Well, parsing the single and double-quoted shell arguments is really
really trivial. runcmd already does that. It's when you need to
create pipes that it gets tricky.

> We could do something like that as well, though there's potential
> breakage with existing configurations.
>

There shouldn't be any breakages really. The runcmd code is fairly
well tested in that respect.

> I've never dug into perl's C code - this would be a handy excuse!
>

I can't think why.

int has_shell_meta_chars(const char *str)
{
const char *p;
for (p = str; p; p++) {
switch (*p) {
case '\'': etc...
return 1;
}
}

return 0;
}


--
Andreas Ericsson [email protected]
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.





This post was automatically imported from historical nagios-devel mailing list archives
Original poster: [email protected]
Locked