[syslog-ng]1.9.3 bug proposal : resolving $HOSTS in destination
Balazs Scheidler
syslog-ng@lists.balabit.hu
Mon, 28 Feb 2005 17:37:37 +0100
On Mon, 2005-02-28 at 15:46 +0100, Gilles Demarty wrote:
> Nate Campi wrote:
> > On Mon, Feb 28, 2005 at 02:31:00PM +0100, Gilles Demarty wrote:
> >
> >>Here are the revelant debugging infos :
> >>
> >>Incoming log entry; line='<21>Feb 28 15:24:46 logger: test'
> >
> >
> > You haven't said what would you have it do when there's no hostname in
> > the incoming message (as is the case here). Would you have it fall back
> > to using the IP of the remote system? Maybe that's not a bad idea.
> >
>
> The issue is not that the hostname is empty( well that's kind of issue
> too, but not the one I point out ;) ) , but that the resolve of the
> string is not perfomed correctly :
> filename='localhost/var/log/hosts//mail 2005-02-28.notice'
> ^^^^^^^^^
>
> I got the same, if I remove the $HOST/ in the destination string. The
> resulting filename is :
> filename='mail/var/log/hosts/ 2005-02-28.notice'
> ^^^^
>
> I know, the title would have been : "[syslog-ng]1.9.3 bug proposal :
> resolving $... in destination" instead of $HOST, but well, that's less
> understanding.
The bug is genuine and I've found it thanks for your report, this patch
fixes it:
--- orig/src/templates.c
+++ mod/src/templates.c
@@ -55,15 +55,6 @@
{
if (*p == '$')
{
- if (last_macro != M_NONE)
- {
- e = g_new0(LogTemplateElem, 1);
- e->macro = last_macro;
- e->text = last_text;
- self->compiled_template = g_list_prepend(self->compiled_template, e);
- last_macro = M_NONE;
- last_text = NULL;
- }
p++;
/* macro reference */
if (*p >= '0' && *p <= '9')
@@ -90,7 +81,16 @@
}
last_macro = log_macro_lookup(start, p - start);
}
-
+ if (last_macro != M_NONE)
+ {
+ e = g_new0(LogTemplateElem, 1);
+ e->macro = last_macro;
+ e->text = last_text;
+ self->compiled_template = g_list_prepend(self->compiled_template, e);
+ last_macro = M_NONE;
+ last_text = NULL;
+ }
+
}
else
{
@@ -122,6 +122,10 @@
for (p = self->compiled_template; p; p = g_list_next(p))
{
e = (LogTemplateElem *) p->data;
+ if (e->text)
+ {
+ g_string_append(result, e->text->str);
+ }
if (e->macro != M_NONE)
{
log_macro_expand(result, e->macro,
@@ -130,10 +134,6 @@
(self->flags & LT_TZ_SET) ? self->zone_offset : timezone,
lm);
}
- if (e->text)
- {
- g_string_append(result, e->text->str);
- }
}
}
--
Bazsi