json: add dot-notation evaluation

This patch adds an implementation for JSON dot notation evaluation. It
can parse a JavaScript dot-notation form and evaluate it on a given
JSON object.

Signed-off-by: Balazs Scheidler <bazsi@balabit.hu>
json: add extract-prefix() option to json-parser

This option adds a new option to json-parser() that instructs the parser
to only extract JSON members from a specific subtree of the incoming object.

Example:
  json-parser(extract-prefix("foo.bar[5]"));

Assuming that the incoming object is named msg, this is equivalent to the
following javascript code:

  msg.foo.bar[5]

The resulting expression must be a JSON object, so that syslog-ng can
extract its members into LogMessage name-value pairs.

This also works when the top-level object is an array, as extract-prefix()
allows the use of an array index at the first indirection level, e.g.

  json-parser(extract-prefix("[5]"));

which translates to: msg[5]

Signed-off-by: Balazs Scheidler <bazsi@balabit.hu>
nodejs: add nodejs() source driver

This patch adds an SCL macro that configures syslog-ng to accept messages
from node applications which use winston as their logging API.

Here's how to configure the Logger in the node application:

$ npm install winston winston-nssocket

==== logapp.js ====
var winston = require('winston')
var nssocket = require('winston-nssocket').Nssocket

winston.add(nssocket, {
  host: 'localhost',
    port: 9003
});

winston.log('info', 'Hello syslog-ng!', {'meta': 'info'} );

=================

And here's how to configure the syslog-ng side:

# make sure that scl is included
@include "scl.conf"
source s_network {
	nodejs();
}:

The nodejs() driver uses port 9003 by default, but you can
change the bind parameters with the port() and localip() parameters.

Signed-off-by: Balazs Scheidler <bazsi@balabit.hu>
run-id: Added implementation of run_id.

run_id is changed every time when syslog-ng is restarted but not when it is
reloaded. The actual value is stored in the persist file. A macro named RUNID
is available for using its value.
lib/tests/Makefile.am: Clean up after test_run_id

Add test_run_id.persist- and test_run_id.persist to CLEANFILES. While
the second one should be automatically cleaned up by the test case, we
leave that in here too, for good measures. And make clean should clean
up after a failed test run, too, anyway.

Signed-off-by: Gergely Nagy <algernon@balabit.hu>
run-id: Changed the persist key of run-id feature.

Signed-off-by: Viktor Tusa <tusa@balabit.hu>
afsocket: Only build the tests if SSL is enabled

The tests require SSL support enabled, and compilation fails if it is
not present. Only build and run them when SSL support is available.

Reported-by: Viktor Tusa <tusa@balabit.hu>
Signed-off-by: Gergely Nagy <algernon@balabit.hu>
driver: Fix a memory leak in log_driver_free()

After freeing up the members of self->plugins, free self->plugins itself
too.

Signed-off-by: Gergely Nagy <algernon@balabit.hu>
json: Added json-c as git submodule
run-id: Fixed run_id_is_same_run functionality.

The test and the code was obviously bad.

Signed-off-by: Tusa Viktor <tusavik@gmail.com>
libtest: Added library for persist-related functions in tests.

This lib covers common tasks for creating/restarting/destroying
PersistState objects.

Also refactored test to use persist_lib provided functions.

Signed-off-by: Viktor Tusa <tusa@balabit.hu>
persist-state: Refactor and extend some PersistEntry-related functions.

Added persist_state_remove_entry.

Removing an entry from persist-state sets its in_use value to zero.
At next open of persist_state, this entry will be purged.
logmsg: Do not use NULL template_options parameter for log_macro_expand.

In case of time-related macros, it uses the members of the
LogTemplateOptions* structure, but it results in a NULL pointer
dereference. Instead of spraying the log_macro_expand code with NULL checks,
we pass an initialized options structure to the function, and wrap it
in the log_macro_expand_simple function.

Signed-off-by: Viktor Tusa <tusa@balabit.hu>
Signed-off-by: Balazs Scheidler <bazsi@balabit.hu>
contrib: Add a Valgrind suppression file

When debugging memory leaks in syslog-ng, there are a couple of known
false positives, or leaks we do not care about (such as OpenSSL
initialisers and such). To silence those, a suppression file was
created. Simply add a --suppressions=/path/to/valgrind/syslog-ng.supp to
the Valgrind command line, and there will be so much less noise.

Signed-off-by: Gergely Nagy <algernon@balabit.hu>
persist-state: Clean up the temporary file upon destroy

When destroying a persist state, unlink the temporary file too, as to
not leave junk behind. Added test cases for both the commit() +
destroy() and the cancel() + destroy() cases. With this fixed, the
persist files created during make check need not be in CLEANFILES.

Signed-off-by: Gergely Nagy <algernon@balabit.hu>
Makefile: Fix make dist in certain edge cases

Due to the way internal modules were built, if both mongodb and
libmongo-client was disabled, make dist failed. When amqp was explicitly
disabled, make dist failed.

The reason being, we use a dummy.c to trigger building the bundled
libraries, but the dummy.c files were not created if mongodb/amqp were
disabled. Now we create them anyway, just don't recurse into the
directory when the module is disabled.

Signed-off-by: Gergely Nagy <algernon@balabit.hu>
afsql: use reentrant interface for libdbi

Signed-off-by: Budai Laszlo <lbudai@balabit.hu>
afsql: force to use libdbi 0.9.0

The reentrant interface is released in a public version of libdbi[0.9.0]

Signed-off-by: Budai Laszlo <lbudai@balabit.hu>