afinet: Disable KEEP_ALIVE when using spoof source

Disabling KEEP_ALIVE when using spoof source will result in rebuilding
the writer at reload, thus, also resolving the destination. This fixes
the issue of never resolving the destination after a reload, and
ending up sending packets to 0.0.0.0.

Patch from Balazs Scheidler <bazsi@balabit.hu>, after debugging the
problem in person, and going through all the different options.

Reported-by: Marvin Nipper <marvin.nipper@stream.com>
Signed-off-by: Gergely Nagy <algernon@balabit.hu>
afsocket: handle max_connections validation properly on SIGHUP

In case a SIGHUP was processed, the num_connections variable got reset to
zero, which made it possible to accept connections excess the
max-connections() option. This patch fixes that by properly setting
the number of connections after reload.

Reported-By: Sandor Geller <wildy@muhelybt.hu>
Signed-off-by: Balazs Scheidler <bazsi@balabit.hu>
Preparations for 3.3.6.

NEWS & VERSION updated to 3.3.6.

Signed-off-by: Gergely Nagy <algernon@balabit.hu>
ivykis: Update to the latest head of the stable-0.30 branch

The stable-0.30 branch has a few fixes that affect us, for example on
Solaris, update the submodule to pull those patches in.

Signed-off-by: Gergely Nagy <algernon@balabit.hu>
cfg-lexer: Fix glob-based include order

When using glob-based includes, matching files were immediately
included, which resulted in the include stack going bonkers. The
proper way to do glob-based includes is to do the same as in the
directory-based case: add the files to the current include stack
level's file list.

This patch does just that, thereby making glob-based includes work as
one would expect them to work.

Signed-off-by: Gergely Nagy <algernon@balabit.hu>
Fix the module registry display in debug mode

In debug mode, msg_init(TRUE) must be called, but we were calling
msg_init(FALSE) unconditionally, which led to segmentation faults when
trying to load the modules and log messages.

To fix this, do not call msg_init(FALSE) at startup, leave that to
app_start() later, but do call msg_init(TRUE) when necessary.

Patch from Tamas Pal <folti@balabit.hu>.

Reported-by: Jose Oliveira <jpo@di.uminho.pt>
Signed-off-by: Gergely Nagy <algernon@balabit.hu>
afsocket: fixed building the notls version

There was a collision in the macro used to enable SSL support in the
configure script and the macro defined by the Makefile in case the SSL
version is being built. The latter is now renamed to "BUILD_WITH_SSL".

Signed-off-by: Balazs Scheidler <bazsi@balabit.hu>
afsocket: Fix compilation without spoof-source

AFInetDestDriver->spoof_source is only available when compiling with
spoof-source enabled, so guard it with an #if.

Reported and patched by Dave Reisner <dreisner@archlinux.org>.

Signed-off-by: Gergely Nagy <algernon@balabit.hu>
lib/ivykis: Update to latest stable-v0.30

Update the bundled ivykis submodule to a commit that fixes the spinning
on FreeBSD.

Reported-by: Cy Schubert <cy@FreeBSD.org>
Signed-off-by: Gergely Nagy <algernon@balabit.hu>
doc: Move old ChangeLogs to doc/

The old ChangeLogs (especially ChangeLog) were looking stale in the
root directory, and ChangeLog was overwritten at make dist
anyway. Since they're historic, move them to doc/: they'll still be
available in the git repo, but they will not be included in the
tarball.

The top-level makefile will continue to re-generate ChangeLog
appropriately, so that the built tarballs will continue to have an
up-to-date changelog.

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

NEWS & VERSION updated for 3.3.6.90 (aka 3.3.7 RC1)

Signed-off-by: Gergely Nagy <algernon@balabit.hu>
afsocket: In case of unix-dgram sources, include the filename in stats

The file source includes the filename of the source in the stats, but
the unix-dgram source does not do the same, which makes it harder to
identify which unix-dgram stat belongs to which source.

With a little change to afsocket_sc_stats_instance(), we can fix that,
by teaching this function to use self->owner->bind_addr if
self->peer_addr is unset.

Reported-by: Evan Rempel <erempel@uvic.ca>
Signed-off-by: Gergely Nagy <algernon@balabit.hu>
Add a Travis-CI control file

Signed-off-by: Gergely Nagy <algernon@balabit.hu>
autogen.sh: No need to special-case lib/ivykis anymore

The --disable-kqueue and --disable-dev-poll options were only
recognised by the BalaBit fork of ivykis. Since we switched to
upstream, these are both obsolete and unnecessary, so lets remove
them.

Signed-off-by: Gergely Nagy <algernon@balabit.hu>
Use https URLs for the submodules & update libmongo-client

Because https can be cloned easier from behind a proxy than git, use
https URLs. While there, also update libmongo-client to v0.1.5, the
latest stable release.

Signed-off-by: Gergely Nagy <algernon@balabit.hu>
afsql: fixed the failure handling branch in afsql

An "address-of" operator was missing from log_queue_push_head() call,
potentially causing crashes when the insertion of a record fails.

Signed-off-by: Balazs Scheidler <bazsi@balabit.hu>
simplify *Options initialization pattern (LogReaderOptions, LogWriterOptions, etc)

The _init() method for various *Options structures were needlessly
complicated with an ugly warning on top of each and every such function.
After giving some thought to why it needs to be so complicated a much
easier pattern could be created, eliminating most of the complexity.

Earlier *_options_init() methods were prepared to be called several times
without a pairing _options_destroy(), e.g. if any memory was allocated
by init, a repeated init should have preserved the allocation (or at least
free the one the previous invocation allocated). This pattern caused
these init methods to actually save a number of variables locally
before commencing on the actual initialization and then restoring
them afterwards.

After giving some thought, this actually addressed an unused use-case:
if the init method is called for the same Options structure with
a changed GlobalConfig instance. In this case init would've inherited
the changed values from GlobalConfig.

However this never happens in reality, options structures may indeed be
initialized multiple times, however in this case the GlobalConfig remains
the same.

Removing this assumption simplifies the code a lot and makes it much more
readable, and finally stops spreading that terrifying comment on the top
as the pattern got implemented in a number of places.

Signed-off-by: Balazs Scheidler <bazsi@balabit.hu>
LogTransportPlain: use polymorphic classes instead of a large number of branches in code

This patch splits LogTransportPlain to 5 polimorphic classes to make the
code easier to follow, and possibly split the source code to five files
in the future.
libtest: added LogProto testing framework as proto_lib.{c,h}

In a similar vain to template_lib.{c,h} implement a LogProto related
assertions and helper functions. Centralizing this makes it possible to
test various LogProto implementations from different unit tests easily
without having to duplicate code.

Signed-off-by: Balazs Scheidler <bazsi@balabit.hu>
LogProto reorganization to support plugins

This patch is a large-scale refactoring for the LogProto code, it does
a number of things and should probably be split to a number of independent
patches for easier review. For now it is a single patch.

  * split the abstract base class LogProto into
    LogProtoClient & LogProtoServer. These are quite independent
    (one doing fetches the other posts), so no explanation why they should
    be the same.
  * LogProtoOptions is introduced to hold options related to LogProto
    classes. The options parsed by the core is provided by a
    cfg-grammar rule too (to be included in plugin specific grammars)
  * added valiate_options method that checks at _init() time whether the
    options parsed from the config make any sense. That's the only
    error-handling possibility as the constructor may not return NULL.
  * LogProto classes got split into a number of files, they are provided
    by the core as classes and the ones used as network transports
    are also published as a plugin. This way extending LogProto with
    a module-specific behaviour can use the base classes, and standard
    protocols can be instantiated using the plugin interface (to be used
    as the transport() option for the network/syslog drivers).