logrewrite: fix rewrite set/subst related segfault

If a set/rewrite operation is referenced from multiple locations, and
it uses template functions, a segfault has occurred, as the clone
operation didn't properly propagate the associated configuration object,
which rendered template->cfg to be NULL, which in turn caused
template-function lookup code to dereference a NULL pointer.

This was fixed by two dependent changes:
  - always passing the already-compiled LogTemplate to the rewrite
    operations instead of a string constant.
  - reusing the compiled template object in clone()

Since LogTemplate is reused, and the first one contains a proper reference
to the appropriate configuration object, the NULL deref issue was
solved too.

Reported-By: Johnson, Chris <chris.johnson3@hp.com>
Signed-off-by: Balazs Scheidler <bazsi@balabit.hu>
logrewrite: Fix the template reference counting

In case of the subst() and set() rewrite statements, when the
implementation was changed to pass a template to the constructor
instead of a string, the free() remained in the parser. While that was
supposed to free a string allocated by the parser, after the change,
that free'd the template that we had stored in the rewrite struct
itself.

To correct the issue, both the subst() and set() constructors will ref
the template, and the parser-side will unref it, instead of free()ing
it up.

Signed-off-by: Gergely Nagy <algernon@balabit.hu>