control: refactor to separate control operations from control channel

Earlier the control subsystem tightly coupled the implementation of the
control channel using UNIX domain sockets and the responses syslog-ng was
performing for each control request.

This patch nicely separates these concepts in both the server and the client
side of the control channel.

Signed-off-by: Juhasz Viktor <jviktor@balabit.hu>
Signed-off-by: Balazs Scheidler <bazsi@balabit.hu>
fixup! mainloop: refactor signals to use a small helper function
fixup! mainloop: factor out systemd communication into a service-management module
fixup! mainloop: factor out systemd communication into a service-management module
mainloop: fix reload handling

The mainloop refactor broke reload as one of the conditionals were negated
in its meaning, causing the reload machinery to never actually start.

Signed-off-by: Balazs Scheidler <bazsi@balabit.hu>
stats: added locking around GHashTable
stats: fix a stats-counter reference counting problem

Associated counters did not properly count the number of outstanding
references causing dynamic stats counters (e.g. per-$PROGRAM,
$HOST and $HOST_FROM) to be miscounted.

This didn't cause memory corruption as this reference counter didn't drive
free operations, it only validated validating stats
registrations/unregistratiions, but wasn't nice nevertheless.

Signed-off-by: Balazs Scheidler <bazsi@balabit.hu>
system-source: Use /dev/log on HP-UX

Using /dev/pipe on HP-UX was a mistake, use /dev/log instead, as the
original shell script did.

Signed-off-by: Gergely Nagy <algernon@balabit.hu>
autogen.sh: Use --copy for libtoolize and automake

Signed-off-by: Gergely Nagy <algernon@balabit.hu>
afstreams: Fix the CPPFLAGS for the module

It should look for files under both ${top_srcdir} and ${top_builddir},
not twice at the same place.

Signed-off-by: Gergely Nagy <algernon@balabit.hu>
afstreams: Migrate to new, working APIs

The afstreams module has been broken for more than a year, this patch
brings it back from the dead by migrating it to newer APIs and all.

Based on a patch by Balazs Scheidler <bazsi@balabit.hu>.

Signed-off-by: Gergely Nagy <algernon@balabit.hu>
system-source: Fix the uname() call on Solaris

On Solaris, uname() can return any positive value, and that indicates
success. Pretty much everywhere else, only 0 does. Thankfully, -1
signals failure everywhere, so check for that.

This makes system() work on Solaris again.

Signed-off-by: Gergely Nagy <algernon@balabit.hu>
Signed-off-by: Balazs Scheidler <bazsi@balabit.hu>
affile: fixed a pipe permission problem

When syslog-ng creates a pipe, create it with user-specified permissions
or restrictive ones (0600) by default, instead of creating it with broad
read-write permissions (0666) and patching it up later.

Signed-off-by: Budai Laszlo <lbudai@balabit.hu>
Signed-off-by: Gergely Nagy <algernon@balabit.hu>
libtest: Added AssertPipe for assert messages arriving on a LogPipe.

AssertPipe provides a LogPipe, on which we can assert on the nvpairs
of an arriving LogMessage.

Unfortunately, so far only one nvpair/LogMessage can be asserted.

Example:
  assert_pipe_new("prop1", "value1", "prop2", "value2");

In this example, the first message is checked if it's "prop1" nvpair
has value "value1", the second message is checked if it's "prop2" nvpair
has value "value2".

If more LogMessages arrives on the AssertPipe, than nvpairs specified in the
constructor, and assertion is raised.
stringutils: Added string utility functions and added unittests for them

This is a place for collecting string utility functions, more
functions from misc.c and from various other source files will follow.
Only functions with unit test coverage can go into this file.
json, state: Added json-c as a git submodule.
state: Added StateHandler framework

StateHandler framework simplifies the usage of persist file entries.
It has a simple interface and it can contain several typed name-value
pairs. This patch does not contain the follow-up of this patch in the
other part of the syslog-ng.
rcptid: WIP: Added unique receipient id feature.

This id is persistent across restarts.

Config option is not implemented yet.
serialization: Added logmsg and nvtable serialization.

Added large number of tests for deserialization, especially for older
types of serialized log messages.