[syslog-ng] [PATCH]: Experimental SMTP destination

Gergely Nagy algernon at balabit.hu
Fri Mar 11 16:25:05 CET 2011


>>> First of all, it stores the headers we explicitly set in a separate
>>> structure, which is fine. When setting header values, libesmtp itself
>>> does not guard against embedded newlines, but we can either replace
>>> newlines with a space, to clean up headers, or add a space after each
>>> newline:
>>> 
>>>   ,----
>>>   | Header: blah blah
>>>   |  blah blah
>>>   |  blah
>>>   `----
>>> 
>>> This is valid MIME. Replacing newlines is easier, though.
>>> 
>>> Anyway, when libesmtp gets around to process the body, it scans it for
>>> headers, in case some were set there too. Sadly, I couldn't find a way
>>> to stop it from doing so. Therefore, extra care will need to be taken to
>>> format the body correctly...
>>
>> using \r\n would work. Let me see if I can create a patch to fix thes
>> problems.
>
> Hrm, that's a possibility, yeah, I didn't check \r\n, nor that part of
> the libesmtp code (yet).

It appears that I fixed this issue by coincidence.. at least I can't
reproduce the problem I saw before.

An smtp destination like this:

,----
| destination d_smtp {
|         smtp(  
|                 host("127.0.0.1")
|                 port(25)
|                 from("syslog-ng alert service <algernon at luthien>")
|                 to("algernon at luthien")
|                 subject("[ALERT] $PROGRAM[$PID]")
|                 body("Date: $S_DATA\nMsg: $MSG\n\nOh, hey there!\nWe received this message, and thought you might be interested.")
|                 header("X-Program" "$PROGRAM")
|                 header("X-Facility" "$FACILITY")
|         );
| };
`----

Did not produce extra headers, nor did it crash anymore.

Furthermore, I fixed the header injection bug by replacing any \rs and
\ns in the headers with a space. Also ported the driver to latest git
head.

It's available on my work/modules/afsmtp branch, and a consolidated
patch will be available on the integration/afsmtp branch soon, too.

This current code seems to be stable and reliable now, but a quick
review probably wouldn't hurt.

-- 
|8]


More information about the syslog-ng mailing list