escaping semicolon
Andreas Ericsson
ae at op5.se
Thu Mar 23 05:03:28 CET 2006
Ethan Galstad wrote:
> On 23 Mar 2006 at 1:51, Andreas Ericsson wrote:
>
>
>>Gerd Mueller wrote:
>>
>>>Hi all,
>>>
>>>
>>>
>>>I thought of writing a patch to quote semicolons with a backslash
>>> or even better to convert hex to ascii (like \xEB for a semicolon).
>>> It was very simple but did not work with NRPE :-(. NRPE has its own
>>> nasty characters. So escaping inside nagios config will not be
>>> enough :-(. So I am thinking of "global" solution of escaping
>>> nasty characters inside nagios.
>>>
>>>
>>>
>>>Anybody any suggestion about a better pattern to escape nasty
>>>characters?
>>>
>>
>>Don't escape them at all, but parse out the string using shell-style
>>parsing and run the command with execve(2). This will also save us the
>>problem of the macro_x locking race that can sometimes occur, making
>>Nagios 2 sometimes crash on FreeBSD.
>
>
> Either I missed an earlier post, or I've been drinking funny juice
> lately. I wasn't aware there was a race condition in the macro
> processing. Can you provide more details?
>
It stems from the discussion I once had with FreeBSD developers on this
list (some 16 months back, I think), but perhaps the list got
short-circuited out somewhere on the way.
I don't remember all the details, but it was something along the lines
of heap-allocated memory from one thread was being accessed in a
fork()'ed instance of the other thread while the macro_x char * array
itself is located on the stack (the stack is thread-local, the heap is
not), so that if the one thread managed to fork() while the other was
updating the macro_x array Bad Things happened.
Try running Nagios 2.x on FreeBSD 4.10 or Linux 2.4.x with LinuxThreads
0.8 or earlier and you'll see what I mean. NPTL on Linux 2.6 with
futexes apparently don't have any problems with this, as is the case
with LinuxThreads 0.10 (haven't tested 0.9). I don't own a FreeBSD box
to test with, but I think it was solved some time back, or users were
recommended to compile against NPTL or LinuxThreads. Can't remember which.
Anyways, I only brought it up because I've been seeing crashes in the
exact same place with a highly experimental module I'm writing, so
obviously something's funny, but only very, very rarely and under very
special circumstances. Probably nothing to worry about in real life
since FreeBSD 4.10 is fairly old and all GNU/*/Linux systems are
migrating away from linuxthreads entirely.
--
Andreas Ericsson andreas.ericsson at op5.se
OP5 AB www.op5.se
Tel: +46 8-230225 Fax: +46 8-230231
-------------------------------------------------------
This SF.Net email is sponsored by xPML, a groundbreaking scripting language
that extends applications into web and mobile media. Attend the live webcast
and join the prime developer group breaking into this new coding territory!
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=110944&bid=241720&dat=121642
More information about the Developers
mailing list