syslog-ng.h: remove unused default_modules variable declaration

Signed-off-by: Balazs Scheidler <bazsi@balabit.hu>
gprocess: setsid() does not depend on isatty()

On HPUX, during boot the console does not considered as a tty, so syslog-ng does not
call setsid, the tty is not detached and the supervisor is killed at the end of the boot.
setsid() does not and should not depend on isatty(), and anyways setsid() is considered
more unix way than ioctl().

Signed-off-by: Juhasz Viktor <jviktor@balabit.hu>
Signed-off-by: Viktor Tusa <tusa@balabit.hu>
logmatcher: better warning message

Signed-off-by: Juhasz Viktor <jviktor@balabit.hu>
logqueue-fifo: print persist name on error and debug messages

Signed-off-by: Juhasz Viktor <jviktor@balabit.hu>
logqueue-fifo: use after free in function log_queue_fifo_ack_backlog

Signed-off-by: Daniel Gados <gdani@balabit.hu>
logqueue-fifo: do not drop the queue if there are messages in the backlog

Signed-off-by: Juhasz Viktor <jviktor@balabit.hu>
persist-state: fix memory leak in persist_state_rename_entry

The old key was leaked when renaming a persist-state key. This patch fixes
that leak.

Signed-off-by: Juhasz Viktor <jviktor@balabit.hu>
Signed-off-by: Balazs Scheidler <bazsi@balabit.hu>
persist-state: free the SerializeArchive used for loading the state in persist_state_load_v4

Signed-off-by: Viktor Juhasz <jviktor@balabit.hu>
Signed-off-by: Balazs Scheidler <bazsi@balabit.hu>
persist-state: close fd and munmap current_map in persist_state_free()

This patch fixes a potential fd and mmap leak, as persist_state_free()
has not freed them. These leaks could only happen once per syslog-ng
invocation as only a single instance of PersistState is created and
is freed right before exiting.

Signed-off-by: Viktor Juhasz <jviktor@balabit.hu>
Signed-off-by: Balazs Scheidler <bazsi@balabit.hu>
serialize: remove unused include

Signed-off-by: Juhasz Viktor <jviktor@balabit.hu>
contrib/selinux: added syslog_ng.if and syslog_ng.sh files
mainloop: remove unneeded cfg_deinit() call from main_loop_run().

cfg_deinit() is called by main_loop_exit_finish() already, no need to call
it again.

Signed-off-by: Balazs Scheidler <bazsi@balabit.hu>
dnscache.c: use strtok_r() instead of strtok while parsing hosts file

To avoid data races between strtok() invocations.

Signed-off-by: Laszlo Budai <lbudiai@balabit.hu>
Signed-off-by: Balazs Scheidler <bazsi@balabit.hu>
dnscache: introduce global and per thread init/deinit functions

This patch splits the DNS cache initialization functions to a global
init/deinit to be called at startup time and a per-thread init/deinit
to be called at thread startup/shutdown time.

The DNS cache API should be refactored in a future point as it uses
a number of global variables where it should be using a GlobalConfig
specific state.

Signed-off-by: Viktor Juhasz <jviktor@balabit.hu>
Signed-off-by: Balazs Scheidler <bazsi@balabit.hu>
dnscache: use per-thread state in the mtime validation of the hosts file

Instead of using global variables in multithreaded code, use per-thread
variables to detect whether the hosts file has changed.

Signed-off-by: Juhasz Viktor <jviktor@balabit.hu>
Signed-off-by: Balazs Scheidler <bazsi@balabit.hu>
dnscache: check thread_init()/deinit() pairing with assert calls

This patch adds asserts to make sure that thread_init/deinit calls are
properly paired.

Signed-off-by: Balazs Scheidler <bazsi@balabit.hu>
test_dnscache: remove inet_ntop() benchmark

This is not needed anymore, it was used to determine whether it makes
sense to store negative matches in the DNS cache. As inet_ntop()
proved about 5x slower it did make sense. But we are doing that and
no need to validate this decision at every unit test invocation. I don't
expect this to change dramatically.

Signed-off-by: Balazs Scheidler <bazsi@balabit.hu>
persist-state: remove main_loop_assert_main_thread() call

This is the only coupling between persist-state and mainloop and I prefer
to reduce coupling over this assertion. The locking rules should be
documented separately.

Signed-off-by: Balazs Scheidler <bazsi@balabit.hu>
thread-utils: new module that wraps thread related utility functions

Working with threads involves some platform specifics, this module
is going to wrap these functions.

For now it provides an alternative to g_thread_self() as it allocates
a GThread instance for non-glib threads on Windows, which never gets freed
causing a memory leak.

Signed-off-by: Balazs Scheidler <bazsi@balabit.hu>
filter: rename filter_expr_node_init() to filter_expr_node_init_instance()

We also have a virtual init method, so rename the instance constructor
to init_instance().

Signed-off-by: Balazs Scheidler <bazsi@balabit.hu>