affile: file destination flags fixed

O_APPEND was missing from open DW_REOPEN_FLAGS

Signed-off-by: Budai Laszlo <lbudai@balabit.hu>
affile: Rename __set_fd_permission() to _set_fd_permission()

Signed-off-by: Budai Laszlo <lbudai@balabit.hu>
Signed-off-by: Gergely Nagy <algernon@balabit.hu>
affile: test_affile_open added
filter: Fix the match() filter grammar

In the filter_re rule, the match() filter's grammar was written with a
":" at the start of the line instead of a "|", therefore yacc did not
consider it part of the rule. This patch corrects that.

Reported-by: Andras Mitzki <micek@balabit.hu>
Signed-off-by: Gergely Nagy <algernon@balabit.hu>
cfg-tree: Added a few tests for cfg-tree

These are some simplistic tests for cfg-tree, that verify some of the
functionality provided. In particular, this tests cfg_tree_start() and
cfg_tree_stop() in a few conditions, using only a simplistic LogPipe.

The intent is to check that cfg_tree_start() initializes only those
pipes that can be and nothing after, and cfg_tree_stop() deinits those
that were initialized before.

Signed-off-by: Gergely Nagy <algernon@balabit.hu>
mainloop: Deinit the new config when reverting to the old one

When reloading, and the new config fails, deinit it before initializing
the old config. This is so that conflicting things do not remain held by
the half-initialized new config, while the old tries to take it
over. (It also removed a couple of memory leaks, most likely.)

The reason we can do this, is because cfg_tree_stop() (called by
cfg_deinit()) goes over all the known nodes, and log_pipe_deinit() is
also smart enough to not deinit a node that has not been inited before.

Signed-off-by: Gergely Nagy <algernon@balabit.hu>
Makefile.am: added populate-makefiles target

This patch adds a new target to the root-level Makefile "populate-makefiles"
which copies a skeleton Makefile to all subdirectories of the build
tree. This allows subdirectory builds even though we use only a single
Makefile in the root directory.

Signed-off-by: Balazs Scheidler <bazsi@balabit.hu>
messages: Add a timestamp to internal messages in debug mode

When running in debug mode, and sending messages to stderr anyway, add a
timestamp to ease debugging. This also changes cfg_tree_compile_node()
to add a timestamp too in similar cases.

Based on a patch by Viktor Juhasz <jviktor@balabit.hu>.

Signed-off-by: Gergely Nagy <algernon@balabit.hu>
Signed-off-by: Balazs Scheidler <bazsi@balabit.hu>
Merge pull request #40 from balabit/merge/h/filter/match-grammar-fix

filter: Fix the match() filter grammar
Merge pull request #41 from balabit/merge/f/cfg-tree/partial-deinit

cfg-tree tests & partial deinit on a reverting reload
nvtable: Reorganized nvtable helper functions.

Moved nv_table_get_dyn_entries and nv_table_get_entry_at_ofs to the
header, and added nv_table_get_dyn_value_offset_from_nventry.

Signed-off-by: Viktor Tusa <tusa@balabit.hu>
persistable-state: Factor out header from LogProtoBufferedServerState

The first few fields of this struct contains members that are relevant to
all such persistable structures.  It's going to be used by the RCPTID
infrastructure.

Signed-off-by: Viktor Tusa <tusa@balabit.hu>
Signed-off-by: Balazs Scheidler <bazsi@balabit.hu>
rcptid: Add unique receipient id framework

This patch adds an rcptid subsytem that can be used to generate per-message
identifiers unique on a given host.

This id is persistent across restarts, and is globally unique for the messages
generated/received on this host/instance.  It is somewhat faster than uuid
template function, but is only a non-zero 48 bit counter.

Signed-off-by: Csaba Karsai <cskarsai@balabit.hu>
Signed-off-by: Viktor Juhasz <jviktor@balabit.hu>
Signed-off-by: Viktor Tusa <tusa@balabit.hu>
Signed-off-by: Balazs Scheidler <bazsi@balabit.hu>
cfg: add use-rcptid() global option

This patch adds a use-rcptid() global option that causes syslog-ng to assign
a reception ID to be assigned to all messages received and generated by syslog-ng.

This can be accessed using the $RCPTID macro and is unique on a given host.
The counter wraps around after 48 bits and is never zero.

It can be used to generate a unique ID for a message.

Signed-off-by: Csaba Karsai <cskarsai@balabit.hu>
Signed-off-by: Viktor Juhasz <jviktor@balabit.hu>
Signed-off-by: Viktor Tusa <tusa@balabit.hu>
Signed-off-by: Balazs Scheidler <bazsi@balabit.hu>
LogMessage: assign RCPTID to all log messages automatically

Signed-off-by: Csaba Karsai <cskarsai@balabit.hu>
Signed-off-by: Viktor Juhasz <jviktor@balabit.hu>
Signed-off-by: Viktor Tusa <tusa@balabit.hu>
Signed-off-by: Balazs Scheidler <bazsi@balabit.hu>
template: add $RCPTID macro

This patch makes the rcptid accessible from templates.

Signed-off-by: Csaba Karsai <cskarsai@balabit.hu>
Signed-off-by: Viktor Juhasz <jviktor@balabit.hu>
Signed-off-by: Viktor Tusa <tusa@balabit.hu>
Signed-off-by: Balazs Scheidler <bazsi@balabit.hu>
test_log_message: add static qualifiers to test functions

Signed-off-by: Balazs Scheidler <bazsi@balabit.hu>
test_log_message: check that rcptid is automatically assigned to a newly created LogMessage
Merge pull request #32 from balabit/merge/f/affile-fixes

Various affile fixes
cfg-lexer: Store the preprocessed config in memory

Instead of writing the preprocessed config into a file directly, store
it in-memory first, before writing it out.

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