diff -Nru syslog-ng-3.11.1/.astylerc syslog-ng-3.13.2/.astylerc --- syslog-ng-3.11.1/.astylerc 2017-07-31 09:05:32.000000000 +0000 +++ syslog-ng-3.13.2/.astylerc 2017-12-06 06:39:39.000000000 +0000 @@ -25,5 +25,5 @@ --ignore-exclude-errors --exclude="lib/ivykis" --exclude="lib/jsonc" ---exclude="modules/afamqp" +--exclude="modules/afamqp/rabbitmq-c" --exclude="modules/afmongodb/mongo-c-driver" diff -Nru syslog-ng-3.11.1/autogen.sh syslog-ng-3.13.2/autogen.sh --- syslog-ng-3.11.1/autogen.sh 2017-07-31 09:05:32.000000000 +0000 +++ syslog-ng-3.13.2/autogen.sh 2017-12-06 06:39:39.000000000 +0000 @@ -69,9 +69,7 @@ cd "$submod" if [ -x autogen.sh ]; then # NOCONFIGURE needed by mongo-c-driver - export NOCONFIGURE=1 - ./autogen.sh - unset NOCONFIGURE + NOCONFIGURE=1 ./autogen.sh elif [ -f configure.in ] || [ -f configure.ac ]; then autoreconf -i else @@ -81,7 +79,7 @@ CONFIGURE_OPTS="--disable-shared --enable-static --with-pic" # kludge needed by make distcheck in mongo-c-driver - CONFIGURE_OPTS="$CONFIGURE_OPTS --enable-man-pages --disable-shm-counters" + CONFIGURE_OPTS="$CONFIGURE_OPTS --enable-man-pages --disable-shm-counters --with-libbson=bundled" sed -e "s/@__CONFIGURE_OPTS__@/${CONFIGURE_OPTS}/g" ${origdir}/sub-configure.sh >configure.gnu cd "$origdir" diff -Nru syslog-ng-3.11.1/configure.ac syslog-ng-3.13.2/configure.ac --- syslog-ng-3.11.1/configure.ac 2017-07-31 09:05:32.000000000 +0000 +++ syslog-ng-3.13.2/configure.ac 2017-12-06 06:39:39.000000000 +0000 @@ -233,7 +233,7 @@ AC_ARG_WITH(mongoc, [ --with-mongoc=[system/internal/auto/no] Link against the system supplied or the built-in mongo-c-driver library. (default: auto)] - ,,with_mongoc="auto") + ,,with_mongoc="internal") AC_ARG_ENABLE(legacy-mongodb-options, [ --enable-legacy-mongodb-options=[yes/no] @@ -243,7 +243,7 @@ AC_ARG_WITH(jsonc, [ --with-jsonc=[system/internal/auto/no] Link against the system supplied or the built-in jsonc library or explicitly disable it. (default:auto)] - ,,with_jsonc="auto") + ,,with_jsonc="internal") AC_ARG_ENABLE(json, [ --enable-json=[yes/no] Enable JSON support (default: yes)] @@ -390,6 +390,9 @@ PKG_PROG_PKG_CONFIG LT_INIT([dlopen disable-static]) AC_PATH_PROG(PYTHON, python) +if test -z "${PYTHON}"; then + AC_MSG_ERROR([Python interpreter is required]) +fi dnl *************************************************************************** dnl Validate yacc @@ -434,6 +437,22 @@ fi dnl *************************************************************************** +dnl Set up NO_PIE_LDFLAG: -no-pie is compatible with $CC. +old_LDFLAGS="$LDFLAGS" +LDFLAGS="$LDFLAGS -no-pie" + +AC_LINK_IFELSE([AC_LANG_SOURCE([int main(void) {return 0;}])], + [no_pie_option_available=yes], + [no_pie_option_available=no]) + +LDFLAGS="$old_LDFLAGS" + +if test "$no_pie_option_available" = "yes"; then + NO_PIE_LDFLAG="-no-pie" +fi +AC_SUBST([NO_PIE_LDFLAG]) + +dnl *************************************************************************** dnl Set up CFLAGS if test "x$ac_compiler_gnu" = "xyes"; then @@ -671,7 +690,6 @@ AC_CACHE_CHECK(for modern utmp, blb_cv_c_modern_utmp, [AC_TRY_COMPILE([ -#include #ifdef HAVE_UTMPX_H #include #else @@ -684,7 +702,7 @@ #else struct utmp ut; #endif - return &ut.ut_type && &ut.ut_user; + return sizeof(ut.ut_type) & sizeof(ut.ut_user); ], blb_cv_c_modern_utmp=yes, blb_cv_c_modern_utmp=no)]) @@ -835,7 +853,10 @@ old_LDFLAGS=$LDFLAGS LDFLAGS="$LDFLAGS $GLIB_LIBS" -AC_CHECK_FUNCS(g_mapped_file_unref) +old_LIBS=$LIBS +LIBS="$LIBS $GLIB_LIBS" +AC_CHECK_FUNCS(g_mapped_file_unref g_list_copy_deep) +LIBS=$old_LIBS AC_CACHE_CHECK(sanity checking Glib headers, blb_cv_glib_sane, @@ -960,6 +981,7 @@ AC_CHECK_DECLS([X509_get_extension_flags], [], [], [[#include ]]) AC_CHECK_DECLS([EVP_MD_CTX_reset], [], [], [[#include ]]) AC_CHECK_DECLS([ASN1_STRING_get0_data], [], [], [[#include ]]) +AC_CHECK_DECLS([DH_set0_pqg], [], [], [[#include ]]) CPPFLAGS="$CPPFLAGS_SAVE" @@ -1250,7 +1272,7 @@ PYTHON_VERSION=`python -V 2>&1 | cut -d ' ' -f 2` PYTHON_MAJOR=`echo $PYTHON_VERSION | cut -d '.' -f 1` PYTHON_MINOR=`echo $PYTHON_VERSION | cut -d '.' -f 2` - if test ${PYTHON} = "" || test $PYTHON_MAJOR -eq 2 && test $PYTHON_MINOR -lt 5; then + if test $PYTHON_MAJOR -eq 2 && test $PYTHON_MINOR -lt 5; then AC_MSG_WARN([Was about to execute rabbitmq configure script, but that requires Python >= 2.5, which you don't seem to have, reverting to system rabbitmq]) with_librabbitmq_client="system" else @@ -1302,17 +1324,30 @@ else enable_riemann="yes"; fi + + if test "$enable_riemann" = "yes"; then + + old_CFLAGS=$CFLAGS + CFLAGS=`pkg-config --cflags riemann-client` + AC_CHECK_DECLS(RIEMANN_EVENT_FIELD_TIME_MICROS, [riemann_micros="yes"], [riemann_micros="no"], [[#include ]]) + CFLAGS=$old_CFLAGS + fi fi dnl *************************************************************************** dnl python checks dnl *************************************************************************** if test "x$enable_python" != "xno"; then - if test "x$with_python" != "xauto"; then + if test "x$with_python" = "xauto"; then + PKG_CHECK_MODULES(PYTHON, python3, python_found="yes", python_found="no") + if test "$python_found" = "no"; then + PKG_CHECK_MODULES(PYTHON, python2, python_found="yes", python_found="no") + if test "$python_found" = "no"; then + PKG_CHECK_MODULES(PYTHON, python, python_found="yes", python_found="no") + fi + fi + else case "$with_python" in - auto) - with_python="python" - ;; [[0-9]]) with_python="python${with_python}" ;; @@ -1320,11 +1355,17 @@ with_python="python-${with_python}" ;; esac - else - with_python="python" + + PKG_CHECK_MODULES(PYTHON, $with_python, python_found="yes", python_found="no") + fi + + if test "x$python_found" = "xyes"; then + old_LIBS=$LIBS + LIBS="$LIBS $PYTHON_LIBS" + AC_CHECK_FUNCS(PyUnicode_AsUTF8, with_python=python3, with_python=python2) + LIBS=$old_LIBS fi - PKG_CHECK_MODULES(PYTHON, $with_python >= 2.6, python_found="yes", python_found="no") if test "x$enable_python" = "xyes" -a "x$python_found" = "xno"; then AC_MSG_ERROR([Could not find the requested Python development libraries]) fi @@ -1659,6 +1700,9 @@ AC_DEFINE_UNQUOTED(ENABLE_SYSTEMD, `enable_value $enable_systemd`, [Enable systemd support]) AC_DEFINE_UNQUOTED(SYSTEMD_JOURNAL_MODE, `journald_mode`, [Systemd-journal support mode]) AC_DEFINE_UNQUOTED(HAVE_INOTIFY, `enable_value $ac_cv_func_inotify_init`, [Have inotify]) +AC_DEFINE_UNQUOTED(ENABLE_PYTHONv2, `(echo "$with_python" | grep -Eq "python-?2.*") && echo 1 || echo 0`, [Python2 c api]) +AC_DEFINE_UNQUOTED(ENABLE_PYTHONv3, `(echo "$with_python" | grep -Eq "python-?3.*") && echo 1 || echo 0`, [Python3 c api]) +AC_DEFINE_UNQUOTED(HAVE_RIEMANN_MICROSECONDS, `enable_value $riemann_micros`, [Riemann microseconds support]) AM_CONDITIONAL(ENABLE_ENV_WRAPPER, [test "$enable_env_wrapper" = "yes"]) @@ -1807,7 +1851,7 @@ echo " GEOIP support (module) : ${enable_geoip:=no}" echo " GEOIP2 support (module) : ${enable_geoip2:=no}" echo " Redis support (module) : ${enable_redis:=no}" -echo " Riemann destination (module): ${enable_riemann:=no}" +echo " Riemann destination (module): ${enable_riemann:=no}, microseconds: ${riemann_micros:=no}" echo " python : ${enable_python:=no} (pkg-config package: ${with_python:=none})" echo " java : ${enable_java:=no}" echo " java modules : ${enable_java_modules:=no}" diff -Nru syslog-ng-3.11.1/contrib/solaris-packaging/syslog-ng@default syslog-ng-3.13.2/contrib/solaris-packaging/syslog-ng@default --- syslog-ng-3.11.1/contrib/solaris-packaging/syslog-ng@default 2017-07-31 09:05:32.000000000 +0000 +++ syslog-ng-3.13.2/contrib/solaris-packaging/syslog-ng@default 2017-12-06 06:39:39.000000000 +0000 @@ -1,6 +1,7 @@ SYSLOGNG_PREFIX=/usr/local CONFIG_FILE=/usr/local/etc/syslog-ng.conf -PERSIST_FILE=/usr/local/var/syslog-ng.persist -CONTROL_FILE=/usr/local/var/run/syslog-ng.ctl +VAR_DIR=/usr/local/var/lib/syslog-ng +PERSIST_FILE=/usr/local/var/lib/syslog-ng/syslog-ng.persist +CONTROL_FILE=/usr/local/var/lib/syslog-ng/run/syslog-ng.ctl PID_FILE=/var/run/syslog.pid OTHER_OPTIONS="--enable-core" diff -Nru syslog-ng-3.11.1/contrib/solaris-packaging/syslog-ng.method syslog-ng-3.13.2/contrib/solaris-packaging/syslog-ng.method --- syslog-ng-3.11.1/contrib/solaris-packaging/syslog-ng.method 2017-07-31 09:05:32.000000000 +0000 +++ syslog-ng-3.13.2/contrib/solaris-packaging/syslog-ng.method 2017-12-06 06:39:39.000000000 +0000 @@ -8,7 +8,7 @@ # added nicer options field # Modified for BalaBit Ltd's syslog-ng package by Tamas Pal Mar, 1st 2006 # Modified for BalaBit's syslog-ng package to make it multi-instance-able by György Pásztor Mar, 21th 2016 -# Minor modifications for Syslog-ng OSE by Janos Szigetvari Jul, 19th 2017 +# Minor modifications for Syslog-ng OSE by Janos Szigetvari Aug, 15th 2017 . /lib/svc/share/smf_include.sh @@ -34,22 +34,23 @@ SYSLOGNG_PREFIX=${SYSLOGNG_PREFIX:-/usr/local} SYSLOGNG="${SYSLOGNG_PREFIX}/sbin/syslog-ng" -VAR_DIR=${VAR_DIR:-${SYSLOGNG_PREFIX}/var} if [ "$instance" = "default" ]; then CONFIG_FILE=${CONFIG_FILE:-${SYSLOGNG_PREFIX}/etc/syslog-ng.conf} + VAR_DIR=${VAR_DIR:-${SYSLOGNG_PREFIX}/var/lib/syslog-ng} PID_FILE=${PID_FILE:-${SYSLOGPID_FILE}} else CONFIG_FILE=${CONFIG_FILE:-${SYSLOGNG_PREFIX}/etc/syslog-ng@${instance}.conf} - PID_FILE=${PID_FILE:-${VAR_DIR}/run/syslog-ng.pid} + VAR_DIR=${VAR_DIR:-${SYSLOGNG_PREFIX}/var/lib/syslog-ng@${instance}} [ -d "${VAR_DIR}" ] || mkdir "${VAR_DIR}" [ -d "${VAR_DIR}/run" ] || mkdir "${VAR_DIR}/run" fi -PERSIST_FILE=${PERSIST_FILE:-${VAR_DIR}/syslog-ng@${instance}.persist} -CONTROL_FILE=${CONTROL_FILE:-${VAR_DIR}/run/syslog-ng@${instance}.ctl} +PID_FILE=${PID_FILE:-${VAR_DIR}/run/syslog-ng.pid} +PERSIST_FILE=${PERSIST_FILE:-${VAR_DIR}/syslog-ng.persist} +CONTROL_FILE=${CONTROL_FILE:-${VAR_DIR}/run/syslog-ng.ctl} METHOD_OPTIONS="--cfgfile=${CONFIG_FILE} --pidfile=${PID_FILE} --persist-file=${PERSIST_FILE} --control=${CONTROL_FILE}" diff -Nru syslog-ng-3.11.1/contrib/syslog-ng-debun syslog-ng-3.13.2/contrib/syslog-ng-debun --- syslog-ng-3.11.1/contrib/syslog-ng-debun 2017-07-31 09:05:32.000000000 +0000 +++ syslog-ng-3.13.2/contrib/syslog-ng-debun 2017-12-06 06:39:39.000000000 +0000 @@ -7,7 +7,7 @@ ### This software may be used and distributed according to the terms of GNU GPLv2 ### http://www.gnu.org/licenses/gpl-2.0.html -version="0.3.5.20170710" +version="0.3.8.20170926" ### Check for "local" variable support if type local >/dev/null; then @@ -41,6 +41,7 @@ ipconfig="ip addr" routeconfig () { netstat -nr ; } netstatnlp () { netstat -nlp ; } +netstatlunp () { netstat -lunp ; } netstatsu="netstat -su" netstatpunt="netstat -punt" binprefix=/opt/syslog-ng @@ -54,8 +55,9 @@ duks="du -ks" grepq="fgrep -q" lddcmd="ldd" +topcmd () { top -b -n 1 -c >"${1}"; } opensslcmd="openssl" -pki_pubkey_parser_cmd="sed -E" +sed_equivalent_cmd="sed -E" mount=mount varlimit=1000 myplimit () { echo "Plimit query is not supported on this platform" >&3 ; } @@ -72,6 +74,8 @@ tcpdumpopts="-p -s 1500 -w" opensslmajor=0 getsyslogpids () { pidof syslog-ng ; } +os_hash_helper () { find . '!' \( -name debun.manifest -o -name syslog-ng.debun.txt \) -type f -print0 | xargs -0 md5sum ; } +dfk_parser () { tail -1 | while read FS ALL USED AVAIL UPERC MP; do if echo ${AVAIL} | ${grepq} '%'; then echo ${USED} ; else echo ${AVAIL} ; fi done ; } trace="strace -s256 -ff -ttT -f" initfile="/etc/init.d/syslog-ng" service_stop="${initfile} stop" @@ -260,23 +264,30 @@ } debun_do_tarball () { - cd $tmpdir + cd ${tmpdir} touch ${tmpdir}.tgz chmod 600 ${tmpdir}.tgz - $selftar | $gzipcmd >${tmpdir}.tgz + ${selftar} | ${gzipcmd} >${tmpdir}.tgz cd .. rm -r "${tmpdir}" printf "Terminating live message watcher: " sync - kill $tailpid + kill ${tailpid} sync sleep 1 } +debun_generate_hashes () { + cd ${tmpdir} + os_hash_helper > debun.manifest +} + debun_final() { debun_finish_debug [ -n "$service_status" ] && $service_status >${tmpdir}/svc.post - printf "\nDebug Bundle generation: Done.\n" + printf "\nGenerating hashes..." + debun_generate_hashes + printf " done.\nDebug Bundle generation: Done.\n" exec >&3 2>&1 debun_do_tarball printf "\n\nYour debug bundle will be stored at %s.tgz\n" "$tmpdir" @@ -344,6 +355,15 @@ acquire_system_info () { printf "System's full uname: " uname -a | tee "${tmpdir}/sys.uname" + free >${tmpdir}/sys.free + vmstat >${tmpdir}/sys.vmstat + topcmd "${tmpdir}/sys.top" + if is_available ${opensslcmd}; then + ${opensslcmd} version >${tmpdir}/sys.openssl.version + fi + if is_available java; then + java -version >${tmpdir}/sys.java.version 2>&1 + fi } acquire_network_info () { @@ -384,14 +404,9 @@ $dmesg >${tmpdir}/sys.dmesg netstatnlp >${tmpdir}/sys.netstat.ltn $netstatpunt >${tmpdir}/sys.netstat.est + netstatlunp >${tmpdir}/sys.netstat.lunp $netstatsu >${tmpdir}/sys.netstat.su - free >${tmpdir}/sys.free - vmstat >${tmpdir}/sys.vmstat [ -f /proc/net/udp ] && cp /proc/net/udp ${tmpdir}/sys.proc.net.udp - - if is_available ${opensslcmd}; then - ${opensslcmd} version >${tmpdir}/sys.openssl.version - fi } ### Here comes the general info acquiring parts @@ -458,14 +473,14 @@ if echo "${oneline_cert}" | $grepq "PublicKey:X509v3extensions"; then printf "NO_PUBLIC_KEY_COULD_BE_EXTRACTED;" else - echo "${oneline_cert}" | ${pki_pubkey_parser_cmd} 's/^.*(Modulus|modulus|pub)(\([0-9]+bit\))?:([a-f0-9:]+).*$/Public Key=\3;/' + echo "${oneline_cert}" | ${sed_equivalent_cmd} 's/^.*(Modulus|modulus|pub)(\([0-9]+bit\))?:([a-f0-9:]+).*$/Public Key=\3;/' fi fi } pki_guess_certificate () { - local header wccout buffer_pubkey buffer_rest hashopts hashnum - wccout=$( wc -c "${1}" ) + local header fsize buffer_pubkey buffer_rest hashopts hashnum + fsize=$( wc -c "${1}" | ${sed_equivalent_cmd} 's:^ *([0-9]+) .*$:\1:' ) if [ ${opensslmajor} -gt 0 ]; then hashopts="-subject_hash -subject_hash_old" @@ -479,12 +494,13 @@ [ "${certcount}" -gt 1 ] && header="STACKED_CERTIFICATE(${certcount});${1};" || header="CERTIFICATE;${1};" buffer_pubkey=$( ${opensslcmd} x509 -in "${1}" -text -noout 2>/dev/null | pki_parse_public_key ) buffer_rest=$( ${opensslcmd} x509 -in "${1}" -noout ${hashopts} -serial -dates -fingerprint -subject -issuer | tr '\n' ';' ) - printf "${header}${wccout% *};${buffer_pubkey}${hashnum}${buffer_rest}" + printf "${header}${fsize};${buffer_pubkey}${hashnum}${buffer_rest}" } pki_guess_private_key () { - local header wccout buffer_pubkey buffer_error - wccout=$( wc -c "${1}" ) + local header fsize buffer_pubkey buffer_error + fsize=$( wc -c "${1}" | ${sed_equivalent_cmd} 's:^ *([0-9]+) .*$:\1:' ) + if pki_is_encrypted "${1}"; then header="PRIVATE_ENCRYPTED;${1};" else @@ -509,15 +525,16 @@ buffer_pubkey=";" fi fi - printf "${header}${wccout% *};${buffer_pubkey}" + printf "${header}${fsize};${buffer_pubkey}" } pki_guess_public_key () { # Public keys do not have their type in the PEM header/footer - local header wccout buffer_pubkey buffer_error + local header fsize buffer_pubkey buffer_error header="PUBLIC;${1};" - wccout=$( wc -c "${1}" ) + fsize=$( wc -c "${1}" | ${sed_equivalent_cmd} 's:^ *([0-9]+) .*$:\1:' ) + if [ ${opensslmajor} -gt 0 ]; then buffer_error=$( ${opensslcmd} pkey -pubin -in "${1}" -noout -text 2>&1 >/dev/null ) if echo "${buffer_error}" | ${grepq} "unable to load"; then @@ -551,13 +568,13 @@ buffer_pubkey=$( ${opensslcmd} rsa -pubin -in "${1}" -noout -text 2>/dev/null | pki_parse_public_key ) fi fi - printf "${header}${wccout% *};${buffer_pubkey}" + printf "${header}${fsize};${buffer_pubkey}" } pki_other_file () { - local wccout - wccout=$( wc -c "${1}" ) - printf "OTHER_FILE;${1};${wccout% *};" + local fsize + fsize=$( wc -c "${1}" | ${sed_equivalent_cmd} 's:^ *([0-9]+) .*$:\1:' ) + printf "OTHER_FILE;${1};${fsize};" } pki_process_file () { @@ -584,7 +601,7 @@ read OPENSSL OPENSSLVER OPENSSLDAY OPENSSLMONTH OPENSSLYEAR REST <${tmpdir}/sys.openssl.version opensslmajor=${OPENSSLVER%%.*} cd "${confdir}" - find . -name '*.0' -o -name '*.key' -o -name '*.crt' -o -name '*.pem' >${tmpdir}/syslog.etc.pki.files 2>/dev/null + find . -name '*.0' -o -name '*.1' -o -name '*.key' -o -name '*.crt' -o -name '*.pem' >${tmpdir}/syslog.etc.pki.files 2>/dev/null while read FILE; do pki_process_file "${FILE}" >>${tmpdir}/syslog.etc.pki.info.csv done <${tmpdir}/syslog.etc.pki.files @@ -594,13 +611,25 @@ fi } +remove_passwords_from_file () { + # + # Double quotes are used because escaping single quotes within a single quoted string is ugly. + # [ \t\r\n\v\f] class is used for matching whitespaces, because \s is unavailable. + # The goal is matching substrings that look like this, to replace the password string, and preserve original formatting: + # password ( 'password-string' ) --> password ( '___PASSWORD_REMOVED___' ) + ### + ${sed_equivalent_cmd} "s|password([ \t\r\n\v\f]*)\(([ \t\r\n\v\f]*)([\"']?)[^)\"']+([\"']?)([ \t\r\n\v\f]*)\)|password\1(\2\3___PASSWORD_REMOVED___\4\5)|g" <"${1}" >"${1}.bak" 2>/dev/null + mv "${1}.bak" "${1}" +} + acquire_syslog_config () { echo "Copy configs from $confdir" cd "${confdir}" mkdir ${tmpdir}/config find . > ${tmpdir}/syslog.etc.files grep '\.key$' ${tmpdir}/syslog.etc.files > ${tmpdir}/syslog.etc.files.removed - grep -v '\.key$' ${tmpdir}/syslog.etc.files | \ + grep '\.jks$' ${tmpdir}/syslog.etc.files > ${tmpdir}/syslog.etc.files.removed + grep -v '\.key$' ${tmpdir}/syslog.etc.files | grep -v '\.jks' | \ while read FILE; do \ if pki_is_private_key "${FILE}" 2>/dev/null; then echo "${FILE}" >> ${tmpdir}/syslog.etc.files.removed @@ -609,6 +638,11 @@ fi done | \ cpio -pd ${tmpdir}/config + + find ${tmpdir}/config -name "*.conf*" | \ + while read FILE; do \ + remove_passwords_from_file "${FILE}" + done } acquire_syslog_pids () { @@ -639,6 +673,7 @@ } acquire_syslog_info () { + ls -la "${binprefix}" > ${tmpdir}/syslog.lsl.install_dir 2>&1 printf "Syslog-ng's exact version: " $syslogbin --version > ${tmpdir}/syslog.version head -1 ${tmpdir}/syslog.version @@ -659,23 +694,38 @@ is_available ${lsof%% *} && $lsof $i >${tmpdir}/syslog.$i.lsof 2>/dev/null || echo "No lsof in path." >${tmpdir}/syslog.$i.lsof myplimit $i >${tmpdir}/syslog.$i.limits done - $syslogbin -s --preprocess-into ${tmpdir}/syslog.pp.conf + + $syslogbin -s --preprocess-into "${tmpdir}/syslog.pp.conf" + [ -f "${tmpdir}/syslog.pp.conf" ] && remove_passwords_from_file "${tmpdir}/syslog.pp.conf" } acquire_syslog_var () { - ls -laR "${vardir}/" >${tmpdir}/syslog.lslR.var 2>&1 + ls -laR "${vardir}" >${tmpdir}/syslog.lslR.var 2>&1 $duks "${vardir}/" >${tmpdir}/syslog.duks.var read vardu dir <${tmpdir}/syslog.duks.var mkdir ${tmpdir}/var cd "${vardir}" - if [ "$vardu" -lt "$varlimit" ] ; then - find . |grep -v run\\/syslog-ng.ctl$ | cpio -pd ${tmpdir}/var + + freek_tmp=$( ${dfk} ${tmpdir} | dfk_parser ) + # + # low disk-space => only copy the persist file and the pid file + ### + if [ "${freek_tmp}" -gt "${vardu}" ] ; then + if [ "$vardu" -lt "$varlimit" ] ; then + find . |grep -v run\\/syslog-ng.ctl$ | cpio -pd ${tmpdir}/var + else + printf "Size of ${vardir} is larger than $varlimit kilobytes.\n" + printf "Do you really want to copy its contents? Type 'YES' with all capitals: " + read ans + if [ "$ans" = "YES" ]; then + find . | grep -v "syslog-ng*\.ctl" | cpio -pd ${tmpdir}/var + fi + fi else - printf "Size of ${vardir} is larger than $varlimit kilobytes.\n" - printf "Do you really want to copy its contents? Type 'YES' with all capitals: " - read ans - [ "$ans" = "YES" ] && find . |grep -v run\\/syslog-ng.ctl$ | cpio -pd ${tmpdir}/var + printf "TOO LOW free disk space on the filesystem holding ${tmpdir}\n" + printf "to create a full copy of ${vardir}!\nOnly copying most important files.\n" + find . \( -name "*.persist" -o -name "*.pid" \) | grep -v "syslog-ng.*\.ctl" | cpio -pd ${tmpdir}/var fi } @@ -848,6 +898,17 @@ echo "No getenforce in path." >"${tmpdir}/sys.selinux" fi + if is_available sysstat ; then + sysstat -P ALL 1 5 >${tmpdir}/sys.sar.cpu + sysstat -d 1 5 >${tmpdir}/sys.sar.disk + elif is_available sar ; then + sar -P ALL 1 5 >${tmpdir}/sys.sar.cpu + sar -d 1 5 >${tmpdir}/sys.sar.disk + fi + if is_available top; then + top -b -H -n 1 -c >${tmpdir}/sys.top.threads + fi + [ -n "$privacy_mode" ] && return if is_available dmidecode; then dmidecode >"${tmpdir}/sys.dmidecode" @@ -895,6 +956,13 @@ if is_available showrev ; then showrev >${tmpdir}/sys.showrev fi + if is_available sar ; then + sar -u 1 5 >${tmpdir}/sys.sar.cpu + sar -d 1 5 >${tmpdir}/sys.sar.disk + fi + if is_available top; then + top -b -t -n 1 -c >${tmpdir}/sys.top.threads + fi } ### Here comes solaris specific parts @@ -905,7 +973,9 @@ } debun_extra_freebsd() { - : + if is_available top; then + top -b -d1 -H >${tmpdir}/sys.top.threads + fi } debun_freebsd() { @@ -915,6 +985,11 @@ debun_extra_hpux () { sysdef >${tmpdir}/sys.sysdef swlist >${tmpdir}/sys.swlist + + if is_available sar ; then + sar -u 1 5 >${tmpdir}/sys.sar.cpu + sar -d 1 5 >${tmpdir}/sys.sar.disk + fi } debun_hpux () { @@ -923,6 +998,11 @@ debun_extra_aix () { alog -o -t console >${tmpdir}/sys.console-log + + if is_available sar ; then + sar -u 1 5 >${tmpdir}/sys.sar.cpu 2>/dev/null + sar -b 1 5 >${tmpdir}/sys.sar.disk 2>/dev/null1 + fi } debun_aix () { @@ -1097,7 +1177,7 @@ if echo "eee" | sed -E 's/eee/fff/g' >/dev/null 2>/dev/null ; then : else - pki_pubkey_parser_cmd="perl -p -e" + sed_equivalent_cmd="perl -p -e" fi } @@ -1139,21 +1219,25 @@ netstatpunt="netstat -n" netstatsu="netstat -s" grepq="/usr/xpg4/bin/grep -q" - pki_pubkey_parser_cmd="perl -p -e" + sed_equivalent_cmd="perl -p -e" - unset mypidof - unset getsyslogpids - unset netstatnlp - unset myplimit - unset free - unset distpkgoffile - unset distpkgstatus + unset -f mypidof + unset -f getsyslogpids + unset -f netstatlunp + unset -f netstatnlp + unset -f myplimit + unset -f topcmd + unset -f free + unset -f distpkgoffile + unset -f distpkgstatus unset -f is_available + unset -f os_hash_helper is_available () { which "$1" | $grepq "no $1 in" && return 1 || return 0 ; } mypidof () { $pseao pid,comm | while read pid bin ; do [ "$bin" = "$1" ] && echo $pid ; done ; } getsyslogpids () { mypidof "${syslogrealbin}" ; } netstatnlp () { netstat -na ; } + netstatlunp () { netstat -P udp -na ; } myplimit () { plimit $1 ; } free () { prtconf | grep Mem ; printf Pagesize:\ ; pagesize -a ; } distpkgoffile () { @@ -1170,6 +1254,24 @@ echo "" } + if is_available top; then + topcmd () { top -b -n 1 -c > "${1}" ; } + else + topcmd () { ( uptime ; echo ; echo "::memstat" | mdb -k ; sar -u 1 1 ; echo ; ps -eao user,pid,ppid,pcpu,pmem,vsz,rss,tty,s,stime,args | head -n 1; ps -eao user,pid,ppid,pcpu,pmem,vsz,rss,tty,s,stime,args | grep -v COMMAND | sort -rn +3 ) >"${1}" 2>/dev/null ; } + fi + + if is_available md5sum; then + os_hash_helper () { + find . '!' \( -name debun.manifest -o -name syslog-ng.debun.txt \) -type f -print0 | xargs -0 md5sum ; + } + elif is_available digest; then + os_hash_helper () { + find . '!' \( -name debun.manifest -o -name syslog-ng.debun.txt \) -type f -exec digest -a md5 -v '{}' \; | sed -e 's:^md5 (\(.*\)) = \([a-z0-9]\{32\}\)$:\2 \1:' + } + else + os_hash_helper () { : ; } + fi + if is_available svcadm ; then service_stop="svcadm disable system/syslog-ng:default" service_start="svcadm enable system/syslog-ng:default" @@ -1194,19 +1296,27 @@ service_start="${initfile} start" service_status="${initfile} status" - unset free - unset netstatnlp - unset mypidof - unset getsyslogpids - unset distpkgoffile - unset distpkgstatus + unset -f free + unset -f netstatnlp + unset -f netstatlunp + unset -f mypidof + unset -f topcmd + unset -f getsyslogpids + unset -f distpkgoffile + unset -f distpkgstatus + unset -f os_hash_helper free () { top -bt 0 ; } netstatnlp () { sockstat ; } + netstatlunp () { netstat -na | grep -E "(Internet|Proto|udp)" ; } + topcmd () { top -b -d1 > "${1}" ; } mypidof () { $pseao pid,comm | while read pid bin ; do [ "$bin" = "$1" ] && echo $pid ; done; } getsyslogpids () { mypidof syslog-ng ; } distpkgoffile () { : ; } distpkgstatus () { : ; } + os_hash_helper () { + find . '!' \( -name debun.manifest -o -name syslog-ng.debun.txt \) -type f -exec md5 '{}' \; | sed -e 's:^MD5 (\(.*\)) = \([a-z0-9]\{32\}\)$:\2 \1:' + } } setup_env_hpux () { @@ -1222,22 +1332,32 @@ service_stop="${initfile} stop" service_start="${initfile} start" service_status="${initfile} status" - pki_pubkey_parser_cmd="perl -p -e" + sed_equivalent_cmd="perl -p -e" unset -f free unset -f netstatnlp + unset -f netstatlunp unset -f mypidof + unset -f topcmd + unset -f os_hash_helper unset -f getsyslogpids unset -f getparent unset -f getchilds unset -f is_available + unset -f dfk_parser unset -f distpkgoffile unset -f distpkgstatus unset -f distpkgoffile_cleanup is_available () { which "$1" | $grepq "no $1 in" && return 1 || return 0 ; } free () { swapinfo -tam ; } - netstatnlp () { netstat -na ; } + netstatnlp () { netstat -na | grep -E "(Internet|Proto|LISTEN)" ; } + netstatlunp () { netstat -na | grep -E "(Internet|Proto|udp)" ; } + topcmd () { top -d 1 -f "${1}" ; } + dfk_parser () { grep free | while read AVAIL REST_TEXT; do echo ${AVAIL}; done } + os_hash_helper () { + find . '!' \( -name debun.manifest -o -name syslog-ng.debun.txt \) -type f -exec md5sum '{}' \; + } mypidof () { ps -e -f | while read uid pid ppid c stime tty time command extra ; do if [ "${stime%%:*}" = "${stime}" ] then @@ -1307,20 +1427,27 @@ service_stop="/usr/bin/stopsrc -s syslog-ng" service_start="/usr/bin/startsrc -s syslog-ng" service_status="/usr/bin/lssrc -s syslog-ng" - pki_pubkey_parser_cmd="perl -p -e" + sed_equivalent_cmd="perl -p -e" - unset initfile - unset netstatnlp - unset routeconfig - unset free - unset getsyslogpids - unset mypidof - unset format_ldd_output + unset -f initfile + unset -f netstatnlp + unset -f netstatlunp + unset -f routeconfig + unset -f free + unset -f dfk_parser + unset -f getsyslogpids + unset -f mypidof + unset -f topcmd + unset -f format_ldd_output + unset -f os_hash_helper format_ldd_output () { sed -e 's:^[^/]*\(.*\)$:\1:' -e 's:^\(.*\)(.*)$:\1:'; } - netstatnlp () { netstat -na | grep LISTEN ; } + netstatnlp () { netstat -na | grep -E "(Active|Proto|LISTEN)" ; } + netstatlunp () { netstat -na | grep -E "(Internet|Proto|udp)" ; } + dfk_parser () { tail -1 | while read FS ALL AVAIL UPERC IUPERC MP; do echo ${AVAIL}; done } routeconfig () { if netstat -nr 2>&1 | $grepq 'Permission error' ; then echo 'WPAR without its own routing table.' ; else netstat -nr ; fi ; } free () { svmon -G -O unit=KB ; } + topcmd () { ( uptime ; svmon -G | head -n 3 ; sar -u 1 1 ; echo ; ps auxwww | head -n 1; ps auxwww | grep -v COMMAND | sort -rn +2 ) >"${1}" 2>/dev/null ; } mypidof () { ps -eaf | while read user pid ppid c stime tty time cmd extra; do if [ "${stime%%:*}" = "${stime}" ] then @@ -1344,6 +1471,9 @@ rpm -qi $1 printf "\n" } + os_hash_helper () { + find . '!' \( -name debun.manifest -o -name syslog-ng.debun.txt \) -type f -exec csum -h MD5 '{}' \; + } } setup_env_generic_pre () { @@ -1353,11 +1483,13 @@ setup_env_generic_post () { ### Check if ss is available (should only be present on Linux) if is_available ss ; then - unset routeconfig - unset netstatnlp + unset -f routeconfig + unset -f netstatnlp + unset -f netstatlunp routeconfig () { ip route show ; } netstatnlp () { ss -nlp ; } + netstatlunp () { ss -lunp ; } netstatpunt="ss -punt" fi if is_available netstat; then diff -Nru syslog-ng-3.11.1/contrib/valgrind/syslog-ng.supp syslog-ng-3.13.2/contrib/valgrind/syslog-ng.supp --- syslog-ng-3.11.1/contrib/valgrind/syslog-ng.supp 2017-07-31 09:05:32.000000000 +0000 +++ syslog-ng-3.13.2/contrib/valgrind/syslog-ng.supp 2017-12-06 06:39:39.000000000 +0000 @@ -24,6 +24,14 @@ ## Miscellaneous non-leaks and false alarms { + suppress_journald_open: see https://github.com/systemd/systemd/issues/6539 + Memcheck:Leak + ... + fun:journald_open + ... +} + +{ suppress_syslog_ng_set_argv_space Memcheck:Leak fun:*alloc @@ -51,17 +59,6 @@ } { - suppress_syslog_ng_path_resolver - Memcheck:Leak - fun:*alloc - ... - fun:path_resolver_new - ... - fun:main_loop_global_init - fun:main -} - -{ suppress_syslog_ng_option_context_parse Memcheck:Leak fun:*alloc @@ -105,15 +102,6 @@ } { - suppress_syslog_ng_reloc - Memcheck:Leak - fun:*alloc - ... - fun:cache_* - fun:get_installation_path_for -} - -{ suppress_syslog_ng_msg_limit_internal_message Memcheck:Leak fun:*alloc @@ -133,14 +121,6 @@ } { - suppress_syslog_ng_aftiner_message_posted - Memcheck:Leak - fun:*alloc - ... - fun:afinter_message_posted -} - -{ supperess_syslog_ng_log_msg_new_internal Memcheck:Leak fun:*alloc @@ -190,15 +170,6 @@ } { - suppress_crypto_ERR_leaks - Memcheck:Leak - fun:*alloc - ... - obj:*/libcrypto.so.* - fun:ERR_* -} - -{ suppress_crypto_OCSP_leaks Memcheck:Leak fun:*alloc @@ -207,15 +178,6 @@ fun:OCSP_* } -{ - suppress_crypto_EVP_leaks - Memcheck:Leak - fun:*alloc - ... - obj:*/libcrypto.so.* - fun:EVP_* -} - ## TLS/SSL related syslog-ng leaks { suppress_syslog_ng_crypto_leaks diff -Nru syslog-ng-3.11.1/dbld/deb syslog-ng-3.13.2/dbld/deb --- syslog-ng-3.11.1/dbld/deb 2017-07-31 09:05:32.000000000 +0000 +++ syslog-ng-3.13.2/dbld/deb 2017-12-06 06:39:39.000000000 +0000 @@ -3,22 +3,19 @@ set -e cd /source -if [ ! -d debian ]; then - echo "You don't seem to have a debian subdirectory, which means one of the followings:" - echo " 1) you don't do this from a release tarball" - echo " 2) you haven't merged the 'release' branch" - echo " 3) you didn't create debian packaging manually" - echo "" - echo "Please make sure you have obtained a source distribution with a debian dir and rerun this command" - exit 1 -fi VERSION=`cat VERSION` - +GITREF=`git describe` cd /build -tar xvf syslog-ng-${VERSION}.tar.gz +rm -rf syslog-ng-${VERSION} +tar xf syslog-ng-${VERSION}.tar.gz cp syslog-ng-${VERSION}.tar.gz syslog-ng_${VERSION}.orig.tar.gz cd syslog-ng-${VERSION} + +if [ ! -d debian ]; then + echo "You have no Debian packaging in debian/, this should already by in the tarball at this point" + exit 1 +fi dpkg-buildpackage -rfakeroot echo "Your debs are in /build, also available on the host in \$(top_srcdir)/dbld/build" diff -Nru syslog-ng-3.11.1/dbld/generate-debian-directory syslog-ng-3.13.2/dbld/generate-debian-directory --- syslog-ng-3.11.1/dbld/generate-debian-directory 1970-01-01 00:00:00.000000000 +0000 +++ syslog-ng-3.13.2/dbld/generate-debian-directory 2017-12-06 06:39:39.000000000 +0000 @@ -0,0 +1,17 @@ +#!/bin/bash + +MODE=$1 +VERSION=`cat /source/VERSION` + +cp -r /source/packaging/debian . +if [ $MODE = "snapshot" ]; then + echo "Generating snapshot version in debian/" + DEBEMAIL="dev@null" DEBFULLNAME="syslog-ng snapshot" debchange --newversion ${VERSION}-1+`date +%Y%m%dT%H%M%S` "Snapshot release based on ${GITREF}" +elif [ $MODE = "release" ]; then + echo "Validating if your debian/ directory matches current version" + DEB_VERSION=`dpkg-parsechangelog -S Version | cut -d - -f1` + if [ "${DEB_VERSION}" != "${VERSION}" ]; then + echo "The version numbers in debian/changelog do not match the current version number. Cannot generate a release tarball this way" + exit 1 + fi +fi diff -Nru syslog-ng-3.11.1/dbld/generate-rpm-specfile syslog-ng-3.13.2/dbld/generate-rpm-specfile --- syslog-ng-3.11.1/dbld/generate-rpm-specfile 1970-01-01 00:00:00.000000000 +0000 +++ syslog-ng-3.13.2/dbld/generate-rpm-specfile 2017-12-06 06:39:39.000000000 +0000 @@ -0,0 +1,19 @@ +#!/bin/bash + +MODE=$1 +VERSION=`cat /source/VERSION` + +cp /source/packaging/rhel/* . + +if [ $MODE = "snapshot" ]; then + echo "Generating snapshot version in syslog-ng.spec" + sed -e "s/^Version: \([0-9.]\+\)/Version: $VERSION/" \ + -e "s/^Release: \([0-9.]\+\)/Release: \1+`date +%Y%m%dT%H%M%S`/" -i syslog-ng.spec +elif [ $MODE = "release" ]; then + echo "Validating that your RPM specfile matches the current version" + RPM_VERSION=`grep ^Version syslog-ng.spec | cut -d ' ' -f2` + if [ "${RPM_VERSION}" != "${VERSION}" ]; then + echo "The version numbers in syslog-ng.spec do not match the current version number. Cannot generate a release tarball this way" + exit 1 + fi +fi diff -Nru syslog-ng-3.11.1/dbld/images/centos7/dev-dependencies.txt syslog-ng-3.13.2/dbld/images/centos7/dev-dependencies.txt --- syslog-ng-3.11.1/dbld/images/centos7/dev-dependencies.txt 2017-07-31 09:05:32.000000000 +0000 +++ syslog-ng-3.13.2/dbld/images/centos7/dev-dependencies.txt 2017-12-06 06:39:39.000000000 +0000 @@ -20,13 +20,11 @@ #ivykis-devel json-c-devel ivykis-devel -gradle libdbi libdbi-drivers librdkafka riemann-c-client-devel syslog-ng-java-deps -eventlog-devel autoconf-archive GeoIP-devel python-pep8 @@ -38,6 +36,8 @@ rpm-build java-1.8.0-openjdk-devel libuuid-devel +libmaxminddb-devel +libmongo-client-devel # required for make make # required for make check @@ -52,4 +52,3 @@ docbook-xsl python-nose python-ply -libmaxminddb-devel diff -Nru syslog-ng-3.11.1/dbld/images/centos7/Dockerfile syslog-ng-3.13.2/dbld/images/centos7/Dockerfile --- syslog-ng-3.11.1/dbld/images/centos7/Dockerfile 2017-07-31 09:05:32.000000000 +0000 +++ syslog-ng-3.13.2/dbld/images/centos7/Dockerfile 2017-12-06 06:39:39.000000000 +0000 @@ -3,11 +3,13 @@ RUN yum install -y wget epel-release -RUN cd /etc/yum.repos.d && wget https://copr.fedorainfracloud.org/coprs/czanik/syslog-ng39/repo/epel-7/czanik-syslog-ng39-epel-7.repo +RUN cd /etc/yum.repos.d && wget https://copr.fedorainfracloud.org/coprs/czanik/syslog-ng311/repo/epel-7/czanik-syslog-ng311-epel-7.repo ADD dev-dependencies.txt . RUN cat dev-dependencies.txt | grep -v "#" | xargs yum -y install - +ADD gradle_installer.sh . +RUN ./gradle_installer.sh +RUN echo "/usr/lib/jvm/jre/lib/amd64/server" | tee --append /etc/ld.so.conf.d/openjdk-libjvm.conf && ldconfig # # if you want to add further packages, add them to addons.txt to make image diff -Nru syslog-ng-3.11.1/dbld/images/centos7/gradle_installer.sh syslog-ng-3.13.2/dbld/images/centos7/gradle_installer.sh --- syslog-ng-3.11.1/dbld/images/centos7/gradle_installer.sh 1970-01-01 00:00:00.000000000 +0000 +++ syslog-ng-3.13.2/dbld/images/centos7/gradle_installer.sh 2017-12-06 06:39:39.000000000 +0000 @@ -0,0 +1,10 @@ +#!/bin/bash + +export GRADLE_HOME=/opt/gradle +export GRADLE_VERSION=4.1 +wget --no-verbose --output-document=gradle.zip "https://services.gradle.org/distributions/gradle-${GRADLE_VERSION}-bin.zip" + +unzip gradle.zip +rm gradle.zip +mv "gradle-${GRADLE_VERSION}" "${GRADLE_HOME}/" +ln --symbolic "${GRADLE_HOME}/bin/gradle" /usr/bin/gradle diff -Nru syslog-ng-3.11.1/dbld/images/jessie/dev-dependencies.txt syslog-ng-3.13.2/dbld/images/jessie/dev-dependencies.txt --- syslog-ng-3.11.1/dbld/images/jessie/dev-dependencies.txt 2017-07-31 09:05:32.000000000 +0000 +++ syslog-ng-3.13.2/dbld/images/jessie/dev-dependencies.txt 2017-12-06 06:39:39.000000000 +0000 @@ -10,7 +10,6 @@ libcap-dev libdbi-dev libesmtp-dev -libevtlog-dev libgeoip-dev libglib2.0-dev libhiredis-dev diff -Nru syslog-ng-3.11.1/dbld/images/xenial/dev-dependencies.txt syslog-ng-3.13.2/dbld/images/xenial/dev-dependencies.txt --- syslog-ng-3.11.1/dbld/images/xenial/dev-dependencies.txt 2017-07-31 09:05:32.000000000 +0000 +++ syslog-ng-3.13.2/dbld/images/xenial/dev-dependencies.txt 2017-12-06 06:39:39.000000000 +0000 @@ -10,7 +10,6 @@ libcap-dev libdbi-dev libesmtp-dev -libevtlog-dev libgeoip-dev libglib2.0-dev libhiredis-dev diff -Nru syslog-ng-3.11.1/dbld/images/zesty/dev-dependencies.txt syslog-ng-3.13.2/dbld/images/zesty/dev-dependencies.txt --- syslog-ng-3.11.1/dbld/images/zesty/dev-dependencies.txt 2017-07-31 09:05:32.000000000 +0000 +++ syslog-ng-3.13.2/dbld/images/zesty/dev-dependencies.txt 2017-12-06 06:39:39.000000000 +0000 @@ -4,13 +4,13 @@ automake libtool pkg-config + # required for configure bison flex libcap-dev libdbi-dev libesmtp-dev -libevtlog-dev libgeoip-dev libglib2.0-dev libhiredis-dev @@ -28,11 +28,18 @@ python-dev uuid-dev xsltproc +libmaxminddb-dev +libmongoc-dev +libbson-dev +librabbitmq-dev + # required for make make + # required for make check criterion-dev libxml2-utils + python-pip # other tools gdb @@ -40,6 +47,7 @@ lsof strace vim + # debian packaging tools debhelper dh-autoreconf @@ -53,4 +61,4 @@ pylint gradle devscripts -libmaxminddb-dev +dh-exec diff -Nru syslog-ng-3.11.1/dbld/images/zesty/Dockerfile syslog-ng-3.13.2/dbld/images/zesty/Dockerfile --- syslog-ng-3.11.1/dbld/images/zesty/Dockerfile 2017-07-31 09:05:32.000000000 +0000 +++ syslog-ng-3.13.2/dbld/images/zesty/Dockerfile 2017-12-06 06:39:39.000000000 +0000 @@ -8,7 +8,7 @@ RUN echo 'deb http://download.opensuse.org/repositories/home:/laszlo_budai:/syslog-ng/xUbuntu_17.04 ./' | tee --append /etc/apt/sources.list.d/syslog-ng-obs.list ADD dev-dependencies.txt . -RUN apt-get update -qq && cat dev-dependencies.txt | grep -v "#" | xargs apt-get install -y +RUN apt-get update -qq && cat dev-dependencies.txt | grep -v "#" | xargs apt-get install -y --allow-unauthenticated # # if you want to add further packages, add them to addons.txt to make image diff -Nru syslog-ng-3.11.1/dbld/Makefile.am syslog-ng-3.13.2/dbld/Makefile.am --- syslog-ng-3.11.1/dbld/Makefile.am 1970-01-01 00:00:00.000000000 +0000 +++ syslog-ng-3.13.2/dbld/Makefile.am 2017-12-06 06:39:39.000000000 +0000 @@ -0,0 +1,9 @@ +EXTRA_DIST += \ + dbld/tarball \ + dbld/pkg-tarball \ + dbld/rpm \ + dbld/deb \ + dbld/generate-rpm-specfile \ + dbld/generate-debian-directory \ + dbld/shell \ + dbld/rules diff -Nru syslog-ng-3.11.1/dbld/pkg-tarball syslog-ng-3.13.2/dbld/pkg-tarball --- syslog-ng-3.11.1/dbld/pkg-tarball 1970-01-01 00:00:00.000000000 +0000 +++ syslog-ng-3.13.2/dbld/pkg-tarball 2017-12-06 06:39:39.000000000 +0000 @@ -0,0 +1,26 @@ +#!/bin/bash + +cd /source + +VERSION=`cat /source/VERSION` +MODE=$1 +SYSLOGNG_DIR=syslog-ng-${VERSION} +SYSLOGNG_TARBALL=${SYSLOGNG_DIR}.tar.gz + +if [ $MODE = "release" ]; then + if ! git diff-index --quiet HEAD; then + echo "Your source tree has changed, you can't generate a release tarball this way." + exit 1 + fi +fi + +cd /build +tar xfz $SYSLOGNG_TARBALL +cp $SYSLOGNG_TARBALL ${SYSLOGNG_TARBALL}.orig +cd $SYSLOGNG_DIR + +/source/dbld/generate-debian-directory $MODE +/source/dbld/generate-rpm-specfile $MODE + +cd .. +tar cfz $SYSLOGNG_TARBALL $SYSLOGNG_DIR diff -Nru syslog-ng-3.11.1/dbld/rpm syslog-ng-3.13.2/dbld/rpm --- syslog-ng-3.11.1/dbld/rpm 2017-07-31 09:05:32.000000000 +0000 +++ syslog-ng-3.13.2/dbld/rpm 2017-12-06 06:39:39.000000000 +0000 @@ -3,18 +3,16 @@ set -e cd /source -if [ ! -f syslog-ng.spec ]; then - echo "You don't seem to have an RPM specfile in the root of your source tree, this means one of the followings:" - echo " 1) you don't do this from a release tarball" - echo " 2) you haven't merged the 'release' branch" - echo " 3) you didn't create rpm packaging manually" - echo "" - echo "Please make sure you have obtained a source distribution with a spec file and rerun this command" - exit 1 -fi VERSION=`cat VERSION` +USER=`whoami` +RPMBUILD=/home/${USER}/rpmbuild +RPMBUILD_SOURCES=$RPMBUILD/SOURCES cd /build +mkdir -p $RPMBUILD_SOURCES +cp syslog-ng-${VERSION}.tar.gz $RPMBUILD_SOURCES + rpmbuild -ta syslog-ng-${VERSION}.tar.gz -mv ~/rpmbuild/RPMS/*/*.rpm /build +mv $RPMBUILD/RPMS/*/*.rpm /build +mv $RPMBUILD/SRPMS/*.rpm /build echo "Your rpms are in /build, also available on the host in \$(top_srcdir)/dbld/build" diff -Nru syslog-ng-3.11.1/dbld/rules syslog-ng-3.13.2/dbld/rules --- syslog-ng-3.11.1/dbld/rules 2017-07-31 09:05:32.000000000 +0000 +++ syslog-ng-3.13.2/dbld/rules 2017-12-06 06:39:39.000000000 +0000 @@ -2,6 +2,7 @@ DOCKER=docker DOCKER_RUN_ARGS=-e USER_NAME_ON_HOST=$(shell whoami) \ + --network=host \ -v $(ROOT_DIR):/source \ -v $(DBLD_DIR)/build:/build \ -v $(DBLD_DIR)/install:/install \ @@ -13,6 +14,7 @@ IMAGE_SHELL=balabit/syslog-ng-jessie VERSION=$(shell cat VERSION) TARBALL=$(BUILD_DIR)/syslog-ng-$(VERSION).tar.gz +MODE=snapshot help: @echo "This script allows you to build release/snapshot artifacts, such " @@ -42,11 +44,6 @@ release: release-deb release-rpm -deb-%: tarball - $(DOCKER) run $(DOCKER_RUN_ARGS) --rm -ti balabit/syslog-ng-$* /source/dbld/deb - -rpm-%: tarball - $(DOCKER) run $(DOCKER_RUN_ARGS) --rm -ti balabit/syslog-ng-$* /source/dbld/rpm tarball: setup if [ -f $(TARBALL) ]; then \ @@ -56,21 +53,19 @@ fi; \ [ "$${count}" -gt 0 ] && $(DOCKER) run $(DOCKER_RUN_ARGS) --rm -ti balabit/syslog-ng-zesty /source/dbld/tarball || true -release-tarball: clean - $(DBLD_DIR)/rules tarball - cp $(BUILD_DIR)/syslog-ng-$(VERSION).tar.gz $(RELEASE_DIR) +pkg-tarball: tarball + $(DOCKER) run $(DOCKER_RUN_ARGS) --rm -ti balabit/syslog-ng-zesty /source/dbld/pkg-tarball $(MODE) +deb-%: pkg-tarball + $(DOCKER) run $(DOCKER_RUN_ARGS) --rm -ti balabit/syslog-ng-$* /source/dbld/deb + +rpm-%: pkg-tarball + $(DOCKER) run $(DOCKER_RUN_ARGS) --rm -ti balabit/syslog-ng-$* /source/dbld/rpm -release-deb: release-tarball - $(DBLD_DIR)/rules deb +release: MODE=release +release: deb-zesty - # Debian sources and binaries - cp $(BUILD_DIR)/syslog-ng_*{dsc,orig.tar.gz,deb} $(RELEASE_DIR) -release-rpm: release-tarball - $(DBLD_DIR)/rules rpm - # RPM sources and binaries - cp $(BUILD_DIR)/syslog-ng*rpm $(RELEASE_DIR) clean: rm -rf $(BUILD_DIR)/* @@ -83,7 +78,7 @@ image-%: - cd $(DBLD_DIR)/images/$* && docker build -t balabit/syslog-ng-$* . + cd $(DBLD_DIR)/images/$* && docker build --network=host -t balabit/syslog-ng-$* . setup: mkdir -p dbld/build || true diff -Nru syslog-ng-3.11.1/dbld/tarball syslog-ng-3.13.2/dbld/tarball --- syslog-ng-3.11.1/dbld/tarball 2017-07-31 09:05:32.000000000 +0000 +++ syslog-ng-3.13.2/dbld/tarball 2017-12-06 06:39:39.000000000 +0000 @@ -7,7 +7,7 @@ ./autogen.sh cd /build -/source/configure +/source/configure --enable-manpages --with-docbook=/usr/share/xml/docbook/stylesheet/docbook-xsl/manpages/docbook.xsl make dist echo "Your tarball is in /build, also available on the host in \$(top_srcdir)/dbld/build" diff -Nru syslog-ng-3.11.1/debian/changelog syslog-ng-3.13.2/debian/changelog --- syslog-ng-3.11.1/debian/changelog 2017-11-08 18:37:49.000000000 +0000 +++ syslog-ng-3.13.2/debian/changelog 2018-02-11 16:06:23.000000000 +0000 @@ -1,9 +1,40 @@ -syslog-ng (3.11.1-2ubuntu1) bionic; urgency=medium +syslog-ng (3.13.2-3) unstable; urgency=medium - * Dont run jobserver mode yet, for now as its kind of unstable (Runs in a - pbuilder and clean chroot but hangs up on the ubuntu buildds). + * [afa41f8] Fixed pylint reported new issues. + The new version of pylint has an added + check which triggered by some of the + python code within the project. (Closes: #889303) - -- Bhavani Shankar Wed, 08 Nov 2017 19:41:14 +0530 + -- SZALAY Attila Sun, 11 Feb 2018 17:06:23 +0100 + +syslog-ng (3.13.2-2) unstable; urgency=medium + + * [776dd44] Removed two typo from the get_path_max code. + Thanks to Aaron M. Ucko for the investigation of this bug (Closes: #885248) + * [e4bb74a] Added the new packages to the test suit + * [f8de833] Added required dependency of modules extra + + -- SZALAY Attila Thu, 28 Dec 2017 19:15:55 +0100 + +syslog-ng (3.13.2-1) unstable; urgency=medium + + * [a088324] New upstream version 3.12.1 + * [029bb36] Removed unneeded dh-systemd (build) dependency + * [aadc721] Temporally add libsnappy-dev dependency until libmongoc-dev fix it + * [aa6e18e] Updated config version to 3.12 + * [eb5e839] Fixed filter expression of gbp import-orig + * [dea804c] New upstream version 3.13.2 + * [abeab4a] Adapt patches to the new version + * [8a82a05] Fixed new pylint issues + * [4355398] Changed package priority to optional + * [831da62] Enable fail-missing option of dh_missing + * [251a0bc] Added new plugins + * [cf80b16] Update the config version + * [cff2c3e] Added a (disabled) test to compile incubator + * [a8f4557] Remove obsoleted eventlog dependency (Closes: #881705) + * [5e715ce] Upgrade ABI version because of incompatible changes + + -- SZALAY Attila Wed, 20 Dec 2017 09:52:22 +0100 syslog-ng (3.11.1-2) unstable; urgency=medium diff -Nru syslog-ng-3.11.1/debian/control syslog-ng-3.13.2/debian/control --- syslog-ng-3.11.1/debian/control 2017-11-08 18:37:56.000000000 +0000 +++ syslog-ng-3.13.2/debian/control 2018-02-11 16:06:23.000000000 +0000 @@ -1,8 +1,7 @@ Source: syslog-ng Section: admin -Priority: extra -Maintainer: Ubuntu Developers -XSBC-Original-Maintainer: syslog-ng maintainers +Priority: optional +Maintainer: syslog-ng maintainers Uploaders: Laszlo Boszormenyi (GCS) , SZALAY Attila Build-Depends: debhelper (>= 10~), @@ -23,7 +22,6 @@ libwrap0-dev, libpcre3-dev, libcap-dev [linux-any], - dh-systemd (>= 1.3), libsystemd-dev (>= 209) [linux-any], libgeoip-dev, libhiredis-dev, @@ -32,7 +30,8 @@ python, python-dev, pep8, pylint, dh-python, dh-exec (>= 0.13~), python-nose, python-ply, - libxml2-utils, geoip-database + libxml2-utils, geoip-database, + libsnappy-dev Build-Conflicts: autoconf2.13 Standards-Version: 3.9.8 Homepage: http://www.syslog-ng.org/ @@ -557,3 +556,80 @@ . This parser module can parse SNMP trap messages and convert it to key-value pairs. + +Package: syslog-ng-mod-xml-parser +Architecture: any +Multi-Arch: foreign +Depends: ${shlibs:Depends}, ${misc:Depends} +Description: Enhanced system logging daemon (xml parser plugin) + syslog-ng is an enhanced log daemon, supporting a wide range of input + and output methods: syslog, unstructured text, message queues, + databases (SQL and NoSQL alike) and more. + . + Key features: + . + * receive and send RFC3164 and RFC5424 style syslog messages + * work with any kind of unstructured data + * receive and send JSON formatted messages + * classify and structure logs with builtin parsers (csv-parser(), + db-parser(), etc.) + * normalize, crunch and process logs as they flow through the system + * hand on messages for further processing using message queues (like + AMQP), files or databases (like PostgreSQL or MongoDB). + . + The xml parser can process input in xml format, and adds the parsed data + to the message object. + +Package: syslog-ng-mod-extra +Architecture: all +Multi-Arch: foreign +Depends: ${shlibs:Depends}, ${misc:Depends}, syslog-ng-mod-json (>= ${source:Version}), syslog-ng-mod-json (<< ${source:Version}.1~) +Description: Enhanced system logging daemon (extra plugins) + syslog-ng is an enhanced log daemon, supporting a wide range of input + and output methods: syslog, unstructured text, message queues, + databases (SQL and NoSQL alike) and more. + . + Key features: + . + * receive and send RFC3164 and RFC5424 style syslog messages + * work with any kind of unstructured data + * receive and send JSON formatted messages + * classify and structure logs with builtin parsers (csv-parser(), + db-parser(), etc.) + * normalize, crunch and process logs as they flow through the system + * hand on messages for further processing using message queues (like + AMQP), files or databases (like PostgreSQL or MongoDB). + . + This package collects all the small plugins, which does not worth to have + a whole package. This package contains: + . + * windows event log parser + * tag parser + * Graylog2 destination + * default Network source driver + * Load balancer destination + * osquery destination + * ewmm (Enterprise wide messaging model) destination and parser + +Package: syslog-ng-mod-tag-parser +Architecture: any +Multi-Arch: foreign +Depends: ${shlibs:Depends}, ${misc:Depends} +Description: Enhanced system logging daemon (tag parser plugin) + syslog-ng is an enhanced log daemon, supporting a wide range of input + and output methods: syslog, unstructured text, message queues, + databases (SQL and NoSQL alike) and more. + . + Key features: + . + * receive and send RFC3164 and RFC5424 style syslog messages + * work with any kind of unstructured data + * receive and send JSON formatted messages + * classify and structure logs with builtin parsers (csv-parser(), + db-parser(), etc.) + * normalize, crunch and process logs as they flow through the system + * hand on messages for further processing using message queues (like + AMQP), files or databases (like PostgreSQL or MongoDB). + . + The new tags-parser() takes a value encoded by $TAGS and parses it + back into actual tags on the message. diff -Nru syslog-ng-3.11.1/debian/gbp.conf syslog-ng-3.13.2/debian/gbp.conf --- syslog-ng-3.11.1/debian/gbp.conf 2017-09-01 20:46:28.000000000 +0000 +++ syslog-ng-3.13.2/debian/gbp.conf 2018-02-11 16:06:23.000000000 +0000 @@ -10,5 +10,4 @@ tarball-dir = ../ [import-orig] -filter = .git -filter = debian/* +filter = [".git", "debian/*"] diff -Nru syslog-ng-3.11.1/debian/not-installed syslog-ng-3.13.2/debian/not-installed --- syslog-ng-3.11.1/debian/not-installed 2017-09-01 20:46:28.000000000 +0000 +++ syslog-ng-3.13.2/debian/not-installed 2018-02-11 16:06:23.000000000 +0000 @@ -1,4 +1,6 @@ usr/share/syslog-ng/include/scl/pacct/plugin.conf usr/share/syslog-ng/include/scl/elasticsearch/plugin.conf usr/share/syslog-ng/include/scl/kafka/plugin.conf -usr/share/syslog-ng/include/scl/hdfs/plugin.conf \ No newline at end of file +usr/share/syslog-ng/include/scl/hdfs/plugin.conf +usr/lib/pkgconfig/syslog-ng-add-contextual-data.pc +lib/systemd/system/syslog-ng@.service diff -Nru syslog-ng-3.11.1/debian/patches/0001-Fixed-line-braking-issue.patch syslog-ng-3.13.2/debian/patches/0001-Fixed-line-braking-issue.patch --- syslog-ng-3.11.1/debian/patches/0001-Fixed-line-braking-issue.patch 2017-09-01 20:46:28.000000000 +0000 +++ syslog-ng-3.13.2/debian/patches/0001-Fixed-line-braking-issue.patch 2018-02-11 16:06:23.000000000 +0000 @@ -12,7 +12,7 @@ 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/doc/man/syslog-ng.8.xml b/doc/man/syslog-ng.8.xml -index c973ef8..ec32b35 100644 +index 35ad1d8..74b9b46 100644 --- a/doc/man/syslog-ng.8.xml +++ b/doc/man/syslog-ng.8.xml @@ -104,7 +104,7 @@ @@ -20,7 +20,7 @@ - A comma-separated list of the modules that are loaded automatically. Modules not loaded automatically can be loaded by including the @module <modulename> statement in the configuration file. The following modules are loaded by default: . Available only in and later. -+ A comma-separated list of the modules that are loaded automatically. Modules not loaded automatically can be loaded by including the @module <modulename> statement in the syslog-ng OSE configuration file. The following modules are loaded by default: affile, afprog, afsocket, afuser, basicfuncs, csvparser, dbparser, syslogformat, afsql. Available only in syslog-ng Open Source Edition 3.3 and later. ++ A comma-separated list of the modules that are loaded automatically. Modules not loaded automatically can be loaded by including the @module <modulename> statement in the syslog-ng OSE configuration file. The following modules are loaded by default: affile, afprog, afsocket, afuser, basicfuncs, csvparser, dbparser, syslogformat, afsql. Available only in syslog-ng Open Source Edition 3.3 and later. diff -Nru syslog-ng-3.11.1/debian/patches/0002-Adapt-test-case-to-the-new-afmongodb-version.patch syslog-ng-3.13.2/debian/patches/0002-Adapt-test-case-to-the-new-afmongodb-version.patch --- syslog-ng-3.11.1/debian/patches/0002-Adapt-test-case-to-the-new-afmongodb-version.patch 2017-09-01 20:46:28.000000000 +0000 +++ syslog-ng-3.13.2/debian/patches/0002-Adapt-test-case-to-the-new-afmongodb-version.patch 1970-01-01 00:00:00.000000000 +0000 @@ -1,33 +0,0 @@ -From: SZALAY Attila -Date: Mon, 28 Aug 2017 21:43:51 +0200 -Subject: Adapt test case to the new afmongodb version - ---- - modules/afmongodb/tests/test-mongodb-config.c | 7 ++----- - 1 file changed, 2 insertions(+), 5 deletions(-) - -diff --git a/modules/afmongodb/tests/test-mongodb-config.c b/modules/afmongodb/tests/test-mongodb-config.c -index 74663d0..6e9b379 100644 ---- a/modules/afmongodb/tests/test-mongodb-config.c -+++ b/modules/afmongodb/tests/test-mongodb-config.c -@@ -166,8 +166,8 @@ _test_uri_correct(void) - { - _expect_uri_in_log("default_uri", "127.0.0.1:27017/syslog" SAFEOPTS, "syslog", "messages"); - -- afmongodb_dd_set_uri(mongodb, "mongodb:///tmp/mongo.sock"); -- _expect_uri_in_log("socket", "/tmp/mongo.sock", "tmp/mongo.sock", "messages"); -+ afmongodb_dd_set_uri(mongodb, "mongodb://%2Ftmp%2Fmongo.sock/syslog"); -+ _expect_uri_in_log("socket", "%2Ftmp%2Fmongo.sock/syslog", "syslog", "messages"); - - afmongodb_dd_set_uri(mongodb, "mongodb://localhost:1234/syslog-ng"); - _expect_uri_in_log("uri", "localhost:1234/syslog-ng", "syslog-ng", "messages"); -@@ -216,9 +216,6 @@ _test_legacy_correct(void) - afmongodb_dd_set_port(mongodb, 1234); - _expect_uri_in_log("port", "127.0.0.1:1234/syslog" SAFEOPTS, "syslog", "messages"); - -- afmongodb_dd_set_path(mongodb, "/tmp/mongo.sock"); -- _expect_uri_in_log("path", "/tmp/mongo.sock" SAFEOPTS, "tmp/mongo.sock", "messages"); -- - afmongodb_dd_set_database(mongodb, "syslog-ng"); - _expect_uri_in_log("database", "127.0.0.1:27017/syslog-ng" SAFEOPTS, "syslog-ng", "messages"); - diff -Nru syslog-ng-3.11.1/debian/patches/0002-Fixed-new-pylint-issues.patch syslog-ng-3.13.2/debian/patches/0002-Fixed-new-pylint-issues.patch --- syslog-ng-3.11.1/debian/patches/0002-Fixed-new-pylint-issues.patch 1970-01-01 00:00:00.000000000 +0000 +++ syslog-ng-3.13.2/debian/patches/0002-Fixed-new-pylint-issues.patch 2018-02-11 16:06:23.000000000 +0000 @@ -0,0 +1,84 @@ +From: SZALAY Attila +Date: Tue, 19 Dec 2017 10:27:02 +0100 +Subject: Fixed new pylint issues + +--- + modules/python/pylib/pylintrc | 2 +- + modules/python/pylib/syslogng/debuggercli/completer.py | 2 +- + modules/python/pylib/syslogng/debuggercli/macrocompleter.py | 6 +++--- + .../pylib/syslogng/debuggercli/tests/test_commandlinelexer.py | 2 +- + .../python/pylib/syslogng/debuggercli/tests/test_templatelexer.py | 2 +- + 5 files changed, 7 insertions(+), 7 deletions(-) + +diff --git a/modules/python/pylib/pylintrc b/modules/python/pylib/pylintrc +index 92e4b72..c0bf699 100644 +--- a/modules/python/pylib/pylintrc ++++ b/modules/python/pylib/pylintrc +@@ -40,7 +40,7 @@ load-plugins= + # --disable=W" + #disable= + +-disable=C0111,W0613,R0903,I0011,W0142,E1101,R0921,R0922,R0801,C0330 ++disable=C0111,W0613,R0903,I0011,W0142,E1101,R0921,R0922,R0801,C0330,R1705,C0201,C1801 + + # C0111 missing-docstring Our priority is to make the code document + # itself. Docstring is required only when +diff --git a/modules/python/pylib/syslogng/debuggercli/completer.py b/modules/python/pylib/syslogng/debuggercli/completer.py +index 3d746bf..30f38a9 100644 +--- a/modules/python/pylib/syslogng/debuggercli/completer.py ++++ b/modules/python/pylib/syslogng/debuggercli/completer.py +@@ -28,6 +28,6 @@ class Completer(object): + __metaclass__ = ABCMeta + + @abstractmethod +- def complete(self, entire_text, word_to_be_completed): ++ def complete(self, entire_input, word_to_be_completed): + """Function to return the list of potential completion for a word""" + raise NotImplementedError +diff --git a/modules/python/pylib/syslogng/debuggercli/macrocompleter.py b/modules/python/pylib/syslogng/debuggercli/macrocompleter.py +index 01eba1c..b38c5a4 100644 +--- a/modules/python/pylib/syslogng/debuggercli/macrocompleter.py ++++ b/modules/python/pylib/syslogng/debuggercli/macrocompleter.py +@@ -37,13 +37,13 @@ class MacroCompleter(Completer): + self._macros = macros + self._completions = [] + +- def complete(self, entire_input, word): ++ def complete(self, entire_input, word_to_be_completed): + if not self._looks_like_a_macro_prefix(entire_input): + return [] +- self._collect_completions(word) ++ self._collect_completions(word_to_be_completed) + return sorted([completion + for completion in self._completions +- if len(word) == 0 or completion.startswith(word)]) ++ if len(word_to_be_completed) == 0 or completion.startswith(word_to_be_completed)]) + + def _looks_like_a_macro_prefix(self, entire_input): + if entire_input == '': +diff --git a/modules/python/pylib/syslogng/debuggercli/tests/test_commandlinelexer.py b/modules/python/pylib/syslogng/debuggercli/tests/test_commandlinelexer.py +index f73faf5..b64e7c5 100644 +--- a/modules/python/pylib/syslogng/debuggercli/tests/test_commandlinelexer.py ++++ b/modules/python/pylib/syslogng/debuggercli/tests/test_commandlinelexer.py +@@ -27,7 +27,7 @@ from .. import commandlinelexer + + class TestCommandLineLexer(TestLexer): + +- def _construct_lexer(self): ++ def _construct_lexer(self, *args, **kwargs): + return commandlinelexer.CommandLineLexer() + + def test_lexer_returns_none_for_empty_string(self): +diff --git a/modules/python/pylib/syslogng/debuggercli/tests/test_templatelexer.py b/modules/python/pylib/syslogng/debuggercli/tests/test_templatelexer.py +index 6601af1..a21ffe8 100644 +--- a/modules/python/pylib/syslogng/debuggercli/tests/test_templatelexer.py ++++ b/modules/python/pylib/syslogng/debuggercli/tests/test_templatelexer.py +@@ -27,7 +27,7 @@ from .test_lexer import TestLexer + + class TestTemplateLexer(TestLexer): + +- def _construct_lexer(self): ++ def _construct_lexer(self, *args, **kwargs): + return templatelexer.TemplateLexer() + + def test_template_literals_are_returned_as_literal_tokens(self): diff -Nru syslog-ng-3.11.1/debian/patches/0003-Remove-obsoleted-eventlog-dependency.patch syslog-ng-3.13.2/debian/patches/0003-Remove-obsoleted-eventlog-dependency.patch --- syslog-ng-3.11.1/debian/patches/0003-Remove-obsoleted-eventlog-dependency.patch 1970-01-01 00:00:00.000000000 +0000 +++ syslog-ng-3.13.2/debian/patches/0003-Remove-obsoleted-eventlog-dependency.patch 2018-02-11 16:06:23.000000000 +0000 @@ -0,0 +1,20 @@ +From: SZALAY Attila +Date: Wed, 20 Dec 2017 08:35:02 +0100 +Subject: Remove obsoleted eventlog dependency + +--- + syslog-ng.pc.in | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +diff --git a/syslog-ng.pc.in b/syslog-ng.pc.in +index 20fbdbc..c9bc892 100644 +--- a/syslog-ng.pc.in ++++ b/syslog-ng.pc.in +@@ -14,6 +14,6 @@ ivykis=@with_ivykis@ + Name: syslog-ng-dev + Description: Dev package for syslog-ng module + Version: @PACKAGE_VERSION@ +-Requires: glib-2.0 eventlog ++Requires: glib-2.0 + Libs: -L${libdir} @GLIB_LIBS@ -lsyslog-ng + Cflags: -I${includedir}/syslog-ng @INTERNAL_IVYKIS_CFLAGS@ diff -Nru syslog-ng-3.11.1/debian/patches/0004-Removed-two-typo-from-the-get_path_max-code.patch syslog-ng-3.13.2/debian/patches/0004-Removed-two-typo-from-the-get_path_max-code.patch --- syslog-ng-3.11.1/debian/patches/0004-Removed-two-typo-from-the-get_path_max-code.patch 1970-01-01 00:00:00.000000000 +0000 +++ syslog-ng-3.13.2/debian/patches/0004-Removed-two-typo-from-the-get_path_max-code.patch 2018-02-11 16:06:23.000000000 +0000 @@ -0,0 +1,64 @@ +From: SZALAY Attila +Date: Tue, 26 Dec 2017 13:22:13 +0100 +Subject: Removed two typo from the get_path_max code + +Closes: #885248 +Thanks: Aaron M. Ucko for the investigation of this bug +--- + modules/affile/directory-monitor.c | 40 +++++++++++++++++++------------------- + 1 file changed, 20 insertions(+), 20 deletions(-) + +diff --git a/modules/affile/directory-monitor.c b/modules/affile/directory-monitor.c +index 9af325a..b09b9ec 100644 +--- a/modules/affile/directory-monitor.c ++++ b/modules/affile/directory-monitor.c +@@ -62,29 +62,29 @@ get_path_max(void) + #ifdef PATH_MAX + path_max = PATH_MAX; + #else +- { +- /* This code based on example from the Advanced Programming in the UNIX environment +- * on how to determine the max path length +- */ +- static long posix_version = 0; +- static long xsi_version = 0; +- if (posix_version == 0) +- posix_version = sysconf(_SC_VERSION); ++ /* This code based on example from the Advanced Programming in the UNIX environment ++ * on how to determine the max path length ++ */ ++ static long posix_version = 0; ++ static long xsi_version = 0; ++ if (posix_version == 0) ++ posix_version = sysconf(_SC_VERSION); + +- if (xsi_version == 0) +- xsi_version = sysconf(_SC_XOPEN_VERSION); ++ if (xsi_version == 0) ++ xsi_version = sysconf(_SC_XOPEN_VERSION); + +- if ((path_max = pathconf("/", _PC_PATH_MAX)) < 0) +- path_max = PATH_MAX_GUESS; +- else +- path_max++; /* add one since it's relative to root */ ++ if ((path_max = pathconf("/", _PC_PATH_MAX)) < 0) ++ path_max = PATH_MAX_GUESS; ++ else ++ path_max++; /* add one since it's relative to root */ ++ ++ /* ++ * Before POSIX.1-2001, we aren't guaranteed that PATH_MAX includes ++ * the terminating null byte. Same goes for XPG3. ++ */ ++ if ((posix_version < 200112L) && (xsi_version < 4)) ++ path_max++; + +- /* +- * Before POSIX.1-2001, we aren't guaranteed that PATH_MAX includes +- * the terminating null byte. Same goes for XPG3. +- */ +- if ((posix_version < 200112L) && (xsi_version < 4)) +- pathmax++; + #endif + } + return path_max; diff -Nru syslog-ng-3.11.1/debian/patches/0005-Fixed-python-issue-R1710.patch syslog-ng-3.13.2/debian/patches/0005-Fixed-python-issue-R1710.patch --- syslog-ng-3.11.1/debian/patches/0005-Fixed-python-issue-R1710.patch 1970-01-01 00:00:00.000000000 +0000 +++ syslog-ng-3.13.2/debian/patches/0005-Fixed-python-issue-R1710.patch 2018-02-11 16:06:23.000000000 +0000 @@ -0,0 +1,87 @@ +From: SZALAY Attila +Date: Sun, 11 Feb 2018 15:16:18 +0100 +Subject: Fixed python issue R1710 + +This pylint issue alerts if the return statements +are inconsistent. It also alerts when some return +statement return with value, but at the function end +the return statement is missing. +--- + modules/python/pylib/syslogng/debuggercli/commandlinelexer.py | 8 ++++++++ + modules/python/pylib/syslogng/debuggercli/completerlang.py | 4 ++-- + modules/python/pylib/syslogng/debuggercli/templatelexer.py | 2 ++ + 3 files changed, 12 insertions(+), 2 deletions(-) + +diff --git a/modules/python/pylib/syslogng/debuggercli/commandlinelexer.py b/modules/python/pylib/syslogng/debuggercli/commandlinelexer.py +index 462f224..b976326 100644 +--- a/modules/python/pylib/syslogng/debuggercli/commandlinelexer.py ++++ b/modules/python/pylib/syslogng/debuggercli/commandlinelexer.py +@@ -82,6 +82,8 @@ class CommandLineLexer(Lexer): + partial = True + return LexerToken('ARG', value=self._current_token, partial=partial, lexpos=start_position) + ++ return None ++ + def _skip_whitespace(self): + while self._current_position < len(self._input) and self._input[self._current_position].isspace(): + self._current_position += 1 +@@ -98,6 +100,8 @@ class CommandLineLexer(Lexer): + else: + self._current_token += current_char + ++ return None ++ + def _open_paren(self, current_char): + self._paren_balance += 1 + self._current_token += current_char +@@ -109,11 +113,15 @@ class CommandLineLexer(Lexer): + return LexerToken('ARG', value=self._current_token) + self._current_token += current_char + ++ return None ++ + def _close_current_token(self, current_char): + if self._paren_balance == 0: + return LexerToken('ARG', value=self._current_token) + self._current_token += current_char + ++ return None ++ + def _process_string_character(self, current_char): + if current_char == '\\': + self._current_state = CLL_QUOTED_CHAR +diff --git a/modules/python/pylib/syslogng/debuggercli/completerlang.py b/modules/python/pylib/syslogng/debuggercli/completerlang.py +index f2bcaaf..9e36878 100644 +--- a/modules/python/pylib/syslogng/debuggercli/completerlang.py ++++ b/modules/python/pylib/syslogng/debuggercli/completerlang.py +@@ -57,7 +57,7 @@ class CompleterLang(object): + def p_error(self, p): + if p is None: + # EOF +- return None ++ return + elif p.type == 'TAB': + # We look up the current grammar state from the local variables of the caller, + # as it doesn't publish this information in self. +@@ -75,7 +75,7 @@ class CompleterLang(object): + elif 'state' in sys._getframe(2).f_locals: + parser_state = sys._getframe(2).f_locals['state'] + else: +- return None ++ return + + # now handle the error that the TAB token caused + self._token_position = p.lexpos +diff --git a/modules/python/pylib/syslogng/debuggercli/templatelexer.py b/modules/python/pylib/syslogng/debuggercli/templatelexer.py +index 0bce89b..9169bda 100644 +--- a/modules/python/pylib/syslogng/debuggercli/templatelexer.py ++++ b/modules/python/pylib/syslogng/debuggercli/templatelexer.py +@@ -136,6 +136,8 @@ class TemplateLexer(LexBasedLexer): + t.lexer.pop_state() + return t + ++ return None ++ + def t_dollarparen_QUOTE(self, t): + r'"' + t.lexer.current_token += t.value diff -Nru syslog-ng-3.11.1/debian/patches/debian-changes syslog-ng-3.13.2/debian/patches/debian-changes --- syslog-ng-3.11.1/debian/patches/debian-changes 2017-11-08 18:38:14.000000000 +0000 +++ syslog-ng-3.13.2/debian/patches/debian-changes 1970-01-01 00:00:00.000000000 +0000 @@ -1,17 +0,0 @@ -Description: Debian-specific changes mixed together. - This patch contains all the Debian-specific changes mixed together. To - review them separately, please inspect the Git history (see the - Vcs-Git field in debian/control); the patches against upstream are all - on the patched branch. - . - For more information, please see debian/README.source. -Origin: Debian - ---- syslog-ng-3.11.1.orig/modules/python/pylib/test_pylib.sh -+++ syslog-ng-3.11.1/modules/python/pylib/test_pylib.sh -@@ -21,4 +21,4 @@ - # - ############################################################################# - --${MAKE} MAKEFLAGS= python-checks -+#${MAKE} MAKEFLAGS= python-checks diff -Nru syslog-ng-3.11.1/debian/patches/series syslog-ng-3.13.2/debian/patches/series --- syslog-ng-3.11.1/debian/patches/series 2017-11-08 18:38:14.000000000 +0000 +++ syslog-ng-3.13.2/debian/patches/series 2018-02-11 16:06:23.000000000 +0000 @@ -1,3 +1,5 @@ 0001-Fixed-line-braking-issue.patch -0002-Adapt-test-case-to-the-new-afmongodb-version.patch -debian-changes +0002-Fixed-new-pylint-issues.patch +0003-Remove-obsoleted-eventlog-dependency.patch +0004-Removed-two-typo-from-the-get_path_max-code.patch +0005-Fixed-python-issue-R1710.patch diff -Nru syslog-ng-3.11.1/debian/rules syslog-ng-3.13.2/debian/rules --- syslog-ng-3.11.1/debian/rules 2017-09-01 20:46:28.000000000 +0000 +++ syslog-ng-3.13.2/debian/rules 2018-02-11 16:06:23.000000000 +0000 @@ -39,7 +39,7 @@ # To better support the Incubator, and have looser dependencies, we # track the ABI version here. Whenever the soname of libsyslog-ng # changes, up this one too! -ABI_VERSION = 3.10-0 +ABI_VERSION = 3.13-0 export DH_OPTIONS += -O-Bdebian/build-tree --dbg-package=syslog-ng-dbg @@ -192,6 +192,9 @@ #* Other, non-override targets ## +override_dh_missing: + dh_missing --fail-missing + # By default, the arch:all syslog-ng package does not need anything # built, so build-indep shall be empty. This avoids triggering another # build attempt, which would fail due to autoreconf being run @@ -201,4 +204,4 @@ # And for the rest, there is debhelper! %: - dh $@ --with autoreconf,systemd,python2 --parallel --list-missing + dh $@ --with autoreconf,systemd,python2 --parallel diff -Nru syslog-ng-3.11.1/debian/syslog-ng.conf syslog-ng-3.13.2/debian/syslog-ng.conf --- syslog-ng-3.11.1/debian/syslog-ng.conf 2017-09-01 20:46:28.000000000 +0000 +++ syslog-ng-3.13.2/debian/syslog-ng.conf 2018-02-11 16:06:23.000000000 +0000 @@ -1,4 +1,4 @@ -@version: 3.11 +@version: 3.13 @include "scl.conf" # Syslog-ng configuration file, compatible with default Debian syslogd diff -Nru syslog-ng-3.11.1/debian/syslog-ng-core.install syslog-ng-3.13.2/debian/syslog-ng-core.install --- syslog-ng-3.11.1/debian/syslog-ng-core.install 2017-09-01 20:46:28.000000000 +0000 +++ syslog-ng-3.13.2/debian/syslog-ng-core.install 2018-02-11 16:06:23.000000000 +0000 @@ -22,6 +22,7 @@ usr/lib/syslog-ng/*/libdate.so usr/lib/syslog-ng/*/libcef.so usr/lib/syslog-ng/*/libdisk-buffer.so +usr/lib/syslog-ng/*/libappmodel.so usr/share/syslog-ng/include/scl/system/* usr/share/syslog-ng/include/scl/syslogconf/* usr/share/syslog-ng/include/scl/rewrite/* @@ -31,6 +32,8 @@ usr/share/syslog-ng/include/scl/logmatic/* usr/share/syslog-ng/include/scl/solaris/* usr/share/syslog-ng/include/scl/cisco/* +usr/share/syslog-ng/include/scl/iptables/* +usr/share/syslog-ng/include/scl/sudo/* usr/share/syslog-ng/xsd/* #[!kfreebsd-any] lib/systemd/system/* [!kfreebsd-any] debian/syslog-ng.systemd => lib/systemd/system/syslog-ng.service diff -Nru syslog-ng-3.11.1/debian/syslog-ng-mod-extra.install syslog-ng-3.13.2/debian/syslog-ng-mod-extra.install --- syslog-ng-3.11.1/debian/syslog-ng-mod-extra.install 1970-01-01 00:00:00.000000000 +0000 +++ syslog-ng-3.13.2/debian/syslog-ng-mod-extra.install 2018-02-11 16:06:23.000000000 +0000 @@ -0,0 +1,8 @@ +usr/share/syslog-ng/include/scl/windowseventlog/plugin.conf +usr/share/syslog-ng/include/scl/windowseventlog/windowseventlog.xml +usr/share/syslog-ng/include/scl/loadbalancer/gen-loadbalancer.sh +usr/share/syslog-ng/include/scl/loadbalancer/plugin.conf +usr/share/syslog-ng/include/scl/default-network-drivers/plugin.conf +usr/share/syslog-ng/include/scl/osquery/plugin.conf +usr/share/syslog-ng/include/scl/ewmm/ewmm.conf +usr/share/syslog-ng/include/scl/graylog2/plugin.conf diff -Nru syslog-ng-3.11.1/debian/syslog-ng-mod-tag-parser.install syslog-ng-3.13.2/debian/syslog-ng-mod-tag-parser.install --- syslog-ng-3.11.1/debian/syslog-ng-mod-tag-parser.install 1970-01-01 00:00:00.000000000 +0000 +++ syslog-ng-3.13.2/debian/syslog-ng-mod-tag-parser.install 2018-02-11 16:06:23.000000000 +0000 @@ -0,0 +1 @@ +usr/lib/syslog-ng/*/libtags-parser.so diff -Nru syslog-ng-3.11.1/debian/syslog-ng-mod-xml-parser.install syslog-ng-3.13.2/debian/syslog-ng-mod-xml-parser.install --- syslog-ng-3.11.1/debian/syslog-ng-mod-xml-parser.install 1970-01-01 00:00:00.000000000 +0000 +++ syslog-ng-3.13.2/debian/syslog-ng-mod-xml-parser.install 2018-02-11 16:06:23.000000000 +0000 @@ -0,0 +1 @@ +usr/lib/syslog-ng/*/libxml.so diff -Nru syslog-ng-3.11.1/debian/tests/compile-incubator syslog-ng-3.13.2/debian/tests/compile-incubator --- syslog-ng-3.11.1/debian/tests/compile-incubator 1970-01-01 00:00:00.000000000 +0000 +++ syslog-ng-3.13.2/debian/tests/compile-incubator 2018-02-11 16:06:23.000000000 +0000 @@ -0,0 +1,2 @@ +#!/bin/sh +apt-get source --compile syslog-ng-incubator \ No newline at end of file diff -Nru syslog-ng-3.11.1/debian/tests/config.syslog syslog-ng-3.13.2/debian/tests/config.syslog --- syslog-ng-3.11.1/debian/tests/config.syslog 2017-09-01 20:46:28.000000000 +0000 +++ syslog-ng-3.13.2/debian/tests/config.syslog 2018-02-11 16:06:23.000000000 +0000 @@ -1,4 +1,4 @@ -@version: 3.11 +@version: 3.13 @include "scl.conf" source s_src { unix-dgram("/tmp/input"); }; diff -Nru syslog-ng-3.11.1/debian/tests/control syslog-ng-3.13.2/debian/tests/control --- syslog-ng-3.11.1/debian/tests/control 2017-09-01 20:46:28.000000000 +0000 +++ syslog-ng-3.13.2/debian/tests/control 2018-02-11 16:06:23.000000000 +0000 @@ -55,6 +55,15 @@ Tests: basic Depends: syslog-ng-core, syslog-ng-mod-snmptrapd-parser +Tests: basic +Depends: syslog-ng-core, syslog-ng-mod-xml-parser + +Tests: basic +Depends: syslog-ng-core, syslog-ng-mod-extra + +Tests: basic +Depends: syslog-ng-core, syslog-ng-mod-tag-parser + Tests: upgrade Restrictions: needs-root Depends: apt-utils @@ -65,3 +74,6 @@ Tests: testinitscript Depends: @, sysvinit-core Restrictions: needs-root + +#Tests: compile-incubator +#Depends: build-essential, syslog-ng-dev, fakeroot, debhelper, dh-autoreconf, automake, liblua5.2-dev, libperl-dev, python-dev, libgrok-dev, libtokyocabinet-dev, librdkafka-dev, libzmq3-dev, libmongo-client-dev diff -Nru syslog-ng-3.11.1/dev-utils/plugin_skeleton_creator/plugin_template_Makefile.am syslog-ng-3.13.2/dev-utils/plugin_skeleton_creator/plugin_template_Makefile.am --- syslog-ng-3.11.1/dev-utils/plugin_skeleton_creator/plugin_template_Makefile.am 2017-07-31 09:05:32.000000000 +0000 +++ syslog-ng-3.13.2/dev-utils/plugin_skeleton_creator/plugin_template_Makefile.am 2017-12-06 06:39:39.000000000 +0000 @@ -21,6 +21,6 @@ modules_@PLUGIN_NAME_US@_lib@PLUGIN_NAME_US@_la_LDFLAGS = $(MODULE_LDFLAGS) modules_@PLUGIN_NAME_US@_lib@PLUGIN_NAME_US@_la_DEPENDENCIES= $(MODULE_DEPS_LIBS) -modules/@PLUGIN_NAME@ modules/@PLUGIN_NAME@/ mod-@PLUGIN_NAME@ mod-file: modules/@PLUGIN_NAME@/lib@PLUGIN_NAME@.la -.PHONY: modules/@PLUGIN_NAME@/ mod-@PLUGIN_NAME@ mod-file +modules/@PLUGIN_NAME@ modules/@PLUGIN_NAME@/ mod-@PLUGIN_NAME@: modules/@PLUGIN_NAME@/lib@PLUGIN_NAME@.la +.PHONY: modules/@PLUGIN_NAME@/ mod-@PLUGIN_NAME@ diff -Nru syslog-ng-3.11.1/dev-utils/plugin_skeleton_creator/plugin_template_parser.h syslog-ng-3.13.2/dev-utils/plugin_skeleton_creator/plugin_template_parser.h --- syslog-ng-3.11.1/dev-utils/plugin_skeleton_creator/plugin_template_parser.h 2017-07-31 09:05:32.000000000 +0000 +++ syslog-ng-3.13.2/dev-utils/plugin_skeleton_creator/plugin_template_parser.h 2017-12-06 06:39:39.000000000 +0000 @@ -24,7 +24,6 @@ #define @PLUGIN_NAME_US@_PARSER_H_INCLUDED #include "cfg-parser.h" -#include "cfg-lexer.h" #include "driver.h" extern CfgParser @PLUGIN_NAME_US@_parser; diff -Nru syslog-ng-3.11.1/dev-utils/plugin_skeleton_creator/plugin_template_plugin.c syslog-ng-3.13.2/dev-utils/plugin_skeleton_creator/plugin_template_plugin.c --- syslog-ng-3.11.1/dev-utils/plugin_skeleton_creator/plugin_template_plugin.c 2017-07-31 09:05:32.000000000 +0000 +++ syslog-ng-3.13.2/dev-utils/plugin_skeleton_creator/plugin_template_plugin.c 2017-12-06 06:39:39.000000000 +0000 @@ -36,9 +36,9 @@ }; gboolean -@PLUGIN_NAME_US@_module_init(GlobalConfig *cfg, CfgArgs *args) +@PLUGIN_NAME_US@_module_init(PluginContext *context, CfgArgs *args) { - plugin_register(cfg, @PLUGIN_NAME_US@_plugins, G_N_ELEMENTS(@PLUGIN_NAME_US@_plugins)); + plugin_register(context, @PLUGIN_NAME_US@_plugins, G_N_ELEMENTS(@PLUGIN_NAME_US@_plugins)); return TRUE; } diff -Nru syslog-ng-3.11.1/doc/man/dqtool.1.xml syslog-ng-3.13.2/doc/man/dqtool.1.xml --- syslog-ng-3.11.1/doc/man/dqtool.1.xml 2017-07-31 09:05:32.000000000 +0000 +++ syslog-ng-3.13.2/doc/man/dqtool.1.xml 2017-12-06 06:39:39.000000000 +0000 @@ -8,7 +8,7 @@ dqtool 1 - 3.11 + 3.13 @@ -95,7 +95,7 @@ syslog-ng(8) - For the detailed documentation of see The 3.11 Administrator Guide + For the detailed documentation of see The 3.13 Administrator Guide If you experience any problems or need help with syslog-ng, visit the syslog-ng mailing list. For news and notifications about of syslog-ng, visit the syslog-ng blogs. diff -Nru syslog-ng-3.11.1/doc/man/loggen.1.xml syslog-ng-3.13.2/doc/man/loggen.1.xml --- syslog-ng-3.11.1/doc/man/loggen.1.xml 2017-07-31 09:05:32.000000000 +0000 +++ syslog-ng-3.13.2/doc/man/loggen.1.xml 2017-12-06 06:39:39.000000000 +0000 @@ -8,7 +8,7 @@ loggen 1 - 3.11 + 3.13 @@ -258,7 +258,7 @@ syslog-ng.conf(5) - For the detailed documentation of see The 3.11 Administrator Guide + For the detailed documentation of see The 3.13 Administrator Guide If you experience any problems or need help with syslog-ng, visit the syslog-ng mailing list. For news and notifications about of syslog-ng, visit the syslog-ng blogs. diff -Nru syslog-ng-3.11.1/doc/man/pdbtool.1.xml syslog-ng-3.13.2/doc/man/pdbtool.1.xml --- syslog-ng-3.11.1/doc/man/pdbtool.1.xml 2017-07-31 09:05:32.000000000 +0000 +++ syslog-ng-3.13.2/doc/man/pdbtool.1.xml 2017-12-06 06:39:39.000000000 +0000 @@ -8,7 +8,7 @@ pdbtool 1 - 3.11 + 3.13 @@ -445,7 +445,7 @@ syslog-ng(8) - For the detailed documentation of see The 3.11 Administrator Guide + For the detailed documentation of see The 3.13 Administrator Guide If you experience any problems or need help with syslog-ng, visit the syslog-ng mailing list. For news and notifications about of syslog-ng, visit the syslog-ng blogs. diff -Nru syslog-ng-3.11.1/doc/man/syslog-ng.8.xml syslog-ng-3.13.2/doc/man/syslog-ng.8.xml --- syslog-ng-3.11.1/doc/man/syslog-ng.8.xml 2017-07-31 09:05:32.000000000 +0000 +++ syslog-ng-3.13.2/doc/man/syslog-ng.8.xml 2017-12-06 06:39:39.000000000 +0000 @@ -8,7 +8,7 @@ syslog-ng 8 - 3.11 + 3.13 @@ -298,7 +298,7 @@ - Sets the number of worker threads can use, including the main thread. Note that certain operations in can use threads that are not limited by this option. This setting has effect only when is running in multithreaded mode. Available only in and later. See The 3.11 Administrator Guide for details. + Sets the number of worker threads can use, including the main thread. Note that certain operations in can use threads that are not limited by this option. This setting has effect only when is running in multithreaded mode. Available only in and later. See The 3.13 Administrator Guide for details. @@ -318,7 +318,7 @@ syslog-ng.conf(5) - For the detailed documentation of see The 3.11 Administrator Guide + For the detailed documentation of see The 3.13 Administrator Guide If you experience any problems or need help with syslog-ng, visit the syslog-ng mailing list. For news and notifications about of syslog-ng, visit the syslog-ng blogs. diff -Nru syslog-ng-3.11.1/doc/man/syslog-ng.conf.5.xml syslog-ng-3.13.2/doc/man/syslog-ng.conf.5.xml --- syslog-ng-3.11.1/doc/man/syslog-ng.conf.5.xml 2017-07-31 09:05:32.000000000 +0000 +++ syslog-ng-3.13.2/doc/man/syslog-ng.conf.5.xml 2017-12-06 06:39:39.000000000 +0000 @@ -8,7 +8,7 @@ syslog-ng.conf 5 - 3.11 + 3.13 @@ -439,7 +439,7 @@ syslog-ng(8) - For the detailed documentation of see The 3.11 Administrator Guide + For the detailed documentation of see The 3.13 Administrator Guide If you experience any problems or need help with syslog-ng, visit the syslog-ng mailing list. For news and notifications about of syslog-ng, visit the syslog-ng blogs. diff -Nru syslog-ng-3.11.1/doc/man/syslog-ng-ctl.1.xml syslog-ng-3.13.2/doc/man/syslog-ng-ctl.1.xml --- syslog-ng-3.11.1/doc/man/syslog-ng-ctl.1.xml 2017-07-31 09:05:32.000000000 +0000 +++ syslog-ng-3.13.2/doc/man/syslog-ng-ctl.1.xml 2017-12-06 06:39:39.000000000 +0000 @@ -8,7 +8,7 @@ syslog-ng-ctl 1 - 3.11 + 3.13 @@ -156,7 +156,7 @@ syslog-ng(8) - For the detailed documentation of see The 3.11 Administrator Guide + For the detailed documentation of see The 3.13 Administrator Guide If you experience any problems or need help with syslog-ng, visit the syslog-ng mailing list. For news and notifications about of syslog-ng, visit the syslog-ng blogs. diff -Nru syslog-ng-3.11.1/doc/man/syslog-ng-debun.1.xml syslog-ng-3.13.2/doc/man/syslog-ng-debun.1.xml --- syslog-ng-3.11.1/doc/man/syslog-ng-debun.1.xml 2017-07-31 09:05:32.000000000 +0000 +++ syslog-ng-3.13.2/doc/man/syslog-ng-debun.1.xml 2017-12-06 06:39:39.000000000 +0000 @@ -8,7 +8,7 @@ syslog-ng-debun 1 - 3.11 + 3.13 @@ -220,7 +220,7 @@ syslog-ng.conf(5) - For the detailed documentation of see The 3.11 Administrator Guide + For the detailed documentation of see The 3.13 Administrator Guide If you experience any problems or need help with syslog-ng, visit the syslog-ng mailing list. For news and notifications about of syslog-ng, visit the syslog-ng blogs. diff -Nru syslog-ng-3.11.1/lib/afinter.c syslog-ng-3.13.2/lib/afinter.c --- syslog-ng-3.11.1/lib/afinter.c 2017-07-31 09:05:32.000000000 +0000 +++ syslog-ng-3.13.2/lib/afinter.c 2017-12-06 06:39:39.000000000 +0000 @@ -96,7 +96,7 @@ struct iv_event schedule_wakeup; struct iv_timer mark_timer; struct iv_task restart_task; - gboolean watches_running:1; + gboolean watches_running:1, free_to_send:1; }; static void afinter_source_update_watches(AFInterSource *self); @@ -219,7 +219,7 @@ * current_internal_source to NULL. Messages get accumulated into * internal_msg_queue. */ g_static_mutex_lock(&internal_msg_lock); - current_internal_source = NULL; + self->free_to_send = FALSE; g_static_mutex_unlock(&internal_msg_lock); /* Possible race: @@ -263,7 +263,7 @@ g_static_mutex_lock(&internal_msg_lock); if (internal_msg_queue && g_queue_get_length(internal_msg_queue) > 0) iv_task_register(&self->restart_task); - current_internal_source = self; + self->free_to_send = TRUE; g_static_mutex_unlock(&internal_msg_lock); } } @@ -290,6 +290,7 @@ g_static_mutex_lock(&internal_msg_lock); current_internal_source = self; + self->free_to_send = TRUE; g_static_mutex_unlock(&internal_msg_lock); return TRUE; @@ -320,7 +321,7 @@ AFInterSource *self = g_new0(AFInterSource, 1); log_source_init_instance(&self->super, owner->super.super.super.cfg); - log_source_set_options(&self->super, options, 0, SCS_INTERNAL, owner->super.super.id, NULL, FALSE, FALSE, + log_source_set_options(&self->super, options, owner->super.super.id, NULL, FALSE, FALSE, owner->super.super.super.expr_node); afinter_source_init_watches(self); self->super.super.init = afinter_source_init; @@ -346,6 +347,8 @@ } log_source_options_init(&self->source_options, cfg, self->super.super.group); + self->source_options.stats_level = STATS_LEVEL0; + self->source_options.stats_source = SCS_INTERNAL; self->source = afinter_source_new(self, &self->source_options); log_pipe_append(&self->source->super, s); @@ -422,10 +425,33 @@ } } +static void +_release_internal_msg_queue(void) +{ + LogMessage *internal_message = g_queue_pop_head(internal_msg_queue); + while (internal_message) + { + log_msg_unref(internal_message); + internal_message = g_queue_pop_head(internal_msg_queue); + } + g_queue_free(internal_msg_queue); + internal_msg_queue = NULL; +} + void afinter_message_posted(LogMessage *msg) { g_static_mutex_lock(&internal_msg_lock); + if (!current_internal_source) + { + if (internal_msg_queue) + { + _release_internal_msg_queue(); + } + log_msg_unref(msg); + goto exit; + } + if (!internal_msg_queue) { internal_msg_queue = g_queue_new(); @@ -440,8 +466,9 @@ g_queue_push_tail(internal_msg_queue, msg); stats_counter_inc(internal_queue_length); - if (current_internal_source) + if (current_internal_source->free_to_send) iv_event_post(¤t_internal_source->post); +exit: g_static_mutex_unlock(&internal_msg_lock); } @@ -456,3 +483,19 @@ { register_application_hook(AH_POST_CONFIG_LOADED, afinter_register_posted_hook, NULL); } + +void +afinter_global_deinit(void) +{ + if (internal_msg_queue) + { + stats_lock(); + StatsClusterKey sc_key; + stats_cluster_logpipe_key_set(&sc_key, SCS_GLOBAL, "internal_queue_length", NULL ); + stats_unregister_counter(&sc_key, SC_TYPE_PROCESSED, &internal_queue_length); + stats_unlock(); + g_queue_free_full(internal_msg_queue, (GDestroyNotify)log_msg_unref); + internal_msg_queue = NULL; + } + current_internal_source = NULL; +} diff -Nru syslog-ng-3.11.1/lib/afinter.h syslog-ng-3.13.2/lib/afinter.h --- syslog-ng-3.11.1/lib/afinter.h 2017-07-31 09:05:32.000000000 +0000 +++ syslog-ng-3.13.2/lib/afinter.h 2017-12-06 06:39:39.000000000 +0000 @@ -41,5 +41,6 @@ void afinter_postpone_mark(gint mark_freq); LogDriver *afinter_sd_new(GlobalConfig *cfg); void afinter_global_init(void); +void afinter_global_deinit(void); #endif diff -Nru syslog-ng-3.11.1/lib/alarms.c syslog-ng-3.13.2/lib/alarms.c --- syslog-ng-3.11.1/lib/alarms.c 2017-07-31 09:05:32.000000000 +0000 +++ syslog-ng-3.13.2/lib/alarms.c 2017-12-06 06:39:39.000000000 +0000 @@ -51,7 +51,7 @@ } void -alarm_cancel() +alarm_cancel(void) { alarm(0); sig_alarm_received = FALSE; @@ -59,14 +59,14 @@ } gboolean -alarm_has_fired() +alarm_has_fired(void) { gboolean res = sig_alarm_received; return res; } void -alarm_init() +alarm_init(void) { struct sigaction sa; diff -Nru syslog-ng-3.11.1/lib/alarms.h syslog-ng-3.13.2/lib/alarms.h --- syslog-ng-3.11.1/lib/alarms.h 2017-07-31 09:05:32.000000000 +0000 +++ syslog-ng-3.13.2/lib/alarms.h 2017-12-06 06:39:39.000000000 +0000 @@ -28,10 +28,10 @@ #include "syslog-ng.h" void alarm_set(int timeout); -void alarm_cancel(); -gboolean alarm_has_fired(); +void alarm_cancel(void); +gboolean alarm_has_fired(void); -void alarm_init(); +void alarm_init(void); #endif diff -Nru syslog-ng-3.11.1/lib/apphook.c syslog-ng-3.13.2/lib/apphook.c --- syslog-ng-3.11.1/lib/apphook.c 2017-07-31 09:05:32.000000000 +0000 +++ syslog-ng-3.13.2/lib/apphook.c 2017-12-06 06:39:39.000000000 +0000 @@ -79,14 +79,17 @@ } static void -run_application_hook(gint type) +run_application_hook(gint type, gboolean remove_hook) { GList *l, *l_next; - g_assert(current_state <= type); + if (remove_hook) + { + g_assert(current_state <= type); + current_state = type; + } msg_debug("Running application hooks", evt_tag_int("hook", type)); - current_state = type; for (l = application_hooks; l; l = l_next) { ApplicationHookEntry *e = l->data; @@ -94,10 +97,13 @@ if (e->type == type) { l_next = l->next; - application_hooks = g_list_remove_link(application_hooks, l); e->func(type, e->user_data); - g_free(e); - g_list_free_1(l); + if (remove_hook) + { + application_hooks = g_list_remove_link(application_hooks, l); + g_free(e); + g_list_free_1(l); + } } else { @@ -149,7 +155,7 @@ void app_post_daemonized(void) { - run_application_hook(AH_POST_DAEMONIZED); + run_application_hook(AH_POST_DAEMONIZED, TRUE); } void @@ -161,14 +167,14 @@ void app_post_config_loaded(void) { - run_application_hook(AH_POST_CONFIG_LOADED); + run_application_hook(AH_POST_CONFIG_LOADED, TRUE); res_init(); } void app_shutdown(void) { - run_application_hook(AH_SHUTDOWN); + run_application_hook(AH_SHUTDOWN, TRUE); scratch_buffers_allocator_deinit(); scratch_buffers_global_deinit(); value_pairs_global_deinit(); @@ -176,6 +182,7 @@ log_tags_global_deinit(); log_msg_global_deinit(); + afinter_global_deinit(); stats_destroy(); child_manager_deinit(); g_list_foreach(application_hooks, (GFunc) g_free, NULL); @@ -201,6 +208,12 @@ } void +app_reopen(void) +{ + run_application_hook(AH_REOPEN, FALSE); +} + +void app_thread_start(void) { scratch_buffers_allocator_init(); diff -Nru syslog-ng-3.11.1/lib/apphook.h syslog-ng-3.13.2/lib/apphook.h --- syslog-ng-3.11.1/lib/apphook.h 2017-07-31 09:05:32.000000000 +0000 +++ syslog-ng-3.13.2/lib/apphook.h 2017-12-06 06:39:39.000000000 +0000 @@ -35,18 +35,20 @@ AH_PRE_CONFIG_LOADED, AH_POST_CONFIG_LOADED, AH_SHUTDOWN, + AH_REOPEN, }; typedef void (*ApplicationHookFunc)(gint type, gpointer user_data); void register_application_hook(gint type, ApplicationHookFunc func, gpointer user_data); -void app_startup(); -void app_finish_app_startup_after_cfg_init(); -void app_post_daemonized(); -void app_pre_config_loaded(); -void app_post_config_loaded(); +void app_startup(void); +void app_finish_app_startup_after_cfg_init(void); +void app_post_daemonized(void); +void app_pre_config_loaded(void); +void app_post_config_loaded(void); void app_thread_start(void); void app_thread_stop(void); -void app_shutdown(); +void app_shutdown(void); +void app_reopen(void); #endif diff -Nru syslog-ng-3.11.1/lib/block-ref-parser.h syslog-ng-3.13.2/lib/block-ref-parser.h --- syslog-ng-3.11.1/lib/block-ref-parser.h 2017-07-31 09:05:32.000000000 +0000 +++ syslog-ng-3.13.2/lib/block-ref-parser.h 2017-12-06 06:39:39.000000000 +0000 @@ -26,7 +26,6 @@ #define BLOCK_REF_PARSER_H_INCLUDED #include "cfg-parser.h" -#include "cfg-lexer.h" extern CfgParser block_ref_parser; extern CfgLexerKeyword *block_def_keywords; diff -Nru syslog-ng-3.11.1/lib/cfg-args.c syslog-ng-3.13.2/lib/cfg-args.c --- syslog-ng-3.11.1/lib/cfg-args.c 2017-07-31 09:05:32.000000000 +0000 +++ syslog-ng-3.13.2/lib/cfg-args.c 2017-12-06 06:39:39.000000000 +0000 @@ -24,6 +24,7 @@ #include "cfg-args.h" #include "messages.h" #include "str-utils.h" +#include "str-repr/encode.h" struct _CfgArgs { @@ -71,6 +72,31 @@ return TRUE; } +static void +_resolve_unknown_blockargs_as_varargs(gpointer key, gpointer value, gpointer user_data) +{ + CfgArgs *defaults = ((gpointer *) user_data)[0]; + GString *varargs = ((gpointer *) user_data)[1]; + + if (!defaults || cfg_args_get(defaults, key) == NULL) + { + g_string_append(varargs, key); + g_string_append_c(varargs, '('); + str_repr_encode_append(varargs, value, -1, NULL); + g_string_append(varargs, ") "); + } +} + +gchar * +cfg_args_format_varargs(CfgArgs *self, CfgArgs *defaults) +{ + GString *varargs = g_string_new(""); + gpointer user_data[] = { defaults, varargs }; + + cfg_args_foreach(self, _resolve_unknown_blockargs_as_varargs, user_data); + return g_string_free(varargs, FALSE); +} + void cfg_args_set(CfgArgs *self, const gchar *name, const gchar *value) { diff -Nru syslog-ng-3.11.1/lib/cfg-args.h syslog-ng-3.13.2/lib/cfg-args.h --- syslog-ng-3.11.1/lib/cfg-args.h 2017-07-31 09:05:32.000000000 +0000 +++ syslog-ng-3.13.2/lib/cfg-args.h 2017-12-06 06:39:39.000000000 +0000 @@ -31,6 +31,7 @@ /* argument list for a block generator */ gboolean cfg_args_validate(CfgArgs *self, CfgArgs *defs, const gchar *context); +gchar *cfg_args_format_varargs(CfgArgs *self, CfgArgs *defaults); void cfg_args_set(CfgArgs *self, const gchar *name, const gchar *value); const gchar *cfg_args_get(CfgArgs *self, const gchar *name); void cfg_args_foreach(CfgArgs *self, GHFunc func, gpointer user_data); diff -Nru syslog-ng-3.11.1/lib/cfg-block.c syslog-ng-3.13.2/lib/cfg-block.c --- syslog-ng-3.11.1/lib/cfg-block.c 1970-01-01 00:00:00.000000000 +0000 +++ syslog-ng-3.13.2/lib/cfg-block.c 2017-12-06 06:39:39.000000000 +0000 @@ -0,0 +1,112 @@ +/* + * Copyright (c) 2002-2017 Balabit + * Copyright (c) 1998-2017 Balázs Scheidler + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + * + * As an additional exemption you are allowed to compile & link against the + * OpenSSL libraries as published by the OpenSSL project. See the file + * COPYING for details. + * + */ +#include "cfg-block.h" +#include "cfg-lexer-subst.h" +#include "cfg.h" +#include "str-utils.h" + +/* + * This class encapsulates a configuration block that the user defined + * via the configuration file. It behaves like a macro, e.g. when + * referenced the content of the block is expanded. + * + * Each block is identified by its name and the context (source, + * destination, etc.) where it is meant to be used. + * + * A block has a set of name-value pairs to allow expansion to be + * parameterized. The set of allowed NV pairs is defined at block + * definition time + */ +typedef struct _CfgBlock CfgBlock; +struct _CfgBlock +{ + CfgBlockGenerator super; + gchar *content; + CfgArgs *arg_defs; +}; + +/* + * cfg_block_generate: + * + * This is a CfgBlockGeneratorFunc, which takes a CfgBlock defined by + * the user, substitutes backtick values and generates input tokens + * for the lexer. + */ +gboolean +cfg_block_generate(CfgBlockGenerator *s, GlobalConfig *cfg, CfgArgs *args, GString *result) +{ + CfgBlock *self = (CfgBlock *) s; + gchar *value; + gsize length; + GError *error = NULL; + + cfg_args_set(args, "__VARARGS__", cfg_args_format_varargs(args, self->arg_defs)); + + value = cfg_lexer_subst_args_in_input(cfg->globals, self->arg_defs, args, self->content, -1, &length, &error); + if (!value) + { + msg_warning("Syntax error while resolving backtick references in block", + evt_tag_str("context", cfg_lexer_lookup_context_name_by_type(self->super.context)), + evt_tag_str("block", self->super.name), + evt_tag_str("error", error->message), + NULL); + g_clear_error(&error); + return FALSE; + } + + g_string_assign_len(result, value, length); + g_free(value); + return TRUE; +} + +/* + * Free a user defined block. + */ +void +cfg_block_free_instance(CfgBlockGenerator *s) +{ + CfgBlock *self = (CfgBlock *) s; + + g_free(self->content); + cfg_args_unref(self->arg_defs); + cfg_block_generator_free_instance(s); +} + + +/* + * Construct a user defined block. + */ +CfgBlockGenerator * +cfg_block_new(gint context, const gchar *name, const gchar *content, CfgArgs *arg_defs) +{ + CfgBlock *self = g_new0(CfgBlock, 1); + + cfg_block_generator_init_instance(&self->super, context, name); + self->super.free_fn = cfg_block_free_instance; + self->super.generate = cfg_block_generate; + self->super.suppress_backticks = TRUE; + self->content = g_strdup(content); + self->arg_defs = arg_defs; + return &self->super; +} diff -Nru syslog-ng-3.11.1/lib/cfg-block-generator.c syslog-ng-3.13.2/lib/cfg-block-generator.c --- syslog-ng-3.11.1/lib/cfg-block-generator.c 1970-01-01 00:00:00.000000000 +0000 +++ syslog-ng-3.13.2/lib/cfg-block-generator.c 2017-12-06 06:39:39.000000000 +0000 @@ -0,0 +1,53 @@ +/* + * Copyright (c) 2002-2017 Balabit + * Copyright (c) 1998-2017 Balázs Scheidler + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + * + * As an additional exemption you are allowed to compile & link against the + * OpenSSL libraries as published by the OpenSSL project. See the file + * COPYING for details. + * + */ + +#include "cfg-block-generator.h" + +gboolean +cfg_block_generator_generate(CfgBlockGenerator *self, GlobalConfig *cfg, CfgArgs *args, GString *result) +{ + return self->generate(self, cfg, args, result); +} + +void +cfg_block_generator_init_instance(CfgBlockGenerator *self, gint context, const gchar *name) +{ + self->context = context; + self->name = g_strdup(name); + self->free_fn = cfg_block_generator_free_instance; +} + +void +cfg_block_generator_free_instance(CfgBlockGenerator *self) +{ + g_free(self->name); +} + +void +cfg_block_generator_free(CfgBlockGenerator *self) +{ + if (self->free_fn) + self->free_fn(self); + g_free(self); +} diff -Nru syslog-ng-3.11.1/lib/cfg-block-generator.h syslog-ng-3.13.2/lib/cfg-block-generator.h --- syslog-ng-3.11.1/lib/cfg-block-generator.h 1970-01-01 00:00:00.000000000 +0000 +++ syslog-ng-3.13.2/lib/cfg-block-generator.h 2017-12-06 06:39:39.000000000 +0000 @@ -0,0 +1,57 @@ +/* + * Copyright (c) 2002-2017 Balabit + * Copyright (c) 1998-2017 Balázs Scheidler + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + * + * As an additional exemption you are allowed to compile & link against the + * OpenSSL libraries as published by the OpenSSL project. See the file + * COPYING for details. + * + */ + +#ifndef CFG_BLOCK_GENERATOR_H_INCLUDED +#define CFG_BLOCK_GENERATOR_H_INCLUDED 1 + +#include "syslog-ng.h" +#include "cfg-args.h" + +/** + * CfgBlockGenerator: + * + * This class describes a block generator, e.g. a function callback + * that returns a configuration snippet in a given context. Each + * user-defined "block" results in a generator to be registered, but + * theoretically this mechanism can be used to write plugins that + * generate syslog-ng configuration on the fly, based on system + * settings for example. + **/ +typedef struct _CfgBlockGenerator CfgBlockGenerator; +struct _CfgBlockGenerator +{ + gint context; + gchar *name; + gboolean suppress_backticks; + gboolean (*generate)(CfgBlockGenerator *self, GlobalConfig *cfg, CfgArgs *args, GString *result); + void (*free_fn)(CfgBlockGenerator *self); +}; + +gboolean cfg_block_generator_generate(CfgBlockGenerator *self, GlobalConfig *cfg, CfgArgs *args, GString *result); +void cfg_block_generator_init_instance(CfgBlockGenerator *self, gint context, const gchar *name); +void cfg_block_generator_free_instance(CfgBlockGenerator *self); +void cfg_block_generator_free(CfgBlockGenerator *self); + + +#endif diff -Nru syslog-ng-3.11.1/lib/cfg-block.h syslog-ng-3.13.2/lib/cfg-block.h --- syslog-ng-3.11.1/lib/cfg-block.h 1970-01-01 00:00:00.000000000 +0000 +++ syslog-ng-3.13.2/lib/cfg-block.h 2017-12-06 06:39:39.000000000 +0000 @@ -0,0 +1,34 @@ +/* + * Copyright (c) 2002-2017 Balabit + * Copyright (c) 1998-2017 Balázs Scheidler + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + * + * As an additional exemption you are allowed to compile & link against the + * OpenSSL libraries as published by the OpenSSL project. See the file + * COPYING for details. + * + */ + +#ifndef CFG_BLOCK_H_INCLUDED +#define CFG_BLOCK_H_INCLUDED 1 + +#include "cfg-block-generator.h" + +/* user defined configuration block */ + +CfgBlockGenerator *cfg_block_new(gint context, const gchar *name, const gchar *content, CfgArgs *arg_defs); + +#endif diff -Nru syslog-ng-3.11.1/lib/cfg.c syslog-ng-3.13.2/lib/cfg.c --- syslog-ng-3.11.1/lib/cfg.c 2017-07-31 09:05:32.000000000 +0000 +++ syslog-ng-3.13.2/lib/cfg.c 2017-12-06 06:39:39.000000000 +0000 @@ -23,6 +23,7 @@ */ #include "cfg.h" +#include "cfg-grammar.h" #include "module-config.h" #include "cfg-tree.h" #include "messages.h" @@ -39,6 +40,7 @@ #include "hostname.h" #include "rcptid.h" #include "resolved-configurable-paths.h" +#include "mainloop.h" #include #include @@ -157,6 +159,88 @@ module_config_deinit(mc, cfg); } +static void +_sync_plugin_module_path_with_global_define(GlobalConfig *self) +{ + const gchar *module_path; + + /* Sync the @define module-path with the actual module search path as implemented by plugin. + * + * if @define module-path is not defined, we use whatever there's in + * PluginContext by default */ + if (self->lexer) + { + module_path = cfg_args_get(self->globals, "module-path"); + if (module_path) + { + plugin_context_set_module_path(&self->plugin_context, module_path); + } + } +} + +gboolean +cfg_load_module(GlobalConfig *cfg, const gchar *module_name) +{ + _sync_plugin_module_path_with_global_define(cfg); + return plugin_load_module(&cfg->plugin_context, module_name, NULL); +} + +void +cfg_load_candidate_modules(GlobalConfig *self) +{ + gboolean autoload_enabled = atoi(cfg_args_get(self->globals, "autoload-compiled-modules") ? : "1"); + + if (self->use_plugin_discovery && + autoload_enabled) + { + _sync_plugin_module_path_with_global_define(self); + plugin_load_candidate_modules(&self->plugin_context); + } +} + +Plugin * +cfg_find_plugin(GlobalConfig *cfg, gint plugin_type, const gchar *plugin_name) +{ + return plugin_find(&cfg->plugin_context, plugin_type, plugin_name); +} + +/* construct a plugin instance by parsing its relevant portion from the + * configuration file */ +gpointer +cfg_parse_plugin(GlobalConfig *cfg, Plugin *plugin, YYLTYPE *yylloc, gpointer arg) +{ + CfgTokenBlock *block; + YYSTYPE token; + + + /* we add two tokens to an inserted token-block: + * 1) the plugin type (in order to make it possible to support different + * plugins from the same grammar) + * + * 2) the keyword equivalent of the plugin name + */ + block = cfg_token_block_new(); + + /* add plugin->type as a token */ + memset(&token, 0, sizeof(token)); + token.type = LL_TOKEN; + token.token = plugin->type; + cfg_token_block_add_and_consume_token(block, &token); + + /* start a new lexer context, so plugin specific keywords are recognized, + * we only do this to lookup the parser name. */ + cfg_lexer_push_context(cfg->lexer, plugin->parser->context, plugin->parser->keywords, plugin->parser->name); + cfg_lexer_lookup_keyword(cfg->lexer, &token, yylloc, plugin->name); + cfg_lexer_pop_context(cfg->lexer); + + /* add plugin name token */ + cfg_token_block_add_and_consume_token(block, &token); + + cfg_lexer_inject_token_block(cfg->lexer, block); + + return plugin_construct_from_config(plugin, cfg->lexer, arg); +} + static gboolean cfg_init_modules(GlobalConfig *cfg) { @@ -173,6 +257,19 @@ g_hash_table_foreach(cfg->module_config, (GHFunc) _invoke_module_deinit, cfg); } +/* Request that this configuration shuts down and terminates. Right now, as + * there's only one configuration executed in a syslog-ng process, it will + * cause the mainloop to exit. Should there be multiple configs running in + * the same process at a future point, this would only terminate one and + * continue with the rest. + */ +void +cfg_shutdown(GlobalConfig *cfg) +{ + MainLoop *main_loop = main_loop_get_instance(); + main_loop_exit(main_loop); +} + gboolean cfg_init(GlobalConfig *cfg) { @@ -223,15 +320,21 @@ return cfg_tree_stop(&cfg->tree); } -void +gboolean cfg_set_version(GlobalConfig *self, gint version) { self->user_version = version; + if (cfg_is_config_version_older(self, 0x0300)) + { + msg_error("ERROR: compatibility with configurations below 3.0 was dropped in " VERSION_3_13 + ", please update your configuration accordingly"); + return FALSE; + } + if (cfg_is_config_version_older(self, VERSION_VALUE)) { - msg_warning("WARNING: Configuration file format is too old, syslog-ng is running in compatibility mode " - "Please update it to use the " VERSION_CURRENT " format at your time of convenience, " - "compatibility mode can operate less efficiently in some cases. " + msg_warning("WARNING: Configuration file format is too old, syslog-ng is running in compatibility mode. " + "Please update it to use the " VERSION_CURRENT " format at your time of convenience. " "To upgrade the configuration, please review the warnings about incompatible changes printed " "by syslog-ng, and once completed change the @version header at the top of the configuration " "file."); @@ -244,18 +347,12 @@ self->user_version = VERSION_VALUE; } - if (cfg_is_config_version_older(self, 0x0300)) - { - msg_warning("WARNING: global: the default value of chain_hostnames is changing to 'no' in " VERSION_3_0 - ", please update your configuration accordingly"); - self->chain_hostnames = TRUE; - } if (cfg_is_config_version_older(self, 0x0303)) { msg_warning("WARNING: global: the default value of log_fifo_size() has changed to 10000 in " VERSION_3_3 " to reflect log_iw_size() changes for tcp()/udp() window size changes"); } - + return TRUE; } gboolean @@ -266,7 +363,7 @@ if (cfg_is_config_version_older(self, 0x0303)) return TRUE; - s = cfg_args_get(self->lexer->globals, "allow-config-dups"); + s = cfg_args_get(self->globals, "allow-config-dups"); if (s && atoi(s)) { return TRUE; @@ -282,15 +379,16 @@ static void cfg_register_builtin_plugins(GlobalConfig *self) { - log_proto_register_builtin_plugins(self); + log_proto_register_builtin_plugins(&self->plugin_context); } GlobalConfig * -cfg_new_snippet(gint version) +cfg_new(gint version) { GlobalConfig *self = g_new0(GlobalConfig, 1); self->module_config = g_hash_table_new_full(g_str_hash, g_str_equal, g_free, (GDestroyNotify) module_config_free); + self->globals = cfg_args_new(); self->user_version = version; self->flush_lines = 100; @@ -321,19 +419,24 @@ self->keep_timestamp = TRUE; self->use_uniqid = FALSE; + self->jvm_options = NULL; stats_options_defaults(&self->stats_options); cfg_tree_init_instance(&self->tree, self); + plugin_context_init_instance(&self->plugin_context); + self->use_plugin_discovery = TRUE; + cfg_register_builtin_plugins(self); return self; } GlobalConfig * -cfg_new(gint version) +cfg_new_snippet(void) { - GlobalConfig *self = cfg_new_snippet(version); - cfg_load_candidate_modules(self); + GlobalConfig *self = cfg_new(VERSION_VALUE); + + self->use_plugin_discovery = FALSE; return self; } @@ -342,16 +445,17 @@ { gchar *include_path; - cfg_args_set(self->lexer->globals, "syslog-ng-root", get_installation_path_for(SYSLOG_NG_PATH_PREFIX)); - cfg_args_set(self->lexer->globals, "syslog-ng-data", get_installation_path_for(SYSLOG_NG_PATH_DATADIR)); - cfg_args_set(self->lexer->globals, "syslog-ng-include", get_installation_path_for(SYSLOG_NG_PATH_CONFIG_INCLUDEDIR)); - cfg_args_set(self->lexer->globals, "scl-root", get_installation_path_for(SYSLOG_NG_PATH_SCLDIR)); - cfg_args_set(self->lexer->globals, "module-path", resolvedConfigurablePaths.initial_module_path); + cfg_args_set(self->globals, "syslog-ng-root", get_installation_path_for(SYSLOG_NG_PATH_PREFIX)); + cfg_args_set(self->globals, "syslog-ng-data", get_installation_path_for(SYSLOG_NG_PATH_DATADIR)); + cfg_args_set(self->globals, "syslog-ng-include", get_installation_path_for(SYSLOG_NG_PATH_CONFIG_INCLUDEDIR)); + cfg_args_set(self->globals, "scl-root", get_installation_path_for(SYSLOG_NG_PATH_SCLDIR)); + cfg_args_set(self->globals, "module-path", resolvedConfigurablePaths.initial_module_path); + cfg_args_set(self->globals, "module-install-dir", resolvedConfigurablePaths.initial_module_path); include_path = g_strdup_printf("%s:%s", get_installation_path_for(SYSLOG_NG_PATH_SYSCONFDIR), get_installation_path_for(SYSLOG_NG_PATH_CONFIG_INCLUDEDIR)); - cfg_args_set(self->lexer->globals, "include-path", include_path); + cfg_args_set(self->globals, "include-path", include_path); g_free(include_path); } @@ -378,12 +482,6 @@ return res; } -void -cfg_load_candidate_modules(GlobalConfig *self) -{ - plugin_load_candidate_modules(self); -} - static void cfg_dump_processed_config(GString *preprocess_output, gchar *output_filename) { @@ -404,7 +502,7 @@ CfgLexer *lexer; GString *preprocess_output = g_string_sized_new(8192); - lexer = cfg_lexer_new_buffer(config_string, strlen(config_string)); + lexer = cfg_lexer_new_buffer(self, config_string, strlen(config_string)); lexer->preprocess_output = preprocess_output; res = cfg_run_parser(self, lexer, &main_parser, (gpointer *) &self, NULL); @@ -433,7 +531,7 @@ CfgLexer *lexer; GString *preprocess_output = g_string_sized_new(8192); - lexer = cfg_lexer_new(cfg_file, fname, preprocess_output); + lexer = cfg_lexer_new(self, cfg_file, fname, preprocess_output); res = cfg_run_parser(self, lexer, &main_parser, (gpointer *) &self, NULL); fclose(cfg_file); if (preprocess_into) @@ -478,10 +576,10 @@ g_free(self->bad_hostname_re); dns_cache_options_destroy(&self->dns_cache_options); g_free(self->custom_domain); - plugin_free_plugins(self); - plugin_free_candidate_modules(self); + plugin_context_deinit_instance(&self->plugin_context); cfg_tree_free_instance(&self->tree); g_hash_table_unref(self->module_config); + cfg_args_unref(self->globals); g_free(self); } diff -Nru syslog-ng-3.11.1/lib/cfg-grammar.y syslog-ng-3.13.2/lib/cfg-grammar.y --- syslog-ng-3.11.1/lib/cfg-grammar.y 2017-07-31 09:05:32.000000000 +0000 +++ syslog-ng-3.13.2/lib/cfg-grammar.y 2017-12-06 06:39:39.000000000 +0000 @@ -192,6 +192,7 @@ %token KW_MARK_MODE 10081 %token KW_ENCODING 10082 %token KW_TYPE 10083 +%token KW_STATS_MAX_DYNAMIC 10084 %token KW_CHAIN_HOSTNAMES 10090 %token KW_NORMALIZE_HOSTNAMES 10091 @@ -233,6 +234,9 @@ %token KW_PERSIST_NAME 10302 +%token KW_JVM_OPTIONS 10303 +%token KW_READ_OLD_RECORDS 10304 + /* log statement options */ %token KW_FLAGS 10190 @@ -337,6 +341,7 @@ #include "cfg-parser.h" #include "cfg.h" #include "cfg-tree.h" +#include "cfg-block.h" #include "template/templates.h" #include "template/user-function.h" #include "logreader.h" @@ -546,10 +551,10 @@ gint context = LL_CONTEXT_ROOT; gpointer result; - p = plugin_find(configuration, context, $1); + p = cfg_find_plugin(configuration, context, $1); CHECK_ERROR(p, @1, "%s plugin %s not found", cfg_lexer_lookup_context_name_by_type(context), $1); - result = plugin_parse_config(p, configuration, &@1, NULL); + result = cfg_parse_plugin(configuration, p, &@1, NULL); free($1); if (!result) YYERROR; @@ -585,10 +590,10 @@ Plugin *p; gint context = LL_CONTEXT_SOURCE; - p = plugin_find(configuration, context, $1); + p = cfg_find_plugin(configuration, context, $1); CHECK_ERROR(p, @1, "%s plugin %s not found", cfg_lexer_lookup_context_name_by_type(context), $1); - last_driver = (LogDriver *) plugin_parse_config(p, configuration, &@1, NULL); + last_driver = (LogDriver *) cfg_parse_plugin(configuration, p, &@1, NULL); free($1); if (!last_driver) { @@ -677,10 +682,10 @@ Plugin *p; gint context = LL_CONTEXT_DESTINATION; - p = plugin_find(configuration, context, $1); + p = cfg_find_plugin(configuration, context, $1); CHECK_ERROR(p, @1, "%s plugin %s not found", cfg_lexer_lookup_context_name_by_type(context), $1); - last_driver = (LogDriver *) plugin_parse_config(p, configuration, &@1, NULL); + last_driver = (LogDriver *) cfg_parse_plugin(configuration, p, &@1, NULL); free($1); if (!last_driver) { @@ -845,15 +850,15 @@ { cfg_lexer_push_context(lexer, LL_CONTEXT_BLOCK_CONTENT, NULL, "block content"); } LL_BLOCK { - CfgBlock *block; + CfgBlockGenerator *block; /* block content */ cfg_lexer_pop_context(lexer); /* block definition */ cfg_lexer_pop_context(lexer); - block = cfg_block_new($10, last_block_args); - CHECK_ERROR(cfg_lexer_register_block_generator(lexer, cfg_lexer_lookup_context_type_by_name($3), $4, cfg_block_generate, block, (GDestroyNotify) cfg_block_free) || cfg_allow_config_dups(configuration), @4, "duplicate block definition"); + block = cfg_block_new(cfg_lexer_lookup_context_type_by_name($3), $4, $10, last_block_args); + cfg_lexer_register_generator_plugin(&configuration->plugin_context, block); free($3); free($4); free($10); @@ -916,6 +921,7 @@ | KW_FILE_TEMPLATE '(' string ')' { configuration->file_template_name = g_strdup($3); free($3); } | KW_PROTO_TEMPLATE '(' string ')' { configuration->proto_template_name = g_strdup($3); free($3); } | KW_RECV_TIME_ZONE '(' string ')' { configuration->recv_time_zone = g_strdup($3); free($3); } + | KW_JVM_OPTIONS '(' string ')' {configuration->jvm_options = g_strdup($3); free($3);} | { last_template_options = &configuration->template_options; } template_option | { last_host_resolve_options = &configuration->host_resolve_options; } host_resolve_option | { last_stats_options = &configuration->stats_options; } stat_option @@ -927,6 +933,7 @@ : KW_STATS_FREQ '(' nonnegative_integer ')' { last_stats_options->log_freq = $3; } | KW_STATS_LEVEL '(' nonnegative_integer ')' { last_stats_options->level = $3; } | KW_STATS_LIFETIME '(' positive_integer ')' { last_stats_options->lifetime = $3; } + | KW_STATS_MAX_DYNAMIC '(' nonnegative_integer ')' { last_stats_options->max_dynamic = $3; } ; dns_cache_option @@ -978,11 +985,11 @@ ; string_list - : string_list_build { $$ = g_list_reverse($1); } + : string_list_build { $$ = $1; } ; string_list_build - : string string_list_build { $$ = g_list_append($2, g_strdup($1)); free($1); } + : string string_list_build { $$ = g_list_prepend($2, g_strdup($1)); free($1); } | { $$ = NULL; } ; @@ -1036,6 +1043,7 @@ | KW_HOST_OVERRIDE '(' string ')' { last_source_options->host_override = g_strdup($3); free($3); } | KW_LOG_PREFIX '(' string ')' { gchar *p = strrchr($3, ':'); if (p) *p = 0; last_source_options->program_override = g_strdup($3); free($3); } | KW_KEEP_TIMESTAMP '(' yesno ')' { last_source_options->keep_timestamp = $3; } + | KW_READ_OLD_RECORDS '(' yesno ')' { last_source_options->read_old_records = $3; } | KW_TAGS '(' string_list ')' { log_source_options_set_tags(last_source_options, $3); } | { last_host_resolve_options = &last_source_options->host_resolve_options; } host_resolve_option | driver_option @@ -1120,10 +1128,10 @@ gint context = LL_CONTEXT_INNER_DEST; gpointer value; - p = plugin_find(configuration, context, $1); + p = cfg_find_plugin(configuration, context, $1); CHECK_ERROR(p, @1, "%s plugin %s not found", cfg_lexer_lookup_context_name_by_type(context), $1); - value = plugin_parse_config(p, configuration, &@1, last_driver); + value = cfg_parse_plugin(configuration, p, &@1, last_driver); free($1); if (!value) diff -Nru syslog-ng-3.11.1/lib/cfg.h syslog-ng-3.13.2/lib/cfg.h --- syslog-ng-3.11.1/lib/cfg.h 2017-07-31 09:05:32.000000000 +0000 +++ syslog-ng-3.13.2/lib/cfg.h 2017-12-06 06:39:39.000000000 +0000 @@ -29,6 +29,7 @@ #include "cfg-tree.h" #include "cfg-lexer.h" #include "cfg-parser.h" +#include "plugin.h" #include "persist-state.h" #include "template/templates.h" #include "host-resolve.h" @@ -65,10 +66,10 @@ * multiple times if the user uses @version multiple times */ gint parsed_version; const gchar *filename; - GList *plugins; - GList *candidate_plugins; - gboolean autoload_compiled_modules; + PluginContext plugin_context; + gboolean use_plugin_discovery; CfgLexer *lexer; + CfgArgs *globals; StatsOptions stats_options; gint mark_freq; @@ -106,6 +107,8 @@ gchar *file_template_name; gchar *proto_template_name; + + gchar *jvm_options; LogTemplate *file_template; LogTemplate *proto_template; @@ -118,6 +121,11 @@ }; +gboolean cfg_load_module(GlobalConfig *cfg, const gchar *module_name); + +Plugin *cfg_find_plugin(GlobalConfig *cfg, gint plugin_type, const gchar *plugin_name); +gpointer cfg_parse_plugin(GlobalConfig *cfg, Plugin *plugin, YYLTYPE *yylloc, gpointer arg); + gboolean cfg_allow_config_dups(GlobalConfig *self); void cfg_bad_hostname_set(GlobalConfig *self, gchar *bad_hostname_re); @@ -127,16 +135,17 @@ gint cfg_tz_convert_value(gchar *convert); gint cfg_ts_format_value(gchar *format); -void cfg_set_version(GlobalConfig *self, gint version); +gboolean cfg_set_version(GlobalConfig *self, gint version); void cfg_load_candidate_modules(GlobalConfig *self); void cfg_set_global_paths(GlobalConfig *self); GlobalConfig *cfg_new(gint version); -GlobalConfig *cfg_new_snippet(gint version); +GlobalConfig *cfg_new_snippet(void); gboolean cfg_run_parser(GlobalConfig *self, CfgLexer *lexer, CfgParser *parser, gpointer *result, gpointer arg); gboolean cfg_read_config(GlobalConfig *cfg, const gchar *fname, gboolean syntax_only, gchar *preprocess_into); gboolean cfg_load_config(GlobalConfig *self, gchar *config_string, gboolean syntax_only, gchar *preprocess_into); +void cfg_shutdown(GlobalConfig *self); void cfg_free(GlobalConfig *self); gboolean cfg_init(GlobalConfig *cfg); gboolean cfg_deinit(GlobalConfig *cfg); diff -Nru syslog-ng-3.11.1/lib/cfg-lexer.c syslog-ng-3.13.2/lib/cfg-lexer.c --- syslog-ng-3.11.1/lib/cfg-lexer.c 2017-07-31 09:05:32.000000000 +0000 +++ syslog-ng-3.13.2/lib/cfg-lexer.c 2017-12-06 06:39:39.000000000 +0000 @@ -24,19 +24,21 @@ #include "cfg-lexer.h" #include "cfg-lexer-subst.h" +#include "cfg-block-generator.h" #include "cfg-lex.h" #include "cfg-grammar.h" #include "block-ref-parser.h" #include "pragma-parser.h" #include "messages.h" #include "pathutils.h" -#include "syslog-ng-config.h" #include "plugin.h" +#include "plugin-types.h" #include #include #include + /* * A token block is a series of tokens to be injected into the tokens * fetched by the lexer. It is assumed to be filled and then depleted, the @@ -49,25 +51,6 @@ }; /** - * CfgBlockGenerator: - * - * This class describes a block generator, e.g. a function callback - * that returns a configuration snippet in a given context. Each - * user-defined "block" results in a generator to be registered, but - * theoretically this mechanism can be used to write plugins that - * generate syslog-ng configuration on the fly, based on system - * settings for example. - **/ -struct _CfgBlockGenerator -{ - gint context; - gchar *name; - CfgBlockGeneratorFunc generator; - gpointer generator_data; - GDestroyNotify generator_data_free; -}; - -/** * CfgLexerContext: * * This object tells the lexer in which context it is operating right @@ -150,18 +133,6 @@ return "configuration"; } -gchar * -cfg_lexer_subst_args(CfgArgs *globals, CfgArgs *defs, CfgArgs *args, const gchar *input, gssize input_length, - gsize *output_length, GError **error) -{ - CfgLexerSubst *subst = cfg_lexer_subst_new(cfg_args_ref(globals), cfg_args_ref(defs), cfg_args_ref(args)); - gchar *result; - - result = cfg_lexer_subst_invoke(subst, input, input_length, output_length, error); - cfg_lexer_subst_free(subst); - return result; -} - /* this can only be called from the grammar */ static CfgIncludeLevel * _find_closest_file_inclusion(CfgLexer *self, YYLTYPE *yylloc) @@ -277,13 +248,17 @@ /* reset the include state, should also handle initial invocations, in which case everything is NULL */ if (level->yybuf) - _cfg_lexer__delete_buffer(level->yybuf, self->state); + { + _cfg_lexer__delete_buffer(level->yybuf, self->state); + level->yybuf = NULL; + } if (level->include_type == CFGI_FILE) { if (level->file.include_file) { fclose(level->file.include_file); + level->file.include_file = NULL; } } @@ -542,10 +517,16 @@ return TRUE; } +static const gchar * +_get_include_path(CfgLexer *self) +{ + return self->cfg ? cfg_args_get(self->cfg->globals, "include-path") : NULL; +} + static gboolean cfg_lexer_include_file_glob(CfgLexer *self, const gchar *filename_) { - const gchar *path = cfg_args_get(self->globals, "include-path"); + const gchar *path = _get_include_path(self); gboolean process = FALSE; self->include_depth++; @@ -593,7 +574,7 @@ return FALSE; } - filename = find_file_in_path(cfg_args_get(self->globals, "include-path"), filename_, G_FILE_TEST_EXISTS); + filename = find_file_in_path(_get_include_path(self), filename_, G_FILE_TEST_EXISTS); if (!filename || stat(filename, &st) < 0) { if (cfg_lexer_include_file_glob(self, filename_)) @@ -601,7 +582,7 @@ msg_error("Include file/directory not found", evt_tag_str("filename", filename_), - evt_tag_str("include-path", cfg_args_get(self->globals, "include-path")), + evt_tag_str("include-path", _get_include_path(self)), evt_tag_errno("error", errno)); return FALSE; } @@ -661,7 +642,8 @@ GError *error = NULL; gboolean result = FALSE; - substituted_buffer = cfg_lexer_subst_args(self->globals, NULL, NULL, buffer, length, &substituted_length, &error); + substituted_buffer = cfg_lexer_subst_args_in_input(self->cfg ? self->cfg->globals : NULL, NULL, NULL, buffer, length, + &substituted_length, &error); if (!substituted_buffer) { msg_error("Error resolving backtick references in block or buffer", @@ -682,55 +664,63 @@ self->token_blocks = g_list_append(self->token_blocks, block); } -static CfgBlockGenerator * -cfg_lexer_find_generator(CfgLexer *self, gint context, const gchar *name) + +typedef struct _GeneratorPlugin { - GList *l; + Plugin super; + CfgBlockGenerator *gen; +} GeneratorPlugin; - for (l = self->generators; l; l = l->next) - { - CfgBlockGenerator *gen = (CfgBlockGenerator *) l->data; +static gpointer +_generator_plugin_construct(Plugin *s) +{ + GeneratorPlugin *self = (GeneratorPlugin *) s; - if ((gen->context == 0 || gen->context == context) && strcmp(gen->name, name) == 0) - { - return gen; - } - } - return NULL; + return self->gen; } -gboolean -cfg_lexer_register_block_generator(CfgLexer *self, gint context, const gchar *name, CfgBlockGeneratorFunc generator, - gpointer generator_data, GDestroyNotify generator_data_free) +static void +_generator_plugin_free(Plugin *s) { - CfgBlockGenerator *gen; - gboolean res = FALSE; + GeneratorPlugin *self = (GeneratorPlugin *) s; - gen = cfg_lexer_find_generator(self, context, name); - if (gen) - { - gen->generator_data_free(gen->generator_data); - g_free(gen->name); - } - else - { - gen = g_new0(CfgBlockGenerator, 1); - self->generators = g_list_append(self->generators, gen); - res = TRUE; - } + cfg_block_generator_free(self->gen); + g_free((gchar *) self->super.name); + g_free(s); +} + +void +cfg_lexer_register_generator_plugin(PluginContext *context, CfgBlockGenerator *gen) +{ + GeneratorPlugin *plugin = g_new0(GeneratorPlugin, 1); - gen->context = context; - gen->name = g_strdup(name); - gen->generator = generator; - gen->generator_data = generator_data; - gen->generator_data_free = generator_data_free; - return res; + plugin->super.type = gen->context | LL_CONTEXT_FLAG_GENERATOR; + plugin->super.name = g_strdup(gen->name); + plugin->super.free_fn = _generator_plugin_free; + plugin->super.construct = _generator_plugin_construct; + plugin->gen = gen; + + plugin_register(context, &plugin->super, 1); } static gboolean -cfg_lexer_generate_block(CfgLexer *self, gint context, const gchar *name, CfgBlockGenerator *gen, CfgArgs *args) +_is_generator_plugin(Plugin *p) +{ + return p->type & LL_CONTEXT_FLAG_GENERATOR; +} + +static CfgBlockGenerator * +cfg_lexer_find_generator(CfgLexer *self, GlobalConfig *cfg, gint context, const gchar *name) { - return gen->generator(self, context, name, args, gen->generator_data); + Plugin *p; + CfgBlockGenerator *gen; + + p = plugin_find(&cfg->plugin_context, context | LL_CONTEXT_FLAG_GENERATOR, name); + if (!p || !_is_generator_plugin(p)) + return NULL; + + gen = plugin_construct(p); + return gen; } static YYSTYPE @@ -861,9 +851,77 @@ g_string_append_printf(self->preprocess_output, "%s", self->token_pretext->str); } - if (self->ignore_pragma) + /* NOTE: most of the code below is a monster, which should be factored out + * to tiny little functions. This is not very simple and I am in the + * middle of something that I would rather close than doing the + * refactoring desperately needed here. I am silencing my conscience with + * this note and also take the time to document some of the quirks below. + * + * 1) This code is deeply coupled with GlobalConfig and most of it does + * not make sense to execute if self->cfg is NULL. Thus, some of the + * conditionals contain an explicit self->cfg check, in other cases it is + * implicitly checked by the first conditional of a series of if-then-else + * statements. + * + * 2) the role of the relex label is to restart the lexing process once + * new tokens were injected into the input stream. (e.g. after a + * generator was called). This should really be a loop, and quite + * possible any refactors should start here by eliminating that + * loop-using-goto + * + * 3) make note that string tokens are allocated by malloc/free and not + * g_malloc/g_free, this is significant. The grammar contains the free() + * call, so getting rid of that would require a lot of changes to the + * grammar. (on Windows glib, malloc/g_malloc are NOT equivalent) + * + */ + + + if (tok == LL_IDENTIFIER && + self->cfg && + (gen = cfg_lexer_find_generator(self, self->cfg, cfg_lexer_get_context_type(self), yylval->cptr))) { - /* only process @pragma/@include tokens in case pragma allowed is set */ + CfgArgs *args; + + self->preprocess_suppress_tokens++; + if (cfg_parser_parse(&block_ref_parser, self, (gpointer *) &args, NULL)) + { + gboolean success; + gchar buf[256]; + GString *result = g_string_sized_new(256); + + self->preprocess_suppress_tokens--; + success = cfg_block_generator_generate(gen, self->cfg, args, result); + + free(yylval->cptr); + cfg_args_unref(args); + g_snprintf(buf, sizeof(buf), "%s generator %s", + cfg_lexer_lookup_context_name_by_type(gen->context), + gen->name); + + if (gen->suppress_backticks) + success = cfg_lexer_include_buffer_without_backtick_substitution(self, buf, result->str, result->len); + else + success = cfg_lexer_include_buffer(self, buf, result->str, result->len); + g_string_free(result, TRUE); + + if (success) + { + goto relex; + } + } + else + { + free(yylval->cptr); + self->preprocess_suppress_tokens--; + } + return LL_ERROR; + } + + if (self->ignore_pragma || self->cfg == NULL) + { + /* only process @pragma/@include tokens in case pragma allowed is set + * and the associated configuration is not NULL */ ; } else if (tok == LL_PRAGMA) @@ -897,60 +955,40 @@ if (tok != ';') { self->preprocess_suppress_tokens--; + g_free(include_file); return LL_ERROR; } if (!cfg_lexer_include_file(self, include_file)) { + g_free(include_file); self->preprocess_suppress_tokens--; return LL_ERROR; } self->preprocess_suppress_tokens--; + g_free(include_file); goto relex; } - else if (tok == LL_IDENTIFIER && (gen = cfg_lexer_find_generator(self, cfg_lexer_get_context_type(self), yylval->cptr))) + else if (self->cfg->user_version == 0 && self->cfg->parsed_version != 0) { - CfgArgs *args; - - self->preprocess_suppress_tokens++; - if (cfg_parser_parse(&block_ref_parser, self, (gpointer *) &args, NULL)) - { - gboolean success; - - self->preprocess_suppress_tokens--; - success = cfg_lexer_generate_block(self, cfg_lexer_get_context_type(self), yylval->cptr, gen, args); - free(yylval->cptr); - cfg_args_unref(args); - if (success) - { - goto relex; - } - } - else - { - free(yylval->cptr); - self->preprocess_suppress_tokens--; - } - return LL_ERROR; - } - else if (configuration->user_version == 0 && configuration->parsed_version != 0) - { - cfg_set_version(configuration, configuration->parsed_version); + if (!cfg_set_version(self->cfg, configuration->parsed_version)) + return LL_ERROR; } else if (cfg_lexer_get_context_type(self) != LL_CONTEXT_PRAGMA && !self->non_pragma_seen) { /* first non-pragma token */ - if (configuration->user_version == 0 && configuration->parsed_version == 0) + if (self->cfg->user_version == 0 && self->cfg->parsed_version == 0) { - /* no version selected yet, and we have a non-pragma token, this - * means that the configuration is meant for syslog-ng 2.1 */ - msg_warning("WARNING: Configuration file has no version number, assuming syslog-ng 2.1 format. Please add @version: maj.min to the beginning of the file to indicate this explicitly"); - cfg_set_version(configuration, 0x0201); + msg_error("ERROR: configuration files without a version number has become unsupported in " VERSION_3_13 + ", please specify a version number using @version and update your configuration accordingly"); + return LL_ERROR; } + cfg_load_candidate_modules(self->cfg); + #if (!SYSLOG_NG_ENABLE_FORCED_SERVER_MODE) - if (!plugin_load_module("license", configuration, NULL)) + if (!cfg_load_module(self->cfg, "license")) { msg_error("Error loading the license module, forcing exit"); exit(1); @@ -971,15 +1009,15 @@ } static void -cfg_lexer_init(CfgLexer *self) +cfg_lexer_init(CfgLexer *self, GlobalConfig *cfg) { - self->globals = cfg_args_new(); CfgIncludeLevel *level; _cfg_lexer_lex_init_extra(self, &self->state); self->string_buffer = g_string_sized_new(32); self->token_text = g_string_sized_new(32); self->token_pretext = g_string_sized_new(32); + self->cfg = cfg; level = &self->include_stack[0]; level->lloc.first_line = level->lloc.last_line = 1; @@ -987,14 +1025,19 @@ level->lloc.level = level; } + +/* NOTE: cfg might be NULL in some call sites, but in those cases the lexer + * should remain operational, obviously skipping cases where it would be + * using the configuration instance. The lexer and the configuration stuff + * should be one-way dependent, right now it is a circular dependency. */ CfgLexer * -cfg_lexer_new(FILE *file, const gchar *filename, GString *preprocess_output) +cfg_lexer_new(GlobalConfig *cfg, FILE *file, const gchar *filename, GString *preprocess_output) { CfgLexer *self; CfgIncludeLevel *level; self = g_new0(CfgLexer, 1); - cfg_lexer_init(self); + cfg_lexer_init(self, cfg); self->preprocess_output = preprocess_output; level = &self->include_stack[0]; @@ -1007,13 +1050,13 @@ } CfgLexer * -cfg_lexer_new_buffer(const gchar *buffer, gsize length) +cfg_lexer_new_buffer(GlobalConfig *cfg, const gchar *buffer, gsize length) { CfgLexer *self; CfgIncludeLevel *level; self = g_new0(CfgLexer, 1); - cfg_lexer_init(self); + cfg_lexer_init(self, cfg); self->ignore_pragma = TRUE; level = &self->include_stack[0]; @@ -1065,17 +1108,6 @@ while (self->context_stack) cfg_lexer_pop_context(self); - while (self->generators) - { - CfgBlockGenerator *gen = self->generators->data; - - if (gen->generator_data && gen->generator_data_free) - gen->generator_data_free(gen->generator_data); - g_free(gen->name); - g_free(gen); - self->generators = g_list_delete_link(self->generators, self->generators); - } - cfg_args_unref(self->globals); g_list_foreach(self->token_blocks, (GFunc) cfg_token_block_free, NULL); g_list_free(self->token_blocks); g_free(self); @@ -1119,6 +1151,7 @@ const gchar * cfg_lexer_lookup_context_name_by_type(gint type) { + type &= ~LL_CONTEXT_FLAGS; g_assert(type < G_N_ELEMENTS(lexer_contexts)); return lexer_contexts[type]; } @@ -1154,7 +1187,7 @@ } CfgTokenBlock * -cfg_token_block_new() +cfg_token_block_new(void) { CfgTokenBlock *self = g_new0(CfgTokenBlock, 1); @@ -1179,109 +1212,6 @@ g_free(self); } -/* user defined blocks */ - -/* - * This class encapsulates a configuration block that the user defined - * via the configuration file. It behaves like a macro, e.g. when - * referenced the content of the block is expanded. - * - * Each block is identified by its name and the context (source, - * destination, etc.) where it is meant to be used. - * - * A block has a set of name-value pairs to allow expansion to be - * parameterized. The set of allowed NV pairs is defined at block - * definition time - */ -struct _CfgBlock -{ - gchar *content; - CfgArgs *arg_defs; -}; - -static void -_resolve_unknown_blockargs_as_varargs(gpointer key, gpointer value, gpointer user_data) -{ - CfgArgs *defs = ((gpointer *) user_data)[0]; - GString *varargs = ((gpointer *) user_data)[1]; - - if (cfg_args_get(defs, key) == NULL) - { - g_string_append_printf(varargs, "%s(%s) ", (gchar *)key, (gchar *)value); - } -} - -static void -_fill_varargs(CfgBlock *block, CfgArgs *args) -{ - GString *varargs = g_string_new(""); - gpointer user_data[] = { block->arg_defs, varargs }; - - cfg_args_foreach(args, _resolve_unknown_blockargs_as_varargs, user_data); - cfg_args_set(args, "__VARARGS__", varargs->str); - g_string_free(varargs, TRUE); -} - -/* - * cfg_block_generate: - * - * This is a CfgBlockGeneratorFunc, which takes a CfgBlock defined by - * the user, substitutes backtick values and generates input tokens - * for the lexer. - */ -gboolean -cfg_block_generate(CfgLexer *lexer, gint context, const gchar *name, CfgArgs *args, gpointer user_data) -{ - CfgBlock *block = (CfgBlock *) user_data; - gchar *value; - gchar buf[256]; - gsize length; - GError *error = NULL; - gboolean result; - - g_snprintf(buf, sizeof(buf), "%s block %s", cfg_lexer_lookup_context_name_by_type(context), name); - _fill_varargs(block, args); - - value = cfg_lexer_subst_args(lexer->globals, block->arg_defs, args, block->content, -1, &length, &error); - - if (!value) - { - msg_warning("Syntax error while resolving backtick references in block", - evt_tag_str("context", cfg_lexer_lookup_context_name_by_type(context)), - evt_tag_str("block", name), - evt_tag_str("error", error->message)); - g_clear_error(&error); - return FALSE; - } - - result = cfg_lexer_include_buffer_without_backtick_substitution(lexer, buf, value, length); - g_free(value); - return result; -} - -/* - * Construct a user defined block. - */ -CfgBlock * -cfg_block_new(const gchar *content, CfgArgs *arg_defs) -{ - CfgBlock *self = g_new0(CfgBlock, 1); - - self->content = g_strdup(content); - self->arg_defs = arg_defs; - return self; -} - -/* - * Free a user defined block. - */ -void -cfg_block_free(CfgBlock *self) -{ - g_free(self->content); - cfg_args_unref(self->arg_defs); - g_free(self); -} GQuark cfg_lexer_error_quark(void) diff -Nru syslog-ng-3.11.1/lib/cfg-lexer.h syslog-ng-3.13.2/lib/cfg-lexer.h --- syslog-ng-3.11.1/lib/cfg-lexer.h 2017-07-31 09:05:32.000000000 +0000 +++ syslog-ng-3.13.2/lib/cfg-lexer.h 2017-12-06 06:39:39.000000000 +0000 @@ -27,6 +27,7 @@ #include "syslog-ng.h" #include "cfg-args.h" +#include "cfg-block-generator.h" #include "messages.h" #include @@ -39,9 +40,6 @@ typedef struct _CfgIncludeLevel CfgIncludeLevel; typedef struct _CfgTokenBlock CfgTokenBlock; -typedef struct _CfgBlockGenerator CfgBlockGenerator; -typedef struct _CfgBlock CfgBlock; -typedef struct _CfgLexer CfgLexer; /* the location type to carry location information from the lexer to the grammar */ #define YYLTYPE YYLTYPE @@ -87,13 +85,7 @@ #define CFG_KEYWORD_STOP "@!#?" -/* a block generator is a function that includes a configuration file - * snippet in place to the block reference. This is used by the - * "block" statement, but can also be used by external plugins to - * generate configuration snippets programmatically. That code - * however is missing as of now. (though would be trivial to add) - */ -typedef gboolean (*CfgBlockGeneratorFunc)(CfgLexer *lexer, gint type, const gchar *name, CfgArgs *args, gpointer user_data); + /* structure that describes a given location in the include stack */ struct _CfgIncludeLevel @@ -138,20 +130,15 @@ gint brace_count; gint tokenize_eol; GList *token_blocks; - GList *generators; GString *string_buffer; GString *preprocess_output; gint preprocess_suppress_tokens; GString *token_pretext; GString *token_text; - CfgArgs *globals; + GlobalConfig *cfg; gboolean non_pragma_seen:1, ignore_pragma:1; }; -/* preprocessor help */ -gchar * -cfg_lexer_subst_args(CfgArgs *globals, CfgArgs *defs, CfgArgs *args, const gchar *input, gssize input_length, gsize *output_length, GError **error); - /* pattern buffer */ void cfg_lexer_unput_token(CfgLexer *self, YYSTYPE *yylval); @@ -160,7 +147,6 @@ void cfg_lexer_append_string(CfgLexer *self, int length, char *str); void cfg_lexer_append_char(CfgLexer *self, char c); - /* keyword handling */ void cfg_lexer_set_current_keywords(CfgLexer *self, CfgLexerKeyword *keywords); char *cfg_lexer_get_keyword_string(CfgLexer *self, int kw); @@ -170,6 +156,8 @@ gboolean cfg_lexer_start_next_include(CfgLexer *self); gboolean cfg_lexer_include_file(CfgLexer *self, const gchar *filename); gboolean cfg_lexer_include_buffer(CfgLexer *self, const gchar *name, const gchar *buffer, gssize length); +gboolean cfg_lexer_include_buffer_without_backtick_substitution(CfgLexer *self, + const gchar *name, const gchar *buffer, gsize length); EVTTAG *cfg_lexer_format_location_tag(CfgLexer *self, YYLTYPE *yylloc); /* context tracking */ @@ -180,13 +168,12 @@ /* token blocks */ void cfg_lexer_inject_token_block(CfgLexer *self, CfgTokenBlock *block); -gboolean cfg_lexer_register_block_generator(CfgLexer *self, gint context, const gchar *name, CfgBlockGeneratorFunc generator, gpointer user_data, GDestroyNotify user_data_free); int cfg_lexer_lex(CfgLexer *self, YYSTYPE *yylval, YYLTYPE *yylloc); void cfg_lexer_free_token(YYSTYPE *token); -CfgLexer *cfg_lexer_new(FILE *file, const gchar *filename, GString *preprocess_output); -CfgLexer *cfg_lexer_new_buffer(const gchar *buffer, gsize length); +CfgLexer *cfg_lexer_new(GlobalConfig *cfg, FILE *file, const gchar *filename, GString *preprocess_output); +CfgLexer *cfg_lexer_new_buffer(GlobalConfig *cfg, const gchar *buffer, gsize length); void cfg_lexer_free(CfgLexer *self); gint cfg_lexer_lookup_context_type_by_name(const gchar *name); @@ -201,11 +188,8 @@ CfgTokenBlock *cfg_token_block_new(void); void cfg_token_block_free(CfgTokenBlock *self); -/* user defined configuration block */ +void cfg_lexer_register_generator_plugin(PluginContext *context, CfgBlockGenerator *gen); -gboolean cfg_block_generate(CfgLexer *lexer, gint context, const gchar *name, CfgArgs *args, gpointer user_data); -CfgBlock *cfg_block_new(const gchar *content, CfgArgs *arg_defs); -void cfg_block_free(CfgBlock *self); #define CFG_LEXER_ERROR cfg_lexer_error_quark() diff -Nru syslog-ng-3.11.1/lib/cfg-lexer-subst.c syslog-ng-3.13.2/lib/cfg-lexer-subst.c --- syslog-ng-3.11.1/lib/cfg-lexer-subst.c 2017-07-31 09:05:32.000000000 +0000 +++ syslog-ng-3.13.2/lib/cfg-lexer-subst.c 2017-12-06 06:39:39.000000000 +0000 @@ -24,7 +24,6 @@ #include "cfg-lexer-subst.h" #include "cfg-args.h" -#include "cfg-lexer.h" #include "cfg-grammar.h" #include @@ -106,7 +105,7 @@ YYLTYPE yylloc, look_ahead_yylloc; gchar *result = NULL; - lexer = cfg_lexer_new_buffer(value, strlen(value)); + lexer = cfg_lexer_new_buffer(configuration, value, strlen(value)); token = cfg_lexer_lex(lexer, &yylval, &yylloc); if (token == LL_STRING) { @@ -297,3 +296,15 @@ cfg_args_unref(self->args); g_free(self); } + +gchar * +cfg_lexer_subst_args_in_input(CfgArgs *globals, CfgArgs *defs, CfgArgs *args, const gchar *input, gssize input_length, + gsize *output_length, GError **error) +{ + CfgLexerSubst *subst = cfg_lexer_subst_new(cfg_args_ref(globals), cfg_args_ref(defs), cfg_args_ref(args)); + gchar *result; + + result = cfg_lexer_subst_invoke(subst, input, input_length, output_length, error); + cfg_lexer_subst_free(subst); + return result; +} diff -Nru syslog-ng-3.11.1/lib/cfg-lexer-subst.h syslog-ng-3.13.2/lib/cfg-lexer-subst.h --- syslog-ng-3.11.1/lib/cfg-lexer-subst.h 2017-07-31 09:05:32.000000000 +0000 +++ syslog-ng-3.13.2/lib/cfg-lexer-subst.h 2017-12-06 06:39:39.000000000 +0000 @@ -35,5 +35,7 @@ CfgLexerSubst *cfg_lexer_subst_new(CfgArgs *globals, CfgArgs *defs, CfgArgs *args); void cfg_lexer_subst_free(CfgLexerSubst *self); +gchar * +cfg_lexer_subst_args_in_input(CfgArgs *globals, CfgArgs *defs, CfgArgs *args, const gchar *input, gssize input_length, gsize *output_length, GError **error); #endif diff -Nru syslog-ng-3.11.1/lib/cfg-lex.l syslog-ng-3.13.2/lib/cfg-lex.l --- syslog-ng-3.11.1/lib/cfg-lex.l 2017-07-31 09:05:32.000000000 +0000 +++ syslog-ng-3.13.2/lib/cfg-lex.l 2017-12-06 06:39:39.000000000 +0000 @@ -25,6 +25,7 @@ #include "syslog-ng.h" #include "cfg-lexer.h" +#include "cfg-lexer-subst.h" #include "cfg-grammar.h" #include "messages.h" #include "parse-number.h" @@ -40,7 +41,7 @@ GError *error = NULL; YYLTYPE *cur_lloc = &self->include_stack[self->include_depth].lloc; - res = cfg_lexer_subst_args(self->globals, NULL, NULL, buf, -1, &len, &error); + res = cfg_lexer_subst_args_in_input(self->cfg->globals, NULL, NULL, buf, -1, &len, &error); if (!res) { msg_error("Error performing backtick substitution in configuration file", @@ -153,7 +154,7 @@ odigit [0-7] alpha [a-zA-Z] alphanum [a-zA-Z0-9] -word [^ \#'"\(\)\{\}\\;\r\n\t,|\.@:] +word [^ \#'"\(\)\{\}\[\]\\;\r\n\t,|\.@:] /* block related states must be last, as we use this fact in YY_INPUT */ %x string @@ -208,6 +209,8 @@ \; | \{ | \} | +\[ | +\] | \: | \| { return yytext[0]; } \, ; @@ -306,8 +309,13 @@ <> { if (!cfg_lexer_start_next_include(yyextra)) { - *yylloc = yyextra->include_stack[0].lloc; - yyterminate(); + if (yyextra->include_depth == 0) + { + *yylloc = yyextra->include_stack[0].lloc; + yyterminate(); + } + else + return LL_ERROR; } } diff -Nru syslog-ng-3.11.1/lib/cfg-parser.c syslog-ng-3.13.2/lib/cfg-parser.c --- syslog-ng-3.11.1/lib/cfg-parser.c 2017-07-31 09:05:32.000000000 +0000 +++ syslog-ng-3.13.2/lib/cfg-parser.c 2017-12-06 06:39:39.000000000 +0000 @@ -23,10 +23,10 @@ */ #include "cfg-parser.h" -#include "cfg-lexer.h" #include "cfg-grammar.h" #include +#include extern int main_debug; @@ -86,6 +86,7 @@ { "stats_lifetime", KW_STATS_LIFETIME }, { "stats_level", KW_STATS_LEVEL }, { "stats", KW_STATS_FREQ, KWS_OBSOLETE, "stats_freq" }, + { "stats_max_dynamics", KW_STATS_MAX_DYNAMIC }, { "flush_lines", KW_FLUSH_LINES }, { "flush_timeout", KW_FLUSH_TIMEOUT }, { "suppress", KW_SUPPRESS }, @@ -130,6 +131,7 @@ { "program_override", KW_PROGRAM_OVERRIDE }, { "host_override", KW_HOST_OVERRIDE }, { "throttle", KW_THROTTLE }, + { "jvm_options", KW_JVM_OPTIONS }, { "create_dirs", KW_CREATE_DIRS }, { "optional", KW_OPTIONAL }, @@ -155,6 +157,7 @@ { "retries", KW_RETRIES }, + { "read_old_records", KW_READ_OLD_RECORDS}, /* filter items */ { "type", KW_TYPE }, { "tags", KW_TAGS }, @@ -276,11 +279,44 @@ _report_buffer_location(level->buffer.content, yylloc); } - fprintf(stderr, "\nsyslog-ng documentation: https://www.balabit.com/support/documentation?product=syslog-ng-ose\n" - "mailing list: https://lists.balabit.hu/mailman/listinfo/syslog-ng\n"); + fprintf(stderr, "\nsyslog-ng documentation: https://www.balabit.com/support/documentation?product=%s\n" + "contact: %s\n", PRODUCT_NAME, PRODUCT_CONTACT); } +/* the debug flag for the main parser will be used for all parsers */ +extern int cfg_parser_debug; + + +gboolean +cfg_parser_parse(CfgParser *self, CfgLexer *lexer, gpointer *instance, gpointer arg) +{ + gboolean success; + + if (cfg_parser_debug) + { + fprintf(stderr, "\n\nStarting parser %s\n", self->name); + } + if (self->debug_flag) + (*self->debug_flag) = cfg_parser_debug; + cfg_lexer_push_context(lexer, self->context, self->keywords, self->name); + success = (self->parse(lexer, instance, arg) == 0); + cfg_lexer_pop_context(lexer); + if (cfg_parser_debug) + { + fprintf(stderr, "\nStopping parser %s, result: %d\n", self->name, success); + } + return success; +} + +void +cfg_parser_cleanup(CfgParser *self, gpointer instance) +{ + if (instance && self->cleanup) + self->cleanup(instance); +} + + /* * This function can be used to parse flags in a flags(...) option. It * makes it quite easy to write a flags parser by specifying the @@ -331,3 +367,11 @@ } return FALSE; } + +gboolean +cfg_process_yesno(const gchar *yesno) +{ + if (strcasecmp(yesno, "yes") == 0 || atoi(yesno) > 0) + return TRUE; + return FALSE; +} diff -Nru syslog-ng-3.11.1/lib/cfg-parser.h syslog-ng-3.13.2/lib/cfg-parser.h --- syslog-ng-3.11.1/lib/cfg-parser.h 2017-07-31 09:05:32.000000000 +0000 +++ syslog-ng-3.13.2/lib/cfg-parser.h 2017-12-06 06:39:39.000000000 +0000 @@ -47,6 +47,9 @@ void (*cleanup)(gpointer instance); } CfgParser; +gboolean cfg_parser_parse(CfgParser *self, CfgLexer *lexer, gpointer *instance, gpointer arg); +void cfg_parser_cleanup(CfgParser *self, gpointer instance); + enum { CFH_SET, @@ -62,39 +65,9 @@ guint32 mask; } CfgFlagHandler; -gboolean -cfg_process_flag(CfgFlagHandler *handlers, gpointer base, const gchar *flag); - -/* the debug flag for the main parser will be used for all parsers */ -extern int cfg_parser_debug; - -static inline gboolean -cfg_parser_parse(CfgParser *self, CfgLexer *lexer, gpointer *instance, gpointer arg) -{ - gboolean success; - - if (cfg_parser_debug) - { - fprintf(stderr, "\n\nStarting parser %s\n", self->name); - } - if (self->debug_flag) - (*self->debug_flag) = cfg_parser_debug; - cfg_lexer_push_context(lexer, self->context, self->keywords, self->name); - success = (self->parse(lexer, instance, arg) == 0); - cfg_lexer_pop_context(lexer); - if (cfg_parser_debug) - { - fprintf(stderr, "\nStopping parser %s, result: %d\n", self->name, success); - } - return success; -} +gboolean cfg_process_flag(CfgFlagHandler *handlers, gpointer base, const gchar *flag); +gboolean cfg_process_yesno(const gchar *yesno); -static inline void -cfg_parser_cleanup(CfgParser *self, gpointer instance) -{ - if (instance && self->cleanup) - self->cleanup(instance); -} extern CfgParser main_parser; diff -Nru syslog-ng-3.11.1/lib/cfg-tree.c syslog-ng-3.13.2/lib/cfg-tree.c --- syslog-ng-3.11.1/lib/cfg-tree.c 2017-07-31 09:05:32.000000000 +0000 +++ syslog-ng-3.13.2/lib/cfg-tree.c 2017-12-06 06:39:39.000000000 +0000 @@ -464,6 +464,8 @@ { /* first reference to the pipe uses the same instance, further ones will get cloned */ pipe->flags |= PIF_INLINED; + /* The pipe object is borrowed, so the reference counter must be increased. */ + log_pipe_ref(pipe); } else { @@ -477,7 +479,7 @@ } pipe->flags |= PIF_INLINED; } - g_ptr_array_add(self->initialized_pipes, log_pipe_ref(pipe)); + g_ptr_array_add(self->initialized_pipes, pipe); pipe->expr_node = node; if ((pipe->flags & PIF_SOURCE) == 0) diff -Nru syslog-ng-3.11.1/lib/CMakeLists.txt syslog-ng-3.13.2/lib/CMakeLists.txt --- syslog-ng-3.11.1/lib/CMakeLists.txt 2017-07-31 09:05:32.000000000 +0000 +++ syslog-ng-3.13.2/lib/CMakeLists.txt 2017-12-06 06:39:39.000000000 +0000 @@ -38,6 +38,9 @@ ${TRANSPORT_HEADERS} ${VALUE_PAIRS_HEADERS} ${CSV_SCANNER_HEADERS} + ${LIST_SCANNER_HEADERS} + ${KV_SCANNER_HEADERS} + ${STR_REPR_HEADERS} ${CMAKE_CURRENT_BINARY_DIR}/filter/filter-expr-grammar.h ${CMAKE_CURRENT_BINARY_DIR}/rewrite/rewrite-expr-grammar.h ${CMAKE_CURRENT_BINARY_DIR}/parser/parser-expr-grammar.h @@ -54,6 +57,8 @@ cfg-lexer.h cfg-lexer-subst.h cfg-args.h + cfg-block.h + cfg-block-generator.h cfg-parser.h cfg-tree.h children.h @@ -138,6 +143,8 @@ cache.c cfg.c cfg-args.c + cfg-block.c + cfg-block-generator.c cfg-lexer.c cfg-lexer-subst.c cfg-parser.c @@ -216,6 +223,9 @@ ${TRANSPORT_SOURCES} ${VALUE_PAIRS_SOURCES} ${CSV_SCANNER_SOURCES} + ${LIST_SCANNER_SOURCES} + ${KV_SCANNER_SOURCES} + ${STR_REPR_SOURCES} ${PROJECT_BINARY_DIR}/lib/cfg-grammar.c ${PROJECT_BINARY_DIR}/lib/block-ref-grammar.c ${PROJECT_BINARY_DIR}/lib/cfg-lex.c diff -Nru syslog-ng-3.11.1/lib/compat/CMakeLists.txt syslog-ng-3.13.2/lib/compat/CMakeLists.txt --- syslog-ng-3.11.1/lib/compat/CMakeLists.txt 2017-07-31 09:05:32.000000000 +0000 +++ syslog-ng-3.13.2/lib/compat/CMakeLists.txt 2017-12-06 06:39:39.000000000 +0000 @@ -9,10 +9,13 @@ compat/time.h compat/openssl_support.h compat/pcre.h + compat/getent.h + compat/getent-bb.h PARENT_SCOPE) set(COMPAT_SOURCES compat/getutent.c + compat/glib.c compat/inet_aton.c compat/memrchr.c compat/pio.c @@ -20,4 +23,5 @@ compat/strtok_r.c compat/time.c compat/openssl_support.c + compat/getent.c PARENT_SCOPE) diff -Nru syslog-ng-3.11.1/lib/compat/getent-bb.h syslog-ng-3.13.2/lib/compat/getent-bb.h --- syslog-ng-3.11.1/lib/compat/getent-bb.h 1970-01-01 00:00:00.000000000 +0000 +++ syslog-ng-3.13.2/lib/compat/getent-bb.h 2017-12-06 06:39:39.000000000 +0000 @@ -0,0 +1,52 @@ +/* + * Copyright (c) 2017 Balabit + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + * + * As an additional exemption you are allowed to compile & link against the + * OpenSSL libraries as published by the OpenSSL project. See the file + * COPYING for details. + * + */ + +#ifndef GETENT_BB_H_INCLUDED +#define GETENT_BB_H_INCLUDED + +#if defined(sun) || defined(__sun) + +#include +#include +#include +#include + +int bb__getprotobynumber_r(int proto, + struct protoent *result_buf, char *buf, + size_t buflen, struct protoent **result); + +int bb__getprotobyname_r(const char *name, + struct protoent *result_buf, char *buf, + size_t buflen, struct protoent **result); + +int bb__getservbyport_r(int port, const char *proto, + struct servent *result_buf, char *buf, + size_t buflen, struct servent **result); + +int bb__getservbyname_r(const char *name, const char *proto, + struct servent *result_buf, char *buf, + size_t buflen, struct servent **result); + +#endif + +#endif diff -Nru syslog-ng-3.11.1/lib/compat/getent.c syslog-ng-3.13.2/lib/compat/getent.c --- syslog-ng-3.11.1/lib/compat/getent.c 1970-01-01 00:00:00.000000000 +0000 +++ syslog-ng-3.13.2/lib/compat/getent.c 2017-12-06 06:39:39.000000000 +0000 @@ -0,0 +1,60 @@ +/* + * Copyright (c) 2017 Balabit + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + * + * As an additional exemption you are allowed to compile & link against the + * OpenSSL libraries as published by the OpenSSL project. See the file + * COPYING for details. + * + */ + +#if defined(sun) || defined(__sun) + +#include "compat/getent-bb.h" +#include + +int bb__getprotobynumber_r(int proto, + struct protoent *result_buf, char *buf, + size_t buflen, struct protoent **result) +{ + *result = getprotobynumber_r(proto, result_buf, buf, buflen); + return (*result ? NULL : errno); +} + +int bb__getprotobyname_r(const char *name, + struct protoent *result_buf, char *buf, + size_t buflen, struct protoent **result) +{ + *result = getprotobyname_r(name, result_buf, buf, buflen); + return (*result ? NULL : errno); +} + +int bb__getservbyport_r(int port, const char *proto, + struct servent *result_buf, char *buf, + size_t buflen, struct servent **result) +{ + *result = getservbyport_r(port, proto, result_buf, buf, buflen); + return (*result ? NULL : errno); +} + +int bb__getservbyname_r(const char *name, const char *proto, + struct servent *result_buf, char *buf, + size_t buflen, struct servent **result) +{ + *result = getservbyname_r(name, proto, result_buf, buf, buflen); + return (*result ? NULL : errno); +} +#endif diff -Nru syslog-ng-3.11.1/lib/compat/getent.h syslog-ng-3.13.2/lib/compat/getent.h --- syslog-ng-3.11.1/lib/compat/getent.h 1970-01-01 00:00:00.000000000 +0000 +++ syslog-ng-3.13.2/lib/compat/getent.h 2017-12-06 06:39:39.000000000 +0000 @@ -0,0 +1,42 @@ +/* + * Copyright (c) 2017 Balabit + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + * + * As an additional exemption you are allowed to compile & link against the + * OpenSSL libraries as published by the OpenSSL project. See the file + * COPYING for details. + * + */ + +#ifndef GETENT_COMPAT_H_INCLUDED +#define GETENT_COMPAT_H_INCLUDED + +#include +#include +#include +#include + +#if defined(sun) || defined(__sun) + +#define getprotobynumber_r bb__getprotobynumber_r +#define getprotobyname_r bb__getprotobyname_r +#define getservbyport_r bb__getservbyport_r +#define getservbyname_r bb__getservbyname_r + +#include "getent-bb.h" + +#endif // Solaris +#endif diff -Nru syslog-ng-3.11.1/lib/compat/glib.c syslog-ng-3.13.2/lib/compat/glib.c --- syslog-ng-3.11.1/lib/compat/glib.c 1970-01-01 00:00:00.000000000 +0000 +++ syslog-ng-3.13.2/lib/compat/glib.c 2017-12-06 06:39:39.000000000 +0000 @@ -0,0 +1,58 @@ +/* + * Copyright (c) 2017 Balabit + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + * + * As an additional exemption you are allowed to compile & link against the + * OpenSSL libraries as published by the OpenSSL project. See the file + * COPYING for details. + * + */ + +#include "glib.h" + +#if !SYSLOG_NG_HAVE_G_LIST_COPY_DEEP + +/* + Less efficient than the original implementation in glib 2.53.2 that + I wanted to port back, because this version iterates through the + list twice. Though the original version depends on the internal api + of GList (for example in terms on memory allocation), so I felt + safer to reduce the problem to use public glib api only: g_list_copy + and iteration. + */ + +GList * +g_list_copy_deep(GList *list, + GCopyFunc func, + gpointer user_data) +{ + if (!list) + return NULL; + + GList *new_list = g_list_copy(list); + if (func) + { + GList *iter = new_list; + while (iter != NULL) + { + iter->data = func(iter->data, user_data); + iter = g_list_next(iter); + } + } + + return new_list; +} +#endif diff -Nru syslog-ng-3.11.1/lib/compat/glib.h syslog-ng-3.13.2/lib/compat/glib.h --- syslog-ng-3.11.1/lib/compat/glib.h 2017-07-31 09:05:32.000000000 +0000 +++ syslog-ng-3.13.2/lib/compat/glib.h 2017-12-06 06:39:39.000000000 +0000 @@ -33,4 +33,8 @@ #define g_mapped_file_unref g_mapped_file_free #endif +#if !SYSLOG_NG_HAVE_G_LIST_COPY_DEEP +GList *g_list_copy_deep (GList *list, GCopyFunc func, gpointer user_data); +#endif + #endif diff -Nru syslog-ng-3.11.1/lib/compat/Makefile.am syslog-ng-3.13.2/lib/compat/Makefile.am --- syslog-ng-3.11.1/lib/compat/Makefile.am 2017-07-31 09:05:32.000000000 +0000 +++ syslog-ng-3.13.2/lib/compat/Makefile.am 2017-12-06 06:39:39.000000000 +0000 @@ -10,16 +10,20 @@ lib/compat/string.h \ lib/compat/time.h \ lib/compat/openssl_support.h \ - lib/compat/pcre.h + lib/compat/pcre.h \ + lib/compat/getent.h \ + lib/compat/getent-bb.h compat_sources = \ lib/compat/getutent.c \ lib/compat/inet_aton.c \ lib/compat/memrchr.c \ lib/compat/pio.c \ + lib/compat/glib.c \ lib/compat/strcasestr.c \ lib/compat/strtok_r.c \ lib/compat/time.c \ - lib/compat/openssl_support.c + lib/compat/openssl_support.c \ + lib/compat/getent.c include lib/compat/tests/Makefile.am diff -Nru syslog-ng-3.11.1/lib/compat/openssl_support.c syslog-ng-3.13.2/lib/compat/openssl_support.c --- syslog-ng-3.11.1/lib/compat/openssl_support.c 2017-07-31 09:05:32.000000000 +0000 +++ syslog-ng-3.13.2/lib/compat/openssl_support.c 2017-12-06 06:39:39.000000000 +0000 @@ -160,3 +160,55 @@ OpenSSL_add_all_algorithms(); #endif } + +void openssl_ctx_setup_ecdh(SSL_CTX *ctx) +{ +#if OPENSSL_VERSION_NUMBER >= 0x10100000L + + /* No need to setup as ECDH auto is the default */ + +#elif OPENSSL_VERSION_NUMBER >= 0x10002000L + + SSL_CTX_set_ecdh_auto(ctx, 1); + +#elif OPENSSL_VERSION_NUMBER >= 0x10001000L + + EC_KEY *ecdh = EC_KEY_new_by_curve_name(NID_X9_62_prime256v1); + if (!ecdh) + return; + + SSL_CTX_set_tmp_ecdh(ctx, ecdh); + EC_KEY_free(ecdh); + +#endif +} + +#if !SYSLOG_NG_HAVE_DECL_DH_SET0_PQG +int DH_set0_pqg(DH *dh, BIGNUM *p, BIGNUM *q, BIGNUM *g) +{ + if ((dh->p == NULL && p == NULL) + || (dh->g == NULL && g == NULL)) + return 0; + + if (p != NULL) + { + BN_free(dh->p); + dh->p = p; + } + if (q != NULL) + { + BN_free(dh->q); + dh->q = q; + } + if (g != NULL) + { + BN_free(dh->g); + dh->g = g; + } + + if (q != NULL) + dh->length = BN_num_bits(q); + + return 1; +} +#endif diff -Nru syslog-ng-3.11.1/lib/compat/openssl_support.h syslog-ng-3.13.2/lib/compat/openssl_support.h --- syslog-ng-3.11.1/lib/compat/openssl_support.h 2017-07-31 09:05:32.000000000 +0000 +++ syslog-ng-3.13.2/lib/compat/openssl_support.h 2017-12-06 06:39:39.000000000 +0000 @@ -26,6 +26,7 @@ #include "compat/compat.h" #include +#include #if !SYSLOG_NG_HAVE_DECL_SSL_CTX_GET0_PARAM X509_VERIFY_PARAM *SSL_CTX_get0_param(SSL_CTX *ctx); @@ -46,16 +47,22 @@ #define DECLARE_EVP_MD_CTX(md_ctx) EVP_MD_CTX * md_ctx = EVP_MD_CTX_create() #else #define DECLARE_EVP_MD_CTX(md_ctx) EVP_MD_CTX _##md_ctx; EVP_MD_CTX * md_ctx = & _##md_ctx -#define EVP_MD_CTX_destroy(md_ctx) EVP_MD_CTX_cleanup(md_ctx) +#define EVP_MD_CTX_destroy(md_ctx) EVP_MD_CTX_cleanup(md_ctx) #endif #if !SYSLOG_NG_HAVE_DECL_ASN1_STRING_GET0_DATA #define ASN1_STRING_get0_data ASN1_STRING_data #endif -void openssl_init(); -void openssl_crypto_init_threading(); -void openssl_crypto_deinit_threading(); +#if !SYSLOG_NG_HAVE_DECL_DH_SET0_PQG +int DH_set0_pqg(DH *dh, BIGNUM *p, BIGNUM *q, BIGNUM *g); +#endif + +void openssl_ctx_setup_ecdh(SSL_CTX *ctx); + +void openssl_init(void); +void openssl_crypto_init_threading(void); +void openssl_crypto_deinit_threading(void); #endif diff -Nru syslog-ng-3.11.1/lib/control/control-commands.c syslog-ng-3.13.2/lib/control/control-commands.c --- syslog-ng-3.11.1/lib/control/control-commands.c 2017-07-31 09:05:32.000000000 +0000 +++ syslog-ng-3.13.2/lib/control/control-commands.c 2017-12-06 06:39:39.000000000 +0000 @@ -25,10 +25,24 @@ #include "control/control-main.h" #include "mainloop.h" #include "messages.h" +#include "apphook.h" #include "stats/stats-query-commands.h" static GList *command_list = NULL; +GList * +get_control_command_list(void) +{ + return command_list; +} + +void +reset_control_command_list(void) +{ + g_list_free_full(command_list, (GDestroyNotify)g_free); + command_list = NULL; +} + void control_register_command(const gchar *command_name, const gchar *description, CommandFunction function, gpointer user_data) @@ -107,11 +121,20 @@ return result; } +static GString * +control_connection_reopen(GString *command, gpointer user_data) +{ + GString *result = g_string_new("OK Re-open of log destination files initiated"); + app_reopen(); + return result; +} + ControlCommand default_commands[] = { { "LOG", NULL, control_connection_message_log }, { "STOP", NULL, control_connection_stop_process }, { "RELOAD", NULL, control_connection_reload }, + { "REOPEN", NULL, control_connection_reopen }, { "QUERY", NULL, process_query_command }, { NULL, NULL, NULL }, }; diff -Nru syslog-ng-3.11.1/lib/control/control-commands.h syslog-ng-3.13.2/lib/control/control-commands.h --- syslog-ng-3.11.1/lib/control/control-commands.h 2017-07-31 09:05:32.000000000 +0000 +++ syslog-ng-3.13.2/lib/control/control-commands.h 2017-12-06 06:39:39.000000000 +0000 @@ -30,5 +30,7 @@ void control_register_command(const gchar *command_name, const gchar *description, CommandFunction function, gpointer user_data); GList *control_register_default_commands(MainLoop *main_loop); +GList *get_control_command_list(void); +void reset_control_command_list(void); #endif diff -Nru syslog-ng-3.11.1/lib/control/tests/test_control_cmds.c syslog-ng-3.13.2/lib/control/tests/test_control_cmds.c --- syslog-ng-3.11.1/lib/control/tests/test_control_cmds.c 2017-07-31 09:05:32.000000000 +0000 +++ syslog-ng-3.13.2/lib/control/tests/test_control_cmds.c 2017-12-06 06:39:39.000000000 +0000 @@ -31,7 +31,7 @@ #include "apphook.h" void -test_log() +test_log(void) { GString *command = g_string_sized_new(128); GString *reply; @@ -87,7 +87,7 @@ } void -test_stats() +test_stats(void) { GString *reply = NULL; GString *command = g_string_sized_new(128); @@ -116,7 +116,7 @@ } void -test_reset_stats() +test_reset_stats(void) { GString *reply = NULL; GString *command = g_string_sized_new(128); diff -Nru syslog-ng-3.11.1/lib/crypto.c syslog-ng-3.13.2/lib/crypto.c --- syslog-ng-3.11.1/lib/crypto.c 2017-07-31 09:05:32.000000000 +0000 +++ syslog-ng-3.13.2/lib/crypto.c 2017-12-06 06:39:39.000000000 +0000 @@ -33,6 +33,9 @@ #include #include +#include +#include + #include static gboolean randfile_loaded; @@ -48,6 +51,10 @@ if (rnd_file[0]) RAND_write_file(rnd_file); } +#if OPENSSL_VERSION_NUMBER < 0x10100000L + ERR_free_strings(); + EVP_cleanup(); +#endif openssl_crypto_deinit_threading(); } @@ -73,4 +80,3 @@ "WARNING: a trusted random number source is not available, crypto operations will probably fail. Please set the RANDFILE environment variable."); } } - diff -Nru syslog-ng-3.11.1/lib/debugger/debugger.c syslog-ng-3.13.2/lib/debugger/debugger.c --- syslog-ng-3.11.1/lib/debugger/debugger.c 2017-07-31 09:05:32.000000000 +0000 +++ syslog-ng-3.13.2/lib/debugger/debugger.c 2017-12-06 06:39:39.000000000 +0000 @@ -106,8 +106,12 @@ buf[0] = 0; fclose(f); } + else + { + buf[0] = 0; + } printf("%-8d %s", expr_node->line, buf); - if (buf[strlen(buf) - 1] != '\n') + if (buf[0] == 0 || buf[strlen(buf) - 1] != '\n') putc('\n', stdout); fflush(stdout); } diff -Nru syslog-ng-3.11.1/lib/debugger/tests/test-debugger.c syslog-ng-3.13.2/lib/debugger/tests/test-debugger.c --- syslog-ng-3.11.1/lib/debugger/tests/test-debugger.c 2017-07-31 09:05:32.000000000 +0000 +++ syslog-ng-3.13.2/lib/debugger/tests/test-debugger.c 2017-12-06 06:39:39.000000000 +0000 @@ -34,10 +34,10 @@ } int -main() +main(void) { app_startup(); - configuration = cfg_new_snippet(VERSION_VALUE); + configuration = cfg_new_snippet(); test_debugger(); cfg_free(configuration); } diff -Nru syslog-ng-3.11.1/lib/eventlog/tests/evtsyslog.c syslog-ng-3.13.2/lib/eventlog/tests/evtsyslog.c --- syslog-ng-3.11.1/lib/eventlog/tests/evtsyslog.c 2017-07-31 09:05:32.000000000 +0000 +++ syslog-ng-3.13.2/lib/eventlog/tests/evtsyslog.c 2017-12-06 06:39:39.000000000 +0000 @@ -5,7 +5,7 @@ #endif int -main() +main(void) { openlog("evtsyslog", LOG_PID, 0); syslog(LOG_AUTH | LOG_NOTICE, "test message"); diff -Nru syslog-ng-3.11.1/lib/filter/filter-expr.c syslog-ng-3.13.2/lib/filter/filter-expr.c --- syslog-ng-3.11.1/lib/filter/filter-expr.c 2017-07-31 09:05:32.000000000 +0000 +++ syslog-ng-3.13.2/lib/filter/filter-expr.c 2017-12-06 06:39:39.000000000 +0000 @@ -46,6 +46,8 @@ { gboolean res; + g_assert(num_msg > 0); + res = self->eval(self, msg, num_msg); msg_debug("Filter node evaluation result", evt_tag_printf("msg", "%p", *msg), @@ -64,8 +66,10 @@ filter_expr_eval_root_with_context(FilterExprNode *self, LogMessage **msg, gint num_msg, const LogPathOptions *path_options) { + g_assert(num_msg > 0); + if (self->modify) - log_msg_make_writable(&msg[0], path_options); + log_msg_make_writable(&msg[num_msg - 1], path_options); return filter_expr_eval_with_context(self, msg, num_msg); } diff -Nru syslog-ng-3.11.1/lib/filter/filter-expr-grammar.ym syslog-ng-3.13.2/lib/filter/filter-expr-grammar.ym --- syslog-ng-3.11.1/lib/filter/filter-expr-grammar.ym 2017-07-31 09:05:32.000000000 +0000 +++ syslog-ng-3.13.2/lib/filter/filter-expr-grammar.ym 2017-12-06 06:39:39.000000000 +0000 @@ -153,10 +153,10 @@ gint context = LL_CONTEXT_FILTER; FilterExprNode *node; - p = plugin_find(configuration, context, $1); + p = cfg_find_plugin(configuration, context, $1); CHECK_ERROR(p, @1, "%s plugin %s not found OR you may not used double quotes in your filter expression", cfg_lexer_lookup_context_name_by_type(context), $1); - node = (FilterExprNode *) plugin_parse_config(p, configuration, &@1, NULL); + node = (FilterExprNode *) cfg_parse_plugin(configuration, p, &@1, NULL); free($1); if (!node) { diff -Nru syslog-ng-3.11.1/lib/filter/filter-expr-parser.h syslog-ng-3.13.2/lib/filter/filter-expr-parser.h --- syslog-ng-3.11.1/lib/filter/filter-expr-parser.h 2017-07-31 09:05:32.000000000 +0000 +++ syslog-ng-3.13.2/lib/filter/filter-expr-parser.h 2017-12-06 06:39:39.000000000 +0000 @@ -26,7 +26,6 @@ #define FILTER_EXPR_PARSER_H_INCLUDED #include "cfg-parser.h" -#include "cfg-lexer.h" #include "filter/filter-expr.h" extern CfgParser filter_expr_parser; diff -Nru syslog-ng-3.11.1/lib/filter/filter-in-list.c syslog-ng-3.13.2/lib/filter/filter-in-list.c --- syslog-ng-3.11.1/lib/filter/filter-in-list.c 2017-07-31 09:05:32.000000000 +0000 +++ syslog-ng-3.13.2/lib/filter/filter-in-list.c 2017-12-06 06:39:39.000000000 +0000 @@ -42,7 +42,7 @@ filter_in_list_eval(FilterExprNode *s, LogMessage **msgs, gint num_msg) { FilterInList *self = (FilterInList *)s; - LogMessage *msg = msgs[0]; + LogMessage *msg = msgs[num_msg - 1]; const gchar *value; gssize len = 0; diff -Nru syslog-ng-3.11.1/lib/filter/filter-netmask6.c syslog-ng-3.13.2/lib/filter/filter-netmask6.c --- syslog-ng-3.11.1/lib/filter/filter-netmask6.c 2017-07-31 09:05:32.000000000 +0000 +++ syslog-ng-3.13.2/lib/filter/filter-netmask6.c 2017-12-06 06:39:39.000000000 +0000 @@ -93,7 +93,7 @@ _eval(FilterExprNode *s, LogMessage **msgs, gint num_msg) { FilterNetmask6 *self = (FilterNetmask6 *) s; - LogMessage *msg = msgs[0]; + LogMessage *msg = msgs[num_msg - 1]; gboolean result = FALSE; struct in6_addr network_address; struct in6_addr address; diff -Nru syslog-ng-3.11.1/lib/filter/filter-netmask.c syslog-ng-3.13.2/lib/filter/filter-netmask.c --- syslog-ng-3.11.1/lib/filter/filter-netmask.c 2017-07-31 09:05:32.000000000 +0000 +++ syslog-ng-3.13.2/lib/filter/filter-netmask.c 2017-12-06 06:39:39.000000000 +0000 @@ -41,7 +41,7 @@ { FilterNetmask *self = (FilterNetmask *) s; struct in_addr addr; - LogMessage *msg = msgs[0]; + LogMessage *msg = msgs[num_msg - 1]; if (msg->saddr && g_sockaddr_inet_check(msg->saddr)) { diff -Nru syslog-ng-3.11.1/lib/filter/filter-pri.c syslog-ng-3.13.2/lib/filter/filter-pri.c --- syslog-ng-3.11.1/lib/filter/filter-pri.c 2017-07-31 09:05:32.000000000 +0000 +++ syslog-ng-3.13.2/lib/filter/filter-pri.c 2017-12-06 06:39:39.000000000 +0000 @@ -36,7 +36,7 @@ filter_facility_eval(FilterExprNode *s, LogMessage **msgs, gint num_msg) { FilterPri *self = (FilterPri *) s; - LogMessage *msg = msgs[0]; + LogMessage *msg = msgs[num_msg - 1]; guint32 fac_num = (msg->pri & LOG_FACMASK) >> 3; if (G_UNLIKELY(self->valid & 0x80000000)) @@ -67,7 +67,7 @@ filter_level_eval(FilterExprNode *s, LogMessage **msgs, gint num_msg) { FilterPri *self = (FilterPri *) s; - LogMessage *msg = msgs[0]; + LogMessage *msg = msgs[num_msg - 1]; guint32 pri = msg->pri & LOG_PRIMASK; diff -Nru syslog-ng-3.11.1/lib/filter/filter-re.c syslog-ng-3.13.2/lib/filter/filter-re.c --- syslog-ng-3.11.1/lib/filter/filter-re.c 2017-07-31 09:05:32.000000000 +0000 +++ syslog-ng-3.13.2/lib/filter/filter-re.c 2017-12-06 06:39:39.000000000 +0000 @@ -49,7 +49,7 @@ { FilterRE *self = (FilterRE *) s; const gchar *value; - LogMessage *msg = msgs[0]; + LogMessage *msg = msgs[num_msg - 1]; gssize len = 0; value = log_msg_get_value(msg, self->value_handle, &len); @@ -125,7 +125,7 @@ FilterRE *self = (FilterRE *) s; gchar *str; gboolean res; - LogMessage *msg = msgs[0]; + LogMessage *msg = msgs[num_msg - 1]; if (G_UNLIKELY(!self->value_handle)) { diff -Nru syslog-ng-3.11.1/lib/filter/filter-tags.c syslog-ng-3.13.2/lib/filter/filter-tags.c --- syslog-ng-3.11.1/lib/filter/filter-tags.c 2017-07-31 09:05:32.000000000 +0000 +++ syslog-ng-3.13.2/lib/filter/filter-tags.c 2017-12-06 06:39:39.000000000 +0000 @@ -36,7 +36,7 @@ filter_tags_eval(FilterExprNode *s, LogMessage **msgs, gint num_msg) { FilterTags *self = (FilterTags *)s; - LogMessage *msg = msgs[0]; + LogMessage *msg = msgs[num_msg - 1]; gint i; for (i = 0; i < self->tags->len; i++) diff -Nru syslog-ng-3.11.1/lib/filter/tests/test_filters.c syslog-ng-3.13.2/lib/filter/tests/test_filters.c --- syslog-ng-3.11.1/lib/filter/tests/test_filters.c 2017-07-31 09:05:32.000000000 +0000 +++ syslog-ng-3.13.2/lib/filter/tests/test_filters.c 2017-12-06 06:39:39.000000000 +0000 @@ -243,8 +243,8 @@ app_startup(); - configuration = cfg_new_snippet(VERSION_VALUE); - plugin_load_module("syslogformat", configuration, NULL); + configuration = cfg_new_snippet(); + cfg_load_module(configuration, "syslogformat"); msg_format_options_defaults(&parse_options); msg_format_options_init(&parse_options, configuration); diff -Nru syslog-ng-3.11.1/lib/filter/tests/test_filters_in_list.c syslog-ng-3.13.2/lib/filter/tests/test_filters_in_list.c --- syslog-ng-3.11.1/lib/filter/tests/test_filters_in_list.c 2017-07-31 09:05:32.000000000 +0000 +++ syslog-ng-3.13.2/lib/filter/tests/test_filters_in_list.c 2017-12-06 06:39:39.000000000 +0000 @@ -161,8 +161,8 @@ app_startup(); - configuration = cfg_new_snippet(0x0305); - plugin_load_module("syslogformat", configuration, NULL); + configuration = cfg_new_snippet(); + cfg_load_module(configuration, "syslogformat"); msg_format_options_defaults(&parse_options); msg_format_options_init(&parse_options, configuration); diff -Nru syslog-ng-3.11.1/lib/filter/tests/test_filters_netmask6.c syslog-ng-3.13.2/lib/filter/tests/test_filters_netmask6.c --- syslog-ng-3.11.1/lib/filter/tests/test_filters_netmask6.c 2017-07-31 09:05:32.000000000 +0000 +++ syslog-ng-3.13.2/lib/filter/tests/test_filters_netmask6.c 2017-12-06 06:39:39.000000000 +0000 @@ -72,7 +72,7 @@ } int -main() +main(void) { const gchar *ipv6 = "2001:db80:85a3:8d30:1319:8a2e:3700:7348"; diff -Nru syslog-ng-3.11.1/lib/filter/tests/test_filters_statistics.c syslog-ng-3.13.2/lib/filter/tests/test_filters_statistics.c --- syslog-ng-3.11.1/lib/filter/tests/test_filters_statistics.c 2017-07-31 09:05:32.000000000 +0000 +++ syslog-ng-3.13.2/lib/filter/tests/test_filters_statistics.c 2017-12-06 06:39:39.000000000 +0000 @@ -40,7 +40,7 @@ MsgFormatOptions parse_options; static LogFilterPipe * -create_log_filter_pipe() +create_log_filter_pipe(void) { FilterExprNode *filter = filter_level_new(level_bits("debug")); filter_expr_init(filter, configuration); @@ -72,9 +72,9 @@ { app_startup(); - configuration = cfg_new_snippet(VERSION_VALUE); + configuration = cfg_new_snippet(); configuration->stats_options.level = 1; - plugin_load_module("syslogformat", configuration, NULL); + cfg_load_module(configuration, "syslogformat"); cr_assert(cfg_init(configuration)); msg_format_options_defaults(&parse_options); diff -Nru syslog-ng-3.11.1/lib/gprocess.c syslog-ng-3.13.2/lib/gprocess.c --- syslog-ng-3.11.1/lib/gprocess.c 2017-07-31 09:05:32.000000000 +0000 +++ syslog-ng-3.13.2/lib/gprocess.c 2017-12-06 06:39:39.000000000 +0000 @@ -358,7 +358,7 @@ * Return the processing mode applied to the daemon. **/ GProcessMode -g_process_get_mode() +g_process_get_mode(void) { return process_opts.mode; } diff -Nru syslog-ng-3.11.1/lib/gprocess.h syslog-ng-3.13.2/lib/gprocess.h --- syslog-ng-3.11.1/lib/gprocess.h 2017-07-31 09:05:32.000000000 +0000 +++ syslog-ng-3.13.2/lib/gprocess.h 2017-12-06 06:39:39.000000000 +0000 @@ -63,7 +63,7 @@ void g_process_message(const gchar *fmt, ...); void g_process_set_mode(GProcessMode mode); -GProcessMode g_process_get_mode(); +GProcessMode g_process_get_mode(void); void g_process_set_name(const gchar *name); void g_process_set_user(const gchar *user); void g_process_set_group(const gchar *group); diff -Nru syslog-ng-3.11.1/lib/host-id.c syslog-ng-3.13.2/lib/host-id.c --- syslog-ng-3.11.1/lib/host-id.c 2017-07-31 09:05:32.000000000 +0000 +++ syslog-ng-3.13.2/lib/host-id.c 2017-12-06 06:39:39.000000000 +0000 @@ -29,7 +29,7 @@ guint32 global_host_id = 0; static guint32 -_create_host_id() +_create_host_id(void) { union { diff -Nru syslog-ng-3.11.1/lib/logmatcher.c syslog-ng-3.13.2/lib/logmatcher.c --- syslog-ng-3.11.1/lib/logmatcher.c 2017-07-31 09:05:32.000000000 +0000 +++ syslog-ng-3.13.2/lib/logmatcher.c 2017-12-06 06:39:39.000000000 +0000 @@ -230,12 +230,6 @@ self->super.replace = log_matcher_posix_re_replace; self->super.free_fn = log_matcher_posix_re_free; - if (cfg_is_config_version_older(cfg, 0x0300)) - { - msg_warning_once("WARNING: filters do not store matches in macros by default from " VERSION_3_0 - ", please update your configuration by using an explicit 'store-matches' flag to achieve that"); - self->super.flags = LMF_STORE_MATCHES; - } return &self->super; } @@ -797,14 +791,6 @@ self->super.replace = log_matcher_pcre_re_replace; self->super.free_fn = log_matcher_pcre_re_free; - if (cfg_is_config_version_older(cfg, 0x0300)) - { - msg_warning_once("WARNING: filters do not store matches in macros by default from " VERSION_3_0 - ", please update your configuration by using an explicit 'store-matches' flag to achieve that"); - self->super.flags = LMF_STORE_MATCHES; - } - - return &self->super; } @@ -934,7 +920,7 @@ } GQuark -log_matcher_error_quark() +log_matcher_error_quark(void) { return g_quark_from_static_string("log-matcher-error-quark"); } diff -Nru syslog-ng-3.11.1/lib/logmsg/logmsg.c syslog-ng-3.13.2/lib/logmsg/logmsg.c --- syslog-ng-3.11.1/lib/logmsg/logmsg.c 2017-07-31 09:05:32.000000000 +0000 +++ syslog-ng-3.13.2/lib/logmsg/logmsg.c 2017-12-06 06:39:39.000000000 +0000 @@ -24,6 +24,7 @@ #include "logmsg/logmsg.h" #include "str-utils.h" +#include "str-repr/encode.h" #include "messages.h" #include "logpipe.h" #include "timeutils.h" @@ -38,11 +39,13 @@ #include "lib/host-id.h" #include "ack_tracker.h" +#include #include #include #include #include #include +#include /* * Reference/ACK counting for LogMessage structures @@ -177,12 +180,6 @@ } static inline void -log_msg_unset_flag(LogMessage *self, gint32 flag) -{ - self->flags &= ~flag; -} - -static inline void log_msg_set_host_id(LogMessage *msg) { msg->host_id = host_id_get(); @@ -573,7 +570,7 @@ if (new_entry) log_msg_update_sdata(self, handle, name, name_len); if (handle == LM_V_PROGRAM || handle == LM_V_PID) - log_msg_unset_flag(self, LF_LEGACY_MSGHDR); + log_msg_unset_value(self, LM_V_LEGACY_MSGHDR); } void @@ -862,6 +859,27 @@ /* structured data elements */ static void +log_msg_sdata_append_key_escaped(GString *result, const gchar *sstr, gssize len) +{ + /* The specification does not have any way to escape keys. + * The goal is to create syntactically valid structured data fields. */ + const guchar *ustr = (const guchar *) sstr; + + for (gssize i = 0; i < len; i++) + { + if (!isascii(ustr[i]) || ustr[i] == '=' || ustr[i] == ' ' + || ustr[i] == '[' || ustr[i] == ']' || ustr[i] == '"') + { + gchar hex_code[4]; + g_sprintf(hex_code, "%%%02X", ustr[i]); + g_string_append(result, hex_code); + } + else + g_string_append_c(result, ustr[i]); + } +} + +static void log_msg_sdata_append_escaped(GString *result, const gchar *sstr, gssize len) { gint i; @@ -993,7 +1011,7 @@ if (value) { g_string_append_c(result, ' '); - g_string_append_len(result, sdata_param, sdata_param_len); + log_msg_sdata_append_key_escaped(result, sdata_param, sdata_param_len); g_string_append(result, "=\""); log_msg_sdata_append_escaped(result, value, len); g_string_append_c(result, '"'); @@ -1037,7 +1055,7 @@ if (result->len > original_length) g_string_append_c(result, ','); - g_string_append(result, name); + str_repr_encode_append(result, name, -1, ","); return TRUE; } @@ -1227,6 +1245,19 @@ return self; } +static gsize +_determine_payload_size(gint length, MsgFormatOptions *parse_options) +{ + gsize payload_size; + + if ((parse_options->flags & LP_STORE_RAW_MESSAGE)) + payload_size = length * 4; + else + payload_size = length * 2; + + return MAX(payload_size, 256); +} + /** * log_msg_new: * @msg: message to parse @@ -1241,7 +1272,7 @@ GSockAddr *saddr, MsgFormatOptions *parse_options) { - LogMessage *self = log_msg_alloc(length == 0 ? 256 : length * 2); + LogMessage *self = log_msg_alloc(_determine_payload_size(length, parse_options)); log_msg_init(self, saddr); diff -Nru syslog-ng-3.11.1/lib/logmsg/logmsg.h syslog-ng-3.13.2/lib/logmsg/logmsg.h --- syslog-ng-3.11.1/lib/logmsg/logmsg.h 2017-07-31 09:05:32.000000000 +0000 +++ syslog-ng-3.13.2/lib/logmsg/logmsg.h 2017-12-06 06:39:39.000000000 +0000 @@ -126,12 +126,18 @@ LF_CHAINED_HOSTNAME = 0x00010000, - /* originally parsed from RFC 3164 format and the legacy message header - * was saved in $LEGACY_MSGHDR. This flag is a hack to avoid a hash lookup - * in the fast path and indicates that the parser has saved the legacy - * message header intact in a value named LEGACY_MSGHDR. + /* NOTE: this flag is now unused. The original intent was to save whether + * LEGACY_MSGHDR was saved by the parser code. Now we simply check + * whether the length of ${LEGACY_MSGHDR} is non-zero. This used to be a + * slow operation (when name-value pairs were stored in a hashtable), now + * it is much faster. Also, this makes it possible to reproduce a message + * entirely based on name-value pairs. Without this change, even if + * LEGACY_MSGHDR was transferred (e.g. ewmm), the other side couldn't + * reproduce the original message, as this flag was not transferred. + * + * The flag remains here for documentation, and also because it is serialized in disk-buffers */ - LF_LEGACY_MSGHDR = 0x00020000, + __UNUSED_LF_LEGACY_MSGHDR = 0x00020000, }; typedef struct _LogMessageQueueNode diff -Nru syslog-ng-3.11.1/lib/logmsg/nvtable.c syslog-ng-3.13.2/lib/logmsg/nvtable.c --- syslog-ng-3.11.1/lib/logmsg/nvtable.c 2017-07-31 09:05:32.000000000 +0000 +++ syslog-ng-3.13.2/lib/logmsg/nvtable.c 2017-12-06 06:39:39.000000000 +0000 @@ -187,6 +187,8 @@ * non-zero terminated strings properly handled, thus the caller has * to supply a non-NULL value_len */ + g_assert(length != NULL); + *length = MIN(entry->vindirect.ofs + entry->vindirect.len, referenced_length) - entry->vindirect.ofs; return referenced_value + entry->vindirect.ofs; } diff -Nru syslog-ng-3.11.1/lib/logmsg/tests/test_log_message.c syslog-ng-3.13.2/lib/logmsg/tests/test_log_message.c --- syslog-ng-3.11.1/lib/logmsg/tests/test_log_message.c 2017-07-31 09:05:32.000000000 +0000 +++ syslog-ng-3.13.2/lib/logmsg/tests/test_log_message.c 2017-12-06 06:39:39.000000000 +0000 @@ -97,7 +97,7 @@ GString *result = g_string_sized_new(0); log_msg_append_format_sdata(msg, result, seq_num); - cr_assert_str_eq(result->str, expected, "SDATA value does not match"); + cr_assert_str_eq(result->str, expected, "SDATA value does not match, '%s' vs '%s'", expected, result->str); g_string_free(result, TRUE); } @@ -332,6 +332,40 @@ cr_assert(are_equals, "The timestamps in a LogMessage created by log_msg_new_local() should be equals"); } +Test(log_message, test_sdata_sanitize_keys) +{ + LogMessage *msg; + /* These keys looks strange, but JSON object can be parsed to SDATA, + * so the key could contain any character, while the specification + * does not declare any way to encode the the keys, just the values. + * The goal is to have a syntactically valid syslog message. */ + + msg = log_msg_new_empty(); + log_msg_set_value_by_name(msg, ".SDATA.foo.bar[0]", "value[0]", -1); + assert_sdata_value_equals(msg, "[foo bar%5B0%5D=\"value[0\\]\"]"); + log_msg_unref(msg); + + msg = log_msg_new_empty(); + log_msg_set_value_by_name(msg, ".SDATA.foo.bácsi", "bácsi", -1); + assert_sdata_value_equals(msg, "[foo b%C3%A1csi=\"bácsi\"]"); + log_msg_unref(msg); + + msg = log_msg_new_empty(); + log_msg_set_value_by_name(msg, ".SDATA.foo.sp ace", "sp ace", -1); + assert_sdata_value_equals(msg, "[foo sp%20ace=\"sp ace\"]"); + log_msg_unref(msg); + + msg = log_msg_new_empty(); + log_msg_set_value_by_name(msg, ".SDATA.foo.eq=al", "eq=al", -1); + assert_sdata_value_equals(msg, "[foo eq%3Dal=\"eq=al\"]"); + log_msg_unref(msg); + + msg = log_msg_new_empty(); + log_msg_set_value_by_name(msg, ".SDATA.foo.quo\"te", "quo\"te", -1); + assert_sdata_value_equals(msg, "[foo quo%22te=\"quo\\\"te\"]"); + log_msg_unref(msg); +} + Test(log_message, test_sdata_value_is_updated_by_sdata_name_value_pairs) { LogMessage *msg; @@ -481,3 +515,14 @@ log_msg_unref(msg); } + +Test(log_message, when_get_indirect_value_with_null_value_len_abort_instead_of_sigsegv, .signal=SIGABRT) +{ + LogMessageTestParams *params = log_message_test_params_new(); + + NVHandle indirect = log_msg_get_value_handle("INDIRECT"); + log_msg_set_value_indirect(params->message, indirect, params->nv_handle, 0, 0, 5); + log_msg_get_value(params->message, indirect, NULL); + + log_message_test_params_free(params); +} diff -Nru syslog-ng-3.11.1/lib/logmsg/tests/test_logmsg_ack.c syslog-ng-3.13.2/lib/logmsg/tests/test_logmsg_ack.c --- syslog-ng-3.11.1/lib/logmsg/tests/test_logmsg_ack.c 2017-07-31 09:05:32.000000000 +0000 +++ syslog-ng-3.13.2/lib/logmsg/tests/test_logmsg_ack.c 2017-12-06 06:39:39.000000000 +0000 @@ -70,7 +70,7 @@ } static AckRecord * -ack_record_new() +ack_record_new(void) { AckRecord *self = g_new0(AckRecord, 1); self->init = _init; diff -Nru syslog-ng-3.11.1/lib/logmsg/tests/test_logmsg_serialize.c syslog-ng-3.13.2/lib/logmsg/tests/test_logmsg_serialize.c --- syslog-ng-3.11.1/lib/logmsg/tests/test_logmsg_serialize.c 2017-07-31 09:05:32.000000000 +0000 +++ syslog-ng-3.13.2/lib/logmsg/tests/test_logmsg_serialize.c 2017-12-06 06:39:39.000000000 +0000 @@ -102,7 +102,7 @@ } static void -_reset_log_msg_registry() +_reset_log_msg_registry(void) { log_msg_registry_deinit(); log_msg_registry_init(); @@ -268,8 +268,8 @@ main(int argc, char **argv) { app_startup(); - cfg = cfg_new_snippet(0x0307); - plugin_load_module("syslogformat", cfg, NULL); + cfg = cfg_new_snippet(); + cfg_load_module(cfg, "syslogformat"); msg_format_options_defaults(&parse_options); msg_format_options_init(&parse_options, cfg); test_serialize(); diff -Nru syslog-ng-3.11.1/lib/logmsg/tests/test_tags.c syslog-ng-3.13.2/lib/logmsg/tests/test_tags.c --- syslog-ng-3.11.1/lib/logmsg/tests/test_tags.c 2017-07-31 09:05:32.000000000 +0000 +++ syslog-ng-3.13.2/lib/logmsg/tests/test_tags.c 2017-12-06 06:39:39.000000000 +0000 @@ -104,7 +104,7 @@ } void -test_msg_tags() +test_msg_tags(void) { gchar *name; gint i, set; diff -Nru syslog-ng-3.11.1/lib/logmsg/tests/test_timestamp_serialize.c syslog-ng-3.13.2/lib/logmsg/tests/test_timestamp_serialize.c --- syslog-ng-3.11.1/lib/logmsg/tests/test_timestamp_serialize.c 2017-07-31 09:05:32.000000000 +0000 +++ syslog-ng-3.13.2/lib/logmsg/tests/test_timestamp_serialize.c 2017-12-06 06:39:39.000000000 +0000 @@ -42,7 +42,7 @@ g_string_free(stream, TRUE); static void -test_normal_working() +test_normal_working(void) { PREPARE_TEST assert_true(timestamp_serialize(sa, input_timestamps), "Failed to serialize timestamps"); @@ -56,7 +56,7 @@ } static void -test_derializing_injured_timestamp() +test_derializing_injured_timestamp(void) { PREPARE_TEST diff -Nru syslog-ng-3.11.1/lib/logpipe.h syslog-ng-3.13.2/lib/logpipe.h --- syslog-ng-3.11.1/lib/logpipe.h 2017-07-31 09:05:32.000000000 +0000 +++ syslog-ng-3.13.2/lib/logpipe.h 2017-12-06 06:39:39.000000000 +0000 @@ -37,8 +37,7 @@ #define NC_WRITE_ERROR 3 #define NC_FILE_MOVED 4 #define NC_FILE_EOF 5 -#define NC_FILE_SKIP 6 -#define NC_REOPEN_REQUIRED 7 +#define NC_REOPEN_REQUIRED 6 /* indicates that the LogPipe was initialized */ #define PIF_INITIALIZED 0x0001 diff -Nru syslog-ng-3.11.1/lib/logproto/logproto-builtins.c syslog-ng-3.13.2/lib/logproto/logproto-builtins.c --- syslog-ng-3.11.1/lib/logproto/logproto-builtins.c 2017-07-31 09:05:32.000000000 +0000 +++ syslog-ng-3.13.2/lib/logproto/logproto-builtins.c 2017-12-06 06:39:39.000000000 +0000 @@ -54,7 +54,7 @@ }; void -log_proto_register_builtin_plugins(GlobalConfig *cfg) +log_proto_register_builtin_plugins(PluginContext *context) { - plugin_register(cfg, framed_server_plugins, G_N_ELEMENTS(framed_server_plugins)); + plugin_register(context, framed_server_plugins, G_N_ELEMENTS(framed_server_plugins)); } diff -Nru syslog-ng-3.11.1/lib/logproto/logproto-builtins.h syslog-ng-3.13.2/lib/logproto/logproto-builtins.h --- syslog-ng-3.11.1/lib/logproto/logproto-builtins.h 2017-07-31 09:05:32.000000000 +0000 +++ syslog-ng-3.13.2/lib/logproto/logproto-builtins.h 2017-12-06 06:39:39.000000000 +0000 @@ -26,6 +26,6 @@ #include "cfg.h" -void log_proto_register_builtin_plugins(GlobalConfig *cfg); +void log_proto_register_builtin_plugins(PluginContext *context); #endif diff -Nru syslog-ng-3.11.1/lib/logproto/logproto-client.c syslog-ng-3.13.2/lib/logproto/logproto-client.c --- syslog-ng-3.11.1/lib/logproto/logproto-client.c 2017-07-31 09:05:32.000000000 +0000 +++ syslog-ng-3.13.2/lib/logproto/logproto-client.c 2017-12-06 06:39:39.000000000 +0000 @@ -74,17 +74,13 @@ } LogProtoClientFactory * -log_proto_client_get_factory(GlobalConfig *cfg, const gchar *name) +log_proto_client_get_factory(PluginContext *context, const gchar *name) { Plugin *plugin; - plugin = plugin_find(cfg, LL_CONTEXT_CLIENT_PROTO, name); + plugin = plugin_find(context, LL_CONTEXT_CLIENT_PROTO, name); if (plugin && plugin->construct) - { - return plugin->construct(plugin, cfg, LL_CONTEXT_CLIENT_PROTO, name); - } - else - { - return NULL; - } + return plugin->construct(plugin); + + return NULL; } diff -Nru syslog-ng-3.11.1/lib/logproto/logproto-client.h syslog-ng-3.13.2/lib/logproto/logproto-client.h --- syslog-ng-3.11.1/lib/logproto/logproto-client.h 2017-07-31 09:05:32.000000000 +0000 +++ syslog-ng-3.13.2/lib/logproto/logproto-client.h 2017-12-06 06:39:39.000000000 +0000 @@ -138,9 +138,7 @@ #define DEFINE_LOG_PROTO_CLIENT(prefix) \ static gpointer \ - prefix ## _client_plugin_construct(Plugin *self, \ - GlobalConfig *cfg, \ - gint plugin_type, const gchar *plugin_name) \ + prefix ## _client_plugin_construct(Plugin *self) \ { \ static LogProtoClientFactory proto = { \ .construct = prefix ## _client_new, \ @@ -168,6 +166,6 @@ return self->construct(transport, options); } -LogProtoClientFactory *log_proto_client_get_factory(GlobalConfig *cfg, const gchar *name); +LogProtoClientFactory *log_proto_client_get_factory(PluginContext *context, const gchar *name); #endif diff -Nru syslog-ng-3.11.1/lib/logproto/logproto-multiline-server.c syslog-ng-3.13.2/lib/logproto/logproto-multiline-server.c --- syslog-ng-3.11.1/lib/logproto/logproto-multiline-server.c 1970-01-01 00:00:00.000000000 +0000 +++ syslog-ng-3.13.2/lib/logproto/logproto-multiline-server.c 2017-12-06 06:39:39.000000000 +0000 @@ -0,0 +1,105 @@ +/* + * Copyright (c) 2017 Balabit + * Copyright (c) 2017 Balazs Scheidler + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + * + * As an additional exemption you are allowed to compile & link against the + * OpenSSL libraries as published by the OpenSSL project. See the file + * COPYING for details. + * + */ +#include "logproto/logproto-multiline-server.h" +#include "logproto/logproto-regexp-multiline-server.h" +#include "logproto/logproto-indented-multiline-server.h" + +/* + * This is basically a factory that takes multi-line related options and + * constructs the appropriate LogProtoServer instance. + */ + +LogProtoServer * +log_proto_multiline_server_new(LogTransport *transport, + const LogProtoMultiLineServerOptions *options) +{ + switch (options->mode) + { + case MLM_INDENTED: + return log_proto_indented_multiline_server_new(transport, &options->super); + case MLM_PREFIX_GARBAGE: + return log_proto_prefix_garbage_multiline_server_new(transport, &options->super, + options->prefix, + options->garbage); + case MLM_PREFIX_SUFFIX: + return log_proto_prefix_suffix_multiline_server_new(transport, &options->super, + options->prefix, + options->garbage); + case MLM_NONE: + return log_proto_text_server_new(transport, &options->super); + } + g_assert_not_reached(); +} + +gboolean +log_proto_multi_line_server_options_set_mode(LogProtoMultiLineServerOptions *options, const gchar *mode) +{ + if (strcasecmp(mode, "indented") == 0) + options->mode = MLM_INDENTED; + else if (strcasecmp(mode, "regexp") == 0) + options->mode = MLM_PREFIX_GARBAGE; + else if (strcasecmp(mode, "prefix-garbage") == 0) + options->mode = MLM_PREFIX_GARBAGE; + else if (strcasecmp(mode, "prefix-suffix") == 0) + options->mode = MLM_PREFIX_SUFFIX; + else if (strcasecmp(mode, "none") == 0) + options->mode = MLM_NONE; + else + return FALSE; + return TRUE; +} + +gboolean +log_proto_multi_line_server_options_set_prefix(LogProtoMultiLineServerOptions *options, const gchar *prefix_regexp, + GError **error) +{ + options->prefix = multi_line_regexp_compile(prefix_regexp, error); + return options->prefix != NULL; +} + +gboolean +log_proto_multi_line_server_options_set_garbage(LogProtoMultiLineServerOptions *options, const gchar *garbage_regexp, + GError **error) +{ + options->garbage = multi_line_regexp_compile(garbage_regexp, error); + return options->garbage != NULL; +} + +void +log_proto_multi_line_server_options_defaults(LogProtoMultiLineServerOptions *options) +{ + options->mode = MLM_NONE; +} + +void +log_proto_multi_line_server_options_init(LogProtoMultiLineServerOptions *options) +{ +} + +void +log_proto_multi_line_server_options_destroy(LogProtoMultiLineServerOptions *options) +{ + multi_line_regexp_free(options->prefix); + multi_line_regexp_free(options->garbage); +} diff -Nru syslog-ng-3.11.1/lib/logproto/logproto-multiline-server.h syslog-ng-3.13.2/lib/logproto/logproto-multiline-server.h --- syslog-ng-3.11.1/lib/logproto/logproto-multiline-server.h 1970-01-01 00:00:00.000000000 +0000 +++ syslog-ng-3.13.2/lib/logproto/logproto-multiline-server.h 2017-12-06 06:39:39.000000000 +0000 @@ -0,0 +1,58 @@ +/* + * Copyright (c) 2017 Balabit + * Copyright (c) 2017 Balazs Scheidler + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + * + * As an additional exemption you are allowed to compile & link against the + * OpenSSL libraries as published by the OpenSSL project. See the file + * COPYING for details. + * + */ +#ifndef LOGPROTO_MULTILINE_SERVER_INCLUDED +#define LOGPROTO_MULTILINE_SERVER_INCLUDED + +#include "logproto/logproto-regexp-multiline-server.h" + +enum +{ + MLM_NONE, + MLM_INDENTED, + MLM_PREFIX_GARBAGE, + MLM_PREFIX_SUFFIX, +}; + +typedef struct _LogProtoMultiLineServerOptions +{ + LogProtoServerOptions super; + gint mode; + MultiLineRegexp *prefix; + MultiLineRegexp *garbage; +} LogProtoMultiLineServerOptions; + +LogProtoServer * +log_proto_multiline_server_new(LogTransport *transport, + const LogProtoMultiLineServerOptions *options); + +gboolean log_proto_multi_line_server_options_set_mode(LogProtoMultiLineServerOptions *options, const gchar *mode); +gboolean log_proto_multi_line_server_options_set_prefix(LogProtoMultiLineServerOptions *options, const gchar *prefix_regexp, GError **error); +gboolean log_proto_multi_line_server_options_set_garbage(LogProtoMultiLineServerOptions *options, const gchar *garbage_regexp, GError **error); + +void log_proto_multi_line_server_options_defaults(LogProtoMultiLineServerOptions *options); +void log_proto_multi_line_server_options_init(LogProtoMultiLineServerOptions *options); +void log_proto_multi_line_server_options_destroy(LogProtoMultiLineServerOptions *options); + + +#endif diff -Nru syslog-ng-3.11.1/lib/logproto/logproto-regexp-multiline-server.c syslog-ng-3.13.2/lib/logproto/logproto-regexp-multiline-server.c --- syslog-ng-3.11.1/lib/logproto/logproto-regexp-multiline-server.c 2017-07-31 09:05:32.000000000 +0000 +++ syslog-ng-3.13.2/lib/logproto/logproto-regexp-multiline-server.c 2017-12-06 06:39:39.000000000 +0000 @@ -206,6 +206,21 @@ } } +static gboolean +log_proto_regexp_multi_line_server_validate_options(LogProtoServer *s) +{ + LogProtoREMultiLineServer *self = (LogProtoREMultiLineServer *) s; + + if (!self->prefix && + !self->garbage) + { + msg_error("To follow files in multi-line-mode() 'regexp', 'prefix-garbage', 'prefix-suffix', " + "please also specifiy regexps using the multi-line-prefix/garbage options"); + return FALSE; + } + return log_proto_text_server_validate_options_method(s); +} + void log_proto_regexp_multiline_server_init(LogProtoREMultiLineServer *self, LogTransport *transport, @@ -214,6 +229,7 @@ MultiLineRegexp *garbage_or_suffix) { log_proto_text_server_init(&self->super, transport, options); + self->super.super.super.validate_options = log_proto_regexp_multi_line_server_validate_options; self->super.accumulate_line = log_proto_regexp_multiline_accumulate_line; self->prefix = prefix; self->garbage = garbage_or_suffix; diff -Nru syslog-ng-3.11.1/lib/logproto/logproto-server.c syslog-ng-3.13.2/lib/logproto/logproto-server.c --- syslog-ng-3.11.1/lib/logproto/logproto-server.c 2017-07-31 09:05:32.000000000 +0000 +++ syslog-ng-3.13.2/lib/logproto/logproto-server.c 2017-12-06 06:39:39.000000000 +0000 @@ -195,17 +195,12 @@ } LogProtoServerFactory * -log_proto_server_get_factory(GlobalConfig *cfg, const gchar *name) +log_proto_server_get_factory(PluginContext *context, const gchar *name) { Plugin *plugin; - plugin = plugin_find(cfg, LL_CONTEXT_SERVER_PROTO, name); + plugin = plugin_find(context, LL_CONTEXT_SERVER_PROTO, name); if (plugin && plugin->construct) - { - return plugin->construct(plugin, cfg, LL_CONTEXT_SERVER_PROTO, name); - } - else - { - return NULL; - } + return plugin->construct(plugin); + return NULL; } diff -Nru syslog-ng-3.11.1/lib/logproto/logproto-server.h syslog-ng-3.13.2/lib/logproto/logproto-server.h --- syslog-ng-3.11.1/lib/logproto/logproto-server.h 2017-07-31 09:05:32.000000000 +0000 +++ syslog-ng-3.13.2/lib/logproto/logproto-server.h 2017-12-06 06:39:39.000000000 +0000 @@ -33,7 +33,7 @@ typedef struct _LogProtoServer LogProtoServer; typedef struct _LogProtoServerOptions LogProtoServerOptions; -#define LOG_PROTO_SERVER_OPTIONS_SIZE 32 +#define LOG_PROTO_SERVER_OPTIONS_SIZE 128 struct _LogProtoServerOptions { @@ -67,7 +67,6 @@ /* FIXME: rename to something else */ gboolean (*is_position_tracked)(LogProtoServer *s); gboolean (*prepare)(LogProtoServer *s, GIOCondition *cond); - gboolean (*is_preemptable)(LogProtoServer *s); gboolean (*restart_with_state)(LogProtoServer *s, PersistState *state, const gchar *persist_name); LogProtoStatus (*fetch)(LogProtoServer *s, const guchar **msg, gsize *msg_len, gboolean *may_read, LogTransportAuxData *aux, Bookmark *bookmark); gboolean (*validate_options)(LogProtoServer *s); @@ -93,14 +92,6 @@ } static inline gboolean -log_proto_server_is_preemptable(LogProtoServer *s) -{ - if (s->is_preemptable) - return s->is_preemptable(s); - return TRUE; -} - -static inline gboolean log_proto_server_restart_with_state(LogProtoServer *s, PersistState *state, const gchar *persist_name) { if (s->restart_with_state) @@ -119,7 +110,9 @@ static inline gint log_proto_server_get_fd(LogProtoServer *s) { - /* FIXME: Layering violation */ + /* FIXME: Layering violation, as transport may not be fd based at all. + * But LogReader assumes it is. */ + return s->transport->fd; } @@ -145,9 +138,7 @@ #define DEFINE_LOG_PROTO_SERVER(prefix) \ static gpointer \ - prefix ## _server_plugin_construct(Plugin *self, \ - GlobalConfig *cfg, \ - gint plugin_type, const gchar *plugin_name) \ + prefix ## _server_plugin_construct(Plugin *self) \ { \ static LogProtoServerFactory proto = { \ .construct = prefix ## _server_new, \ @@ -175,7 +166,7 @@ return self->construct(transport, options); } -LogProtoServerFactory *log_proto_server_get_factory(GlobalConfig *cfg, const gchar *name); +LogProtoServerFactory *log_proto_server_get_factory(PluginContext *context, const gchar *name); const guchar *find_eom(const guchar *s, gsize n); diff -Nru syslog-ng-3.11.1/lib/logproto/logproto-text-server.c syslog-ng-3.13.2/lib/logproto/logproto-text-server.c --- syslog-ng-3.11.1/lib/logproto/logproto-text-server.c 2017-07-31 09:05:32.000000000 +0000 +++ syslog-ng-3.13.2/lib/logproto/logproto-text-server.c 2017-12-06 06:39:39.000000000 +0000 @@ -83,25 +83,6 @@ } -/** - * This function is called in cases when several files are continously - * polled for changes. Whenever the caller would like to switch to another - * file, it will call this function to check whether it should be allowed to do so. - * - * This function returns true if the current state of this LogProtoServer would - * allow preemption, e.g. the contents of the current buffer can be - * discarded. - **/ -static gboolean -log_proto_text_server_is_preemptable(LogProtoServer *s) -{ - LogProtoTextServer *self = (LogProtoTextServer *) s; - gboolean preemptable; - - preemptable = (self->cached_eol_pos == 0); - return preemptable; -} - static gboolean log_proto_text_server_prepare(LogProtoServer *s, GIOCondition *cond) { @@ -444,7 +425,6 @@ log_proto_text_server_init(LogProtoTextServer *self, LogTransport *transport, const LogProtoServerOptions *options) { log_proto_buffered_server_init(&self->super, transport, options); - self->super.super.is_preemptable = log_proto_text_server_is_preemptable; self->super.super.prepare = log_proto_text_server_prepare; self->super.super.free_fn = log_proto_text_server_free; self->super.fetch_from_buffer = log_proto_text_server_fetch_from_buffer; diff -Nru syslog-ng-3.11.1/lib/logproto/logproto-text-server.h syslog-ng-3.13.2/lib/logproto/logproto-text-server.h --- syslog-ng-3.11.1/lib/logproto/logproto-text-server.h 2017-07-31 09:05:32.000000000 +0000 +++ syslog-ng-3.13.2/lib/logproto/logproto-text-server.h 2017-12-06 06:39:39.000000000 +0000 @@ -75,4 +75,10 @@ gint log_proto_get_char_size_for_fixed_encoding(const gchar *encoding); +static inline gboolean +log_proto_text_server_validate_options_method(LogProtoServer *s) +{ + return log_proto_buffered_server_validate_options_method(s); +} + #endif diff -Nru syslog-ng-3.11.1/lib/logproto/Makefile.am syslog-ng-3.13.2/lib/logproto/Makefile.am --- syslog-ng-3.11.1/lib/logproto/Makefile.am 2017-07-31 09:05:32.000000000 +0000 +++ syslog-ng-3.13.2/lib/logproto/Makefile.am 2017-12-06 06:39:39.000000000 +0000 @@ -11,6 +11,7 @@ lib/logproto/logproto-text-server.h \ lib/logproto/logproto-indented-multiline-server.h \ lib/logproto/logproto-regexp-multiline-server.h \ + lib/logproto/logproto-multiline-server.h \ lib/logproto/logproto-record-server.h \ lib/logproto/logproto-builtins.h \ lib/logproto/logproto.h @@ -26,6 +27,7 @@ lib/logproto/logproto-text-server.c \ lib/logproto/logproto-indented-multiline-server.c \ lib/logproto/logproto-regexp-multiline-server.c \ + lib/logproto/logproto-multiline-server.c \ lib/logproto/logproto-record-server.c \ lib/logproto/logproto-builtins.c diff -Nru syslog-ng-3.11.1/lib/logproto/tests/test_findeom.c syslog-ng-3.13.2/lib/logproto/tests/test_findeom.c --- syslog-ng-3.11.1/lib/logproto/tests/test_findeom.c 2017-07-31 09:05:32.000000000 +0000 +++ syslog-ng-3.13.2/lib/logproto/tests/test_findeom.c 2017-12-06 06:39:39.000000000 +0000 @@ -49,7 +49,7 @@ } int -main() +main(void) { testcase("a\nb\nc\n", 6, 1); testcase("ab\nb\nc\n", 7, 2); diff -Nru syslog-ng-3.11.1/lib/logreader.c syslog-ng-3.13.2/lib/logreader.c --- syslog-ng-3.11.1/lib/logreader.c 2017-07-31 09:05:32.000000000 +0000 +++ syslog-ng-3.13.2/lib/logreader.c 2017-12-06 06:39:39.000000000 +0000 @@ -35,13 +35,10 @@ LogSource super; LogProtoServer *proto; gboolean immediate_check; - gboolean waiting_for_preemption; LogPipe *control; LogReaderOptions *options; PollEvents *poll_events; GSockAddr *peer_addr; - ino_t inode; - gint64 size; /* NOTE: these used to be LogReaderWatch members, which were merged into * LogReader with the multi-thread refactorization */ @@ -331,9 +328,6 @@ gboolean may_read = TRUE; LogTransportAuxData aux; - if (self->waiting_for_preemption) - may_read = FALSE; - /* NOTE: this loop is here to decrease the load on the main loop, we try * to fetch a couple of messages in a single run (but only up to * fetch_limit). @@ -360,9 +354,11 @@ switch (status) { case LPS_EOF: + g_sockaddr_unref(aux.peer_addr); + return NC_CLOSE; case LPS_ERROR: g_sockaddr_unref(aux.peer_addr); - return status == LPS_ERROR ? NC_READ_ERROR : NC_CLOSE; + return NC_READ_ERROR; case LPS_SUCCESS: break; default: @@ -391,18 +387,7 @@ } } log_transport_aux_data_destroy(&aux); - if (self->options->flags & LR_PREEMPT) - { - if (log_proto_server_is_preemptable(self->proto)) - { - self->waiting_for_preemption = FALSE; - log_pipe_notify(self->control, NC_FILE_SKIP, self); - } - else - { - self->waiting_for_preemption = TRUE; - } - } + if (msg_count == self->options->fetch_limit) self->immediate_check = TRUE; return 0; @@ -470,14 +455,20 @@ } void -log_reader_set_options(LogReader *s, LogPipe *control, LogReaderOptions *options, gint stats_level, gint stats_source, +log_reader_set_options(LogReader *s, LogPipe *control, LogReaderOptions *options, const gchar *stats_id, const gchar *stats_instance) { LogReader *self = (LogReader *) s; - gboolean pos_tracked = ((self->proto != NULL) && log_proto_server_is_position_tracked(self->proto)); + /* log_reader_reopen() needs to be called prior to set_options. This is + * an ugly hack, but at least it is more explicitly than what used to be + * here, which silently ignored if self->proto was NULL. + */ + + g_assert(self->proto != NULL); + gboolean pos_tracked = log_proto_server_is_position_tracked(self->proto); - log_source_set_options(&self->super, &options->super, stats_level, stats_source, stats_id, stats_instance, + log_source_set_options(&self->super, &options->super, stats_id, stats_instance, (options->flags & LR_THREADED), pos_tracked, control->expr_node); log_pipe_unref(self->control); @@ -485,8 +476,7 @@ self->control = control; self->options = options; - if (self->proto) - log_proto_server_set_options(self->proto, &self->options->proto_options.super); + log_proto_server_set_options(self->proto, &self->options->proto_options.super); } /* run in the main thread in reaction to a log_reader_reopen to change @@ -519,8 +509,6 @@ { gpointer args[] = { self, proto, poll_events }; - log_source_deinit(&self->super.super); - main_loop_call((MainLoopTaskFunc) log_reader_reopen_deferred, args, TRUE); if (!main_loop_is_main_thread()) @@ -532,7 +520,6 @@ } g_static_mutex_unlock(&self->pending_proto_lock); } - log_source_init(&self->super.super); } void @@ -576,12 +563,6 @@ log_proto_server_options_defaults(&options->proto_options.super); msg_format_options_defaults(&options->parse_options); options->fetch_limit = 10; - if (configuration && cfg_is_config_version_older(configuration, 0x0300)) - { - msg_warning_once("WARNING: input: sources do not remove new-line characters from messages by default from " VERSION_3_0 - ", please add 'no-multi-line' flag to your configuration if you want to retain this functionality"); - options->parse_options.flags |= LP_NO_MULTI_LINE; - } } /* diff -Nru syslog-ng-3.11.1/lib/logreader.h syslog-ng-3.13.2/lib/logreader.h --- syslog-ng-3.11.1/lib/logreader.h 2017-07-31 09:05:32.000000000 +0000 +++ syslog-ng-3.13.2/lib/logreader.h 2017-12-06 06:39:39.000000000 +0000 @@ -21,7 +21,7 @@ * COPYING for details. * */ - + #ifndef LOGREADER_H_INCLUDED #define LOGREADER_H_INCLUDED @@ -33,9 +33,6 @@ /* flags */ #define LR_KERNEL 0x0002 #define LR_EMPTY_LINES 0x0004 -#define LR_IGNORE_TIMEOUT 0x0008 -#define LR_SYSLOG_PROTOCOL 0x0010 -#define LR_PREEMPT 0x0020 #define LR_THREADED 0x0040 /* options */ @@ -54,7 +51,7 @@ typedef struct _LogReader LogReader; -void log_reader_set_options(LogReader *s, LogPipe *control, LogReaderOptions *options, gint stats_level, gint stats_source, const gchar *stats_id, const gchar *stats_instance); +void log_reader_set_options(LogReader *s, LogPipe *control, LogReaderOptions *options, const gchar *stats_id, const gchar *stats_instance); void log_reader_set_follow_filename(LogReader *self, const gchar *follow_filename); void log_reader_set_peer_addr(LogReader *s, GSockAddr *peer_addr); void log_reader_set_immediate_check(LogReader *s); diff -Nru syslog-ng-3.11.1/lib/logsource.c syslog-ng-3.13.2/lib/logsource.c --- syslog-ng-3.11.1/lib/logsource.c 2017-07-31 09:05:32.000000000 +0000 +++ syslog-ng-3.13.2/lib/logsource.c 2017-12-06 06:39:39.000000000 +0000 @@ -213,10 +213,10 @@ stats_lock(); StatsClusterKey sc_key; - stats_cluster_logpipe_key_set(&sc_key, self->stats_source | SCS_SOURCE, self->stats_id, self->stats_instance ); - stats_register_counter(self->stats_level, &sc_key, + stats_cluster_logpipe_key_set(&sc_key, self->options->stats_source | SCS_SOURCE, self->stats_id, self->stats_instance); + stats_register_counter(self->options->stats_level, &sc_key, SC_TYPE_PROCESSED, &self->recvd_messages); - stats_register_counter(self->stats_level, &sc_key, SC_TYPE_STAMP, &self->last_message_seen); + stats_register_counter(self->options->stats_level, &sc_key, SC_TYPE_STAMP, &self->last_message_seen); stats_unlock(); return TRUE; } @@ -228,7 +228,7 @@ stats_lock(); StatsClusterKey sc_key; - stats_cluster_logpipe_key_set(&sc_key, self->stats_source | SCS_SOURCE, self->stats_id, self->stats_instance ); + stats_cluster_logpipe_key_set(&sc_key, self->options->stats_source | SCS_SOURCE, self->stats_id, self->stats_instance); stats_unregister_counter(&sc_key, SC_TYPE_PROCESSED, &self->recvd_messages); stats_unregister_counter(&sc_key, SC_TYPE_STAMP, &self->last_message_seen); stats_unlock(); @@ -387,8 +387,9 @@ } void -log_source_set_options(LogSource *self, LogSourceOptions *options, gint stats_level, gint stats_source, - const gchar *stats_id, const gchar *stats_instance, gboolean threaded, gboolean pos_tracked, LogExprNode *expr_node) +log_source_set_options(LogSource *self, LogSourceOptions *options, + const gchar *stats_id, const gchar *stats_instance, + gboolean threaded, gboolean pos_tracked, LogExprNode *expr_node) { /* NOTE: we don't adjust window_size even in case it was changed in the * configuration and we received a SIGHUP. This means that opened @@ -397,8 +398,6 @@ if (g_atomic_counter_get(&self->window_size) == -1) g_atomic_counter_set(&self->window_size, options->init_window_size); self->options = options; - self->stats_level = stats_level; - self->stats_source = stats_source; if (self->stats_id) g_free(self->stats_id); self->stats_id = stats_id ? g_strdup(stats_id) : NULL; @@ -445,6 +444,7 @@ options->program_override_len = -1; options->host_override_len = -1; options->tags = NULL; + options->read_old_records = TRUE; host_resolve_options_defaults(&options->host_resolve_options); } diff -Nru syslog-ng-3.11.1/lib/logsource.h syslog-ng-3.13.2/lib/logsource.h --- syslog-ng-3.11.1/lib/logsource.h 2017-07-31 09:05:32.000000000 +0000 +++ syslog-ng-3.13.2/lib/logsource.h 2017-12-06 06:39:39.000000000 +0000 @@ -41,8 +41,11 @@ gchar *host_override; gint host_override_len; LogTagId source_group_tag; + gboolean read_old_records; GArray *tags; GList *source_queue_callbacks; + gint stats_level; + gint stats_source; } LogSourceOptions; typedef struct _LogSource LogSource; @@ -59,8 +62,6 @@ { LogPipe super; LogSourceOptions *options; - guint16 stats_level; - guint16 stats_source; gboolean threaded; gboolean pos_tracked; gchar *stats_id; @@ -95,7 +96,7 @@ void log_source_post(LogSource *self, LogMessage *msg); -void log_source_set_options(LogSource *self, LogSourceOptions *options, gint stats_level, gint stats_source, const gchar *stats_id, const gchar *stats_instance, gboolean threaded, gboolean pos_tracked, LogExprNode *expr_node); +void log_source_set_options(LogSource *self, LogSourceOptions *options, const gchar *stats_id, const gchar *stats_instance, gboolean threaded, gboolean pos_tracked, LogExprNode *expr_node); void log_source_mangle_hostname(LogSource *self, LogMessage *msg); void log_source_init_instance(LogSource *self, GlobalConfig *cfg); void log_source_options_defaults(LogSourceOptions *options); diff -Nru syslog-ng-3.11.1/lib/logstamp.h syslog-ng-3.13.2/lib/logstamp.h --- syslog-ng-3.11.1/lib/logstamp.h 2017-07-31 09:05:32.000000000 +0000 +++ syslog-ng-3.13.2/lib/logstamp.h 2017-12-06 06:39:39.000000000 +0000 @@ -42,6 +42,12 @@ gint32 zone_offset; } LogStamp; +static inline gboolean +log_stamp_is_timezone_set(const LogStamp *self) +{ + return self->zone_offset != -1; +} + void log_stamp_format(LogStamp *stamp, GString *target, gint ts_format, glong zone_offset, gint frac_digits); void log_stamp_append_format(const LogStamp *stamp, GString *target, gint ts_format, glong zone_offset, gint frac_digits); gboolean log_stamp_eq(const LogStamp *a, const LogStamp *b); diff -Nru syslog-ng-3.11.1/lib/logwriter.c syslog-ng-3.13.2/lib/logwriter.c --- syslog-ng-3.11.1/lib/logwriter.c 2017-07-31 09:05:32.000000000 +0000 +++ syslog-ng-3.13.2/lib/logwriter.c 2017-12-06 06:39:39.000000000 +0000 @@ -75,8 +75,6 @@ guint32 last_msg_count; GString *line_buffer; - gint stats_level; - guint16 stats_source; gchar *stats_id; gchar *stats_instance; @@ -1006,9 +1004,9 @@ g_string_append_len(result, p, len); g_string_append_c(result, ' '); - if ((lm->flags & LF_LEGACY_MSGHDR)) + p = log_msg_get_value(lm, LM_V_LEGACY_MSGHDR, &len); + if (len > 0) { - p = log_msg_get_value(lm, LM_V_LEGACY_MSGHDR, &len); g_string_append_len(result, p, len); } else @@ -1274,14 +1272,15 @@ stats_lock(); { StatsClusterKey sc_key; - stats_cluster_logpipe_key_set(&sc_key, self->stats_source | SCS_DESTINATION, self->stats_id, self->stats_instance ); + stats_cluster_logpipe_key_set(&sc_key, self->options->stats_source | SCS_DESTINATION, self->stats_id, + self->stats_instance); if (self->options->suppress > 0) - stats_register_counter(self->stats_level, &sc_key, SC_TYPE_SUPPRESSED, &self->suppressed_messages); - stats_register_counter(self->stats_level, &sc_key, SC_TYPE_DROPPED, &self->dropped_messages); - stats_register_counter(self->stats_level, &sc_key, SC_TYPE_PROCESSED, &self->processed_messages); - stats_register_counter(self->stats_level, &sc_key, SC_TYPE_QUEUED, &self->queued_messages); - stats_register_counter(self->stats_level, &sc_key, SC_TYPE_WRITTEN, &self->written_messages); + stats_register_counter(self->options->stats_level, &sc_key, SC_TYPE_SUPPRESSED, &self->suppressed_messages); + stats_register_counter(self->options->stats_level, &sc_key, SC_TYPE_DROPPED, &self->dropped_messages); + stats_register_counter(self->options->stats_level, &sc_key, SC_TYPE_PROCESSED, &self->processed_messages); + stats_register_counter(self->options->stats_level, &sc_key, SC_TYPE_QUEUED, &self->queued_messages); + stats_register_counter(self->options->stats_level, &sc_key, SC_TYPE_WRITTEN, &self->written_messages); stats_register_counter_and_index(STATS_LEVEL1, &sc_key, SC_TYPE_MEMORY_USAGE, &self->memory_usage); } @@ -1347,7 +1346,8 @@ stats_lock(); { StatsClusterKey sc_key; - stats_cluster_logpipe_key_set(&sc_key, self->stats_source | SCS_DESTINATION, self->stats_id, self->stats_instance ); + stats_cluster_logpipe_key_set(&sc_key, self->options->stats_source | SCS_DESTINATION, self->stats_id, + self->stats_instance); stats_unregister_counter(&sc_key, SC_TYPE_DROPPED, &self->dropped_messages); stats_unregister_counter(&sc_key, SC_TYPE_SUPPRESSED, &self->suppressed_messages); @@ -1546,14 +1546,12 @@ } void -log_writer_set_options(LogWriter *self, LogPipe *control, LogWriterOptions *options, gint stats_level, - gint stats_source, const gchar *stats_id, const gchar *stats_instance) +log_writer_set_options(LogWriter *self, LogPipe *control, LogWriterOptions *options, + const gchar *stats_id, const gchar *stats_instance) { self->control = control; self->options = options; - self->stats_level = stats_level; - self->stats_source = stats_source; if (control) self->super.expr_node = control->expr_node; diff -Nru syslog-ng-3.11.1/lib/logwriter.h syslog-ng-3.13.2/lib/logwriter.h --- syslog-ng-3.11.1/lib/logwriter.h 2017-07-31 09:05:32.000000000 +0000 +++ syslog-ng-3.13.2/lib/logwriter.h 2017-12-06 06:39:39.000000000 +0000 @@ -72,13 +72,15 @@ gint padding; gint mark_mode; gint mark_freq; + gint stats_level; + gint stats_source; } LogWriterOptions; typedef struct _LogWriter LogWriter; void log_writer_set_flags(LogWriter *self, guint32 flags); guint32 log_writer_get_flags(LogWriter *self); -void log_writer_set_options(LogWriter *self, LogPipe *control, LogWriterOptions *options, gint stats_level, gint stats_source, const gchar *stats_id, const gchar *stats_instance); +void log_writer_set_options(LogWriter *self, LogPipe *control, LogWriterOptions *options, const gchar *stats_id, const gchar *stats_instance); void log_writer_format_log(LogWriter *self, LogMessage *lm, GString *result); gboolean log_writer_has_pending_writes(LogWriter *self); gboolean log_writer_opened(LogWriter *self); diff -Nru syslog-ng-3.11.1/lib/mainloop.c syslog-ng-3.13.2/lib/mainloop.c --- syslog-ng-3.11.1/lib/mainloop.c 2017-07-31 09:05:32.000000000 +0000 +++ syslog-ng-3.13.2/lib/mainloop.c 2017-12-06 06:39:39.000000000 +0000 @@ -89,6 +89,8 @@ */ ThreadId main_thread_handle; +GCond thread_halt_cond; +GMutex workers_running_lock = G_STATIC_MUTEX_INIT; struct _MainLoop { @@ -130,6 +132,7 @@ struct iv_signal sigterm_poll; struct iv_signal sigint_poll; struct iv_signal sigchild_poll; + struct iv_signal sigusr1_poll; struct iv_event exit_requested; struct iv_event reload_config_requested; @@ -297,6 +300,25 @@ main_loop_worker_sync_call(main_loop_reload_config_apply, self); } +static void +block_till_workers_exit() +{ + gint64 end_time; + end_time = g_get_monotonic_time() + 15*G_TIME_SPAN_SECOND; + + g_mutex_lock(&workers_running_lock); + while (main_loop_workers_running) + if (!g_cond_wait_until(&thread_halt_cond, &workers_running_lock, end_time)) + { + /* timeout has passed. */ + fprintf(stderr, "Main thread timed out (15s) while waiting workers threads to exit. " + "workers_running: %d. Continuing ...\n", main_loop_workers_running); + break; + } + + g_mutex_unlock (&workers_running_lock); +} + /************************************************************************************ * syncronized exit ************************************************************************************/ @@ -382,6 +404,12 @@ } static void +sig_usr1_handler(gpointer user_data) +{ + app_reopen(); +} + +static void _ignore_signal(gint signum) { struct sigaction sa; @@ -410,6 +438,7 @@ _register_signal_handler(&self->sigchild_poll, SIGCHLD, sig_child_handler, self); _register_signal_handler(&self->sigterm_poll, SIGTERM, sig_term_handler, self); _register_signal_handler(&self->sigint_poll, SIGINT, sig_term_handler, self); + _register_signal_handler(&self->sigusr1_poll, SIGUSR1, sig_usr1_handler, self); } /************************************************************************************ @@ -511,6 +540,7 @@ main_loop_call_deinit(); main_loop_io_worker_deinit(); main_loop_worker_deinit(); + block_till_workers_exit(); scratch_buffers_automatic_gc_deinit(); } @@ -525,7 +555,7 @@ service_management_clear_status(); if (self->options->interactive_mode) { - plugin_load_module("python", self->current_configuration, NULL); + cfg_load_module(self->current_configuration, "python"); debugger_start(self, self->current_configuration); } iv_main(); diff -Nru syslog-ng-3.11.1/lib/mainloop.h syslog-ng-3.13.2/lib/mainloop.h --- syslog-ng-3.11.1/lib/mainloop.h 2017-07-31 09:05:32.000000000 +0000 +++ syslog-ng-3.13.2/lib/mainloop.h 2017-12-06 06:39:39.000000000 +0000 @@ -27,6 +27,8 @@ #include "syslog-ng.h" #include "thread-utils.h" +volatile gint main_loop_workers_running; + typedef struct _MainLoop MainLoop; typedef struct _MainLoopOptions @@ -38,6 +40,8 @@ } MainLoopOptions; extern ThreadId main_thread_handle; +extern GCond thread_halt_cond; +extern GMutex workers_running_lock; typedef gpointer (*MainLoopTaskFunc)(gpointer user_data); diff -Nru syslog-ng-3.11.1/lib/mainloop-worker.c syslog-ng-3.13.2/lib/mainloop-worker.c --- syslog-ng-3.11.1/lib/mainloop-worker.c 2017-07-31 09:05:32.000000000 +0000 +++ syslog-ng-3.13.2/lib/mainloop-worker.c 2017-12-06 06:39:39.000000000 +0000 @@ -58,7 +58,7 @@ volatile gboolean is_reloading_scheduled; /* number of I/O worker jobs running */ -static gint main_loop_workers_running; +static gint main_loop_jobs_running; static struct iv_task main_loop_workers_reenable_jobs_task; @@ -176,6 +176,11 @@ _allocate_thread_id(); INIT_IV_LIST_HEAD(&batch_callbacks); + + g_mutex_lock(&workers_running_lock); + main_loop_workers_running++; + g_mutex_unlock(&workers_running_lock); + app_thread_start(); } @@ -185,6 +190,12 @@ { app_thread_stop(); _release_thread_id(); + + g_mutex_lock(&workers_running_lock); + main_loop_workers_running--; + g_mutex_unlock(&workers_running_lock); + + g_cond_signal(&thread_halt_cond); } void @@ -202,7 +213,7 @@ { main_loop_assert_main_thread(); - main_loop_workers_running++; + main_loop_jobs_running++; } typedef struct @@ -231,7 +242,7 @@ } static void -_invoke_sync_call_actions() +_invoke_sync_call_actions(void) { g_queue_foreach(&sync_call_actions, (GFunc)_consume_action, NULL); g_queue_clear(&sync_call_actions); @@ -250,8 +261,8 @@ { main_loop_assert_main_thread(); - main_loop_workers_running--; - if (main_loop_workers_quit && main_loop_workers_running == 0) + main_loop_jobs_running--; + if (main_loop_workers_quit && main_loop_jobs_running == 0) { /* NOTE: we can't reenable I/O jobs by setting * main_loop_io_workers_quit to FALSE right here, because a task @@ -378,7 +389,7 @@ _register_sync_call_action(&sync_call_actions, func, user_data); - if (main_loop_workers_running == 0) + if (main_loop_jobs_running == 0) { _invoke_sync_call_actions(); _reenable_worker_jobs(NULL); diff -Nru syslog-ng-3.11.1/lib/Makefile.am syslog-ng-3.13.2/lib/Makefile.am --- syslog-ng-3.11.1/lib/Makefile.am 2017-07-31 09:05:32.000000000 +0000 +++ syslog-ng-3.13.2/lib/Makefile.am 2017-12-06 06:39:39.000000000 +0000 @@ -56,6 +56,9 @@ CLEAN_SUBDIRS += @IVYKIS_SUBDIRS@ +EXTRA_DIST += \ + lib/ivykis/configure.gnu + install-ivykis: ${MAKE} -C lib/ivykis/src \ install-includeHEADERS \ @@ -94,6 +97,8 @@ lib/cfg-lexer.h \ lib/cfg-lexer-subst.h \ lib/cfg-args.h \ + lib/cfg-block.h \ + lib/cfg-block-generator.h \ lib/cfg-parser.h \ lib/cfg-tree.h \ lib/children.h \ @@ -175,6 +180,8 @@ lib/cache.c \ lib/cfg.c \ lib/cfg-args.c \ + lib/cfg-block.c \ + lib/cfg-block-generator.c \ lib/cfg-lexer.c \ lib/cfg-lexer-subst.c \ lib/cfg-parser.c \ @@ -278,8 +285,7 @@ lib/block-ref-grammar.ym \ lib/pragma-grammar.ym \ lib/merge-grammar.py \ - lib/hostname-unix.c \ - lib/ivykis/configure.gnu + lib/hostname-unix.c lib/plugin-types.h: lib/cfg-grammar.h diff -Nru syslog-ng-3.11.1/lib/memtrace.c syslog-ng-3.13.2/lib/memtrace.c --- syslog-ng-3.11.1/lib/memtrace.c 2017-07-31 09:05:32.000000000 +0000 +++ syslog-ng-3.13.2/lib/memtrace.c 2017-12-06 06:39:39.000000000 +0000 @@ -209,7 +209,7 @@ static gpointer z_mem_trace_check_canaries(gpointer ptr); void -z_mem_trace_dump() +z_mem_trace_dump(void) { int i; @@ -613,7 +613,7 @@ } void -z_mem_trace_dump() +z_mem_trace_dump(void) { } diff -Nru syslog-ng-3.11.1/lib/messages.c syslog-ng-3.13.2/lib/messages.c --- syslog-ng-3.11.1/lib/messages.c 2017-07-31 09:05:32.000000000 +0000 +++ syslog-ng-3.13.2/lib/messages.c 2017-12-06 06:39:39.000000000 +0000 @@ -261,6 +261,9 @@ log_msg_unref(msg); } +static guint g_log_handler_id; +static guint glib_handler_id; + void msg_init(gboolean interactive) { @@ -269,8 +272,8 @@ if (!interactive) { - g_log_set_handler(G_LOG_DOMAIN, 0xff, msg_log_func, NULL); - g_log_set_handler("GLib", 0xff, msg_log_func, NULL); + g_log_handler_id = g_log_set_handler(G_LOG_DOMAIN, 0xff, msg_log_func, NULL); + glib_handler_id = g_log_set_handler("GLib", 0xff, msg_log_func, NULL); } else { @@ -285,7 +288,19 @@ msg_deinit(void) { evt_ctx_free(evt_context); + evt_context = NULL; log_stderr = TRUE; + + if (g_log_handler_id) + { + g_log_remove_handler(G_LOG_DOMAIN, g_log_handler_id); + g_log_handler_id = 0; + } + if (glib_handler_id) + { + g_log_remove_handler("GLib", glib_handler_id); + glib_handler_id = 0; + } } static GOptionEntry msg_option_entries[] = diff -Nru syslog-ng-3.11.1/lib/msg-format.c syslog-ng-3.13.2/lib/msg-format.c --- syslog-ng-3.11.1/lib/msg-format.c 2017-07-31 09:05:32.000000000 +0000 +++ syslog-ng-3.13.2/lib/msg-format.c 2017-12-06 06:39:39.000000000 +0000 @@ -78,9 +78,9 @@ if (!options->format) options->format = g_strdup("syslog"); - p = plugin_find(cfg, LL_CONTEXT_FORMAT, options->format); + p = cfg_find_plugin(cfg, LL_CONTEXT_FORMAT, options->format); if (p) - options->format_handler = plugin_construct(p, cfg, LL_CONTEXT_FORMAT, options->format); + options->format_handler = plugin_construct(p); options->initialized = TRUE; } @@ -127,6 +127,7 @@ { "sanitize-utf8", CFH_SET, offsetof(MsgFormatOptions, flags), LP_SANITIZE_UTF8 }, { "no-multi-line", CFH_SET, offsetof(MsgFormatOptions, flags), LP_NO_MULTI_LINE }, { "store-legacy-msghdr", CFH_SET, offsetof(MsgFormatOptions, flags), LP_STORE_LEGACY_MSGHDR }, + { "store-raw-message", CFH_SET, offsetof(MsgFormatOptions, flags), LP_STORE_RAW_MESSAGE }, { "dont-store-legacy-msghdr", CFH_CLEAR, offsetof(MsgFormatOptions, flags), LP_STORE_LEGACY_MSGHDR }, { "expect-hostname", CFH_SET, offsetof(MsgFormatOptions, flags), LP_EXPECT_HOSTNAME }, { "no-hostname", CFH_CLEAR, offsetof(MsgFormatOptions, flags), LP_EXPECT_HOSTNAME }, diff -Nru syslog-ng-3.11.1/lib/msg-format.h syslog-ng-3.13.2/lib/msg-format.h --- syslog-ng-3.11.1/lib/msg-format.h 2017-07-31 09:05:32.000000000 +0000 +++ syslog-ng-3.13.2/lib/msg-format.h 2017-12-06 06:39:39.000000000 +0000 @@ -55,6 +55,7 @@ LP_LOCAL = 0x0200, /* for the date part of a message, only skip it, don't fully parse - recommended for keep_timestamp(no) */ LP_NO_PARSE_DATE = 0x0400, + LP_STORE_RAW_MESSAGE = 0x0800, }; typedef struct _MsgFormatHandler MsgFormatHandler; diff -Nru syslog-ng-3.11.1/lib/parse-number.c syslog-ng-3.13.2/lib/parse-number.c --- syslog-ng-3.11.1/lib/parse-number.c 2017-07-31 09:05:32.000000000 +0000 +++ syslog-ng-3.13.2/lib/parse-number.c 2017-12-06 06:39:39.000000000 +0000 @@ -149,7 +149,7 @@ gint64 val; errno = 0; - val = strtoll(s, endptr, 10); + val = strtoll(s, endptr, 0); if (errno == ERANGE || errno == EINVAL) return FALSE; diff -Nru syslog-ng-3.11.1/lib/parser/parser-expr.c syslog-ng-3.13.2/lib/parser/parser-expr.c --- syslog-ng-3.11.1/lib/parser/parser-expr.c 2017-07-31 09:05:32.000000000 +0000 +++ syslog-ng-3.13.2/lib/parser/parser-expr.c 2017-12-06 06:39:39.000000000 +0000 @@ -139,6 +139,7 @@ { log_pipe_init_instance(&self->super, cfg); self->super.init = log_parser_init_method; + self->super.deinit = log_parser_deinit_method; self->super.free_fn = log_parser_free_method; self->super.queue = log_parser_queue; } diff -Nru syslog-ng-3.11.1/lib/parser/parser-expr-grammar.ym syslog-ng-3.13.2/lib/parser/parser-expr-grammar.ym --- syslog-ng-3.11.1/lib/parser/parser-expr-grammar.ym 2017-07-31 09:05:32.000000000 +0000 +++ syslog-ng-3.13.2/lib/parser/parser-expr-grammar.ym 2017-12-06 06:39:39.000000000 +0000 @@ -68,10 +68,10 @@ Plugin *p; gint context = LL_CONTEXT_PARSER; - p = plugin_find(configuration, context, $1); + p = cfg_find_plugin(configuration, context, $1); CHECK_ERROR(p, @1, "%s plugin %s not found", cfg_lexer_lookup_context_name_by_type(context), $1); - last_parser = (LogParser *) plugin_parse_config(p, configuration, &@1, NULL); + last_parser = (LogParser *) cfg_parse_plugin(configuration, p, &@1, NULL); free($1); if (!last_parser) { diff -Nru syslog-ng-3.11.1/lib/parser/parser-expr.h syslog-ng-3.13.2/lib/parser/parser-expr.h --- syslog-ng-3.11.1/lib/parser/parser-expr.h 2017-07-31 09:05:32.000000000 +0000 +++ syslog-ng-3.13.2/lib/parser/parser-expr.h 2017-12-06 06:39:39.000000000 +0000 @@ -42,8 +42,17 @@ gchar *name; }; -void log_parser_set_template(LogParser *self, LogTemplate *template); +static inline gboolean +log_parser_deinit_method(LogPipe *s) +{ + /* NOTE: placeholder for the future and to pair up with + * log_parser_init_method(). There's no log_pipe_deinit_method() to call + */ + return TRUE; +} + gboolean log_parser_init_method(LogPipe *s); +void log_parser_set_template(LogParser *self, LogTemplate *template); void log_parser_init_instance(LogParser *self, GlobalConfig *cfg); void log_parser_free_method(LogPipe *self); diff -Nru syslog-ng-3.11.1/lib/parser/parser-expr-parser.h syslog-ng-3.13.2/lib/parser/parser-expr-parser.h --- syslog-ng-3.11.1/lib/parser/parser-expr-parser.h 2017-07-31 09:05:32.000000000 +0000 +++ syslog-ng-3.13.2/lib/parser/parser-expr-parser.h 2017-12-06 06:39:39.000000000 +0000 @@ -26,9 +26,7 @@ #define PARSER_EXPR_PARSER_H_INCLUDED #include "cfg-parser.h" -#include "cfg-lexer.h" #include "parser/parser-expr.h" -#include "cfg-tree.h" extern CfgParser parser_expr_parser; diff -Nru syslog-ng-3.11.1/lib/plugin.c syslog-ng-3.13.2/lib/plugin.c --- syslog-ng-3.11.1/lib/plugin.c 2017-07-31 09:05:32.000000000 +0000 +++ syslog-ng-3.13.2/lib/plugin.c 2017-12-06 06:39:39.000000000 +0000 @@ -23,27 +23,22 @@ */ #include "plugin.h" -#include "driver.h" -#include "messages.h" -#include "cfg-lexer.h" #include "plugin-types.h" +#include "messages.h" #include "pathutils.h" #include "resolved-configurable-paths.h" -#include +#include #include +#include +#include +#include #ifdef _AIX #define G_MODULE_SUFFIX "a" #endif static void -plugin_candidate_set_preference(PluginCandidate *self, gint preference) -{ - self->preference = preference; -} - -static void plugin_candidate_set_module_name(PluginCandidate *self, const gchar *module_name) { g_free(self->module_name); @@ -52,14 +47,13 @@ PluginCandidate * -plugin_candidate_new(gint plugin_type, const gchar *name, const gchar *module_name, gint preference) +plugin_candidate_new(gint plugin_type, const gchar *name, const gchar *module_name) { PluginCandidate *self = g_new0(PluginCandidate, 1); self->super.type = plugin_type; self->super.name = g_strdup(name); self->module_name = g_strdup(module_name); - self->preference = preference; self->super.failure_info.aux_data = NULL; return self; @@ -73,8 +67,63 @@ g_free(self); } +/* construct a plugin without having a configuration file to parse */ +gpointer +plugin_construct(Plugin *self) +{ + g_assert(self->parser == NULL); + if (self->construct) + { + return self->construct(self); + } + return NULL; +} + +static gboolean +_is_log_pipe(Plugin *self) +{ + switch (self->type) + { + case LL_CONTEXT_SOURCE: + case LL_CONTEXT_DESTINATION: + case LL_CONTEXT_PARSER: + case LL_CONTEXT_FILTER: + case LL_CONTEXT_REWRITE: + return TRUE; + default: + return FALSE; + } +} + +gpointer +plugin_construct_from_config(Plugin *self, CfgLexer *lexer, gpointer arg) +{ + gpointer instance = NULL; + + g_assert(self->construct == NULL); + if (!cfg_parser_parse(self->parser, lexer, &instance, arg)) + { + cfg_parser_cleanup(self->parser, instance); + return NULL; + } + + if (_is_log_pipe(self)) + { + LogPipe *p = (LogPipe *)instance; + p->plugin_name = g_strdup(self->name); + if (self->failure_info.aux_data != NULL) + p->init = self->failure_info.aux_data; + } + + return instance; +} + +/***************************************************************************** + * Implementation of PluginContext + *****************************************************************************/ + static Plugin * -plugin_find_in_list(GlobalConfig *cfg, GList *head, gint plugin_type, const gchar *plugin_name) +plugin_find_in_list(GList *head, gint plugin_type, const gchar *plugin_name) { GList *p; Plugin *plugin; @@ -106,45 +155,48 @@ } void -plugin_register(GlobalConfig *cfg, Plugin *p, gint number) +plugin_register(PluginContext *context, Plugin *p, gint number) { gint i; for (i = 0; i < number; i++) { - if (plugin_find_in_list(cfg, cfg->plugins, p[i].type, p[i].name)) + Plugin *existing_plugin; + + existing_plugin = plugin_find_in_list(context->plugins, p[i].type, p[i].name); + if (existing_plugin) { - msg_debug("Attempted to register the same plugin multiple times, ignoring", + msg_debug("Attempted to register the same plugin multiple times, dropping the old one", evt_tag_str("context", cfg_lexer_lookup_context_name_by_type(p[i].type)), evt_tag_str("name", p[i].name)); - continue; + context->plugins = g_list_remove(context->plugins, existing_plugin); } - cfg->plugins = g_list_prepend(cfg->plugins, &p[i]); + context->plugins = g_list_prepend(context->plugins, &p[i]); } } Plugin * -plugin_find(GlobalConfig *cfg, gint plugin_type, const gchar *plugin_name) +plugin_find(PluginContext *context, gint plugin_type, const gchar *plugin_name) { Plugin *p; PluginCandidate *candidate; /* try registered plugins first */ - p = plugin_find_in_list(cfg, cfg->plugins, plugin_type, plugin_name); + p = plugin_find_in_list(context->plugins, plugin_type, plugin_name); if (p) { return p; } - candidate = (PluginCandidate *) plugin_find_in_list(cfg, cfg->candidate_plugins, plugin_type, plugin_name); + candidate = (PluginCandidate *) plugin_find_in_list(context->candidate_plugins, plugin_type, plugin_name); if (!candidate) return NULL; /* try to autoload the module */ - plugin_load_module(candidate->module_name, cfg, NULL); + plugin_load_module(context, candidate->module_name, NULL); /* by this time it should've registered */ - p = plugin_find_in_list(cfg, cfg->plugins, plugin_type, plugin_name); + p = plugin_find_in_list(context->plugins, plugin_type, plugin_name); if (p) { p->failure_info.aux_data = candidate->super.failure_info.aux_data; @@ -160,84 +212,6 @@ return NULL; } -/* construct a plugin without having a configuration file to parse */ -gpointer -plugin_construct(Plugin *self, GlobalConfig *cfg, gint plugin_type, const gchar *plugin_name) -{ - g_assert(self->parser == NULL); - if (self->construct) - { - return self->construct(self, cfg, plugin_type, plugin_name); - } - return NULL; -} - -static gboolean -_is_log_pipe(Plugin *self) -{ - switch (self->type) - { - case LL_CONTEXT_SOURCE: - case LL_CONTEXT_DESTINATION: - case LL_CONTEXT_PARSER: - case LL_CONTEXT_FILTER: - case LL_CONTEXT_REWRITE: - return TRUE; - default: - return FALSE; - } -} - -/* construct a plugin instance by parsing a configuration file */ -gpointer -plugin_parse_config(Plugin *self, GlobalConfig *cfg, YYLTYPE *yylloc, gpointer arg) -{ - gpointer instance = NULL; - - g_assert(self->construct == NULL); - - /* make sure '_' and '-' are handled equally in plugin name */ - if (!self->setup_context) - { - CfgTokenBlock *block; - YYSTYPE token; - - block = cfg_token_block_new(); - - memset(&token, 0, sizeof(token)); - token.type = LL_TOKEN; - token.token = self->type; - cfg_token_block_add_and_consume_token(block, &token); - cfg_lexer_push_context(cfg->lexer, self->parser->context, self->parser->keywords, self->parser->name); - cfg_lexer_lookup_keyword(cfg->lexer, &token, yylloc, self->name); - cfg_lexer_pop_context(cfg->lexer); - cfg_token_block_add_and_consume_token(block, &token); - - cfg_lexer_inject_token_block(cfg->lexer, block); - } - else - { - (self->setup_context)(self, cfg, self->type, self->name); - } - - if (!cfg_parser_parse(self->parser, cfg->lexer, &instance, arg)) - { - cfg_parser_cleanup(self->parser, instance); - instance = NULL; - return NULL; - } - - if (_is_log_pipe(self)) - { - LogPipe *p = (LogPipe *)instance; - p->plugin_name = g_strdup(self->name); - if (self->failure_info.aux_data != NULL) - p->init = self->failure_info.aux_data; - } - - return instance; -} - static ModuleInfo * plugin_get_module_info(GModule *mod) { @@ -264,7 +238,43 @@ } static GModule * -plugin_dlopen_module(const gchar *module_name, const gchar *module_path) +plugin_dlopen_module_as_filename(const gchar *module_file_name, const gchar *module_name) +{ + GModule *mod = NULL; + + msg_trace("Trying to open module", + evt_tag_str("module", module_name), + evt_tag_str("filename", module_file_name), + NULL); + + mod = g_module_open(module_file_name, G_MODULE_BIND_LAZY); + if (!mod) + { + msg_error("Error opening plugin module", + evt_tag_str("module", module_name), + evt_tag_str("error", g_module_error()), + NULL); + return NULL; + } + return mod; +} + +static GModule * +plugin_dlopen_module_as_dir_and_filename(const gchar *module_dir_name, const gchar *module_file_name, + const gchar *module_name) +{ + gchar *path; + GModule *mod; + + path = g_build_path(G_DIR_SEPARATOR_S, module_dir_name, module_file_name, NULL); + mod = plugin_dlopen_module_as_filename(path, module_name); + g_free(path); + return mod; +} + + +static GModule * +plugin_dlopen_module_on_path(const gchar *module_name, const gchar *module_path) { gchar *plugin_module_name = NULL; gchar **module_path_dirs, *p, *dot; @@ -318,30 +328,19 @@ evt_tag_str("module", module_name)); return NULL; } - msg_trace("Trying to open module", - evt_tag_str("module", module_name), - evt_tag_str("filename", plugin_module_name)); - mod = g_module_open(plugin_module_name, G_MODULE_BIND_LAZY); + mod = plugin_dlopen_module_as_filename(plugin_module_name, module_name); g_free(plugin_module_name); - if (!mod) - { - msg_debug("Error opening plugin module", - evt_tag_str("module", module_name), - evt_tag_str("error", g_module_error())); - return NULL; - } return mod; } gboolean -plugin_load_module(const gchar *module_name, GlobalConfig *cfg, CfgArgs *args) +plugin_load_module(PluginContext *context, const gchar *module_name, CfgArgs *args) { GModule *mod; static GModule *main_module_handle; - gboolean (*init_func)(GlobalConfig *cfg, CfgArgs *args); + gboolean (*init_func)(PluginContext *context, CfgArgs *args); gchar *module_init_func; - const gchar *mp; gboolean result; ModuleInfo *module_info; @@ -357,15 +356,7 @@ } /* try to load it from external .so */ - if (cfg->lexer) - mp = cfg_args_get(cfg->lexer->globals, "module-path"); - else - mp = NULL; - - if (!mp) - mp = resolvedConfigurablePaths.initial_module_path; - - mod = plugin_dlopen_module(module_name, mp); + mod = plugin_dlopen_module_on_path(module_name, context->module_path); if (!mod) { g_free(module_init_func); @@ -392,7 +383,7 @@ call_init: g_free(module_init_func); - result = (*init_func)(cfg, args); + result = (*init_func)(context, args); if (result) msg_verbose("Module loaded and initialized successfully", evt_tag_str("module", module_name)); @@ -402,21 +393,37 @@ return result; } -void -plugin_load_candidate_modules(GlobalConfig *cfg) +/************************************************************ + * Candidate modules + ************************************************************/ + +static void +_free_candidate_plugin_list(GList *candidate_plugins) +{ + g_list_foreach(candidate_plugins, (GFunc) plugin_candidate_free, NULL); + g_list_free(candidate_plugins); +} + +/* This functions runs in a separate process during startup, thus we don't + * really have a means to report errors, stderr may not be available. */ +static void +_enumerate_and_dump_plugin_info_in_modules(const gchar *module_path, int output_fd) { GModule *mod; gchar **mod_paths; gint i, j; + FILE *discovery; - mod_paths = g_strsplit(resolvedConfigurablePaths.initial_module_path ? : "", G_SEARCHPATH_SEPARATOR_S, 0); + discovery = fdopen(output_fd, "w"); + if (!discovery) + return; + + mod_paths = g_strsplit(module_path ? : "", G_SEARCHPATH_SEPARATOR_S, 0); for (i = 0; mod_paths[i]; i++) { GDir *dir; const gchar *fname; - msg_debug("Reading path for candidate modules", - evt_tag_str("path", mod_paths[i])); dir = g_dir_open(mod_paths[i], 0, NULL); if (!dir) continue; @@ -426,16 +433,13 @@ { gchar *module_name; ModuleInfo *module_info; + const gchar *so_basename = fname; if (g_str_has_prefix(fname, "lib")) - fname += 3; - module_name = g_strndup(fname, (gint) (strlen(fname) - strlen(G_MODULE_SUFFIX) - 1)); + so_basename = fname + 3; + module_name = g_strndup(so_basename, (gint) (strlen(so_basename) - strlen(G_MODULE_SUFFIX) - 1)); - msg_debug("Reading shared object for a candidate module", - evt_tag_str("path", mod_paths[i]), - evt_tag_str("fname", fname), - evt_tag_str("module", module_name)); - mod = plugin_dlopen_module(module_name, resolvedConfigurablePaths.initial_module_path); + mod = plugin_dlopen_module_as_dir_and_filename(mod_paths[i], fname, module_name); module_info = plugin_get_module_info(mod); if (module_info) @@ -443,28 +447,8 @@ for (j = 0; j < module_info->plugins_len; j++) { Plugin *plugin = &module_info->plugins[j]; - PluginCandidate *candidate_plugin; - - candidate_plugin = (PluginCandidate *) plugin_find_in_list(cfg, cfg->candidate_plugins, plugin->type, plugin->name); - msg_debug("Registering candidate plugin", - evt_tag_str("module", module_name), - evt_tag_str("context", cfg_lexer_lookup_context_name_by_type(plugin->type)), - evt_tag_str("name", plugin->name), - evt_tag_int("preference", module_info->preference)); - if (candidate_plugin) - { - if (candidate_plugin->preference < module_info->preference) - { - plugin_candidate_set_module_name(candidate_plugin, module_name); - plugin_candidate_set_preference(candidate_plugin, module_info->preference); - } - } - else - { - cfg->candidate_plugins = g_list_prepend(cfg->candidate_plugins, plugin_candidate_new(plugin->type, plugin->name, - module_name, module_info->preference)); - } + fprintf(discovery, "%s %d %s\n", module_name, plugin->type, plugin->name); } } g_free(module_name); @@ -477,16 +461,169 @@ g_dir_close(dir); } g_strfreev(mod_paths); + fclose(discovery); +} + +static GList * +_parse_and_load_plugin_info_in_modules(int input_fd) +{ + FILE *discovery; + GList *candidate_plugins = NULL; + gchar module_name[4096]; + gint plugin_type; + gchar plugin_name[256]; + + discovery = fdopen(input_fd, "r"); + if (!discovery) + { + msg_error("Error happened while opening plugin discovery output, fdopen() failed", + evt_tag_errno("error", errno)); + return NULL; + } + + while (fscanf(discovery, "%4095s %d %255s\n", + module_name, + &plugin_type, + plugin_name) == 3) + { + PluginCandidate *candidate_plugin; + + candidate_plugin = (PluginCandidate *) plugin_find_in_list(candidate_plugins, plugin_type, plugin_name); + + msg_debug("Registering candidate plugin", + evt_tag_str("module", module_name), + evt_tag_str("context", cfg_lexer_lookup_context_name_by_type(plugin_type)), + evt_tag_str("name", plugin_name)); + if (candidate_plugin) + { + msg_debug("Duplicate plugin candidate, overriding previous registration with the new one", + evt_tag_str("old-module", candidate_plugin->module_name), + evt_tag_str("new-module", module_name), + evt_tag_str("context", cfg_lexer_lookup_context_name_by_type(plugin_type)), + evt_tag_str("name", plugin_name)); + plugin_candidate_set_module_name(candidate_plugin, module_name); + } + else + { + candidate_plugins = g_list_prepend(candidate_plugins, + plugin_candidate_new(plugin_type, plugin_name, module_name)); + } + + } + + if (!feof(discovery)) + { + msg_error("Error parsing the output of the discovery process, " + "not all lines were consumed, this is an internal error."); + } + + fclose(discovery); + return candidate_plugins; +} + +GList * +plugin_discover_candidate_modules(const gchar *module_path) +{ + pid_t discover_pid; + int discover_pipe[2]; + + if (pipe(discover_pipe) < 0) + { + msg_error("Error creating pipe for discover process", + evt_tag_errno("error", errno)); + return NULL; + } + + if ((discover_pid = fork()) < 0) + { + msg_error("Error creating discover process, fork() failed", + evt_tag_errno("error", errno)); + return NULL; + } + + if (discover_pid == 0) + { + close(discover_pipe[0]); + _enumerate_and_dump_plugin_info_in_modules(module_path, dup(discover_pipe[1])); + close(discover_pipe[1]); + _exit(0); + } + else + { + int exit_code; + GList *candidate_modules; + + close(discover_pipe[1]); + candidate_modules = _parse_and_load_plugin_info_in_modules(dup(discover_pipe[0])); + close(discover_pipe[0]); + if (waitpid(discover_pid, &exit_code, 0) < 0) + { + msg_error("Error waiting for discover process, waitpid() failed", + evt_tag_errno("error", errno)); + _free_candidate_plugin_list(candidate_modules); + return NULL; + } + if (exit_code != 0) + { + msg_error("Error in discover process, exit code is not zero", + evt_tag_int("exit_code", WEXITSTATUS(exit_code)), + evt_tag_int("status", exit_code)); + _free_candidate_plugin_list(candidate_modules); + return NULL; + } + return candidate_modules; + } } void -plugin_free_candidate_modules(GlobalConfig *cfg) +plugin_load_candidate_modules(PluginContext *context) { - g_list_foreach(cfg->candidate_plugins, (GFunc) plugin_candidate_free, NULL); - g_list_free(cfg->candidate_plugins); - cfg->candidate_plugins = NULL; + if (context->candidate_plugins) + return; + context->candidate_plugins = plugin_discover_candidate_modules(context->module_path); } +static void +_free_plugin(Plugin *plugin, gpointer user_data) +{ + if (plugin->free_fn) + plugin->free_fn(plugin); +} + +static void +plugin_free_plugins(PluginContext *context) +{ + g_list_foreach(context->plugins, (GFunc) _free_plugin, NULL); + g_list_free(context->plugins); + context->plugins = NULL; +} + +void +plugin_context_set_module_path(PluginContext *context, const gchar *module_path) +{ + g_free(context->module_path); + context->module_path = g_strdup(module_path); +} + +void +plugin_context_init_instance(PluginContext *context) +{ + memset(context, 0, sizeof(*context)); + plugin_context_set_module_path(context, resolvedConfigurablePaths.initial_module_path); +} + +void +plugin_context_deinit_instance(PluginContext *context) +{ + plugin_free_plugins(context); + _free_candidate_plugin_list(context->candidate_plugins); + context->candidate_plugins = NULL; + + g_free(context->module_path); +} + +/* global functions */ + void plugin_list_modules(FILE *out, gboolean verbose) { @@ -510,12 +647,13 @@ { gchar *module_name; ModuleInfo *module_info; + const gchar *so_basename = fname; if (g_str_has_prefix(fname, "lib")) - fname += 3; - module_name = g_strndup(fname, (gint) (strlen(fname) - strlen(G_MODULE_SUFFIX) - 1)); + so_basename = fname + 3; + module_name = g_strndup(so_basename, (gint) (strlen(so_basename) - strlen(G_MODULE_SUFFIX) - 1)); - mod = plugin_dlopen_module(module_name, resolvedConfigurablePaths.initial_module_path); + mod = plugin_dlopen_module_as_dir_and_filename(mod_paths[i], fname, module_name); module_info = plugin_get_module_info(mod); if (verbose) { @@ -571,17 +709,3 @@ if (!verbose) fprintf(out, "\n"); } - -static void -_free_plugin(Plugin *plugin, gpointer user_data) -{ - if (plugin->free_fn) - plugin->free_fn(plugin); -} - -void -plugin_free_plugins(GlobalConfig *cfg) -{ - g_list_foreach(cfg->plugins, (GFunc) _free_plugin, NULL); - g_list_free(cfg->plugins); -} diff -Nru syslog-ng-3.11.1/lib/plugin.h syslog-ng-3.13.2/lib/plugin.h --- syslog-ng-3.11.1/lib/plugin.h 2017-07-31 09:05:32.000000000 +0000 +++ syslog-ng-3.13.2/lib/plugin.h 2017-12-06 06:39:39.000000000 +0000 @@ -27,9 +27,6 @@ #include "cfg-parser.h" -typedef struct _Plugin Plugin; -typedef struct _ModuleInfo ModuleInfo; - typedef struct _PluginFailureInfo { gconstpointer aux_data; @@ -48,7 +45,6 @@ { PluginBase super; gchar *module_name; - gint preference; } PluginCandidate; /* A plugin actually registered by a module. See PluginCandidate in @@ -59,6 +55,7 @@ * contrast with the "module" which is the shared object itself which * registers plugins. Each module can register a number of plugins, * not just one. */ +typedef struct _Plugin Plugin; struct _Plugin { /* NOTE: the first two fields must match PluginCandidate struct defined in @@ -67,11 +64,14 @@ const gchar *name; PluginFailureInfo failure_info; CfgParser *parser; - void (*setup_context)(Plugin *self, GlobalConfig *cfg, gint plugin_type, const gchar *plugin_name); - gpointer (*construct)(Plugin *self, GlobalConfig *cfg, gint plugin_type, const gchar *plugin_name); + gpointer (*construct)(Plugin *self); void (*free_fn)(Plugin *s); }; +gpointer plugin_construct(Plugin *self); +gpointer plugin_construct_from_config(Plugin *self, CfgLexer *lexer, gpointer arg); + +typedef struct _ModuleInfo ModuleInfo; struct _ModuleInfo { /* name of the module to be loaded as */ @@ -85,26 +85,31 @@ Plugin *plugins; gint plugins_len; /* the higher the better */ - gint preference; }; -/* instantiate a new plugin */ -Plugin *plugin_find(GlobalConfig *cfg, gint plugin_type, const gchar *plugin_name); -gpointer plugin_construct(Plugin *self, GlobalConfig *cfg, gint plugin_type, const gchar *plugin_name); -gpointer plugin_parse_config(Plugin *plugin, GlobalConfig *cfg, YYLTYPE *yylloc, gpointer arg); +struct _PluginContext +{ + GList *plugins; + GList *candidate_plugins; + gchar *module_path; +}; +/* instantiate a new plugin */ +Plugin *plugin_find(PluginContext *context, gint plugin_type, const gchar *plugin_name); /* plugin side API */ -PluginCandidate * plugin_candidate_new(gint plugin_type, const gchar *name, const gchar *module_name, gint preference); +PluginCandidate * plugin_candidate_new(gint plugin_type, const gchar *name, const gchar *module_name); void plugin_candidate_free(PluginCandidate *self); -void plugin_register(GlobalConfig *cfg, Plugin *p, gint number); -gboolean plugin_load_module(const gchar *module_name, GlobalConfig *cfg, CfgArgs *args); +void plugin_register(PluginContext *context, Plugin *p, gint number); +gboolean plugin_load_module(PluginContext *context, const gchar *module_name, CfgArgs *args); void plugin_list_modules(FILE *out, gboolean verbose); -void plugin_load_candidate_modules(GlobalConfig *cfg); -void plugin_free_candidate_modules(GlobalConfig *cfg); -void plugin_free_plugins(GlobalConfig *cfg); +void plugin_load_candidate_modules(PluginContext *context); + +void plugin_context_set_module_path(PluginContext *context, const gchar *module_path); +void plugin_context_init_instance(PluginContext *context); +void plugin_context_deinit_instance(PluginContext *context); #endif diff -Nru syslog-ng-3.11.1/lib/plugin-types.h syslog-ng-3.13.2/lib/plugin-types.h --- syslog-ng-3.11.1/lib/plugin-types.h 2017-07-31 09:05:32.000000000 +0000 +++ syslog-ng-3.13.2/lib/plugin-types.h 2017-12-06 06:39:39.000000000 +0000 @@ -39,4 +39,18 @@ #include "cfg-grammar.h" + +/* bitmask to cover non-context flags in the "plugin_type", e.g. + * LL_CONTEXT_FLAG_* */ + +#define LL_CONTEXT_FLAGS 0xF00 + +/* indicates that a plugin is actually a generator, e.g. it is registered + * as LL_CONTEXT_SOURCE but instead of running through the normal plugin + * instantiation via Plugin->parse, let it generate a configuration snippet + * that will be parsed normally. + */ + +#define LL_CONTEXT_FLAG_GENERATOR 0x0100 + #endif diff -Nru syslog-ng-3.11.1/lib/pragma-grammar.ym syslog-ng-3.13.2/lib/pragma-grammar.ym --- syslog-ng-3.11.1/lib/pragma-grammar.ym 2017-07-31 09:05:32.000000000 +0000 +++ syslog-ng-3.13.2/lib/pragma-grammar.ym 2017-12-06 06:39:39.000000000 +0000 @@ -104,12 +104,12 @@ : KW_DEFINE LL_IDENTIFIER string_or_number { msg_debug("Global value changed", evt_tag_str("define", $2), evt_tag_str("value", $3)); - cfg_args_set(lexer->globals, $2, $3); free($2); free($3); } + cfg_args_set(configuration->globals, $2, $3); free($2); free($3); } module_stmt : KW_MODULE string { last_module_args = cfg_args_new(); } module_params { - plugin_load_module($2, configuration, last_module_args); + plugin_load_module(&configuration->plugin_context, $2, last_module_args); free($2); cfg_args_unref(last_module_args); last_module_args = NULL; diff -Nru syslog-ng-3.11.1/lib/pragma-parser.h syslog-ng-3.13.2/lib/pragma-parser.h --- syslog-ng-3.11.1/lib/pragma-parser.h 2017-07-31 09:05:32.000000000 +0000 +++ syslog-ng-3.13.2/lib/pragma-parser.h 2017-12-06 06:39:39.000000000 +0000 @@ -26,7 +26,6 @@ #define PRAGMA_PARSER_H_INCLUDED #include "cfg-parser.h" -#include "cfg-lexer.h" extern CfgParser pragma_parser; diff -Nru syslog-ng-3.11.1/lib/reloc.c syslog-ng-3.13.2/lib/reloc.c --- syslog-ng-3.11.1/lib/reloc.c 2017-07-31 09:05:32.000000000 +0000 +++ syslog-ng-3.13.2/lib/reloc.c 2017-12-06 06:39:39.000000000 +0000 @@ -179,3 +179,13 @@ path_cache = cache_new(path_resolver_new(lookup_sysprefix())); return cache_lookup(path_cache, template); } + +void +reloc_deinit(void) +{ + if (path_cache) + { + cache_free(path_cache); + path_cache = NULL; + } +} diff -Nru syslog-ng-3.11.1/lib/reloc.h syslog-ng-3.13.2/lib/reloc.h --- syslog-ng-3.11.1/lib/reloc.h 2017-07-31 09:05:32.000000000 +0000 +++ syslog-ng-3.13.2/lib/reloc.h 2017-12-06 06:39:39.000000000 +0000 @@ -31,5 +31,6 @@ CacheResolver *path_resolver_new(const gchar *sysprefix); const gchar *get_installation_path_for(const gchar *template); +void reloc_deinit(void); #endif diff -Nru syslog-ng-3.11.1/lib/rewrite/rewrite-expr-grammar.ym syslog-ng-3.13.2/lib/rewrite/rewrite-expr-grammar.ym --- syslog-ng-3.11.1/lib/rewrite/rewrite-expr-grammar.ym 2017-07-31 09:05:32.000000000 +0000 +++ syslog-ng-3.13.2/lib/rewrite/rewrite-expr-grammar.ym 2017-12-06 06:39:39.000000000 +0000 @@ -136,10 +136,10 @@ Plugin *p; gint context = LL_CONTEXT_REWRITE; - p = plugin_find(configuration, context, $1); + p = cfg_find_plugin(configuration, context, $1); CHECK_ERROR(p, @1, "%s plugin %s not found", cfg_lexer_lookup_context_name_by_type(context), $1); - last_rewrite = (LogRewrite *) plugin_parse_config(p, configuration, &@1, NULL); + last_rewrite = (LogRewrite *) cfg_parse_plugin(configuration, p, &@1, NULL); free($1); if (!last_rewrite) { diff -Nru syslog-ng-3.11.1/lib/rewrite/rewrite-expr-parser.h syslog-ng-3.13.2/lib/rewrite/rewrite-expr-parser.h --- syslog-ng-3.11.1/lib/rewrite/rewrite-expr-parser.h 2017-07-31 09:05:32.000000000 +0000 +++ syslog-ng-3.13.2/lib/rewrite/rewrite-expr-parser.h 2017-12-06 06:39:39.000000000 +0000 @@ -26,7 +26,6 @@ #define REWRITE_EXPR_PARSER_H_INCLUDED #include "cfg-parser.h" -#include "cfg-lexer.h" #include "cfg-tree.h" extern CfgParser rewrite_expr_parser; diff -Nru syslog-ng-3.11.1/lib/rewrite/rewrite-subst.c syslog-ng-3.13.2/lib/rewrite/rewrite-subst.c --- syslog-ng-3.11.1/lib/rewrite/rewrite-subst.c 2017-07-31 09:05:32.000000000 +0000 +++ syslog-ng-3.13.2/lib/rewrite/rewrite-subst.c 2017-12-06 06:39:39.000000000 +0000 @@ -92,7 +92,7 @@ LogRewriteSubst *self = (LogRewriteSubst *) s; LogRewriteSubst *cloned; - cloned = (LogRewriteSubst *) log_rewrite_subst_new(log_template_ref(self->replacement), s->cfg); + cloned = (LogRewriteSubst *) log_rewrite_subst_new(self->replacement, s->cfg); cloned->matcher = log_matcher_ref(self->matcher); cloned->super.value_handle = self->super.value_handle; diff -Nru syslog-ng-3.11.1/lib/rewrite/tests/test_rewrite.c syslog-ng-3.13.2/lib/rewrite/tests/test_rewrite.c --- syslog-ng-3.11.1/lib/rewrite/tests/test_rewrite.c 2017-07-31 09:05:32.000000000 +0000 +++ syslog-ng-3.13.2/lib/rewrite/tests/test_rewrite.c 2017-12-06 06:39:39.000000000 +0000 @@ -34,7 +34,7 @@ { char raw_config[1024]; - configuration = cfg_new_snippet(VERSION_VALUE); + configuration = cfg_new_snippet(); snprintf(raw_config, sizeof(raw_config), "rewrite s_test{ %s };", raw_rewrite_rule); assert_false(parse_config(raw_config, LL_CONTEXT_ROOT, NULL, NULL), ASSERTION_ERROR("Parsing the given configuration failed")); @@ -46,7 +46,7 @@ { char raw_config[1024]; - configuration = cfg_new_snippet(VERSION_VALUE); + configuration = cfg_new_snippet(); snprintf(raw_config, sizeof(raw_config), "rewrite s_test{ %s }; log{ rewrite(s_test); };", raw_rewrite_rule); assert_true(parse_config(raw_config, LL_CONTEXT_ROOT, NULL, NULL), ASSERTION_ERROR("Parsing the given configuration failed")); @@ -98,7 +98,7 @@ } void -test_condition_success() +test_condition_success(void) { LogRewrite *test_rewrite = create_rewrite_rule("set(\"00100\", value(\"device_id\") condition(program(\"ARCGIS\")));"); LogMessage *msg = create_message_with_field("PROGRAM", "ARCGIS"); @@ -108,7 +108,7 @@ } void -test_reference_on_condition_cloned() +test_reference_on_condition_cloned(void) { LogRewrite *test_rewrite = create_rewrite_rule("set(\"00100\", value(\"device_id\") condition(program(\"ARCGIS\")));"); LogPipe *cloned_rule = log_pipe_clone(&test_rewrite->super); @@ -118,7 +118,7 @@ cfg_free(configuration); } -void test_set_field_exist_and_set_literal_string() +void test_set_field_exist_and_set_literal_string(void) { LogRewrite *test_rewrite = create_rewrite_rule("set(\"value\" value(\"field1\") );"); LogMessage *msg = create_message_with_field("field1", "oldvalue"); @@ -127,7 +127,7 @@ rewrite_teardown(msg); } -void test_set_field_not_exist_and_set_literal_string() +void test_set_field_not_exist_and_set_literal_string(void) { LogRewrite *test_rewrite = create_rewrite_rule("set(\"value\" value(\"field1\") );"); LogMessage *msg = log_msg_new_empty(); @@ -137,7 +137,7 @@ rewrite_teardown(msg); } -void test_set_field_exist_and_set_template_string() +void test_set_field_exist_and_set_template_string(void) { LogRewrite *test_rewrite = create_rewrite_rule("set(\"$field2\" value(\"field1\") );"); LogMessage *msg = create_message_with_fields("field1", "oldvalue", "field2","newvalue", NULL); @@ -147,7 +147,7 @@ rewrite_teardown(msg); } -void test_subst_field_exist_and_substring_substituted() +void test_subst_field_exist_and_substring_substituted(void) { LogRewrite *test_rewrite = create_rewrite_rule("subst(\"substring\" \"substitute\" value(\"field1\") );"); LogMessage *msg = create_message_with_fields("field1", "asubstringb", NULL); @@ -157,7 +157,7 @@ rewrite_teardown(msg); } -void test_subst_field_exist_and_substring_substituted_with_template() +void test_subst_field_exist_and_substring_substituted_with_template(void) { LogRewrite *test_rewrite = create_rewrite_rule("subst(\"substring\" \"$field2\" value(\"field1\") );"); LogMessage *msg = create_message_with_fields("field1", "asubstringb", "field2","substitute", NULL); @@ -167,7 +167,7 @@ rewrite_teardown(msg); } -void test_subst_field_exist_and_substring_substituted_only_once_without_global() +void test_subst_field_exist_and_substring_substituted_only_once_without_global(void) { LogRewrite *test_rewrite = create_rewrite_rule("subst(\"substring\" \"substitute\" value(\"field1\") );"); LogMessage *msg = create_message_with_fields("field1", "substring substring", NULL); @@ -177,7 +177,7 @@ rewrite_teardown(msg); } -void test_subst_field_exist_and_substring_substituted_every_occurence_with_global() +void test_subst_field_exist_and_substring_substituted_every_occurence_with_global(void) { LogRewrite *test_rewrite = create_rewrite_rule("subst(\"substring\" \"substitute\" value(\"field1\") flags(global) );"); LogMessage *msg = create_message_with_fields("field1", "substring substring", NULL); @@ -187,7 +187,7 @@ rewrite_teardown(msg); } -void test_subst_field_exist_and_substring_substituted_when_regexp_matched() +void test_subst_field_exist_and_substring_substituted_when_regexp_matched(void) { LogRewrite *test_rewrite = create_rewrite_rule("subst(\"[0-9]+\" \"substitute\" value(\"field1\") );"); LogMessage *msg = create_message_with_fields("field1", "a123b", NULL); @@ -197,7 +197,7 @@ rewrite_teardown(msg); } -void test_set_field_exist_and_group_set_literal_string() +void test_set_field_exist_and_group_set_literal_string(void) { LogRewrite *test_rewrite = create_rewrite_rule("groupset(\"value\" values(\"field1\") );"); LogMessage *msg = create_message_with_field("field1", "oldvalue"); @@ -206,7 +206,7 @@ rewrite_teardown(msg); } -void test_set_field_honors_time_zone() +void test_set_field_honors_time_zone(void) { LogRewrite *test_rewrite = create_rewrite_rule("set('${ISODATE}' value('UTCDATE') time-zone('Asia/Tokyo'));"); LogMessage *msg = create_message_with_fields("field1", "a123b", NULL); @@ -216,7 +216,7 @@ rewrite_teardown(msg); } -void test_set_field_exist_and_group_set_multiple_fields_with_glob_pattern_literal_string() +void test_set_field_exist_and_group_set_multiple_fields_with_glob_pattern_literal_string(void) { LogRewrite *test_rewrite = create_rewrite_rule("groupset(\"value\" values(\"field.*\") );"); LogMessage *msg = create_message_with_fields("field.name1", "oldvalue","field.name2", "oldvalue", NULL); @@ -226,7 +226,7 @@ rewrite_teardown(msg); } -void test_set_field_exist_and_group_set_multiple_fields_with_glob_question_mark_pattern_literal_string() +void test_set_field_exist_and_group_set_multiple_fields_with_glob_question_mark_pattern_literal_string(void) { LogRewrite *test_rewrite = create_rewrite_rule("groupset(\"value\" values(\"field?\") );"); LogMessage *msg = create_message_with_fields("field1", "oldvalue","field2", "oldvalue", NULL); @@ -236,7 +236,7 @@ rewrite_teardown(msg); } -void test_set_field_exist_and_group_set_multiple_fields_with_multiple_glob_pattern_literal_string() +void test_set_field_exist_and_group_set_multiple_fields_with_multiple_glob_pattern_literal_string(void) { LogRewrite *test_rewrite = create_rewrite_rule("groupset(\"value\" values(\"field1\" \"field2\") );"); LogMessage *msg = create_message_with_fields("field1", "oldvalue","field2", "oldvalue", NULL); @@ -246,7 +246,7 @@ rewrite_teardown(msg); } -void test_set_field_exist_and_group_set_template_string() +void test_set_field_exist_and_group_set_template_string(void) { LogRewrite *test_rewrite = create_rewrite_rule("groupset(\"$field2\" values(\"field1\") );"); LogMessage *msg = create_message_with_fields("field1", "oldvalue", "field2", "value", NULL); @@ -255,7 +255,7 @@ rewrite_teardown(msg); } -void test_set_field_exist_and_group_set_template_string_with_old_value() +void test_set_field_exist_and_group_set_template_string_with_old_value(void) { LogRewrite *test_rewrite = create_rewrite_rule("groupset(\"$_ alma\" values(\"field1\") );"); LogMessage *msg = create_message_with_field("field1", "value"); @@ -264,7 +264,7 @@ rewrite_teardown(msg); } -void test_set_field_exist_and_group_set_when_condition_doesnt_match() +void test_set_field_exist_and_group_set_when_condition_doesnt_match(void) { LogRewrite *test_rewrite = create_rewrite_rule("groupset(\"value\" values(\"field1\") condition( program(\"program1\") ) );"); @@ -275,7 +275,7 @@ rewrite_teardown(msg); } -void test_set_field_exist_and_group_set_when_condition_matches() +void test_set_field_exist_and_group_set_when_condition_matches(void) { LogRewrite *test_rewrite = create_rewrite_rule("groupset(\"value\" values(\"field1\") condition( program(\"program\") ) );"); @@ -285,7 +285,7 @@ rewrite_teardown(msg); } -void test_set_field_cloned() +void test_set_field_cloned(void) { LogRewrite *test_rewrite = create_rewrite_rule("groupset(\"value\" values(\"field1\") condition( program(\"program\") ) );"); @@ -295,7 +295,7 @@ cfg_free(configuration); } -void test_set_field_invalid_template() +void test_set_field_invalid_template(void) { expect_config_parse_failure("groupset(\"${alma\" values(\"field1\") );"); } diff -Nru syslog-ng-3.11.1/lib/scanner/CMakeLists.txt syslog-ng-3.13.2/lib/scanner/CMakeLists.txt --- syslog-ng-3.11.1/lib/scanner/CMakeLists.txt 2017-07-31 09:05:32.000000000 +0000 +++ syslog-ng-3.13.2/lib/scanner/CMakeLists.txt 2017-12-06 06:39:39.000000000 +0000 @@ -1 +1,3 @@ add_subdirectory(csv-scanner) +add_subdirectory(list-scanner) +add_subdirectory(kv-scanner) diff -Nru syslog-ng-3.11.1/lib/scanner/kv-scanner/kv-scanner.c syslog-ng-3.13.2/lib/scanner/kv-scanner/kv-scanner.c --- syslog-ng-3.11.1/lib/scanner/kv-scanner/kv-scanner.c 2017-07-31 09:05:32.000000000 +0000 +++ syslog-ng-3.13.2/lib/scanner/kv-scanner/kv-scanner.c 2017-12-06 06:39:39.000000000 +0000 @@ -23,6 +23,7 @@ #include "kv-scanner.h" #include "str-repr/decode.h" #include "str-repr/encode.h" +#include "scratch-buffers.h" #include static inline gboolean @@ -322,53 +323,40 @@ return TRUE; } -static KVScanner * -_clone(KVScanner *self) +void +kv_scanner_deinit(KVScanner *self) { - KVScanner *scanner = kv_scanner_new(self->value_separator, - self->pair_separator, - self->stray_words != NULL); - kv_scanner_set_transform_value(scanner, self->transform_value); - kv_scanner_set_valid_key_character_func(scanner, self->is_valid_key_character); - kv_scanner_set_stop_character(scanner, self->stop_char); - kv_scanner_set_extract_annotation_func(scanner, self->extract_annotation); - return scanner; -} - -void kv_scanner_free_method(KVScanner *self) -{ - g_string_free(self->key, TRUE); - g_string_free(self->value, TRUE); - g_string_free(self->decoded_value, TRUE); - if (self->stray_words) - g_string_free(self->stray_words, TRUE); - g_free(self->pair_separator); } void -kv_scanner_init_instance(KVScanner *self, gchar value_separator, const gchar *pair_separator, - gboolean extract_stray_words) +kv_scanner_init(KVScanner *self, gchar value_separator, const gchar *pair_separator, + gboolean extract_stray_words) { - self->key = g_string_sized_new(32); - self->value = g_string_sized_new(64); - self->decoded_value = g_string_sized_new(64); + memset(self, 0, sizeof(*self)); + self->key = scratch_buffers_alloc(); + self->value = scratch_buffers_alloc(); + self->decoded_value = scratch_buffers_alloc(); if (extract_stray_words) - self->stray_words = g_string_sized_new(64); + self->stray_words = scratch_buffers_alloc(); self->value_separator = value_separator; - self->pair_separator = g_strdup(pair_separator ? : ", "); - self->pair_separator_len = self->pair_separator ? strlen(self->pair_separator) : 0; + self->pair_separator = pair_separator ? : ", "; + self->pair_separator_len = strlen(self->pair_separator); self->is_valid_key_character = _is_valid_key_character; self->stop_char = 0; - - self->clone = _clone; - self->free_fn = kv_scanner_free_method; } KVScanner * kv_scanner_new(gchar value_separator, const gchar *pair_separator, gboolean extract_stray_words) { KVScanner *self = g_new0(KVScanner, 1); - kv_scanner_init_instance(self, value_separator, pair_separator, extract_stray_words); + kv_scanner_init(self, value_separator, pair_separator, extract_stray_words); return self; } + +void +kv_scanner_free(KVScanner *self) +{ + kv_scanner_deinit(self); + g_free(self); +} diff -Nru syslog-ng-3.11.1/lib/scanner/kv-scanner/kv-scanner.h syslog-ng-3.13.2/lib/scanner/kv-scanner/kv-scanner.h --- syslog-ng-3.11.1/lib/scanner/kv-scanner/kv-scanner.h 2017-07-31 09:05:32.000000000 +0000 +++ syslog-ng-3.13.2/lib/scanner/kv-scanner/kv-scanner.h 2017-12-06 06:39:39.000000000 +0000 @@ -43,19 +43,17 @@ GString *stray_words; gboolean value_was_quoted; gchar value_separator; - gchar *pair_separator; + const gchar *pair_separator; gsize pair_separator_len; gchar stop_char; KVTransformValueFunc transform_value; KVExtractAnnotationFunc extract_annotation; KVIsValidKeyCharFunc is_valid_key_character; - KVScanner* (*clone)(KVScanner *self); - void (*free_fn)(KVScanner *self); }; -void kv_scanner_init_instance(KVScanner *self, gchar value_separator, const gchar *pair_separator, gboolean extract_stray_words); -void kv_scanner_free_method(KVScanner *self); +void kv_scanner_init(KVScanner *self, gchar value_separator, const gchar *pair_separator, gboolean extract_stray_words); +void kv_scanner_deinit(KVScanner *self); static inline void kv_scanner_input(KVScanner *self, const gchar *input) @@ -66,12 +64,6 @@ g_string_truncate(self->stray_words, 0); } -static inline KVScanner * -kv_scanner_clone(KVScanner *self) -{ - return self->clone(self); -} - static inline const gchar * kv_scanner_get_current_key(KVScanner *self) { @@ -114,17 +106,8 @@ self->stop_char = stop_char; } -static inline void -kv_scanner_free(KVScanner *self) -{ - if (!self || !self->free_fn) - return; - - self->free_fn(self); - g_free(self); -} - gboolean kv_scanner_scan_next(KVScanner *self); KVScanner *kv_scanner_new(gchar value_separator, const gchar *pair_separator, gboolean extract_stray_words); +void kv_scanner_free(KVScanner *self); #endif diff -Nru syslog-ng-3.11.1/lib/scanner/kv-scanner/tests/test_kv_scanner.c syslog-ng-3.13.2/lib/scanner/kv-scanner/tests/test_kv_scanner.c --- syslog-ng-3.11.1/lib/scanner/kv-scanner/tests/test_kv_scanner.c 2017-07-31 09:05:32.000000000 +0000 +++ syslog-ng-3.13.2/lib/scanner/kv-scanner/tests/test_kv_scanner.c 2017-12-06 06:39:39.000000000 +0000 @@ -23,7 +23,8 @@ #include #include #include "stopwatch.h" - +#include "scratch-buffers.h" +#include "apphook.h" #include "kv-scanner.h" static gboolean @@ -143,10 +144,7 @@ { KVScanner *scanner = kv_scanner_new(config.kv_separator, config.pair_separator, config.extract_stray_words); scanner->transform_value = config.transform_value; - - KVScanner *cloned = kv_scanner_clone(scanner); - kv_scanner_free(scanner); - return cloned; + return scanner; } #define VARARG_STRUCT(VARARG_STRUCT_cont, VARARG_STRUCT_elem, ...) \ @@ -976,24 +974,25 @@ for (tc = tcs; tc->input; tc++) { - KVScanner *scanner = create_kv_scanner(((ScannerConfig) - {'=' - })); + KVScanner scanner; + start_stopwatch(); for (iteration_index = 0; iteration_index < ITERATION_NUMBER; iteration_index++) { gchar *error = NULL; - kv_scanner_input(scanner, tc->input); - if (!_expect_kv_pairs(scanner, tc->expected, &error)) + kv_scanner_init(&scanner, '=', ",", FALSE); + kv_scanner_input(&scanner, tc->input); + if (!_expect_kv_pairs(&scanner, tc->expected, &error)) { cr_expect(FALSE, "%s", error); g_free(error); } + kv_scanner_deinit(&scanner); + scratch_buffers_explicit_gc(); } stop_stopwatch_and_display_result(iteration_index, "%.64s...", tc->input); - kv_scanner_free(scanner); } g_free(tcs); } @@ -1003,3 +1002,18 @@ _test_performance(_provide_cases_for_performance_test_nothing_to_parse(), "Nothing to parse in the message"); _test_performance(_provide_cases_for_performance_test_parse_long_msg(), "Parse long strings"); } + +static void +setup(void) +{ + app_startup(); +} + +static void +teardown(void) +{ + scratch_buffers_explicit_gc(); + app_shutdown(); +} + +TestSuite(kv_scanner, .init = setup, .fini = teardown); diff -Nru syslog-ng-3.11.1/lib/scanner/list-scanner/CMakeLists.txt syslog-ng-3.13.2/lib/scanner/list-scanner/CMakeLists.txt --- syslog-ng-3.11.1/lib/scanner/list-scanner/CMakeLists.txt 1970-01-01 00:00:00.000000000 +0000 +++ syslog-ng-3.13.2/lib/scanner/list-scanner/CMakeLists.txt 2017-12-06 06:39:39.000000000 +0000 @@ -0,0 +1,7 @@ +set(LIST_SCANNER_HEADERS + list-scanner/list-scanner.h + PARENT_SCOPE) + +set(LIST_SCANNER_SOURCES + list-scanner/list-scanner.c + PARENT_SCOPE) diff -Nru syslog-ng-3.11.1/lib/service-management.c syslog-ng-3.13.2/lib/service-management.c --- syslog-ng-3.11.1/lib/service-management.c 2017-07-31 09:05:32.000000000 +0000 +++ syslog-ng-3.13.2/lib/service-management.c 2017-12-06 06:39:39.000000000 +0000 @@ -60,19 +60,19 @@ } static inline void -service_management_systemd_clear_status() +service_management_systemd_clear_status(void) { sd_notify(0, "STATUS="); } static inline void -service_management_systemd_indicate_readiness() +service_management_systemd_indicate_readiness(void) { sd_notify(0, "READY=1"); } static gboolean -service_management_systemd_is_active() +service_management_systemd_is_active(void) { struct stat st; @@ -120,17 +120,17 @@ } static inline void -service_management_dummy_clear_status() +service_management_dummy_clear_status(void) { } static inline void -service_management_dummy_indicate_readiness() +service_management_dummy_indicate_readiness(void) { } static gboolean -service_management_dummy_is_active() +service_management_dummy_is_active(void) { return TRUE; } @@ -156,7 +156,7 @@ }; void -service_management_init() +service_management_init(void) { gint i = 0; while (i < sizeof(service_managements) / sizeof(ServiceManagement)) diff -Nru syslog-ng-3.11.1/lib/stats/stats.c syslog-ng-3.13.2/lib/stats/stats.c --- syslog-ng-3.11.1/lib/stats/stats.c 2017-07-31 09:05:32.000000000 +0000 +++ syslog-ng-3.13.2/lib/stats/stats.c 2017-12-06 06:39:39.000000000 +0000 @@ -248,6 +248,7 @@ { stats_query_deinit(); stats_registry_deinit(); + stats_unregister_control_commands(); } void @@ -256,6 +257,7 @@ options->level = 0; options->log_freq = 600; options->lifetime = 600; + options->max_dynamic = -1; } gboolean @@ -266,3 +268,22 @@ else return level == 0; } + +gboolean +stats_check_dynamic_clusters_limit(guint number_of_clusters) +{ + if (!stats_options) + return TRUE; + if (stats_options->max_dynamic == -1) + return TRUE; + return (stats_options->max_dynamic > number_of_clusters); +} + +gint +stats_number_of_dynamic_clusters_limit() +{ + if (!stats_options) + return -1; + return stats_options->max_dynamic; +} + diff -Nru syslog-ng-3.11.1/lib/stats/stats-cluster.c syslog-ng-3.13.2/lib/stats/stats-cluster.c --- syslog-ng-3.11.1/lib/stats/stats-cluster.c 2017-07-31 09:05:32.000000000 +0000 +++ syslog-ng-3.13.2/lib/stats/stats-cluster.c 2017-12-06 06:39:39.000000000 +0000 @@ -264,6 +264,15 @@ return self; } +StatsCluster * +stats_cluster_dynamic_new(const StatsClusterKey *key) +{ + StatsCluster *sc = stats_cluster_new(key); + sc->dynamic = TRUE; + + return sc; +} + void stats_counter_group_free(StatsCounterGroup *self) { diff -Nru syslog-ng-3.11.1/lib/stats/stats-cluster.h syslog-ng-3.13.2/lib/stats/stats-cluster.h --- syslog-ng-3.11.1/lib/stats/stats-cluster.h 2017-07-31 09:05:32.000000000 +0000 +++ syslog-ng-3.13.2/lib/stats/stats-cluster.h 2017-12-06 06:39:39.000000000 +0000 @@ -74,6 +74,7 @@ SCS_FILTER = 38, SCS_PARSER = 39, SCS_MONITORING = 40, + SCS_STDIN = 41, SCS_MAX, SCS_SOURCE_MASK = 0xff }; @@ -146,6 +147,7 @@ gboolean stats_cluster_is_indexed(StatsCluster *self, gint type); StatsCluster *stats_cluster_new(const StatsClusterKey *key); +StatsCluster *stats_cluster_dynamic_new(const StatsClusterKey *key); void stats_cluster_free(StatsCluster *self); void stats_cluster_key_set(StatsClusterKey *self, guint16 component, const gchar *id, const gchar *instance, StatsCounterGroupInit counter_group_ctor); diff -Nru syslog-ng-3.11.1/lib/stats/stats-control.c syslog-ng-3.13.2/lib/stats/stats-control.c --- syslog-ng-3.11.1/lib/stats/stats-control.c 2017-07-31 09:05:32.000000000 +0000 +++ syslog-ng-3.13.2/lib/stats/stats-control.c 2017-12-06 06:39:39.000000000 +0000 @@ -49,3 +49,9 @@ control_register_command("STATS", NULL, control_connection_send_stats, NULL); control_register_command("RESET_STATS", NULL, control_connection_reset_stats, NULL); } + +void +stats_unregister_control_commands(void) +{ + reset_control_command_list(); +} diff -Nru syslog-ng-3.11.1/lib/stats/stats-control.h syslog-ng-3.13.2/lib/stats/stats-control.h --- syslog-ng-3.11.1/lib/stats/stats-control.h 2017-07-31 09:05:32.000000000 +0000 +++ syslog-ng-3.13.2/lib/stats/stats-control.h 2017-12-06 06:39:39.000000000 +0000 @@ -27,5 +27,6 @@ #include "syslog-ng.h" void stats_register_control_commands(void); +void stats_unregister_control_commands(void); #endif diff -Nru syslog-ng-3.11.1/lib/stats/stats.h syslog-ng-3.13.2/lib/stats/stats.h --- syslog-ng-3.11.1/lib/stats/stats.h 2017-07-31 09:05:32.000000000 +0000 +++ syslog-ng-3.13.2/lib/stats/stats.h 2017-12-06 06:39:39.000000000 +0000 @@ -33,6 +33,7 @@ gint log_freq; gint level; gint lifetime; + gint max_dynamic; } StatsOptions; enum @@ -49,6 +50,5 @@ void stats_options_defaults(StatsOptions *options); - #endif diff -Nru syslog-ng-3.11.1/lib/stats/stats-query.c syslog-ng-3.13.2/lib/stats/stats-query.c --- syslog-ng-3.11.1/lib/stats/stats-query.c 2017-07-31 09:05:32.000000000 +0000 +++ syslog-ng-3.13.2/lib/stats/stats-query.c 2017-12-06 06:39:39.000000000 +0000 @@ -125,25 +125,18 @@ } static void -_update_indexes_of_cluster_if_needed(gpointer key, gpointer value) +_update_indexes_of_cluster_if_needed(StatsCluster *sc, gpointer user_data) { - StatsCluster *sc = (StatsCluster *)key; stats_cluster_foreach_counter(sc, _index_counter, NULL); } static void _update_index(void) { - GHashTable *counter_container = stats_registry_get_container(); - gpointer key, value; - GHashTableIter iter; - g_static_mutex_lock(&stats_query_mutex); - g_hash_table_iter_init(&iter, counter_container); - while (g_hash_table_iter_next(&iter, &key, &value)) - { - _update_indexes_of_cluster_if_needed(key, value); - } + stats_lock(); + stats_foreach_cluster(_update_indexes_of_cluster_if_needed, NULL); + stats_unlock(); g_static_mutex_unlock(&stats_query_mutex); } diff -Nru syslog-ng-3.11.1/lib/stats/stats-registry.c syslog-ng-3.13.2/lib/stats/stats-registry.c --- syslog-ng-3.11.1/lib/stats/stats-registry.c 2017-07-31 09:05:32.000000000 +0000 +++ syslog-ng-3.13.2/lib/stats/stats-registry.c 2017-12-06 06:39:39.000000000 +0000 @@ -26,14 +26,30 @@ #include "cfg.h" #include -static GHashTable *stats_cluster_container; +typedef struct _StatsClusterContainer +{ + GHashTable *static_clusters; + GHashTable *dynamic_clusters; +} StatsClusterContainer; + +static StatsClusterContainer stats_cluster_container; + +static guint +_number_of_dynamic_clusters(void) +{ + return g_hash_table_size(stats_cluster_container.dynamic_clusters); +} + static GStaticMutex stats_mutex = G_STATIC_MUTEX_INIT; gboolean stats_locked; static void _insert_cluster(StatsCluster *sc) { - g_hash_table_insert(stats_cluster_container, &sc->key, sc); + if (sc->dynamic) + g_hash_table_insert(stats_cluster_container.dynamic_clusters, &sc->key, sc); + else + g_hash_table_insert(stats_cluster_container.static_clusters, &sc->key, sc); } void @@ -51,31 +67,65 @@ } static StatsCluster * -_grab_cluster(gint stats_level, const StatsClusterKey *sc_key, gboolean dynamic) +_grab_dynamic_cluster(const StatsClusterKey *sc_key) { StatsCluster *sc; - if (!stats_check_level(stats_level)) - return NULL; + sc = g_hash_table_lookup(stats_cluster_container.dynamic_clusters, sc_key); + if (!sc) + { + if (!stats_check_dynamic_clusters_limit(_number_of_dynamic_clusters())) + return NULL; + sc = stats_cluster_dynamic_new(sc_key); + _insert_cluster(sc); + if ( !stats_check_dynamic_clusters_limit(_number_of_dynamic_clusters())) + { + msg_warning("Number of dynamic cluster limit has been reached.", + evt_tag_int("allowed_clusters", stats_number_of_dynamic_clusters_limit())); + } + } + + return sc; + +} + +static StatsCluster * +_grab_static_cluster(const StatsClusterKey *sc_key) +{ + StatsCluster *sc; - sc = g_hash_table_lookup(stats_cluster_container, sc_key); + sc = g_hash_table_lookup(stats_cluster_container.static_clusters, sc_key); if (!sc) { - /* no such StatsCluster instance, register one */ sc = stats_cluster_new(sc_key); - sc->dynamic = dynamic; _insert_cluster(sc); } + + return sc; +} + +static StatsCluster * +_grab_cluster(gint stats_level, const StatsClusterKey *sc_key, gboolean dynamic) +{ + if (!stats_check_level(stats_level)) + return NULL; + + StatsCluster *sc = NULL; + + if (dynamic) + sc = _grab_dynamic_cluster(sc_key); else - { - /* check that we are not overwriting a dynamic counter with a - * non-dynamic one or vica versa. This could only happen if the same - * key is used for both a dynamic counter and a non-dynamic one, which - * is a programming error */ + sc = _grab_static_cluster(sc_key); - g_assert(sc->dynamic == dynamic); - } + if (!sc) + return NULL; + /* check that we are not overwriting a dynamic counter with a + * non-dynamic one or vica versa. This could only happen if the same + * key is used for both a dynamic counter and a non-dynamic one, which + * is a programming error */ + + g_assert(sc->dynamic == dynamic); return sc; } @@ -156,6 +206,8 @@ g_assert(stats_locked); handle = stats_register_dynamic_counter(stats_level, sc_key, SC_TYPE_PROCESSED, &counter); + if (!handle) + return; stats_counter_inc(counter); if (timestamp >= 0) { @@ -199,7 +251,7 @@ if (*counter == NULL) return; - sc = g_hash_table_lookup(stats_cluster_container, sc_key); + sc = g_hash_table_lookup(stats_cluster_container.static_clusters, sc_key); stats_cluster_untrack_counter(sc, type, counter); } @@ -251,7 +303,8 @@ gpointer args[] = { func, user_data }; g_assert(stats_locked); - g_hash_table_foreach(stats_cluster_container, _foreach_cluster_helper, args); + g_hash_table_foreach(stats_cluster_container.static_clusters, _foreach_cluster_helper, args); + g_hash_table_foreach(stats_cluster_container.dynamic_clusters, _foreach_cluster_helper, args); } static gboolean @@ -269,7 +322,8 @@ stats_foreach_cluster_remove(StatsForeachClusterRemoveFunc func, gpointer user_data) { gpointer args[] = { func, user_data }; - g_hash_table_foreach_remove(stats_cluster_container, _foreach_cluster_remove_helper, args); + g_hash_table_foreach_remove(stats_cluster_container.static_clusters, _foreach_cluster_remove_helper, args); + g_hash_table_foreach_remove(stats_cluster_container.dynamic_clusters, _foreach_cluster_remove_helper, args); } static void @@ -294,21 +348,23 @@ void stats_registry_init(void) { - stats_cluster_container = g_hash_table_new_full((GHashFunc) stats_cluster_hash, (GEqualFunc) stats_cluster_equal, NULL, - (GDestroyNotify) stats_cluster_free); + stats_cluster_container.static_clusters = g_hash_table_new_full((GHashFunc) stats_cluster_hash, + (GEqualFunc) stats_cluster_equal, NULL, + (GDestroyNotify) stats_cluster_free); + stats_cluster_container.dynamic_clusters = g_hash_table_new_full((GHashFunc) stats_cluster_hash, + (GEqualFunc) stats_cluster_equal, NULL, + (GDestroyNotify) stats_cluster_free); + g_static_mutex_init(&stats_mutex); } void stats_registry_deinit(void) { - g_hash_table_destroy(stats_cluster_container); - stats_cluster_container = NULL; + g_hash_table_destroy(stats_cluster_container.static_clusters); + g_hash_table_destroy(stats_cluster_container.dynamic_clusters); + stats_cluster_container.static_clusters = NULL; + stats_cluster_container.dynamic_clusters = NULL; g_static_mutex_free(&stats_mutex); } -GHashTable * -stats_registry_get_container(void) -{ - return stats_cluster_container; -} diff -Nru syslog-ng-3.11.1/lib/stats/stats-registry.h syslog-ng-3.13.2/lib/stats/stats-registry.h --- syslog-ng-3.11.1/lib/stats/stats-registry.h 2017-07-31 09:05:32.000000000 +0000 +++ syslog-ng-3.13.2/lib/stats/stats-registry.h 2017-12-06 06:39:39.000000000 +0000 @@ -50,9 +50,10 @@ void stats_registry_init(void); void stats_registry_deinit(void); -GHashTable* stats_registry_get_container(void); - void save_counter_to_persistent_storage(GlobalConfig *cfg, StatsCounterItem *counter); void load_counter_from_persistent_storage(GlobalConfig *cfg, StatsCounterItem *counter); +gboolean stats_check_dynamic_clusters_limit(guint number_of_clusters); +gint stats_number_of_dynamic_clusters_limit(void); + #endif diff -Nru syslog-ng-3.11.1/lib/stats/tests/Makefile.am syslog-ng-3.13.2/lib/stats/tests/Makefile.am --- syslog-ng-3.11.1/lib/stats/tests/Makefile.am 2017-07-31 09:05:32.000000000 +0000 +++ syslog-ng-3.13.2/lib/stats/tests/Makefile.am 2017-12-06 06:39:39.000000000 +0000 @@ -14,9 +14,15 @@ $(PREOPEN_SYSLOGFORMAT) lib_stats_tests_TESTS += \ - lib/stats/tests/test_stats_query + lib/stats/tests/test_stats_query \ + lib/stats/tests/test_dynamic_ctr_reg lib_stats_tests_test_stats_query_CFLAGS = $(TEST_CFLAGS) lib_stats_tests_test_stats_query_LDADD = \ $(TEST_LDADD) $(stats_test_extra_modules) + +lib_stats_tests_test_dynamic_ctr_reg_CFLAGS = $(TEST_CFLAGS) +lib_stats_tests_test_dynamic_ctr_reg_LDADD = \ + $(TEST_LDADD) $(stats_test_extra_modules) + endif diff -Nru syslog-ng-3.11.1/lib/stats/tests/test_dynamic_ctr_reg.c syslog-ng-3.13.2/lib/stats/tests/test_dynamic_ctr_reg.c --- syslog-ng-3.11.1/lib/stats/tests/test_dynamic_ctr_reg.c 1970-01-01 00:00:00.000000000 +0000 +++ syslog-ng-3.13.2/lib/stats/tests/test_dynamic_ctr_reg.c 2017-12-06 06:39:39.000000000 +0000 @@ -0,0 +1,85 @@ +/* + * Copyright (c) 2017 Balabit + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + * + * As an additional exemption you are allowed to compile & link against the + * OpenSSL libraries as published by the OpenSSL project. See the file + * COPYING for details. + * + */ + + +#include "apphook.h" +#include "logmsg/logmsg.h" +#include "stats/stats-cluster.h" +#include "stats/stats-cluster-single.h" +#include "stats/stats-counter.h" +#include "stats/stats-query.h" +#include "stats/stats-registry.h" +#include "syslog-ng.h" + +#include +#include + +#include +#include + +TestSuite(stats_dynamic_clusters, .init = app_startup, .fini = app_shutdown); + +Test(stats_dynamic_clusters, unlimited_by_default) +{ + StatsOptions stats_opts; + stats_options_defaults(&stats_opts); + stats_reinit(&stats_opts); + cr_assert_eq(stats_check_dynamic_clusters_limit(0), TRUE); + cr_assert_eq(stats_check_dynamic_clusters_limit(UINT_MAX), TRUE); +} + +Test(stats_dynamic_clusters, limited) +{ + StatsOptions stats_opts; + stats_options_defaults(&stats_opts); + stats_opts.max_dynamic = 2; + stats_reinit(&stats_opts); + cr_assert_eq(stats_check_dynamic_clusters_limit(0), TRUE); + cr_assert_eq(stats_check_dynamic_clusters_limit(1), TRUE); + cr_assert_eq(stats_check_dynamic_clusters_limit(2), FALSE); +} + +Test(stats_dynamic_clusters, register_limited) +{ + StatsOptions stats_opts; + stats_options_defaults(&stats_opts); + stats_opts.level = 3; + stats_opts.max_dynamic = 2; + stats_reinit(&stats_opts); + stats_lock(); + { + StatsClusterKey sc_key; + stats_cluster_logpipe_key_set(&sc_key, SCS_HOST | SCS_SENDER, NULL, "testhost1"); + StatsCounterItem *counter = NULL; + StatsCluster *sc = stats_register_dynamic_counter(1, &sc_key, SC_TYPE_PROCESSED, &counter); + cr_assert_not_null(sc); + stats_cluster_logpipe_key_set(&sc_key, SCS_HOST | SCS_SENDER, NULL, "testhost2"); + sc = stats_register_dynamic_counter(1, &sc_key, SC_TYPE_PROCESSED, &counter); + cr_assert_not_null(sc); + stats_cluster_logpipe_key_set(&sc_key, SCS_HOST | SCS_SENDER, NULL, "testhost3"); + sc = stats_register_dynamic_counter(1, &sc_key, SC_TYPE_PROCESSED, &counter); + cr_assert_null(sc); + } + stats_unlock(); +} + diff -Nru syslog-ng-3.11.1/lib/stats/tests/test_stats_query.c syslog-ng-3.13.2/lib/stats/tests/test_stats_query.c --- syslog-ng-3.11.1/lib/stats/tests/test_stats_query.c 2017-07-31 09:05:32.000000000 +0000 +++ syslog-ng-3.13.2/lib/stats/tests/test_stats_query.c 2017-12-06 06:39:39.000000000 +0000 @@ -99,7 +99,7 @@ } static void -_register_single_counter_with_name() +_register_single_counter_with_name(void) { stats_lock(); { diff -Nru syslog-ng-3.11.1/lib/syslog-ng.h syslog-ng-3.13.2/lib/syslog-ng.h --- syslog-ng-3.11.1/lib/syslog-ng.h 2017-07-31 09:05:32.000000000 +0000 +++ syslog-ng-3.13.2/lib/syslog-ng.h 2017-12-06 06:39:39.000000000 +0000 @@ -47,6 +47,8 @@ typedef struct _LogPipe LogPipe; typedef struct _LogMessage LogMessage; typedef struct _GlobalConfig GlobalConfig; +typedef struct _CfgLexer CfgLexer; +typedef struct _PluginContext PluginContext; typedef struct _Bookmark Bookmark; typedef struct _AckTracker AckTracker; typedef struct _AckRecord AckRecord; diff -Nru syslog-ng-3.11.1/lib/template/compiler.c syslog-ng-3.13.2/lib/template/compiler.c --- syslog-ng-3.11.1/lib/template/compiler.c 2017-07-31 09:05:32.000000000 +0000 +++ syslog-ng-3.13.2/lib/template/compiler.c 2017-12-06 06:39:39.000000000 +0000 @@ -71,7 +71,7 @@ gchar *argv_copy[argc + 1]; g_return_val_if_fail(error == NULL || *error == NULL, FALSE); - e->func.ops = plugin_construct(p, self->template->cfg, LL_CONTEXT_TEMPLATE_FUNC, argv[0]); + e->func.ops = plugin_construct(p); e->func.state = e->func.ops->size_of_state > 0 ? g_malloc0(e->func.ops->size_of_state) : NULL; /* prepare may modify the argv array: remove and rearrange elements */ @@ -99,8 +99,7 @@ Plugin *p; g_return_val_if_fail(error == NULL || *error == NULL, FALSE); - - p = plugin_find(self->template->cfg, LL_CONTEXT_TEMPLATE_FUNC, argv[0]); + p = cfg_find_plugin(self->template->cfg, LL_CONTEXT_TEMPLATE_FUNC, argv[0]); if (!p) { diff -Nru syslog-ng-3.11.1/lib/template/function.h syslog-ng-3.13.2/lib/template/function.h --- syslog-ng-3.11.1/lib/template/function.h 2017-07-31 09:05:32.000000000 +0000 +++ syslog-ng-3.13.2/lib/template/function.h 2017-12-06 06:39:39.000000000 +0000 @@ -83,9 +83,7 @@ #define TEMPLATE_FUNCTION_PROTOTYPE(prefix) \ gpointer \ - prefix ## _construct(Plugin *self, \ - GlobalConfig *cfg, \ - gint plugin_type, const gchar *plugin_name) + prefix ## _construct(Plugin *self) #define TEMPLATE_FUNCTION_DECLARE(prefix) \ TEMPLATE_FUNCTION_PROTOTYPE(prefix); diff -Nru syslog-ng-3.11.1/lib/template/macros.c syslog-ng-3.13.2/lib/template/macros.c --- syslog-ng-3.11.1/lib/template/macros.c 2017-07-31 09:05:32.000000000 +0000 +++ syslog-ng-3.13.2/lib/template/macros.c 2017-12-06 06:39:39.000000000 +0000 @@ -320,17 +320,16 @@ } break; case M_MSGHDR: - if ((msg->flags & LF_LEGACY_MSGHDR)) - { - /* fast path for now, as most messages come from legacy devices */ + { + gssize len; + const gchar *p; - _result_append_value(result, msg, LM_V_LEGACY_MSGHDR, escape); - } + p = log_msg_get_value(msg, LM_V_LEGACY_MSGHDR, &len); + if (len > 0) + result_append(result, p, len, escape); else { /* message, complete with program name and pid */ - gssize len; - len = result->len; _result_append_value(result, msg, LM_V_PROGRAM, escape); if (len != result->len) @@ -346,9 +345,8 @@ } } break; + } case M_MESSAGE: - if (cfg_is_config_version_older(configuration, 0x0300)) - log_macro_expand(result, M_MSGHDR, escape, opts, tz, seq_num, context_id, msg); _result_append_value(result, msg, LM_V_MESSAGE, escape); break; case M_SOURCE_IP: @@ -595,12 +593,6 @@ g_assert(macro_hash); g_strlcpy(buf, macro, MIN(sizeof(buf), len+1)); macro_id = GPOINTER_TO_INT(g_hash_table_lookup(macro_hash, buf)); - - if (cfg_is_config_version_older(configuration, 0x0300) && (macro_id == M_MESSAGE)) - { - msg_warning_once("WARNING: template: the meaning of the $MSG/$MESSAGE macros has changed from " VERSION_3_0 - ", please prepend a $MSGHDR when upgrading to " VERSION_3_0 " config format"); - } return macro_id; } diff -Nru syslog-ng-3.11.1/lib/template/templates.c syslog-ng-3.13.2/lib/template/templates.c --- syslog-ng-3.11.1/lib/template/templates.c 2017-07-31 09:05:32.000000000 +0000 +++ syslog-ng-3.13.2/lib/template/templates.c 2017-12-06 06:39:39.000000000 +0000 @@ -230,12 +230,6 @@ self->ref_cnt = 1; self->cfg = cfg; g_static_mutex_init(&self->arg_lock); - if (cfg_is_config_version_older(cfg, 0x0300)) - { - msg_warning_once("WARNING: template: the default value for template-escape has changed to 'no' from " VERSION_3_0 - ", please update your configuration file accordingly"); - self->escape = TRUE; - } return self; } @@ -329,7 +323,7 @@ } GQuark -log_template_error_quark() +log_template_error_quark(void) { return g_quark_from_static_string("log-template-error-quark"); } diff -Nru syslog-ng-3.11.1/lib/template/tests/test_template.c syslog-ng-3.13.2/lib/template/tests/test_template.c --- syslog-ng-3.11.1/lib/template/tests/test_template.c 2017-07-31 09:05:32.000000000 +0000 +++ syslog-ng-3.13.2/lib/template/tests/test_template.c 2017-12-06 06:39:39.000000000 +0000 @@ -116,7 +116,7 @@ assert_template_format("$LEVEL", "err"); assert_template_format("$LEVEL_NUM", "3"); assert_template_format("$TAG", "9b"); - assert_template_format("$TAGS", "alma,korte,citrom"); + assert_template_format("$TAGS", "alma,korte,citrom,\"tag,containing,comma\""); assert_template_format("$PRI", "155"); assert_template_format("$DATE", "Feb 11 10:34:56.000"); assert_template_format("$FULLDATE", "2006 Feb 11 10:34:56.000"); @@ -245,34 +245,6 @@ } static void -test_compat(void) -{ - gint old_version; - - old_version = configuration->user_version; - /* old version for various macros */ - configuration->user_version = 0x0201; - - start_grabbing_messages(); - assert_template_format("$MSGHDR", "syslog-ng[23323]:"); - gchar *expected_msg_default_value_changed = - g_strdup_printf("the default value for template-escape has changed to 'no' from %s", VERSION_3_0); - assert_grabbed_messages_contain(expected_msg_default_value_changed, NULL); - reset_grabbed_messages(); - assert_template_format("$MSG", "syslog-ng[23323]:árvíztűrőtükörfúrógép"); - gchar *expected_msg_macros_changed = g_strdup_printf("the meaning of the $MSG/$MESSAGE macros has changed from %s", - VERSION_3_0); - assert_grabbed_messages_contain(expected_msg_macros_changed, NULL); - stop_grabbing_messages(); - g_free(expected_msg_default_value_changed); - g_free(expected_msg_macros_changed); - assert_template_format("$MSGONLY", "árvíztűrőtükörfúrógép"); - assert_template_format("$MESSAGE", "syslog-ng[23323]:árvíztűrőtükörfúrógép"); - - configuration->user_version = old_version; -} - -static void test_multi_thread(void) { /* name-value pair */ @@ -320,7 +292,7 @@ app_startup(); init_template_tests(); - plugin_load_module("basicfuncs", configuration, NULL); + cfg_load_module(configuration, "basicfuncs"); configuration->template_options.frac_digits = 3; configuration->template_options.time_zone_info[LTZ_LOCAL] = time_zone_info_new(NULL); @@ -333,7 +305,6 @@ test_template_functions(); test_message_refs(); test_syntax_errors(); - test_compat(); test_multi_thread(); test_escaping(); test_template_function_args(); diff -Nru syslog-ng-3.11.1/lib/template/tests/test_template_compile.c syslog-ng-3.13.2/lib/template/tests/test_template_compile.c --- syslog-ng-3.11.1/lib/template/tests/test_template_compile.c 2017-07-31 09:05:32.000000000 +0000 +++ syslog-ng-3.13.2/lib/template/tests/test_template_compile.c 2017-12-06 06:39:39.000000000 +0000 @@ -144,11 +144,11 @@ { Plugin *plugin; - plugin = plugin_find(configuration, LL_CONTEXT_TEMPLATE_FUNC, name); + plugin = cfg_find_plugin(configuration, LL_CONTEXT_TEMPLATE_FUNC, name); assert_not_null(plugin, "Template function %s is not found", name); if (plugin) - return plugin->construct(plugin, configuration, LL_CONTEXT_TEMPLATE_FUNC, name); + return plugin->construct(plugin); return NULL; } @@ -249,7 +249,7 @@ } static void -test_double_dollars_is_a_literal_dollar() +test_double_dollars_is_a_literal_dollar(void) { assert_template_compile("$$VALUE_NAME"); assert_compiled_template(text = "$VALUE_NAME", default_value = NULL, macro = M_NONE, type = LTE_MACRO, msg_ref = 0); @@ -343,7 +343,7 @@ } static void -test_template_compile_value() +test_template_compile_value(void) { TEMPLATE_TESTCASE(test_simple_value); TEMPLATE_TESTCASE(test_value_without_braces); @@ -463,10 +463,10 @@ { msg_init(FALSE); - configuration = cfg_new_snippet(VERSION_VALUE); + configuration = cfg_new_snippet(); log_msg_registry_init(); log_template_global_init(); - plugin_register(configuration, &hello_plugin, 1); + plugin_register(&configuration->plugin_context, &hello_plugin, 1); test_template_compile_macro(); test_template_compile_value(); diff -Nru syslog-ng-3.11.1/lib/template/tests/test_template_speed.c syslog-ng-3.13.2/lib/template/tests/test_template_speed.c --- syslog-ng-3.11.1/lib/template/tests/test_template_speed.c 2017-07-31 09:05:32.000000000 +0000 +++ syslog-ng-3.13.2/lib/template/tests/test_template_speed.c 2017-12-06 06:39:39.000000000 +0000 @@ -49,7 +49,8 @@ putenv("TZ=MET-1METDST"); tzset(); - plugin_load_module("basicfuncs", configuration, NULL); + cfg_load_module(configuration, "syslogformat"); + cfg_load_module(configuration, "basicfuncs"); perftest_template("$DATE\n"); perftest_template("<$PRI>$DATE $HOST $MSGHDR$MSG\n"); diff -Nru syslog-ng-3.11.1/lib/template/user-function.c syslog-ng-3.13.2/lib/template/user-function.c --- syslog-ng-3.11.1/lib/template/user-function.c 2017-07-31 09:05:32.000000000 +0000 +++ syslog-ng-3.13.2/lib/template/user-function.c 2017-12-06 06:39:39.000000000 +0000 @@ -90,7 +90,7 @@ } UserTemplateFunctionPlugin; static gpointer -user_template_function_construct(Plugin *s, GlobalConfig *cfg, gint plugin_type, const gchar *plugin_name) +user_template_function_construct(Plugin *s) { UserTemplateFunctionPlugin *self = (UserTemplateFunctionPlugin *) s; @@ -116,9 +116,8 @@ plugin->super.type = LL_CONTEXT_TEMPLATE_FUNC; plugin->super.name = g_strdup(name); plugin->super.parser = NULL; - plugin->super.setup_context = NULL; plugin->super.construct = user_template_function_construct; plugin->super.free_fn = user_template_function_plugin_free; plugin->template = log_template_ref(template); - plugin_register(cfg, &plugin->super, 1); + plugin_register(&cfg->plugin_context, &plugin->super, 1); } diff -Nru syslog-ng-3.11.1/lib/tests/test_cfg_lexer_subst.c syslog-ng-3.13.2/lib/tests/test_cfg_lexer_subst.c --- syslog-ng-3.11.1/lib/tests/test_cfg_lexer_subst.c 2017-07-31 09:05:32.000000000 +0000 +++ syslog-ng-3.13.2/lib/tests/test_cfg_lexer_subst.c 2017-12-06 06:39:39.000000000 +0000 @@ -317,7 +317,7 @@ SUBST_TESTCASE(test_strings_with_embedded_apostrophe_cause_an_error_when_encoding_in_qstring); } -int main() +int main(void) { app_startup(); diff -Nru syslog-ng-3.11.1/lib/tests/test_host_resolve.c syslog-ng-3.13.2/lib/tests/test_host_resolve.c --- syslog-ng-3.11.1/lib/tests/test_host_resolve.c 2017-07-31 09:05:32.000000000 +0000 +++ syslog-ng-3.13.2/lib/tests/test_host_resolve.c 2017-12-06 06:39:39.000000000 +0000 @@ -308,7 +308,7 @@ { app_startup(); - configuration = cfg_new_snippet(VERSION_VALUE); + configuration = cfg_new_snippet(); test_resolve_hostname_to_hostname(); test_resolve_hostname_to_sockaddr(); test_resolve_sockaddr_to_hostname(); diff -Nru syslog-ng-3.11.1/lib/tests/test_lexer.c syslog-ng-3.13.2/lib/tests/test_lexer.c --- syslog-ng-3.11.1/lib/tests/test_lexer.c 2017-07-31 09:05:32.000000000 +0000 +++ syslog-ng-3.13.2/lib/tests/test_lexer.c 2017-12-06 06:39:39.000000000 +0000 @@ -53,7 +53,7 @@ { if (self->lexer) cfg_lexer_free(self->lexer); - self->lexer = cfg_lexer_new_buffer(buffer, strlen(buffer)); + self->lexer = cfg_lexer_new_buffer(configuration, buffer, strlen(buffer)); } TestParser * diff -Nru syslog-ng-3.11.1/lib/tests/test_parse_number.c syslog-ng-3.13.2/lib/tests/test_parse_number.c --- syslog-ng-3.11.1/lib/tests/test_parse_number.c 2017-07-31 09:05:32.000000000 +0000 +++ syslog-ng-3.13.2/lib/tests/test_parse_number.c 2017-12-06 06:39:39.000000000 +0000 @@ -82,6 +82,15 @@ } static void +test_c_like_prefixes_select_base(void) +{ + assert_parse("0x20", 32); + assert_parse("020", 16); + assert_parse("20", 20); + assert_parse_with_suffix("0x20kiB", 32 * 1024); +} + +static void test_exponent_suffix_is_parsed_properly(void) { assert_parse_with_suffix("1K", 1000); @@ -137,6 +146,7 @@ test_byte_units_are_accepted(); test_base2_is_selected_by_an_i_modifier(); test_invalid_formats_are_not_accepted(); + test_c_like_prefixes_select_base(); return 0; } diff -Nru syslog-ng-3.11.1/lib/tests/test_pathutils.c syslog-ng-3.13.2/lib/tests/test_pathutils.c --- syslog-ng-3.11.1/lib/tests/test_pathutils.c 2017-07-31 09:05:32.000000000 +0000 +++ syslog-ng-3.13.2/lib/tests/test_pathutils.c 2017-12-06 06:39:39.000000000 +0000 @@ -46,7 +46,7 @@ } int -main() +main(void) { test_is_directory_return_false_in_case_of_regular_file(); } diff -Nru syslog-ng-3.11.1/lib/tests/test_rcptid.c syslog-ng-3.13.2/lib/tests/test_rcptid.c --- syslog-ng-3.11.1/lib/tests/test_rcptid.c 2017-07-31 09:05:32.000000000 +0000 +++ syslog-ng-3.13.2/lib/tests/test_rcptid.c 2017-12-06 06:39:39.000000000 +0000 @@ -34,14 +34,14 @@ PersistState *state; void -setup_persist_id_test() +setup_persist_id_test(void) { state = clean_and_create_persist_state_for_test("test_values.persist"); rcptid_init(state, TRUE); } void -teardown_persist_id_test() +teardown_persist_id_test(void) { commit_and_destroy_persist_state(state); rcptid_deinit(); @@ -115,7 +115,7 @@ } static void -rcptid_test_case() +rcptid_test_case(void) { test_rcptid_is_persistent_across_persist_backend_reinits(); test_rcptid_overflows_at_64bits_and_is_reset_to_one(); diff -Nru syslog-ng-3.11.1/lib/tests/test_runid.c syslog-ng-3.13.2/lib/tests/test_runid.c --- syslog-ng-3.11.1/lib/tests/test_runid.c 2017-07-31 09:05:32.000000000 +0000 +++ syslog-ng-3.13.2/lib/tests/test_runid.c 2017-12-06 06:39:39.000000000 +0000 @@ -152,7 +152,7 @@ int -main() +main(void) { app_startup(); test_run_id__first_run__run_id_is_one(); diff -Nru syslog-ng-3.11.1/lib/tests/test_str_format.c syslog-ng-3.13.2/lib/tests/test_str_format.c --- syslog-ng-3.11.1/lib/tests/test_str_format.c 2017-07-31 09:05:32.000000000 +0000 +++ syslog-ng-3.13.2/lib/tests/test_str_format.c 2017-12-06 06:39:39.000000000 +0000 @@ -26,7 +26,7 @@ #include "str-format.h" #include "testutils.h" -void test_format_hex_string__single_byte__perfect() +void test_format_hex_string__single_byte__perfect(void) { gchar expected_output[3] = "40"; gchar output[3]; @@ -38,7 +38,7 @@ "format_hex_string output does not match!", NULL); } -void test_format_hex_string__two_bytes__perfect() +void test_format_hex_string__two_bytes__perfect(void) { gchar expected_output[5] = "4041"; gchar output[5]; @@ -50,7 +50,7 @@ "format_hex_string output does not match with two bytes!", NULL); } -void test_format_hex_string_with_delimiter__single_byte__perfect() +void test_format_hex_string_with_delimiter__single_byte__perfect(void) { gchar expected_output[3] = "40"; gchar output[3]; @@ -62,7 +62,7 @@ "format_hex_string_with_delimiter output does not match!", NULL); } -void test_format_hex_string_with_delimiter__two_bytes__perfect() +void test_format_hex_string_with_delimiter__two_bytes__perfect(void) { gchar expected_output[6] = "40 41"; gchar output[6]; @@ -74,7 +74,7 @@ "format_hex_string_with_delimiter output does not match in case of two bytes!", NULL); } -int main() +int main(void) { test_format_hex_string__single_byte__perfect(); test_format_hex_string__two_bytes__perfect(); diff -Nru syslog-ng-3.11.1/lib/timeutils.c syslog-ng-3.13.2/lib/timeutils.c --- syslog-ng-3.11.1/lib/timeutils.c 2017-07-31 09:05:32.000000000 +0000 +++ syslog-ng-3.13.2/lib/timeutils.c 2017-12-06 06:39:39.000000000 +0000 @@ -150,7 +150,7 @@ } time_t -cached_g_current_time_sec() +cached_g_current_time_sec(void) { GTimeVal now; diff -Nru syslog-ng-3.11.1/lib/tlscontext.c syslog-ng-3.13.2/lib/tlscontext.c --- syslog-ng-3.11.1/lib/tlscontext.c 2017-07-31 09:05:32.000000000 +0000 +++ syslog-ng-3.13.2/lib/tlscontext.c 2017-12-06 06:39:39.000000000 +0000 @@ -28,10 +28,32 @@ #include #include +#include #include #include #include #include +#include +#include +#include + +struct _TLSContext +{ + TLSMode mode; + gint verify_mode; + gchar *key_file; + gchar *cert_file; + gchar *dhparam_file; + gchar *pkcs12_file; + gchar *ca_dir; + gchar *crl_dir; + gchar *cipher_suite; + gchar *ecdh_curve_list; + SSL_CTX *ssl_ctx; + GList *trusted_fingerpint_list; + GList *trusted_dn_list; + gint ssl_options; +}; gboolean tls_get_x509_digest(X509 *x, GString *hash_string) @@ -305,121 +327,354 @@ return TRUE; } -TLSSession * -tls_context_setup_session(TLSContext *self) +static void +_print_and_clear_tls_session_error(void) { - SSL *ssl; - TLSSession *session; - gint ssl_error; - long ssl_options; + gulong ssl_error = ERR_get_error(); + msg_error("Error setting up TLS session context", + evt_tag_printf("tls_error", "%s:%s:%s", + ERR_lib_error_string(ssl_error), + ERR_func_error_string(ssl_error), + ERR_reason_error_string(ssl_error))); + ERR_clear_error(); +} - if (!self->ssl_ctx) +static void +tls_context_setup_verify_mode(TLSContext *self) +{ + gint verify_mode = 0; + + switch (self->verify_mode) + { + case TVM_NONE: + verify_mode = SSL_VERIFY_NONE; + break; + case TVM_OPTIONAL | TVM_UNTRUSTED: + verify_mode = SSL_VERIFY_NONE; + break; + case TVM_OPTIONAL | TVM_TRUSTED: + verify_mode = SSL_VERIFY_PEER | SSL_VERIFY_CLIENT_ONCE; + break; + case TVM_REQUIRED | TVM_UNTRUSTED: + verify_mode = SSL_VERIFY_PEER | SSL_VERIFY_CLIENT_ONCE | SSL_VERIFY_FAIL_IF_NO_PEER_CERT; + break; + case TVM_REQUIRED | TVM_TRUSTED: + verify_mode = SSL_VERIFY_PEER | SSL_VERIFY_CLIENT_ONCE | SSL_VERIFY_FAIL_IF_NO_PEER_CERT; + break; + default: + g_assert_not_reached(); + } + + SSL_CTX_set_verify(self->ssl_ctx, verify_mode, tls_session_verify_callback); +} + +static void +tls_context_setup_ssl_options(TLSContext *self) +{ + if (self->ssl_options != TSO_NONE) + { + glong ssl_options = 0; + if(self->ssl_options & TSO_NOSSLv2) + ssl_options |= SSL_OP_NO_SSLv2; + if(self->ssl_options & TSO_NOSSLv3) + ssl_options |= SSL_OP_NO_SSLv3; + if(self->ssl_options & TSO_NOTLSv1) + ssl_options |= SSL_OP_NO_TLSv1; +#ifdef SSL_OP_NO_TLSv1_2 + if(self->ssl_options & TSO_NOTLSv11) + ssl_options |= SSL_OP_NO_TLSv1_1; + if(self->ssl_options & TSO_NOTLSv12) + ssl_options |= SSL_OP_NO_TLSv1_2; +#endif +#ifdef SSL_OP_CIPHER_SERVER_PREFERENCE + if (self->mode == TM_SERVER) + ssl_options |= SSL_OP_CIPHER_SERVER_PREFERENCE; +#endif + SSL_CTX_set_options(self->ssl_ctx, ssl_options); + } + else { - gint verify_mode = 0; - gint verify_flags = X509_V_FLAG_POLICY_CHECK; + msg_debug("empty ssl options"); + } +} - if (self->mode == TM_CLIENT) - self->ssl_ctx = SSL_CTX_new(SSLv23_client_method()); - else - self->ssl_ctx = SSL_CTX_new(SSLv23_server_method()); +static gboolean +_set_optional_ecdh_curve_list(SSL_CTX *ctx, const gchar *ecdh_curve_list) +{ +#if OPENSSL_VERSION_NUMBER >= 0x10002000L + if (ecdh_curve_list && !SSL_CTX_set1_curves_list(ctx, ecdh_curve_list)) + { + msg_error("Error setting up TLS session context, invalid curve name in list", + evt_tag_str("ecdh_curve_list", ecdh_curve_list)); + return FALSE; + } +#endif - if (!self->ssl_ctx) - goto error; - if (file_exists(self->key_file) && !SSL_CTX_use_PrivateKey_file(self->ssl_ctx, self->key_file, SSL_FILETYPE_PEM)) - goto error; + return TRUE; +} - if (file_exists(self->cert_file) && !SSL_CTX_use_certificate_chain_file(self->ssl_ctx, self->cert_file)) - goto error; - if (self->key_file && self->cert_file && !SSL_CTX_check_private_key(self->ssl_ctx)) - goto error; +static gboolean +_is_dh_valid(DH *dh) +{ + if (!dh) + return FALSE; - if (file_exists(self->ca_dir) && !SSL_CTX_load_verify_locations(self->ssl_ctx, NULL, self->ca_dir)) - goto error; + gint check_flags; + if (!DH_check(dh, &check_flags)) + return FALSE; - if (file_exists(self->crl_dir) && !SSL_CTX_load_verify_locations(self->ssl_ctx, NULL, self->crl_dir)) - goto error; + gboolean error_flag_is_set = check_flags & + (DH_CHECK_P_NOT_PRIME + | DH_UNABLE_TO_CHECK_GENERATOR + | DH_CHECK_P_NOT_SAFE_PRIME + | DH_NOT_SUITABLE_GENERATOR); - if (self->crl_dir) - verify_flags |= X509_V_FLAG_CRL_CHECK | X509_V_FLAG_CRL_CHECK_ALL; + return !error_flag_is_set; +} - X509_VERIFY_PARAM_set_flags(SSL_CTX_get0_param(self->ssl_ctx), verify_flags); +static DH * +_load_dh_from_file(const gchar *dhparam_file) +{ + if (!file_exists(dhparam_file)) + return NULL; - switch (self->verify_mode) - { - case TVM_NONE: - verify_mode = SSL_VERIFY_NONE; - break; - case TVM_OPTIONAL | TVM_UNTRUSTED: - verify_mode = SSL_VERIFY_NONE; - break; - case TVM_OPTIONAL | TVM_TRUSTED: - verify_mode = SSL_VERIFY_PEER | SSL_VERIFY_CLIENT_ONCE; - break; - case TVM_REQUIRED | TVM_UNTRUSTED: - verify_mode = SSL_VERIFY_PEER | SSL_VERIFY_CLIENT_ONCE | SSL_VERIFY_FAIL_IF_NO_PEER_CERT; - break; - case TVM_REQUIRED | TVM_TRUSTED: - verify_mode = SSL_VERIFY_PEER | SSL_VERIFY_CLIENT_ONCE | SSL_VERIFY_FAIL_IF_NO_PEER_CERT; - break; - default: - g_assert_not_reached(); - } + BIO *bio = BIO_new_file(dhparam_file, "r"); + if (!bio) + return NULL; - SSL_CTX_set_verify(self->ssl_ctx, verify_mode, tls_session_verify_callback); + DH *dh = PEM_read_bio_DHparams(bio, NULL, NULL, NULL); + BIO_free(bio); - if (self->ssl_options != TSO_NONE) - { - ssl_options=0; - if(self->ssl_options & TSO_NOSSLv2) - ssl_options |= SSL_OP_NO_SSLv2; - if(self->ssl_options & TSO_NOSSLv3) - ssl_options |= SSL_OP_NO_SSLv3; - if(self->ssl_options & TSO_NOTLSv1) - ssl_options |= SSL_OP_NO_TLSv1; -#ifdef SSL_OP_NO_TLSv1_2 - if(self->ssl_options & TSO_NOTLSv11) - ssl_options |= SSL_OP_NO_TLSv1_1; - if(self->ssl_options & TSO_NOTLSv12) - ssl_options |= SSL_OP_NO_TLSv1_2; -#endif -#ifdef SSL_OP_CIPHER_SERVER_PREFERENCE - if (self->mode == TM_SERVER) - ssl_options |= SSL_OP_CIPHER_SERVER_PREFERENCE; -#endif - SSL_CTX_set_options(self->ssl_ctx, ssl_options); - } - else - msg_debug("empty ssl options"); - if (self->cipher_suite) - { - if (!SSL_CTX_set_cipher_list(self->ssl_ctx, self->cipher_suite)) - goto error; - } + if (!_is_dh_valid(dh)) + { + msg_error("Error setting up TLS session context, invalid DH parameters", + evt_tag_str("dhparam_file", dhparam_file), + NULL); + + DH_free(dh); + return NULL; } - ssl = SSL_new(self->ssl_ctx); + return dh; +} - if (self->mode == TM_CLIENT) - SSL_set_connect_state(ssl); +static DH * +_load_dh_fallback(void) +{ + DH *dh = DH_new(); + + if (!dh) + return NULL; + + /* + * "2048-bit MODP Group" from RFC3526, Section 3. + * + * The prime is: 2^2048 - 2^1984 - 1 + 2^64 * { [2^1918 pi] + 124476 } + * + * RFC3526 specifies a generator of 2. + */ + + BIGNUM *g = NULL; + BN_dec2bn(&g, "2"); + + if (!DH_set0_pqg(dh, get_rfc3526_prime_2048(NULL), NULL, g)) + { + BN_free(g); + DH_free(dh); + return NULL; + } + + return dh; +} + +static gboolean +tls_context_setup_ecdh(TLSContext *self) +{ + /* server only */ + if (self->mode != TM_SERVER) + return TRUE; + + if (!_set_optional_ecdh_curve_list(self->ssl_ctx, self->ecdh_curve_list)) + return FALSE; + + openssl_ctx_setup_ecdh(self->ssl_ctx); + + return TRUE; +} + +static gboolean +tls_context_setup_dh(TLSContext *self) +{ + DH *dh = self->dhparam_file ? _load_dh_from_file(self->dhparam_file) : _load_dh_fallback(); + + if (!dh) + return FALSE; + + gboolean ctx_dh_success = SSL_CTX_set_tmp_dh(self->ssl_ctx, dh); + + DH_free(dh); + return ctx_dh_success; +} + +static PKCS12 * +_load_pkcs12_file(const gchar *pkcs12_file) +{ + if (!file_exists(pkcs12_file)) + return NULL; + + FILE *p12_file = fopen(pkcs12_file, "rb"); + + if (!p12_file) + return NULL; + + PKCS12 *pkcs12 = d2i_PKCS12_fp(p12_file, NULL); + fclose(p12_file); + + return pkcs12; +} + +static gboolean +_extract_pkcs12_content(PKCS12 *pkcs12, EVP_PKEY **private_key, X509 **cert, STACK_OF(X509) **ca_list) +{ + return PKCS12_parse(pkcs12, "", private_key, cert, ca_list); +} + +static gboolean +tls_context_add_certs(TLSContext *self, STACK_OF(X509) *ca_list) +{ + for (gint ca_index = 0; ca_index < sk_X509_num(ca_list); ++ca_index) + { + X509 *current_ca = sk_X509_value(ca_list, ca_index); + + if (!X509_STORE_add_cert(SSL_CTX_get_cert_store(self->ssl_ctx), current_ca)) + return FALSE; + if (self->mode == TM_SERVER && !SSL_CTX_add_client_CA(self->ssl_ctx, current_ca)) + return FALSE; + } + + return TRUE; +} + +static gboolean +tls_context_load_pkcs12(TLSContext *self) +{ + PKCS12 *pkcs12 = _load_pkcs12_file(self->pkcs12_file); + + if (!pkcs12) + return FALSE; + + EVP_PKEY *private_key; + X509 *cert; + STACK_OF(X509) *ca_list = NULL; + + if (!_extract_pkcs12_content(pkcs12, &private_key, &cert, &ca_list)) + { + PKCS12_free(pkcs12); + return FALSE; + } + + PKCS12_free(pkcs12); + + if (ca_list && !tls_context_add_certs(self, ca_list)) + return FALSE; + + return SSL_CTX_use_certificate(self->ssl_ctx, cert) + && SSL_CTX_use_PrivateKey(self->ssl_ctx, private_key) + && SSL_CTX_check_private_key(self->ssl_ctx); +} + +static gboolean +tls_context_load_key_and_cert(TLSContext *self) +{ + if (file_exists(self->key_file) && !SSL_CTX_use_PrivateKey_file(self->ssl_ctx, self->key_file, SSL_FILETYPE_PEM)) + return FALSE; + if (file_exists(self->cert_file) && !SSL_CTX_use_certificate_chain_file(self->ssl_ctx, self->cert_file)) + return FALSE; + if (self->key_file && self->cert_file && !SSL_CTX_check_private_key(self->ssl_ctx)) + return FALSE; + + return TRUE; +} + +gboolean +tls_context_setup_context(TLSContext *self) +{ + gint verify_flags = X509_V_FLAG_POLICY_CHECK; + + if (!self->ssl_ctx) + goto error; + + if (self->pkcs12_file) + { + if (self->cert_file || self->key_file) + msg_warning("WARNING: pkcs12-file() is specified, key-file() and cert-file() will be omitted"); + + if (!tls_context_load_pkcs12(self)) + goto error; + } else - SSL_set_accept_state(ssl); + { + if (!tls_context_load_key_and_cert(self)) + goto error; + } - session = tls_session_new(ssl, self); - SSL_set_app_data(ssl, session); - return session; + if (file_exists(self->ca_dir) && !SSL_CTX_load_verify_locations(self->ssl_ctx, NULL, self->ca_dir)) + goto error; + + if (file_exists(self->crl_dir) && !SSL_CTX_load_verify_locations(self->ssl_ctx, NULL, self->crl_dir)) + goto error; + + if (self->crl_dir) + verify_flags |= X509_V_FLAG_CRL_CHECK | X509_V_FLAG_CRL_CHECK_ALL; + + X509_VERIFY_PARAM_set_flags(SSL_CTX_get0_param(self->ssl_ctx), verify_flags); + + tls_context_setup_verify_mode(self); + tls_context_setup_ssl_options(self); + if (!tls_context_setup_ecdh(self)) + { + SSL_CTX_free(self->ssl_ctx); + self->ssl_ctx = NULL; + return FALSE; + } + + if (!tls_context_setup_dh(self)) + goto error; + + if (self->cipher_suite) + { + if (!SSL_CTX_set_cipher_list(self->ssl_ctx, self->cipher_suite)) + goto error; + } + + return TRUE; error: - ssl_error = ERR_get_error(); - msg_error("Error setting up TLS session context", - evt_tag_printf("tls_error", "%s:%s:%s", ERR_lib_error_string(ssl_error), ERR_func_error_string(ssl_error), - ERR_reason_error_string(ssl_error))); - ERR_clear_error(); + _print_and_clear_tls_session_error(); if (self->ssl_ctx) { SSL_CTX_free(self->ssl_ctx); self->ssl_ctx = NULL; } - return NULL; + return FALSE; +} + +TLSSession * +tls_context_setup_session(TLSContext *self) +{ + if (!self->ssl_ctx) + return NULL; + + SSL *ssl = SSL_new(self->ssl_ctx); + + if (self->mode == TM_CLIENT) + SSL_set_connect_state(ssl); + else + SSL_set_accept_state(ssl); + + TLSSession *session = tls_session_new(ssl, self); + SSL_set_app_data(ssl, session); + return session; } TLSContext * @@ -430,6 +685,12 @@ self->mode = mode; self->verify_mode = TVM_REQUIRED | TVM_TRUSTED; self->ssl_options = TSO_NOSSLv2; + + if (self->mode == TM_CLIENT) + self->ssl_ctx = SSL_CTX_new(SSLv23_client_method()); + else + self->ssl_ctx = SSL_CTX_new(SSLv23_server_method()); + return self; } @@ -440,55 +701,127 @@ g_list_foreach(self->trusted_fingerpint_list, (GFunc) g_free, NULL); g_list_foreach(self->trusted_dn_list, (GFunc) g_free, NULL); g_free(self->key_file); + g_free(self->pkcs12_file); g_free(self->cert_file); + g_free(self->dhparam_file); g_free(self->ca_dir); g_free(self->crl_dir); g_free(self->cipher_suite); + g_free(self->ecdh_curve_list); g_free(self); } -TLSVerifyMode -tls_lookup_verify_mode(const gchar *mode_str) +gboolean +tls_context_set_verify_mode_by_name(TLSContext *self, const gchar *mode_str) { if (strcasecmp(mode_str, "none") == 0) - return TVM_NONE; + self->verify_mode = TVM_NONE; else if (strcasecmp(mode_str, "optional-trusted") == 0 || strcasecmp(mode_str, "optional_trusted") == 0) - return TVM_OPTIONAL | TVM_TRUSTED; + self->verify_mode = TVM_OPTIONAL | TVM_TRUSTED; else if (strcasecmp(mode_str, "optional-untrusted") == 0 || strcasecmp(mode_str, "optional_untrusted") == 0) - return TVM_OPTIONAL | TVM_UNTRUSTED; + self->verify_mode = TVM_OPTIONAL | TVM_UNTRUSTED; else if (strcasecmp(mode_str, "required-trusted") == 0 || strcasecmp(mode_str, "required_trusted") == 0) - return TVM_REQUIRED | TVM_TRUSTED; + self->verify_mode = TVM_REQUIRED | TVM_TRUSTED; else if (strcasecmp(mode_str, "required-untrusted") == 0 || strcasecmp(mode_str, "required_untrusted") == 0) - return TVM_REQUIRED | TVM_UNTRUSTED; + self->verify_mode = TVM_REQUIRED | TVM_UNTRUSTED; + else + return FALSE; - return TVM_REQUIRED | TVM_TRUSTED; + return TRUE; } -gint -tls_lookup_options(GList *options) +gboolean +tls_context_set_ssl_options_by_name(TLSContext *self, GList *options) { - gint ret=TSO_NONE; + self->ssl_options = TSO_NONE; + GList *l; for (l=options; l != NULL; l=l->next) { - msg_debug("ssl-option", evt_tag_str("opt", l->data)); if (strcasecmp(l->data, "no-sslv2") == 0 || strcasecmp(l->data, "no_sslv2") == 0) - ret|=TSO_NOSSLv2; + self->ssl_options |= TSO_NOSSLv2; else if (strcasecmp(l->data, "no-sslv3") == 0 || strcasecmp(l->data, "no_sslv3") == 0) - ret|=TSO_NOSSLv3; + self->ssl_options |= TSO_NOSSLv3; else if (strcasecmp(l->data, "no-tlsv1") == 0 || strcasecmp(l->data, "no_tlsv1") == 0) - ret|=TSO_NOTLSv1; + self->ssl_options |= TSO_NOTLSv1; #ifdef SSL_OP_NO_TLSv1_2 else if (strcasecmp(l->data, "no-tlsv11") == 0 || strcasecmp(l->data, "no_tlsv11") == 0) - ret|=TSO_NOTLSv11; + self->ssl_options |= TSO_NOTLSv11; else if (strcasecmp(l->data, "no-tlsv12") == 0 || strcasecmp(l->data, "no_tlsv12") == 0) - ret|=TSO_NOTLSv12; + self->ssl_options |= TSO_NOTLSv12; #endif else - msg_error("Unknown ssl-option", evt_tag_str("option", l->data)); + return FALSE; } - msg_debug("ssl-options parsed", evt_tag_printf("parsed value", "%d", ret)); - return ret; + + return TRUE; +} + +gint +tls_context_get_verify_mode(const TLSContext *self) +{ + return self->verify_mode; +} + +void tls_context_set_verify_mode(TLSContext *self, gint verify_mode) +{ + self->verify_mode = verify_mode; +} + +void +tls_context_set_key_file(TLSContext *self, const gchar *key_file) +{ + g_free(self->key_file); + self->key_file = g_strdup(key_file); +} + +void +tls_context_set_cert_file(TLSContext *self, const gchar *cert_file) +{ + g_free(self->cert_file); + self->cert_file = g_strdup(cert_file); +} + +void +tls_context_set_pkcs12_file(TLSContext *self, const gchar *pkcs12_file) +{ + g_free(self->pkcs12_file); + self->pkcs12_file = g_strdup(pkcs12_file); +} + +void +tls_context_set_ca_dir(TLSContext *self, const gchar *ca_dir) +{ + g_free(self->ca_dir); + self->ca_dir = g_strdup(ca_dir); +} + +void +tls_context_set_crl_dir(TLSContext *self, const gchar *crl_dir) +{ + g_free(self->crl_dir); + self->crl_dir = g_strdup(crl_dir); +} + +void +tls_context_set_cipher_suite(TLSContext *self, const gchar *cipher_suite) +{ + g_free(self->cipher_suite); + self->cipher_suite = g_strdup(cipher_suite); +} + +void +tls_context_set_ecdh_curve_list(TLSContext *self, const gchar *ecdh_curve_list) +{ + g_free(self->ecdh_curve_list); + self->ecdh_curve_list = g_strdup(ecdh_curve_list); +} + +void +tls_context_set_dhparam_file(TLSContext *self, const gchar *dhparam_file) +{ + g_free(self->dhparam_file); + self->dhparam_file = g_strdup(dhparam_file); } void diff -Nru syslog-ng-3.11.1/lib/tlscontext.h syslog-ng-3.13.2/lib/tlscontext.h --- syslog-ng-3.11.1/lib/tlscontext.h 2017-07-31 09:05:32.000000000 +0000 +++ syslog-ng-3.13.2/lib/tlscontext.h 2017-12-06 06:39:39.000000000 +0000 @@ -80,30 +80,26 @@ void tls_session_set_verify(TLSSession *self, TLSSessionVerifyFunc verify_func, gpointer verify_data, GDestroyNotify verify_destroy); void tls_session_free(TLSSession *self); -struct _TLSContext -{ - TLSMode mode; - gint verify_mode; - gchar *key_file; - gchar *cert_file; - gchar *ca_dir; - gchar *crl_dir; - gchar *cipher_suite; - SSL_CTX *ssl_ctx; - GList *trusted_fingerpint_list; - GList *trusted_dn_list; - gint ssl_options; -}; - - +gboolean tls_context_setup_context(TLSContext *self); TLSSession *tls_context_setup_session(TLSContext *self); void tls_session_set_trusted_fingerprints(TLSContext *self, GList *fingerprints); void tls_session_set_trusted_dn(TLSContext *self, GList *dns); + TLSContext *tls_context_new(TLSMode mode); void tls_context_free(TLSContext *s); -TLSVerifyMode tls_lookup_verify_mode(const gchar *mode_str); -gint tls_lookup_options(GList *options); +gboolean tls_context_set_verify_mode_by_name(TLSContext *self, const gchar *mode_str); +gboolean tls_context_set_ssl_options_by_name(TLSContext *self, GList *options); +gint tls_context_get_verify_mode(const TLSContext *self); +void tls_context_set_verify_mode(TLSContext *self, gint verify_mode); +void tls_context_set_key_file(TLSContext *self, const gchar *key_file); +void tls_context_set_cert_file(TLSContext *self, const gchar *cert_file); +void tls_context_set_pkcs12_file(TLSContext *self, const gchar *pkcs12_file); +void tls_context_set_ca_dir(TLSContext *self, const gchar *ca_dir); +void tls_context_set_crl_dir(TLSContext *self, const gchar *crl_dir); +void tls_context_set_cipher_suite(TLSContext *self, const gchar *cipher_suite); +void tls_context_set_ecdh_curve_list(TLSContext *self, const gchar *ecdh_curve_list); +void tls_context_set_dhparam_file(TLSContext *self, const gchar *dhparam_file); void tls_log_certificate_validation_progress(int ok, X509_STORE_CTX *ctx); gboolean tls_verify_certificate_name(X509 *cert, const gchar *hostname); diff -Nru syslog-ng-3.11.1/lib/transport/CMakeLists.txt syslog-ng-3.13.2/lib/transport/CMakeLists.txt --- syslog-ng-3.11.1/lib/transport/CMakeLists.txt 2017-07-31 09:05:32.000000000 +0000 +++ syslog-ng-3.13.2/lib/transport/CMakeLists.txt 2017-12-06 06:39:39.000000000 +0000 @@ -4,7 +4,6 @@ transport/transport-tls.h transport/transport-file.h transport/transport-pipe.h - transport/transport-device.h transport/transport-socket.h PARENT_SCOPE) @@ -13,7 +12,6 @@ transport/transport-aux-data.c transport/transport-file.c transport/transport-pipe.c - transport/transport-device.c transport/transport-socket.c transport/transport-tls.c PARENT_SCOPE) diff -Nru syslog-ng-3.11.1/lib/transport/Makefile.am syslog-ng-3.13.2/lib/transport/Makefile.am --- syslog-ng-3.11.1/lib/transport/Makefile.am 2017-07-31 09:05:32.000000000 +0000 +++ syslog-ng-3.13.2/lib/transport/Makefile.am 2017-12-06 06:39:39.000000000 +0000 @@ -6,7 +6,6 @@ lib/transport/transport-tls.h \ lib/transport/transport-file.h \ lib/transport/transport-pipe.h \ - lib/transport/transport-device.h \ lib/transport/transport-socket.h transport_sources = \ @@ -14,7 +13,6 @@ lib/transport/transport-aux-data.c \ lib/transport/transport-file.c \ lib/transport/transport-pipe.c \ - lib/transport/transport-device.c \ lib/transport/transport-socket.c transport_crypto_sources = \ diff -Nru syslog-ng-3.11.1/lib/transport/tests/test_aux_data.c syslog-ng-3.13.2/lib/transport/tests/test_aux_data.c --- syslog-ng-3.11.1/lib/transport/tests/test_aux_data.c 2017-07-31 09:05:32.000000000 +0000 +++ syslog-ng-3.13.2/lib/transport/tests/test_aux_data.c 2017-12-06 06:39:39.000000000 +0000 @@ -171,7 +171,7 @@ AUX_DATA_TESTCASE(test_add_nv_pair_to_a_NULL_aux_data_will_do_nothing); } -int main() +int main(void) { test_aux_data(); return 0; diff -Nru syslog-ng-3.11.1/lib/transport/transport-device.c syslog-ng-3.13.2/lib/transport/transport-device.c --- syslog-ng-3.11.1/lib/transport/transport-device.c 2017-07-31 09:05:32.000000000 +0000 +++ syslog-ng-3.13.2/lib/transport/transport-device.c 1970-01-01 00:00:00.000000000 +0000 @@ -1,77 +0,0 @@ -/* - * Copyright (c) 2002-2013 Balabit - * Copyright (c) 1998-2013 Balázs Scheidler - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - * - * As an additional exemption you are allowed to compile & link against the - * OpenSSL libraries as published by the OpenSSL project. See the file - * COPYING for details. - * - */ - -#include "transport/transport-device.h" -#include "messages.h" -#include "alarms.h" - -#include -#include - -typedef struct _LogTransportDevice LogTransportDevice; -struct _LogTransportDevice -{ - LogTransport super; - gint timeout; -}; - -static gssize -log_transport_device_read_method(LogTransport *s, gpointer buf, gsize buflen, LogTransportAuxData *aux) -{ - LogTransportDevice *self = (LogTransportDevice *) s; - gint rc; - - do - { - if (self->timeout) - alarm_set(self->timeout); - rc = read(self->super.fd, buf, buflen); - - if (self->timeout > 0 && rc == -1 && errno == EINTR && alarm_has_fired()) - { - msg_notice("Nonblocking read has blocked, returning with an error", - evt_tag_int("fd", self->super.fd), - evt_tag_int("timeout", self->timeout)); - alarm_cancel(); - break; - } - if (self->timeout) - alarm_cancel(); - } - while (rc == -1 && errno == EINTR); - return rc; -} - -LogTransport * -log_transport_device_new(gint fd, gint timeout) -{ - LogTransportDevice *self = g_new0(LogTransportDevice, 1); - - log_transport_init_instance(&self->super, fd); - self->timeout = timeout; - self->super.read = log_transport_device_read_method; - self->super.write = NULL; - self->super.free_fn = log_transport_free_method; - return &self->super; -} diff -Nru syslog-ng-3.11.1/lib/transport/transport-device.h syslog-ng-3.13.2/lib/transport/transport-device.h --- syslog-ng-3.11.1/lib/transport/transport-device.h 2017-07-31 09:05:32.000000000 +0000 +++ syslog-ng-3.13.2/lib/transport/transport-device.h 1970-01-01 00:00:00.000000000 +0000 @@ -1,32 +0,0 @@ -/* - * Copyright (c) 2002-2013 Balabit - * Copyright (c) 1998-2013 Balázs Scheidler - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - * - * As an additional exemption you are allowed to compile & link against the - * OpenSSL libraries as published by the OpenSSL project. See the file - * COPYING for details. - * - */ - -#ifndef TRANSPORT_TRANSPORT_DEVICE_H_INCLUDED -#define TRANSPORT_TRANSPORT_DEVICE_H_INCLUDED 1 - -#include "logtransport.h" - -LogTransport *log_transport_device_new(gint fd, gint timeout); - -#endif diff -Nru syslog-ng-3.11.1/lib/transport/transport-file.c syslog-ng-3.13.2/lib/transport/transport-file.c --- syslog-ng-3.11.1/lib/transport/transport-file.c 2017-07-31 09:05:32.000000000 +0000 +++ syslog-ng-3.13.2/lib/transport/transport-file.c 2017-12-06 06:39:39.000000000 +0000 @@ -26,36 +26,41 @@ #include #include -static gssize -log_transport_file_read_method(LogTransport *s, gpointer buf, gsize buflen, LogTransportAuxData *aux) +gssize +log_transport_file_read_method(LogTransport *self, gpointer buf, gsize buflen, LogTransportAuxData *aux) { - LogTransportFile *self = (LogTransportFile *) s; gint rc; do { - rc = read(self->super.fd, buf, buflen); + rc = read(self->fd, buf, buflen); } while (rc == -1 && errno == EINTR); + return rc; +} + +gssize +log_transport_file_read_and_ignore_eof_method(LogTransport *self, gpointer buf, gsize buflen, LogTransportAuxData *aux) +{ + gint rc; + rc = log_transport_file_read_method(self, buf, buflen, aux); if (rc == 0) { - /* regular files should never return EOF, they just need to be read again */ rc = -1; errno = EAGAIN; } return rc; } -static gssize -log_transport_file_write_method(LogTransport *s, const gpointer buf, gsize buflen) +gssize +log_transport_file_write_method(LogTransport *self, const gpointer buf, gsize buflen) { - LogTransportFile *self = (LogTransportFile *) s; gint rc; do { - rc = write(self->super.fd, buf, buflen); + rc = write(self->fd, buf, buflen); } while (rc == -1 && errno == EINTR); return rc; @@ -70,7 +75,6 @@ self->super.free_fn = log_transport_free_method; } -/* regular files */ LogTransport * log_transport_file_new(gint fd) { diff -Nru syslog-ng-3.11.1/lib/transport/transport-file.h syslog-ng-3.13.2/lib/transport/transport-file.h --- syslog-ng-3.11.1/lib/transport/transport-file.h 2017-07-31 09:05:32.000000000 +0000 +++ syslog-ng-3.13.2/lib/transport/transport-file.h 2017-12-06 06:39:39.000000000 +0000 @@ -34,6 +34,10 @@ LogTransport super; }; +gssize log_transport_file_read_method(LogTransport *self, gpointer buf, gsize buflen, LogTransportAuxData *aux); +gssize log_transport_file_read_and_ignore_eof_method(LogTransport *self, gpointer buf, gsize buflen, LogTransportAuxData *aux); +gssize log_transport_file_write_method(LogTransport *self, const gpointer buf, gsize buflen); + void log_transport_file_init_instance(LogTransportFile *self, gint fd); LogTransport *log_transport_file_new(gint fd); diff -Nru syslog-ng-3.11.1/lib/transport/transport-pipe.c syslog-ng-3.13.2/lib/transport/transport-pipe.c --- syslog-ng-3.11.1/lib/transport/transport-pipe.c 2017-07-31 09:05:32.000000000 +0000 +++ syslog-ng-3.13.2/lib/transport/transport-pipe.c 2017-12-06 06:39:39.000000000 +0000 @@ -27,7 +27,7 @@ #include #include -static gssize +gssize log_transport_pipe_write_method(LogTransport *s, const gpointer buf, gsize buflen) { LogTransportFile *self = (LogTransportFile *) s; diff -Nru syslog-ng-3.11.1/lib/transport/transport-pipe.h syslog-ng-3.13.2/lib/transport/transport-pipe.h --- syslog-ng-3.11.1/lib/transport/transport-pipe.h 2017-07-31 09:05:32.000000000 +0000 +++ syslog-ng-3.13.2/lib/transport/transport-pipe.h 2017-12-06 06:39:39.000000000 +0000 @@ -27,6 +27,7 @@ #include "logtransport.h" +gssize log_transport_pipe_write_method(LogTransport *s, const gpointer buf, gsize buflen); LogTransport *log_transport_pipe_new(gint fd); #endif diff -Nru syslog-ng-3.11.1/lib/type-hinting.c syslog-ng-3.13.2/lib/type-hinting.c --- syslog-ng-3.11.1/lib/type-hinting.c 2017-07-31 09:05:32.000000000 +0000 +++ syslog-ng-3.13.2/lib/type-hinting.c 2017-12-06 06:39:39.000000000 +0000 @@ -32,7 +32,7 @@ #include GQuark -type_hinting_error_quark() +type_hinting_error_quark(void) { return g_quark_from_static_string("type-hinting-error-quark"); } diff -Nru syslog-ng-3.11.1/lib/value-pairs/cmdline.c syslog-ng-3.13.2/lib/value-pairs/cmdline.c --- syslog-ng-3.11.1/lib/value-pairs/cmdline.c 2017-07-31 09:05:32.000000000 +0000 +++ syslog-ng-3.13.2/lib/value-pairs/cmdline.c 2017-12-06 06:39:39.000000000 +0000 @@ -347,7 +347,8 @@ ValuePairs * value_pairs_new_from_cmdline (GlobalConfig *cfg, - gint argc, gchar **argv, + gint *argc, gchar ***argv, + gboolean ignore_unknown_options, GError **error) { ValuePairs *vp; @@ -411,18 +412,19 @@ user_data_args[2] = NULL; user_data_args[3] = NULL; - ctx = g_option_context_new ("value-pairs"); - og = g_option_group_new (NULL, NULL, NULL, user_data_args, NULL); - g_option_group_add_entries (og, vp_options); - g_option_context_set_main_group (ctx, og); - - success = g_option_context_parse (ctx, &argc, &argv, error); - vp_cmdline_parse_rekey_finish (user_data_args); - g_option_context_free (ctx); + ctx = g_option_context_new("value-pairs"); + og = g_option_group_new(NULL, NULL, NULL, user_data_args, NULL); + g_option_group_add_entries(og, vp_options); + g_option_context_set_main_group(ctx, og); + g_option_context_set_ignore_unknown_options(ctx, ignore_unknown_options); + + success = g_option_context_parse(ctx, argc, argv, error); + vp_cmdline_parse_rekey_finish(user_data_args); + g_option_context_free(ctx); if (!success) { - value_pairs_unref (vp); + value_pairs_unref(vp); vp = NULL; } diff -Nru syslog-ng-3.11.1/lib/value-pairs/cmdline.h syslog-ng-3.13.2/lib/value-pairs/cmdline.h --- syslog-ng-3.11.1/lib/value-pairs/cmdline.h 2017-07-31 09:05:32.000000000 +0000 +++ syslog-ng-3.13.2/lib/value-pairs/cmdline.h 2017-12-06 06:39:39.000000000 +0000 @@ -27,7 +27,8 @@ #include "value-pairs/value-pairs.h" ValuePairs *value_pairs_new_from_cmdline(GlobalConfig *cfg, - gint argc, gchar **argv, + gint *argc, gchar ***argv, + gboolean ignore_unknown_options, GError **error); #endif diff -Nru syslog-ng-3.11.1/lib/value-pairs/tests/test_value_pairs.c syslog-ng-3.13.2/lib/value-pairs/tests/test_value_pairs.c --- syslog-ng-3.11.1/lib/value-pairs/tests/test_value_pairs.c 2017-07-31 09:05:32.000000000 +0000 +++ syslog-ng-3.13.2/lib/value-pairs/tests/test_value_pairs.c 2017-12-06 06:39:39.000000000 +0000 @@ -151,8 +151,8 @@ putenv("TZ=MET-1METDST"); tzset(); - cfg = cfg_new_snippet(VERSION_VALUE); - plugin_load_module("syslogformat", cfg, NULL); + cfg = cfg_new_snippet(); + cfg_load_module(cfg, "syslogformat"); msg_format_options_defaults(&parse_options); msg_format_options_init(&parse_options, cfg); parse_options.flags |= LP_SYSLOG_PROTOCOL; diff -Nru syslog-ng-3.11.1/lib/value-pairs/tests/test_value_pairs_walk.c syslog-ng-3.13.2/lib/value-pairs/tests/test_value_pairs_walk.c --- syslog-ng-3.11.1/lib/value-pairs/tests/test_value_pairs_walk.c 2017-07-31 09:05:32.000000000 +0000 +++ syslog-ng-3.13.2/lib/value-pairs/tests/test_value_pairs_walk.c 2017-12-06 06:39:39.000000000 +0000 @@ -128,12 +128,12 @@ log_msg_unref(msg); }; -int main() +int main(void) { app_startup(); - configuration = cfg_new_snippet(0x0303); - plugin_load_module("syslogformat", configuration, NULL); + configuration = cfg_new_snippet(); + cfg_load_module(configuration, "syslogformat"); msg_format_options_defaults(&parse_options); msg_format_options_init(&parse_options, configuration); diff -Nru syslog-ng-3.11.1/lib/value-pairs/value-pairs.c syslog-ng-3.13.2/lib/value-pairs/value-pairs.c --- syslog-ng-3.11.1/lib/value-pairs/value-pairs.c 2017-07-31 09:05:32.000000000 +0000 +++ syslog-ng-3.13.2/lib/value-pairs/value-pairs.c 2017-12-06 06:39:39.000000000 +0000 @@ -664,13 +664,18 @@ token_end = vp_walker_skip_sdata_enterprise_id(token_end); break; case '.': - g_ptr_array_add(array, g_strndup(token_start, token_end - token_start)); - ++token_end; - token_start = token_end; - break; + if (token_start != token_end) + { + g_ptr_array_add(array, g_strndup(token_start, token_end - token_start)); + ++token_end; + token_start = token_end; + break; + } + /* fall through, zero length token is not considered a separate token */ default: ++token_end; token_end += strcspn(token_end, "@."); + break; } } @@ -986,4 +991,5 @@ void value_pairs_global_deinit(void) { + g_free(all_macros); } diff -Nru syslog-ng-3.11.1/lib/versioning.h syslog-ng-3.13.2/lib/versioning.h --- syslog-ng-3.11.1/lib/versioning.h 2017-07-31 09:05:32.000000000 +0000 +++ syslog-ng-3.13.2/lib/versioning.h 2017-12-06 06:39:39.000000000 +0000 @@ -91,6 +91,9 @@ * should reference the syslog-ng version number through these macros, in order * to make it relatively simple to explain PE/OSE version numbers to users. */ +#define PRODUCT_NAME "syslog-ng-ose" +#define PRODUCT_CONTACT "https://lists.balabit.hu/mailman/listinfo/syslog-ng" + #define VERSION_3_0 "syslog-ng 3.0" #define VERSION_3_1 "syslog-ng 3.1" #define VERSION_3_2 "syslog-ng 3.2" @@ -103,6 +106,8 @@ #define VERSION_3_9 "syslog-ng 3.9" #define VERSION_3_10 "syslog-ng 3.10" #define VERSION_3_11 "syslog-ng 3.11" +#define VERSION_3_12 "syslog-ng 3.12" +#define VERSION_3_13 "syslog-ng 3.13" #define VERSION_VALUE_3_0 0x0300 #define VERSION_VALUE_3_1 0x0301 @@ -116,11 +121,13 @@ #define VERSION_VALUE_3_9 0x0309 #define VERSION_VALUE_3_10 0x030a #define VERSION_VALUE_3_11 0x030b +#define VERSION_VALUE_3_12 0x030c +#define VERSION_VALUE_3_13 0x030d /* config version code, in the same format as GlobalConfig->version */ -#define VERSION_VALUE 0x030b -#define VERSION_CURRENT VERSION_3_11 -#define VERSION_CURRENT_VER_ONLY "3.11" +#define VERSION_VALUE 0x030d +#define VERSION_CURRENT VERSION_3_13 +#define VERSION_CURRENT_VER_ONLY "3.13" #define version_convert_from_user(v) (v) diff -Nru syslog-ng-3.11.1/libtest/config_parse_lib.c syslog-ng-3.13.2/libtest/config_parse_lib.c --- syslog-ng-3.11.1/libtest/config_parse_lib.c 2017-07-31 09:05:32.000000000 +0000 +++ syslog-ng-3.13.2/libtest/config_parse_lib.c 2017-12-06 06:39:39.000000000 +0000 @@ -69,7 +69,7 @@ return NULL; } - lexer = cfg_lexer_new_buffer(delimited[1], strlen(delimited[1])); + lexer = cfg_lexer_new_buffer(configuration, delimited[1], strlen(delimited[1])); if (!lexer) { fprintf(stderr, "Error parsing expression\n"); @@ -83,7 +83,7 @@ yylloc->last_line = 1; yylloc->level = &lexer->include_stack[0]; - plugin = plugin_find(configuration, context, delimited[0]); + plugin = cfg_find_plugin(configuration, context, delimited[0]); if (!plugin) { fprintf(stderr, "Error parsing expression\n"); @@ -94,7 +94,7 @@ cfg_set_global_paths(configuration); cfg_lexer_push_context(lexer, main_parser.context, main_parser.keywords, main_parser.name); - result = plugin_parse_config(plugin, configuration, yylloc, arg); + result = cfg_parse_plugin(configuration, plugin, yylloc, arg); cfg_lexer_pop_context(lexer); if (!result) @@ -116,7 +116,7 @@ parse_general_config(const gchar *config_to_parse, gint context, gpointer arg) { gpointer result = NULL; - CfgLexer *lexer = cfg_lexer_new_buffer(config_to_parse, strlen(config_to_parse)); + CfgLexer *lexer = cfg_lexer_new_buffer(configuration, config_to_parse, strlen(config_to_parse)); if (!cfg_run_parser(configuration, lexer, &main_parser, &result, arg)) { diff -Nru syslog-ng-3.11.1/libtest/libtest.c syslog-ng-3.13.2/libtest/libtest.c --- syslog-ng-3.11.1/libtest/libtest.c 2017-07-31 09:05:32.000000000 +0000 +++ syslog-ng-3.13.2/libtest/libtest.c 2017-12-06 06:39:39.000000000 +0000 @@ -29,7 +29,7 @@ } void -main_loop_wakeup() +main_loop_wakeup(void) { ; } diff -Nru syslog-ng-3.11.1/libtest/msg_parse_lib.c syslog-ng-3.13.2/libtest/msg_parse_lib.c --- syslog-ng-3.11.1/libtest/msg_parse_lib.c 2017-07-31 09:05:32.000000000 +0000 +++ syslog-ng-3.13.2/libtest/msg_parse_lib.c 2017-12-06 06:39:39.000000000 +0000 @@ -26,16 +26,16 @@ #include "plugin.h" void -init_and_load_syslogformat_module() +init_and_load_syslogformat_module(void) { - configuration = cfg_new_snippet(VERSION_VALUE); - plugin_load_module("syslogformat", configuration, NULL); + configuration = cfg_new_snippet(); + cfg_load_module(configuration, "syslogformat"); msg_format_options_defaults(&parse_options); msg_format_options_init(&parse_options, configuration); } void -deinit_syslogformat_module() +deinit_syslogformat_module(void) { if (configuration) cfg_free(configuration); diff -Nru syslog-ng-3.11.1/libtest/msg_parse_lib.h syslog-ng-3.13.2/libtest/msg_parse_lib.h --- syslog-ng-3.11.1/libtest/msg_parse_lib.h 2017-07-31 09:05:32.000000000 +0000 +++ syslog-ng-3.13.2/libtest/msg_parse_lib.h 2017-12-06 06:39:39.000000000 +0000 @@ -49,8 +49,8 @@ while (0) -void init_and_load_syslogformat_module(); -void deinit_syslogformat_module(); +void init_and_load_syslogformat_module(void); +void deinit_syslogformat_module(void); void assert_log_messages_equal(LogMessage *log_message_a, LogMessage *log_message_b); diff -Nru syslog-ng-3.11.1/libtest/proto_lib.c syslog-ng-3.13.2/libtest/proto_lib.c --- syslog-ng-3.11.1/libtest/proto_lib.c 2017-07-31 09:05:32.000000000 +0000 +++ syslog-ng-3.13.2/libtest/proto_lib.c 2017-12-06 06:39:39.000000000 +0000 @@ -69,7 +69,7 @@ LogProtoServerFactory *proto_factory; log_proto_server_options_init(&proto_server_options, configuration); - proto_factory = log_proto_server_get_factory(configuration, name); + proto_factory = log_proto_server_get_factory(&configuration->plugin_context, name); assert_true(proto_factory != NULL, "error looking up proto factory"); return log_proto_server_factory_construct(proto_factory, transport, &proto_server_options); } diff -Nru syslog-ng-3.11.1/libtest/stopwatch.h syslog-ng-3.13.2/libtest/stopwatch.h --- syslog-ng-3.11.1/libtest/stopwatch.h 2017-07-31 09:05:32.000000000 +0000 +++ syslog-ng-3.13.2/libtest/stopwatch.h 2017-12-06 06:39:39.000000000 +0000 @@ -28,7 +28,7 @@ #include -void start_stopwatch(); +void start_stopwatch(void); void stop_stopwatch_and_display_result(gint iterations, gchar *message_template, ...); #endif diff -Nru syslog-ng-3.11.1/libtest/template_lib.c syslog-ng-3.13.2/libtest/template_lib.c --- syslog-ng-3.11.1/libtest/template_lib.c 2017-07-31 09:05:32.000000000 +0000 +++ syslog-ng-3.13.2/libtest/template_lib.c 2017-12-06 06:39:39.000000000 +0000 @@ -82,6 +82,7 @@ log_msg_set_tag_by_name(msg, "korte"); log_msg_clear_tag_by_name(msg, "narancs"); log_msg_set_tag_by_name(msg, "citrom"); + log_msg_set_tag_by_name(msg, "tag,containing,comma"); msg->rcptid = 555; msg->host_id = 0xcafebabe; @@ -145,49 +146,63 @@ } void -assert_template_format(const gchar *template, const gchar *expected) +assert_template_format_with_escaping_and_context_msgs(const gchar *template, gboolean escaping, + const gchar *expected, gssize expected_len, + LogMessage **msgs, gint num_messages) { - assert_template_format_with_escaping(template, FALSE, expected); + LogTemplate *templ = compile_template(template, escaping); + if (!templ) + return; + + GString *res = g_string_sized_new(128); + const gchar *context_id = "test-context-id"; + + log_template_format_with_context(templ, msgs, num_messages, NULL, LTZ_LOCAL, 999, context_id, res); + expect_nstring(res->str, res->len, + expected, expected_len >= 0 ? expected_len : strlen(expected), + "context template test failed, template=%s", template); + log_template_unref(templ); + g_string_free(res, TRUE); } void -assert_template_format_msg(const gchar *template, const gchar *expected, - LogMessage *msg) +assert_template_format_with_context_msgs(const gchar *template, const gchar *expected, LogMessage **msgs, + gint num_messages) { - assert_template_format_with_escaping_msg(template, FALSE, expected, msg); + assert_template_format_with_escaping_and_context_msgs(template, FALSE, expected, -1, msgs, num_messages); } void assert_template_format_with_escaping_msg(const gchar *template, gboolean escaping, - const gchar *expected, LogMessage *msg) + const gchar *expected, + LogMessage *msg) { - LogTemplate *templ = compile_template(template, escaping); - if (!templ) - return; - - GString *res = g_string_sized_new(128); - const gchar *context_id = "test-context-id"; - - log_template_format(templ, msg, NULL, LTZ_LOCAL, 999, context_id, res); - expect_nstring(res->str, res->len, expected, strlen(expected), - "template test failed, template=%s", template); - log_template_unref(templ); - g_string_free(res, TRUE); + assert_template_format_with_escaping_and_context_msgs(template, escaping, expected, -1, &msg, 1); } void -assert_template_format_with_escaping(const gchar *template, gboolean escaping, - const gchar *expected) +assert_template_format_with_escaping(const gchar *template, gboolean escaping, const gchar *expected) { LogMessage *msg = create_sample_message(); assert_template_format_with_escaping_msg(template, escaping, expected, msg); - log_msg_unref(msg); } void +assert_template_format_msg(const gchar *template, const gchar *expected, LogMessage *msg) +{ + assert_template_format_with_escaping_msg(template, FALSE, expected, msg); +} + +void +assert_template_format(const gchar *template, const gchar *expected) +{ + assert_template_format_with_escaping(template, FALSE, expected); +} + +void assert_template_format_with_context(const gchar *template, const gchar *expected) { LogMessage *msg; @@ -202,20 +217,12 @@ } void -assert_template_format_with_context_msgs(const gchar *template, const gchar *expected, - LogMessage **msgs, gint num_messages) +assert_template_format_with_len(const gchar *template, const gchar *expected, gssize expected_len) { - LogTemplate *templ = compile_template(template, FALSE); - if (!templ) - return; - - GString *res = g_string_sized_new(128); - const gchar *context_id = "test-context-id"; + LogMessage *msg = create_sample_message(); - log_template_format_with_context(templ, msgs, num_messages, NULL, LTZ_LOCAL, 999, context_id, res); - expect_nstring(res->str, res->len, expected, strlen(expected), "context template test failed, template=%s", template); - log_template_unref(templ); - g_string_free(res, TRUE); + assert_template_format_with_escaping_and_context_msgs(template, FALSE, expected, expected_len, &msg, 1); + log_msg_unref(msg); } void diff -Nru syslog-ng-3.11.1/libtest/template_lib.h syslog-ng-3.13.2/libtest/template_lib.h --- syslog-ng-3.11.1/libtest/template_lib.h 2017-07-31 09:05:32.000000000 +0000 +++ syslog-ng-3.13.2/libtest/template_lib.h 2017-12-06 06:39:39.000000000 +0000 @@ -37,6 +37,10 @@ const gchar *expected, LogMessage *msg); void assert_template_format_with_context(const gchar *template, const gchar *expected); void assert_template_format_with_context_msgs(const gchar *template, const gchar *expected, LogMessage **msgs, gint num_messages); +void assert_template_format_with_len(const gchar *template, const gchar *expected, gssize expected_len); +void assert_template_format_with_escaping_and_context_msgs(const gchar *template, gboolean escaping, + const gchar *expected, gssize expected_len, + LogMessage **msgs, gint num_messages); void assert_template_failure(const gchar *template, const gchar *expected_failure); void perftest_template(gchar *template); diff -Nru syslog-ng-3.11.1/Makefile.am syslog-ng-3.13.2/Makefile.am --- syslog-ng-3.11.1/Makefile.am 2017-07-31 09:05:32.000000000 +0000 +++ syslog-ng-3.13.2/Makefile.am 2017-12-06 06:39:39.000000000 +0000 @@ -60,7 +60,7 @@ TEST_LDADD += $(CRITERION_LIBS) endif -test_ldflags = -no-install +test_ldflags = -no-install $(NO_PIE_LDFLAG) PREOPEN_SYSLOGFORMAT = -dlpreopen ${top_builddir}/modules/syslogformat/libsyslogformat.la PREOPEN_BASICFUNCS = -dlpreopen ${top_builddir}/modules/basicfuncs/libbasicfuncs.la @@ -88,7 +88,7 @@ ${AM_v_at}${MAKE} check check_PROGRAMS="${current_tests} ${subdir_tests}" \ TESTS="${current_tests} ${subdir_tests}" -${check_PROGRAMS}: LDFLAGS+="${test_ldflags}" +${check_PROGRAMS}: LDFLAGS+=${test_ldflags} noinst_LIBRARIES = noinst_DATA = @@ -167,6 +167,8 @@ include doc/Makefile.am include contrib/Makefile.am include scl/Makefile.am +include packaging/debian/Makefile.am +include dbld/Makefile.am TEST_EXTENSIONS = .sh @VALGRIND_CHECK_RULES@ diff -Nru syslog-ng-3.11.1/modules/add-contextual-data/add-contextual-data.c syslog-ng-3.13.2/modules/add-contextual-data/add-contextual-data.c --- syslog-ng-3.11.1/modules/add-contextual-data/add-contextual-data.c 2017-07-31 09:05:32.000000000 +0000 +++ syslog-ng-3.13.2/modules/add-contextual-data/add-contextual-data.c 2017-12-06 06:39:39.000000000 +0000 @@ -251,6 +251,9 @@ static gboolean _init_context_info_db(AddContextualData *self) { + if (self->selector && add_contextual_data_selector_is_ordering_required(self->selector)) + context_info_db_enable_ordering(self->context_info_db); + if (self->filename == NULL) { msg_error("No database file set."); diff -Nru syslog-ng-3.11.1/modules/add-contextual-data/add-contextual-data-grammar.ym syslog-ng-3.13.2/modules/add-contextual-data/add-contextual-data-grammar.ym --- syslog-ng-3.11.1/modules/add-contextual-data/add-contextual-data-grammar.ym 2017-07-31 09:05:32.000000000 +0000 +++ syslog-ng-3.13.2/modules/add-contextual-data/add-contextual-data-grammar.ym 2017-12-06 06:39:39.000000000 +0000 @@ -105,10 +105,10 @@ gint context = LL_CONTEXT_SELECTOR; gpointer value; - p = plugin_find(configuration, context, $1); + p = cfg_find_plugin(configuration, context, $1); CHECK_ERROR(p, @1, "%s plugin %s not found", cfg_lexer_lookup_context_name_by_type(context), $1); - value = plugin_parse_config(p, configuration, &@1, NULL); + value = cfg_parse_plugin(configuration, p, &@1, NULL); free($1); if (!value) diff -Nru syslog-ng-3.11.1/modules/add-contextual-data/add-contextual-data-parser.c syslog-ng-3.13.2/modules/add-contextual-data/add-contextual-data-parser.c --- syslog-ng-3.11.1/modules/add-contextual-data/add-contextual-data-parser.c 2017-07-31 09:05:32.000000000 +0000 +++ syslog-ng-3.13.2/modules/add-contextual-data/add-contextual-data-parser.c 2017-12-06 06:39:39.000000000 +0000 @@ -21,7 +21,6 @@ */ #include "add-contextual-data.h" -#include "cfg-lexer.h" #include "cfg-parser.h" #include "add-contextual-data-grammar.h" #include "logpipe.h" diff -Nru syslog-ng-3.11.1/modules/add-contextual-data/add-contextual-data-parser.h syslog-ng-3.13.2/modules/add-contextual-data/add-contextual-data-parser.h --- syslog-ng-3.11.1/modules/add-contextual-data/add-contextual-data-parser.h 2017-07-31 09:05:32.000000000 +0000 +++ syslog-ng-3.13.2/modules/add-contextual-data/add-contextual-data-parser.h 2017-12-06 06:39:39.000000000 +0000 @@ -24,7 +24,6 @@ #define ADD_CONTEXTUAL_DATA_PARSER_H_INCLUDED #include "cfg-parser.h" -#include "cfg-lexer.h" #include "parser/parser-expr.h" extern CfgParser add_contextual_data_parser; diff -Nru syslog-ng-3.11.1/modules/add-contextual-data/add-contextual-data-plugin.c syslog-ng-3.13.2/modules/add-contextual-data/add-contextual-data-plugin.c --- syslog-ng-3.11.1/modules/add-contextual-data/add-contextual-data-plugin.c 2017-07-31 09:05:32.000000000 +0000 +++ syslog-ng-3.13.2/modules/add-contextual-data/add-contextual-data-plugin.c 2017-12-06 06:39:39.000000000 +0000 @@ -37,9 +37,9 @@ }; gboolean -add_contextual_data_module_init(GlobalConfig *cfg, CfgArgs *args) +add_contextual_data_module_init(PluginContext *context, CfgArgs *args) { - plugin_register(cfg, add_contextual_data_plugins, + plugin_register(context, add_contextual_data_plugins, G_N_ELEMENTS(add_contextual_data_plugins)); return TRUE; } diff -Nru syslog-ng-3.11.1/modules/add-contextual-data/add-contextual-data-selector.h syslog-ng-3.13.2/modules/add-contextual-data/add-contextual-data-selector.h --- syslog-ng-3.11.1/modules/add-contextual-data/add-contextual-data-selector.h 2017-07-31 09:05:32.000000000 +0000 +++ syslog-ng-3.13.2/modules/add-contextual-data/add-contextual-data-selector.h 2017-12-06 06:39:39.000000000 +0000 @@ -29,6 +29,7 @@ typedef struct _AddContextualDataSelector AddContextualDataSelector; struct _AddContextualDataSelector{ + gboolean ordering_required; gchar *(*resolve)(AddContextualDataSelector *self, LogMessage *msg); void (*free)(AddContextualDataSelector *self); AddContextualDataSelector*(*clone)(AddContextualDataSelector *self, GlobalConfig *cfg); @@ -77,4 +78,10 @@ return NULL; } +static inline gboolean +add_contextual_data_selector_is_ordering_required(AddContextualDataSelector *self) +{ + return self->ordering_required; +} + #endif diff -Nru syslog-ng-3.11.1/modules/add-contextual-data/context-info-db.c syslog-ng-3.13.2/modules/add-contextual-data/context-info-db.c --- syslog-ng-3.11.1/modules/add-contextual-data/context-info-db.c 2017-07-31 09:05:32.000000000 +0000 +++ syslog-ng-3.13.2/modules/add-contextual-data/context-info-db.c 2017-12-06 06:39:39.000000000 +0000 @@ -33,6 +33,7 @@ GArray *data; GHashTable *index; gboolean is_data_indexed; + gboolean is_ordering_enabled; GList *ordered_selectors; }; @@ -51,6 +52,12 @@ return strcmp(r1->selector->str, r2->selector->str); } +void +context_info_db_enable_ordering(ContextInfoDB *self) +{ + self->is_ordering_enabled = TRUE; +} + GList * context_info_db_ordered_selectors(ContextInfoDB *self) { @@ -152,7 +159,7 @@ } ContextInfoDB * -context_info_db_new() +context_info_db_new(void) { ContextInfoDB *self = g_new0(ContextInfoDB, 1); @@ -217,7 +224,7 @@ { g_array_append_val(self->data, *record); self->is_data_indexed = FALSE; - if (!g_list_find_custom(self->ordered_selectors, record->selector->str, _g_strcmp)) + if (self->is_ordering_enabled && !g_list_find_custom(self->ordered_selectors, record->selector->str, _g_strcmp)) self->ordered_selectors = g_list_append(self->ordered_selectors, record->selector->str); } diff -Nru syslog-ng-3.11.1/modules/add-contextual-data/context-info-db.h syslog-ng-3.13.2/modules/add-contextual-data/context-info-db.h --- syslog-ng-3.11.1/modules/add-contextual-data/context-info-db.h 2017-07-31 09:05:32.000000000 +0000 +++ syslog-ng-3.13.2/modules/add-contextual-data/context-info-db.h 2017-12-06 06:39:39.000000000 +0000 @@ -32,8 +32,9 @@ typedef void (*ADD_CONTEXT_INFO_CB) (gpointer arg, const ContextualDataRecord *record); +void context_info_db_enable_ordering(ContextInfoDB *self); GList * context_info_db_ordered_selectors(ContextInfoDB *self); -ContextInfoDB *context_info_db_new(); +ContextInfoDB *context_info_db_new(void); void context_info_db_free(ContextInfoDB *self); ContextInfoDB *context_info_db_ref(ContextInfoDB *self); diff -Nru syslog-ng-3.11.1/modules/add-contextual-data/csv-contextual-data-record-scanner.c syslog-ng-3.13.2/modules/add-contextual-data/csv-contextual-data-record-scanner.c --- syslog-ng-3.11.1/modules/add-contextual-data/csv-contextual-data-record-scanner.c 2017-07-31 09:05:32.000000000 +0000 +++ syslog-ng-3.13.2/modules/add-contextual-data/csv-contextual-data-record-scanner.c 2017-12-06 06:39:39.000000000 +0000 @@ -90,7 +90,7 @@ } ContextualDataRecordScanner * -csv_contextual_data_record_scanner_new() +csv_contextual_data_record_scanner_new(void) { CSVContextualDataRecordScanner *self = g_new0(CSVContextualDataRecordScanner, 1); diff -Nru syslog-ng-3.11.1/modules/add-contextual-data/csv-contextual-data-record-scanner.h syslog-ng-3.13.2/modules/add-contextual-data/csv-contextual-data-record-scanner.h --- syslog-ng-3.11.1/modules/add-contextual-data/csv-contextual-data-record-scanner.h 2017-07-31 09:05:32.000000000 +0000 +++ syslog-ng-3.13.2/modules/add-contextual-data/csv-contextual-data-record-scanner.h 2017-12-06 06:39:39.000000000 +0000 @@ -33,6 +33,6 @@ CSVScannerOptions options; } CSVContextualDataRecordScanner; -ContextualDataRecordScanner *csv_contextual_data_record_scanner_new(); +ContextualDataRecordScanner *csv_contextual_data_record_scanner_new(void); #endif diff -Nru syslog-ng-3.11.1/modules/add-contextual-data/tests/test_context_info_db.c syslog-ng-3.13.2/modules/add-contextual-data/tests/test_context_info_db.c --- syslog-ng-3.11.1/modules/add-contextual-data/tests/test_context_info_db.c 2017-07-31 09:05:32.000000000 +0000 +++ syslog-ng-3.13.2/modules/add-contextual-data/tests/test_context_info_db.c 2017-12-06 06:39:39.000000000 +0000 @@ -119,6 +119,7 @@ Test(add_contextual_data, test_insert) { ContextInfoDB *context_info_db = context_info_db_new(); + context_info_db_enable_ordering(context_info_db); _fill_context_info_db(context_info_db, "selector", "name", "value", 2, 5); int ctr = 0; diff -Nru syslog-ng-3.11.1/modules/add-contextual-data/tests/test_selector.c syslog-ng-3.13.2/modules/add-contextual-data/tests/test_selector.c --- syslog-ng-3.11.1/modules/add-contextual-data/tests/test_selector.c 2017-07-31 09:05:32.000000000 +0000 +++ syslog-ng-3.13.2/modules/add-contextual-data/tests/test_selector.c 2017-12-06 06:39:39.000000000 +0000 @@ -54,7 +54,7 @@ static AddContextualDataSelector * _create_template_selector(const gchar *template_string) { - GlobalConfig *cfg = cfg_new_snippet(VERSION_VALUE); + GlobalConfig *cfg = cfg_new_snippet(); AddContextualDataSelector *selector = add_contextual_data_template_selector_new(cfg, template_string); add_contextual_data_selector_init(selector, NULL); diff -Nru syslog-ng-3.11.1/modules/afamqp/afamqp.c syslog-ng-3.13.2/modules/afamqp/afamqp.c --- syslog-ng-3.11.1/modules/afamqp/afamqp.c 2017-07-31 09:05:32.000000000 +0000 +++ syslog-ng-3.13.2/modules/afamqp/afamqp.c 2017-12-06 06:39:39.000000000 +0000 @@ -63,7 +63,7 @@ /* Writer-only stuff */ amqp_connection_state_t conn; - amqp_socket_t* sockfd; + amqp_socket_t *sockfd; amqp_table_entry_t *entries; gint32 max_entries; @@ -264,14 +264,14 @@ } static inline void -_amqp_connection_deinit(AMQPDestDriver* self) +_amqp_connection_deinit(AMQPDestDriver *self) { amqp_destroy_connection(self->conn); self->conn = NULL; } static void -_amqp_connection_disconnect(AMQPDestDriver* self) +_amqp_connection_disconnect(AMQPDestDriver *self) { amqp_channel_close(self->conn, 1, AMQP_REPLY_SUCCESS); amqp_connection_close(self->conn, AMQP_REPLY_SUCCESS); @@ -305,41 +305,41 @@ return FALSE; case AMQP_RESPONSE_LIBRARY_EXCEPTION: - { - msg_error(context, - evt_tag_str("driver", self->super.super.super.id), - evt_tag_str("error", amqp_error_string2(ret.library_error)), - evt_tag_int("time_reopen", self->super.time_reopen)); - return FALSE; - } + { + msg_error(context, + evt_tag_str("driver", self->super.super.super.id), + evt_tag_str("error", amqp_error_string2(ret.library_error)), + evt_tag_int("time_reopen", self->super.time_reopen)); + return FALSE; + } case AMQP_RESPONSE_SERVER_EXCEPTION: switch (ret.reply.id) { case AMQP_CONNECTION_CLOSE_METHOD: - { - amqp_connection_close_t *m = - (amqp_connection_close_t *) ret.reply.decoded; - msg_error(context, - evt_tag_str("driver", self->super.super.super.id), - evt_tag_str("error", "server connection error"), - evt_tag_int("code", m->reply_code), - evt_tag_str("text", m->reply_text.bytes), - evt_tag_int("time_reopen", self->super.time_reopen)); - return FALSE; - } + { + amqp_connection_close_t *m = + (amqp_connection_close_t *) ret.reply.decoded; + msg_error(context, + evt_tag_str("driver", self->super.super.super.id), + evt_tag_str("error", "server connection error"), + evt_tag_int("code", m->reply_code), + evt_tag_str("text", m->reply_text.bytes), + evt_tag_int("time_reopen", self->super.time_reopen)); + return FALSE; + } case AMQP_CHANNEL_CLOSE_METHOD: - { - amqp_channel_close_t *m = - (amqp_channel_close_t *) ret.reply.decoded; - msg_error(context, - evt_tag_str("driver", self->super.super.super.id), - evt_tag_str("error", "server channel error"), - evt_tag_int("code", m->reply_code), - evt_tag_str("text", m->reply_text.bytes), - evt_tag_int("time_reopen", self->super.time_reopen)); - return FALSE; - } + { + amqp_channel_close_t *m = + (amqp_channel_close_t *) ret.reply.decoded; + msg_error(context, + evt_tag_str("driver", self->super.super.super.id), + evt_tag_str("error", "server channel error"), + evt_tag_int("code", m->reply_code), + evt_tag_str("text", m->reply_text.bytes), + evt_tag_int("time_reopen", self->super.time_reopen)); + return FALSE; + } default: msg_error(context, evt_tag_str("driver", self->super.super.super.id), @@ -354,52 +354,54 @@ } static gboolean -afamqp_dd_socket_init(AMQPDestDriver *self) { +afamqp_dd_socket_init(AMQPDestDriver *self) +{ + + self->conn = amqp_new_connection(); - self->conn = amqp_new_connection(); + if (self->conn == NULL) + { + msg_error("Error allocating AMQP connection."); + return FALSE; + } + + if (self->ca_file) + { + int ca_file_ret; + self->sockfd = amqp_ssl_socket_new(self->conn); + ca_file_ret = amqp_ssl_socket_set_cacert(self->sockfd, self->ca_file); + if(ca_file_ret != AMQP_STATUS_OK) + { + msg_error("Error connecting to AMQP server while setting ca_file", + evt_tag_str("driver", self->super.super.super.id), + evt_tag_str("error", amqp_error_string2(ca_file_ret)), + evt_tag_int("time_reopen", self->super.time_reopen)); + + return FALSE; - if (self->conn == NULL) - { - msg_error("Error allocating AMQP connection."); - return FALSE; - } - - if (self->ca_file) - { - int ca_file_ret; - self->sockfd = amqp_ssl_socket_new(self->conn); - ca_file_ret = amqp_ssl_socket_set_cacert(self->sockfd, self->ca_file); - if(ca_file_ret != AMQP_STATUS_OK) - { - msg_error("Error connecting to AMQP server while setting ca_file", - evt_tag_str("driver", self->super.super.super.id), - evt_tag_str("error", amqp_error_string2(ca_file_ret)), - evt_tag_int("time_reopen", self->super.time_reopen)); - - return FALSE; - - } - - if (self->key_file && self->cert_file) - { - int setkey_ret = amqp_ssl_socket_set_key(self->sockfd, self->cert_file, self->key_file); - if(setkey_ret != AMQP_STATUS_OK) - { - msg_error("Error connecting to AMQP server while setting key_file and cert_file", - evt_tag_str("driver", self->super.super.super.id), - evt_tag_str("error", amqp_error_string2(setkey_ret)), - evt_tag_int("time_reopen", self->super.time_reopen)); - - return FALSE; - - } - } - amqp_ssl_socket_set_verify(self->sockfd, self->peer_verify); - } - else - self->sockfd = amqp_tcp_socket_new(self->conn); + } + + if (self->key_file && self->cert_file) + { + int setkey_ret = amqp_ssl_socket_set_key(self->sockfd, self->cert_file, self->key_file); + if(setkey_ret != AMQP_STATUS_OK) + { + msg_error("Error connecting to AMQP server while setting key_file and cert_file", + evt_tag_str("driver", self->super.super.super.id), + evt_tag_str("error", amqp_error_string2(setkey_ret)), + evt_tag_int("time_reopen", self->super.time_reopen)); + + return FALSE; + + } + } + amqp_ssl_socket_set_verify_peer(self->sockfd, self->peer_verify); + amqp_ssl_socket_set_verify_hostname(self->sockfd, self->peer_verify); + } + else + self->sockfd = amqp_tcp_socket_new(self->conn); - return TRUE; + return TRUE; } static gboolean @@ -422,7 +424,7 @@ } if(!afamqp_dd_socket_init(self)) - goto exception_amqp_dd_connect_failed_init; + goto exception_amqp_dd_connect_failed_init; struct timeval delay; delay.tv_sec = 1; @@ -471,13 +473,13 @@ return TRUE; /* Exceptions */ - exception_amqp_dd_connect_failed_exchange: +exception_amqp_dd_connect_failed_exchange: amqp_channel_close(self->conn, 1, AMQP_REPLY_SUCCESS); - exception_amqp_dd_connect_failed_channel: +exception_amqp_dd_connect_failed_channel: amqp_connection_close(self->conn, AMQP_REPLY_SUCCESS); - exception_amqp_dd_connect_failed_init: +exception_amqp_dd_connect_failed_init: _amqp_connection_deinit(self); return FALSE; } @@ -533,7 +535,7 @@ table.entries = self->entries; props._flags = AMQP_BASIC_CONTENT_TYPE_FLAG - | AMQP_BASIC_DELIVERY_MODE_FLAG | AMQP_BASIC_HEADERS_FLAG; + | AMQP_BASIC_DELIVERY_MODE_FLAG | AMQP_BASIC_HEADERS_FLAG; props.content_type = amqp_cstring_bytes("text/plain"); props.delivery_mode = self->persistent; props.headers = table; @@ -711,9 +713,9 @@ }; gboolean -afamqp_module_init(GlobalConfig *cfg, CfgArgs *args) +afamqp_module_init(PluginContext *context, CfgArgs *args) { - plugin_register(cfg, &afamqp_plugin, 1); + plugin_register(context, &afamqp_plugin, 1); return TRUE; } diff -Nru syslog-ng-3.11.1/modules/afamqp/afamqp-grammar.ym syslog-ng-3.13.2/modules/afamqp/afamqp-grammar.ym --- syslog-ng-3.11.1/modules/afamqp/afamqp-grammar.ym 2017-07-31 09:05:32.000000000 +0000 +++ syslog-ng-3.13.2/modules/afamqp/afamqp-grammar.ym 2017-12-06 06:39:39.000000000 +0000 @@ -61,6 +61,7 @@ %token KW_KEY_FILE %token KW_CERT_FILE %token KW_PEER_VERIFY +%token KW_TLS %% @@ -89,16 +90,27 @@ | KW_PERSISTENT '(' yesno ')' { afamqp_dd_set_persistent(last_driver, $3); } | KW_USERNAME '(' string ')' { afamqp_dd_set_user(last_driver, $3); free($3); } | KW_PASSWORD '(' string ')' { afamqp_dd_set_password(last_driver, $3); free($3); } - | KW_CA_FILE '(' string ')' { afamqp_dd_set_ca_file(last_driver, $3); free($3); } - | KW_KEY_FILE '(' string ')' { afamqp_dd_set_key_file(last_driver, $3); free($3); } - | KW_CERT_FILE '(' string ')' { afamqp_dd_set_cert_file(last_driver, $3); free($3); } - | KW_PEER_VERIFY '(' yesno ')' { afamqp_dd_set_peer_verify(last_driver, $3); } | value_pair_option { afamqp_dd_set_value_pairs(last_driver, $1); } | dest_driver_option | threaded_dest_driver_option + | afamqp_tls_option + | KW_TLS '(' afamqp_tls_options ')' | { last_template_options = afamqp_dd_get_template_options(last_driver); } template_option ; + +afamqp_tls_options + : afamqp_tls_option afamqp_tls_options + | + ; + +afamqp_tls_option + : KW_CA_FILE '(' string ')' { afamqp_dd_set_ca_file(last_driver, $3); free($3); } + | KW_KEY_FILE '(' string ')' { afamqp_dd_set_key_file(last_driver, $3); free($3); } + | KW_CERT_FILE '(' string ')' { afamqp_dd_set_cert_file(last_driver, $3); free($3); } + | KW_PEER_VERIFY '(' yesno ')' { afamqp_dd_set_peer_verify(last_driver, $3); } + ; + /* INCLUDE_RULES */ %% diff -Nru syslog-ng-3.11.1/modules/afamqp/afamqp-parser.c syslog-ng-3.13.2/modules/afamqp/afamqp-parser.c --- syslog-ng-3.11.1/modules/afamqp/afamqp-parser.c 2017-07-31 09:05:32.000000000 +0000 +++ syslog-ng-3.13.2/modules/afamqp/afamqp-parser.c 2017-12-06 06:39:39.000000000 +0000 @@ -29,24 +29,26 @@ extern int afamqp_debug; int afamqp_parse(CfgLexer *lexer, LogDriver **instance, gpointer arg); -static CfgLexerKeyword afamqp_keywords[] = { - { "amqp", KW_AMQP }, - { "vhost", KW_VHOST }, - { "host", KW_HOST }, - { "port", KW_PORT }, - { "exchange", KW_EXCHANGE }, - { "exchange_declare", KW_EXCHANGE_DECLARE }, - { "exchange_type", KW_EXCHANGE_TYPE }, - { "routing_key", KW_ROUTING_KEY }, - { "persistent", KW_PERSISTENT }, - { "username", KW_USERNAME }, - { "password", KW_PASSWORD }, - { "log_fifo_size", KW_LOG_FIFO_SIZE }, - { "body", KW_BODY }, - { "ca_file", KW_CA_FILE }, - { "key_file", KW_KEY_FILE }, - { "cert_file", KW_CERT_FILE }, - { "peer_verify", KW_PEER_VERIFY }, +static CfgLexerKeyword afamqp_keywords[] = +{ + { "amqp", KW_AMQP }, + { "vhost", KW_VHOST }, + { "host", KW_HOST }, + { "port", KW_PORT }, + { "exchange", KW_EXCHANGE }, + { "exchange_declare", KW_EXCHANGE_DECLARE }, + { "exchange_type", KW_EXCHANGE_TYPE }, + { "routing_key", KW_ROUTING_KEY }, + { "persistent", KW_PERSISTENT }, + { "username", KW_USERNAME }, + { "password", KW_PASSWORD }, + { "log_fifo_size", KW_LOG_FIFO_SIZE }, + { "body", KW_BODY }, + { "ca_file", KW_CA_FILE }, + { "key_file", KW_KEY_FILE }, + { "cert_file", KW_CERT_FILE }, + { "peer_verify", KW_PEER_VERIFY }, + { "tls", KW_TLS }, { NULL } }; diff -Nru syslog-ng-3.11.1/modules/afamqp/afamqp-parser.h syslog-ng-3.13.2/modules/afamqp/afamqp-parser.h --- syslog-ng-3.11.1/modules/afamqp/afamqp-parser.h 2017-07-31 09:05:32.000000000 +0000 +++ syslog-ng-3.13.2/modules/afamqp/afamqp-parser.h 2017-12-06 06:39:39.000000000 +0000 @@ -26,7 +26,6 @@ #define AFAMQP_PARSER_H_INCLUDED #include "cfg-parser.h" -#include "cfg-lexer.h" #include "afamqp.h" extern CfgParser afamqp_parser; diff -Nru syslog-ng-3.11.1/modules/afamqp/Makefile.am syslog-ng-3.13.2/modules/afamqp/Makefile.am --- syslog-ng-3.11.1/modules/afamqp/Makefile.am 2017-07-31 09:05:32.000000000 +0000 +++ syslog-ng-3.13.2/modules/afamqp/Makefile.am 2017-12-06 06:39:39.000000000 +0000 @@ -38,13 +38,19 @@ modules/afamqp modules/afamqp/ mod-afamqp mod-amqp: endif +if LIBRABBITMQ_INTERNAL + +EXTRA_DIST += \ + modules/afamqp/rabbitmq-c/configure.gnu + +endif + BUILT_SOURCES += \ modules/afamqp/afamqp-grammar.y \ modules/afamqp/afamqp-grammar.c \ modules/afamqp/afamqp-grammar.h EXTRA_DIST += \ - modules/afamqp/afamqp-grammar.ym \ - modules/afamqp/rabbitmq-c/configure.gnu + modules/afamqp/afamqp-grammar.ym .PHONY: modules/afamqp/ mod-afamqp mod-amqp diff -Nru syslog-ng-3.11.1/modules/affile/affile-common.c syslog-ng-3.13.2/modules/affile/affile-common.c --- syslog-ng-3.11.1/modules/affile/affile-common.c 2017-07-31 09:05:32.000000000 +0000 +++ syslog-ng-3.13.2/modules/affile/affile-common.c 1970-01-01 00:00:00.000000000 +0000 @@ -1,169 +0,0 @@ -/* - * Copyright (c) 2002-2013 Balabit - * Copyright (c) 1998-2012 Balázs Scheidler - * - * This program is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 as published - * by the Free Software Foundation, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - * - * As an additional exemption you are allowed to compile & link against the - * OpenSSL libraries as published by the OpenSSL project. See the file - * COPYING for details. - * - */ -#include "affile-common.h" -#include "messages.h" -#include "gprocess.h" -#include "fdhelpers.h" -#include "pathutils.h" - -#include -#include -#include -#include -#include -#include -#include -#include - -static const gchar *spurious_paths[] = {"../", "/..", NULL}; - -static inline gboolean -_string_contains_fragment(const gchar *str, const gchar *fragments[]) -{ - int i; - - for (i = 0; fragments[i]; i++) - { - if (strstr(str, fragments[i])) - return TRUE; - } - - return FALSE; -} - -static inline gboolean -_is_path_spurious(const gchar *name) -{ - return _string_contains_fragment(name, spurious_paths); -} - -static inline gboolean -_obtain_capabilities(gchar *name, FileOpenOptions *open_opts, FilePermOptions *perm_opts, cap_t *act_caps) -{ - if (open_opts->needs_privileges) - { - g_process_cap_modify(CAP_DAC_READ_SEARCH, TRUE); - g_process_cap_modify(CAP_SYSLOG, TRUE); - } - else - { - g_process_cap_modify(CAP_DAC_OVERRIDE, TRUE); - } - - if (open_opts->create_dirs && perm_opts && - !file_perm_options_create_containing_directory(perm_opts, name)) - { - return FALSE; - } - - return TRUE; -} - -static inline void -_set_fd_permission(FilePermOptions *perm_opts, int fd) -{ - if (fd != -1) - { - g_fd_set_cloexec(fd, TRUE); - - g_process_cap_modify(CAP_CHOWN, TRUE); - g_process_cap_modify(CAP_FOWNER, TRUE); - - if (perm_opts) - file_perm_options_apply_fd(perm_opts, fd); - } -} - -static inline int -_open_fd(const gchar *name, FileOpenOptions *open_opts, FilePermOptions *perm_opts) -{ - int fd; - int mode = (perm_opts && (perm_opts->file_perm >= 0)) - ? perm_opts->file_perm : 0600; - - fd = open(name, open_opts->open_flags, mode); - - if (open_opts->is_pipe && fd < 0 && errno == ENOENT) - { - if (mkfifo(name, mode) >= 0) - fd = open(name, open_opts->open_flags, mode); - } - - return fd; -} - -static inline void -_validate_file_type(const gchar *name, FileOpenOptions *open_opts) -{ - struct stat st; - - if (stat(name, &st) >= 0) - { - if (open_opts->is_pipe && !S_ISFIFO(st.st_mode)) - { - msg_warning("WARNING: you are using the pipe driver, underlying file is not a FIFO, it should be used by file()", - evt_tag_str("filename", name)); - } - else if (!open_opts->is_pipe && S_ISFIFO(st.st_mode)) - { - msg_warning("WARNING: you are using the file driver, underlying file is a FIFO, it should be used by pipe()", - evt_tag_str("filename", name)); - } - } -} - -gboolean -affile_open_file(gchar *name, FileOpenOptions *open_opts, FilePermOptions *perm_opts, gint *fd) -{ - cap_t saved_caps; - - if (_is_path_spurious(name)) - { - msg_error("Spurious path, logfile not created", - evt_tag_str("path", name)); - return FALSE; - } - - saved_caps = g_process_cap_save(); - - if (!_obtain_capabilities(name, open_opts, perm_opts, &saved_caps)) - { - g_process_cap_restore(saved_caps); - return FALSE; - } - - _validate_file_type(name, open_opts); - - *fd = _open_fd(name, open_opts, perm_opts); - - if (!is_file_device(name)) - _set_fd_permission(perm_opts, *fd); - - g_process_cap_restore(saved_caps); - - msg_trace("affile_open_file", - evt_tag_str("path", name), - evt_tag_int("fd", *fd)); - - return (*fd != -1); -} diff -Nru syslog-ng-3.11.1/modules/affile/affile-common.h syslog-ng-3.13.2/modules/affile/affile-common.h --- syslog-ng-3.11.1/modules/affile/affile-common.h 2017-07-31 09:05:32.000000000 +0000 +++ syslog-ng-3.13.2/modules/affile/affile-common.h 1970-01-01 00:00:00.000000000 +0000 @@ -1,53 +0,0 @@ -/* - * Copyright (c) 2002-2013 Balabit - * Copyright (c) 1998-2012 Balázs Scheidler - * - * This program is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 as published - * by the Free Software Foundation, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - * - * As an additional exemption you are allowed to compile & link against the - * OpenSSL libraries as published by the OpenSSL project. See the file - * COPYING for details. - * - */ - -#ifndef AFFILE_COMMON_H_INCLUDED -#define AFFILE_COMMON_H_INCLUDED - -/* portable largefile support for affile */ -#include "compat/lfs.h" - -#include "file-perms.h" -#include - -typedef struct _FileOpenOptions -{ - gboolean needs_privileges:1, - is_pipe:1; - gint open_flags; - gint create_dirs; -} FileOpenOptions; - -gboolean affile_open_file(gchar *name, FileOpenOptions *open_opts, FilePermOptions *perm_opts, gint *fd); - -static inline gboolean -affile_is_linux_proc_kmsg(const gchar *filename) -{ -#ifdef __linux__ - if (strcmp(filename, "/proc/kmsg") == 0) - return TRUE; -#endif - return FALSE; -} - -#endif diff -Nru syslog-ng-3.11.1/modules/affile/affile-dest.c syslog-ng-3.13.2/modules/affile/affile-dest.c --- syslog-ng-3.11.1/modules/affile/affile-dest.c 2017-07-31 09:05:32.000000000 +0000 +++ syslog-ng-3.13.2/modules/affile/affile-dest.c 2017-12-06 06:39:39.000000000 +0000 @@ -20,7 +20,7 @@ * COPYING for details. * */ -#include "affile-common.h" +#include "file-opener.h" #include "affile-dest.h" #include "driver.h" #include "messages.h" @@ -29,12 +29,13 @@ #include "stats/stats-registry.h" #include "mainloop-call.h" #include "transport/transport-file.h" -#include "logproto/logproto-text-client.h" #include "logproto-file-writer.h" #include "transport/transport-file.h" #include "transport/transport-pipe.h" #include "logwriter.h" #include "affile-dest-internal-queue-filter.h" +#include "file-specializations.h" +#include "apphook.h" #include #include @@ -46,9 +47,6 @@ #include #include -#define DEFAULT_DW_REOPEN_FLAGS (O_WRONLY | O_CREAT | O_NOCTTY | O_NONBLOCK | O_LARGEFILE | O_APPEND) -#define DEFAULT_DW_REOPEN_FLAGS_PIPE (O_RDWR | O_NOCTTY | O_NONBLOCK | O_LARGEFILE) - /* * Threading notes: * @@ -86,6 +84,8 @@ * go away in a parallel reaper process. */ +static GList *affile_dest_drivers = NULL; + struct _AFFileDestWriter { LogPipe super; @@ -149,12 +149,6 @@ } static gboolean -_affile_dw_reopen_file(AFFileDestWriter *self, gchar *name, gint *fd) -{ - return affile_open_file(name, &self->owner->file_open_options, &self->owner->file_perm_options, fd); -} - -static gboolean affile_dw_reopen(AFFileDestWriter *self) { int fd; @@ -181,15 +175,15 @@ unlink(self->filename); } - if (_affile_dw_reopen_file(self, self->filename, &fd)) + if (file_opener_open_fd(self->owner->file_opener, self->filename, AFFILE_DIR_WRITE, &fd)) { - proto = self->owner->file_open_options.is_pipe - ? log_proto_text_client_new(log_transport_pipe_new(fd), &self->owner->writer_options.proto_options.super) - : log_proto_file_writer_new(log_transport_file_new(fd), &self->owner->writer_options.proto_options.super, - self->owner->writer_options.flush_lines, - self->owner->use_fsync); + LogTransport *transport = file_opener_construct_transport(self->owner->file_opener, fd); + + proto = file_opener_construct_dst_proto(self->owner->file_opener, transport, + &self->owner->writer_options.proto_options.super); - main_loop_call((void *(*)(void *)) affile_dw_arm_reaper, self, TRUE); + if (!iv_timer_registered(&self->reap_timer)) + main_loop_call((void *(*)(void *)) affile_dw_arm_reaper, self, TRUE); } else { @@ -211,18 +205,12 @@ if (!self->writer) { - guint32 flags; - - flags = LW_FORMAT_FILE | - (self->owner->file_open_options.is_pipe ? 0 : LW_SOFT_FLOW_CONTROL); - - self->writer = log_writer_new(flags, cfg); + self->writer = log_writer_new(self->owner->writer_flags, cfg); } + log_writer_set_options(self->writer, s, &self->owner->writer_options, - STATS_LEVEL1, - self->owner->file_open_options.is_pipe ? SCS_PIPE : SCS_FILE, self->owner->super.super.id, self->filename); log_writer_set_queue(self->writer, log_dest_driver_acquire_queue(&self->owner->super, @@ -313,8 +301,6 @@ log_writer_set_options(self->writer, &self->super, &owner->writer_options, - STATS_LEVEL1, - SCS_FILE, self->owner->super.super.id, self->filename); } @@ -372,12 +358,35 @@ return self; } +static void +affile_dw_reopen_writer(gpointer key, gpointer value, gpointer user_data) +{ + AFFileDestWriter *writer = (AFFileDestWriter *) value; + affile_dw_reopen(writer); +} + +static void +affile_dd_reopen_all_writers(gpointer data, gpointer user_data) +{ + AFFileDestDriver *driver = (AFFileDestDriver *) data; + if (driver->single_writer) + affile_dw_reopen(driver->single_writer); + else if (driver->writer_hash) + g_hash_table_foreach(driver->writer_hash, affile_dw_reopen_writer, NULL); +} + +static void +affile_dd_register_reopen_hook(gint hook_type, gpointer user_data) +{ + g_list_foreach(affile_dest_drivers, affile_dd_reopen_all_writers, NULL); +} + void affile_dd_set_create_dirs(LogDriver *s, gboolean create_dirs) { AFFileDestDriver *self = (AFFileDestDriver *) s; - self->file_open_options.create_dirs = create_dirs; + self->file_opener_options.create_dirs = create_dirs; } void @@ -474,12 +483,13 @@ if (!log_dest_driver_init_method(s)) return FALSE; - if (self->file_open_options.create_dirs == -1) - self->file_open_options.create_dirs = cfg->create_dirs; + if (self->file_opener_options.create_dirs == -1) + self->file_opener_options.create_dirs = cfg->create_dirs; if (self->time_reap == -1) self->time_reap = cfg->time_reap; - file_perm_options_inherit_from(&self->file_perm_options, &cfg->file_perm_options); + file_opener_options_init(&self->file_opener_options, cfg); + file_opener_set_options(self->file_opener, &self->file_opener_options); log_writer_options_init(&self->writer_options, cfg, 0); if (self->filename_is_a_template) @@ -740,16 +750,19 @@ AFFileDestDriver *self = (AFFileDestDriver *) s; g_static_mutex_free(&self->lock); + affile_dest_drivers = g_list_remove(affile_dest_drivers, self); /* NOTE: this must be NULL as deinit has freed it, otherwise we'd have circular references */ g_assert(self->single_writer == NULL && self->writer_hash == NULL); log_template_unref(self->filename_template); log_writer_options_destroy(&self->writer_options); + file_opener_options_deinit(&self->file_opener_options); + file_opener_free(self->file_opener); log_dest_driver_free(s); } -static AFFileDestDriver * +AFFileDestDriver * affile_dd_new_instance(gchar *filename, GlobalConfig *cfg) { AFFileDestDriver *self = g_new0(AFFileDestDriver, 1); @@ -763,33 +776,37 @@ self->filename_template = log_template_new(cfg, NULL); log_template_compile(self->filename_template, filename, NULL); log_writer_options_defaults(&self->writer_options); - file_perm_options_defaults(&self->file_perm_options); self->writer_options.mark_mode = MM_NONE; + self->writer_options.stats_level = STATS_LEVEL1; + self->writer_flags = LW_FORMAT_FILE; + if (strchr(filename, '$') != NULL) { self->filename_is_a_template = TRUE; } + file_opener_options_defaults(&self->file_opener_options); + self->time_reap = -1; - self->file_open_options.create_dirs = -1; - self->file_open_options.is_pipe = FALSE; - self->file_open_options.needs_privileges = FALSE; - self->file_open_options.open_flags = DEFAULT_DW_REOPEN_FLAGS; g_static_mutex_init(&self->lock); + + affile_dest_drivers = g_list_append(affile_dest_drivers, self); + return self; } LogDriver * affile_dd_new(gchar *filename, GlobalConfig *cfg) { - return &affile_dd_new_instance(filename, cfg)->super.super; -} - -LogDriver * -afpipe_dd_new(gchar *filename, GlobalConfig *cfg) -{ AFFileDestDriver *self = affile_dd_new_instance(filename, cfg); - self->file_open_options.is_pipe = TRUE; - self->file_open_options.open_flags = DEFAULT_DW_REOPEN_FLAGS_PIPE; + self->writer_flags |= LW_SOFT_FLOW_CONTROL; + self->writer_options.stats_source = SCS_FILE; + self->file_opener = file_opener_for_regular_dest_files_new(&self->writer_options, &self->use_fsync); return &self->super.super; } + +void +affile_dd_global_init(void) +{ + register_application_hook(AH_REOPEN, affile_dd_register_reopen_hook, NULL); +} diff -Nru syslog-ng-3.11.1/modules/affile/affile-dest.h syslog-ng-3.13.2/modules/affile/affile-dest.h --- syslog-ng-3.11.1/modules/affile/affile-dest.h 2017-07-31 09:05:32.000000000 +0000 +++ syslog-ng-3.13.2/modules/affile/affile-dest.h 2017-12-06 06:39:39.000000000 +0000 @@ -26,7 +26,7 @@ #include "driver.h" #include "logwriter.h" -#include "affile-common.h" +#include "file-opener.h" typedef struct _AFFileDestWriter AFFileDestWriter; @@ -36,13 +36,14 @@ GStaticMutex lock; LogTemplate *filename_template; AFFileDestWriter *single_writer; - gboolean filename_is_a_template:1, - template_escape:1, - use_fsync:1; - FilePermOptions file_perm_options; - FileOpenOptions file_open_options; + gboolean filename_is_a_template; + gboolean template_escape; + gboolean use_fsync; + FileOpenerOptions file_opener_options; + FileOpener *file_opener; TimeZoneInfo *local_time_zone_info; LogWriterOptions writer_options; + guint32 writer_flags; GHashTable *writer_hash; gint overwrite_if_older; @@ -50,12 +51,13 @@ gint time_reap; } AFFileDestDriver; +AFFileDestDriver *affile_dd_new_instance(gchar *filename, GlobalConfig *cfg); LogDriver *affile_dd_new(gchar *filename, GlobalConfig *cfg); -LogDriver *afpipe_dd_new(gchar *filename, GlobalConfig *cfg); void affile_dd_set_create_dirs(LogDriver *s, gboolean create_dirs); void affile_dd_set_fsync(LogDriver *s, gboolean enable); void affile_dd_set_overwrite_if_older(LogDriver *s, gint overwrite_if_older); void affile_dd_set_local_time_zone(LogDriver *s, const gchar *local_time_zone); +void affile_dd_global_init(void); #endif diff -Nru syslog-ng-3.11.1/modules/affile/affile-grammar.ym syslog-ng-3.13.2/modules/affile/affile-grammar.ym --- syslog-ng-3.11.1/modules/affile/affile-grammar.ym 2017-07-31 09:05:32.000000000 +0000 +++ syslog-ng-3.13.2/modules/affile/affile-grammar.ym 2017-12-06 06:39:39.000000000 +0000 @@ -29,7 +29,7 @@ %code { -#include "affile-common.h" +#include "file-opener.h" #include "affile-source.h" #include "wildcard-source.h" #include "affile-dest.h" @@ -39,10 +39,13 @@ #include "messages.h" #include "plugin.h" #include "cfg-grammar.h" +#include "stdin.h" +#include "named-pipe.h" #include FileReaderOptions *last_file_reader_options; +LogProtoFileReaderOptions *last_log_proto_options; } %name-prefix "affile_" @@ -73,10 +76,13 @@ %token KW_MAX_FILES %token KW_MONITOR_METHOD +%token KW_STDIN + %type source_affile %type source_affile_params %type source_afpipe_params %type source_wildcard_params +%type source_stdin_params %type dest_affile %type dest_affile_params %type dest_afpipe_params @@ -91,12 +97,14 @@ source_affile : KW_FILE '(' source_affile_params ')' { $$ = $3; } | KW_PIPE '(' source_afpipe_params ')' { $$ = $3; } + | KW_STDIN '(' source_stdin_params ')' { $$ = $3; } | KW_WILDCARD_FILE { last_driver = *instance = wildcard_sd_new(configuration); last_file_reader_options = &((WildcardSourceDriver *) last_driver)->file_reader_options; last_reader_options = &last_file_reader_options->reader_options; - last_file_perm_options = &last_file_reader_options->file_perm_options; + last_file_perm_options = &((WildcardSourceDriver *) last_driver)->file_opener_options.file_perm_options; + last_log_proto_options = file_reader_options_get_log_proto_options(last_file_reader_options); } '(' source_wildcard_params ')' { $$ = last_driver; } ; @@ -109,13 +117,26 @@ | ; +source_stdin_params + : + { + last_driver = *instance = stdin_sd_new(configuration); + last_file_reader_options = &((AFFileSourceDriver *) last_driver)->file_reader_options; + last_reader_options = &last_file_reader_options->reader_options; + last_file_perm_options = &((AFFileSourceDriver *) last_driver)->file_opener_options.file_perm_options; + last_log_proto_options = file_reader_options_get_log_proto_options(last_file_reader_options); + } + source_affile_options { $$ = last_driver; } + ; + source_affile_params : string { - last_driver = *instance = affile_sd_new($1, configuration); + last_driver = *instance = affile_sd_new($1, configuration); last_file_reader_options = &((AFFileSourceDriver *) last_driver)->file_reader_options; last_reader_options = &last_file_reader_options->reader_options; - last_file_perm_options = &last_file_reader_options->file_perm_options; + last_file_perm_options = &((AFFileSourceDriver *) last_driver)->file_opener_options.file_perm_options; + last_log_proto_options = file_reader_options_get_log_proto_options(last_file_reader_options); } source_affile_options { $$ = last_driver; free($1); } ; @@ -127,31 +148,34 @@ source_affile_option : KW_FOLLOW_FREQ '(' LL_FLOAT ')' { file_reader_options_set_follow_freq(last_file_reader_options, (long) ($3 * 1000)); } - | KW_FOLLOW_FREQ '(' nonnegative_integer ')' { file_reader_options_set_follow_freq(last_file_reader_options, ($3 * 1000)); } - | KW_PAD_SIZE '(' nonnegative_integer ')' { last_file_reader_options->pad_size = $3; } + | KW_FOLLOW_FREQ '(' nonnegative_integer ')' { file_reader_options_set_follow_freq(last_file_reader_options, ($3 * 1000)); } + | KW_PAD_SIZE '(' nonnegative_integer ')' { last_log_proto_options->pad_size = $3; } | multi_line_option + | file_perm_option | source_reader_option ; source_wildcard_option - : KW_BASE_DIR '(' string ')' { wildcard_sd_set_base_dir(last_driver, $3); free($3); } - | KW_FILENAME_PATTERN '(' string ')' { - wildcard_sd_set_filename_pattern(last_driver, $3); - free($3); } - | KW_RECURSIVE '(' yesno ')' { wildcard_sd_set_recursive(last_driver, $3); } - | KW_MAX_FILES '(' LL_NUMBER ')' { wildcard_sd_set_max_files(last_driver, $3); } - | KW_MONITOR_METHOD '(' string ')' { CHECK_ERROR(wildcard_sd_set_monitor_method(last_driver, $3), @3, "Invalid monitor-method"); free($3); } - | source_affile_option - ; - + : KW_BASE_DIR '(' string ')' { wildcard_sd_set_base_dir(last_driver, $3); free($3); } + | KW_FILENAME_PATTERN '(' string ')' + { + wildcard_sd_set_filename_pattern(last_driver, $3); + free($3); + } + | KW_RECURSIVE '(' yesno ')' { wildcard_sd_set_recursive(last_driver, $3); } + | KW_MAX_FILES '(' LL_NUMBER ')' { wildcard_sd_set_max_files(last_driver, $3); } + | KW_MONITOR_METHOD '(' string ')' { CHECK_ERROR(wildcard_sd_set_monitor_method(last_driver, $3), @3, "Invalid monitor-method"); free($3); } + | source_affile_option + ; source_afpipe_params : string { - last_driver = *instance = afpipe_sd_new($1, configuration); + last_driver = *instance = pipe_sd_new($1, configuration); last_file_reader_options = &((AFFileSourceDriver *) last_driver)->file_reader_options; last_reader_options = &last_file_reader_options->reader_options; - last_file_perm_options = &last_file_reader_options->file_perm_options; + last_file_perm_options = &((AFFileSourceDriver *) last_driver)->file_opener_options.file_perm_options; + last_log_proto_options = file_reader_options_get_log_proto_options(last_file_reader_options); } source_afpipe_options { $$ = last_driver; free($1); } ; @@ -163,7 +187,7 @@ source_afpipe_option : KW_OPTIONAL '(' yesno ')' { last_driver->optional = $3; } - | KW_PAD_SIZE '(' nonnegative_integer ')' { last_file_reader_options->pad_size = $3; } + | KW_PAD_SIZE '(' nonnegative_integer ')' { last_log_proto_options->pad_size = $3; } | multi_line_option | file_perm_option | source_reader_option @@ -173,18 +197,24 @@ * move it to cfg-grammar.y instead */ multi_line_option - : KW_MULTI_LINE_MODE '(' string ')' { CHECK_ERROR(file_reader_options_set_multi_line_mode(last_file_reader_options, $3), @3, "Invalid multi-line mode"); free($3); } + : KW_MULTI_LINE_MODE '(' string ')' + { + CHECK_ERROR(log_proto_multi_line_server_options_set_mode(&last_log_proto_options->super, $3), @3, "Invalid multi-line mode"); + free($3); + } | KW_MULTI_LINE_PREFIX '(' string ')' { GError *error = NULL; - CHECK_ERROR_GERROR(file_reader_options_set_multi_line_prefix(last_file_reader_options, $3, &error), @3, error, "error compiling multi-line regexp"); free($3); + CHECK_ERROR_GERROR(log_proto_multi_line_server_options_set_prefix(&last_log_proto_options->super, $3, &error), @3, error, "error compiling multi-line regexp"); + free($3); } | KW_MULTI_LINE_GARBAGE '(' string ')' { GError *error = NULL; - CHECK_ERROR_GERROR(file_reader_options_set_multi_line_garbage(last_file_reader_options, $3, &error), @3, error, "error compiling multi-line regexp"); free($3); + CHECK_ERROR_GERROR(log_proto_multi_line_server_options_set_garbage(&last_log_proto_options->super, $3, &error), @3, error, "error compiling multi-line regexp"); + free($3); } ; @@ -198,7 +228,7 @@ { last_driver = *instance = affile_dd_new($1, configuration); last_writer_options = &((AFFileDestDriver *) last_driver)->writer_options; - last_file_perm_options = &((AFFileDestDriver *) last_driver)->file_perm_options; + last_file_perm_options = &((AFFileDestDriver *) last_driver)->file_opener_options.file_perm_options; } dest_affile_options { $$ = last_driver; free($1); } ; @@ -221,9 +251,9 @@ dest_afpipe_params : string { - last_driver = *instance = afpipe_dd_new($1, configuration); + last_driver = *instance = pipe_dd_new($1, configuration); last_writer_options = &((AFFileDestDriver *) last_driver)->writer_options; - last_file_perm_options = &((AFFileDestDriver *) last_driver)->file_perm_options; + last_file_perm_options = &((AFFileDestDriver *) last_driver)->file_opener_options.file_perm_options; } dest_afpipe_options { $$ = last_driver; free($1); } ; diff -Nru syslog-ng-3.11.1/modules/affile/affile-parser.c syslog-ng-3.13.2/modules/affile/affile-parser.c --- syslog-ng-3.11.1/modules/affile/affile-parser.c 2017-07-31 09:05:32.000000000 +0000 +++ syslog-ng-3.13.2/modules/affile/affile-parser.c 2017-12-06 06:39:39.000000000 +0000 @@ -34,6 +34,7 @@ { "file", KW_FILE }, { "fifo", KW_PIPE }, { "pipe", KW_PIPE }, + { "stdin", KW_STDIN }, { "wildcard_file", KW_WILDCARD_FILE }, { "base_dir", KW_BASE_DIR }, diff -Nru syslog-ng-3.11.1/modules/affile/affile-parser.h syslog-ng-3.13.2/modules/affile/affile-parser.h --- syslog-ng-3.11.1/modules/affile/affile-parser.h 2017-07-31 09:05:32.000000000 +0000 +++ syslog-ng-3.13.2/modules/affile/affile-parser.h 2017-12-06 06:39:39.000000000 +0000 @@ -25,7 +25,6 @@ #define AFFILE_PARSER_H_INCLUDED #include "cfg-parser.h" -#include "cfg-lexer.h" #include "driver.h" extern CfgParser affile_parser; diff -Nru syslog-ng-3.11.1/modules/affile/affile-plugin.c syslog-ng-3.13.2/modules/affile/affile-plugin.c --- syslog-ng-3.11.1/modules/affile/affile-plugin.c 2017-07-31 09:05:32.000000000 +0000 +++ syslog-ng-3.13.2/modules/affile/affile-plugin.c 2017-12-06 06:39:39.000000000 +0000 @@ -24,6 +24,7 @@ #include "cfg-parser.h" #include "plugin.h" #include "plugin-types.h" +#include "affile-dest.h" extern CfgParser affile_parser; @@ -45,6 +46,11 @@ .parser = &affile_parser, }, { + .type = LL_CONTEXT_SOURCE, + .name = "stdin", + .parser = &affile_parser, + }, + { .type = LL_CONTEXT_DESTINATION, .name = "file", .parser = &affile_parser, @@ -57,9 +63,10 @@ }; gboolean -affile_module_init(GlobalConfig *cfg, CfgArgs *args) +affile_module_init(PluginContext *context, CfgArgs *args) { - plugin_register(cfg, affile_plugins, G_N_ELEMENTS(affile_plugins)); + plugin_register(context, affile_plugins, G_N_ELEMENTS(affile_plugins)); + affile_dd_global_init(); return TRUE; } diff -Nru syslog-ng-3.11.1/modules/affile/affile-source.c syslog-ng-3.13.2/modules/affile/affile-source.c --- syslog-ng-3.11.1/modules/affile/affile-source.c 2017-07-31 09:05:32.000000000 +0000 +++ syslog-ng-3.13.2/modules/affile/affile-source.c 2017-12-06 06:39:39.000000000 +0000 @@ -24,7 +24,7 @@ #include "driver.h" #include "messages.h" #include "gprocess.h" -#include "mainloop.h" +#include "file-specializations.h" #include #include @@ -37,11 +37,29 @@ #include -#define DEFAULT_SD_OPEN_FLAGS (O_RDONLY | O_NOCTTY | O_NONBLOCK | O_LARGEFILE) -#define DEFAULT_SD_OPEN_FLAGS_PIPE (O_RDWR | O_NOCTTY | O_NONBLOCK | O_LARGEFILE) + +static gboolean +_is_linux_proc_kmsg(const gchar *filename) +{ +#ifdef __linux__ + if (strcmp(filename, "/proc/kmsg") == 0) + return TRUE; +#endif + return FALSE; +} + +static gboolean +_is_linux_dev_kmsg(const gchar *filename) +{ +#ifdef __linux__ + if (strcmp(filename, "/dev/kmsg") == 0) + return TRUE; +#endif + return FALSE; +} static inline gboolean -affile_is_device_node(const gchar *filename) +_is_device_node(const gchar *filename) { struct stat st; @@ -66,11 +84,14 @@ static gboolean _are_multi_line_settings_invalid(AFFileSourceDriver *self) { - gboolean is_garbage_mode = self->file_reader_options.multi_line_mode == MLM_PREFIX_GARBAGE; - gboolean is_suffix_mode = self->file_reader_options.multi_line_mode == MLM_PREFIX_SUFFIX; + LogProtoMultiLineServerOptions *multi_line_options = + (LogProtoMultiLineServerOptions *) &self->file_reader_options.reader_options.proto_options; - return (!is_garbage_mode && !is_suffix_mode) && (self->file_reader_options.multi_line_prefix - || self->file_reader_options.multi_line_garbage); + gboolean is_garbage_mode = multi_line_options->mode == MLM_PREFIX_GARBAGE; + gboolean is_suffix_mode = multi_line_options->mode == MLM_PREFIX_SUFFIX; + + return (!is_garbage_mode && !is_suffix_mode) && (multi_line_options->prefix + || multi_line_options->garbage); } static gboolean @@ -82,7 +103,13 @@ if (!log_src_driver_init_method(s)) return FALSE; - log_reader_options_init(&self->file_reader_options.reader_options, cfg, self->super.super.group); + file_reader_options_init(&self->file_reader_options, cfg, self->super.super.group); + file_opener_options_init(&self->file_opener_options, cfg); + + file_opener_set_options(self->file_opener, &self->file_opener_options); + self->file_reader = file_reader_new(self->filename->str, &self->file_reader_options, + self->file_opener, + &self->super, cfg); if (_are_multi_line_settings_invalid(self)) { @@ -113,32 +140,33 @@ { AFFileSourceDriver *self = (AFFileSourceDriver *) s; + file_opener_free(self->file_opener); log_pipe_unref(&self->file_reader->super); g_string_free(self->filename, TRUE); - file_reader_options_destroy(&self->file_reader_options); + file_reader_options_deinit(&self->file_reader_options); + file_opener_options_deinit(&self->file_opener_options); log_src_driver_free(s); } -static AFFileSourceDriver * +AFFileSourceDriver * affile_sd_new_instance(gchar *filename, GlobalConfig *cfg) { AFFileSourceDriver *self = g_new0(AFFileSourceDriver, 1); log_src_driver_init_instance(&self->super, cfg); - self->filename = g_string_new(filename); - self->file_reader = file_reader_new(filename, &self->super, cfg); - self->file_reader->file_reader_options = &self->file_reader_options; self->super.super.super.init = affile_sd_init; self->super.super.super.queue = affile_sd_queue; self->super.super.super.deinit = affile_sd_deinit; self->super.super.super.free_fn = affile_sd_free; self->super.super.super.generate_persist_name = affile_sd_format_persist_name; - log_reader_options_defaults(&self->file_reader_options.reader_options); - file_perm_options_defaults(&self->file_reader_options.file_perm_options); - self->file_reader_options.reader_options.parse_options.flags |= LP_LOCAL; - if (affile_is_linux_proc_kmsg(filename)) - self->file_reader_options.file_open_options.needs_privileges = TRUE; + self->filename = g_string_new(filename); + + file_reader_options_defaults(&self->file_reader_options); + self->file_reader_options.reader_options.super.stats_level = STATS_LEVEL1; + + file_opener_options_defaults(&self->file_opener_options); + return self; } @@ -147,45 +175,26 @@ { AFFileSourceDriver *self = affile_sd_new_instance(filename, cfg); - self->file_reader_options.file_open_options.is_pipe = FALSE; - self->file_reader_options.file_open_options.open_flags = DEFAULT_SD_OPEN_FLAGS; + self->file_reader_options.reader_options.super.stats_source = SCS_FILE; - if (cfg_is_config_version_older(cfg, 0x0300)) - { - msg_warning_once("WARNING: file source: default value of follow_freq in file sources has changed in " VERSION_3_0 - " to '1' for all files except /proc/kmsg"); - self->file_reader_options.follow_freq = -1; - } + if (_is_device_node(filename) || _is_linux_proc_kmsg(filename)) + self->file_reader_options.follow_freq = 0; else - { - if (affile_is_device_node(filename) || affile_is_linux_proc_kmsg(filename)) - self->file_reader_options.follow_freq = 0; - else - self->file_reader_options.follow_freq = 1000; - } - - return &self->super.super; -} + self->file_reader_options.follow_freq = 1000; -LogDriver * -afpipe_sd_new(gchar *filename, GlobalConfig *cfg) -{ - AFFileSourceDriver *self = affile_sd_new_instance(filename, cfg); - - self->file_reader_options.file_open_options.is_pipe = TRUE; - self->file_reader_options.file_open_options.open_flags = DEFAULT_SD_OPEN_FLAGS_PIPE; - - if (cfg_is_config_version_older(cfg, 0x0302)) + if (self->file_reader_options.follow_freq > 0) + self->file_opener = file_opener_for_regular_source_files_new(); + else if (_is_linux_proc_kmsg(self->filename->str)) { - msg_warning_once("WARNING: the expected message format is being changed for pipe() to improve " - "syslogd compatibity with " VERSION_3_2 ". If you are using custom " - "applications which bypass the syslog() API, you might " - "need the 'expect-hostname' flag to get the old behaviour back"); + self->file_opener_options.needs_privileges = TRUE; + self->file_opener = file_opener_for_prockmsg_new(); } + else if (_is_linux_dev_kmsg(self->filename->str)) + self->file_opener = file_opener_for_devkmsg_new(); else - { - self->file_reader_options.reader_options.parse_options.flags &= ~LP_EXPECT_HOSTNAME; - } + self->file_opener = file_opener_for_regular_source_files_new(); + self->file_reader_options.restore_state = self->file_reader_options.follow_freq > 0; + file_opener_options_defaults_dont_change_permissions(&self->file_opener_options); return &self->super.super; } diff -Nru syslog-ng-3.11.1/modules/affile/affile-source.h syslog-ng-3.13.2/modules/affile/affile-source.h --- syslog-ng-3.11.1/modules/affile/affile-source.h 2017-07-31 09:05:32.000000000 +0000 +++ syslog-ng-3.13.2/modules/affile/affile-source.h 2017-12-06 06:39:39.000000000 +0000 @@ -26,8 +26,7 @@ #include "driver.h" #include "logreader.h" -#include "logproto/logproto-regexp-multiline-server.h" -#include "affile-common.h" +#include "file-opener.h" #include "file-reader.h" typedef struct _AFFileSourceDriver @@ -35,12 +34,14 @@ LogSrcDriver super; GString *filename; FileReader *file_reader; + FileOpener *file_opener; FileReaderOptions file_reader_options; - /* state information to follow a set of files using a wildcard expression */ + FileOpenerOptions file_opener_options; } AFFileSourceDriver; +AFFileSourceDriver *affile_sd_new_instance(gchar *filename, GlobalConfig *cfg); LogDriver *affile_sd_new(gchar *filename, GlobalConfig *cfg); -LogDriver *afpipe_sd_new(gchar *filename, GlobalConfig *cfg); + void affile_sd_set_recursion(LogDriver *s, const gint recursion); void affile_sd_set_pri_level(LogDriver *s, const gint16 severity); diff -Nru syslog-ng-3.11.1/modules/affile/CMakeLists.txt syslog-ng-3.13.2/modules/affile/CMakeLists.txt --- syslog-ng-3.11.1/modules/affile/CMakeLists.txt 2017-07-31 09:05:32.000000000 +0000 +++ syslog-ng-3.13.2/modules/affile/CMakeLists.txt 2017-12-06 06:39:39.000000000 +0000 @@ -1,9 +1,13 @@ set(AFFILE_HEADERS - "logproto-linux-proc-kmsg-reader.h" "logproto-file-writer.h" + "logproto-file-reader.h" "poll-file-changes.h" + "transport-prockmsg.h" "file-reader.h" - "affile-common.h" + "file-opener.h" + "file-specializations.h" + "stdin.h" + "named-pipe.h" "affile-source.h" "affile-dest.h" "affile-parser.h" @@ -18,9 +22,15 @@ set(AFFILE_SOURCES "logproto-file-writer.c" + "logproto-file-reader.c" "poll-file-changes.c" + "transport-prockmsg.c" "file-reader.c" - "affile-common.c" + "file-opener.c" + "regular-files.c" + "named-pipe.c" + "linux-kmsg.c" + "stdin.c" "affile-source.c" "affile-dest.c" "affile-parser.c" diff -Nru syslog-ng-3.11.1/modules/affile/collection-comporator.c syslog-ng-3.13.2/modules/affile/collection-comporator.c --- syslog-ng-3.11.1/modules/affile/collection-comporator.c 2017-07-31 09:05:32.000000000 +0000 +++ syslog-ng-3.13.2/modules/affile/collection-comporator.c 2017-12-06 06:39:39.000000000 +0000 @@ -61,7 +61,7 @@ } CollectionComporator * -collection_comporator_new() +collection_comporator_new(void) { CollectionComporator *self = g_new0(CollectionComporator, 1); self->original_map = g_hash_table_new(g_str_hash, g_str_equal); diff -Nru syslog-ng-3.11.1/modules/affile/collection-comporator.h syslog-ng-3.13.2/modules/affile/collection-comporator.h --- syslog-ng-3.11.1/modules/affile/collection-comporator.h 2017-07-31 09:05:32.000000000 +0000 +++ syslog-ng-3.13.2/modules/affile/collection-comporator.h 2017-12-06 06:39:39.000000000 +0000 @@ -28,7 +28,7 @@ typedef void (*cc_callback)(const gchar *value, gpointer user_data); -CollectionComporator *collection_comporator_new(); +CollectionComporator *collection_comporator_new(void); void collection_comporator_free(CollectionComporator *self); void collection_comporator_start(CollectionComporator *self); void collection_comporator_stop(CollectionComporator *self); diff -Nru syslog-ng-3.11.1/modules/affile/directory-monitor.c syslog-ng-3.13.2/modules/affile/directory-monitor.c --- syslog-ng-3.11.1/modules/affile/directory-monitor.c 2017-07-31 09:05:32.000000000 +0000 +++ syslog-ng-3.13.2/modules/affile/directory-monitor.c 2017-12-06 06:39:39.000000000 +0000 @@ -54,7 +54,7 @@ #define PATH_MAX_GUESS 1024 static inline long -get_path_max() +get_path_max(void) { static long path_max = 0; if (path_max == 0) diff -Nru syslog-ng-3.11.1/modules/affile/file-opener.c syslog-ng-3.13.2/modules/affile/file-opener.c --- syslog-ng-3.11.1/modules/affile/file-opener.c 1970-01-01 00:00:00.000000000 +0000 +++ syslog-ng-3.13.2/modules/affile/file-opener.c 2017-12-06 06:39:39.000000000 +0000 @@ -0,0 +1,235 @@ +/* + * Copyright (c) 2002-2013 Balabit + * Copyright (c) 1998-2012 Balázs Scheidler + * + * This program is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 as published + * by the Free Software Foundation, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + * + * As an additional exemption you are allowed to compile & link against the + * OpenSSL libraries as published by the OpenSSL project. See the file + * COPYING for details. + * + */ +#include "file-opener.h" +#include "messages.h" +#include "gprocess.h" +#include "fdhelpers.h" +#include "pathutils.h" +#include "cfg.h" +#include "transport/transport-file.h" + +#include +#include +#include +#include +#include +#include +#include +#include + +static inline gboolean +file_opener_prepare_open(FileOpener *self, const gchar *name) +{ + if (self->prepare_open) + return self->prepare_open(self, name); + return TRUE; +} + +static inline gint +file_opener_open(FileOpener *self, const gchar *name, gint flags) +{ + return self->open(self, name, flags); +} + +static gint +file_opener_get_open_flags_method(FileOpener *self, FileDirection dir) +{ + switch (dir) + { + case AFFILE_DIR_READ: + return O_RDONLY | O_NOCTTY | O_NONBLOCK | O_LARGEFILE; + case AFFILE_DIR_WRITE: + return O_WRONLY | O_CREAT | O_NOCTTY | O_NONBLOCK | O_LARGEFILE | O_APPEND; + default: + g_assert_not_reached(); + } +} + +static inline gint +file_opener_get_open_flags(FileOpener *self, FileDirection dir) +{ + return self->get_open_flags(self, dir); +} + +static const gchar *spurious_paths[] = {"../", "/..", NULL}; + +static inline gboolean +_string_contains_fragment(const gchar *str, const gchar *fragments[]) +{ + int i; + + for (i = 0; fragments[i]; i++) + { + if (strstr(str, fragments[i])) + return TRUE; + } + + return FALSE; +} + +static inline gboolean +_is_path_spurious(const gchar *name) +{ + return _string_contains_fragment(name, spurious_paths); +} + +static inline gboolean +_obtain_capabilities(FileOpener *self, gchar *name, cap_t *act_caps) +{ + if (self->options->needs_privileges) + { + g_process_cap_modify(CAP_DAC_READ_SEARCH, TRUE); + g_process_cap_modify(CAP_SYSLOG, TRUE); + } + else + { + g_process_cap_modify(CAP_DAC_OVERRIDE, TRUE); + } + + if (self->options->create_dirs && + !file_perm_options_create_containing_directory(&self->options->file_perm_options, name)) + { + return FALSE; + } + + return TRUE; +} + +static inline void +_set_fd_permission(FileOpener *self, int fd) +{ + if (fd != -1) + { + g_fd_set_cloexec(fd, TRUE); + + g_process_cap_modify(CAP_CHOWN, TRUE); + g_process_cap_modify(CAP_FOWNER, TRUE); + + file_perm_options_apply_fd(&self->options->file_perm_options, fd); + } +} + +static int +_open(FileOpener *self, const gchar *name, gint open_flags) +{ + FilePermOptions *perm_opts = &self->options->file_perm_options; + int fd; + int mode = (perm_opts && (perm_opts->file_perm >= 0)) + ? perm_opts->file_perm : 0600; + + fd = open(name, open_flags, mode); + + return fd; +} + +gboolean +file_opener_open_fd(FileOpener *self, gchar *name, FileDirection dir, gint *fd) +{ + cap_t saved_caps; + + if (_is_path_spurious(name)) + { + msg_error("Spurious path, logfile not created", + evt_tag_str("path", name)); + return FALSE; + } + + saved_caps = g_process_cap_save(); + + if (!_obtain_capabilities(self, name, &saved_caps)) + { + g_process_cap_restore(saved_caps); + return FALSE; + } + + if (!file_opener_prepare_open(self, name)) + return FALSE; + + *fd = file_opener_open(self, name, file_opener_get_open_flags(self, dir)); + + if (!is_file_device(name)) + _set_fd_permission(self, *fd); + + g_process_cap_restore(saved_caps); + + msg_trace("affile_open_file", + evt_tag_str("path", name), + evt_tag_int("fd", *fd)); + + return (*fd != -1); +} + +void +file_opener_set_options(FileOpener *self, FileOpenerOptions *options) +{ + self->options = options; +} + +void +file_opener_init_instance(FileOpener *self) +{ + self->get_open_flags = file_opener_get_open_flags_method; + self->open = _open; +} + +FileOpener * +file_opener_new(void) +{ + FileOpener *self = g_new0(FileOpener, 1); + + file_opener_init_instance(self); + return self; +} + +void +file_opener_free(FileOpener *self) +{ + g_free(self); +} + +void +file_opener_options_defaults(FileOpenerOptions *options) +{ + file_perm_options_defaults(&options->file_perm_options); + options->create_dirs = -1; + options->needs_privileges = FALSE; +} + +void +file_opener_options_defaults_dont_change_permissions(FileOpenerOptions *options) +{ + file_opener_options_defaults(options); + file_perm_options_inherit_dont_change(&options->file_perm_options); +} + +void +file_opener_options_init(FileOpenerOptions *options, GlobalConfig *cfg) +{ + file_perm_options_inherit_from(&options->file_perm_options, &cfg->file_perm_options); +} + +void +file_opener_options_deinit(FileOpenerOptions *options) +{ + /* empty, this function only serves to meet the conventions of *Options */ +} diff -Nru syslog-ng-3.11.1/modules/affile/file-opener.h syslog-ng-3.13.2/modules/affile/file-opener.h --- syslog-ng-3.11.1/modules/affile/file-opener.h 1970-01-01 00:00:00.000000000 +0000 +++ syslog-ng-3.13.2/modules/affile/file-opener.h 2017-12-06 06:39:39.000000000 +0000 @@ -0,0 +1,93 @@ +/* + * Copyright (c) 2002-2013 Balabit + * Copyright (c) 1998-2012 Balázs Scheidler + * + * This program is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 as published + * by the Free Software Foundation, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + * + * As an additional exemption you are allowed to compile & link against the + * OpenSSL libraries as published by the OpenSSL project. See the file + * COPYING for details. + * + */ + +#ifndef AFFILE_FILE_OPENER_H_INCLUDED +#define AFFILE_FILE_OPENER_H_INCLUDED + +/* portable largefile support for affile */ +#include "compat/lfs.h" + +#include "file-perms.h" +#include "transport/logtransport.h" +#include "logproto/logproto-server.h" +#include "logproto/logproto-client.h" +#include "logproto-file-reader.h" +#include + +typedef enum +{ + AFFILE_DIR_READ = 0x01, + AFFILE_DIR_WRITE = 0x02, +} FileDirection; + +typedef struct _FileOpenerOptions +{ + FilePermOptions file_perm_options; + gboolean needs_privileges:1; + gint create_dirs; +} FileOpenerOptions; + +typedef struct _FileOpener FileOpener; +struct _FileOpener +{ + FileOpenerOptions *options; + gboolean (*prepare_open)(FileOpener *self, const gchar *name); + gint (*open)(FileOpener *self, const gchar *name, gint flags); + gint (*get_open_flags)(FileOpener *self, FileDirection dir); + LogTransport *(*construct_transport)(FileOpener *self, gint fd); + LogProtoServer *(*construct_src_proto)(FileOpener *self, LogTransport *transport, LogProtoFileReaderOptions *proto_options); + LogProtoClient *(*construct_dst_proto)(FileOpener *self, LogTransport *transport, LogProtoClientOptions *proto_options); +}; + +static inline LogTransport * +file_opener_construct_transport(FileOpener *self, gint fd) +{ + return self->construct_transport(self, fd); +} + +static inline LogProtoServer * +file_opener_construct_src_proto(FileOpener *self, LogTransport *transport, LogProtoFileReaderOptions *proto_options) +{ + return self->construct_src_proto(self, transport, proto_options); +} + +static inline LogProtoClient * +file_opener_construct_dst_proto(FileOpener *self, LogTransport *transport, LogProtoClientOptions *proto_options) +{ + return self->construct_dst_proto(self, transport, proto_options); +} + +gboolean file_opener_open_fd(FileOpener *self, gchar *name, FileDirection dir, gint *fd); + +void file_opener_set_options(FileOpener *self, FileOpenerOptions *options); +void file_opener_init_instance(FileOpener *self); +FileOpener *file_opener_new(void); +void file_opener_free(FileOpener *self); + +void file_opener_options_defaults(FileOpenerOptions *options); +void file_opener_options_defaults_dont_change_permissions(FileOpenerOptions *options); +void file_opener_options_init(FileOpenerOptions *options, GlobalConfig *cfg); +void file_opener_options_deinit(FileOpenerOptions *options); + + +#endif diff -Nru syslog-ng-3.11.1/modules/affile/file-reader.c syslog-ng-3.13.2/modules/affile/file-reader.c --- syslog-ng-3.11.1/modules/affile/file-reader.c 2017-07-31 09:05:32.000000000 +0000 +++ syslog-ng-3.13.2/modules/affile/file-reader.c 2017-12-06 06:39:39.000000000 +0000 @@ -26,15 +26,9 @@ #include "serialize.h" #include "gprocess.h" #include "stats/stats-registry.h" -#include "mainloop.h" #include "transport/transport-file.h" #include "transport/transport-pipe.h" -#include "transport/transport-device.h" -#include "logproto/logproto-record-server.h" -#include "logproto/logproto-text-server.h" -#include "logproto/logproto-dgram-server.h" -#include "logproto/logproto-indented-multiline-server.h" -#include "logproto-linux-proc-kmsg-reader.h" +#include "transport-prockmsg.h" #include "poll-fd-events.h" #include "poll-file-changes.h" @@ -49,25 +43,6 @@ #include - -static inline gboolean -_is_linux_dev_kmsg(const gchar *filename) -{ -#ifdef __linux__ - if (strcmp(filename, "/dev/kmsg") == 0) - return TRUE; -#endif - return FALSE; -} - -static gboolean -_sd_open_file(FileReader *self, gchar *name, gint *fd) -{ - return affile_open_file(name, - &self->file_reader_options->file_open_options, - &self->file_reader_options->file_perm_options, fd); -} - static inline const gchar * _format_persist_name(const LogPipe *s) { @@ -87,7 +62,7 @@ { FileReader *self = (FileReader *) s; - if (self->file_reader_options->file_open_options.is_pipe || self->file_reader_options->follow_freq <= 0) + if (!self->options->restore_state) return; if (!log_proto_server_restart_with_state(proto, cfg->state, _format_persist_name(s))) @@ -117,8 +92,8 @@ static PollEvents * _construct_poll_events(FileReader *self, gint fd) { - if (self->file_reader_options->follow_freq > 0) - return poll_file_changes_new(fd, self->filename->str, self->file_reader_options->follow_freq, &self->super); + if (self->options->follow_freq > 0) + return poll_file_changes_new(fd, self->filename->str, self->options->follow_freq, &self->super); else if (fd >= 0 && _is_fd_pollable(fd)) return poll_fd_events_new(fd); else @@ -135,30 +110,14 @@ static LogTransport * _construct_transport(FileReader *self, gint fd) { - if (self->file_reader_options->file_open_options.is_pipe) - return log_transport_pipe_new(fd); - else if (self->file_reader_options->follow_freq > 0) - return log_transport_file_new(fd); - else if (affile_is_linux_proc_kmsg(self->filename->str)) - return log_transport_device_new(fd, 10); - else if (_is_linux_dev_kmsg(self->filename->str)) - { - if (lseek(fd, 0, SEEK_END) < 0) - { - msg_error("Error seeking /dev/kmsg to the end", - evt_tag_str("error", g_strerror(errno))); - } - return log_transport_device_new(fd, 0); - } - else - return log_transport_pipe_new(fd); + return file_opener_construct_transport(self->opener, fd); } static LogProtoServer * _construct_proto(FileReader *self, gint fd) { - LogReaderOptions *reader_options = &self->file_reader_options->reader_options; - LogProtoServerOptions *proto_options = &reader_options->proto_options.super; + LogReaderOptions *reader_options = &self->options->reader_options; + LogProtoFileReaderOptions *proto_options = file_reader_options_get_log_proto_options(self->options); LogTransport *transport; MsgFormatHandler *format_handler; @@ -167,38 +126,11 @@ format_handler = reader_options->parse_options.format_handler; if ((format_handler && format_handler->construct_proto)) { - proto_options->position_tracking_enabled = TRUE; - return format_handler->construct_proto(&reader_options->parse_options, transport, proto_options); + proto_options->super.super.position_tracking_enabled = TRUE; + return format_handler->construct_proto(&reader_options->parse_options, transport, &proto_options->super.super); } - if (self->file_reader_options->pad_size) - { - proto_options->position_tracking_enabled = TRUE; - return log_proto_padded_record_server_new(transport, proto_options, self->file_reader_options->pad_size); - } - else if (affile_is_linux_proc_kmsg(self->filename->str)) - return log_proto_linux_proc_kmsg_reader_new(transport, proto_options); - else if (_is_linux_dev_kmsg(self->filename->str)) - return log_proto_dgram_server_new(transport, proto_options); - else - { - proto_options->position_tracking_enabled = TRUE; - switch (self->file_reader_options->multi_line_mode) - { - case MLM_INDENTED: - return log_proto_indented_multiline_server_new(transport, proto_options); - case MLM_PREFIX_GARBAGE: - return log_proto_prefix_garbage_multiline_server_new(transport, proto_options, - self->file_reader_options->multi_line_prefix, - self->file_reader_options->multi_line_garbage); - case MLM_PREFIX_SUFFIX: - return log_proto_prefix_suffix_multiline_server_new(transport, proto_options, - self->file_reader_options->multi_line_prefix, - self->file_reader_options->multi_line_garbage); - default: - return log_proto_text_server_new(transport, proto_options); - } - } + return file_opener_construct_src_proto(self->opener, transport, proto_options); } static void @@ -209,26 +141,19 @@ self->reader = NULL; } -static gint -_get_stats_source(FileReader *self) -{ - return self->file_reader_options->file_open_options.is_pipe ? SCS_PIPE : SCS_FILE; -} - static void _setup_logreader(LogPipe *s, PollEvents *poll_events, LogProtoServer *proto, gboolean check_immediately) { FileReader *self = (FileReader *) s; + self->reader = log_reader_new(log_pipe_get_config(s)); log_reader_reopen(self->reader, proto, poll_events); - log_reader_set_options(self->reader, s, - &self->file_reader_options->reader_options, - STATS_LEVEL1, - _get_stats_source(self), + &self->options->reader_options, self->owner->super.id, self->filename->str); + if (check_immediately) log_reader_set_immediate_check(self->reader); @@ -256,8 +181,8 @@ gint fd; gboolean file_opened, open_deferred = FALSE; - file_opened = _sd_open_file(self, self->filename->str, &fd); - if (!file_opened && self->file_reader_options->follow_freq > 0) + file_opened = file_opener_open_fd(self->opener, self->filename->str, AFFILE_DIR_READ, &fd); + if (!file_opened && self->options->follow_freq > 0) { msg_info("Follow-mode file source not found, deferring open", evt_tag_str("filename", self->filename->str)); open_deferred = TRUE; @@ -319,20 +244,23 @@ switch (notify_code) { + case NC_CLOSE: + if (self->options->exit_on_eof) + cfg_shutdown(log_pipe_get_config(s)); + break; + case NC_FILE_MOVED: - { msg_verbose("Follow-mode file source moved, tracking of the new file is started", evt_tag_str("filename", self->filename->str)); _reopen_on_notify(s, TRUE); break; - } + case NC_READ_ERROR: - { msg_verbose("Error while following source file, reopening in the hope it would work", evt_tag_str("filename", self->filename->str)); _reopen_on_notify(s, FALSE); break; - } + default: break; } @@ -369,9 +297,11 @@ static void _free(LogPipe *s) { - FileReader *self = (FileReader *)s; - g_string_free(self->filename, TRUE); + FileReader *self = (FileReader *) s; + g_assert(!self->reader); + + g_string_free(self->filename, TRUE); } void @@ -385,65 +315,51 @@ } FileReader * -file_reader_new(const gchar *filename, LogSrcDriver *owner, GlobalConfig *cfg) +file_reader_new(const gchar *filename, FileReaderOptions *options, FileOpener *opener, LogSrcDriver *owner, + GlobalConfig *cfg) { FileReader *self = g_new0(FileReader, 1); + log_pipe_init_instance(&self->super, cfg); - self->owner = owner; - self->filename = g_string_new(filename); self->super.init = _init; self->super.queue = _queue; self->super.deinit = _deinit; self->super.notify = _notify; self->super.free_fn = _free; self->super.generate_persist_name = _format_persist_name; - return self; -} -gboolean -file_reader_options_set_multi_line_mode(FileReaderOptions *options, const gchar *mode) -{ - if (strcasecmp(mode, "indented") == 0) - options->multi_line_mode = MLM_INDENTED; - else if (strcasecmp(mode, "regexp") == 0) - options->multi_line_mode = MLM_PREFIX_GARBAGE; - else if (strcasecmp(mode, "prefix-garbage") == 0) - options->multi_line_mode = MLM_PREFIX_GARBAGE; - else if (strcasecmp(mode, "prefix-suffix") == 0) - options->multi_line_mode = MLM_PREFIX_SUFFIX; - else if (strcasecmp(mode, "none") == 0) - options->multi_line_mode = MLM_NONE; - else - return FALSE; - return TRUE; + self->filename = g_string_new(filename); + self->options = options; + self->opener = opener; + self->owner = owner; + return self; } -gboolean -file_reader_options_set_multi_line_prefix(FileReaderOptions *options, const gchar *prefix_regexp, GError **error) +void +file_reader_options_set_follow_freq(FileReaderOptions *options, gint follow_freq) { - options->multi_line_prefix = multi_line_regexp_compile(prefix_regexp, error); - return options->multi_line_prefix != NULL; + options->follow_freq = follow_freq; } -gboolean -file_reader_options_set_multi_line_garbage(FileReaderOptions *options, const gchar *garbage_regexp, GError **error) +void +file_reader_options_defaults(FileReaderOptions *options) { - options->multi_line_garbage = multi_line_regexp_compile(garbage_regexp, error); - return options->multi_line_garbage != NULL; + log_reader_options_defaults(&options->reader_options); + log_proto_file_reader_options_defaults(file_reader_options_get_log_proto_options(options)); + options->reader_options.parse_options.flags |= LP_LOCAL; + options->restore_state = FALSE; } - void -file_reader_options_set_follow_freq(FileReaderOptions *options, gint follow_freq) +file_reader_options_init(FileReaderOptions *options, GlobalConfig *cfg, const gchar *group) { - options->follow_freq = follow_freq; + log_reader_options_init(&options->reader_options, cfg, group); + log_proto_file_reader_options_init(file_reader_options_get_log_proto_options(options)); } void -file_reader_options_destroy(FileReaderOptions *options) +file_reader_options_deinit(FileReaderOptions *options) { log_reader_options_destroy(&options->reader_options); - - multi_line_regexp_free(options->multi_line_prefix); - multi_line_regexp_free(options->multi_line_garbage); + log_proto_file_reader_options_destroy(file_reader_options_get_log_proto_options(options)); } diff -Nru syslog-ng-3.11.1/modules/affile/file-reader.h syslog-ng-3.13.2/modules/affile/file-reader.h --- syslog-ng-3.11.1/modules/affile/file-reader.h 2017-07-31 09:05:32.000000000 +0000 +++ syslog-ng-3.13.2/modules/affile/file-reader.h 2017-12-06 06:39:39.000000000 +0000 @@ -24,25 +24,14 @@ #include "driver.h" #include "logreader.h" -#include "logproto/logproto-regexp-multiline-server.h" -#include "affile-common.h" +#include "file-opener.h" -enum +typedef struct _FileReaderOptions { - MLM_NONE, - MLM_INDENTED, - MLM_PREFIX_GARBAGE, - MLM_PREFIX_SUFFIX, -}; - -typedef struct _FileReaderOptions { - FilePermOptions file_perm_options; - FileOpenOptions file_open_options; - gint pad_size; gint follow_freq; - gint multi_line_mode; - MultiLineRegexp *multi_line_prefix, *multi_line_garbage; + gboolean restore_state; LogReaderOptions reader_options; + gboolean exit_on_eof; } FileReaderOptions; typedef struct _FileReader @@ -50,20 +39,27 @@ LogPipe super; LogSrcDriver *owner; GString *filename; - FileReaderOptions *file_reader_options; + FileReaderOptions *options; + FileOpener *opener; LogReader *reader; + gboolean is_pipe; } FileReader; -FileReader *file_reader_new(const gchar *filename, LogSrcDriver *owner, GlobalConfig *cfg); +static inline LogProtoFileReaderOptions * +file_reader_options_get_log_proto_options(FileReaderOptions *options) +{ + return (LogProtoFileReaderOptions *) &options->reader_options.proto_options; +} + +FileReader *file_reader_new(const gchar *filename, FileReaderOptions *options, FileOpener *opener, LogSrcDriver *owner, GlobalConfig *cfg); void file_reader_remove_persist_state(FileReader *self); void file_reader_options_set_follow_freq(FileReaderOptions *options, gint follow_freq); -gboolean file_reader_options_set_multi_line_mode(FileReaderOptions *options, const gchar *mode); -gboolean file_reader_options_set_multi_line_prefix(FileReaderOptions *options, const gchar *prefix_regexp, GError **error); -gboolean file_reader_options_set_multi_line_garbage(FileReaderOptions *options, const gchar *prefix_regexp, GError **error); -void file_reader_options_destroy(FileReaderOptions *options); +void file_reader_options_defaults(FileReaderOptions *options); +void file_reader_options_init(FileReaderOptions *options, GlobalConfig *cfg, const gchar *group); +void file_reader_options_deinit(FileReaderOptions *options); #endif /* MODULES_AFFILE_FILE_READER_H_ */ diff -Nru syslog-ng-3.11.1/modules/affile/file-specializations.h syslog-ng-3.13.2/modules/affile/file-specializations.h --- syslog-ng-3.11.1/modules/affile/file-specializations.h 1970-01-01 00:00:00.000000000 +0000 +++ syslog-ng-3.13.2/modules/affile/file-specializations.h 2017-12-06 06:39:39.000000000 +0000 @@ -0,0 +1,35 @@ +/* + * Copyright (c) 2017 Balabit + * Copyright (c) 2017 Balázs Scheidler + * + * This program is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 as published + * by the Free Software Foundation, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + * + * As an additional exemption you are allowed to compile & link against the + * OpenSSL libraries as published by the OpenSSL project. See the file + * COPYING for details. + * + */ + +#ifndef AFFILE_FILE_SPECIALIZATIONS_H_INCLUDED +#define AFFILE_FILE_SPECIALIZATIONS_H_INCLUDED + +#include "file-opener.h" +#include "logwriter.h" + +FileOpener *file_opener_for_regular_source_files_new(void); +FileOpener *file_opener_for_regular_dest_files_new(const LogWriterOptions *writer_options, gboolean *use_fsync); +FileOpener *file_opener_for_devkmsg_new(void); +FileOpener *file_opener_for_prockmsg_new(void); + +#endif diff -Nru syslog-ng-3.11.1/modules/affile/linux-kmsg.c syslog-ng-3.13.2/modules/affile/linux-kmsg.c --- syslog-ng-3.11.1/modules/affile/linux-kmsg.c 1970-01-01 00:00:00.000000000 +0000 +++ syslog-ng-3.13.2/modules/affile/linux-kmsg.c 2017-12-06 06:39:39.000000000 +0000 @@ -0,0 +1,107 @@ +/* + * Copyright (c) 2017 Balabit + * Copyright (c) 2017 Balázs Scheidler + * + * This program is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 as published + * by the Free Software Foundation, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + * + * As an additional exemption you are allowed to compile & link against the + * OpenSSL libraries as published by the OpenSSL project. See the file + * COPYING for details. + * + */ +#include "file-specializations.h" +#include "transport/transport-file.h" +#include "transport-prockmsg.h" +#include "messages.h" +#include "logproto/logproto-dgram-server.h" +#include "logproto/logproto-text-server.h" + +#include +#include + +/************************************************************** + * /dev/kmsg support + **************************************************************/ + + +LogTransport * +log_transport_devkmsg_new(gint fd) +{ + if (lseek(fd, 0, SEEK_END) < 0) + { + msg_error("Error seeking /dev/kmsg to the end", + evt_tag_str("error", g_strerror(errno))); + } + return log_transport_file_new(fd); +} + + +static LogTransport * +_construct_devkmsg_transport(FileOpener *self, gint fd) +{ + return log_transport_devkmsg_new(fd); +} + +static LogProtoServer * +_construct_devkmsg_proto(FileOpener *self, LogTransport *transport, LogProtoFileReaderOptions *options) +{ + return log_proto_dgram_server_new(transport, &options->super.super); +} + +FileOpener * +file_opener_for_devkmsg_new(void) +{ + FileOpener *self = file_opener_new(); + + self->construct_transport = _construct_devkmsg_transport; + self->construct_src_proto = _construct_devkmsg_proto; + return self; +} + +/************************************************************** + * /proc/kmsg support + **************************************************************/ + +static LogProtoServer * +log_proto_linux_proc_kmsg_reader_new(LogTransport *transport, const LogProtoServerOptions *options) +{ + LogProtoServer *proto; + + proto = log_proto_text_server_new(transport, options); + ((LogProtoTextServer *) proto)->super.no_multi_read = TRUE; + return proto; +} + + +static LogTransport * +_construct_prockmsg_transport(FileOpener *self, gint fd) +{ + return log_transport_prockmsg_new(fd, 10); +} + +static LogProtoServer * +_construct_prockmsg_proto(FileOpener *self, LogTransport *transport, LogProtoFileReaderOptions *options) +{ + return log_proto_linux_proc_kmsg_reader_new(transport, &options->super.super); +} + +FileOpener * +file_opener_for_prockmsg_new(void) +{ + FileOpener *self = file_opener_new(); + + self->construct_transport = _construct_prockmsg_transport; + self->construct_src_proto = _construct_prockmsg_proto; + return self; +} diff -Nru syslog-ng-3.11.1/modules/affile/logproto-file-reader.c syslog-ng-3.13.2/modules/affile/logproto-file-reader.c --- syslog-ng-3.11.1/modules/affile/logproto-file-reader.c 1970-01-01 00:00:00.000000000 +0000 +++ syslog-ng-3.13.2/modules/affile/logproto-file-reader.c 2017-12-06 06:39:39.000000000 +0000 @@ -0,0 +1,54 @@ +/* + * Copyright (c) 2017 Balabit + * Copyright (c) 2017 Balázs Scheidler + * + * This program is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 as published + * by the Free Software Foundation, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + * + * As an additional exemption you are allowed to compile & link against the + * OpenSSL libraries as published by the OpenSSL project. See the file + * COPYING for details. + * + */ + +#include "logproto-file-reader.h" +#include "logproto/logproto-record-server.h" +#include "logproto/logproto-multiline-server.h" + +LogProtoServer * +log_proto_file_reader_new(LogTransport *transport, const LogProtoFileReaderOptions *options) +{ + if (options->pad_size > 0) + return log_proto_padded_record_server_new(transport, &options->super.super, options->pad_size); + else + return log_proto_multiline_server_new(transport, &options->super); +} + +void +log_proto_file_reader_options_defaults(LogProtoFileReaderOptions *options) +{ + log_proto_multi_line_server_options_defaults(&options->super); + options->pad_size = 0; +} + +void +log_proto_file_reader_options_init(LogProtoFileReaderOptions *options) +{ + log_proto_multi_line_server_options_init(&options->super); +} + +void +log_proto_file_reader_options_destroy(LogProtoFileReaderOptions *options) +{ + log_proto_multi_line_server_options_destroy(&options->super); +} diff -Nru syslog-ng-3.11.1/modules/affile/logproto-file-reader.h syslog-ng-3.13.2/modules/affile/logproto-file-reader.h --- syslog-ng-3.11.1/modules/affile/logproto-file-reader.h 1970-01-01 00:00:00.000000000 +0000 +++ syslog-ng-3.13.2/modules/affile/logproto-file-reader.h 2017-12-06 06:39:39.000000000 +0000 @@ -0,0 +1,42 @@ +/* + * Copyright (c) 2017 Balabit + * Copyright (c) 2017 Balázs Scheidler + * + * This program is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 as published + * by the Free Software Foundation, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + * + * As an additional exemption you are allowed to compile & link against the + * OpenSSL libraries as published by the OpenSSL project. See the file + * COPYING for details. + * + */ + +#ifndef LOG_PROTO_FILE_READER_H_INCLUDED +#define LOG_PROTO_FILE_READER_H_INCLUDED + +#include "logproto/logproto-multiline-server.h" + +typedef struct _LogProtoFileReaderOptions +{ + LogProtoMultiLineServerOptions super; + gint pad_size; +} LogProtoFileReaderOptions; + +LogProtoServer *log_proto_file_reader_new(LogTransport *transport, const LogProtoFileReaderOptions *options); + +void log_proto_file_reader_options_defaults(LogProtoFileReaderOptions *options); +void log_proto_file_reader_options_init(LogProtoFileReaderOptions *options); +void log_proto_file_reader_options_destroy(LogProtoFileReaderOptions *options); + + +#endif diff -Nru syslog-ng-3.11.1/modules/affile/logproto-file-writer.c syslog-ng-3.13.2/modules/affile/logproto-file-writer.c --- syslog-ng-3.11.1/modules/affile/logproto-file-writer.c 2017-07-31 09:05:32.000000000 +0000 +++ syslog-ng-3.13.2/modules/affile/logproto-file-writer.c 2017-12-06 06:39:39.000000000 +0000 @@ -179,16 +179,15 @@ ++self->buf_count; self->sum_len += msg_len; + *consumed = TRUE; + log_proto_client_msg_ack(&self->super, 1); + if (self->buf_count == self->buf_size) { /* we have reached the max buffer size -> we need to write the messages */ - result = log_proto_file_writer_flush(s); - if (result != LPS_SUCCESS) - return result; + return log_proto_file_writer_flush(s); } - *consumed = TRUE; - log_proto_client_msg_ack(&self->super, 1); return LPS_SUCCESS; } diff -Nru syslog-ng-3.11.1/modules/affile/logproto-linux-proc-kmsg-reader.h syslog-ng-3.13.2/modules/affile/logproto-linux-proc-kmsg-reader.h --- syslog-ng-3.11.1/modules/affile/logproto-linux-proc-kmsg-reader.h 2017-07-31 09:05:32.000000000 +0000 +++ syslog-ng-3.13.2/modules/affile/logproto-linux-proc-kmsg-reader.h 1970-01-01 00:00:00.000000000 +0000 @@ -1,39 +0,0 @@ -/* - * Copyright (c) 2002-2012 Balabit - * Copyright (c) 1998-2012 Balázs Scheidler - * - * This program is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 as published - * by the Free Software Foundation, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - * - * As an additional exemption you are allowed to compile & link against the - * OpenSSL libraries as published by the OpenSSL project. See the file - * COPYING for details. - * - */ - -#ifndef LOGPROTO_PROC_KMSG_READER_H_INCLUDED -#define LOGPROTO_PROC_KMSG_READER_H_INCLUDED - -#include "logproto/logproto-text-server.h" - -static inline LogProtoServer * -log_proto_linux_proc_kmsg_reader_new(LogTransport *transport, const LogProtoServerOptions *options) -{ - LogProtoServer *proto; - - proto = log_proto_text_server_new(transport, options); - ((LogProtoTextServer *) proto)->super.no_multi_read = TRUE; - return proto; -} - -#endif diff -Nru syslog-ng-3.11.1/modules/affile/Makefile.am syslog-ng-3.13.2/modules/affile/Makefile.am --- syslog-ng-3.11.1/modules/affile/Makefile.am 2017-07-31 09:05:32.000000000 +0000 +++ syslog-ng-3.13.2/modules/affile/Makefile.am 2017-12-06 06:39:39.000000000 +0000 @@ -1,10 +1,13 @@ module_LTLIBRARIES += modules/affile/libaffile.la modules_affile_libaffile_la_SOURCES = \ - modules/affile/logproto-linux-proc-kmsg-reader.h \ modules/affile/logproto-file-writer.c \ modules/affile/logproto-file-writer.h \ + modules/affile/logproto-file-reader.c \ + modules/affile/logproto-file-reader.h \ modules/affile/poll-file-changes.c \ modules/affile/poll-file-changes.h \ + modules/affile/transport-prockmsg.c \ + modules/affile/transport-prockmsg.h \ modules/affile/file-reader.c \ modules/affile/file-reader.h \ modules/affile/wildcard-source.h \ @@ -17,8 +20,15 @@ modules/affile/collection-comporator.c \ modules/affile/directory-monitor-poll.h \ modules/affile/directory-monitor-poll.c \ - modules/affile/affile-common.c \ - modules/affile/affile-common.h \ + modules/affile/file-opener.c \ + modules/affile/file-opener.h \ + modules/affile/file-specializations.h \ + modules/affile/regular-files.c \ + modules/affile/named-pipe.c \ + modules/affile/named-pipe.h \ + modules/affile/linux-kmsg.c \ + modules/affile/stdin.c \ + modules/affile/stdin.h \ modules/affile/affile-source.c \ modules/affile/affile-source.h \ modules/affile/affile-dest.c \ diff -Nru syslog-ng-3.11.1/modules/affile/named-pipe.c syslog-ng-3.13.2/modules/affile/named-pipe.c --- syslog-ng-3.11.1/modules/affile/named-pipe.c 1970-01-01 00:00:00.000000000 +0000 +++ syslog-ng-3.13.2/modules/affile/named-pipe.c 2017-12-06 06:39:39.000000000 +0000 @@ -0,0 +1,145 @@ +/* + * Copyright (c) 2017 Balabit + * Copyright (c) 2017 Balázs Scheidler + * + * This program is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 as published + * by the Free Software Foundation, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + * + * As an additional exemption you are allowed to compile & link against the + * OpenSSL libraries as published by the OpenSSL project. See the file + * COPYING for details. + * + */ +#include "named-pipe.h" +#include "affile-source.h" +#include "affile-dest.h" +#include "transport/transport-file.h" +#include "transport/transport-pipe.h" +#include "file-opener.h" +#include "logproto/logproto-text-client.h" +#include "messages.h" + +#include +#include +#include +#include +#include + +static gboolean +_prepare_open(FileOpener *self, const gchar *name) +{ + struct stat st; + + if (stat(name, &st) < 0 && + (errno == ENOENT || errno == ENOTDIR)) + { + if (mkfifo(name, self->options->file_perm_options.file_perm) < 0) + { + msg_error("Error creating named pipe, mkfifo() returned an error", + evt_tag_str("file", name), + evt_tag_str("error", g_strerror(errno))); + return FALSE; + } + return TRUE; + } + + if (!S_ISFIFO(st.st_mode)) + { + msg_error("You are using the pipe() driver, underlying file is not a FIFO, it should be used by file()", + evt_tag_str("filename", name)); + errno = EINVAL; + return FALSE; + } + return TRUE; +} + +static gint +_get_open_flags(FileOpener *self, FileDirection dir) +{ + switch (dir) + { + case AFFILE_DIR_READ: + case AFFILE_DIR_WRITE: + return (O_RDWR | O_NOCTTY | O_NONBLOCK | O_LARGEFILE); + default: + g_assert_not_reached(); + } +} + +static LogTransport * +_construct_transport(FileOpener *self, gint fd) +{ + LogTransport *transport = log_transport_pipe_new(fd); + + transport->read = log_transport_file_read_and_ignore_eof_method; + return transport; +} + +static LogProtoServer * +_construct_src_proto(FileOpener *s, LogTransport *transport, LogProtoFileReaderOptions *proto_options) +{ + return log_proto_file_reader_new(transport, proto_options); +} + +static LogProtoClient * +_construct_dst_proto(FileOpener *self, LogTransport *transport, LogProtoClientOptions *proto_options) +{ + return log_proto_text_client_new(transport, proto_options); +} + +FileOpener * +file_opener_for_named_pipes_new(void) +{ + FileOpener *self = file_opener_new(); + + self->prepare_open = _prepare_open; + self->get_open_flags = _get_open_flags; + self->construct_transport = _construct_transport; + self->construct_src_proto = _construct_src_proto; + self->construct_dst_proto = _construct_dst_proto; + return self; +} + +LogDriver * +pipe_sd_new(gchar *filename, GlobalConfig *cfg) +{ + AFFileSourceDriver *self = affile_sd_new_instance(filename, cfg); + + self->file_reader_options.reader_options.super.stats_source = SCS_PIPE; + + if (cfg_is_config_version_older(cfg, 0x0302)) + { + msg_warning_once("WARNING: the expected message format is being changed for pipe() to improve " + "syslogd compatibity with " VERSION_3_2 ". If you are using custom " + "applications which bypass the syslog() API, you might " + "need the 'expect-hostname' flag to get the old behaviour back"); + } + else + { + self->file_reader_options.reader_options.parse_options.flags &= ~LP_EXPECT_HOSTNAME; + } + + self->file_opener = file_opener_for_named_pipes_new(); + + return &self->super.super; +} + +LogDriver * +pipe_dd_new(gchar *filename, GlobalConfig *cfg) +{ + AFFileDestDriver *self = affile_dd_new_instance(filename, cfg); + + self->writer_options.stats_source = SCS_PIPE; + self->file_opener = file_opener_for_named_pipes_new(); + return &self->super.super; +} diff -Nru syslog-ng-3.11.1/modules/affile/named-pipe.h syslog-ng-3.13.2/modules/affile/named-pipe.h --- syslog-ng-3.11.1/modules/affile/named-pipe.h 1970-01-01 00:00:00.000000000 +0000 +++ syslog-ng-3.13.2/modules/affile/named-pipe.h 2017-12-06 06:39:39.000000000 +0000 @@ -0,0 +1,35 @@ +/* + * Copyright (c) 2017 Balabit + * Copyright (c) 2017 Balázs Scheidler + * + * This program is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 as published + * by the Free Software Foundation, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + * + * As an additional exemption you are allowed to compile & link against the + * OpenSSL libraries as published by the OpenSSL project. See the file + * COPYING for details. + * + */ + +#ifndef AFFILE_NAMED_PIPE_H_INCLUDED +#define AFFILE_NAMED_PIPE_H_INCLUDED + +#include "driver.h" +#include "cfg.h" +#include "file-opener.h" + +FileOpener *file_opener_for_named_pipes_new(void); +LogDriver *pipe_sd_new(gchar *filename, GlobalConfig *cfg); +LogDriver *pipe_dd_new(gchar *filename, GlobalConfig *cfg); + +#endif diff -Nru syslog-ng-3.11.1/modules/affile/regular-files.c syslog-ng-3.13.2/modules/affile/regular-files.c --- syslog-ng-3.11.1/modules/affile/regular-files.c 1970-01-01 00:00:00.000000000 +0000 +++ syslog-ng-3.13.2/modules/affile/regular-files.c 2017-12-06 06:39:39.000000000 +0000 @@ -0,0 +1,112 @@ +/* + * Copyright (c) 2017 Balabit + * Copyright (c) 2017 Balázs Scheidler + * + * This program is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 as published + * by the Free Software Foundation, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + * + * As an additional exemption you are allowed to compile & link against the + * OpenSSL libraries as published by the OpenSSL project. See the file + * COPYING for details. + * + */ +#include "file-specializations.h" +#include "transport/transport-file.h" +#include "logproto-file-writer.h" +#include "messages.h" + +#include +#include +#include +#include + +static gboolean +_prepare_open(FileOpener *self, const gchar *name) +{ + struct stat st; + + if (stat(name, &st) >= 0) + { + if (S_ISFIFO(st.st_mode)) + { + msg_error("You are using the file() driver, underlying file is a FIFO, it should be used by pipe()", + evt_tag_str("filename", name)); + errno = EINVAL; + return FALSE; + } + } + return TRUE; +} + +static LogTransport * +_construct_src_transport(FileOpener *self, gint fd) +{ + LogTransport *transport = log_transport_file_new(fd); + + transport->read = log_transport_file_read_and_ignore_eof_method; + return transport; +} + +static LogProtoServer * +_construct_src_proto(FileOpener *s, LogTransport *transport, LogProtoFileReaderOptions *proto_options) +{ + proto_options->super.super.position_tracking_enabled = TRUE; + return log_proto_file_reader_new(transport, proto_options); +} + +FileOpener * +file_opener_for_regular_source_files_new(void) +{ + FileOpener *self = file_opener_new(); + + self->prepare_open = _prepare_open; + self->construct_transport = _construct_src_transport; + self->construct_src_proto = _construct_src_proto; + return self; +} + +typedef struct _FileOpenerRegularDestFiles +{ + FileOpener super; + const LogWriterOptions *writer_options; + gboolean *use_fsync; +} FileOpenerRegularDestFiles; + +static LogProtoClient * +_construct_dst_proto(FileOpener *s, LogTransport *transport, LogProtoClientOptions *proto_options) +{ + FileOpenerRegularDestFiles *self = (FileOpenerRegularDestFiles *) s; + + return log_proto_file_writer_new(transport, proto_options, + self->writer_options->flush_lines, + *self->use_fsync); +} + +static LogTransport * +_construct_transport(FileOpener *s, gint fd) +{ + return log_transport_file_new(fd); +} + +FileOpener * +file_opener_for_regular_dest_files_new(const LogWriterOptions *writer_options, gboolean *use_fsync) +{ + FileOpenerRegularDestFiles *self = g_new0(FileOpenerRegularDestFiles, 1); + + file_opener_init_instance(&self->super); + self->super.construct_transport = _construct_transport; + self->super.construct_dst_proto = _construct_dst_proto; + self->writer_options = writer_options; + self->use_fsync = use_fsync; + return &self->super; +} diff -Nru syslog-ng-3.11.1/modules/affile/stdin.c syslog-ng-3.13.2/modules/affile/stdin.c --- syslog-ng-3.11.1/modules/affile/stdin.c 1970-01-01 00:00:00.000000000 +0000 +++ syslog-ng-3.13.2/modules/affile/stdin.c 2017-12-06 06:39:39.000000000 +0000 @@ -0,0 +1,67 @@ +/* + * Copyright (c) 2017 Balabit + * Copyright (c) 2017 Balázs Scheidler + * + * This program is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 as published + * by the Free Software Foundation, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + * + * As an additional exemption you are allowed to compile & link against the + * OpenSSL libraries as published by the OpenSSL project. See the file + * COPYING for details. + * + */ +#include "file-specializations.h" +#include "transport/transport-file.h" +#include "affile-source.h" + +#include + +static LogTransport * +_construct_transport(FileOpener *self, gint fd) +{ + return log_transport_file_new(fd); +} + +static LogProtoServer * +_construct_src_proto(FileOpener *s, LogTransport *transport, LogProtoFileReaderOptions *proto_options) +{ + return log_proto_file_reader_new(transport, proto_options); +} + +static gint +_open(FileOpener *self, const gchar *name, gint flags) +{ + return dup(0); +} + +FileOpener * +file_opener_for_stdin_new(void) +{ + FileOpener *self = file_opener_new(); + + self->construct_transport = _construct_transport; + self->construct_src_proto = _construct_src_proto; + self->open = _open; + return self; +} + +LogDriver * +stdin_sd_new(GlobalConfig *cfg) +{ + AFFileSourceDriver *self = affile_sd_new_instance("-", cfg); + + self->file_reader_options.exit_on_eof = TRUE; + self->file_reader_options.reader_options.super.stats_source = SCS_STDIN; + self->file_opener = file_opener_for_stdin_new(); + return &self->super.super; +} diff -Nru syslog-ng-3.11.1/modules/affile/stdin.h syslog-ng-3.13.2/modules/affile/stdin.h --- syslog-ng-3.11.1/modules/affile/stdin.h 1970-01-01 00:00:00.000000000 +0000 +++ syslog-ng-3.13.2/modules/affile/stdin.h 2017-12-06 06:39:39.000000000 +0000 @@ -0,0 +1,32 @@ +/* + * Copyright (c) 2017 Balabit + * Copyright (c) 2017 Balázs Scheidler + * + * This program is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 as published + * by the Free Software Foundation, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + * + * As an additional exemption you are allowed to compile & link against the + * OpenSSL libraries as published by the OpenSSL project. See the file + * COPYING for details. + * + */ + +#ifndef AFFILE_STDIN_H_INCLUDED +#define AFFILE_STDIN_H_INCLUDED + +#include "driver.h" +#include "cfg.h" + +LogDriver *stdin_sd_new(GlobalConfig *cfg); + +#endif diff -Nru syslog-ng-3.11.1/modules/affile/tests/Makefile.am syslog-ng-3.13.2/modules/affile/tests/Makefile.am --- syslog-ng-3.11.1/modules/affile/tests/Makefile.am 2017-07-31 09:05:32.000000000 +0000 +++ syslog-ng-3.13.2/modules/affile/tests/Makefile.am 2017-12-06 06:39:39.000000000 +0000 @@ -1,34 +1,27 @@ -modules_affile_tests_TESTS = \ - modules/affile/tests/test_affile_open_file - +if ENABLE_CRITERION check_PROGRAMS += \ ${modules_affile_tests_TESTS} -modules_affile_tests_test_affile_open_file_CFLAGS = $(TEST_CFLAGS) -modules_affile_tests_test_affile_open_file_LDADD = $(TEST_LDADD) \ - -dlpreopen $(top_builddir)/modules/affile/libaffile.la -modules_affile_tests_test_affile_open_file_LDFLAGS = \ - $(PREOPEN_CORE) - -if ENABLE_CRITERION -modules_affile_tests_TESTS += \ +modules_affile_tests_TESTS = \ modules/affile/tests/test_wildcard_source \ modules/affile/tests/test_directory_monitor \ - modules/affile/tests/test_collection_comporator + modules/affile/tests/test_collection_comporator \ + modules/affile/tests/test_file_opener modules_affile_tests_test_wildcard_source_CFLAGS = $(TEST_CFLAGS) -I$(top_srcdir)/modules/affile modules_affile_tests_test_wildcard_source_LDADD = $(TEST_LDADD) \ -dlpreopen $(top_builddir)/modules/affile/libaffile.la -modules_affile_tests_test_wildcard_source_LDFLAGS = $(PREOPEN_CORE) modules_affile_tests_test_directory_monitor_CFLAGS = $(TEST_CFLAGS) -I$(top_srcdir)/modules/affile modules_affile_tests_test_directory_monitor_LDADD = $(TEST_LDADD) \ -dlpreopen $(top_builddir)/modules/affile/libaffile.la -modules_affile_tests_test_directory_monitor_LDFLAGS = $(PREOPEN_CORE) modules_affile_tests_test_collection_comporator_CFLAGS = $(TEST_CFLAGS) -I$(top_srcdir)/modules/affile modules_affile_tests_test_collection_comporator_LDADD = $(TEST_LDADD) \ -dlpreopen $(top_builddir)/modules/affile/libaffile.la -modules_affile_tests_test_collection_comporator_LDFLAGS = $(PREOPEN_CORE) + +modules_affile_tests_test_file_opener_CFLAGS = $(TEST_CFLAGS) +modules_affile_tests_test_file_opener_LDADD = $(TEST_LDADD) \ + -dlpreopen $(top_builddir)/modules/affile/libaffile.la endif diff -Nru syslog-ng-3.11.1/modules/affile/tests/test_affile_open_file.c syslog-ng-3.13.2/modules/affile/tests/test_affile_open_file.c --- syslog-ng-3.11.1/modules/affile/tests/test_affile_open_file.c 2017-07-31 09:05:32.000000000 +0000 +++ syslog-ng-3.13.2/modules/affile/tests/test_affile_open_file.c 1970-01-01 00:00:00.000000000 +0000 @@ -1,150 +0,0 @@ -/* - * Copyright (c) 2013 Balabit - * Copyright (c) 2013 Laszlo Budai - * - * This program is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 as published - * by the Free Software Foundation, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - * - * As an additional exemption you are allowed to compile & link against the - * OpenSSL libraries as published by the OpenSSL project. See the file - * COPYING for details. - * - */ - -#include "testutils.h" -#include "affile/affile-common.h" -#include "lib/messages.h" -#include -#include -#include -#include -#include -#include -#include - -#define AFFILE_TESTCASE(testfunc, ...) { testcase_begin("%s(%s)", #testfunc, #__VA_ARGS__); testfunc(__VA_ARGS__); testcase_end(); } - -#define CREATE_DIRS 0x01 -#define PIPE 0x02 - -#define TEST_DIR "affile_test_dir" - -#define PIPE_OPEN_FLAGS (O_RDWR | O_NOCTTY | O_NONBLOCK | O_LARGEFILE) -#define REGULAR_FILE_OPEN_FLAGS (O_CREAT | O_NOCTTY | O_LARGEFILE) - -static void -setup() -{ - msg_init(FALSE); -} - -static mode_t -get_fd_file_mode(gint fd) -{ - struct stat st; - - fstat(fd, &st); - return st.st_mode; -} - -static gboolean -open_file(gchar *fname, int open_flags, gint extra_flags, gint *fd) -{ - FilePermOptions perm_opts; - FileOpenOptions open_opts; - - file_perm_options_defaults(&perm_opts); - - open_opts.open_flags = open_flags; - open_opts.create_dirs = !!(extra_flags & CREATE_DIRS); - open_opts.is_pipe = !!(extra_flags & PIPE); - open_opts.needs_privileges = FALSE; - - return affile_open_file(fname, &open_opts, &perm_opts, fd); -} - -static void -test_open_regular_file() -{ - gint fd; - gchar fname[] = "test.log"; - - assert_true(open_file(fname, REGULAR_FILE_OPEN_FLAGS, 0, &fd), "affile_open_file failed: %s", fname); - assert_true(S_ISREG(get_fd_file_mode(fd)) != 0, "%s is not regular file", fname); - - close(fd); - remove(fname); -} - -static void -test_open_pipe() -{ - gint fd; - gchar fname[] = "test.pipe"; - - assert_true(open_file(fname, PIPE_OPEN_FLAGS, PIPE, &fd), "failed to open %s", fname); - assert_true(S_ISFIFO(get_fd_file_mode(fd)) != 0, "%s is not pipe", fname); - - close(fd); - remove(fname); -} - -static void -test_spurious_path() -{ - gint fd; - gchar fname[] = "./../test.fname"; - - assert_false(open_file(fname, REGULAR_FILE_OPEN_FLAGS, 0, &fd), "affile_open_file should not be able to open: %s", - fname); -} - -static void -test_create_file_in_nonexistent_dir() -{ - gchar test_dir[] = "nonexistent"; - gchar fname[] = "nonexistent/test.txt"; - gint fd; - - assert_false(open_file(fname, REGULAR_FILE_OPEN_FLAGS, 0, &fd), "affile_open_file failed: %s", fname); - assert_true(open_file(fname, REGULAR_FILE_OPEN_FLAGS, CREATE_DIRS, &fd), "affile_open_file failed: %s", fname); - - close(fd); - remove(fname); - rmdir(test_dir); -} - -static void -test_file_flags() -{ - gint fd; - gchar fname[] = "test_flags.log"; - gint flags = O_CREAT|O_WRONLY; - - assert_true(open_file(fname, flags, 0, &fd), "affile_open_file failed: %s", fname); - assert_true((fcntl(fd, F_GETFL) & O_WRONLY) == O_WRONLY, "invalid open flags"); - - close(fd); - remove(fname); -} - -int main(int argc, char **argv) -{ - setup(); - - AFFILE_TESTCASE(test_open_regular_file); - AFFILE_TESTCASE(test_open_pipe); - AFFILE_TESTCASE(test_spurious_path); - AFFILE_TESTCASE(test_create_file_in_nonexistent_dir); - AFFILE_TESTCASE(test_file_flags); -} diff -Nru syslog-ng-3.11.1/modules/affile/tests/test_collection_comporator.c syslog-ng-3.13.2/modules/affile/tests/test_collection_comporator.c --- syslog-ng-3.11.1/modules/affile/tests/test_collection_comporator.c 2017-07-31 09:05:32.000000000 +0000 +++ syslog-ng-3.13.2/modules/affile/tests/test_collection_comporator.c 2017-12-06 06:39:39.000000000 +0000 @@ -36,7 +36,7 @@ static const gchar *TEST = "test"; TestData * -test_data_new() +test_data_new(void) { TestData *self = g_new0(TestData, 1); self->deleted_entries = g_hash_table_new_full(g_str_hash, g_str_equal, g_free, NULL); diff -Nru syslog-ng-3.11.1/modules/affile/tests/test_file_opener.c syslog-ng-3.13.2/modules/affile/tests/test_file_opener.c --- syslog-ng-3.11.1/modules/affile/tests/test_file_opener.c 1970-01-01 00:00:00.000000000 +0000 +++ syslog-ng-3.13.2/modules/affile/tests/test_file_opener.c 2017-12-06 06:39:39.000000000 +0000 @@ -0,0 +1,171 @@ +/* + * Copyright (c) 2013 Balabit + * Copyright (c) 2013 Laszlo Budai + * + * This program is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 as published + * by the Free Software Foundation, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + * + * As an additional exemption you are allowed to compile & link against the + * OpenSSL libraries as published by the OpenSSL project. See the file + * COPYING for details. + * + */ + +#include +#include "affile/file-opener.h" +#include "affile/named-pipe.h" +#include "affile/file-specializations.h" +#include "messages.h" + +#include +#include +#include +#include +#include +#include +#include + +#define CREATE_DIRS 0x01 +#define SRC_FILE 0x02 +#define DST_FILE 0x04 + +static mode_t +get_fd_file_mode(gint fd) +{ + struct stat st; + + fstat(fd, &st); + return st.st_mode; +} + +static gboolean +open_fd(FileOpener *file_opener, gchar *fname, gint extra_flags, gint *fd) +{ + FileOpenerOptions open_opts; + FileDirection dir; + + if (extra_flags & DST_FILE) + dir = AFFILE_DIR_WRITE; + else if (extra_flags & SRC_FILE) + dir = AFFILE_DIR_READ; + else + g_assert_not_reached(); + + file_opener_options_defaults(&open_opts); + file_opener_options_init(&open_opts, configuration); + open_opts.create_dirs = !!(extra_flags & CREATE_DIRS); + open_opts.needs_privileges = FALSE; + + file_opener_set_options(file_opener, &open_opts); + + gboolean success = file_opener_open_fd(file_opener, fname, dir, fd); + file_opener_free(file_opener); + return success; +} + +static gboolean +open_regular_source_file(gchar *fname, gint extra_flags, gint *fd) +{ + FileOpener *file_opener = file_opener_for_regular_source_files_new(); + return open_fd(file_opener, fname, extra_flags, fd); +} + +static gboolean +open_named_pipe(gchar *fname, gint extra_flags, gint *fd) +{ + FileOpener *file_opener = file_opener_for_named_pipes_new(); + return open_fd(file_opener, fname, extra_flags, fd); +} + +Test(file_opener, test_open_regular_file) +{ + gint fd; + gchar fname[] = "test.log"; + + cr_assert(open_regular_source_file(fname, DST_FILE, &fd), "file_opener_open_fd failed: %s", fname); + cr_assert(S_ISREG(get_fd_file_mode(fd)) != 0, "%s is not regular file", fname); + + close(fd); + + cr_assert(open_regular_source_file(fname, SRC_FILE, &fd), "file_opener_open_fd failed: %s", fname); + cr_assert(S_ISREG(get_fd_file_mode(fd)) != 0, "%s is not regular file", fname); + + close(fd); + + remove(fname); +} + +Test(file_opener, test_open_named_pipe) +{ + gint fd; + gchar fname[] = "test.pipe"; + + cr_assert(open_named_pipe(fname, SRC_FILE, &fd), "failed to open %s", fname); + cr_assert(S_ISFIFO(get_fd_file_mode(fd)) != 0, "%s is not pipe", fname); + + close(fd); + remove(fname); +} + +Test(file_opener, test_spurious_path) +{ + gint fd; + gchar fname[] = "./../test.fname"; + + cr_assert_not(open_regular_source_file(fname, DST_FILE, &fd), "file_opener_open_fd should not be able to open: %s", + fname); +} + +Test(file_opener, test_create_file_in_nonexistent_dir) +{ + gchar test_dir[] = "nonexistent"; + gchar fname[] = "nonexistent/test.txt"; + gint fd; + + cr_assert_not(open_regular_source_file(fname, DST_FILE, &fd), "file_opener_open_fd failed: %s", fname); + cr_assert(open_regular_source_file(fname, CREATE_DIRS | DST_FILE, &fd), "file_opener_open_fd failed: %s", fname); + + close(fd); + remove(fname); + rmdir(test_dir); +} + +Test(file_opener, test_file_flags) +{ + gint fd; + gchar fname[] = "test_flags.log"; + + cr_assert(open_regular_source_file(fname, DST_FILE, &fd), "file_opener_open_fd failed: %s", fname); + cr_assert((fcntl(fd, F_GETFL) & O_APPEND) == O_APPEND, "invalid open flags"); + close(fd); + + cr_assert(open_regular_source_file(fname, SRC_FILE, &fd), "file_opener_open_fd failed: %s", fname); + cr_assert((fcntl(fd, F_GETFL) & O_APPEND) != O_APPEND, "invalid open flags"); + + close(fd); + remove(fname); +} + +static void +setup(void) +{ + msg_init(FALSE); + configuration = cfg_new(VERSION_VALUE); +} + +void +teardown(void) +{ +} + +TestSuite(file_opener, .init = setup, .fini = teardown); diff -Nru syslog-ng-3.11.1/modules/affile/tests/test_wildcard_source.c syslog-ng-3.13.2/modules/affile/tests/test_wildcard_source.c --- syslog-ng-3.11.1/modules/affile/tests/test_wildcard_source.c 2017-07-31 09:05:32.000000000 +0000 +++ syslog-ng-3.13.2/modules/affile/tests/test_wildcard_source.c 2017-12-06 06:39:39.000000000 +0000 @@ -32,8 +32,8 @@ _init(void) { app_startup(); - configuration = cfg_new_snippet(VERSION_VALUE); - cr_assert(plugin_load_module("affile", configuration, NULL)); + configuration = cfg_new_snippet(); + cr_assert(cfg_load_module(configuration, "affile")); } static void @@ -93,10 +93,10 @@ "multi-line-prefix(\\d+)" "multi-line-garbage(garbage)"); cr_assert_eq(driver->file_reader_options.follow_freq, 10000); - cr_assert_eq(driver->file_reader_options.pad_size, 5); - cr_assert_eq(driver->file_reader_options.multi_line_mode, MLM_PREFIX_GARBAGE); - cr_assert(driver->file_reader_options.multi_line_prefix != NULL); - cr_assert(driver->file_reader_options.multi_line_garbage != NULL); + cr_assert_eq(file_reader_options_get_log_proto_options(&driver->file_reader_options)->pad_size, 5); + cr_assert_eq(file_reader_options_get_log_proto_options(&driver->file_reader_options)->super.mode, MLM_PREFIX_GARBAGE); + cr_assert(file_reader_options_get_log_proto_options(&driver->file_reader_options)->super.prefix != NULL); + cr_assert(file_reader_options_get_log_proto_options(&driver->file_reader_options)->super.garbage != NULL); } Test(wildcard_source, test_option_duplication) diff -Nru syslog-ng-3.11.1/modules/affile/transport-prockmsg.c syslog-ng-3.13.2/modules/affile/transport-prockmsg.c --- syslog-ng-3.11.1/modules/affile/transport-prockmsg.c 1970-01-01 00:00:00.000000000 +0000 +++ syslog-ng-3.13.2/modules/affile/transport-prockmsg.c 2017-12-06 06:39:39.000000000 +0000 @@ -0,0 +1,76 @@ +/* + * Copyright (c) 2002-2013 Balabit + * Copyright (c) 1998-2013 Balázs Scheidler + * + * This program is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 as published + * by the Free Software Foundation, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + * + * As an additional exemption you are allowed to compile & link against the + * OpenSSL libraries as published by the OpenSSL project. See the file + * COPYING for details. + * + */ + +#include "transport-prockmsg.h" +#include "messages.h" +#include "alarms.h" + +#include +#include + +typedef struct _LogTransportDevice LogTransportDevice; +struct _LogTransportDevice +{ + LogTransport super; + gint timeout; +}; + +static gssize +log_transport_prockmsg_read_method(LogTransport *s, gpointer buf, gsize buflen, LogTransportAuxData *aux) +{ + LogTransportDevice *self = (LogTransportDevice *) s; + gint rc; + + do + { + if (self->timeout) + alarm_set(self->timeout); + rc = read(self->super.fd, buf, buflen); + + if (self->timeout > 0 && rc == -1 && errno == EINTR && alarm_has_fired()) + { + msg_notice("Nonblocking read has blocked, returning with an error", + evt_tag_int("fd", self->super.fd), + evt_tag_int("timeout", self->timeout)); + alarm_cancel(); + break; + } + if (self->timeout) + alarm_cancel(); + } + while (rc == -1 && errno == EINTR); + return rc; +} + +LogTransport * +log_transport_prockmsg_new(gint fd, gint timeout) +{ + LogTransportDevice *self = g_new0(LogTransportDevice, 1); + + log_transport_init_instance(&self->super, fd); + self->timeout = timeout; + self->super.read = log_transport_prockmsg_read_method; + self->super.write = NULL; + self->super.free_fn = log_transport_free_method; + return &self->super; +} diff -Nru syslog-ng-3.11.1/modules/affile/transport-prockmsg.h syslog-ng-3.13.2/modules/affile/transport-prockmsg.h --- syslog-ng-3.11.1/modules/affile/transport-prockmsg.h 1970-01-01 00:00:00.000000000 +0000 +++ syslog-ng-3.13.2/modules/affile/transport-prockmsg.h 2017-12-06 06:39:39.000000000 +0000 @@ -0,0 +1,31 @@ +/* + * Copyright (c) 2002-2013 Balabit + * Copyright (c) 1998-2013 Balázs Scheidler + * + * This program is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 as published + * by the Free Software Foundation, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + * + * As an additional exemption you are allowed to compile & link against the + * OpenSSL libraries as published by the OpenSSL project. See the file + * COPYING for details. + * + */ + +#ifndef AFFILE_PROCKMSG_H_INCLUDED +#define AFFILE_PROCKMSG_H_INCLUDED 1 + +#include "transport/logtransport.h" + +LogTransport *log_transport_prockmsg_new(gint fd, gint timeout); + +#endif diff -Nru syslog-ng-3.11.1/modules/affile/wildcard-source.c syslog-ng-3.13.2/modules/affile/wildcard-source.c --- syslog-ng-3.11.1/modules/affile/wildcard-source.c 2017-07-31 09:05:32.000000000 +0000 +++ syslog-ng-3.13.2/modules/affile/wildcard-source.c 2017-12-06 06:39:39.000000000 +0000 @@ -23,6 +23,8 @@ #include "wildcard-source.h" #include "directory-monitor-factory.h" #include "messages.h" +#include "file-specializations.h" + #include #define DEFAULT_SD_OPEN_FLAGS (O_RDONLY | O_NOCTTY | O_NONBLOCK | O_LARGEFILE) @@ -52,6 +54,8 @@ _create_file_reader(WildcardSourceDriver *self, const gchar *full_path) { FileReader *reader = NULL; + GlobalConfig *cfg = log_pipe_get_config(&self->super.super.super); + if (g_hash_table_size(self->file_readers) >= self->max_files) { msg_warning("Number of allowed monitorod file is reached, rejecting read file", @@ -60,9 +64,8 @@ evt_tag_int("max_files", self->max_files)); return; } - GlobalConfig *cfg = log_pipe_get_config(&self->super.super.super); - reader = file_reader_new(full_path, &self->super, cfg); - reader->file_reader_options = &self->file_reader_options; + + reader = file_reader_new(full_path, &self->file_reader_options, self->file_opener, &self->super, cfg); log_pipe_append(&reader->super, &self->super.super.super); if (!log_pipe_init(&reader->super)) { @@ -82,6 +85,7 @@ if (g_pattern_match_string(self->compiled_pattern, event->name)) { FileReader *reader = g_hash_table_lookup(self->file_readers, event->full_path); + if (!reader) { _create_file_reader(self, event->full_path); @@ -114,6 +118,7 @@ _handle_deleted(WildcardSourceDriver *self, const DirectoryMonitorEvent *event) { FileReader *reader = g_hash_table_lookup(self->file_readers, event->full_path); + if (reader) { msg_debug("Monitored file is deleted", evt_tag_str("filename", event->full_path)); @@ -130,6 +135,7 @@ _on_directory_monitor_changed(const DirectoryMonitorEvent *event, gpointer user_data) { WildcardSourceDriver *self = (WildcardSourceDriver *)user_data; + if ((event->event_type == FILE_CREATED)) { _handle_file_created(self, event); @@ -169,7 +175,14 @@ self->window_size_initialized = TRUE; } - log_reader_options_init(&self->file_reader_options.reader_options, cfg, self->super.super.group); + file_reader_options_init(&self->file_reader_options, cfg, self->super.super.group); +} + +static void +_init_opener_options(WildcardSourceDriver *self, GlobalConfig *cfg) +{ + file_opener_options_init(&self->file_opener_options, cfg); + file_opener_set_options(self->file_opener, &self->file_opener_options); } static gboolean @@ -191,9 +204,11 @@ DirectoryMonitorOptions options = { .dir = directory, - .follow_freq = self->file_reader_options.follow_freq + .follow_freq = self->file_reader_options.follow_freq, + .method = self->monitor_method }; DirectoryMonitor *monitor = create_directory_monitor(&options); + directory_monitor_set_callback(monitor, _on_directory_monitor_changed, self); directory_monitor_start(monitor); g_hash_table_insert(self->directory_monitors, g_strdup(directory), monitor); @@ -220,6 +235,8 @@ } _init_reader_options(self, cfg); + _init_opener_options(self, cfg); + _add_directory_monitor(self, self->base_dir); return TRUE; } @@ -227,7 +244,8 @@ static void _deinit_reader(gpointer key, gpointer value, gpointer user_data) { - FileReader *reader = (FileReader *)value; + FileReader *reader = (FileReader *) value; + log_pipe_deinit(&reader->super); } @@ -235,6 +253,7 @@ _deinit(LogPipe *s) { WildcardSourceDriver *self = (WildcardSourceDriver *)s; + g_pattern_spec_free(self->compiled_pattern); g_hash_table_foreach(self->file_readers, _deinit_reader, NULL); return TRUE; @@ -244,6 +263,7 @@ wildcard_sd_set_base_dir(LogDriver *s, const gchar *base_dir) { WildcardSourceDriver *self = (WildcardSourceDriver *)s; + g_free(self->base_dir); self->base_dir = g_strdup(base_dir); } @@ -252,6 +272,7 @@ wildcard_sd_set_filename_pattern(LogDriver *s, const gchar *filename_pattern) { WildcardSourceDriver *self = (WildcardSourceDriver *)s; + g_free(self->filename_pattern); self->filename_pattern = g_strdup(filename_pattern); } @@ -260,6 +281,7 @@ wildcard_sd_set_recursive(LogDriver *s, gboolean recursive) { WildcardSourceDriver *self = (WildcardSourceDriver *)s; + self->recursive = recursive; } @@ -268,6 +290,7 @@ { WildcardSourceDriver *self = (WildcardSourceDriver *)s; MonitorMethod new_method = directory_monitor_factory_get_monitor_method(method); + if (new_method == MM_UNKNOWN) { msg_error("Invalid monitor-method", evt_tag_str("monitor-method", method)); @@ -281,6 +304,7 @@ wildcard_sd_set_max_files(LogDriver *s, guint32 max_files) { WildcardSourceDriver *self = (WildcardSourceDriver *)s; + self->max_files = max_files; } @@ -288,11 +312,14 @@ _free(LogPipe *s) { WildcardSourceDriver *self = (WildcardSourceDriver *)s; + + file_opener_free(self->file_opener); g_free(self->base_dir); g_free(self->filename_pattern); g_hash_table_unref(self->file_readers); g_hash_table_unref(self->directory_monitors); - file_reader_options_destroy(&self->file_reader_options); + file_reader_options_deinit(&self->file_reader_options); + file_opener_options_deinit(&self->file_opener_options); log_src_driver_free(s); } @@ -300,6 +327,7 @@ _stop_and_destroy_directory_monitor(gpointer s) { DirectoryMonitor *monitor = (DirectoryMonitor *)s; + directory_monitor_stop(monitor); directory_monitor_free(monitor); } @@ -319,17 +347,17 @@ self->directory_monitors = g_hash_table_new_full(g_str_hash, g_str_equal, g_free, (GDestroyNotify)_stop_and_destroy_directory_monitor); - log_reader_options_defaults(&self->file_reader_options.reader_options); - file_perm_options_defaults(&self->file_reader_options.file_perm_options); self->monitor_method = MM_AUTO; - self->file_reader_options.reader_options.parse_options.flags |= LP_LOCAL; - self->file_reader_options.file_open_options.is_pipe = FALSE; - self->file_reader_options.file_open_options.open_flags = DEFAULT_SD_OPEN_FLAGS; + file_reader_options_defaults(&self->file_reader_options); + file_opener_options_defaults_dont_change_permissions(&self->file_opener_options); self->file_reader_options.follow_freq = 1000; self->file_reader_options.reader_options.super.init_window_size = MINIMUM_WINDOW_SIZE * DEFAULT_MAX_FILES; + self->file_reader_options.reader_options.super.stats_source = SCS_FILE; + self->file_reader_options.restore_state = TRUE; self->max_files = DEFAULT_MAX_FILES; + self->file_opener = file_opener_for_regular_source_files_new(); return &self->super.super; } diff -Nru syslog-ng-3.11.1/modules/affile/wildcard-source.h syslog-ng-3.13.2/modules/affile/wildcard-source.h --- syslog-ng-3.11.1/modules/affile/wildcard-source.h 2017-07-31 09:05:32.000000000 +0000 +++ syslog-ng-3.13.2/modules/affile/wildcard-source.h 2017-12-06 06:39:39.000000000 +0000 @@ -24,7 +24,6 @@ #include "syslog-ng.h" #include "driver.h" -#include "affile-common.h" #include "file-reader.h" #include "directory-monitor.h" #include "directory-monitor-factory.h" @@ -32,7 +31,8 @@ #define MINIMUM_WINDOW_SIZE 100 #define DEFAULT_MAX_FILES 100 -typedef struct _WildcardSourceDriver { +typedef struct _WildcardSourceDriver +{ LogSrcDriver super; gchar *base_dir; gchar *filename_pattern; @@ -43,10 +43,12 @@ gboolean recursive; FileReaderOptions file_reader_options; + FileOpenerOptions file_opener_options; GPatternSpec *compiled_pattern; GHashTable *file_readers; GHashTable *directory_monitors; + FileOpener *file_opener; } WildcardSourceDriver; LogDriver *wildcard_sd_new(GlobalConfig *cfg); diff -Nru syslog-ng-3.11.1/modules/afmongodb/afmongodb.c syslog-ng-3.13.2/modules/afmongodb/afmongodb.c --- syslog-ng-3.11.1/modules/afmongodb/afmongodb.c 2017-07-31 09:05:32.000000000 +0000 +++ syslog-ng-3.13.2/modules/afmongodb/afmongodb.c 2017-12-06 06:39:39.000000000 +0000 @@ -181,12 +181,12 @@ } } - bson_t *status = bson_new(); + bson_t reply; bson_error_t error; const mongoc_read_prefs_t *read_prefs = mongoc_collection_get_read_prefs(self->coll_obj); gboolean ok = mongoc_client_get_server_status(self->client, (mongoc_read_prefs_t *)read_prefs, - status, &error); - bson_destroy(status); + &reply, &error); + bson_destroy(&reply); if (!ok) { msg_error("Error connecting to MongoDB", @@ -558,7 +558,8 @@ mongoc_uri_destroy(self->uri_obj); if (self->coll_obj) mongoc_collection_destroy(self->coll_obj); - mongoc_cleanup(); + if (self->client) + mongoc_cleanup(); log_threaded_dest_driver_free(d); } @@ -617,9 +618,9 @@ }; gboolean -afmongodb_module_init(GlobalConfig *cfg, CfgArgs *args) +afmongodb_module_init(PluginContext *context, CfgArgs *args) { - plugin_register(cfg, &afmongodb_plugin, 1); + plugin_register(context, &afmongodb_plugin, 1); return TRUE; } diff -Nru syslog-ng-3.11.1/modules/afmongodb/afmongodb-parser.h syslog-ng-3.13.2/modules/afmongodb/afmongodb-parser.h --- syslog-ng-3.11.1/modules/afmongodb/afmongodb-parser.h 2017-07-31 09:05:32.000000000 +0000 +++ syslog-ng-3.13.2/modules/afmongodb/afmongodb-parser.h 2017-12-06 06:39:39.000000000 +0000 @@ -26,7 +26,6 @@ #include "syslog-ng.h" #include "cfg-parser.h" -#include "cfg-lexer.h" #include "afmongodb.h" #if SYSLOG_NG_ENABLE_LEGACY_MONGODB_OPTIONS diff -Nru syslog-ng-3.11.1/modules/afmongodb/Makefile.am syslog-ng-3.13.2/modules/afmongodb/Makefile.am --- syslog-ng-3.11.1/modules/afmongodb/Makefile.am 2017-07-31 09:05:32.000000000 +0000 +++ syslog-ng-3.13.2/modules/afmongodb/Makefile.am 2017-12-06 06:39:39.000000000 +0000 @@ -52,13 +52,19 @@ modules/afmongodb modules/afmongodb/ mod-afmongodb mod-mongodb: endif +if LIBMONGO_INTERNAL + +EXTRA_DIST += \ + modules/afmongodb/mongo-c-driver/configure.gnu + +endif + BUILT_SOURCES += \ modules/afmongodb/afmongodb-grammar.y \ modules/afmongodb/afmongodb-grammar.c \ modules/afmongodb/afmongodb-grammar.h EXTRA_DIST += \ - modules/afmongodb/afmongodb-grammar.ym \ - modules/afmongodb/mongo-c-driver/configure.gnu + modules/afmongodb/afmongodb-grammar.ym .PHONY: modules/afmongodb/ mod-afmongodb mod-mongodb diff -Nru syslog-ng-3.11.1/modules/afmongodb/tests/test-mongodb-config.c syslog-ng-3.13.2/modules/afmongodb/tests/test-mongodb-config.c --- syslog-ng-3.11.1/modules/afmongodb/tests/test-mongodb-config.c 2017-07-31 09:05:32.000000000 +0000 +++ syslog-ng-3.13.2/modules/afmongodb/tests/test-mongodb-config.c 2017-12-06 06:39:39.000000000 +0000 @@ -166,8 +166,8 @@ { _expect_uri_in_log("default_uri", "127.0.0.1:27017/syslog" SAFEOPTS, "syslog", "messages"); - afmongodb_dd_set_uri(mongodb, "mongodb:///tmp/mongo.sock"); - _expect_uri_in_log("socket", "/tmp/mongo.sock", "tmp/mongo.sock", "messages"); + afmongodb_dd_set_uri(mongodb, "mongodb://%2Ftmp%2Fmongo.sock/syslog"); + _expect_uri_in_log("socket", "%2Ftmp%2Fmongo.sock/syslog", "syslog", "messages"); afmongodb_dd_set_uri(mongodb, "mongodb://localhost:1234/syslog-ng"); _expect_uri_in_log("uri", "localhost:1234/syslog-ng", "syslog-ng", "messages"); @@ -216,9 +216,6 @@ afmongodb_dd_set_port(mongodb, 1234); _expect_uri_in_log("port", "127.0.0.1:1234/syslog" SAFEOPTS, "syslog", "messages"); - afmongodb_dd_set_path(mongodb, "/tmp/mongo.sock"); - _expect_uri_in_log("path", "/tmp/mongo.sock" SAFEOPTS, "tmp/mongo.sock", "messages"); - afmongodb_dd_set_database(mongodb, "syslog-ng"); _expect_uri_in_log("database", "127.0.0.1:27017/syslog-ng" SAFEOPTS, "syslog-ng", "messages"); @@ -304,7 +301,7 @@ log_msg_registry_init(); - test_cfg = cfg_new_snippet(0x0308); + test_cfg = cfg_new_snippet(); g_assert(test_cfg); const gchar *persist_filename = ""; diff -Nru syslog-ng-3.11.1/modules/afprog/afprog.c syslog-ng-3.13.2/modules/afprog/afprog.c --- syslog-ng-3.11.1/modules/afprog/afprog.c 2017-07-31 09:05:32.000000000 +0000 +++ syslog-ng-3.13.2/modules/afprog/afprog.c 2017-12-06 06:39:39.000000000 +0000 @@ -226,16 +226,17 @@ if (!self->reader) { LogTransport *transport; + LogProtoServer *proto; transport = log_transport_pipe_new(fd); + proto = log_proto_text_server_new(transport, &self->reader_options.proto_options.super); + self->reader = log_reader_new(s->cfg); - log_reader_reopen(self->reader, log_proto_text_server_new(transport, &self->reader_options.proto_options.super), + log_reader_reopen(self->reader, proto, poll_fd_events_new(fd)); log_reader_set_options(self->reader, s, &self->reader_options, - STATS_LEVEL0, - SCS_PROGRAM, self->super.super.id, self->process_info.cmdline->str); } @@ -308,6 +309,8 @@ afprogram_set_inherit_environment(&self->process_info, TRUE); log_reader_options_defaults(&self->reader_options); self->reader_options.parse_options.flags |= LP_LOCAL; + self->reader_options.super.stats_level = STATS_LEVEL0; + self->reader_options.super.stats_source = SCS_PROGRAM; return &self->super.super; } @@ -446,8 +449,6 @@ log_writer_set_options(self->writer, s, &self->writer_options, - STATS_LEVEL0, - SCS_PROGRAM, self->super.super.id, self->process_info.cmdline->str); log_writer_set_queue(self->writer, log_dest_driver_acquire_queue(&self->super, @@ -546,6 +547,8 @@ self->process_info.pid = -1; afprogram_set_inherit_environment(&self->process_info, TRUE); log_writer_options_defaults(&self->writer_options); + self->writer_options.stats_level = STATS_LEVEL0; + self->writer_options.stats_source = SCS_PROGRAM; return &self->super.super; } diff -Nru syslog-ng-3.11.1/modules/afprog/afprog-parser.h syslog-ng-3.13.2/modules/afprog/afprog-parser.h --- syslog-ng-3.11.1/modules/afprog/afprog-parser.h 2017-07-31 09:05:32.000000000 +0000 +++ syslog-ng-3.13.2/modules/afprog/afprog-parser.h 2017-12-06 06:39:39.000000000 +0000 @@ -25,7 +25,6 @@ #define AFPROG_PARSER_H_INCLUDED #include "cfg-parser.h" -#include "cfg-lexer.h" #include "driver.h" extern CfgParser afprog_parser; diff -Nru syslog-ng-3.11.1/modules/afprog/afprog-plugin.c syslog-ng-3.13.2/modules/afprog/afprog-plugin.c --- syslog-ng-3.11.1/modules/afprog/afprog-plugin.c 2017-07-31 09:05:32.000000000 +0000 +++ syslog-ng-3.13.2/modules/afprog/afprog-plugin.c 2017-12-06 06:39:39.000000000 +0000 @@ -42,9 +42,9 @@ }; gboolean -afprog_module_init(GlobalConfig *cfg, CfgArgs *args) +afprog_module_init(PluginContext *context, CfgArgs *args) { - plugin_register(cfg, afprog_plugins, G_N_ELEMENTS(afprog_plugins)); + plugin_register(context, afprog_plugins, G_N_ELEMENTS(afprog_plugins)); return TRUE; } diff -Nru syslog-ng-3.11.1/modules/afsmtp/afsmtp.c syslog-ng-3.13.2/modules/afsmtp/afsmtp.c --- syslog-ng-3.11.1/modules/afsmtp/afsmtp.c 2017-07-31 09:05:32.000000000 +0000 +++ syslog-ng-3.13.2/modules/afsmtp/afsmtp.c 2017-12-06 06:39:39.000000000 +0000 @@ -695,9 +695,9 @@ }; gboolean -afsmtp_module_init(GlobalConfig *cfg, CfgArgs *args) +afsmtp_module_init(PluginContext *context, CfgArgs *args) { - plugin_register(cfg, &afsmtp_plugin, 1); + plugin_register(context, &afsmtp_plugin, 1); return TRUE; } diff -Nru syslog-ng-3.11.1/modules/afsmtp/afsmtp-parser.h syslog-ng-3.13.2/modules/afsmtp/afsmtp-parser.h --- syslog-ng-3.11.1/modules/afsmtp/afsmtp-parser.h 2017-07-31 09:05:32.000000000 +0000 +++ syslog-ng-3.13.2/modules/afsmtp/afsmtp-parser.h 2017-12-06 06:39:39.000000000 +0000 @@ -25,7 +25,6 @@ #define AFSMTP_PARSER_H_INCLUDED #include "cfg-parser.h" -#include "cfg-lexer.h" #include "afsmtp.h" extern CfgParser afsmtp_parser; diff -Nru syslog-ng-3.11.1/modules/afsocket/afinet-dest.c syslog-ng-3.13.2/modules/afsocket/afinet-dest.c --- syslog-ng-3.11.1/modules/afsocket/afinet-dest.c 2017-07-31 09:05:32.000000000 +0000 +++ syslog-ng-3.13.2/modules/afsocket/afinet-dest.c 2017-12-06 06:39:39.000000000 +0000 @@ -102,7 +102,7 @@ X509 *cert = X509_STORE_CTX_get0_cert(ctx); if (ok && current_cert == cert && self->hostname - && (transport_mapper_inet->tls_context->verify_mode & TVM_TRUSTED)) + && (tls_context_get_verify_mode(transport_mapper_inet->tls_context) & TVM_TRUSTED)) { ok = tls_verify_certificate_name(cert, self->hostname); } diff -Nru syslog-ng-3.11.1/modules/afsocket/afsocket-dest.c syslog-ng-3.13.2/modules/afsocket/afsocket-dest.c --- syslog-ng-3.11.1/modules/afsocket/afsocket-dest.c 2017-07-31 09:05:32.000000000 +0000 +++ syslog-ng-3.13.2/modules/afsocket/afsocket-dest.c 2017-12-06 06:39:39.000000000 +0000 @@ -69,9 +69,9 @@ } static inline gboolean -_is_protocol_type_changed_during_reload(AFSocketDestDriver *self, ReloadStoreItem *item) +_is_protocol_compatible_with_writer_after_reload(AFSocketDestDriver *self, ReloadStoreItem *item) { - return (self->proto_factory->construct != item->proto_factory->construct); + return (self->proto_factory->construct == item->proto_factory->construct); } void @@ -337,7 +337,7 @@ { GlobalConfig *cfg = log_pipe_get_config(&self->super.super.super); - self->proto_factory = log_proto_client_get_factory(cfg, self->transport_mapper->logproto); + self->proto_factory = log_proto_client_get_factory(&cfg->plugin_context, self->transport_mapper->logproto); if (!self->proto_factory) { msg_error("Unknown value specified in the transport() option, no such LogProto plugin found", @@ -379,17 +379,22 @@ } static void -afsocket_dd_restore_writer(AFSocketDestDriver *self) +_afsocket_dd_try_to_restore_writer(AFSocketDestDriver *self) { - GlobalConfig *cfg; - ReloadStoreItem *item; - - g_assert(self->writer == NULL); + /* If we are reinitializing an old config, an existing writer may be present */ + if (self->writer) + return; - cfg = log_pipe_get_config(&self->super.super.super); - item = cfg_persist_config_fetch(cfg, afsocket_dd_format_connections_name(self)); + ReloadStoreItem *item = cfg_persist_config_fetch( + log_pipe_get_config(&self->super.super.super), + afsocket_dd_format_connections_name(self)); + + /* We don't have an item stored in the reload cache, which means */ + /* it is the first time when we try to initialize the writer */ + if (!item) + return; - if (item && !_is_protocol_type_changed_during_reload(self, item)) + if (_is_protocol_compatible_with_writer_after_reload(self, item)) self->writer = _reload_store_item_release_writer(item); _reload_store_item_free(item); @@ -410,7 +415,7 @@ static gboolean afsocket_dd_setup_writer(AFSocketDestDriver *self) { - afsocket_dd_restore_writer(self); + _afsocket_dd_try_to_restore_writer(self); if (!self->writer) { @@ -422,8 +427,6 @@ log_pipe_set_config((LogPipe *)self->writer, log_pipe_get_config(&self->super.super.super)); log_writer_set_options(self->writer, &self->super.super.super, &self->writer_options, - STATS_LEVEL0, - self->transport_mapper->stats_source, self->super.super.id, afsocket_dd_stats_instance(self)); log_writer_set_queue(self->writer, log_dest_driver_acquire_queue( @@ -464,6 +467,9 @@ return FALSE; } + if (!transport_mapper_init(self->transport_mapper)) + return FALSE; + if (!afsocket_dd_setup_writer(self)) return FALSE; @@ -567,5 +573,7 @@ self->writer_options.mark_mode = MM_GLOBAL; + self->writer_options.stats_level = STATS_LEVEL0; + self->writer_options.stats_source = self->transport_mapper->stats_source; afsocket_dd_init_watches(self); } diff -Nru syslog-ng-3.11.1/modules/afsocket/afsocket-grammar.ym syslog-ng-3.13.2/modules/afsocket/afsocket-grammar.ym --- syslog-ng-3.11.1/modules/afsocket/afsocket-grammar.ym 2017-07-31 09:05:32.000000000 +0000 +++ syslog-ng-3.13.2/modules/afsocket/afsocket-grammar.ym 2017-12-06 06:39:39.000000000 +0000 @@ -163,11 +163,14 @@ %token KW_PEER_VERIFY %token KW_KEY_FILE %token KW_CERT_FILE +%token KW_DHPARAM_FILE +%token KW_PKCS12_FILE %token KW_CA_DIR %token KW_CRL_DIR %token KW_TRUSTED_KEYS %token KW_TRUSTED_DN %token KW_CIPHER_SUITE +%token KW_ECDH_CURVE_LIST %token KW_SSL_OPTIONS /* INCLUDE_DECLS */ @@ -228,7 +231,7 @@ | LL_CONTEXT_DESTINATION dest_afnetwork { $$ = $2; } ; - + source_afunix : KW_UNIX_DGRAM '(' source_afunix_dgram_params ')' { $$ = $3; } | KW_UNIX_STREAM '(' source_afunix_stream_params ')' { $$ = $3; } @@ -455,7 +458,7 @@ : source_reader_option | socket_option ; - + dest_afunix : KW_UNIX_DGRAM '(' dest_afunix_dgram_params ')' { $$ = $3; } | KW_UNIX_STREAM '(' dest_afunix_stream_params ')' { $$ = $3; } @@ -667,33 +670,43 @@ | KW_PEER_VERIFY '(' yesno ')' { - last_tls_context->verify_mode = $3 - ? (TVM_REQUIRED | TVM_TRUSTED) - : (TVM_OPTIONAL | TVM_UNTRUSTED); + gint verify_mode = $3 ? (TVM_REQUIRED | TVM_TRUSTED) : (TVM_OPTIONAL | TVM_UNTRUSTED); + tls_context_set_verify_mode(last_tls_context, verify_mode); } | KW_PEER_VERIFY '(' string ')' { - last_tls_context->verify_mode = tls_lookup_verify_mode($3); + CHECK_ERROR(tls_context_set_verify_mode_by_name(last_tls_context, $3), @3, + "unknown peer-verify() argument"); free($3); } | KW_KEY_FILE '(' string ')' { - last_tls_context->key_file = g_strdup($3); + tls_context_set_key_file(last_tls_context, $3); free($3); } | KW_CERT_FILE '(' string ')' { - last_tls_context->cert_file = g_strdup($3); + tls_context_set_cert_file(last_tls_context, $3); + free($3); + } + | KW_DHPARAM_FILE '(' string ')' + { + tls_context_set_dhparam_file(last_tls_context, $3); + free($3); + } + | KW_PKCS12_FILE '(' string ')' + { + tls_context_set_pkcs12_file(last_tls_context, $3); free($3); } | KW_CA_DIR '(' string ')' { - last_tls_context->ca_dir = g_strdup($3); + tls_context_set_ca_dir(last_tls_context, $3); free($3); } | KW_CRL_DIR '(' string ')' { - last_tls_context->crl_dir = g_strdup($3); + tls_context_set_crl_dir(last_tls_context, $3); free($3); } | KW_TRUSTED_KEYS '(' string_list ')' @@ -706,12 +719,18 @@ } | KW_CIPHER_SUITE '(' string ')' { - last_tls_context->cipher_suite = g_strdup($3); + tls_context_set_cipher_suite(last_tls_context, $3); free($3); } + | KW_ECDH_CURVE_LIST '(' string ')' + { + tls_context_set_ecdh_curve_list(last_tls_context, $3); + free($3); + } | KW_SSL_OPTIONS '(' string_list ')' { - last_tls_context->ssl_options = tls_lookup_options($3); + CHECK_ERROR(tls_context_set_ssl_options_by_name(last_tls_context, $3), @3, + "unknown ssl-options() argument"); } | KW_ENDIF { } diff -Nru syslog-ng-3.11.1/modules/afsocket/afsocket-parser.c syslog-ng-3.13.2/modules/afsocket/afsocket-parser.c --- syslog-ng-3.11.1/modules/afsocket/afsocket-parser.c 2017-07-31 09:05:32.000000000 +0000 +++ syslog-ng-3.13.2/modules/afsocket/afsocket-parser.c 2017-12-06 06:39:39.000000000 +0000 @@ -47,11 +47,15 @@ { "peer_verify", KW_PEER_VERIFY }, { "key_file", KW_KEY_FILE }, { "cert_file", KW_CERT_FILE }, + { "dhparam_file", KW_DHPARAM_FILE }, + { "pkcs12_file", KW_PKCS12_FILE }, { "ca_dir", KW_CA_DIR }, { "crl_dir", KW_CRL_DIR }, { "trusted_keys", KW_TRUSTED_KEYS }, { "trusted_dn", KW_TRUSTED_DN }, { "cipher_suite", KW_CIPHER_SUITE }, + { "ecdh_curve_list", KW_ECDH_CURVE_LIST }, + { "curve_list", KW_ECDH_CURVE_LIST, KWS_OBSOLETE, "ecdh_curve_list"}, { "ssl_options", KW_SSL_OPTIONS }, { "localip", KW_LOCALIP }, diff -Nru syslog-ng-3.11.1/modules/afsocket/afsocket-parser.h syslog-ng-3.13.2/modules/afsocket/afsocket-parser.h --- syslog-ng-3.11.1/modules/afsocket/afsocket-parser.h 2017-07-31 09:05:32.000000000 +0000 +++ syslog-ng-3.13.2/modules/afsocket/afsocket-parser.h 2017-12-06 06:39:39.000000000 +0000 @@ -25,7 +25,6 @@ #define AFSOCKET_PARSER_H_INCLUDED #include "cfg-parser.h" -#include "cfg-lexer.h" #include "driver.h" extern CfgParser afsocket_parser; diff -Nru syslog-ng-3.11.1/modules/afsocket/afsocket-plugin.c syslog-ng-3.13.2/modules/afsocket/afsocket-plugin.c --- syslog-ng-3.11.1/modules/afsocket/afsocket-plugin.c 2017-07-31 09:05:32.000000000 +0000 +++ syslog-ng-3.13.2/modules/afsocket/afsocket-plugin.c 2017-12-06 06:39:39.000000000 +0000 @@ -117,9 +117,9 @@ }; gboolean -afsocket_module_init(GlobalConfig *cfg, CfgArgs *args) +afsocket_module_init(PluginContext *context, CfgArgs *args) { - plugin_register(cfg, afsocket_plugins, G_N_ELEMENTS(afsocket_plugins)); + plugin_register(context, afsocket_plugins, G_N_ELEMENTS(afsocket_plugins)); return TRUE; } @@ -127,7 +127,6 @@ { .canonical_name = "afsocket", .version = SYSLOG_NG_VERSION, - .preference = 100, .description = "The afsocket module provides socket based transports for syslog-ng, such as the udp(), tcp() and syslog() drivers. This module is compiled with SSL support.", .core_revision = SYSLOG_NG_SOURCE_REVISION, .plugins = afsocket_plugins, diff -Nru syslog-ng-3.11.1/modules/afsocket/afsocket-source.c syslog-ng-3.13.2/modules/afsocket/afsocket-source.c --- syslog-ng-3.11.1/modules/afsocket/afsocket-source.c 2017-07-31 09:05:32.000000000 +0000 +++ syslog-ng-3.13.2/modules/afsocket/afsocket-source.c 2017-12-06 06:39:39.000000000 +0000 @@ -99,12 +99,11 @@ log_reader_reopen(self->reader, proto, poll_fd_events_new(self->sock)); log_reader_set_peer_addr(self->reader, self->peer_addr); } - log_reader_set_options(self->reader, s, + log_reader_set_options(self->reader, &self->super, &self->owner->reader_options, - STATS_LEVEL1, - self->owner->transport_mapper->stats_source, self->owner->super.super.id, afsocket_sc_stats_instance(self)); + log_pipe_append((LogPipe *) self->reader, s); if (log_pipe_init((LogPipe *) self->reader)) { @@ -494,7 +493,7 @@ if (!transport_mapper_apply_transport(self->transport_mapper, cfg)) return FALSE; - self->proto_factory = log_proto_server_get_factory(cfg, self->transport_mapper->logproto); + self->proto_factory = log_proto_server_get_factory(&cfg->plugin_context, self->transport_mapper->logproto); if (!self->proto_factory) { msg_error("Unknown value specified in the transport() option, no such LogProto plugin found", @@ -674,7 +673,8 @@ afsocket_sd_setup_transport(self) && afsocket_sd_setup_addresses(self) && afsocket_sd_restore_kept_alive_connections(self) && - afsocket_sd_open_listener(self); + afsocket_sd_open_listener(self) && + transport_mapper_init(self->transport_mapper); } gboolean @@ -735,6 +735,8 @@ self->listen_backlog = 255; self->connections_kept_alive_accross_reloads = TRUE; log_reader_options_defaults(&self->reader_options); + self->reader_options.super.stats_level = STATS_LEVEL1; + self->reader_options.super.stats_source = transport_mapper->stats_source; /* NOTE: this changes the initial window size from 100 to 1000. Reasons: * Starting with syslog-ng 3.3, window-size is distributed evenly between diff -Nru syslog-ng-3.11.1/modules/afsocket/tests/test-transport-mapper-unix.c syslog-ng-3.13.2/modules/afsocket/tests/test-transport-mapper-unix.c --- syslog-ng-3.11.1/modules/afsocket/tests/test-transport-mapper-unix.c 2017-07-31 09:05:32.000000000 +0000 +++ syslog-ng-3.13.2/modules/afsocket/tests/test-transport-mapper-unix.c 2017-12-06 06:39:39.000000000 +0000 @@ -26,7 +26,7 @@ #include "transport-mapper-lib.h" static void -test_transport_mapper_unix_stream_apply_transport_sets_defaults() +test_transport_mapper_unix_stream_apply_transport_sets_defaults(void) { assert_transport_mapper_apply(transport_mapper, NULL); assert_transport_mapper_transport(transport_mapper, "unix-stream"); @@ -38,7 +38,7 @@ } static void -test_transport_mapper_unix_dgram_apply_transport_sets_defaults() +test_transport_mapper_unix_dgram_apply_transport_sets_defaults(void) { assert_transport_mapper_apply(transport_mapper, NULL); assert_transport_mapper_transport(transport_mapper, "unix-dgram"); diff -Nru syslog-ng-3.11.1/modules/afsocket/transport-mapper.h syslog-ng-3.13.2/modules/afsocket/transport-mapper.h --- syslog-ng-3.11.1/modules/afsocket/transport-mapper.h 2017-07-31 09:05:32.000000000 +0000 +++ syslog-ng-3.13.2/modules/afsocket/transport-mapper.h 2017-12-06 06:39:39.000000000 +0000 @@ -47,6 +47,7 @@ gboolean (*apply_transport)(TransportMapper *self, GlobalConfig *cfg); LogTransport *(*construct_log_transport)(TransportMapper *self, gint fd); + gboolean (*init)(TransportMapper *self); void (*free_fn)(TransportMapper *self); }; @@ -78,4 +79,13 @@ return self->construct_log_transport(self, fd); } +static inline gboolean +transport_mapper_init(TransportMapper *self) +{ + if (self->init) + return self->init(self); + + return TRUE; +} + #endif diff -Nru syslog-ng-3.11.1/modules/afsocket/transport-mapper-inet.c syslog-ng-3.13.2/modules/afsocket/transport-mapper-inet.c --- syslog-ng-3.11.1/modules/afsocket/transport-mapper-inet.c 2017-07-31 09:05:32.000000000 +0000 +++ syslog-ng-3.13.2/modules/afsocket/transport-mapper-inet.c 2017-12-06 06:39:39.000000000 +0000 @@ -102,6 +102,17 @@ return transport_mapper_construct_log_transport_method(s, fd); } +static gboolean +transport_mapper_inet_init(TransportMapper *s) +{ + TransportMapperInet *self = (TransportMapperInet *) s; + + if (self->tls_context && !tls_context_setup_context(self->tls_context)) + return FALSE; + + return TRUE; +} + void transport_mapper_inet_free_method(TransportMapper *s) { @@ -118,6 +129,7 @@ transport_mapper_init_instance(&self->super, transport); self->super.apply_transport = transport_mapper_inet_apply_transport_method; self->super.construct_log_transport = transport_mapper_inet_construct_log_transport; + self->super.init = transport_mapper_inet_init; self->super.free_fn = transport_mapper_inet_free_method; self->super.address_family = AF_INET; } diff -Nru syslog-ng-3.11.1/modules/afsql/afsql-parser.h syslog-ng-3.13.2/modules/afsql/afsql-parser.h --- syslog-ng-3.11.1/modules/afsql/afsql-parser.h 2017-07-31 09:05:32.000000000 +0000 +++ syslog-ng-3.13.2/modules/afsql/afsql-parser.h 2017-12-06 06:39:39.000000000 +0000 @@ -25,7 +25,6 @@ #define AFSOCKET_PARSER_H_INCLUDED #include "cfg-parser.h" -#include "cfg-lexer.h" #include "driver.h" extern CfgParser afsql_parser; diff -Nru syslog-ng-3.11.1/modules/afsql/afsql-plugin.c syslog-ng-3.13.2/modules/afsql/afsql-plugin.c --- syslog-ng-3.11.1/modules/afsql/afsql-plugin.c 2017-07-31 09:05:32.000000000 +0000 +++ syslog-ng-3.13.2/modules/afsql/afsql-plugin.c 2017-12-06 06:39:39.000000000 +0000 @@ -37,9 +37,9 @@ }; gboolean -afsql_module_init(GlobalConfig *cfg, CfgArgs *args) +afsql_module_init(PluginContext *context, CfgArgs *args) { - plugin_register(cfg, afsql_plugins, G_N_ELEMENTS(afsql_plugins)); + plugin_register(context, afsql_plugins, G_N_ELEMENTS(afsql_plugins)); return TRUE; } diff -Nru syslog-ng-3.11.1/modules/afstomp/afstomp.c syslog-ng-3.13.2/modules/afstomp/afstomp.c --- syslog-ng-3.11.1/modules/afstomp/afstomp.c 2017-07-31 09:05:32.000000000 +0000 +++ syslog-ng-3.13.2/modules/afstomp/afstomp.c 2017-12-06 06:39:39.000000000 +0000 @@ -416,9 +416,9 @@ }; gboolean -afstomp_module_init(GlobalConfig *cfg, CfgArgs *args) +afstomp_module_init(PluginContext *context, CfgArgs *args) { - plugin_register(cfg, &afstomp_plugin, 1); + plugin_register(context, &afstomp_plugin, 1); return TRUE; } diff -Nru syslog-ng-3.11.1/modules/afstomp/afstomp-parser.h syslog-ng-3.13.2/modules/afstomp/afstomp-parser.h --- syslog-ng-3.11.1/modules/afstomp/afstomp-parser.h 2017-07-31 09:05:32.000000000 +0000 +++ syslog-ng-3.13.2/modules/afstomp/afstomp-parser.h 2017-12-06 06:39:39.000000000 +0000 @@ -26,7 +26,6 @@ #define AFSTOMP_PARSER_H_INCLUDED #include "cfg-parser.h" -#include "cfg-lexer.h" #include "afstomp.h" extern CfgParser afstomp_parser; diff -Nru syslog-ng-3.11.1/modules/afstomp/tests/test_stomp_proto.c syslog-ng-3.13.2/modules/afstomp/tests/test_stomp_proto.c --- syslog-ng-3.11.1/modules/afstomp/tests/test_stomp_proto.c 2017-07-31 09:05:32.000000000 +0000 +++ syslog-ng-3.13.2/modules/afstomp/tests/test_stomp_proto.c 2017-12-06 06:39:39.000000000 +0000 @@ -45,7 +45,7 @@ } void -test_only_command() +test_only_command(void) { stomp_frame frame; @@ -55,7 +55,7 @@ } void -test_command_and_data() +test_command_and_data(void) { stomp_frame frame; @@ -66,7 +66,7 @@ }; void -test_command_and_header_and_data() +test_command_and_header_and_data(void) { stomp_frame frame; @@ -78,7 +78,7 @@ }; void -test_command_and_header() +test_command_and_header(void) { stomp_frame frame; @@ -89,7 +89,7 @@ }; void -test_generate_gstring_from_frame() +test_generate_gstring_from_frame(void) { stomp_frame frame; GString *actual; diff -Nru syslog-ng-3.11.1/modules/afstreams/afstreams.c syslog-ng-3.13.2/modules/afstreams/afstreams.c --- syslog-ng-3.11.1/modules/afstreams/afstreams.c 2017-07-31 09:05:32.000000000 +0000 +++ syslog-ng-3.13.2/modules/afstreams/afstreams.c 2017-12-06 06:39:39.000000000 +0000 @@ -190,8 +190,6 @@ log_reader_set_options(self->reader, s, &self->reader_options, - STATS_LEVEL1, - SCS_SUN_STREAMS, self->super.super.id, self->dev_filename->str); log_pipe_append((LogPipe *) self->reader, s); @@ -277,5 +275,7 @@ log_reader_options_defaults(&self->reader_options); self->reader_options.parse_options.flags |= LP_LOCAL; self->reader_options.parse_options.flags &= ~LP_EXPECT_HOSTNAME; + self->reader_options.super.stats_level = STATS_LEVEL1; + self->reader_options.super.stats_source = SCS_SUN_STREAMS; return &self->super.super; } diff -Nru syslog-ng-3.11.1/modules/afstreams/afstreams-parser.h syslog-ng-3.13.2/modules/afstreams/afstreams-parser.h --- syslog-ng-3.11.1/modules/afstreams/afstreams-parser.h 2017-07-31 09:05:32.000000000 +0000 +++ syslog-ng-3.13.2/modules/afstreams/afstreams-parser.h 2017-12-06 06:39:39.000000000 +0000 @@ -25,7 +25,6 @@ #define AFSOCKET_PARSER_H_INCLUDED #include "cfg-parser.h" -#include "cfg-lexer.h" #include "driver.h" extern CfgParser afstreams_parser; diff -Nru syslog-ng-3.11.1/modules/afstreams/afstreams-plugin.c syslog-ng-3.13.2/modules/afstreams/afstreams-plugin.c --- syslog-ng-3.11.1/modules/afstreams/afstreams-plugin.c 2017-07-31 09:05:32.000000000 +0000 +++ syslog-ng-3.13.2/modules/afstreams/afstreams-plugin.c 2017-12-06 06:39:39.000000000 +0000 @@ -37,9 +37,9 @@ }; gboolean -afstreams_module_init(GlobalConfig *cfg, CfgArgs *args) +afstreams_module_init(PluginContext *context, CfgArgs *args) { - plugin_register(cfg, afstreams_plugins, G_N_ELEMENTS(afstreams_plugins)); + plugin_register(context, afstreams_plugins, G_N_ELEMENTS(afstreams_plugins)); return TRUE; } diff -Nru syslog-ng-3.11.1/modules/afuser/afuser-parser.h syslog-ng-3.13.2/modules/afuser/afuser-parser.h --- syslog-ng-3.11.1/modules/afuser/afuser-parser.h 2017-07-31 09:05:32.000000000 +0000 +++ syslog-ng-3.13.2/modules/afuser/afuser-parser.h 2017-12-06 06:39:39.000000000 +0000 @@ -25,7 +25,6 @@ #define AFUSER_PARSER_H_INCLUDED #include "cfg-parser.h" -#include "cfg-lexer.h" #include "driver.h" extern CfgParser afuser_parser; diff -Nru syslog-ng-3.11.1/modules/afuser/afuser-plugin.c syslog-ng-3.13.2/modules/afuser/afuser-plugin.c --- syslog-ng-3.11.1/modules/afuser/afuser-plugin.c 2017-07-31 09:05:32.000000000 +0000 +++ syslog-ng-3.13.2/modules/afuser/afuser-plugin.c 2017-12-06 06:39:39.000000000 +0000 @@ -37,9 +37,9 @@ }; gboolean -afuser_module_init(GlobalConfig *cfg, CfgArgs *args) +afuser_module_init(PluginContext *context, CfgArgs *args) { - plugin_register(cfg, afuser_plugins, G_N_ELEMENTS(afuser_plugins)); + plugin_register(context, afuser_plugins, G_N_ELEMENTS(afuser_plugins)); return TRUE; } diff -Nru syslog-ng-3.11.1/modules/appmodel/application.c syslog-ng-3.13.2/modules/appmodel/application.c --- syslog-ng-3.11.1/modules/appmodel/application.c 1970-01-01 00:00:00.000000000 +0000 +++ syslog-ng-3.13.2/modules/appmodel/application.c 2017-12-06 06:39:39.000000000 +0000 @@ -0,0 +1,58 @@ +/* + * Copyright (c) 2002-2017 Balabit + * Copyright (c) 1998-2017 Balázs Scheidler + * + * This program is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 as published + * by the Free Software Foundation, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + * + * As an additional exemption you are allowed to compile & link against the + * OpenSSL libraries as published by the OpenSSL project. See the file + * COPYING for details. + * + */ + +#include "application.h" + +void +application_set_filter(Application *self, const gchar *filter_expr) +{ + g_free(self->filter_expr); + self->filter_expr = g_strdup(filter_expr); +} + +void +application_set_parser(Application *self, const gchar *parser_expr) +{ + g_free(self->parser_expr); + self->parser_expr = g_strdup(parser_expr); +} + +Application * +application_new(const gchar *name, const gchar *topic) +{ + Application *self = g_new0(Application, 1); + + self->name = g_strdup(name); + self->topic = g_strdup(topic); + return self; +} + +void +application_free(Application *self) +{ + g_free(self->name); + g_free(self->topic); + g_free(self->filter_expr); + g_free(self->parser_expr); + g_free(self); +} diff -Nru syslog-ng-3.11.1/modules/appmodel/application.h syslog-ng-3.13.2/modules/appmodel/application.h --- syslog-ng-3.11.1/modules/appmodel/application.h 1970-01-01 00:00:00.000000000 +0000 +++ syslog-ng-3.13.2/modules/appmodel/application.h 2017-12-06 06:39:39.000000000 +0000 @@ -0,0 +1,43 @@ +/* + * Copyright (c) 2002-2017 Balabit + * Copyright (c) 1998-2017 Balázs Scheidler + * + * This program is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 as published + * by the Free Software Foundation, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + * + * As an additional exemption you are allowed to compile & link against the + * OpenSSL libraries as published by the OpenSSL project. See the file + * COPYING for details. + * + */ + +#ifndef APPMODEL_APPLICATION_H_INCLUDED +#define APPMODEL_APPLICATION_H_INCLUDED + +#include "syslog-ng.h" + +typedef struct _Application +{ + gchar *name; + gchar *topic; + gchar *filter_expr; + gchar *parser_expr; +} Application; + +void application_set_filter(Application *self, const gchar *filter_expr); +void application_set_parser(Application *self, const gchar *parser_expr); + +Application *application_new(const gchar *name, const gchar *topic); +void application_free(Application *s); + +#endif diff -Nru syslog-ng-3.11.1/modules/appmodel/appmodel.c syslog-ng-3.13.2/modules/appmodel/appmodel.c --- syslog-ng-3.11.1/modules/appmodel/appmodel.c 1970-01-01 00:00:00.000000000 +0000 +++ syslog-ng-3.13.2/modules/appmodel/appmodel.c 2017-12-06 06:39:39.000000000 +0000 @@ -0,0 +1,47 @@ +/* + * Copyright (c) 2017 Balabit + * Copyright (c) 2017 Balazs Scheidler + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + * + * As an additional exemption you are allowed to compile & link against the + * OpenSSL libraries as published by the OpenSSL project. See the file + * COPYING for details. + * + */ +#include "appmodel.h" +#include "cfg.h" + +#define MODULE_CONFIG_KEY "appmodel" + +AppModelContext * +appmodel_get_context(GlobalConfig *cfg) +{ + AppModelContext *ac = g_hash_table_lookup(cfg->module_config, MODULE_CONFIG_KEY); + if (!ac) + { + ac = appmodel_context_new(); + g_hash_table_insert(cfg->module_config, g_strdup(MODULE_CONFIG_KEY), ac); + } + return ac; +} + +void +appmodel_register_application(GlobalConfig *cfg, Application *application) +{ + AppModelContext *ac = appmodel_get_context(cfg); + + appmodel_context_register_application(ac, application); +} diff -Nru syslog-ng-3.11.1/modules/appmodel/appmodel-context.c syslog-ng-3.13.2/modules/appmodel/appmodel-context.c --- syslog-ng-3.11.1/modules/appmodel/appmodel-context.c 1970-01-01 00:00:00.000000000 +0000 +++ syslog-ng-3.13.2/modules/appmodel/appmodel-context.c 2017-12-06 06:39:39.000000000 +0000 @@ -0,0 +1,134 @@ +/* + * Copyright (c) 2015 Balabit + * Copyright (c) 2015 Balazs Scheidler + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + * + * As an additional exemption you are allowed to compile & link against the + * OpenSSL libraries as published by the OpenSSL project. See the file + * COPYING for details. + * + */ +#include "appmodel.h" + +#include + +typedef struct _AppModelContext +{ + /* the context structure is registered into GlobalConfig, thus it must be + * derived from ModuleConfig */ + ModuleConfig super; + GHashTable *applications; + GPtrArray *application_ptrs; +} AppModelContext; + +static gboolean +_application_equal(gconstpointer v1, gconstpointer v2) +{ + Application *r1 = (Application *) v1; + Application *r2 = (Application *) v2; + + if (strcmp(r1->name, r2->name) != 0) + return FALSE; + + if (strcmp(r1->topic, r2->topic) != 0) + return FALSE; + + return TRUE; +} + +static guint +_application_hash(gconstpointer v) +{ + Application *r = (Application *) v; + + return g_str_hash(r->name) + g_str_hash(r->topic); +} + +void +appmodel_context_register_application(AppModelContext *self, Application *app) +{ + Application *orig_app; + + orig_app = g_hash_table_lookup(self->applications, app); + if (!orig_app) + { + g_hash_table_insert(self->applications, app, app); + g_ptr_array_add(self->application_ptrs, app); + } + else + { + g_hash_table_replace(self->applications, app, app); + + g_ptr_array_remove(self->application_ptrs, orig_app); + g_ptr_array_add(self->application_ptrs, app); + } +} + +Application * +appmodel_context_lookup_application(AppModelContext *self, const gchar *name, const gchar *topic) +{ + Application lookup_app = { 0 }; + + lookup_app.name = (gchar *) name; + lookup_app.topic = (gchar *) topic; + return (Application *) g_hash_table_lookup(self->applications, &lookup_app); +} + +void +appmodel_context_iter_applications(AppModelContext *self, void (*foreach)(Application *app, Application *base_app, + gpointer user_data), gpointer user_data) +{ + gint i; + + for (i = 0; i < self->application_ptrs->len; i++) + { + Application *app = g_ptr_array_index(self->application_ptrs, i); + + if (strcmp(app->topic, "*") == 0) + continue; + + Application *base_app = appmodel_context_lookup_application(self, app->name, "*"); + foreach(app, base_app, user_data); + } +} + +void +appmodel_context_free_method(ModuleConfig *s) +{ + AppModelContext *self = (AppModelContext *) s; + + g_hash_table_destroy(self->applications); + g_ptr_array_free(self->application_ptrs, TRUE); + module_config_free_method(s); +} + +AppModelContext * +appmodel_context_new(void) +{ + AppModelContext *self = g_new0(AppModelContext, 1); + + self->super.free_fn = appmodel_context_free_method; + self->applications = g_hash_table_new_full(_application_hash, _application_equal, + NULL, (GDestroyNotify) application_free); + self->application_ptrs = g_ptr_array_new(); + return self; +} + +void +appmodel_context_free(AppModelContext *self) +{ + return module_config_free(&self->super); +} diff -Nru syslog-ng-3.11.1/modules/appmodel/appmodel-context.h syslog-ng-3.13.2/modules/appmodel/appmodel-context.h --- syslog-ng-3.11.1/modules/appmodel/appmodel-context.h 1970-01-01 00:00:00.000000000 +0000 +++ syslog-ng-3.13.2/modules/appmodel/appmodel-context.h 2017-12-06 06:39:39.000000000 +0000 @@ -0,0 +1,39 @@ +/* + * Copyright (c) 2017 Balabit + * Copyright (c) 2017 Balazs Scheidler + * + * This program is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 as published + * by the Free Software Foundation, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + * + * As an additional exemption you are allowed to compile & link against the + * OpenSSL libraries as published by the OpenSSL project. See the file + * COPYING for details. + * + */ +#ifndef APPMODEL_CONTEXT_H_INCLUDED +#define APPMODEL_CONTEXT_H_INCLUDED 1 + +#include "module-config.h" +#include "application.h" + +typedef struct _AppModelContext AppModelContext; + +void appmodel_context_iter_applications(AppModelContext *self, + void (*foreach)(Application *app, Application *base_app, gpointer user_data), + gpointer user_data); +Application *appmodel_context_lookup_application(AppModelContext *self, const gchar *name, const gchar *topic); +void appmodel_context_register_application(AppModelContext *self, Application *app); +void appmodel_context_free(AppModelContext *self); +AppModelContext *appmodel_context_new(void); + +#endif diff -Nru syslog-ng-3.11.1/modules/appmodel/appmodel-grammar.ym syslog-ng-3.13.2/modules/appmodel/appmodel-grammar.ym --- syslog-ng-3.11.1/modules/appmodel/appmodel-grammar.ym 1970-01-01 00:00:00.000000000 +0000 +++ syslog-ng-3.13.2/modules/appmodel/appmodel-grammar.ym 2017-12-06 06:39:39.000000000 +0000 @@ -0,0 +1,104 @@ +/* + * Copyright (c) 2002-2017 Balabit + * Copyright (c) 1998-2017 Balázs Scheidler + * + * This program is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 as published + * by the Free Software Foundation, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + * + * As an additional exemption you are allowed to compile & link against the + * OpenSSL libraries as published by the OpenSSL project. See the file + * COPYING for details. + * + */ + +%code top { +#include "appmodel.h" +#include "appmodel-parser.h" +} + + +%code { + +#include "cfg-parser.h" +#include "cfg-grammar.h" +#include "appmodel-grammar.h" +#include "messages.h" + +Application *last_application; + +} + +%name-prefix "appmodel_" + +/* this parameter is needed in order to instruct bison to use a complete + * argument list for yylex/yyerror */ + +%lex-param {CfgLexer *lexer} +%parse-param {CfgLexer *lexer} +%parse-param {gpointer *instance} +%parse-param {gpointer arg} + +/* INCLUDE_DECLS */ + +%token KW_APPLICATION + +%type application_definition + +%% + +start + : LL_CONTEXT_ROOT application_definition + { + appmodel_register_application(configuration, last_application); + *instance = last_application; + YYACCEPT; + } + ; + + +application_definition + : KW_APPLICATION string '[' string ']' + { + last_application = application_new($2, $4); + } + '{' application_options '}' + { + $$ = last_application; + } + ; + +application_options + : application_option ';' application_options + | + ; + +application_option + : KW_FILTER + { cfg_lexer_push_context(lexer, LL_CONTEXT_BLOCK_CONTENT, NULL, "app filter block"); } + LL_BLOCK + { cfg_lexer_pop_context(lexer); } + { + application_set_filter(last_application, $3); + } + | KW_PARSER + { cfg_lexer_push_context(lexer, LL_CONTEXT_BLOCK_CONTENT, NULL, "app parser block"); } + LL_BLOCK + { cfg_lexer_pop_context(lexer); } + { + application_set_parser(last_application, $3); + } + ; + +/* INCLUDE_RULES */ + +%% diff -Nru syslog-ng-3.11.1/modules/appmodel/appmodel.h syslog-ng-3.13.2/modules/appmodel/appmodel.h --- syslog-ng-3.11.1/modules/appmodel/appmodel.h 1970-01-01 00:00:00.000000000 +0000 +++ syslog-ng-3.13.2/modules/appmodel/appmodel.h 2017-12-06 06:39:39.000000000 +0000 @@ -0,0 +1,32 @@ +/* + * Copyright (c) 2017 Balabit + * Copyright (c) 2017 Balazs Scheidler + * + * This program is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 as published + * by the Free Software Foundation, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + * + * As an additional exemption you are allowed to compile & link against the + * OpenSSL libraries as published by the OpenSSL project. See the file + * COPYING for details. + * + */ +#ifndef APPMODEL_H_INCLUDED +#define APPMODEL_H_INCLUDED 1 + +#include "module-config.h" +#include "appmodel-context.h" + +AppModelContext *appmodel_get_context(GlobalConfig *cfg); +void appmodel_register_application(GlobalConfig *cfg, Application *application); + +#endif diff -Nru syslog-ng-3.11.1/modules/appmodel/appmodel-parser.c syslog-ng-3.13.2/modules/appmodel/appmodel-parser.c --- syslog-ng-3.11.1/modules/appmodel/appmodel-parser.c 1970-01-01 00:00:00.000000000 +0000 +++ syslog-ng-3.13.2/modules/appmodel/appmodel-parser.c 2017-12-06 06:39:39.000000000 +0000 @@ -0,0 +1,49 @@ +/* + * Copyright (c) 2002-2017 Balabit + * Copyright (c) 1998-2017 Balázs Scheidler + * + * This program is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 as published + * by the Free Software Foundation, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + * + * As an additional exemption you are allowed to compile & link against the + * OpenSSL libraries as published by the OpenSSL project. See the file + * COPYING for details. + * + */ + +#include "appmodel.h" +#include "cfg-parser.h" +#include "appmodel-grammar.h" + +extern int appmodel_debug; + +int appmodel_parse(CfgLexer *lexer, gpointer *instance, gpointer arg); + +static CfgLexerKeyword appmodel_keywords[] = +{ + { "application", KW_APPLICATION }, + { NULL } +}; + +CfgParser appmodel_parser = +{ +#if SYSLOG_NG_ENABLE_DEBUG + .debug_flag = &appmodel_debug, +#endif + .name = "appmodel", + .keywords = appmodel_keywords, + .parse = (gint (*)(CfgLexer *, gpointer *, gpointer)) appmodel_parse, + .cleanup = NULL, +}; + +CFG_PARSER_IMPLEMENT_LEXER_BINDING(appmodel_, gpointer *) diff -Nru syslog-ng-3.11.1/modules/appmodel/appmodel-parser.h syslog-ng-3.13.2/modules/appmodel/appmodel-parser.h --- syslog-ng-3.11.1/modules/appmodel/appmodel-parser.h 1970-01-01 00:00:00.000000000 +0000 +++ syslog-ng-3.13.2/modules/appmodel/appmodel-parser.h 2017-12-06 06:39:39.000000000 +0000 @@ -0,0 +1,34 @@ +/* + * Copyright (c) 2002-2015 Balabit + * Copyright (c) 1998-2015 Balázs Scheidler + * + * This program is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 as published + * by the Free Software Foundation, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + * + * As an additional exemption you are allowed to compile & link against the + * OpenSSL libraries as published by the OpenSSL project. See the file + * COPYING for details. + * + */ + +#ifndef APPMODEL_PARSER_H_INCLUDED +#define APPMODEL_PARSER_H_INCLUDED + +#include "cfg-parser.h" +#include "cfg-lexer.h" + +extern CfgParser appmodel_parser; + +CFG_PARSER_DECLARE_LEXER_BINDING(appmodel_, gpointer *) + +#endif diff -Nru syslog-ng-3.11.1/modules/appmodel/appmodel-plugin.c syslog-ng-3.13.2/modules/appmodel/appmodel-plugin.c --- syslog-ng-3.11.1/modules/appmodel/appmodel-plugin.c 1970-01-01 00:00:00.000000000 +0000 +++ syslog-ng-3.13.2/modules/appmodel/appmodel-plugin.c 2017-12-06 06:39:39.000000000 +0000 @@ -0,0 +1,67 @@ +/* + * Copyright (c) 2002-2015 Balabit + * Copyright (c) 1998-2015 Balázs Scheidler + * + * This program is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 as published + * by the Free Software Foundation, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + * + * As an additional exemption you are allowed to compile & link against the + * OpenSSL libraries as published by the OpenSSL project. See the file + * COPYING for details. + * + */ + +#include "cfg-parser.h" +#include "appmodel-parser.h" +#include "app-parser-generator.h" +#include "plugin.h" +#include "plugin-types.h" + +extern CfgParser appmodel_parser; + +static gpointer +app_parser_construct(Plugin *p) +{ + return app_parser_generator_new(p->type, p->name); +} + +static Plugin appmodel_plugins[] = +{ + { + .type = LL_CONTEXT_ROOT, + .name = "application", + .parser = &appmodel_parser, + }, + { + .type = LL_CONTEXT_PARSER | LL_CONTEXT_FLAG_GENERATOR, + .name = "app-parser", + .construct = app_parser_construct + } +}; + +gboolean +appmodel_module_init(PluginContext *context, CfgArgs *args) +{ + plugin_register(context, appmodel_plugins, G_N_ELEMENTS(appmodel_plugins)); + return TRUE; +} + +const ModuleInfo module_info = +{ + .canonical_name = "appmodel", + .version = SYSLOG_NG_VERSION, + .description = "The appmodel module provides parsing support for restoring message tags as produced by the TAGS macro.", + .core_revision = SYSLOG_NG_SOURCE_REVISION, + .plugins = appmodel_plugins, + .plugins_len = G_N_ELEMENTS(appmodel_plugins), +}; diff -Nru syslog-ng-3.11.1/modules/appmodel/app-parser-generator.c syslog-ng-3.13.2/modules/appmodel/app-parser-generator.c --- syslog-ng-3.11.1/modules/appmodel/app-parser-generator.c 1970-01-01 00:00:00.000000000 +0000 +++ syslog-ng-3.13.2/modules/appmodel/app-parser-generator.c 2017-12-06 06:39:39.000000000 +0000 @@ -0,0 +1,233 @@ +/* + * Copyright (c) 2017 Balabit + * Copyright (c) 2017 Balazs Scheidler + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + * + * As an additional exemption you are allowed to compile & link against the + * OpenSSL libraries as published by the OpenSSL project. See the file + * COPYING for details. + * + */ + +#include "app-parser-generator.h" +#include "appmodel.h" + +#include + +typedef struct _AppParserGenerator +{ + CfgBlockGenerator super; + GString *block; + const gchar *topic; + const gchar *included_apps; + const gchar *excluded_apps; + gboolean is_parsing_enabled; +} AppParserGenerator; + +static const gchar * +_get_filter_expr(Application *app, Application *base_app) +{ + if (app->filter_expr) + return app->filter_expr; + if (base_app) + return base_app->filter_expr; + return NULL; +} + +static const gchar * +_get_parser_expr(Application *app, Application *base_app) +{ + if (app->parser_expr) + return app->parser_expr; + if (base_app) + return base_app->parser_expr; + return NULL; +} + +static void +_generate_filter(AppParserGenerator *self, const gchar *filter_expr) +{ + if (filter_expr) + g_string_append_printf(self->block, " filter { %s };\n", filter_expr); +} + +static void +_generate_parser(AppParserGenerator *self, const gchar *parser_expr) +{ + if (parser_expr) + g_string_append_printf(self->block, " parser { %s };\n", parser_expr); +} + +static void +_generate_action(AppParserGenerator *self, Application *app) +{ + g_string_append_printf(self->block, " rewrite { set-tag('.app.%s'); };\n", app->name); + g_string_append(self->block, " flags(final);\n"); +} + +static gboolean +_is_application_included(AppParserGenerator *self, Application *app) +{ + /* include everything if we don't have the option */ + if (!self->included_apps) + return TRUE; + return strstr(self->included_apps, app->name) != NULL; +} + +static gboolean +_is_application_excluded(AppParserGenerator *self, Application *app) +{ + if (!self->excluded_apps) + return FALSE; + return strstr(self->excluded_apps, app->name) != NULL; +} + +static void +_generate_application(Application *app, Application *base_app, gpointer user_data) +{ + AppParserGenerator *self = (AppParserGenerator *) user_data; + + if (strcmp(self->topic, app->topic) != 0) + return; + + if (!_is_application_included(self, app)) + return; + + if (_is_application_excluded(self, app)) + return; + + g_string_append(self->block, "channel {\n"); + _generate_filter(self, _get_filter_expr(app, base_app)); + _generate_parser(self, _get_parser_expr(app, base_app)); + _generate_action(self, app); + g_string_append(self->block, "};\n"); + +} + +static void +_generate_applications(AppParserGenerator *self, AppModelContext *appmodel) +{ + appmodel_context_iter_applications(appmodel, _generate_application, self); +} + + +static void +_generate_framing(AppParserGenerator *self, AppModelContext *appmodel) +{ + g_string_append(self->block, + "\nchannel {\n" + " junction {\n"); + + _generate_applications(self, appmodel); + + g_string_append(self->block, " };\n"); + g_string_append(self->block, "}"); +} + +static void +_generate_empty_frame(AppParserGenerator *self) +{ + g_string_append(self->block, "\nchannel {}"); +} + +static gboolean +_parse_auto_parse_arg(AppParserGenerator *self, CfgArgs *args) +{ + const gchar *v = cfg_args_get(args, "auto-parse"); + + if (v) + self->is_parsing_enabled = cfg_process_yesno(v); + else + self->is_parsing_enabled = TRUE; + return TRUE; +} + +static gboolean +_parse_auto_parse_exclude_arg(AppParserGenerator *self, CfgArgs *args) +{ + const gchar *v = cfg_args_get(args, "auto-parse-exclude"); + if (!v) + return TRUE; + self->excluded_apps = g_strdup(v); + return TRUE; +} + +static gboolean +_parse_auto_parse_include_arg(AppParserGenerator *self, CfgArgs *args) +{ + const gchar *v = cfg_args_get(args, "auto-parse-include"); + if (!v) + return TRUE; + self->included_apps = g_strdup(v); + return TRUE; +} + +static gboolean +_parse_topic_arg(AppParserGenerator *self, CfgArgs *args) +{ + self->topic = cfg_args_get(args, "topic"); + if (!self->topic) + { + msg_error("app-parser() requires a topic() argument"); + return FALSE; + } + return TRUE; +} + +static gboolean +_parse_arguments(AppParserGenerator *self, CfgArgs *args) +{ + g_assert(args != NULL); + + if (!_parse_topic_arg(self, args)) + return FALSE; + if (!_parse_auto_parse_arg(self, args)) + return FALSE; + if (!_parse_auto_parse_exclude_arg(self, args)) + return FALSE; + if (!_parse_auto_parse_include_arg(self, args)) + return FALSE; + return TRUE; +} + +static gboolean +_generate(CfgBlockGenerator *s, GlobalConfig *cfg, CfgArgs *args, GString *result) +{ + AppParserGenerator *self = (AppParserGenerator *) s; + AppModelContext *appmodel = appmodel_get_context(cfg); + + if (!_parse_arguments(self, args)) + return FALSE; + + self->block = result; + if (self->is_parsing_enabled) + _generate_framing(self, appmodel); + else + _generate_empty_frame(self); + self->block = NULL; + + return TRUE; +} + +CfgBlockGenerator * +app_parser_generator_new(gint context, const gchar *name) +{ + AppParserGenerator *self = g_new0(AppParserGenerator, 1); + + cfg_block_generator_init_instance(&self->super, context, name); + self->super.generate = _generate; + return &self->super; +} diff -Nru syslog-ng-3.11.1/modules/appmodel/app-parser-generator.h syslog-ng-3.13.2/modules/appmodel/app-parser-generator.h --- syslog-ng-3.11.1/modules/appmodel/app-parser-generator.h 1970-01-01 00:00:00.000000000 +0000 +++ syslog-ng-3.13.2/modules/appmodel/app-parser-generator.h 2017-12-06 06:39:39.000000000 +0000 @@ -0,0 +1,32 @@ +/* + * Copyright (c) 2017 Balabit + * Copyright (c) 2017 Balazs Scheidler + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + * + * As an additional exemption you are allowed to compile & link against the + * OpenSSL libraries as published by the OpenSSL project. See the file + * COPYING for details. + * + */ + +#ifndef APPMODEL_APPPARSER_GENERATOR_H_INCLUDED +#define APPMODEL_APPPARSER_GENERATOR_H_INCLUDED + +#include "plugin.h" + +CfgBlockGenerator *app_parser_generator_new(gint context, const gchar *name); + +#endif diff -Nru syslog-ng-3.11.1/modules/appmodel/Makefile.am syslog-ng-3.13.2/modules/appmodel/Makefile.am --- syslog-ng-3.11.1/modules/appmodel/Makefile.am 1970-01-01 00:00:00.000000000 +0000 +++ syslog-ng-3.13.2/modules/appmodel/Makefile.am 2017-12-06 06:39:39.000000000 +0000 @@ -0,0 +1,42 @@ + +appmodel_sources = + +module_LTLIBRARIES += modules/appmodel/libappmodel.la +modules_appmodel_libappmodel_la_SOURCES = \ + modules/appmodel/appmodel.c \ + modules/appmodel/appmodel.h \ + modules/appmodel/appmodel-parser.c \ + modules/appmodel/appmodel-parser.h \ + modules/appmodel/appmodel-plugin.c \ + modules/appmodel/appmodel-context.c \ + modules/appmodel/appmodel-context.h \ + modules/appmodel/app-parser-generator.c \ + modules/appmodel/app-parser-generator.h \ + modules/appmodel/application.c \ + modules/appmodel/application.h \ + modules/appmodel/appmodel-grammar.y + +modules_appmodel_libappmodel_la_CPPFLAGS = \ + $(AM_CPPFLAGS) \ + -I$(top_srcdir)/modules/appmodel \ + -I$(top_builddir)/modules/appmodel +modules_appmodel_libappmodel_la_LIBADD = \ + $(MODULE_DEPS_LIBS) +modules_appmodel_libappmodel_la_LDFLAGS = \ + $(MODULE_LDFLAGS) +modules_appmodel_libappmodel_la_DEPENDENCIES = \ + $(MODULE_DEPS_LIBS) + +BUILT_SOURCES += \ + modules/appmodel/appmodel-grammar.y \ + modules/appmodel/appmodel-grammar.c \ + modules/appmodel/appmodel-grammar.h +EXTRA_DIST += \ + modules/appmodel/appmodel-grammar.ym + +modules/appmodel modules/appmodel/ mod-tags-parser: modules/appmodel/libappmodel.la +.PHONY: modules/appmodel/ mod-tags-parser + + + +include modules/appmodel/tests/Makefile.am diff -Nru syslog-ng-3.11.1/modules/appmodel/tests/Makefile.am syslog-ng-3.13.2/modules/appmodel/tests/Makefile.am --- syslog-ng-3.11.1/modules/appmodel/tests/Makefile.am 1970-01-01 00:00:00.000000000 +0000 +++ syslog-ng-3.13.2/modules/appmodel/tests/Makefile.am 2017-12-06 06:39:39.000000000 +0000 @@ -0,0 +1,52 @@ +if ENABLE_CRITERION + +modules_appmodel_tests_TESTS = \ + modules/appmodel/tests/test_appmodel \ + modules/appmodel/tests/test_appmodel_context \ + modules/appmodel/tests/test_app_parser_generator \ + modules/appmodel/tests/test_application + +check_PROGRAMS += \ + ${modules_appmodel_tests_TESTS} + +modules_appmodel_tests_test_appmodel_CFLAGS = \ + $(TEST_CFLAGS) -I$(top_srcdir)/modules/appmodel +modules_appmodel_tests_test_appmodel_LDADD = \ + $(TEST_LDADD) +modules_appmodel_tests_test_appmodel_LDFLAGS = \ + $(PREOPEN_SYSLOGFORMAT) \ + -dlpreopen $(top_builddir)/modules/appmodel/libappmodel.la +modules_appmodel_tests_test_appmodel_DEPENDENCIES = \ + $(top_builddir)/modules/appmodel/libappmodel.la + +modules_appmodel_tests_test_appmodel_context_CFLAGS = \ + $(TEST_CFLAGS) -I$(top_srcdir)/modules/appmodel +modules_appmodel_tests_test_appmodel_context_LDADD = \ + $(TEST_LDADD) +modules_appmodel_tests_test_appmodel_context_LDFLAGS = \ + $(PREOPEN_SYSLOGFORMAT) \ + -dlpreopen $(top_builddir)/modules/appmodel/libappmodel.la +modules_appmodel_tests_test_appmodel_context_DEPENDENCIES = \ + $(top_builddir)/modules/appmodel/libappmodel.la + +modules_appmodel_tests_test_app_parser_generator_CFLAGS = \ + $(TEST_CFLAGS) -I$(top_srcdir)/modules/appmodel +modules_appmodel_tests_test_app_parser_generator_LDADD = \ + $(TEST_LDADD) +modules_appmodel_tests_test_app_parser_generator_LDFLAGS = \ + $(PREOPEN_SYSLOGFORMAT) \ + -dlpreopen $(top_builddir)/modules/appmodel/libappmodel.la +modules_appmodel_tests_test_app_parser_generator_DEPENDENCIES = \ + $(top_builddir)/modules/appmodel/libappmodel.la + +modules_appmodel_tests_test_application_CFLAGS = \ + $(TEST_CFLAGS) -I$(top_srcdir)/modules/appmodel +modules_appmodel_tests_test_application_LDADD = \ + $(TEST_LDADD) +modules_appmodel_tests_test_application_LDFLAGS = \ + $(PREOPEN_SYSLOGFORMAT) \ + -dlpreopen $(top_builddir)/modules/appmodel/libappmodel.la +modules_appmodel_tests_test_application_DEPENDENCIES = \ + $(top_builddir)/modules/appmodel/libappmodel.la + +endif diff -Nru syslog-ng-3.11.1/modules/appmodel/tests/test_application.c syslog-ng-3.13.2/modules/appmodel/tests/test_application.c --- syslog-ng-3.11.1/modules/appmodel/tests/test_application.c 1970-01-01 00:00:00.000000000 +0000 +++ syslog-ng-3.13.2/modules/appmodel/tests/test_application.c 2017-12-06 06:39:39.000000000 +0000 @@ -0,0 +1,63 @@ +/* + * Copyright (c) 2017 Balabit + * Copyright (c) 2017 Balazs Scheidler + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + * + * As an additional exemption you are allowed to compile & link against the + * OpenSSL libraries as published by the OpenSSL project. See the file + * COPYING for details. + * + */ +#include +#include "application.h" + +Test(application, empty_application_can_be_created_and_freed) +{ + Application *app; + + app = application_new("foobar", "*"); + application_free(app); +} + +Test(application, filter_can_be_set_and_queried) +{ + Application *app; + const gchar *filter_expr = "'1' eq '1'"; + const gchar *filter_expr2 = "'2' eq '2'"; + + app = application_new("foobar", "*"); + application_set_filter(app, filter_expr); + cr_assert_str_eq(app->filter_expr, filter_expr); + + application_set_filter(app, filter_expr2); + cr_assert_str_eq(app->filter_expr, filter_expr2); + application_free(app); +} + +Test(application, parser_can_be_set_and_queried) +{ + Application *app; + const gchar *parser_expr = "kv-parser();"; + const gchar *parser_expr2 = "csv-parser();"; + + app = application_new("foobar", "*"); + application_set_parser(app, parser_expr); + cr_assert_str_eq(app->parser_expr, parser_expr); + + application_set_parser(app, parser_expr2); + cr_assert_str_eq(app->parser_expr, parser_expr2); + application_free(app); +} diff -Nru syslog-ng-3.11.1/modules/appmodel/tests/test_appmodel.c syslog-ng-3.13.2/modules/appmodel/tests/test_appmodel.c --- syslog-ng-3.11.1/modules/appmodel/tests/test_appmodel.c 1970-01-01 00:00:00.000000000 +0000 +++ syslog-ng-3.13.2/modules/appmodel/tests/test_appmodel.c 2017-12-06 06:39:39.000000000 +0000 @@ -0,0 +1,116 @@ +/* + * Copyright (c) 2017 Balabit + * Copyright (c) 2017 Balazs Scheidler + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + * + * As an additional exemption you are allowed to compile & link against the + * OpenSSL libraries as published by the OpenSSL project. See the file + * COPYING for details. + * + */ + +#include +#include "appmodel.h" +#include "application.h" +#include "plugin.h" +#include "apphook.h" +#include "cfg-grammar.h" +#include "config_parse_lib.h" + +Application * +_parse_application(const char *appmodel, const gchar *name, const gchar *topic) +{ + AppModelContext *ac; + + cfg_load_module(configuration, "appmodel"); + cr_assert(parse_config(appmodel, LL_CONTEXT_ROOT, NULL, NULL), + "Parsing the given configuration failed: %s", appmodel); + ac = appmodel_get_context(configuration); + return appmodel_context_lookup_application(ac, name, topic); +} + +Test(appmodel, empty_application_can_be_parsed_properly) +{ + Application *app; + + app = _parse_application("application foobar[*] {};", "foobar", "*"); + cr_assert(app != NULL); + cr_assert_str_eq(app->name, "foobar"); + cr_assert_str_eq(app->topic, "*"); +} + +Test(appmodel, name_is_parsed_into_name_member) +{ + Application *app; + + app = _parse_application("application name[*] {};", "name", "*"); + cr_assert(app != NULL); +} + +Test(appmodel, topic_in_brackets_is_parsed_into_topic) +{ + Application *app; + + app = _parse_application("application name[port514] {};", "name", "port514"); + cr_assert(app != NULL); + cr_assert_str_eq(app->topic, "port514"); +} + +Test(appmodel, filter_expressions_can_be_specified_with_a_filter_keyword) +{ + Application *app; + + app = _parse_application( + "application name[port514] {" + " filter { program(\"kernel\"); };" + " parser { kv-parser(); };" + "};", + "name", "port514"); + cr_assert(app != NULL); + cr_assert_str_eq(app->topic, "port514"); + cr_assert_str_eq(app->filter_expr, " program(\"kernel\"); "); +} + +Test(appmodel, parser_expressions_can_be_specified_with_a_parser_keyword) +{ + Application *app; + + app = _parse_application( + "application name[port514] {" + " parser { kv-parser(); };" + " filter { program(\"kernel\"); };" + "};", + "name", "port514"); + cr_assert(app != NULL); + cr_assert_str_eq(app->topic, "port514"); + cr_assert_str_eq(app->parser_expr, " kv-parser(); "); +} + +static void +setup(void) +{ + app_startup(); + configuration = cfg_new_snippet(); +} + +void +teardown(void) +{ + cfg_free(configuration); + app_shutdown(); +} + +TestSuite(appmodel, .init = setup, .fini = teardown); diff -Nru syslog-ng-3.11.1/modules/appmodel/tests/test_appmodel_context.c syslog-ng-3.13.2/modules/appmodel/tests/test_appmodel_context.c --- syslog-ng-3.11.1/modules/appmodel/tests/test_appmodel_context.c 1970-01-01 00:00:00.000000000 +0000 +++ syslog-ng-3.13.2/modules/appmodel/tests/test_appmodel_context.c 2017-12-06 06:39:39.000000000 +0000 @@ -0,0 +1,86 @@ +/* + * Copyright (c) 2017 Balabit + * Copyright (c) 2017 Balazs Scheidler + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + * + * As an additional exemption you are allowed to compile & link against the + * OpenSSL libraries as published by the OpenSSL project. See the file + * COPYING for details. + * + */ +#include +#include "appmodel.h" + +static AppModelContext *ac; + +static void +startup(void) +{ + ac = appmodel_context_new(); +} + +static void +teardown(void) +{ + appmodel_context_free(ac); + ac = NULL; +} + +Test(appmodel_context, register_application_makes_the_app_available) +{ + appmodel_context_register_application(ac, application_new("foobar", "*")); + appmodel_context_lookup_application(ac, "foobar", "*"); +} + +static void +_foreach_app(Application *app, Application *base_app, gpointer user_data) +{ + GString *result = (GString *) user_data; + + g_string_append(result, app->name); +} + +Test(appmodel_context, iter_applications_enumerates_apps_without_asterisk) +{ + GString *result = g_string_sized_new(128); + + appmodel_context_register_application(ac, application_new("foo", "*")); + appmodel_context_register_application(ac, application_new("foo", "port514")); + appmodel_context_register_application(ac, application_new("bar", "*")); + appmodel_context_register_application(ac, application_new("bar", "port514")); + appmodel_context_register_application(ac, application_new("baz", "*")); + appmodel_context_register_application(ac, application_new("baz", "port514")); + appmodel_context_iter_applications(ac, _foreach_app, result); + cr_assert_str_eq(result->str, "foobarbaz"); + g_string_free(result, TRUE); +} + +Test(appmodel_context, iter_applications_enumerates_apps_in_the_order_of_registration) +{ + GString *result = g_string_sized_new(128); + + appmodel_context_register_application(ac, application_new("baz", "*")); + appmodel_context_register_application(ac, application_new("baz", "port514")); + appmodel_context_register_application(ac, application_new("bar", "*")); + appmodel_context_register_application(ac, application_new("bar", "port514")); + appmodel_context_register_application(ac, application_new("foo", "*")); + appmodel_context_register_application(ac, application_new("foo", "port514")); + appmodel_context_iter_applications(ac, _foreach_app, result); + cr_assert_str_eq(result->str, "bazbarfoo"); + g_string_free(result, TRUE); +} + +TestSuite(appmodel_context, .init = startup, .fini = teardown); diff -Nru syslog-ng-3.11.1/modules/appmodel/tests/test_app_parser_generator.c syslog-ng-3.13.2/modules/appmodel/tests/test_app_parser_generator.c --- syslog-ng-3.11.1/modules/appmodel/tests/test_app_parser_generator.c 1970-01-01 00:00:00.000000000 +0000 +++ syslog-ng-3.13.2/modules/appmodel/tests/test_app_parser_generator.c 2017-12-06 06:39:39.000000000 +0000 @@ -0,0 +1,264 @@ +/* + * Copyright (c) 2017 Balabit + * Copyright (c) 2017 Balazs Scheidler + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + * + * As an additional exemption you are allowed to compile & link against the + * OpenSSL libraries as published by the OpenSSL project. See the file + * COPYING for details. + * + */ + +#include +#include "app-parser-generator.h" +#include "apphook.h" +#include "plugin-types.h" + +#include "config_parse_lib.h" + +static CfgBlockGenerator *app_parser; +static GString *result; + +void +_register_application(const char *appmodel) +{ + cr_assert(parse_config(appmodel, LL_CONTEXT_ROOT, NULL, NULL), + "Parsing the given configuration failed: %s", appmodel); +} + +void +_register_sample_application(const gchar *name, const gchar *topic) +{ + gchar *app; + + app = g_strdup_printf("application %s[%s] {\n" + " filter { program('%s'); };\n" + " parser { kv-parser(prefix('%s.')); };\n" + "};", name, topic, name, name); + _register_application(app); + g_free(app); +} + +static CfgBlockGenerator * +_construct_app_parser(void) +{ + return app_parser_generator_new(LL_CONTEXT_PARSER, "app-parser"); +} + +static CfgArgs * +_build_cfg_args(const gchar *key, const gchar *value, ...) +{ + CfgArgs *args = cfg_args_new(); + va_list va; + + va_start(va, value); + while (key) + { + cfg_args_set(args, key, value); + key = va_arg(va, gchar *); + if (!key) + break; + value = va_arg(va, gchar *); + } + va_end(va); + return args; +} + +static void +_app_parser_generate_with_args(const gchar *topic, CfgArgs *args) +{ + cfg_args_set(args, "topic", topic); + cfg_block_generator_generate(app_parser, configuration, args, result); + cfg_args_unref(args); +} + +static void +_app_parser_generate(const gchar *topic) +{ + _app_parser_generate_with_args(topic, cfg_args_new()); +} + +static void +_assert_config_is_valid(const gchar *topic, const gchar *varargs) +{ + const gchar *config_fmt = "" + "parser p_test {\n" + " app-parser(topic(\"%s\") %s);\n" + "};\n"; + gchar *config; + + config = g_strdup_printf(config_fmt, topic, varargs ? : ""); + cr_assert(parse_config(config, LL_CONTEXT_ROOT, NULL, NULL), + "Parsing the given configuration failed: %s", config); + g_free(config); +} + +static void +_assert_snippet_is_present(const gchar *snippet) +{ + cr_assert(strstr(result->str, snippet), + "Can't find config snippet in generated output: %s, config: >>>%s<<<", + snippet, result->str); +} + +static void +_assert_snippet_is_not_present(const gchar *snippet) +{ + cr_assert(strstr(result->str, snippet) == NULL, + "Could find config snippet which shouldn't be there in generated output: %s, config: >>>%s<<<", + snippet, result->str); +} + +static void +_assert_application_is_present(const gchar *application) +{ + const gchar *settag_fmt = "set-tag('.app.%s');"; + gchar *settag_snippet = g_strdup_printf(settag_fmt, application); + + cr_assert(strstr(result->str, settag_snippet), + "Can't find set-tag() invocation for this application: %s, snippet: %s, config: >>>%s<<<", + application, settag_snippet, result->str); + g_free(settag_snippet); +} + +static void +_assert_parser_framing_is_present(void) +{ + cr_assert(g_str_has_prefix(result->str, "\nchannel"), "Cannot find app-parser() framing (prefix) >>>%s<<<", + result->str); + cr_assert(g_str_has_suffix(result->str, "};\n}"), "Cannot find app-parser() framing (suffix): >>>%s<<<", result->str); +} + +static void +startup(void) +{ + app_startup(); + configuration = cfg_new_snippet(); + cfg_load_module(configuration, "appmodel"); + app_parser = _construct_app_parser(); + result = g_string_new(""); +} + +static void +teardown(void) +{ + g_string_free(result, TRUE); + app_shutdown(); +} + +Test(app_parser_generator, app_parser_with_no_apps_registered_generates_empty_framing) +{ + _app_parser_generate("port514"); + _assert_parser_framing_is_present(); + _assert_config_is_valid("port514", NULL); +} + +Test(app_parser_generator, app_parser_generates_references_to_apps) +{ + _register_sample_application("foo", "port514"); + _register_sample_application("bar", "port514"); + + _app_parser_generate("port514"); + _assert_parser_framing_is_present(); + _assert_application_is_present("foo"); + _assert_application_is_present("bar"); + _assert_config_is_valid("port514", NULL); +} + +Test(app_parser_generator, app_parser_uses_filter_or_parser_from_base_topics) +{ + _register_application("application foo[port514] {\n" + "};"); + + _register_sample_application("foo", "*"); + + _app_parser_generate("port514"); + _assert_parser_framing_is_present(); + _assert_application_is_present("foo"); + _assert_snippet_is_present("program('foo')"); + _assert_snippet_is_present("kv-parser(prefix('foo.'))"); + _assert_config_is_valid("port514", NULL); +} + +Test(app_parser_generator, app_parser_base_topics_are_skipped) +{ + _register_sample_application("foo", "*"); + _register_sample_application("bar", "*"); + + _app_parser_generate("port514"); + _assert_parser_framing_is_present(); + _assert_snippet_is_not_present("program('foo')"); + _assert_snippet_is_not_present("program('bar')"); + _assert_config_is_valid("port514", NULL); +} + +Test(app_parser_generator, app_parser_is_disabled_if_auto_parse_is_set_to_no) +{ + _register_sample_application("foo", "port514"); + _register_sample_application("bar", "port514"); + + _app_parser_generate_with_args("port514", _build_cfg_args("auto-parse", "no", NULL)); + cr_assert_str_eq(result->str, "\nchannel {}", "result is expected to be an empty channel, but it is %s", result->str); + + _app_parser_generate_with_args("port514", _build_cfg_args("auto-parse", "yes", NULL)); + _assert_parser_framing_is_present(); + _assert_snippet_is_present("program('foo')"); + _assert_snippet_is_present("program('bar')"); + _assert_config_is_valid("port514", "auto-parse(yes)"); +} + +Test(app_parser_generator, app_parser_excludes_apps) +{ + _register_sample_application("foo", "port514"); + _register_sample_application("bar", "port514"); + + _app_parser_generate_with_args("port514", _build_cfg_args("auto-parse-exclude", "foo", NULL)); + _assert_parser_framing_is_present(); + _assert_snippet_is_not_present("program('foo')"); + _assert_snippet_is_present("program('bar')"); +} + +Test(app_parser_generator, app_parser_includes_apps) +{ + _register_sample_application("foo", "port514"); + _register_sample_application("bar", "port514"); + _register_sample_application("baz", "port514"); + + _app_parser_generate_with_args("port514", _build_cfg_args("auto-parse-include", "foo", NULL)); + _assert_parser_framing_is_present(); + _assert_snippet_is_present("program('foo')"); + _assert_snippet_is_not_present("program('bar')"); + _assert_snippet_is_not_present("program('baz')"); +} + +Test(app_parser_generator, app_parser_includes_and_excludes_apps) +{ + _register_sample_application("foo", "port514"); + _register_sample_application("bar", "port514"); + _register_sample_application("baz", "port514"); + + _app_parser_generate_with_args("port514", + _build_cfg_args("auto-parse-include", "foo,bar", + "auto-parse-exclude", "bar", + NULL)); + _assert_parser_framing_is_present(); + _assert_snippet_is_present("program('foo')"); + _assert_snippet_is_not_present("program('bar')"); + _assert_snippet_is_not_present("program('baz')"); +} + + +TestSuite(app_parser_generator, .init = startup, .fini = teardown); diff -Nru syslog-ng-3.11.1/modules/basicfuncs/basic-funcs.c syslog-ng-3.13.2/modules/basicfuncs/basic-funcs.c --- syslog-ng-3.11.1/modules/basicfuncs/basic-funcs.c 2017-07-31 09:05:32.000000000 +0000 +++ syslog-ng-3.13.2/modules/basicfuncs/basic-funcs.c 2017-12-06 06:39:39.000000000 +0000 @@ -70,6 +70,7 @@ TEMPLATE_FUNCTION_PLUGIN(tf_uppercase, "uppercase"), TEMPLATE_FUNCTION_PLUGIN(tf_replace_delimiter, "replace-delimiter"), TEMPLATE_FUNCTION_PLUGIN(tf_string_padding, "padding"), + TEMPLATE_FUNCTION_PLUGIN(tf_binary, "binary"), /* fname-funcs */ TEMPLATE_FUNCTION_PLUGIN(tf_dirname, "dirname"), @@ -105,9 +106,9 @@ }; gboolean -basicfuncs_module_init(GlobalConfig *cfg, CfgArgs *args) +basicfuncs_module_init(PluginContext *context, CfgArgs *args) { - plugin_register(cfg, basicfuncs_plugins, G_N_ELEMENTS(basicfuncs_plugins)); + plugin_register(context, basicfuncs_plugins, G_N_ELEMENTS(basicfuncs_plugins)); return TRUE; } diff -Nru syslog-ng-3.11.1/modules/basicfuncs/cond-funcs.c syslog-ng-3.13.2/modules/basicfuncs/cond-funcs.c --- syslog-ng-3.11.1/modules/basicfuncs/cond-funcs.c 2017-07-31 09:05:32.000000000 +0000 +++ syslog-ng-3.13.2/modules/basicfuncs/cond-funcs.c 2017-12-06 06:39:39.000000000 +0000 @@ -37,10 +37,11 @@ g_return_val_if_fail(error == NULL || *error == NULL, FALSE); - lexer = cfg_lexer_new_buffer(argv[1], strlen(argv[1])); + lexer = cfg_lexer_new_buffer(parent->cfg, argv[1], strlen(argv[1])); if (!cfg_run_parser(parent->cfg, lexer, &filter_expr_parser, (gpointer *) &state->filter, NULL)) { - g_set_error(error, LOG_TEMPLATE_ERROR, LOG_TEMPLATE_ERROR_COMPILE, "Error parsing conditional filter expression"); + g_set_error(error, LOG_TEMPLATE_ERROR, LOG_TEMPLATE_ERROR_COMPILE, + "$(%s) Error parsing conditional filter expression", argv[0]); return FALSE; } memmove(&argv[1], &argv[2], sizeof(argv[0]) * (argc - 2)); diff -Nru syslog-ng-3.11.1/modules/basicfuncs/str-funcs.c syslog-ng-3.13.2/modules/basicfuncs/str-funcs.c --- syslog-ng-3.11.1/modules/basicfuncs/str-funcs.c 2017-07-31 09:05:32.000000000 +0000 +++ syslog-ng-3.13.2/modules/basicfuncs/str-funcs.c 2017-12-06 06:39:39.000000000 +0000 @@ -433,3 +433,75 @@ } TEMPLATE_FUNCTION_SIMPLE(tf_string_padding); + +typedef struct _TFBinaryState +{ + TFSimpleFuncState super; + GString *octets; +} TFBinaryState; + +static void +tf_binary_call(LogTemplateFunction *self, gpointer s, const LogTemplateInvokeArgs *args, GString *result) +{ + TFBinaryState *state = (TFBinaryState *) s; + + g_string_append_len(result, state->octets->str, state->octets->len); +} + +static gboolean +tf_binary_prepare(LogTemplateFunction *self, gpointer s, LogTemplate *parent, gint argc, gchar *argv[], GError **error) +{ + TFBinaryState *state = (TFBinaryState *) s; + GString *octets = g_string_new(""); + + if (argc < 2) + { + g_set_error(error, LOG_TEMPLATE_ERROR, LOG_TEMPLATE_ERROR_COMPILE, + "$(binary) Incorrect parameters, usage $(binary ...)"); + goto error; + } + + for (gint i = 1; i < argc; i++) + { + gint64 number; + + gchar *token = argv[i]; + if (!parse_number(token, &number)) + { + g_set_error(error, LOG_TEMPLATE_ERROR, LOG_TEMPLATE_ERROR_COMPILE, + "$(binary) template function requires list of dec/hex/oct numbers as arguments, unable to parse %s as a number", + token); + goto error; + } + if (number > 0xFF) + { + g_set_error(error, LOG_TEMPLATE_ERROR, LOG_TEMPLATE_ERROR_COMPILE, + "$(binary) template function only supports 8 bit values as characters, %" G_GUINT64_FORMAT " is above 255", number); + goto error; + } + g_string_append_c(octets, (gchar) number); + } + + if (!tf_simple_func_prepare(self, state, parent, argc, argv, error)) + { + goto error; + } + + state->octets = octets; + return TRUE; +error: + g_string_free(octets, TRUE); + return FALSE; +} + +static void +tf_binary_free_state(gpointer s) +{ + TFBinaryState *state = (TFBinaryState *) s; + + g_string_free(state->octets, TRUE); + tf_simple_func_free_state(&state->super); +} + +TEMPLATE_FUNCTION(TFBinaryState, tf_binary, tf_binary_prepare, tf_simple_func_eval, tf_binary_call, + tf_binary_free_state, NULL); diff -Nru syslog-ng-3.11.1/modules/basicfuncs/tests/test_basicfuncs.c syslog-ng-3.13.2/modules/basicfuncs/tests/test_basicfuncs.c --- syslog-ng-3.11.1/modules/basicfuncs/tests/test_basicfuncs.c 2017-07-31 09:05:32.000000000 +0000 +++ syslog-ng-3.13.2/modules/basicfuncs/tests/test_basicfuncs.c 2017-12-06 06:39:39.000000000 +0000 @@ -153,6 +153,14 @@ assert_template_format("$(padding foo 10)", " foo"); assert_template_format("$(padding foo 10 x)", "xxxxxxxfoo"); assert_template_format("$(padding foo 10 abc)", "abcabcafoo"); + + assert_template_failure("$(binary)", "Incorrect parameters"); + assert_template_failure("$(binary abc)", "unable to parse abc"); + assert_template_failure("$(binary 256)", "256 is above 255"); + assert_template_format("$(binary 1)", "\1"); + assert_template_format("$(binary 1 0x1)", "\1\1"); + assert_template_format("$(binary 0xFF 255 0377)", "\xFF\xFF\xFF"); + assert_template_format_with_len("$(binary 0xFF 0x00 0x40)", "\xFF\000@", 3); } void @@ -382,7 +390,7 @@ app_startup(); init_template_tests(); add_dummy_template_to_configuration(); - plugin_load_module("basicfuncs", configuration, NULL); + cfg_load_module(configuration, "basicfuncs"); test_cond_funcs(); test_str_funcs(); diff -Nru syslog-ng-3.11.1/modules/basicfuncs/tf-template.c syslog-ng-3.13.2/modules/basicfuncs/tf-template.c --- syslog-ng-3.11.1/modules/basicfuncs/tf-template.c 2017-07-31 09:05:32.000000000 +0000 +++ syslog-ng-3.13.2/modules/basicfuncs/tf-template.c 2017-12-06 06:39:39.000000000 +0000 @@ -36,7 +36,8 @@ state->invoked_template = cfg_tree_lookup_template(&cfg->tree, function_name); if (!state->invoked_template) { - g_set_error(error, LOG_TEMPLATE_ERROR, LOG_TEMPLATE_ERROR_COMPILE, "Unknown template function or template \"%s\"", + g_set_error(error, LOG_TEMPLATE_ERROR, LOG_TEMPLATE_ERROR_COMPILE, + "$(template) Unknown template function or template \"%s\"", function_name); return FALSE; } diff -Nru syslog-ng-3.11.1/modules/cef/cef-plugin.c syslog-ng-3.13.2/modules/cef/cef-plugin.c --- syslog-ng-3.11.1/modules/cef/cef-plugin.c 2017-07-31 09:05:32.000000000 +0000 +++ syslog-ng-3.13.2/modules/cef/cef-plugin.c 2017-12-06 06:39:39.000000000 +0000 @@ -29,9 +29,9 @@ }; gboolean -cef_module_init(GlobalConfig *cfg, CfgArgs *args) +cef_module_init(PluginContext *context, CfgArgs *args) { - plugin_register(cfg, cef_plugins, G_N_ELEMENTS(cef_plugins)); + plugin_register(context, cef_plugins, G_N_ELEMENTS(cef_plugins)); return TRUE; } diff -Nru syslog-ng-3.11.1/modules/cef/format-cef-extension.c syslog-ng-3.13.2/modules/cef/format-cef-extension.c --- syslog-ng-3.11.1/modules/cef/format-cef-extension.c 2017-07-31 09:05:32.000000000 +0000 +++ syslog-ng-3.13.2/modules/cef/format-cef-extension.c 2017-12-06 06:39:39.000000000 +0000 @@ -41,7 +41,7 @@ { TFCefState *state = (TFCefState *)s; - state->vp = value_pairs_new_from_cmdline(parent->cfg, argc, argv, error); + state->vp = value_pairs_new_from_cmdline(parent->cfg, &argc, &argv, FALSE, error); if (!state->vp) return FALSE; diff -Nru syslog-ng-3.11.1/modules/cef/tests/test-format-cef-extension.c syslog-ng-3.13.2/modules/cef/tests/test-format-cef-extension.c --- syslog-ng-3.11.1/modules/cef/tests/test-format-cef-extension.c 2017-07-31 09:05:32.000000000 +0000 +++ syslog-ng-3.13.2/modules/cef/tests/test-format-cef-extension.c 2017-12-06 06:39:39.000000000 +0000 @@ -76,7 +76,7 @@ } static void -_test_null_in_value() +_test_null_in_value(void) { LogMessage *msg = create_empty_message(); @@ -221,7 +221,7 @@ putenv("TZ=UTC"); tzset(); init_template_tests(); - plugin_load_module("cef", configuration, NULL); + cfg_load_module(configuration, "cef"); _test_filter(); _test_multiple_properties_with_space(); diff -Nru syslog-ng-3.11.1/modules/CMakeLists.txt syslog-ng-3.13.2/modules/CMakeLists.txt --- syslog-ng-3.11.1/modules/CMakeLists.txt 2017-07-31 09:05:32.000000000 +0000 +++ syslog-ng-3.13.2/modules/CMakeLists.txt 2017-12-06 06:39:39.000000000 +0000 @@ -32,3 +32,5 @@ add_subdirectory(java) add_subdirectory(java-modules) add_subdirectory(http) +add_subdirectory(tagsparser) +add_subdirectory(xml) diff -Nru syslog-ng-3.11.1/modules/confgen/confgen-plugin.c syslog-ng-3.13.2/modules/confgen/confgen-plugin.c --- syslog-ng-3.11.1/modules/confgen/confgen-plugin.c 2017-07-31 09:05:32.000000000 +0000 +++ syslog-ng-3.13.2/modules/confgen/confgen-plugin.c 2017-12-06 06:39:39.000000000 +0000 @@ -23,67 +23,105 @@ #include "confgen.h" #include "cfg.h" -#include "cfg-lexer.h" +#include "cfg-block-generator.h" #include "messages.h" #include "plugin.h" -#include "plugin-types.h" #include #include +#include + + +static void +confgen_set_args_as_env(gpointer k, gpointer v, gpointer user_data) +{ + gchar buf[1024]; + g_snprintf(buf, sizeof(buf), "confgen_%s", (gchar *)k); + setenv(buf, (gchar *)v, 1); +} + +static void +confgen_unset_args_from_env(gpointer k, gpointer v, gpointer user_data) +{ + gchar buf[1024]; + g_snprintf(buf, sizeof(buf), "confgen_%s", (gchar *)k); + unsetenv(buf); +} + +typedef struct _ConfgenExec +{ + CfgBlockGenerator super; + gchar *exec; +} ConfgenExec; gboolean -confgen_generate(CfgLexer *lexer, gint type, const gchar *name, CfgArgs *args, gpointer user_data) +confgen_exec_generate(CfgBlockGenerator *s, GlobalConfig *cfg, CfgArgs *args, GString *result) { - gchar *value; - gsize value_len = 0; + ConfgenExec *self = (ConfgenExec *) s; FILE *out; - gchar *exec = (gchar *) user_data; gsize res; gchar buf[256]; - gboolean result; - g_snprintf(buf, sizeof(buf), "%s confgen %s", cfg_lexer_lookup_context_name_by_type(type), name); - if (!cfg_args_validate(args, NULL, buf)) - { - msg_error("confgen: confgen invocations do not process arguments, but your argument list is not empty", - evt_tag_str("context", cfg_lexer_lookup_context_name_by_type(type)), - evt_tag_str("block", name)); - return FALSE; - } + g_snprintf(buf, sizeof(buf), "%s confgen %s", cfg_lexer_lookup_context_name_by_type(self->super.context), + self->super.name); + + cfg_args_foreach(args, confgen_set_args_as_env, NULL); + out = popen(self->exec, "r"); + cfg_args_foreach(args, confgen_unset_args_from_env, NULL); - out = popen((gchar *) user_data, "r"); if (!out) { msg_error("confgen: Error executing generator program", - evt_tag_str("context", cfg_lexer_lookup_context_name_by_type(type)), - evt_tag_str("block", name), - evt_tag_str("exec", exec), + evt_tag_str("context", cfg_lexer_lookup_context_name_by_type(self->super.context)), + evt_tag_str("block", self->super.name), + evt_tag_str("exec", self->exec), evt_tag_errno("error", errno)); return FALSE; } - value = g_malloc(1024); - while ((res = fread(value + value_len, 1, 1024, out)) > 0) + g_string_set_size(result, 1024); + while ((res = fread(result->str + result->len, 1, 1024, out)) > 0) { - value_len += res; - value = g_realloc(value, value_len + 1024); + result->len += res; + g_string_set_size(result, result->len + 1024); } res = pclose(out); if (res != 0) { msg_error("confgen: Generator program returned with non-zero exit code", - evt_tag_str("block", name), - evt_tag_str("exec", exec), + evt_tag_str("context", cfg_lexer_lookup_context_name_by_type(self->super.context)), + evt_tag_str("block", self->super.name), + evt_tag_str("exec", self->exec), evt_tag_int("rc", res)); - g_free(value); return FALSE; } - result = cfg_lexer_include_buffer(lexer, buf, value, value_len); - g_free(value); - return result; + msg_debug("confgen: output from the executed program to be included is", + evt_tag_printf("block", "%.*s", (gint) result->len, result->str)); + return TRUE; +} + +static void +confgen_exec_free(CfgBlockGenerator *s) +{ + ConfgenExec *self = (ConfgenExec *) s; + + g_free(self->exec); + cfg_block_generator_free_instance(s); +} + +static CfgBlockGenerator * +confgen_exec_new(gint context, const gchar *name, const gchar *exec) +{ + ConfgenExec *self = g_new0(ConfgenExec, 1); + + cfg_block_generator_init_instance(&self->super, context, name); + self->super.generate = confgen_exec_generate; + self->super.free_fn = confgen_exec_free; + self->exec = g_strdup(exec); + return &self->super; } gboolean -confgen_module_init(GlobalConfig *cfg, CfgArgs *args) +confgen_module_init(PluginContext *plugin_context, CfgArgs *args) { const gchar *name, *context, *exec; @@ -105,8 +143,8 @@ msg_error("confgen: exec argument expected"); return FALSE; } - cfg_lexer_register_block_generator(cfg->lexer, cfg_lexer_lookup_context_type_by_name(context), name, confgen_generate, - g_strdup(exec), g_free); + cfg_lexer_register_generator_plugin(plugin_context, confgen_exec_new(cfg_lexer_lookup_context_type_by_name(context), + name, exec)); return TRUE; } diff -Nru syslog-ng-3.11.1/modules/cryptofuncs/cryptofuncs.c syslog-ng-3.13.2/modules/cryptofuncs/cryptofuncs.c --- syslog-ng-3.11.1/modules/cryptofuncs/cryptofuncs.c 2017-07-31 09:05:32.000000000 +0000 +++ syslog-ng-3.13.2/modules/cryptofuncs/cryptofuncs.c 2017-12-06 06:39:39.000000000 +0000 @@ -168,9 +168,9 @@ }; gboolean -cryptofuncs_module_init(GlobalConfig *cfg, CfgArgs *args) +cryptofuncs_module_init(PluginContext *context, CfgArgs *args) { - plugin_register(cfg, cryptofuncs_plugins, G_N_ELEMENTS(cryptofuncs_plugins)); + plugin_register(context, cryptofuncs_plugins, G_N_ELEMENTS(cryptofuncs_plugins)); return TRUE; } diff -Nru syslog-ng-3.11.1/modules/cryptofuncs/tests/test_cryptofuncs.c syslog-ng-3.13.2/modules/cryptofuncs/tests/test_cryptofuncs.c --- syslog-ng-3.11.1/modules/cryptofuncs/tests/test_cryptofuncs.c 2017-07-31 09:05:32.000000000 +0000 +++ syslog-ng-3.13.2/modules/cryptofuncs/tests/test_cryptofuncs.c 2017-12-06 06:39:39.000000000 +0000 @@ -23,7 +23,7 @@ #include "template_lib.h" #include "apphook.h" -#include "plugin.h" +#include "cfg.h" void test_hash(void) @@ -55,7 +55,7 @@ { app_startup(); init_template_tests(); - plugin_load_module("cryptofuncs", configuration, NULL); + cfg_load_module(configuration, "cryptofuncs"); test_hash(); diff -Nru syslog-ng-3.11.1/modules/csvparser/csvparser-parser.h syslog-ng-3.13.2/modules/csvparser/csvparser-parser.h --- syslog-ng-3.11.1/modules/csvparser/csvparser-parser.h 2017-07-31 09:05:32.000000000 +0000 +++ syslog-ng-3.13.2/modules/csvparser/csvparser-parser.h 2017-12-06 06:39:39.000000000 +0000 @@ -25,7 +25,6 @@ #define CSVPARSER_PARSER_H_INCLUDED #include "cfg-parser.h" -#include "cfg-lexer.h" #include "parser/parser-expr.h" extern CfgParser csvparser_parser; diff -Nru syslog-ng-3.11.1/modules/csvparser/csvparser-plugin.c syslog-ng-3.13.2/modules/csvparser/csvparser-plugin.c --- syslog-ng-3.11.1/modules/csvparser/csvparser-plugin.c 2017-07-31 09:05:32.000000000 +0000 +++ syslog-ng-3.13.2/modules/csvparser/csvparser-plugin.c 2017-12-06 06:39:39.000000000 +0000 @@ -38,9 +38,9 @@ }; gboolean -csvparser_module_init(GlobalConfig *cfg, CfgArgs *args) +csvparser_module_init(PluginContext *context, CfgArgs *args) { - plugin_register(cfg, csvparser_plugins, G_N_ELEMENTS(csvparser_plugins)); + plugin_register(context, csvparser_plugins, G_N_ELEMENTS(csvparser_plugins)); return TRUE; } diff -Nru syslog-ng-3.11.1/modules/csvparser/tests/test_csvparser.c syslog-ng-3.13.2/modules/csvparser/tests/test_csvparser.c --- syslog-ng-3.11.1/modules/csvparser/tests/test_csvparser.c 2017-07-31 09:05:32.000000000 +0000 +++ syslog-ng-3.13.2/modules/csvparser/tests/test_csvparser.c 2017-12-06 06:39:39.000000000 +0000 @@ -176,8 +176,8 @@ putenv("TZ=MET-1METDST"); tzset(); - configuration = cfg_new_snippet(0x0302); - plugin_load_module("syslogformat", configuration, NULL); + configuration = cfg_new_snippet(); + cfg_load_module(configuration, "syslogformat"); msg_format_options_defaults(&parse_options); msg_format_options_init(&parse_options, configuration); diff -Nru syslog-ng-3.11.1/modules/csvparser/tests/test_csvparser_statistics.c syslog-ng-3.13.2/modules/csvparser/tests/test_csvparser_statistics.c --- syslog-ng-3.11.1/modules/csvparser/tests/test_csvparser_statistics.c 2017-07-31 09:05:32.000000000 +0000 +++ syslog-ng-3.13.2/modules/csvparser/tests/test_csvparser_statistics.c 2017-12-06 06:39:39.000000000 +0000 @@ -74,11 +74,11 @@ Test(test_filters_statistics, filter_stastistics) { app_startup(); - configuration = cfg_new_snippet(VERSION_VALUE); + configuration = cfg_new_snippet(); configuration->stats_options.level = 1; cr_assert(cfg_init(configuration)); - plugin_load_module("syslogformat", configuration, NULL); + cfg_load_module(configuration, "syslogformat"); msg_format_options_defaults(&parse_options); msg_format_options_init(&parse_options, configuration); diff -Nru syslog-ng-3.11.1/modules/date/date-parser-parser.h syslog-ng-3.13.2/modules/date/date-parser-parser.h --- syslog-ng-3.11.1/modules/date/date-parser-parser.h 2017-07-31 09:05:32.000000000 +0000 +++ syslog-ng-3.13.2/modules/date/date-parser-parser.h 2017-12-06 06:39:39.000000000 +0000 @@ -26,7 +26,6 @@ #include "date-parser.h" #include "cfg-parser.h" -#include "cfg-lexer.h" extern CfgParser date_parser; diff -Nru syslog-ng-3.11.1/modules/date/date-plugin.c syslog-ng-3.13.2/modules/date/date-plugin.c --- syslog-ng-3.11.1/modules/date/date-plugin.c 2017-07-31 09:05:32.000000000 +0000 +++ syslog-ng-3.13.2/modules/date/date-plugin.c 2017-12-06 06:39:39.000000000 +0000 @@ -37,9 +37,9 @@ }; gboolean -date_module_init(GlobalConfig *cfg, CfgArgs *args G_GNUC_UNUSED) +date_module_init(PluginContext *context, CfgArgs *args G_GNUC_UNUSED) { - plugin_register(cfg, &date_plugin, 1); + plugin_register(context, &date_plugin, 1); return TRUE; } diff -Nru syslog-ng-3.11.1/modules/date/tests/test_date.c syslog-ng-3.13.2/modules/date/tests/test_date.c --- syslog-ng-3.11.1/modules/date/tests/test_date.c 2017-07-31 09:05:32.000000000 +0000 +++ syslog-ng-3.13.2/modules/date/tests/test_date.c 2017-12-06 06:39:39.000000000 +0000 @@ -76,7 +76,7 @@ putenv("TZ=CET-1"); tzset(); - configuration = cfg_new_snippet(0x0302); + configuration = cfg_new_snippet(); } void diff -Nru syslog-ng-3.11.1/modules/dbparser/dbparser.c syslog-ng-3.13.2/modules/dbparser/dbparser.c --- syslog-ng-3.11.1/modules/dbparser/dbparser.c 2017-07-31 09:05:32.000000000 +0000 +++ syslog-ng-3.13.2/modules/dbparser/dbparser.c 2017-12-06 06:39:39.000000000 +0000 @@ -156,7 +156,7 @@ iv_timer_register(&self->tick); if (!self->db) return FALSE; - return log_parser_init_method(s); + return stateful_parser_init_method(s); } static gboolean @@ -172,7 +172,7 @@ cfg_persist_config_add(cfg, log_db_parser_format_persist_name(self), self->db, (GDestroyNotify) pattern_db_free, FALSE); self->db = NULL; - return TRUE; + return stateful_parser_deinit_method(s); } static gboolean diff -Nru syslog-ng-3.11.1/modules/dbparser/dbparser-grammar.ym syslog-ng-3.13.2/modules/dbparser/dbparser-grammar.ym --- syslog-ng-3.11.1/modules/dbparser/dbparser-grammar.ym 2017-07-31 09:05:32.000000000 +0000 +++ syslog-ng-3.13.2/modules/dbparser/dbparser-grammar.ym 2017-12-06 06:39:39.000000000 +0000 @@ -142,7 +142,12 @@ CHECK_ERROR_WITHOUT_MESSAGE(cfg_parser_parse(&filter_expr_parser, lexer, (gpointer *) &filter_expr, NULL), @1); grouping_by_set_having_condition(last_parser, filter_expr); } ')' - | KW_TIMEOUT '(' nonnegative_integer ')' { grouping_by_set_timeout(last_parser, $3); } + | KW_TIMEOUT '(' nonnegative_integer ')' + { + CHECK_ERROR($3 >= 1, @1, "timeout() needs to be greater than 1 second"); + + grouping_by_set_timeout(last_parser, $3); + } | KW_AGGREGATE '(' synthetic_message ')' { grouping_by_set_synthetic_message(last_parser, $3); } | KW_TRIGGER '(' { diff -Nru syslog-ng-3.11.1/modules/dbparser/dbparser-parser.h syslog-ng-3.13.2/modules/dbparser/dbparser-parser.h --- syslog-ng-3.11.1/modules/dbparser/dbparser-parser.h 2017-07-31 09:05:32.000000000 +0000 +++ syslog-ng-3.13.2/modules/dbparser/dbparser-parser.h 2017-12-06 06:39:39.000000000 +0000 @@ -25,7 +25,6 @@ #define DBPARSER_PARSER_H_INCLUDED #include "cfg-parser.h" -#include "cfg-lexer.h" #include "parser/parser-expr.h" extern CfgParser dbparser_parser; diff -Nru syslog-ng-3.11.1/modules/dbparser/dbparser-plugin.c syslog-ng-3.13.2/modules/dbparser/dbparser-plugin.c --- syslog-ng-3.11.1/modules/dbparser/dbparser-plugin.c 2017-07-31 09:05:32.000000000 +0000 +++ syslog-ng-3.13.2/modules/dbparser/dbparser-plugin.c 2017-12-06 06:39:39.000000000 +0000 @@ -44,11 +44,11 @@ }; gboolean -dbparser_module_init(GlobalConfig *cfg, CfgArgs *args) +dbparser_module_init(PluginContext *context, CfgArgs *args) { pattern_db_global_init(); grouping_by_global_init(); - plugin_register(cfg, dbparser_plugins, G_N_ELEMENTS(dbparser_plugins)); + plugin_register(context, dbparser_plugins, G_N_ELEMENTS(dbparser_plugins)); return TRUE; } diff -Nru syslog-ng-3.11.1/modules/dbparser/groupingby.c syslog-ng-3.13.2/modules/dbparser/groupingby.c --- syslog-ng-3.11.1/modules/dbparser/groupingby.c 2017-07-31 09:05:32.000000000 +0000 +++ syslog-ng-3.13.2/modules/dbparser/groupingby.c 2017-12-06 06:39:39.000000000 +0000 @@ -212,7 +212,7 @@ _evaluate_trigger(GroupingBy *self, CorrellationContext *context) { if (!self->trigger_condition_expr) - return TRUE; + return FALSE; return _evaluate_filter(self->trigger_condition_expr, context); } @@ -387,6 +387,25 @@ GroupingBy *self = (GroupingBy *) s; GlobalConfig *cfg = log_pipe_get_config(s); + if (!self->synthetic_message) + { + msg_error("The aggregate() option for grouping-by() is mandatory", + log_pipe_location_tag(s)); + return FALSE; + } + if (self->timeout < 1) + { + msg_error("timeout() needs to be specified explicitly and must be greater than 0 in the grouping-by() parser", + log_pipe_location_tag(s)); + return FALSE; + } + if (!self->key_template) + { + msg_error("The key() option is mandatory for the grouping-by() parser", + log_pipe_location_tag(s)); + return FALSE; + } + self->correllation = cfg_persist_config_fetch(cfg, grouping_by_format_persist_name(self)); if (!self->correllation) { @@ -400,7 +419,7 @@ self->tick.expires.tv_sec++; self->tick.expires.tv_nsec = 0; iv_timer_register(&self->tick); - return TRUE; + return stateful_parser_init_method(s); } static gboolean @@ -417,7 +436,7 @@ cfg_persist_config_add(cfg, grouping_by_format_persist_name(self), self->correllation, (GDestroyNotify) correllation_state_free, FALSE); self->correllation = NULL; - return TRUE; + return stateful_parser_deinit_method(s); } static LogPipe * @@ -462,6 +481,7 @@ self->timer_wheel = timer_wheel_new(); timer_wheel_set_associated_data(self->timer_wheel, self, NULL); cached_g_current_time(&self->last_tick); + self->timeout = -1; return &self->super.super; } diff -Nru syslog-ng-3.11.1/modules/dbparser/pdb-action.c syslog-ng-3.13.2/modules/dbparser/pdb-action.c --- syslog-ng-3.11.1/modules/dbparser/pdb-action.c 2017-07-31 09:05:32.000000000 +0000 +++ syslog-ng-3.13.2/modules/dbparser/pdb-action.c 2017-12-06 06:39:39.000000000 +0000 @@ -31,7 +31,7 @@ { CfgLexer *lexer; - lexer = cfg_lexer_new_buffer(filter_string, strlen(filter_string)); + lexer = cfg_lexer_new_buffer(cfg, filter_string, strlen(filter_string)); if (!cfg_run_parser(cfg, lexer, &filter_expr_parser, (gpointer *) &self->condition, NULL)) { g_set_error(error, PDB_ERROR, PDB_ERROR_FAILED, "Error compiling conditional expression"); diff -Nru syslog-ng-3.11.1/modules/dbparser/pdbtool/pdbtool.c syslog-ng-3.13.2/modules/dbparser/pdbtool/pdbtool.c --- syslog-ng-3.11.1/modules/dbparser/pdbtool/pdbtool.c 2017-07-31 09:05:32.000000000 +0000 +++ syslog-ng-3.13.2/modules/dbparser/pdbtool/pdbtool.c 2017-12-06 06:39:39.000000000 +0000 @@ -420,7 +420,7 @@ { CfgLexer *lexer; - lexer = cfg_lexer_new_buffer(filter_string, strlen(filter_string)); + lexer = cfg_lexer_new_buffer(configuration, filter_string, strlen(filter_string)); if (!cfg_run_parser(configuration, lexer, &filter_expr_parser, (gpointer *) &filter, NULL)) { fprintf(stderr, "Error parsing filter expression\n"); @@ -1024,7 +1024,7 @@ static gboolean pdbtool_load_module(const gchar *option_name, const gchar *value, gpointer data, GError **error) { - return plugin_load_module(value, configuration, NULL); + return cfg_load_module(configuration, value); } static gchar *input_logfile = NULL; @@ -1233,7 +1233,7 @@ pattern_db_global_init(); crypto_init(); - configuration = cfg_new_snippet(VERSION_VALUE); + configuration = cfg_new_snippet(); if (!g_option_context_parse(ctx, &argc, &argv, &error)) { @@ -1244,8 +1244,8 @@ } g_option_context_free(ctx); - plugin_load_module("syslogformat", configuration, NULL); - plugin_load_module("basicfuncs", configuration, NULL); + cfg_load_module(configuration, "syslogformat"); + cfg_load_module(configuration, "basicfuncs"); if (color_out) colors = full_colors; diff -Nru syslog-ng-3.11.1/modules/dbparser/stateful-parser.h syslog-ng-3.13.2/modules/dbparser/stateful-parser.h --- syslog-ng-3.11.1/modules/dbparser/stateful-parser.h 2017-07-31 09:05:32.000000000 +0000 +++ syslog-ng-3.13.2/modules/dbparser/stateful-parser.h 2017-12-06 06:39:39.000000000 +0000 @@ -38,6 +38,18 @@ LogDBParserInjectMode inject_mode; } StatefulParser; +static inline gboolean +stateful_parser_init_method(LogPipe *s) +{ + return log_parser_init_method(s); +} + +static inline gboolean +stateful_parser_deinit_method(LogPipe *s) +{ + return log_parser_deinit_method(s); +} + void stateful_parser_set_inject_mode(StatefulParser *self, LogDBParserInjectMode inject_mode); void stateful_parser_emit_synthetic(StatefulParser *self, LogMessage *msg); void stateful_parser_init_instance(StatefulParser *self, GlobalConfig *cfg); diff -Nru syslog-ng-3.11.1/modules/dbparser/tests/test_parsers_e2e.c syslog-ng-3.13.2/modules/dbparser/tests/test_parsers_e2e.c --- syslog-ng-3.11.1/modules/dbparser/tests/test_parsers_e2e.c 2017-07-31 09:05:32.000000000 +0000 +++ syslog-ng-3.13.2/modules/dbparser/tests/test_parsers_e2e.c 2017-12-06 06:39:39.000000000 +0000 @@ -249,7 +249,7 @@ gchar **parsers[] = {test1, test2, test3, test4, test5, test6, test7, test8, test9, test10, test11, test12, NULL}; void -test_patterndb_parsers() +test_patterndb_parsers(void) { gint i; diff -Nru syslog-ng-3.11.1/modules/dbparser/tests/test_patterndb.c syslog-ng-3.13.2/modules/dbparser/tests/test_patterndb.c --- syslog-ng-3.11.1/modules/dbparser/tests/test_patterndb.c 2017-07-31 09:05:32.000000000 +0000 +++ syslog-ng-3.13.2/modules/dbparser/tests/test_patterndb.c 2017-12-06 06:39:39.000000000 +0000 @@ -891,7 +891,7 @@ "; void -test_patterndb_message_property_inheritance_enabled() +test_patterndb_message_property_inheritance_enabled(void) { _load_pattern_db_from_string(pdb_inheritance_enabled_skeleton); @@ -937,7 +937,7 @@ "; void -test_patterndb_message_property_inheritance_disabled() +test_patterndb_message_property_inheritance_disabled(void) { _load_pattern_db_from_string(pdb_inheritance_disabled_skeleton); @@ -1068,7 +1068,7 @@ "; void -test_patterndb_context_length() +test_patterndb_context_length(void) { _load_pattern_db_from_string(pdb_msg_count_skeleton); @@ -1095,7 +1095,7 @@ "; void -test_patterndb_tags_outside_of_rule() +test_patterndb_tags_outside_of_rule(void) { patterndb = pattern_db_new(); messages = NULL; @@ -1119,9 +1119,9 @@ msg_init(TRUE); - configuration = cfg_new_snippet(0x0302); - plugin_load_module("basicfuncs", configuration, NULL); - plugin_load_module("syslogformat", configuration, NULL); + configuration = cfg_new_snippet(); + cfg_load_module(configuration, "basicfuncs"); + cfg_load_module(configuration, "syslogformat"); pattern_db_global_init(); diff -Nru syslog-ng-3.11.1/modules/dbparser/tests/test_patternize.c syslog-ng-3.13.2/modules/dbparser/tests/test_patternize.c --- syslog-ng-3.11.1/modules/dbparser/tests/test_patternize.c 2017-07-31 09:05:32.000000000 +0000 +++ syslog-ng-3.13.2/modules/dbparser/tests/test_patternize.c 2017-12-06 06:39:39.000000000 +0000 @@ -151,7 +151,7 @@ } void -frequent_words_tests() +frequent_words_tests(void) { /* simple tests */ @@ -367,7 +367,7 @@ } void -find_clusters_slct_tests() +find_clusters_slct_tests(void) { testcase_find_clusters_slct( "a\n", 0, @@ -445,11 +445,11 @@ } int -main() +main(void) { app_startup(); - configuration = cfg_new_snippet(0x0201); - plugin_load_module("syslogformat", configuration, NULL); + configuration = cfg_new_snippet(); + cfg_load_module(configuration, "syslogformat"); msg_format_options_defaults(&parse_options); msg_format_options_init(&parse_options, configuration); diff -Nru syslog-ng-3.11.1/modules/dbparser/tests/test_timer_wheel.c syslog-ng-3.13.2/modules/dbparser/tests/test_timer_wheel.c --- syslog-ng-3.11.1/modules/dbparser/tests/test_timer_wheel.c 2017-07-31 09:05:32.000000000 +0000 +++ syslog-ng-3.13.2/modules/dbparser/tests/test_timer_wheel.c 2017-12-06 06:39:39.000000000 +0000 @@ -136,7 +136,7 @@ } int -main() +main(void) { test_wheel(1234567890); test_wheel(time(NULL)); diff -Nru syslog-ng-3.11.1/modules/diskq/diskq-options.c syslog-ng-3.13.2/modules/diskq/diskq-options.c --- syslog-ng-3.11.1/modules/diskq/diskq-options.c 2017-07-31 09:05:32.000000000 +0000 +++ syslog-ng-3.13.2/modules/diskq/diskq-options.c 2017-12-06 06:39:39.000000000 +0000 @@ -79,14 +79,14 @@ { if (self->mem_buf_length > 0) { - msg_warning("WARNING: Reliable queue: the mem-buf-length parameter is omitted"); + msg_warning("WARNING: mem-buf-length parameter was ignored as it is not compatible with reliable queue. Did you mean mem-buf-size?"); } } else { if (self->mem_buf_size > 0) { - msg_warning("WARNING: Non-reliable queue: the mem-buf-size parameter is omitted"); + msg_warning("WARNING: mem-buf-size parameter was ignored as it is not compatible with non-reliable queue. Did you mean mem-buf-length?"); } } } diff -Nru syslog-ng-3.11.1/modules/diskq/diskq-parser.h syslog-ng-3.13.2/modules/diskq/diskq-parser.h --- syslog-ng-3.11.1/modules/diskq/diskq-parser.h 2017-07-31 09:05:32.000000000 +0000 +++ syslog-ng-3.13.2/modules/diskq/diskq-parser.h 2017-12-06 06:39:39.000000000 +0000 @@ -25,7 +25,6 @@ #define DISKQ_PARSER_H_INCLUDED #include "cfg-parser.h" -#include "cfg-lexer.h" #include "diskq.h" extern CfgParser diskq_parser; diff -Nru syslog-ng-3.11.1/modules/diskq/diskq-plugin.c syslog-ng-3.13.2/modules/diskq/diskq-plugin.c --- syslog-ng-3.11.1/modules/diskq/diskq-plugin.c 2017-07-31 09:05:32.000000000 +0000 +++ syslog-ng-3.13.2/modules/diskq/diskq-plugin.c 2017-12-06 06:39:39.000000000 +0000 @@ -49,8 +49,8 @@ #endif gboolean -disk_buffer_module_init(GlobalConfig *cfg, CfgArgs *args) +disk_buffer_module_init(PluginContext *context, CfgArgs *args) { - plugin_register(cfg, diskq_plugins, G_N_ELEMENTS(diskq_plugins)); + plugin_register(context, diskq_plugins, G_N_ELEMENTS(diskq_plugins)); return TRUE; } diff -Nru syslog-ng-3.11.1/modules/diskq/dqtool.c syslog-ng-3.13.2/modules/diskq/dqtool.c --- syslog-ng-3.11.1/modules/diskq/dqtool.c 2017-07-31 09:05:32.000000000 +0000 +++ syslog-ng-3.13.2/modules/diskq/dqtool.c 2017-12-06 06:39:39.000000000 +0000 @@ -290,7 +290,7 @@ return 0; } - configuration = cfg_new_snippet(VERSION_VALUE); + configuration = cfg_new_snippet(); configuration->template_options.frac_digits = 3; configuration->template_options.time_zone_info[LTZ_LOCAL] = time_zone_info_new(NULL); diff -Nru syslog-ng-3.11.1/modules/diskq/qdisk.c syslog-ng-3.13.2/modules/diskq/qdisk.c --- syslog-ng-3.11.1/modules/diskq/qdisk.c 2017-07-31 09:05:32.000000000 +0000 +++ syslog-ng-3.13.2/modules/diskq/qdisk.c 2017-12-06 06:39:39.000000000 +0000 @@ -1010,7 +1010,7 @@ } QDisk * -qdisk_new() +qdisk_new(void) { QDisk *self = g_new0(QDisk, 1); return self; diff -Nru syslog-ng-3.11.1/modules/diskq/qdisk.h syslog-ng-3.13.2/modules/diskq/qdisk.h --- syslog-ng-3.11.1/modules/diskq/qdisk.h 2017-07-31 09:05:32.000000000 +0000 +++ syslog-ng-3.13.2/modules/diskq/qdisk.h 2017-12-06 06:39:39.000000000 +0000 @@ -39,7 +39,7 @@ typedef struct _QDisk QDisk; -QDisk *qdisk_new(); +QDisk *qdisk_new(void); gboolean qdisk_is_space_avail(QDisk *self, gint at_least); gboolean qdisk_push_tail(QDisk *self, GString *record); diff -Nru syslog-ng-3.11.1/modules/diskq/tests/test_diskq.c syslog-ng-3.13.2/modules/diskq/tests/test_diskq.c --- syslog-ng-3.11.1/modules/diskq/tests/test_diskq.c 2017-07-31 09:05:32.000000000 +0000 +++ syslog-ng-3.13.2/modules/diskq/tests/test_diskq.c 2017-12-06 06:39:39.000000000 +0000 @@ -52,7 +52,7 @@ MsgFormatOptions parse_options; static void -testcase_zero_diskbuf_and_normal_acks() +testcase_zero_diskbuf_and_normal_acks(void) { LogQueue *q; gint i; @@ -86,7 +86,7 @@ } static void -testcase_zero_diskbuf_alternating_send_acks() +testcase_zero_diskbuf_alternating_send_acks(void) { LogQueue *q; gint i; @@ -121,7 +121,7 @@ } static void -testcase_ack_and_rewind_messages() +testcase_ack_and_rewind_messages(void) { LogQueue *q; gint i; @@ -273,7 +273,7 @@ static void -testcase_with_threads() +testcase_with_threads(void) { LogQueue *q; GThread *thread_feed[FEEDERS], *thread_consume; @@ -478,7 +478,7 @@ } int -main() +main(void) { #if _AIX fprintf(stderr, @@ -489,10 +489,10 @@ putenv("TZ=MET-1METDST"); tzset(); - configuration = cfg_new_snippet(VERSION_VALUE); + configuration = cfg_new_snippet(); configuration->stats_options.level = 1; assert_true(cfg_init(configuration), "cfg_init failed!"); - plugin_load_module("syslogformat", configuration, NULL); + cfg_load_module(configuration, "syslogformat"); msg_format_options_defaults(&parse_options); msg_format_options_init(&parse_options, configuration); diff -Nru syslog-ng-3.11.1/modules/diskq/tests/test_diskq_full.c syslog-ng-3.13.2/modules/diskq/tests/test_diskq_full.c --- syslog-ng-3.11.1/modules/diskq/tests/test_diskq_full.c 2017-07-31 09:05:32.000000000 +0000 +++ syslog-ng-3.13.2/modules/diskq/tests/test_diskq_full.c 2017-12-06 06:39:39.000000000 +0000 @@ -88,16 +88,16 @@ } int -main() +main(void) { app_startup(); putenv("TZ=MET-1METDST"); tzset(); - configuration = cfg_new_snippet(0x0308); - plugin_load_module("syslogformat", configuration, NULL ); - plugin_load_module("disk-buffer", configuration, NULL ); - plugin_load_module("builtin-serializer", configuration, NULL ); + configuration = cfg_new_snippet(); + cfg_load_module(configuration, "syslogformat"); + cfg_load_module(configuration, "disk-buffer"); + cfg_load_module(configuration, "builtin-serializer"); msg_set_post_func(msg_post_function); msg_format_options_defaults(&parse_options); msg_format_options_init(&parse_options, configuration); diff -Nru syslog-ng-3.11.1/modules/diskq/tests/test_reliable_backlog.c syslog-ng-3.13.2/modules/diskq/tests/test_reliable_backlog.c --- syslog-ng-3.11.1/modules/diskq/tests/test_reliable_backlog.c 2017-07-31 09:05:32.000000000 +0000 +++ syslog-ng-3.13.2/modules/diskq/tests/test_reliable_backlog.c 2017-12-06 06:39:39.000000000 +0000 @@ -106,7 +106,7 @@ } static void -set_mark_message_serialized_size() +set_mark_message_serialized_size(void) { LogMessage *mark_message = log_msg_new_mark(); mark_message_serialized_size = get_serialized_message_size(mark_message); @@ -216,7 +216,7 @@ /* TODO: add 3 messages and rewind 1 instead of 0 */ /* TODO: split this test into 3 tests (read ack rewind mechanism (setup method) */ static void -test_over_EOF() +test_over_EOF(void) { LogQueueDiskReliable *dq = _init_diskq_for_test(TEST_DISKQ_SIZE, TEST_DISKQ_SIZE); LogMessage *msg1; @@ -360,7 +360,7 @@ * qbacklog must be always in sync with backlog */ void -test_rewind_backlog() +test_rewind_backlog(void) { LogQueueDiskReliable *dq = _init_diskq_for_test(QDISK_RESERVED_SPACE + mark_message_serialized_size * 10, mark_message_serialized_size * 5); @@ -384,9 +384,9 @@ putenv("TZ=MET-1METDST"); tzset(); - configuration = cfg_new_snippet(0x0308); - plugin_load_module("syslogformat", configuration, NULL); - plugin_load_module("disk-buffer", configuration, NULL); + configuration = cfg_new_snippet(); + cfg_load_module(configuration, "syslogformat"); + cfg_load_module(configuration, "disk-buffer"); msg_format_options_defaults(&parse_options); msg_format_options_init(&parse_options, configuration); set_mark_message_serialized_size(); diff -Nru syslog-ng-3.11.1/modules/geoip/geoip-parser-parser.h syslog-ng-3.13.2/modules/geoip/geoip-parser-parser.h --- syslog-ng-3.11.1/modules/geoip/geoip-parser-parser.h 2017-07-31 09:05:32.000000000 +0000 +++ syslog-ng-3.13.2/modules/geoip/geoip-parser-parser.h 2017-12-06 06:39:39.000000000 +0000 @@ -25,7 +25,6 @@ #define GEOIP_PARSER_PARSER_H_INCLUDED #include "cfg-parser.h" -#include "cfg-lexer.h" #include "parser/parser-expr.h" extern CfgParser geoip_parser_parser; diff -Nru syslog-ng-3.11.1/modules/geoip/geoip-plugin.c syslog-ng-3.13.2/modules/geoip/geoip-plugin.c --- syslog-ng-3.11.1/modules/geoip/geoip-plugin.c 2017-07-31 09:05:32.000000000 +0000 +++ syslog-ng-3.13.2/modules/geoip/geoip-plugin.c 2017-12-06 06:39:39.000000000 +0000 @@ -40,9 +40,9 @@ }; gboolean -geoip_module_init(GlobalConfig *cfg, CfgArgs *args) +geoip_module_init(PluginContext *context, CfgArgs *args) { - plugin_register(cfg, geoip_plugins, G_N_ELEMENTS(geoip_plugins)); + plugin_register(context, geoip_plugins, G_N_ELEMENTS(geoip_plugins)); return TRUE; } diff -Nru syslog-ng-3.11.1/modules/geoip2/geoip-parser-parser.h syslog-ng-3.13.2/modules/geoip2/geoip-parser-parser.h --- syslog-ng-3.11.1/modules/geoip2/geoip-parser-parser.h 2017-07-31 09:05:32.000000000 +0000 +++ syslog-ng-3.13.2/modules/geoip2/geoip-parser-parser.h 2017-12-06 06:39:39.000000000 +0000 @@ -24,7 +24,6 @@ #define GEOIP2_PARSER_PARSER_H_INCLUDED #include "cfg-parser.h" -#include "cfg-lexer.h" #include "parser/parser-expr.h" extern CfgParser geoip2_parser_parser; diff -Nru syslog-ng-3.11.1/modules/geoip2/geoip-plugin.c syslog-ng-3.13.2/modules/geoip2/geoip-plugin.c --- syslog-ng-3.11.1/modules/geoip2/geoip-plugin.c 2017-07-31 09:05:32.000000000 +0000 +++ syslog-ng-3.13.2/modules/geoip2/geoip-plugin.c 2017-12-06 06:39:39.000000000 +0000 @@ -39,9 +39,9 @@ }; gboolean -geoip2_module_init(GlobalConfig *cfg, CfgArgs *args) +geoip2_module_init(PluginContext *context, CfgArgs *args) { - plugin_register(cfg, geoip2_plugins, G_N_ELEMENTS(geoip2_plugins)); + plugin_register(context, geoip2_plugins, G_N_ELEMENTS(geoip2_plugins)); return TRUE; } diff -Nru syslog-ng-3.11.1/modules/geoip2/tests/test_geoip_parser.c syslog-ng-3.13.2/modules/geoip2/tests/test_geoip_parser.c --- syslog-ng-3.11.1/modules/geoip2/tests/test_geoip_parser.c 2017-07-31 09:05:32.000000000 +0000 +++ syslog-ng-3.13.2/modules/geoip2/tests/test_geoip_parser.c 2017-12-06 06:39:39.000000000 +0000 @@ -84,7 +84,7 @@ } static void -test_geoip_parser_basics() +test_geoip_parser_basics(void) { LogMessage *msg; @@ -101,7 +101,7 @@ } static void -test_geoip_parser_uses_template_to_parse_input() +test_geoip_parser_uses_template_to_parse_input(void) { LogMessage *msg; LogTemplate *template; diff -Nru syslog-ng-3.11.1/modules/getent/getent-group.c syslog-ng-3.13.2/modules/getent/getent-group.c --- syslog-ng-3.11.1/modules/getent/getent-group.c 2017-07-31 09:05:32.000000000 +0000 +++ syslog-ng-3.13.2/modules/getent/getent-group.c 2017-12-06 06:39:39.000000000 +0000 @@ -24,7 +24,7 @@ { { "name", _getent_format_string, offsetof(struct group, gr_name) }, { "gid", _getent_format_uid_gid, offsetof(struct group, gr_gid) }, - { "members", _getent_format_array, offsetof(struct group, gr_mem) }, + { "members", _getent_format_array_at_location, offsetof(struct group, gr_mem) }, { NULL, NULL, 0 } }; diff -Nru syslog-ng-3.11.1/modules/getent/getent-protocols.c syslog-ng-3.13.2/modules/getent/getent-protocols.c --- syslog-ng-3.11.1/modules/getent/getent-protocols.c 2017-07-31 09:05:32.000000000 +0000 +++ syslog-ng-3.13.2/modules/getent/getent-protocols.c 2017-12-06 06:39:39.000000000 +0000 @@ -39,7 +39,7 @@ if (is_num) g_string_append(result, res->p_name); else - g_string_append_printf(result, "%i", htons(res->p_proto)); + g_string_append_printf(result, "%d", res->p_proto); return TRUE; } diff -Nru syslog-ng-3.11.1/modules/getent/tfgetent.c syslog-ng-3.13.2/modules/getent/tfgetent.c --- syslog-ng-3.11.1/modules/getent/tfgetent.c 2017-07-31 09:05:32.000000000 +0000 +++ syslog-ng-3.13.2/modules/getent/tfgetent.c 2017-12-06 06:39:39.000000000 +0000 @@ -20,6 +20,10 @@ * COPYING for details. */ +#if defined(sun) || defined(__sun) +#define _POSIX_PTHREAD_SEMANTICS +#endif + #include "syslog-ng.h" #include "logmsg/logmsg.h" #include "plugin.h" @@ -27,6 +31,7 @@ #include "cfg.h" #include "parse-number.h" #include "template/simple-function.h" +#include "compat/getent.h" #include #include @@ -48,26 +53,38 @@ } formatter_map_t; static gboolean -_getent_format_array(gchar *member_name, gpointer member, GString *result) +_getent_format_array(gchar *name_or_gid, gpointer members, GString *result) { + + gchar **member_array = (gchar **)members; int i = 0; - char *o = *(char **)member; - char *p = *(char **)o; - char *sep = ""; - - do - { - g_string_append(result, sep); - g_string_append(result, p); - sep = ","; - p = *((char **)o + ++i); + + if (member_array[i]) + { + g_string_append(result, member_array[i]); + i++; + } + else + return TRUE; + + while (member_array[i]) + { + g_string_append(result, ","); + g_string_append(result, member_array[i]); + i++; } - while (p != NULL && p != '\0'); return TRUE; } static gboolean +_getent_format_array_at_location(gchar *name_or_gid, gpointer location, GString *result) +{ + gpointer members = *((gchar **)location); + return _getent_format_array(name_or_gid, members, result); +} + +static gboolean _getent_format_string(gchar *member_name, gpointer member, GString *result) { char *value = *(char **)member; @@ -174,9 +191,9 @@ }; gboolean -getent_plugin_module_init(GlobalConfig *cfg, CfgArgs *args) +getent_plugin_module_init(PluginContext *context, CfgArgs *args) { - plugin_register(cfg, getent_plugins, G_N_ELEMENTS(getent_plugins)); + plugin_register(context, getent_plugins, G_N_ELEMENTS(getent_plugins)); return TRUE; } diff -Nru syslog-ng-3.11.1/modules/graphite/graphite-output.c syslog-ng-3.13.2/modules/graphite/graphite-output.c --- syslog-ng-3.11.1/modules/graphite/graphite-output.c 2017-07-31 09:05:32.000000000 +0000 +++ syslog-ng-3.13.2/modules/graphite/graphite-output.c 2017-12-06 06:39:39.000000000 +0000 @@ -96,7 +96,7 @@ log_template_compile(state->timestamp_template, "$R_UNIXTIME", NULL); } - state->vp = value_pairs_new_from_cmdline (parent->cfg, argc, argv, error); + state->vp = value_pairs_new_from_cmdline (parent->cfg, &argc, &argv, FALSE, error); if (!state->vp) return FALSE; diff -Nru syslog-ng-3.11.1/modules/graphite/graphite-plugin.c syslog-ng-3.13.2/modules/graphite/graphite-plugin.c --- syslog-ng-3.11.1/modules/graphite/graphite-plugin.c 2017-07-31 09:05:32.000000000 +0000 +++ syslog-ng-3.13.2/modules/graphite/graphite-plugin.c 2017-12-06 06:39:39.000000000 +0000 @@ -31,9 +31,9 @@ }; gboolean -graphite_module_init(GlobalConfig *cfg, CfgArgs *args) +graphite_module_init(PluginContext *context, CfgArgs *args) { - plugin_register(cfg, graphite_plugins, G_N_ELEMENTS(graphite_plugins)); + plugin_register(context, graphite_plugins, G_N_ELEMENTS(graphite_plugins)); return TRUE; } diff -Nru syslog-ng-3.11.1/modules/http/http.c syslog-ng-3.13.2/modules/http/http.c --- syslog-ng-3.11.1/modules/http/http.c 2017-07-31 09:05:32.000000000 +0000 +++ syslog-ng-3.13.2/modules/http/http.c 2017-12-06 06:39:39.000000000 +0000 @@ -137,6 +137,48 @@ return log_msg_get_value(msg, LM_V_MESSAGE, NULL); } +static +void _http_trace_sanitize_dump(const gchar *text, gchar *data, size_t size) +{ + gchar *sanitized = g_new0(gchar, size+1); + int i; + for (i = 0; i < size && data[i]; i++) + { + sanitized[i] = g_ascii_isprint(data[i]) ? data[i] : '.'; + } + sanitized[i] = 0; + msg_debug("curl trace log", + evt_tag_str("curl_info_type", text), + evt_tag_str("data", sanitized)); + g_free(sanitized); +} + +gchar *curl_infotype_to_text[] = +{ + "curl_trace_text", + "curl_trace_header_in", + "curl_trace_header_out", + "curl_trace_data_in", + "curl_trace_data_out", + "curl_trace_ssl_data_in", + "curl_trace_ssl_data_out", +}; + +static +gint _http_trace(CURL *handle, curl_infotype type, + char *data, size_t size, + void *userp) +{ + if (!G_UNLIKELY(debug_flag)) + return 0; + + g_assert(type < sizeof(curl_infotype_to_text)/sizeof(curl_infotype_to_text[0])); + + _http_trace_sanitize_dump(curl_infotype_to_text[type], data, size); + + return 0; +} + static void _set_curl_opt(HTTPDestinationDriver *self) { @@ -175,6 +217,9 @@ curl_easy_setopt(self->curl, CURLOPT_SSL_VERIFYHOST, self->peer_verify ? 2L : 0L); curl_easy_setopt(self->curl, CURLOPT_SSL_VERIFYPEER, self->peer_verify ? 1L : 0L); + curl_easy_setopt(self->curl, CURLOPT_DEBUGFUNCTION, _http_trace); + curl_easy_setopt(self->curl, CURLOPT_VERBOSE, 1L); + curl_easy_setopt(self->curl, CURLOPT_TIMEOUT, self->timeout); if (self->method_type == METHOD_TYPE_PUT) @@ -289,14 +334,7 @@ HTTPDestinationDriver *self = (HTTPDestinationDriver *) d; g_list_free_full(self->headers, g_free); - self->headers = g_list_copy(headers); - - GList *header = self->headers; - while (header != NULL) - { - header->data = g_strdup(header->data); - header = g_list_next(header); - } + self->headers = g_list_copy_deep(headers, ((GCopyFunc)g_strdup), NULL); } void diff -Nru syslog-ng-3.11.1/modules/http/http-grammar.ym syslog-ng-3.13.2/modules/http/http-grammar.ym --- syslog-ng-3.11.1/modules/http/http-grammar.ym 2017-07-31 09:05:32.000000000 +0000 +++ syslog-ng-3.13.2/modules/http/http-grammar.ym 2017-12-06 06:39:39.000000000 +0000 @@ -64,6 +64,7 @@ %token KW_SSL_VERSION %token KW_PEER_VERIFY %token KW_TIMEOUT +%token KW_TLS %type driver %type http_destination @@ -107,17 +108,27 @@ | KW_HEADERS '(' string_list ')' { http_dd_set_headers(last_driver, $3); g_list_free_full($3, free); } | KW_METHOD '(' string ')' { http_dd_set_method(last_driver, $3); free($3); } | KW_BODY '(' template_content ')' { http_dd_set_body(last_driver, $3); log_template_unref($3); } - | KW_CA_DIR '(' string ')' { http_dd_set_ca_dir(last_driver, $3); free($3); } + | KW_TIMEOUT '(' nonnegative_integer ')' { http_dd_set_timeout(last_driver, $3); } + | dest_driver_option + | threaded_dest_driver_option + | http_tls_option + | KW_TLS '(' http_tls_options ')' + | { last_template_options = http_dd_get_template_options(last_driver); } template_option + ; + +http_tls_options + : http_tls_option http_tls_options + | + ; + +http_tls_option + : KW_CA_DIR '(' string ')' { http_dd_set_ca_dir(last_driver, $3); free($3); } | KW_CA_FILE '(' string ')' { http_dd_set_ca_file(last_driver, $3); free($3); } | KW_CERT_FILE '(' string ')' { http_dd_set_cert_file(last_driver, $3); free($3); } | KW_KEY_FILE '(' string ')' { http_dd_set_key_file(last_driver, $3); free($3); } | KW_CIPHER_SUITE '(' string ')' { http_dd_set_cipher_suite(last_driver, $3); free($3); } | KW_SSL_VERSION '(' string ')' { http_dd_set_ssl_version(last_driver, $3); free($3); } | KW_PEER_VERIFY '(' yesno ')' { http_dd_set_peer_verify(last_driver, $3); } - | KW_TIMEOUT '(' nonnegative_integer ')' { http_dd_set_timeout(last_driver, $3); } - | dest_driver_option - | threaded_dest_driver_option - | { last_template_options = http_dd_get_template_options(last_driver); } template_option ; /* INCLUDE_RULES */ diff -Nru syslog-ng-3.11.1/modules/http/http-parser.c syslog-ng-3.13.2/modules/http/http-parser.c --- syslog-ng-3.11.1/modules/http/http-parser.c 2017-07-31 09:05:32.000000000 +0000 +++ syslog-ng-3.13.2/modules/http/http-parser.c 2017-12-06 06:39:39.000000000 +0000 @@ -46,6 +46,7 @@ { "ssl_version", KW_SSL_VERSION }, { "peer_verify", KW_PEER_VERIFY }, { "timeout", KW_TIMEOUT }, + { "tls", KW_TLS }, { NULL } }; diff -Nru syslog-ng-3.11.1/modules/http/http-parser.h syslog-ng-3.13.2/modules/http/http-parser.h --- syslog-ng-3.11.1/modules/http/http-parser.h 2017-07-31 09:05:32.000000000 +0000 +++ syslog-ng-3.13.2/modules/http/http-parser.h 2017-12-06 06:39:39.000000000 +0000 @@ -24,7 +24,6 @@ #define HTTP_PARSER_H_INCLUDED #include "cfg-parser.h" -#include "cfg-lexer.h" #include "driver.h" extern CfgParser http_parser; diff -Nru syslog-ng-3.11.1/modules/http/http-plugin.c syslog-ng-3.13.2/modules/http/http-plugin.c --- syslog-ng-3.11.1/modules/http/http-plugin.c 2017-07-31 09:05:32.000000000 +0000 +++ syslog-ng-3.13.2/modules/http/http-plugin.c 2017-12-06 06:39:39.000000000 +0000 @@ -36,9 +36,9 @@ }; gboolean -http_module_init(GlobalConfig *cfg, CfgArgs *args) +http_module_init(PluginContext *context, CfgArgs *args) { - plugin_register(cfg, http_plugins, G_N_ELEMENTS(http_plugins)); + plugin_register(context, http_plugins, G_N_ELEMENTS(http_plugins)); return TRUE; } diff -Nru syslog-ng-3.11.1/modules/java/native/java-destination.c syslog-ng-3.13.2/modules/java/native/java-destination.c --- syslog-ng-3.11.1/modules/java/native/java-destination.c 2017-07-31 09:05:32.000000000 +0000 +++ syslog-ng-3.13.2/modules/java/native/java-destination.c 2017-12-06 06:39:39.000000000 +0000 @@ -64,6 +64,13 @@ return (jlong)(&self->template_options); } +JNIEXPORT jint JNICALL +Java_org_syslog_1ng_LogDestination_getSeqNum(JNIEnv *env, jobject obj, jlong handle) +{ + JavaDestDriver *self = (JavaDestDriver *)handle; + return (jint)(self->super.seq_num); +} + JNIEXPORT jlong JNICALL Java_org_syslog_1ng_LogPipe_getConfigHandle(JNIEnv *env, jobject obj, jlong handle) { @@ -123,7 +130,8 @@ return FALSE; } - self->proxy = java_destination_proxy_new(self->class_name, self->class_path->str, self, self->template); + self->proxy = java_destination_proxy_new(self->class_name, self->class_path->str, self, self->template, + &self->super.seq_num, cfg->jvm_options); if (!self->proxy) return FALSE; diff -Nru syslog-ng-3.11.1/modules/java/native/java_machine.c syslog-ng-3.13.2/modules/java/native/java_machine.c --- syslog-ng-3.11.1/modules/java/native/java_machine.c 2017-07-31 09:05:32.000000000 +0000 +++ syslog-ng-3.13.2/modules/java/native/java_machine.c 2017-12-06 06:39:39.000000000 +0000 @@ -30,11 +30,11 @@ #include "lib/reloc.h" #include "plugin.h" #include "resolved-configurable-paths.h" +#include struct _JavaVMSingleton { GAtomicCounter ref_cnt; - JavaVMOption options[3]; JNIEnv *env; JavaVM *jvm; JavaVMInitArgs vm_args; @@ -92,24 +92,91 @@ } } +static GArray * +_jvm_options_array_append(GArray *jvm_options_array, char *option_string) +{ + JavaVMOption opt; + opt.optionString = option_string; + return g_array_append_val(jvm_options_array, opt); +} + +static gboolean +_is_jvm_option_predefined(const gchar *option) +{ + static const gchar *predefined_options[] = + { + "Djava.class.path", + "Djava.library.path", + NULL + }; + + for (gint i = 0; predefined_options[i] != NULL; i++) + { + if (!strcmp(option, predefined_options[i])) + { + msg_info("JVM option is set by syslog-ng, cannot be overridden by user-defined values.", + evt_tag_str("option", option)); + return TRUE; + } + } + + return FALSE; +} + +static GArray * +_jvm_options_split(const gchar *jvm_options_str) +{ + GArray *jvm_options_array = g_array_new(FALSE, TRUE, sizeof(JavaVMOption)); + + if (!jvm_options_str) + return jvm_options_array; + + gchar **options_str_array = g_strsplit_set(jvm_options_str, " \t", 0); + + for (gint i = 0; options_str_array[i]; i++) + { + if (options_str_array[i][0] == '\0' || _is_jvm_option_predefined(options_str_array[i])) + { + g_free(options_str_array[i]); + continue; + } + + jvm_options_array = _jvm_options_array_append(jvm_options_array, options_str_array[i]); + } + g_free(options_str_array); + + return jvm_options_array; +} + +static void +_setup_jvm_options_array(JavaVMSingleton *self, const gchar *jvm_options_str) +{ + GArray *jvm_options_array = _jvm_options_split(jvm_options_str); + + jvm_options_array = _jvm_options_array_append(jvm_options_array, + g_strdup_printf("-Djava.class.path=%s", + self->class_path->str)); + + jvm_options_array = _jvm_options_array_append(jvm_options_array, + g_strdup_printf("-Djava.library.path=%s", + resolvedConfigurablePaths.initial_module_path)); + + jvm_options_array = _jvm_options_array_append(jvm_options_array, + g_strdup("-Xrs")); + + self->vm_args.nOptions = jvm_options_array->len; + self->vm_args.options = (JavaVMOption *)jvm_options_array->data; +} + gboolean -java_machine_start(JavaVMSingleton *self) +java_machine_start(JavaVMSingleton *self, const gchar *jvm_options) { g_assert(self == g_jvm_s); if (!self->jvm) { long status; - self->options[0].optionString = g_strdup_printf( - "-Djava.class.path=%s", self->class_path->str); - - self->options[1].optionString = g_strdup_printf( - "-Djava.library.path=%s", resolvedConfigurablePaths.initial_module_path); - - self->options[2].optionString = g_strdup("-Xrs"); - + _setup_jvm_options_array(self, jvm_options); self->vm_args.version = JNI_VERSION_1_6; - self->vm_args.nOptions = 3; - self->vm_args.options = self->options; status = JNI_CreateJavaVM(&self->jvm, (void **) &self->env, &self->vm_args); if (status == JNI_ERR) diff -Nru syslog-ng-3.11.1/modules/java/native/java_machine.h syslog-ng-3.13.2/modules/java/native/java_machine.h --- syslog-ng-3.11.1/modules/java/native/java_machine.h 2017-07-31 09:05:32.000000000 +0000 +++ syslog-ng-3.13.2/modules/java/native/java_machine.h 2017-12-06 06:39:39.000000000 +0000 @@ -35,7 +35,7 @@ JavaVMSingleton *java_machine_ref(void); void java_machine_unref(JavaVMSingleton *self); -gboolean java_machine_start(JavaVMSingleton* self); +gboolean java_machine_start(JavaVMSingleton* self, const gchar *jvm_options); void java_machine_detach_thread(void); diff -Nru syslog-ng-3.11.1/modules/java/native/java-parser.h syslog-ng-3.13.2/modules/java/native/java-parser.h --- syslog-ng-3.11.1/modules/java/native/java-parser.h 2017-07-31 09:05:32.000000000 +0000 +++ syslog-ng-3.13.2/modules/java/native/java-parser.h 2017-12-06 06:39:39.000000000 +0000 @@ -26,7 +26,6 @@ #define MODJAVA_PARSER_H_INCLUDED #include "cfg-parser.h" -#include "cfg-lexer.h" #include "java-destination.h" extern CfgParser java_parser; diff -Nru syslog-ng-3.11.1/modules/java/native/java-plugin.c syslog-ng-3.13.2/modules/java/native/java-plugin.c --- syslog-ng-3.11.1/modules/java/native/java-plugin.c 2017-07-31 09:05:32.000000000 +0000 +++ syslog-ng-3.13.2/modules/java/native/java-plugin.c 2017-12-06 06:39:39.000000000 +0000 @@ -45,9 +45,9 @@ }; gboolean -java_module_init(GlobalConfig *cfg, CfgArgs *args) +java_module_init(PluginContext *context, CfgArgs *args) { - plugin_register(cfg, java_plugins, G_N_ELEMENTS(java_plugins)); + plugin_register(context, java_plugins, G_N_ELEMENTS(java_plugins)); return TRUE; } diff -Nru syslog-ng-3.11.1/modules/java/proxies/java-destination-proxy.c syslog-ng-3.13.2/modules/java/proxies/java-destination-proxy.c --- syslog-ng-3.11.1/modules/java/proxies/java-destination-proxy.c 2017-07-31 09:05:32.000000000 +0000 +++ syslog-ng-3.13.2/modules/java/proxies/java-destination-proxy.c 2017-12-06 06:39:39.000000000 +0000 @@ -51,6 +51,7 @@ jclass loaded_class; JavaDestinationImpl dest_impl; LogTemplate *template; + gint32 *seq_num; GString *formatted_message; JavaLogMessageProxy *msg_builder; gchar *name_by_uniq_options; @@ -192,14 +193,16 @@ } JavaDestinationProxy * -java_destination_proxy_new(const gchar *class_name, const gchar *class_path, gpointer handle, LogTemplate *template) +java_destination_proxy_new(const gchar *class_name, const gchar *class_path, gpointer handle, LogTemplate *template, + gint32 *seq_num, const gchar *jvm_options) { JavaDestinationProxy *self = g_new0(JavaDestinationProxy, 1); self->java_machine = java_machine_ref(); self->formatted_message = g_string_sized_new(1024); self->template = log_template_ref(template); + self->seq_num = seq_num; - if (!java_machine_start(self->java_machine)) + if (!java_machine_start(self->java_machine, jvm_options)) goto error; if (!__load_destination_object(self, class_name, class_path, handle)) @@ -236,7 +239,7 @@ static gboolean __queue_formatted_message(JavaDestinationProxy *self, JNIEnv *env, LogMessage *msg) { - log_template_format(self->template, msg, NULL, LTZ_SEND, 0, NULL, self->formatted_message); + log_template_format(self->template, msg, NULL, LTZ_SEND, *self->seq_num, NULL, self->formatted_message); jstring message = CALL_JAVA_FUNCTION(env, NewStringUTF, self->formatted_message->str); jboolean res = CALL_JAVA_FUNCTION(env, CallBooleanMethod, self->dest_impl.dest_object, self->dest_impl.mi_send, message); @@ -357,7 +360,6 @@ return !!(res); } - void java_destination_proxy_close(JavaDestinationProxy *self) { diff -Nru syslog-ng-3.11.1/modules/java/proxies/java-destination-proxy.h syslog-ng-3.13.2/modules/java/proxies/java-destination-proxy.h --- syslog-ng-3.11.1/modules/java/proxies/java-destination-proxy.h 2017-07-31 09:05:32.000000000 +0000 +++ syslog-ng-3.13.2/modules/java/proxies/java-destination-proxy.h 2017-12-06 06:39:39.000000000 +0000 @@ -33,7 +33,7 @@ typedef struct _JavaDestinationProxy JavaDestinationProxy; -JavaDestinationProxy *java_destination_proxy_new(const gchar *class_name, const gchar *class_path, gpointer handle, LogTemplate *template); +JavaDestinationProxy *java_destination_proxy_new(const gchar *class_name, const gchar *class_path, gpointer handle, LogTemplate *template, gint32 *seq_num, const gchar *jvm_options); gboolean java_destination_proxy_init(JavaDestinationProxy *self); void java_destination_proxy_deinit(JavaDestinationProxy *self); diff -Nru syslog-ng-3.11.1/modules/java/proxies/java-logmsg-proxy.c syslog-ng-3.13.2/modules/java/proxies/java-logmsg-proxy.c --- syslog-ng-3.11.1/modules/java/proxies/java-logmsg-proxy.c 2017-07-31 09:05:32.000000000 +0000 +++ syslog-ng-3.13.2/modules/java/proxies/java-logmsg-proxy.c 2017-12-06 06:39:39.000000000 +0000 @@ -25,6 +25,7 @@ #include "java-logmsg-proxy.h" #include "java_machine.h" #include "messages.h" +#include "str-utils.h" #include "logmsg/logmsg.h" @@ -49,6 +50,7 @@ { LogMessage *msg = (LogMessage *)handle; const gchar *value; + gssize value_len; const char *name_str = (*env)->GetStringUTFChars(env, name, NULL); if (name_str == NULL) @@ -56,12 +58,13 @@ return NULL; } - value = log_msg_get_value_by_name(msg, name_str, NULL); + value = log_msg_get_value_by_name(msg, name_str, &value_len); (*env)->ReleaseStringUTFChars(env, name, name_str); if (value) { + APPEND_ZERO(value, value, value_len); return (*env)->NewStringUTF(env, value); } else @@ -122,7 +125,7 @@ } JavaLogMessageProxy * -java_log_message_proxy_new(LogMessage *msg) +java_log_message_proxy_new(void) { JavaLogMessageProxy *self = g_new0(JavaLogMessageProxy, 1); self->java_machine = java_machine_ref(); diff -Nru syslog-ng-3.11.1/modules/java/proxies/java-logmsg-proxy.h syslog-ng-3.13.2/modules/java/proxies/java-logmsg-proxy.h --- syslog-ng-3.11.1/modules/java/proxies/java-logmsg-proxy.h 2017-07-31 09:05:32.000000000 +0000 +++ syslog-ng-3.13.2/modules/java/proxies/java-logmsg-proxy.h 2017-12-06 06:39:39.000000000 +0000 @@ -31,7 +31,7 @@ typedef struct _JavaLogMessageProxy JavaLogMessageProxy; -JavaLogMessageProxy *java_log_message_proxy_new(); +JavaLogMessageProxy *java_log_message_proxy_new(void); void java_log_message_proxy_free(JavaLogMessageProxy *self); jobject java_log_message_proxy_create_java_object(JavaLogMessageProxy *self, LogMessage *msg); diff -Nru syslog-ng-3.11.1/modules/java/proxies/java-template-proxy.c syslog-ng-3.13.2/modules/java/proxies/java-template-proxy.c --- syslog-ng-3.11.1/modules/java/proxies/java-template-proxy.c 2017-07-31 09:05:32.000000000 +0000 +++ syslog-ng-3.13.2/modules/java/proxies/java-template-proxy.c 2017-12-06 06:39:39.000000000 +0000 @@ -56,14 +56,14 @@ JNIEXPORT jstring JNICALL Java_org_syslog_1ng_LogTemplate_format(JNIEnv *env, jobject obj, jlong template_handle, jlong msg_handle, - jlong logtemplate_options_handle, jint tz) + jlong logtemplate_options_handle, jint tz, jint seqnum) { LogTemplate *template = (LogTemplate *)template_handle; LogTemplateOptions *template_options = (LogTemplateOptions *)logtemplate_options_handle; LogMessage *msg = (LogMessage *)msg_handle; GString *formatted_message = g_string_sized_new(1024); jstring result = NULL; - log_template_format(template, msg, template_options, tz, 0, NULL, formatted_message); + log_template_format(template, msg, template_options, tz, seqnum, NULL, formatted_message); result = (*env)->NewStringUTF(env, formatted_message->str); g_string_free(formatted_message, TRUE); return result; diff -Nru syslog-ng-3.11.1/modules/java/src/main/java/org/syslog_ng/LogDestination.java syslog-ng-3.13.2/modules/java/src/main/java/org/syslog_ng/LogDestination.java --- syslog-ng-3.11.1/modules/java/src/main/java/org/syslog_ng/LogDestination.java 2017-07-31 09:05:32.000000000 +0000 +++ syslog-ng-3.13.2/modules/java/src/main/java/org/syslog_ng/LogDestination.java 2017-12-06 06:39:39.000000000 +0000 @@ -38,6 +38,10 @@ return getTemplateOptionsHandle(getHandle()); } + public int getSeqNum() { + return getSeqNum(getHandle()); + } + protected abstract boolean open(); protected abstract void close(); @@ -50,6 +54,8 @@ private native long getTemplateOptionsHandle(long ptr); + private native int getSeqNum(long ptr); + protected void onMessageQueueEmpty() { return; } diff -Nru syslog-ng-3.11.1/modules/java/src/main/java/org/syslog_ng/LogTemplate.java syslog-ng-3.13.2/modules/java/src/main/java/org/syslog_ng/LogTemplate.java --- syslog-ng-3.11.1/modules/java/src/main/java/org/syslog_ng/LogTemplate.java 2017-07-31 09:05:32.000000000 +0000 +++ syslog-ng-3.13.2/modules/java/src/main/java/org/syslog_ng/LogTemplate.java 2017-12-06 06:39:39.000000000 +0000 @@ -49,7 +49,11 @@ } public String format(LogMessage msg, long logTemplateOptionsHandle, int timezone) { - return format(templateHandle, msg.getHandle(), logTemplateOptionsHandle, timezone); + return format(templateHandle, msg.getHandle(), logTemplateOptionsHandle, timezone, 0); + } + + public String format(LogMessage msg, long logTemplateOptionsHandle, int timezone, int seqnum) { + return format(templateHandle, msg.getHandle(), logTemplateOptionsHandle, timezone, seqnum); } public void release() { @@ -58,6 +62,6 @@ private native long create_new_template_instance(long configHandle); private native boolean compile(long templateHandle, String template); - private native String format(long templateHandle, long msgHandle, long templateOptionsHandle, int timezone); + private native String format(long templateHandle, long msgHandle, long templateOptionsHandle, int timezone, int seqnum); private native void unref(long templateHandle); } diff -Nru syslog-ng-3.11.1/modules/java-modules/elastic-v2/src/main/java/org/syslog_ng/elasticsearch_v2/client/ESClient.java syslog-ng-3.13.2/modules/java-modules/elastic-v2/src/main/java/org/syslog_ng/elasticsearch_v2/client/ESClient.java --- syslog-ng-3.11.1/modules/java-modules/elastic-v2/src/main/java/org/syslog_ng/elasticsearch_v2/client/ESClient.java 2017-07-31 09:05:32.000000000 +0000 +++ syslog-ng-3.13.2/modules/java-modules/elastic-v2/src/main/java/org/syslog_ng/elasticsearch_v2/client/ESClient.java 2017-12-06 06:39:39.000000000 +0000 @@ -33,4 +33,5 @@ void deinit(); boolean send(ESIndex index); String getClusterName(); + void onMessageQueueEmpty(); } diff -Nru syslog-ng-3.11.1/modules/java-modules/elastic-v2/src/main/java/org/syslog_ng/elasticsearch_v2/client/esnative/ESNativeClient.java syslog-ng-3.13.2/modules/java-modules/elastic-v2/src/main/java/org/syslog_ng/elasticsearch_v2/client/esnative/ESNativeClient.java --- syslog-ng-3.11.1/modules/java-modules/elastic-v2/src/main/java/org/syslog_ng/elasticsearch_v2/client/esnative/ESNativeClient.java 2017-07-31 09:05:32.000000000 +0000 +++ syslog-ng-3.13.2/modules/java-modules/elastic-v2/src/main/java/org/syslog_ng/elasticsearch_v2/client/esnative/ESNativeClient.java 2017-12-06 06:39:39.000000000 +0000 @@ -143,4 +143,9 @@ public boolean send(ESIndex index) { return messageProcessor.send(index); } + + @Override + public void onMessageQueueEmpty() { + + } } diff -Nru syslog-ng-3.11.1/modules/java-modules/elastic-v2/src/main/java/org/syslog_ng/elasticsearch_v2/client/http/ESHttpClient.java syslog-ng-3.13.2/modules/java-modules/elastic-v2/src/main/java/org/syslog_ng/elasticsearch_v2/client/http/ESHttpClient.java --- syslog-ng-3.11.1/modules/java-modules/elastic-v2/src/main/java/org/syslog_ng/elasticsearch_v2/client/http/ESHttpClient.java 2017-07-31 09:05:32.000000000 +0000 +++ syslog-ng-3.13.2/modules/java-modules/elastic-v2/src/main/java/org/syslog_ng/elasticsearch_v2/client/http/ESHttpClient.java 2017-12-06 06:39:39.000000000 +0000 @@ -166,4 +166,9 @@ } return clusterName; } + + @Override + public void onMessageQueueEmpty() { + messageProcessor.onMessageQueueEmpty(); + } } diff -Nru syslog-ng-3.11.1/modules/java-modules/elastic-v2/src/main/java/org/syslog_ng/elasticsearch_v2/ElasticSearchDestination.java syslog-ng-3.13.2/modules/java-modules/elastic-v2/src/main/java/org/syslog_ng/elasticsearch_v2/ElasticSearchDestination.java --- syslog-ng-3.11.1/modules/java-modules/elastic-v2/src/main/java/org/syslog_ng/elasticsearch_v2/ElasticSearchDestination.java 2017-07-31 09:05:32.000000000 +0000 +++ syslog-ng-3.13.2/modules/java-modules/elastic-v2/src/main/java/org/syslog_ng/elasticsearch_v2/ElasticSearchDestination.java 2017-12-06 06:39:39.000000000 +0000 @@ -113,4 +113,9 @@ client.deinit(); options.deinit(); } + + @Override + public void onMessageQueueEmpty() { + client.onMessageQueueEmpty(); + } } diff -Nru syslog-ng-3.11.1/modules/java-modules/elastic-v2/src/main/java/org/syslog_ng/elasticsearch_v2/messageprocessor/http/HttpBulkMessageProcessor.java syslog-ng-3.13.2/modules/java-modules/elastic-v2/src/main/java/org/syslog_ng/elasticsearch_v2/messageprocessor/http/HttpBulkMessageProcessor.java --- syslog-ng-3.11.1/modules/java-modules/elastic-v2/src/main/java/org/syslog_ng/elasticsearch_v2/messageprocessor/http/HttpBulkMessageProcessor.java 2017-07-31 09:05:32.000000000 +0000 +++ syslog-ng-3.13.2/modules/java-modules/elastic-v2/src/main/java/org/syslog_ng/elasticsearch_v2/messageprocessor/http/HttpBulkMessageProcessor.java 2017-12-06 06:39:39.000000000 +0000 @@ -72,4 +72,9 @@ messageCounter++; return true; } + + @Override + public void onMessageQueueEmpty() { + flush(); + } } diff -Nru syslog-ng-3.11.1/modules/java-modules/elastic-v2/src/main/java/org/syslog_ng/elasticsearch_v2/messageprocessor/http/HttpMessageProcessor.java syslog-ng-3.13.2/modules/java-modules/elastic-v2/src/main/java/org/syslog_ng/elasticsearch_v2/messageprocessor/http/HttpMessageProcessor.java --- syslog-ng-3.11.1/modules/java-modules/elastic-v2/src/main/java/org/syslog_ng/elasticsearch_v2/messageprocessor/http/HttpMessageProcessor.java 2017-07-31 09:05:32.000000000 +0000 +++ syslog-ng-3.13.2/modules/java-modules/elastic-v2/src/main/java/org/syslog_ng/elasticsearch_v2/messageprocessor/http/HttpMessageProcessor.java 2017-12-06 06:39:39.000000000 +0000 @@ -60,4 +60,8 @@ Index req = new Index.Builder(index.getFormattedMessage()).index(index.getIndex()).type(index.getType()).id(index.getId()).build(); return send(req); } + + public void onMessageQueueEmpty() { + + } } diff -Nru syslog-ng-3.11.1/modules/java-modules/hdfs/src/main/java/org/syslog_ng/hdfs/HdfsDestination.java syslog-ng-3.13.2/modules/java-modules/hdfs/src/main/java/org/syslog_ng/hdfs/HdfsDestination.java --- syslog-ng-3.11.1/modules/java-modules/hdfs/src/main/java/org/syslog_ng/hdfs/HdfsDestination.java 2017-07-31 09:05:32.000000000 +0000 +++ syslog-ng-3.13.2/modules/java-modules/hdfs/src/main/java/org/syslog_ng/hdfs/HdfsDestination.java 2017-12-06 06:39:39.000000000 +0000 @@ -32,30 +32,32 @@ import org.apache.hadoop.fs.FileSystem; import org.apache.hadoop.fs.Path; import org.apache.hadoop.security.UserGroupInformation; -import org.apache.log4j.Level; import org.apache.log4j.Logger; import java.io.IOException; import java.net.URI; -import java.net.URISyntaxException; import java.nio.charset.Charset; -import java.util.Locale; +import java.util.HashMap; +import java.util.Iterator; +import java.util.Map; +import java.util.Map.Entry; import java.util.UUID; -public class HdfsDestination extends TextLogDestination { +public class HdfsDestination extends StructuredLogDestination { private static final String LOG_TAG = "HDFS:"; private static final String HADOOP_SECURITY_AUTH_KEY = "hadoop.security.authentication"; + private static final String DFS_SUPPORT_APPEND_KEY = "dfs.support.append"; HdfsOptions options; Logger logger; private FileSystem hdfs; - private FSDataOutputStream fsDataOutputStream; - - private Path currentFilePath; private boolean isOpened; private int maxFileNameLength = 255; + private boolean appendEnabled; + + HashMap openedFiles; public HdfsDestination(long handle) { super(handle); @@ -67,10 +69,10 @@ @Override public boolean init() { try { - options.init(); - } catch(InvalidOptionException e) { - logger.error(e.getMessage()); - return false; + options.init(); + } catch (InvalidOptionException e) { + logger.error(e.getMessage()); + return false; } return true; } @@ -83,13 +85,18 @@ @Override public boolean open() { logger.debug("Opening hdfs"); + openedFiles = new HashMap(); isOpened = false; + appendEnabled = options.getAppendEnabled(); try { Configuration configuration = new Configuration(); loadConfigResources(configuration); if (isKerberosAuthEnabled()) { setKerberosAuth(configuration); } + if (appendEnabled) { + enableDfsSupportAppend(configuration); + } hdfs = FileSystem.get(new URI(options.getUri()), configuration); hdfs.getStatus(); // Just to be sure we are really connected to hdfs @@ -104,7 +111,7 @@ private void loadConfigResources(Configuration configuration) { String[] resources = options.getResouces(); if (resources == null) { - return; + return; } for (int i = 0; i < resources.length; i++) { String resource = resources[i]; @@ -124,16 +131,20 @@ } @Override - public boolean send(String message) { + public boolean send(LogMessage logMessage) { isOpened = false; - - if (!ensureDataOutputStream()) { + String resolvedFileName = options.getFileNameTemplate().getResolvedString(logMessage); + FSDataOutputStream fsDataOutputStream = getFSDataOutputStream(resolvedFileName); + if (fsDataOutputStream == null) { + // Unable to open file + closeAll(options.getArchiveDir() != null); return false; } try { - logger.debug("Outgoing message: " + message); - fsDataOutputStream.write(message.getBytes(Charset.forName("UTF-8"))); + String formattedMessage = options.getTemplate().getResolvedString(logMessage); + logger.debug("Outgoing message: " + formattedMessage); + fsDataOutputStream.write(formattedMessage.getBytes(Charset.forName("UTF-8"))); } catch (IOException e) { printStackTrace(e); closeAll(false); @@ -144,70 +155,84 @@ return true; } - private String truncateFileName(String fileName, int maxLength) { - if (fileName.length() > maxLength) { - return fileName.substring(0, maxLength); + private FSDataOutputStream getFSDataOutputStream(String resolvedFileName) { + HdfsFile hdfsFile = openedFiles.get(resolvedFileName); + if (hdfsFile == null) { + hdfsFile = createHdfsFile(resolvedFileName); + openedFiles.put(resolvedFileName, hdfsFile); } - return fileName; + return hdfsFile.getFsDataOutputStream(); } - private boolean ensureDataOutputStream() { - if (fsDataOutputStream == null) { - // file not yet opened - String currentFile = String.format("%s.%s", options.getFile(), UUID.randomUUID()); - currentFilePath = new Path(String.format("%s/%s", options.getUri(), currentFile)); + private HdfsFile createHdfsFile(String resolvedFileName) { + HdfsFile hdfsFile = new HdfsFile(); + Path filePath = getFilePath(resolvedFileName); + hdfsFile.setPath(filePath); + hdfsFile.setFsDataOutputStream(createFsDataOutputStream(hdfs, filePath)); + return hdfsFile; + } - if (currentFilePath.getName().length() > options.getMaxFilenameLength()) { - String fileName = truncateFileName(currentFilePath.getName(), options.getMaxFilenameLength()); - logger.debug(String.format("Maximum file name length (%s) exceeded, truncated to %s", maxFileNameLength, fileName)); + private Path getFilePath(String resolvedFileName) { + if (!appendEnabled) { + // when append is not enabled, we create a unique filename for every file + resolvedFileName = String.format("%s.%s", resolvedFileName, UUID.randomUUID()); + } + Path filePath = new Path(String.format("%s/%s", options.getUri(), resolvedFileName)); - currentFilePath = new Path(currentFilePath.getParent(), fileName); - } + if (filePath.getName().length() > options.getMaxFilenameLength()) { + String fileName = truncateFileName(filePath.getName(), options.getMaxFilenameLength()); + logger.debug(String.format("Maximum file name length (%s) exceeded, truncated to %s", maxFileNameLength, + fileName)); + filePath = new Path(filePath.getParent(), fileName); + } + return filePath; + } - fsDataOutputStream = getFsDataOutputStream(hdfs, currentFilePath); - if (fsDataOutputStream == null) { - closeAll(false); - return false; - } + private String truncateFileName(String fileName, int maxLength) { + if (fileName.length() > maxLength) { + return fileName.substring(0, maxLength); } - return true; + return fileName; } - private FSDataOutputStream getFsDataOutputStream(FileSystem hdfs, Path file) { + private FSDataOutputStream createFsDataOutputStream(FileSystem hdfs, Path file) { FSDataOutputStream fsDataOutputStream = null; try { - fsDataOutputStream = createFile(file); + hdfs.mkdirs(file.getParent()); + if (appendEnabled && hdfs.exists(file)) { + logger.debug(String.format("Appending file %s", file.toString())); + fsDataOutputStream = hdfs.append(file); + } else { + logger.debug(String.format("Creating file %s", file.toString())); + fsDataOutputStream = hdfs.create(file); + } } catch (IOException e) { printStackTrace(e); } return fsDataOutputStream; } - private FSDataOutputStream createFile(Path file) throws IOException { - logger.debug(String.format("Creating file %s", file.toString())); - hdfs.mkdirs(file.getParent()); - FSDataOutputStream fsDataOutputStream = hdfs.create(file); - return fsDataOutputStream; - } - - @SuppressWarnings("unused") - private boolean isDfsSupportAppendEnabled(FileSystem hdfs) { - // This is for future usage when we enable append - return Boolean.valueOf(hdfs.getConf().get("dfs.support.append")); + private void enableDfsSupportAppend(Configuration configuration) { + configuration.setBoolean(DFS_SUPPORT_APPEND_KEY, true); } @Override public void onMessageQueueEmpty() { - if (fsDataOutputStream != null) { - try { - // Trying to flush however the effect is - // questionable... (It is not guaranteed that data has been - // flushed to persistent store on the datanode) - logger.debug("Flushing hdfs"); - fsDataOutputStream.hflush(); - fsDataOutputStream.hsync(); - } catch (IOException e) { - logger.debug(String.format("Flush failed, reason: %s", e.getMessage())); + /* + * Trying to flush however the effect is questionable... (It is not guaranteed + * that data has been flushed to persistent store on the datanode) + */ + + logger.debug("Flushing hdfs"); + for (Map.Entry entry : openedFiles.entrySet()) { + FSDataOutputStream outputStream = entry.getValue().getFsDataOutputStream(); + if (outputStream != null) { + try { + outputStream.hflush(); + outputStream.hsync(); + } catch (IOException e) { + logger.debug(String.format("Flush failed on file %s, reason: %s", entry.getKey(), e.getMessage())); + } } } } @@ -220,24 +245,28 @@ } private void closeAll(boolean isArchiving) { - closeDataOutputStream(); + closeDataOutputStreams(); if (isArchiving) { - archiveFile(); + archiveFiles(); } closeHdfs(); isOpened = false; } - private void closeDataOutputStream() { - if (fsDataOutputStream != null) { - try { - fsDataOutputStream.close(); - } catch (IOException e) { - fsDataOutputStream = null; - printStackTrace(e); + private void closeDataOutputStreams() { + for (Map.Entry entry : openedFiles.entrySet()) { + FSDataOutputStream outputStream = entry.getValue().getFsDataOutputStream(); + if (outputStream != null) { + try { + logger.debug(String.format("Closing file: %s", entry.getKey())); + outputStream.close(); + } catch (IOException e) { + printStackTrace(e); + } } + entry.getValue().setFsDataOutputStream(null); } } @@ -252,15 +281,18 @@ } } - private void archiveFile() { - if (options.getArchiveDir() != null && currentFilePath != null) { - logger.debug(String.format("Trying to archive %s to %s", currentFilePath.getName(), options.getArchiveDir())); - Path archiveDirPath = new Path(String.format("%s/%s", options.getUri(), options.getArchiveDir())); - try { - hdfs.mkdirs(archiveDirPath); - hdfs.rename(currentFilePath, archiveDirPath); - } catch (IOException e) { - logger.debug(String.format("Unable to archive, reason: %s", e.getMessage())); + private void archiveFiles() { + if (options.getArchiveDir() != null) { + for (Map.Entry entry : openedFiles.entrySet()) { + Path filePath = entry.getValue().getPath(); + logger.debug(String.format("Trying to archive %s to %s", filePath.getName(), options.getArchiveDir())); + Path archiveDirPath = new Path(String.format("%s/%s", options.getUri(), options.getArchiveDir())); + try { + hdfs.mkdirs(archiveDirPath); + hdfs.rename(filePath, archiveDirPath); + } catch (IOException e) { + logger.debug(String.format("Unable to archive, reason: %s", e.getMessage())); + } } } @@ -273,7 +305,7 @@ @Override public String getNameByUniqOptions() { - return String.format("hdfs,%s,%s", options.getUri(), options.getFile()); + return String.format("hdfs,%s,%s", options.getUri(), options.getFileNameTemplate().getValue()); } @Override @@ -281,4 +313,5 @@ logger.debug("Deinitialize hdfs destination"); options.deinit(); } + } diff -Nru syslog-ng-3.11.1/modules/java-modules/hdfs/src/main/java/org/syslog_ng/hdfs/HdfsFile.java syslog-ng-3.13.2/modules/java-modules/hdfs/src/main/java/org/syslog_ng/hdfs/HdfsFile.java --- syslog-ng-3.11.1/modules/java-modules/hdfs/src/main/java/org/syslog_ng/hdfs/HdfsFile.java 1970-01-01 00:00:00.000000000 +0000 +++ syslog-ng-3.13.2/modules/java-modules/hdfs/src/main/java/org/syslog_ng/hdfs/HdfsFile.java 2017-12-06 06:39:39.000000000 +0000 @@ -0,0 +1,48 @@ +/* + * Copyright (c) 2017 Balabit + * Copyright (c) 2017 Zoltan Pallagi + * + * This program is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 as published + * by the Free Software Foundation, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + * + * As an additional exemption you are allowed to compile & link against the + * OpenSSL libraries as published by the OpenSSL project. See the file + * COPYING for details. + * + */ + +package org.syslog_ng.hdfs; + +import org.apache.hadoop.fs.FSDataOutputStream; +import org.apache.hadoop.fs.Path; + +public class HdfsFile { + private FSDataOutputStream fsDataOutputStream; + private Path path; + + public FSDataOutputStream getFsDataOutputStream() { + return fsDataOutputStream; + } + + public void setFsDataOutputStream(FSDataOutputStream fsDataOutputStream) { + this.fsDataOutputStream = fsDataOutputStream; + } + + public Path getPath() { + return path; + } + + public void setPath(Path path) { + this.path = path; + } +} diff -Nru syslog-ng-3.11.1/modules/java-modules/hdfs/src/main/java/org/syslog_ng/hdfs/HdfsOptions.java syslog-ng-3.13.2/modules/java-modules/hdfs/src/main/java/org/syslog_ng/hdfs/HdfsOptions.java --- syslog-ng-3.11.1/modules/java-modules/hdfs/src/main/java/org/syslog_ng/hdfs/HdfsOptions.java 2017-07-31 09:05:32.000000000 +0000 +++ syslog-ng-3.13.2/modules/java-modules/hdfs/src/main/java/org/syslog_ng/hdfs/HdfsOptions.java 2017-12-06 06:39:39.000000000 +0000 @@ -31,76 +31,99 @@ public class HdfsOptions { - public static String URI = "hdfs_uri"; - public static String FILE = "hdfs_file"; - public static String ARCHIVE_DIR = "hdfs_archive_dir"; - public static String RESOURCES = "hdfs_resources"; - public static String MAX_FILENAME_LENGTH = "hdfs_max_filename_length"; - public static String MAX_FILENAME_LENGTH_DEFAULT = "255"; - public static String KERBEROS_PRINCIPAL = "kerberos_principal"; - public static String KERBEROS_KEYTAB_FILE = "kerberos_keytab_file"; - - private LogDestination owner; - private Options options; - - public HdfsOptions(LogDestination owner) { - this.owner = owner; - options = new Options(); - fillOptions(); - } - - public void init() throws InvalidOptionException { - options.validate(); - } - - public void deinit() { - options.deinit(); - } - - public Option getOption(String optionName) { - return options.get(optionName); - } - - public String getUri() { - return options.get(URI).getValue(); - } - - public String getFile() { - return options.get(FILE).getValue(); - } - - public String getArchiveDir() { - return options.get(ARCHIVE_DIR).getValue(); - } - - public String[] getResouces() { - return options.get(RESOURCES).getValueAsStringList(";"); - } - - public int getMaxFilenameLength() { - return options.get(MAX_FILENAME_LENGTH).getValueAsInteger(); - } - - public String getKerberosPrincipal() { - return options.get(KERBEROS_PRINCIPAL).getValue(); - } - - public String getKerberosKeytabFile() { - return options.get(KERBEROS_KEYTAB_FILE).getValue(); - } - - private void fillOptions() { - fillStringOptions(); - } - - private void fillStringOptions() { - options.put(new RequiredOptionDecorator(new StringOption(owner, URI))); - options.put(new RequiredOptionDecorator(new StringOption(owner, FILE))); - options.put(new StringOption(owner, ARCHIVE_DIR)); - options.put(new StringOption(owner, RESOURCES)); - options.put(new StringOption(owner, MAX_FILENAME_LENGTH, MAX_FILENAME_LENGTH_DEFAULT)); - options.put(new StringOption(owner, KERBEROS_PRINCIPAL)); - options.put(new StringOption(owner, KERBEROS_KEYTAB_FILE)); - } + public static String URI = "hdfs_uri"; + public static String FILE = "hdfs_file"; + public static String ARCHIVE_DIR = "hdfs_archive_dir"; + public static String RESOURCES = "hdfs_resources"; + public static String MAX_FILENAME_LENGTH = "hdfs_max_filename_length"; + public static String MAX_FILENAME_LENGTH_DEFAULT = "255"; + public static String KERBEROS_PRINCIPAL = "kerberos_principal"; + public static String KERBEROS_KEYTAB_FILE = "kerberos_keytab_file"; + public static String TEMPLATE = "template"; + public static String TEMPLATE_DEFAULT = "${ISODATE} ${HOST} ${MSGHDR}${MSG}\n"; + public static String APPEND_ENABLED = "hdfs_append_enabled"; + public static String APPEND_ENABLED_DEFAULT = "false"; + + private LogDestination owner; + private Options options; + + public HdfsOptions(LogDestination owner) { + this.owner = owner; + options = new Options(); + fillOptions(); + fillTemplateOptions(); + } + + public void init() throws InvalidOptionException { + options.validate(); + } + + public void deinit() { + options.deinit(); + } + + public Option getOption(String optionName) { + return options.get(optionName); + } + + public String getUri() { + return options.get(URI).getValue(); + } + + public String getArchiveDir() { + return options.get(ARCHIVE_DIR).getValue(); + } + + public String[] getResouces() { + return options.get(RESOURCES).getValueAsStringList(";"); + } + + public int getMaxFilenameLength() { + return options.get(MAX_FILENAME_LENGTH).getValueAsInteger(); + } + + public String getKerberosPrincipal() { + return options.get(KERBEROS_PRINCIPAL).getValue(); + } + + public String getKerberosKeytabFile() { + return options.get(KERBEROS_KEYTAB_FILE).getValue(); + } + + public TemplateOption getTemplate() { + return options.getTemplateOption(TEMPLATE); + } + + public TemplateOption getFileNameTemplate() { + return options.getTemplateOption(FILE); + } + + private void fillOptions() { + fillStringOptions(); + fillBooleanOptions(); + } + + public boolean getAppendEnabled() { + return options.get(APPEND_ENABLED).getValueAsBoolean(); + } + + private void fillStringOptions() { + options.put(new RequiredOptionDecorator(new StringOption(owner, URI))); + options.put(new StringOption(owner, ARCHIVE_DIR)); + options.put(new StringOption(owner, RESOURCES)); + options.put(new StringOption(owner, MAX_FILENAME_LENGTH, MAX_FILENAME_LENGTH_DEFAULT)); + options.put(new StringOption(owner, KERBEROS_PRINCIPAL)); + options.put(new StringOption(owner, KERBEROS_KEYTAB_FILE)); + } + + private void fillBooleanOptions() { + options.put(new BooleanOptionDecorator(new StringOption(owner, APPEND_ENABLED, APPEND_ENABLED_DEFAULT))); + } + + private void fillTemplateOptions() { + options.put(new TemplateOption(owner.getConfigHandle(), new StringOption(owner, TEMPLATE, TEMPLATE_DEFAULT))); + options.put(new TemplateOption(owner.getConfigHandle(), + new RequiredOptionDecorator(new StringOption(owner, FILE)))); + } } diff -Nru syslog-ng-3.11.1/modules/java-modules/Makefile.am syslog-ng-3.13.2/modules/java-modules/Makefile.am --- syslog-ng-3.11.1/modules/java-modules/Makefile.am 2017-07-31 09:05:32.000000000 +0000 +++ syslog-ng-3.13.2/modules/java-modules/Makefile.am 2017-12-06 06:39:39.000000000 +0000 @@ -87,6 +87,7 @@ modules/java-modules/common/src/test/java/org/syslog_ng/logging/test/MockLogDestination.java \ modules/java-modules/hdfs/src/main/java/org/syslog_ng/hdfs/HdfsDestination.java \ modules/java-modules/hdfs/src/main/java/org/syslog_ng/hdfs/HdfsOptions.java \ + modules/java-modules/hdfs/src/main/java/org/syslog_ng/hdfs/HdfsFile.java \ modules/java-modules/http/src/main/java/org/syslog_ng/http/HTTPDestination.java \ modules/java-modules/http/src/main/java/org/syslog_ng/http/HTTPDestinationOptions.java \ modules/java-modules/dummy/src/main/java/org/syslog_ng/DummyTextDestination.java \ diff -Nru syslog-ng-3.11.1/modules/json/format-json.c syslog-ng-3.13.2/modules/json/format-json.c --- syslog-ng-3.11.1/modules/json/format-json.c 2017-07-31 09:05:32.000000000 +0000 +++ syslog-ng-3.13.2/modules/json/format-json.c 2017-12-06 06:39:39.000000000 +0000 @@ -38,21 +38,48 @@ } TFJsonState; static gboolean +_parse_additional_options(gint argc, gchar **argv, gboolean *transform_initial_dot, GError **error) +{ + *transform_initial_dot = TRUE; + for (gint i = 1; i < argc; i++) + { + if (argv[i][0] != '-') + continue; + + if (strcmp(argv[i], "--leave-initial-dot") == 0) + *transform_initial_dot = FALSE; + else + { + g_set_error(error, G_OPTION_ERROR, G_OPTION_ERROR_UNKNOWN_OPTION, "$(format-json) unknown option: %s", argv[i]); + return FALSE; + } + } + return TRUE; +} + +static gboolean tf_json_prepare(LogTemplateFunction *self, gpointer s, LogTemplate *parent, gint argc, gchar *argv[], GError **error) { TFJsonState *state = (TFJsonState *)s; ValuePairsTransformSet *vpts; + gboolean transform_initial_dot; - state->vp = value_pairs_new_from_cmdline (parent->cfg, argc, argv, error); + state->vp = value_pairs_new_from_cmdline (parent->cfg, &argc, &argv, TRUE, error); if (!state->vp) return FALSE; - /* Always replace a leading dot with an underscore. */ - vpts = value_pairs_transform_set_new(".*"); - value_pairs_transform_set_add_func(vpts, value_pairs_new_transform_replace_prefix(".", "_")); - value_pairs_add_transforms(state->vp, vpts); + if (!_parse_additional_options(argc, argv, &transform_initial_dot, error)) + return FALSE; + + if (transform_initial_dot) + { + /* Always replace a leading dot with an underscore. */ + vpts = value_pairs_transform_set_new(".*"); + value_pairs_transform_set_add_func(vpts, value_pairs_new_transform_replace_prefix(".", "_")); + value_pairs_add_transforms(state->vp, vpts); + } return TRUE; } diff -Nru syslog-ng-3.11.1/modules/json/json-parser-parser.h syslog-ng-3.13.2/modules/json/json-parser-parser.h --- syslog-ng-3.11.1/modules/json/json-parser-parser.h 2017-07-31 09:05:32.000000000 +0000 +++ syslog-ng-3.13.2/modules/json/json-parser-parser.h 2017-12-06 06:39:39.000000000 +0000 @@ -24,7 +24,6 @@ #define JSONPARSER_PARSER_H_INCLUDED #include "cfg-parser.h" -#include "cfg-lexer.h" #include "parser/parser-expr.h" extern CfgParser json_parser_parser; diff -Nru syslog-ng-3.11.1/modules/json/json-plugin.c syslog-ng-3.13.2/modules/json/json-plugin.c --- syslog-ng-3.11.1/modules/json/json-plugin.c 2017-07-31 09:05:32.000000000 +0000 +++ syslog-ng-3.13.2/modules/json/json-plugin.c 2017-12-06 06:39:39.000000000 +0000 @@ -38,9 +38,9 @@ }; gboolean -json_plugin_module_init(GlobalConfig *cfg, CfgArgs *args) +json_plugin_module_init(PluginContext *context, CfgArgs *args) { - plugin_register(cfg, json_plugins, G_N_ELEMENTS(json_plugins)); + plugin_register(context, json_plugins, G_N_ELEMENTS(json_plugins)); return TRUE; } diff -Nru syslog-ng-3.11.1/modules/json/tests/test_format_json.c syslog-ng-3.13.2/modules/json/tests/test_format_json.c --- syslog-ng-3.11.1/modules/json/tests/test_format_json.c 2017-07-31 09:05:32.000000000 +0000 +++ syslog-ng-3.13.2/modules/json/tests/test_format_json.c 2017-12-06 06:39:39.000000000 +0000 @@ -50,7 +50,7 @@ "{\"sdata\":{\"win@18372.4\":{\"taste\":\"good\",\"fruit\":\"pear\"}}}"); assert_template_format("$(format-json --scope selected_macros)", - "{\"TAGS\":\"alma,korte,citrom\",\"SOURCEIP\":\"10.11.12.13\",\"SEQNUM\":\"999\",\"PROGRAM\":\"syslog-ng\",\"PRIORITY\":\"err\",\"PID\":\"23323\",\"MESSAGE\":\"árvíztűrőtükörfúrógép\",\"HOST\":\"bzorp\",\"FACILITY\":\"local3\",\"DATE\":\"Feb 11 10:34:56\"}"); + "{\"TAGS\":\"alma,korte,citrom,\\\"tag,containing,comma\\\"\",\"SOURCEIP\":\"10.11.12.13\",\"SEQNUM\":\"999\",\"PROGRAM\":\"syslog-ng\",\"PRIORITY\":\"err\",\"PID\":\"23323\",\"MESSAGE\":\"árvíztűrőtükörfúrógép\",\"HOST\":\"bzorp\",\"FACILITY\":\"local3\",\"DATE\":\"Feb 11 10:34:56\"}"); assert_template_format("$(format-json --scope rfc3164 --key *.*)", "{\"_unix\":{\"uid\":\"1000\",\"gid\":\"1000\",\"cmd\":\"command\"},\"_json\":{\"sub\":{\"value2\":\"subvalue2\",\"value1\":\"subvalue1\"},\"foo\":\"bar\"},\"PROGRAM\":\"syslog-ng\",\"PRIORITY\":\"err\",\"PID\":\"23323\",\"MESSAGE\":\"árvíztűrőtükörfúrógép\",\"HOST\":\"bzorp\",\"FACILITY\":\"local3\",\"DATE\":\"Feb 11 10:34:56\",\"APP\":{\"VALUE7\":\"value\",\"VALUE6\":\"value\",\"VALUE5\":\"value\",\"VALUE4\":\"value\",\"VALUE3\":\"value\",\"VALUE2\":\"value\",\"VALUE\":\"value\",\"STRIP5\":\"\",\"STRIP4\":\"value\",\"STRIP3\":\" value \",\"STRIP2\":\"value \",\"STRIP1\":\" value\",\"QVALUE\":\"\\\"value\\\"\"}}"); @@ -63,6 +63,10 @@ assert_template_format("$(format-json @.program=${PROGRAM})", "{\"@\":{\"program\":\"syslog-ng\"}}"); assert_template_format("$(format-json .program.n@me=${PROGRAM})", "{\"_program\":{\"n@me\":\"syslog-ng\"}}"); assert_template_format("$(format-json .program.@name=${PROGRAM})", "{\"_program\":{\"@name\":\"syslog-ng\"}}"); + assert_template_format("$(format-json --leave-initial-dot .program.@name=${PROGRAM})", + "{\".program\":{\"@name\":\"syslog-ng\"}}"); + assert_template_format("$(format-json --leave-initial-dot .program.@name=${PROGRAM} .program.foo .program.bar)", + "{\".program\":{\"@name\":\"syslog-ng\"}}"); } void @@ -75,7 +79,7 @@ "{\"MESSAGE\":\"árvíztűrőtükörfúrógép\",\"HOST\":\"bzorp\"}"); assert_template_format("$(format-json --scope selected-macros --key MSG)", - "{\"TAGS\":\"alma,korte,citrom\",\"SOURCEIP\":\"10.11.12.13\",\"SEQNUM\":\"999\",\"PROGRAM\":\"syslog-ng\",\"PRIORITY\":\"err\",\"PID\":\"23323\",\"MSG\":\"árvíztűrőtükörfúrógép\",\"MESSAGE\":\"árvíztűrőtükörfúrógép\",\"HOST\":\"bzorp\",\"FACILITY\":\"local3\",\"DATE\":\"Feb 11 10:34:56\"}"); + "{\"TAGS\":\"alma,korte,citrom,\\\"tag,containing,comma\\\"\",\"SOURCEIP\":\"10.11.12.13\",\"SEQNUM\":\"999\",\"PROGRAM\":\"syslog-ng\",\"PRIORITY\":\"err\",\"PID\":\"23323\",\"MSG\":\"árvíztűrőtükörfúrógép\",\"MESSAGE\":\"árvíztűrőtükörfúrógép\",\"HOST\":\"bzorp\",\"FACILITY\":\"local3\",\"DATE\":\"Feb 11 10:34:56\"}"); assert_template_format("$(format-json --key MSG)", "{\"MSG\":\"árvíztűrőtükörfúrógép\"}"); assert_template_format("$(format-json --key DATE)", "{\"DATE\":\"Feb 11 10:34:56\"}"); @@ -158,6 +162,13 @@ "--exclude .SDATA.* " "..RSTAMP='${R_UNIXTIME}${R_TZ}' " "..TAGS=${TAGS})\n"); + perftest_template("<$PRI>1 $ISODATE $LOGHOST @syslog-ng - - ${SDATA:--} $(format-json --leave-initial-dot --scope all-nv-pairs " + "--exclude 0* --exclude 1* --exclude 2* --exclude 3* --exclude 4* --exclude 5* " + "--exclude 6* --exclude 7* --exclude 8* --exclude 9* " + "--exclude SOURCE " + "--exclude .SDATA.* " + "..RSTAMP='${R_UNIXTIME}${R_TZ}' " + "..TAGS=${TAGS})\n"); } int @@ -167,7 +178,7 @@ putenv("TZ=UTC"); tzset(); init_template_tests(); - plugin_load_module("json-plugin", configuration, NULL); + cfg_load_module(configuration, "json-plugin"); test_format_json(); test_format_json_key(); diff -Nru syslog-ng-3.11.1/modules/kvformat/format-welf.c syslog-ng-3.13.2/modules/kvformat/format-welf.c --- syslog-ng-3.11.1/modules/kvformat/format-welf.c 2017-07-31 09:05:32.000000000 +0000 +++ syslog-ng-3.13.2/modules/kvformat/format-welf.c 2017-12-06 06:39:39.000000000 +0000 @@ -30,6 +30,12 @@ ValuePairs *vp; } TFWelfState; +typedef struct _TFWelfIterState +{ + GString *result; + gboolean initial_kv_pair_printed; +} TFWelfIterState; + static gboolean tf_format_welf_prepare(LogTemplateFunction *self, gpointer s, LogTemplate *parent, gint argc, gchar *argv[], @@ -37,7 +43,7 @@ { TFWelfState *state = (TFWelfState *) s; - state->vp = value_pairs_new_from_cmdline (parent->cfg, argc, argv, error); + state->vp = value_pairs_new_from_cmdline (parent->cfg, &argc, &argv, FALSE, error); if (!state->vp) return FALSE; @@ -48,10 +54,14 @@ tf_format_welf_foreach(const gchar *name, TypeHint type, const gchar *value, gsize value_len, gpointer user_data) { - GString *result = (GString *) user_data; + TFWelfIterState *iter_state = (TFWelfIterState *) user_data; + GString *result = iter_state->result; - if (result->len > 0) + if (iter_state->initial_kv_pair_printed) g_string_append(result, " "); + else + iter_state->initial_kv_pair_printed = TRUE; + g_string_append(result, name); g_string_append_c(result, '='); if (memchr(value, ' ', value_len) == NULL) @@ -79,13 +89,18 @@ tf_format_welf_call(LogTemplateFunction *self, gpointer s, const LogTemplateInvokeArgs *args, GString *result) { TFWelfState *state = (TFWelfState *) s; + TFWelfIterState iter_state = + { + .result = result, + .initial_kv_pair_printed = FALSE + }; gint i; for (i = 0; i < args->num_messages; i++) { value_pairs_foreach_sorted(state->vp, tf_format_welf_foreach, (GCompareFunc) tf_format_welf_strcmp, - args->messages[i], 0, args->tz, args->opts, result); + args->messages[i], 0, args->tz, args->opts, &iter_state); } } diff -Nru syslog-ng-3.11.1/modules/kvformat/kvformat-plugin.c syslog-ng-3.13.2/modules/kvformat/kvformat-plugin.c --- syslog-ng-3.11.1/modules/kvformat/kvformat-plugin.c 2017-07-31 09:05:32.000000000 +0000 +++ syslog-ng-3.13.2/modules/kvformat/kvformat-plugin.c 2017-12-06 06:39:39.000000000 +0000 @@ -42,9 +42,9 @@ }; gboolean -kvformat_module_init(GlobalConfig *cfg, CfgArgs *args) +kvformat_module_init(PluginContext *context, CfgArgs *args) { - plugin_register(cfg, kvformat_plugins, G_N_ELEMENTS(kvformat_plugins)); + plugin_register(context, kvformat_plugins, G_N_ELEMENTS(kvformat_plugins)); return TRUE; } diff -Nru syslog-ng-3.11.1/modules/kvformat/kv-parser.c syslog-ng-3.13.2/modules/kvformat/kv-parser.c --- syslog-ng-3.11.1/modules/kvformat/kv-parser.c 2017-07-31 09:05:32.000000000 +0000 +++ syslog-ng-3.13.2/modules/kvformat/kv-parser.c 2017-12-06 06:39:39.000000000 +0000 @@ -87,28 +87,37 @@ return self->formatted_key->str; } +void +kv_parser_init_scanner_method(KVParser *self, KVScanner *kv_scanner) +{ + kv_scanner_init(kv_scanner, self->value_separator, self->pair_separator, self->stray_words_value_name != NULL); +} + static gboolean _process(LogParser *s, LogMessage **pmsg, const LogPathOptions *path_options, const gchar *input, gsize input_len) { KVParser *self = (KVParser *) s; + KVScanner kv_scanner; + kv_parser_init_scanner(self, &kv_scanner); log_msg_make_writable(pmsg, path_options); /* FIXME: input length */ - kv_scanner_input(self->kv_scanner, input); - while (kv_scanner_scan_next(self->kv_scanner)) + kv_scanner_input(&kv_scanner, input); + while (kv_scanner_scan_next(&kv_scanner)) { /* FIXME: value length */ log_msg_set_value_by_name(*pmsg, - _get_formatted_key(self, kv_scanner_get_current_key(self->kv_scanner)), - kv_scanner_get_current_value(self->kv_scanner), -1); + _get_formatted_key(self, kv_scanner_get_current_key(&kv_scanner)), + kv_scanner_get_current_value(&kv_scanner), -1); } if (self->stray_words_value_name) log_msg_set_value_by_name(*pmsg, self->stray_words_value_name, - kv_scanner_get_stray_words(self->kv_scanner), -1); + kv_scanner_get_stray_words(&kv_scanner), -1); + kv_scanner_deinit(&kv_scanner); return TRUE; } @@ -121,9 +130,6 @@ kv_parser_set_pair_separator(&dst->super, src->pair_separator); kv_parser_set_stray_words_value_name(&dst->super, src->stray_words_value_name); - if (src->kv_scanner) - dst->kv_scanner = kv_scanner_clone(src->kv_scanner); - return &dst->super.super; } @@ -141,55 +147,19 @@ { KVParser *self = (KVParser *)s; - kv_scanner_free(self->kv_scanner); g_string_free(self->formatted_key, TRUE); g_free(self->prefix); g_free(self->pair_separator); log_parser_free_method(s); } -static gboolean -_process_threaded(LogParser *s, LogMessage **pmsg, const LogPathOptions *path_options, const gchar *input, - gsize input_len) -{ - LogParser *self = (LogParser *)log_pipe_clone(&s->super); - - gboolean ok = _process(self, pmsg, path_options, input, input_len); - - log_pipe_unref(&self->super); - return ok; -} - -gboolean -kv_parser_init_method(LogPipe *s) -{ - KVParser *self = (KVParser *)s; - g_assert(self->kv_scanner == NULL); - - self->kv_scanner = kv_scanner_new(self->value_separator, self->pair_separator, self->stray_words_value_name != NULL); - - return log_parser_init_method(s); -} - -gboolean -kv_parser_deinit_method(LogPipe *s) -{ - KVParser *self = (KVParser *)s; - - kv_scanner_free(self->kv_scanner); - self->kv_scanner = NULL; - return TRUE; -} - void kv_parser_init_instance(KVParser *self, GlobalConfig *cfg) { log_parser_init_instance(&self->super, cfg); - self->super.super.init = kv_parser_init_method; - self->super.super.deinit = kv_parser_deinit_method; self->super.super.free_fn = _free; - self->super.process = _process_threaded; - self->kv_scanner = NULL; + self->super.process = _process; + self->init_scanner = kv_parser_init_scanner_method; self->value_separator = '='; self->pair_separator = g_strdup(", "); self->formatted_key = g_string_sized_new(32); diff -Nru syslog-ng-3.11.1/modules/kvformat/kv-parser.h syslog-ng-3.13.2/modules/kvformat/kv-parser.h --- syslog-ng-3.11.1/modules/kvformat/kv-parser.h 2017-07-31 09:05:32.000000000 +0000 +++ syslog-ng-3.13.2/modules/kvformat/kv-parser.h 2017-12-06 06:39:39.000000000 +0000 @@ -26,7 +26,8 @@ #include "scanner/kv-scanner/kv-scanner.h" /* base class */ -typedef struct _KVParser +typedef struct _KVParser KVParser; +struct _KVParser { LogParser super; gchar value_separator; @@ -35,8 +36,14 @@ gchar *stray_words_value_name; gsize prefix_len; GString *formatted_key; - KVScanner *kv_scanner; -} KVParser; + void (*init_scanner)(KVParser *self, KVScanner *kv_scanner); +}; + +static inline void +kv_parser_init_scanner(KVParser *self, KVScanner *kv_scanner) +{ + self->init_scanner(self, kv_scanner); +} void kv_parser_set_prefix(LogParser *p, const gchar *prefix); void kv_parser_set_value_separator(LogParser *p, gchar value_separator); @@ -44,6 +51,8 @@ void kv_parser_set_stray_words_value_name(LogParser *s, const gchar *value_name); gboolean kv_parser_is_valid_separator_character(gchar c); +void kv_parser_init_scanner_method(KVParser *self, KVScanner *kv_scanner); + gboolean kv_parser_init_method(LogPipe *s); gboolean kv_parser_deinit_method(LogPipe *s); LogPipe *kv_parser_clone_method(KVParser *dst, KVParser *src); diff -Nru syslog-ng-3.11.1/modules/kvformat/kv-parser-parser.h syslog-ng-3.13.2/modules/kvformat/kv-parser-parser.h --- syslog-ng-3.11.1/modules/kvformat/kv-parser-parser.h 2017-07-31 09:05:32.000000000 +0000 +++ syslog-ng-3.13.2/modules/kvformat/kv-parser-parser.h 2017-12-06 06:39:39.000000000 +0000 @@ -23,7 +23,6 @@ #define KVPARSER_PARSER_H_INCLUDED #include "cfg-parser.h" -#include "cfg-lexer.h" #include "parser/parser-expr.h" extern CfgParser kv_parser_parser; diff -Nru syslog-ng-3.11.1/modules/kvformat/linux-audit-parser.c syslog-ng-3.13.2/modules/kvformat/linux-audit-parser.c --- syslog-ng-3.11.1/modules/kvformat/linux-audit-parser.c 2017-07-31 09:05:32.000000000 +0000 +++ syslog-ng-3.13.2/modules/kvformat/linux-audit-parser.c 2017-12-06 06:39:39.000000000 +0000 @@ -133,17 +133,11 @@ return FALSE; } -static gboolean -_init(LogPipe *s) +static void +_init_scanner(KVParser *self, KVScanner *kv_scanner) { - KVParser *self = (KVParser *) s; - - g_assert(self->kv_scanner == NULL); - if (!kv_parser_init_method(s)) - return FALSE; - kv_scanner_set_transform_value(self->kv_scanner, parse_linux_audit_style_hexdump); - - return TRUE; + kv_parser_init_scanner_method(self, kv_scanner); + kv_scanner_set_transform_value(kv_scanner, parse_linux_audit_style_hexdump); } static LogPipe * @@ -161,8 +155,7 @@ KVParser *self = g_new0(KVParser, 1); kv_parser_init_instance(self, cfg); - self->super.super.init = _init; self->super.super.clone = _clone; - + self->init_scanner = _init_scanner; return &self->super; } diff -Nru syslog-ng-3.11.1/modules/kvformat/tests/test_format_welf.c syslog-ng-3.13.2/modules/kvformat/tests/test_format_welf.c --- syslog-ng-3.11.1/modules/kvformat/tests/test_format_welf.c 2017-07-31 09:05:32.000000000 +0000 +++ syslog-ng-3.13.2/modules/kvformat/tests/test_format_welf.c 2017-12-06 06:39:39.000000000 +0000 @@ -29,6 +29,7 @@ test_format_welf(void) { assert_template_format("$(format-welf MSG=$MSG)", "MSG=árvíztűrőtükörfúrógép"); + assert_template_format("xxx$(format-welf MSG=$MSG)yyy", "xxxMSG=árvíztűrőtükörfúrógépyyy"); assert_template_format("$(format-welf MSG=$escaping)", "MSG=\"binary stuff follows \\\"\\xad árvíztűrőtükörfúrógép\""); assert_template_format("$(format-welf MSG=$escaping2)", "MSG=\\xc3"); @@ -57,7 +58,7 @@ putenv("TZ=UTC"); tzset(); init_template_tests(); - plugin_load_module("kvformat", configuration, NULL); + cfg_load_module(configuration, "kvformat"); test_format_welf(); test_format_welf_performance(); diff -Nru syslog-ng-3.11.1/modules/kvformat/tests/test_linux_audit_scanner.c syslog-ng-3.13.2/modules/kvformat/tests/test_linux_audit_scanner.c --- syslog-ng-3.11.1/modules/kvformat/tests/test_linux_audit_scanner.c 2017-07-31 09:05:32.000000000 +0000 +++ syslog-ng-3.13.2/modules/kvformat/tests/test_linux_audit_scanner.c 2017-12-06 06:39:39.000000000 +0000 @@ -20,6 +20,7 @@ */ #include "scanner/kv-scanner/kv-scanner.h" #include "linux-audit-parser.h" +#include "apphook.h" #include "testutils.h" #define kv_scanner_testcase_begin(func, args) \ @@ -128,5 +129,7 @@ int main(int argc, char *argv[]) { + app_startup(); test_kv_scanner(); + app_shutdown(); } diff -Nru syslog-ng-3.11.1/modules/linux-kmsg-format/linux-kmsg-format-plugin.c syslog-ng-3.13.2/modules/linux-kmsg-format/linux-kmsg-format-plugin.c --- syslog-ng-3.11.1/modules/linux-kmsg-format/linux-kmsg-format-plugin.c 2017-07-31 09:05:32.000000000 +0000 +++ syslog-ng-3.13.2/modules/linux-kmsg-format/linux-kmsg-format-plugin.c 2017-12-06 06:39:39.000000000 +0000 @@ -31,24 +31,24 @@ .parse = &linux_kmsg_format_handler }; -static MsgFormatHandler * -linux_kmsg_format_construct(Plugin *self, GlobalConfig *cfg, gint plugin_type, const gchar *plugin_name) +static gpointer +linux_kmsg_format_construct(Plugin *self) { - return &linux_kmsg_handler; + return (gpointer) &linux_kmsg_handler; } static Plugin linux_kmsg_format_plugin = { .type = LL_CONTEXT_FORMAT, .name = "linux-kmsg", - .construct = (gpointer (*)(Plugin *self, GlobalConfig *cfg, gint plugin_type, const gchar *plugin_name)) linux_kmsg_format_construct, + .construct = linux_kmsg_format_construct, }; gboolean -linux_kmsg_format_module_init(GlobalConfig *cfg, CfgArgs *args) +linux_kmsg_format_module_init(PluginContext *context, CfgArgs *args) { linux_msg_format_init(); - plugin_register(cfg, &linux_kmsg_format_plugin, 1); + plugin_register(context, &linux_kmsg_format_plugin, 1); return TRUE; } diff -Nru syslog-ng-3.11.1/modules/linux-kmsg-format/tests/test_linux_format_kmsg.c syslog-ng-3.13.2/modules/linux-kmsg-format/tests/test_linux_format_kmsg.c --- syslog-ng-3.11.1/modules/linux-kmsg-format/tests/test_linux_format_kmsg.c 2017-07-31 09:05:32.000000000 +0000 +++ syslog-ng-3.13.2/modules/linux-kmsg-format/tests/test_linux_format_kmsg.c 2017-12-06 06:39:39.000000000 +0000 @@ -171,10 +171,10 @@ } void -init_and_load_kmsgformat_module() +init_and_load_kmsgformat_module(void) { - configuration = cfg_new_snippet(VERSION_VALUE); - plugin_load_module("linux-kmsg-format", configuration, NULL); + configuration = cfg_new_snippet(); + cfg_load_module(configuration, "linux-kmsg-format"); parse_options.format = "linux-kmsg"; msg_format_options_defaults(&parse_options); @@ -182,7 +182,7 @@ } void -deinit_kmsgformat_module() +deinit_kmsgformat_module(void) { if (configuration) cfg_free(configuration); diff -Nru syslog-ng-3.11.1/modules/Makefile.am syslog-ng-3.13.2/modules/Makefile.am --- syslog-ng-3.11.1/modules/Makefile.am 2017-07-31 09:05:32.000000000 +0000 +++ syslog-ng-3.13.2/modules/Makefile.am 2017-12-06 06:39:39.000000000 +0000 @@ -39,6 +39,9 @@ include modules/map-value-pairs/Makefile.am include modules/stardate/Makefile.am include modules/snmptrapd-parser/Makefile.am +include modules/tagsparser/Makefile.am +include modules/xml/Makefile.am +include modules/appmodel/Makefile.am SYSLOG_NG_CORE_JAR=$(top_builddir)/modules/java/syslog-ng-core/libs/syslog-ng-core.jar @@ -51,8 +54,8 @@ mod-redis mod-pseudofile mod-graphite mod-riemann \ mod-python mod-java mod-java-modules mod-kvformat mod-date \ mod-native mod-cef mod-add-contextual-data mod-diskq mod-getent \ - mod-map-value-pairs mod-snmptrapd-parser - + mod-map-value-pairs mod-snmptrapd-parser mod-tags-parser mod-xml \ + mod-appmodel modules modules/: ${SYSLOG_NG_MODULES} @@ -67,6 +70,6 @@ modules_graphite modules_riemann modules_python \ modules_systemd_journal modules_kvformat modules_date \ modules_cef modules_diskq modules-add-contextual-data modules_getent \ - modules_map-value-pairs + modules_map-value-pairs modules_tagsparser modules_xml modules_appmodel .PHONY: modules modules/ diff -Nru syslog-ng-3.11.1/modules/map-value-pairs/map-value-pairs-parser.h syslog-ng-3.13.2/modules/map-value-pairs/map-value-pairs-parser.h --- syslog-ng-3.11.1/modules/map-value-pairs/map-value-pairs-parser.h 2017-07-31 09:05:32.000000000 +0000 +++ syslog-ng-3.13.2/modules/map-value-pairs/map-value-pairs-parser.h 2017-12-06 06:39:39.000000000 +0000 @@ -26,7 +26,6 @@ #include "parser/parser-expr.h" #include "cfg-parser.h" -#include "cfg-lexer.h" extern CfgParser map_value_pairs_parser; diff -Nru syslog-ng-3.11.1/modules/map-value-pairs/map-value-pairs-plugin.c syslog-ng-3.13.2/modules/map-value-pairs/map-value-pairs-plugin.c --- syslog-ng-3.11.1/modules/map-value-pairs/map-value-pairs-plugin.c 2017-07-31 09:05:32.000000000 +0000 +++ syslog-ng-3.13.2/modules/map-value-pairs/map-value-pairs-plugin.c 2017-12-06 06:39:39.000000000 +0000 @@ -36,9 +36,9 @@ }; gboolean -map_value_pairs_module_init(GlobalConfig *cfg, CfgArgs *args G_GNUC_UNUSED) +map_value_pairs_module_init(PluginContext *context, CfgArgs *args G_GNUC_UNUSED) { - plugin_register(cfg, map_value_pairs_plugins, G_N_ELEMENTS(map_value_pairs_plugins)); + plugin_register(context, map_value_pairs_plugins, G_N_ELEMENTS(map_value_pairs_plugins)); return TRUE; } diff -Nru syslog-ng-3.11.1/modules/native/native-parser.h syslog-ng-3.13.2/modules/native/native-parser.h --- syslog-ng-3.11.1/modules/native/native-parser.h 2017-07-31 09:05:32.000000000 +0000 +++ syslog-ng-3.13.2/modules/native/native-parser.h 2017-12-06 06:39:39.000000000 +0000 @@ -26,7 +26,6 @@ #define NATIVE_PARSER_H_INCLUDED #include "cfg-parser.h" -#include "cfg-lexer.h" #include "parser/parser-expr.h" CFG_PARSER_DECLARE_LEXER_BINDING(native_, LogParser **) diff -Nru syslog-ng-3.11.1/modules/native/parser.c syslog-ng-3.13.2/modules/native/parser.c --- syslog-ng-3.11.1/modules/native/parser.c 2017-07-31 09:05:32.000000000 +0000 +++ syslog-ng-3.13.2/modules/native/parser.c 2017-12-06 06:39:39.000000000 +0000 @@ -88,7 +88,9 @@ { ParserNative *self = (ParserNative *) s; - return !!native_parser_proxy_deinit(self->native_object); + if (!native_parser_proxy_deinit(self->native_object)) + return FALSE; + return log_parser_deinit_method(s); } static void diff -Nru syslog-ng-3.11.1/modules/pacctformat/pacct-format-plugin.c syslog-ng-3.13.2/modules/pacctformat/pacct-format-plugin.c --- syslog-ng-3.11.1/modules/pacctformat/pacct-format-plugin.c 2017-07-31 09:05:32.000000000 +0000 +++ syslog-ng-3.13.2/modules/pacctformat/pacct-format-plugin.c 2017-12-06 06:39:39.000000000 +0000 @@ -26,8 +26,8 @@ #include "plugin.h" #include "plugin-types.h" -static MsgFormatHandler * -pacct_format_construct(Plugin *self, GlobalConfig *cfg, gint plugin_type, const gchar *plugin_name) +static gpointer +pacct_format_construct(Plugin *self) { return &pacct_handler; } @@ -36,13 +36,13 @@ { .type = LL_CONTEXT_FORMAT, .name = "pacct", - .construct = (gpointer (*)(Plugin *self, GlobalConfig *cfg, gint plugin_type, const gchar *plugin_name)) pacct_format_construct, + .construct = pacct_format_construct, }; gboolean -pacctformat_module_init(GlobalConfig *cfg, CfgArgs *args) +pacctformat_module_init(PluginContext *context, CfgArgs *args) { - plugin_register(cfg, &pacct_format_plugin, 1); + plugin_register(context, &pacct_format_plugin, 1); return TRUE; } diff -Nru syslog-ng-3.11.1/modules/pseudofile/pseudofile-parser.h syslog-ng-3.13.2/modules/pseudofile/pseudofile-parser.h --- syslog-ng-3.11.1/modules/pseudofile/pseudofile-parser.h 2017-07-31 09:05:32.000000000 +0000 +++ syslog-ng-3.13.2/modules/pseudofile/pseudofile-parser.h 2017-12-06 06:39:39.000000000 +0000 @@ -25,7 +25,6 @@ #define PSEUDOFILE_PARSER_H_INCLUDED #include "cfg-parser.h" -#include "cfg-lexer.h" #include "driver.h" extern CfgParser pseudofile_parser; diff -Nru syslog-ng-3.11.1/modules/pseudofile/pseudofile-plugin.c syslog-ng-3.13.2/modules/pseudofile/pseudofile-plugin.c --- syslog-ng-3.11.1/modules/pseudofile/pseudofile-plugin.c 2017-07-31 09:05:32.000000000 +0000 +++ syslog-ng-3.13.2/modules/pseudofile/pseudofile-plugin.c 2017-12-06 06:39:39.000000000 +0000 @@ -37,9 +37,9 @@ }; gboolean -pseudofile_module_init(GlobalConfig *cfg, CfgArgs *args) +pseudofile_module_init(PluginContext *context, CfgArgs *args) { - plugin_register(cfg, pseudofile_plugins, G_N_ELEMENTS(pseudofile_plugins)); + plugin_register(context, pseudofile_plugins, G_N_ELEMENTS(pseudofile_plugins)); return TRUE; } diff -Nru syslog-ng-3.11.1/modules/python/compat/compat-python.c syslog-ng-3.13.2/modules/python/compat/compat-python.c --- syslog-ng-3.11.1/modules/python/compat/compat-python.c 1970-01-01 00:00:00.000000000 +0000 +++ syslog-ng-3.13.2/modules/python/compat/compat-python.c 2017-12-06 06:39:39.000000000 +0000 @@ -0,0 +1,32 @@ +/* + * Copyright (c) 2017 Balabit + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + * + * As an additional exemption you are allowed to compile & link against the + * OpenSSL libraries as published by the OpenSSL project. See the file + * COPYING for details. + * + */ + +#include "compat-python.h" + +#if SYSLOG_NG_ENABLE_PYTHONv2 +#include "compat-python-v2.c" +#endif + +#if SYSLOG_NG_ENABLE_PYTHONv3 +#include "compat-python-v3.c" +#endif diff -Nru syslog-ng-3.11.1/modules/python/compat/compat-python.h syslog-ng-3.13.2/modules/python/compat/compat-python.h --- syslog-ng-3.11.1/modules/python/compat/compat-python.h 1970-01-01 00:00:00.000000000 +0000 +++ syslog-ng-3.13.2/modules/python/compat/compat-python.h 2017-12-06 06:39:39.000000000 +0000 @@ -0,0 +1,32 @@ +/* + * Copyright (c) 2017 Balabit + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + * + * As an additional exemption you are allowed to compile & link against the + * OpenSSL libraries as published by the OpenSSL project. See the file + * COPYING for details. + * + */ + +#ifndef _COMPAT_PYTHON_H +#define _COMPAT_PYTHON_H + +#include +#include "syslog-ng.h" + +gboolean py_is_string(PyObject *object); +const gchar *py_object_as_string(PyObject *object); +#endif diff -Nru syslog-ng-3.11.1/modules/python/compat/compat-python-v2.c syslog-ng-3.13.2/modules/python/compat/compat-python-v2.c --- syslog-ng-3.11.1/modules/python/compat/compat-python-v2.c 1970-01-01 00:00:00.000000000 +0000 +++ syslog-ng-3.13.2/modules/python/compat/compat-python-v2.c 2017-12-06 06:39:39.000000000 +0000 @@ -0,0 +1,34 @@ +/* + * Copyright (c) 2017 Balabit + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + * + * As an additional exemption you are allowed to compile & link against the + * OpenSSL libraries as published by the OpenSSL project. See the file + * COPYING for details. + * + */ + +gboolean +py_is_string(PyObject *object) +{ + return PyBytes_Check(object); +} + +const gchar * +py_object_as_string(PyObject *object) +{ + return PyBytes_AsString(object); +} diff -Nru syslog-ng-3.11.1/modules/python/compat/compat-python-v3.c syslog-ng-3.13.2/modules/python/compat/compat-python-v3.c --- syslog-ng-3.11.1/modules/python/compat/compat-python-v3.c 1970-01-01 00:00:00.000000000 +0000 +++ syslog-ng-3.13.2/modules/python/compat/compat-python-v3.c 2017-12-06 06:39:39.000000000 +0000 @@ -0,0 +1,34 @@ +/* + * Copyright (c) 2017 Balabit + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + * + * As an additional exemption you are allowed to compile & link against the + * OpenSSL libraries as published by the OpenSSL project. See the file + * COPYING for details. + * + */ + +gboolean +py_is_string(PyObject *object) +{ + return PyUnicode_Check(object); +} + +const gchar * +py_object_as_string(PyObject *object) +{ + return PyUnicode_AsUTF8(object); +} diff -Nru syslog-ng-3.11.1/modules/python/Makefile.am syslog-ng-3.13.2/modules/python/Makefile.am --- syslog-ng-3.11.1/modules/python/Makefile.am 2017-07-31 09:05:32.000000000 +0000 +++ syslog-ng-3.13.2/modules/python/Makefile.am 2017-12-06 06:39:39.000000000 +0000 @@ -21,6 +21,8 @@ $(IVYKIS_LIBS) modules_python_libmod_python_la_SOURCES = \ + modules/python/compat/compat-python.h \ + modules/python/compat/compat-python.c \ modules/python/python-module.h \ modules/python/python-config.h \ modules/python/python-config.c \ @@ -63,11 +65,13 @@ endif include modules/python/pylib/Makefile.am +include modules/python/tests/Makefile.am EXTRA_DIST += \ + modules/python/compat/compat-python-v2.c \ + modules/python/compat/compat-python-v3.c \ modules/python/python-grammar.ym \ modules/python/python-example.conf \ modules/python/sngexample.py .PHONY: modules/python mod-python - diff -Nru syslog-ng-3.11.1/modules/python/python-debugger.c syslog-ng-3.13.2/modules/python/python-debugger.c --- syslog-ng-3.11.1/modules/python/python-debugger.c 2017-07-31 09:05:32.000000000 +0000 +++ syslog-ng-3.13.2/modules/python/python-debugger.c 2017-12-06 06:39:39.000000000 +0000 @@ -128,7 +128,7 @@ Py_DECREF(ret); goto exit; } - command = g_strdup(PyBytes_AsString(ret)); + command = g_strdup(py_object_as_string(ret)); Py_DECREF(ret); exit: PyGILState_Release(gstate); diff -Nru syslog-ng-3.11.1/modules/python/python-helpers.c syslog-ng-3.13.2/modules/python/python-helpers.c --- syslog-ng-3.11.1/modules/python/python-helpers.c 2017-07-31 09:05:32.000000000 +0000 +++ syslog-ng-3.13.2/modules/python/python-helpers.c 2017-12-06 06:39:39.000000000 +0000 @@ -31,7 +31,7 @@ if (name) { - g_strlcpy(buf, PyBytes_AsString(name), buf_len); + g_strlcpy(buf, py_object_as_string(name), buf_len); } else { @@ -58,7 +58,7 @@ str = PyObject_Str(value); if (str) { - g_snprintf(buf, buf_len, "%s: %s", ((PyTypeObject *) exc)->tp_name, PyBytes_AsString(str)); + g_snprintf(buf, buf_len, "%s: %s", ((PyTypeObject *) exc)->tp_name, py_object_as_string(str)); } else { @@ -280,4 +280,3 @@ { g_list_foreach(imports, _foreach_import, NULL); } - diff -Nru syslog-ng-3.11.1/modules/python/python-logmsg.c syslog-ng-3.13.2/modules/python/python-logmsg.c --- syslog-ng-3.11.1/modules/python/python-logmsg.c 2017-07-31 09:05:32.000000000 +0000 +++ syslog-ng-3.13.2/modules/python/python-logmsg.c 2017-12-06 06:39:39.000000000 +0000 @@ -24,6 +24,7 @@ #include "python-logmsg.h" #include "logmsg/logmsg.h" #include "messages.h" +#include "str-utils.h" typedef struct _PyLogMessage { @@ -68,10 +69,11 @@ static PyObject * _py_log_message_getattr(PyObject *o, PyObject *key) { - if (!PyBytes_Check(key)) + if (!py_is_string(key)) return NULL; - gchar *name = PyBytes_AsString(key); + const gchar *name = py_object_as_string(key); + if (_is_key_blacklisted(name)) { msg_error("Blacklisted attribute requested", evt_tag_str("key", name)); @@ -79,28 +81,33 @@ } NVHandle handle = log_msg_get_value_handle(name); PyLogMessage *py_msg = (PyLogMessage *)o; - const gchar *value = log_msg_get_value(py_msg->msg, handle, NULL); + gssize value_len = 0; + const gchar *value = log_msg_get_value(py_msg->msg, handle, &value_len); + if (!value) { PyErr_SetString(PyExc_AttributeError, "No such attribute"); return NULL; } + + APPEND_ZERO(value, value, value_len); + return PyBytes_FromString(value); } static int _py_log_message_setattr(PyObject *o, PyObject *key, PyObject *value) { - if (!PyBytes_Check(key)) + if (!py_is_string(key)) return -1; PyLogMessage *py_msg = (PyLogMessage *)o; - gchar *name = PyBytes_AsString(key); + const gchar *name = py_object_as_string(key); NVHandle handle = log_msg_get_value_handle(name); PyObject *value_as_strobj = PyObject_Str(value); if (value_as_strobj) { - log_msg_set_value(py_msg->msg, handle, PyBytes_AsString(value_as_strobj), -1); + log_msg_set_value(py_msg->msg, handle, py_object_as_string(value_as_strobj), -1); Py_DECREF(value_as_strobj); } else diff -Nru syslog-ng-3.11.1/modules/python/python-logparser.c syslog-ng-3.13.2/modules/python/python-logparser.c --- syslog-ng-3.11.1/modules/python/python-logparser.c 2017-07-31 09:05:32.000000000 +0000 +++ syslog-ng-3.13.2/modules/python/python-logparser.c 2017-12-06 06:39:39.000000000 +0000 @@ -234,7 +234,7 @@ _py_invoke_deinit(self); PyGILState_Release(gstate); - return TRUE; + return log_parser_deinit_method(d); } static void diff -Nru syslog-ng-3.11.1/modules/python/python-module.h syslog-ng-3.13.2/modules/python/python-module.h --- syslog-ng-3.11.1/modules/python/python-module.h 2017-07-31 09:05:32.000000000 +0000 +++ syslog-ng-3.13.2/modules/python/python-module.h 2017-12-06 06:39:39.000000000 +0000 @@ -62,7 +62,5 @@ #error "_POSIX_C_SOURCE or _XOPEN_SOURCE is already defined, python-module.h should be included first. Check out the comment in python-module.h for more information" #endif -#include -#include "syslog-ng.h" - +#include "compat/compat-python.h" #endif diff -Nru syslog-ng-3.11.1/modules/python/python-parser.h syslog-ng-3.13.2/modules/python/python-parser.h --- syslog-ng-3.11.1/modules/python/python-parser.h 2017-07-31 09:05:32.000000000 +0000 +++ syslog-ng-3.13.2/modules/python/python-parser.h 2017-12-06 06:39:39.000000000 +0000 @@ -29,7 +29,6 @@ #include "driver.h" #include "parser/parser-expr.h" #include "cfg-parser.h" -#include "cfg-lexer.h" extern CfgParser python_parser; diff -Nru syslog-ng-3.11.1/modules/python/python-plugin.c syslog-ng-3.13.2/modules/python/python-plugin.c --- syslog-ng-3.11.1/modules/python/python-plugin.c 2017-07-31 09:05:32.000000000 +0000 +++ syslog-ng-3.13.2/modules/python/python-plugin.c 2017-12-06 06:39:39.000000000 +0000 @@ -74,11 +74,11 @@ } gboolean -python_module_init(GlobalConfig *cfg, CfgArgs *args G_GNUC_UNUSED) +python_module_init(PluginContext *context, CfgArgs *args G_GNUC_UNUSED) { _py_init_interpreter(); python_debugger_init(); - plugin_register(cfg, python_plugins, G_N_ELEMENTS(python_plugins)); + plugin_register(context, python_plugins, G_N_ELEMENTS(python_plugins)); return TRUE; } diff -Nru syslog-ng-3.11.1/modules/python/python-value-pairs.c syslog-ng-3.13.2/modules/python/python-value-pairs.c --- syslog-ng-3.11.1/modules/python/python-value-pairs.c 2017-07-31 09:05:32.000000000 +0000 +++ syslog-ng-3.13.2/modules/python/python-value-pairs.c 2017-12-06 06:39:39.000000000 +0000 @@ -23,10 +23,45 @@ * */ #include "python-value-pairs.h" +#include "python-helpers.h" +#include "messages.h" /** Value pairs **/ -/* TODO escape '\0' when passing down the value */ +static void +add_long_to_dict(PyObject *dict, const gchar *name, long num) +{ + gchar buf[256]; + + PyObject *pyobject_to_add = PyLong_FromLong(num); + if (!pyobject_to_add) + { + msg_error("Error while constructing python object", + evt_tag_str("exception", _py_fetch_and_format_exception_text(buf, sizeof(buf)))); + return; + } + + PyDict_SetItemString(dict, name, pyobject_to_add); + Py_DECREF(pyobject_to_add); +} + +static void +add_string_to_dict(PyObject *dict, const gchar *name, const char *value, gsize value_len) +{ + gchar buf[256]; + + PyObject *pyobject_to_add = PyBytes_FromStringAndSize(value, value_len); + if (!pyobject_to_add) + { + msg_error("Error while constructing python object", + evt_tag_str("exception", _py_fetch_and_format_exception_text(buf, sizeof(buf)))); + return; + } + + PyDict_SetItemString(dict, name, pyobject_to_add); + Py_DECREF(pyobject_to_add); +} + static gboolean python_worker_vp_add_one(const gchar *name, TypeHint type, const gchar *value, gsize value_len, @@ -45,25 +80,30 @@ gint64 i; if (type_cast_to_int64(value, &i, NULL)) - PyDict_SetItemString(dict, name, PyLong_FromLong(i)); + { + add_long_to_dict(dict, name, i); + } else { need_drop = type_cast_drop_helper(template_options->on_error, value, "int"); if (fallback) - PyDict_SetItemString(dict, name, PyUnicode_FromString(value)); + { + add_string_to_dict(dict, name, value, value_len); + } } break; } case TYPE_HINT_STRING: - PyDict_SetItemString(dict, name, PyUnicode_FromString(value)); + add_string_to_dict(dict, name, value, value_len); break; default: need_drop = type_cast_drop_helper(template_options->on_error, value, ""); break; } + return need_drop; } diff -Nru syslog-ng-3.11.1/modules/python/tests/Makefile.am syslog-ng-3.13.2/modules/python/tests/Makefile.am --- syslog-ng-3.11.1/modules/python/tests/Makefile.am 1970-01-01 00:00:00.000000000 +0000 +++ syslog-ng-3.13.2/modules/python/tests/Makefile.am 2017-12-06 06:39:39.000000000 +0000 @@ -0,0 +1,13 @@ +if ENABLE_CRITERION +check_PROGRAMS += \ + ${modules_python_tests_TESTS} + +modules_python_tests_TESTS = \ + modules/python/tests/test_python_logmsg + +modules_python_tests_test_python_logmsg_CFLAGS = $(TEST_CFLAGS) $(PYTHON_CFLAGS) -I$(top_srcdir)/modules/python +modules_python_tests_test_python_logmsg_LDADD = $(TEST_LDADD) \ + -dlpreopen $(top_builddir)/modules/python/libmod-python.la \ + $(PYTHON_LIBS) +endif + diff -Nru syslog-ng-3.11.1/modules/python/tests/test_python_logmsg.c syslog-ng-3.13.2/modules/python/tests/test_python_logmsg.c --- syslog-ng-3.11.1/modules/python/tests/test_python_logmsg.c 1970-01-01 00:00:00.000000000 +0000 +++ syslog-ng-3.13.2/modules/python/tests/test_python_logmsg.c 2017-12-06 06:39:39.000000000 +0000 @@ -0,0 +1,133 @@ +/* + * Copyright (c) 2017 Balabit + * + * This program is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 as published + * by the Free Software Foundation, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + * + * As an additional exemption you are allowed to compile & link against the + * OpenSSL libraries as published by the OpenSSL project. See the file + * COPYING for details. + */ + +#include "python-helpers.h" +#include "python-logmsg.h" +#include +#include "apphook.h" +#include "msg_parse_lib.h" + +static PyObject *_python_main; +static PyObject *_python_main_dict; + +static void +_py_init_interpreter(void) +{ + Py_Initialize(); + PyEval_InitThreads(); + python_log_message_init(); + PyEval_SaveThread(); +} + +static void +_init_python_main(void) +{ + PyGILState_STATE gstate = PyGILState_Ensure(); + { + _python_main = PyImport_AddModule("__main__"); + _python_main_dict = PyModule_GetDict(_python_main); + } + PyGILState_Release(gstate); +} + +static gchar * +_dict_clone_value(PyObject *dict, const gchar *key) +{ + PyObject *res_obj = PyObject_Str(PyDict_GetItemString(dict, key)); + if (!res_obj) + return NULL; + gchar *res = g_strdup(py_object_as_string(res_obj)); + Py_XDECREF(res_obj); + return res; +} + +void setup(void) +{ + app_startup(); + _py_init_interpreter(); + _init_python_main(); +} + +void teardown(void) +{ + app_shutdown(); +} + +TestSuite(python_log_message, .init = setup, .fini = teardown); + +Test(python_log_message, test_python_logmessage_set_value) +{ + const gchar *raw_msg = "test_msg"; + LogMessage *msg = log_msg_new(raw_msg, strlen(raw_msg), NULL, &parse_options); + + PyGILState_STATE gstate; + gstate = PyGILState_Ensure(); + { + PyObject *msg_object = py_log_message_new(msg); + + PyDict_SetItemString(_python_main_dict, "test_msg", msg_object); + const gchar *set_value = "test_msg['test_field'] = 'test_value'\nresult=test_msg['test_field']"; + PyRun_String(set_value, Py_file_input, _python_main_dict, _python_main_dict); + + gchar *res = _dict_clone_value(_python_main_dict, "result"); + cr_assert_str_eq(res, "test_value"); + g_free(res); + + const gchar *test_value=log_msg_get_value_by_name(msg, "test_field", NULL); + cr_assert_str_eq(test_value, "test_value"); + + Py_XDECREF(msg_object); + } + PyGILState_Release(gstate); +} + +Test(python_log_message, test_python_logmessage_set_value_indirect) +{ + const gchar *raw_msg = "test_msg"; + const gchar *test_value = "test_value"; + const gchar *test_key = "test_key"; + LogMessage *msg = log_msg_new(raw_msg, strlen(raw_msg), NULL, &parse_options); + NVHandle test_key_handle = log_msg_get_value_handle(test_key); + log_msg_set_value(msg, test_key_handle, test_value, -1); + + PyGILState_STATE gstate; + gstate = PyGILState_Ensure(); + { + PyObject *msg_object = py_log_message_new(msg); + + PyDict_SetItemString(_python_main_dict, "test_msg", msg_object); + + gssize len = strlen(test_value); + NVHandle indirect_key_handle = log_msg_get_value_handle("indirect"); + log_msg_set_value_indirect(msg, indirect_key_handle, test_key_handle, 0, 0, len); + + const gchar *get_value_indirect = "indirect = test_msg['indirect']"; + PyRun_String(get_value_indirect, Py_file_input, _python_main_dict, _python_main_dict); + + gchar *res_indirect = _dict_clone_value(_python_main_dict, "indirect"); + cr_assert_str_eq(res_indirect, "test_value"); + g_free(res_indirect); + + Py_XDECREF(msg_object); + } + PyGILState_Release(gstate); +} + diff -Nru syslog-ng-3.11.1/modules/redis/redis.c syslog-ng-3.13.2/modules/redis/redis.c --- syslog-ng-3.11.1/modules/redis/redis.c 2017-07-31 09:05:32.000000000 +0000 +++ syslog-ng-3.13.2/modules/redis/redis.c 2017-12-06 06:39:39.000000000 +0000 @@ -346,6 +346,13 @@ if (!log_dest_driver_init_method(s)) return FALSE; + if (!self->key && !self->param1) + { + msg_error("Error initializing Redis destination, command option MUST be set", + log_pipe_location_tag(s)); + return FALSE; + } + log_template_options_init(&self->template_options, cfg); msg_verbose("Initializing Redis destination", @@ -418,9 +425,9 @@ }; gboolean -redis_module_init(GlobalConfig *cfg, CfgArgs *args) +redis_module_init(PluginContext *context, CfgArgs *args) { - plugin_register(cfg, &redis_plugin, 1); + plugin_register(context, &redis_plugin, 1); return TRUE; } diff -Nru syslog-ng-3.11.1/modules/redis/redis-parser.h syslog-ng-3.13.2/modules/redis/redis-parser.h --- syslog-ng-3.11.1/modules/redis/redis-parser.h 2017-07-31 09:05:32.000000000 +0000 +++ syslog-ng-3.13.2/modules/redis/redis-parser.h 2017-12-06 06:39:39.000000000 +0000 @@ -25,7 +25,6 @@ #define REDIS_PARSER_H_INCLUDED #include "cfg-parser.h" -#include "cfg-lexer.h" #include "redis.h" extern CfgParser redis_parser; diff -Nru syslog-ng-3.11.1/modules/riemann/riemann.c syslog-ng-3.13.2/modules/riemann/riemann.c --- syslog-ng-3.11.1/modules/riemann/riemann.c 2017-07-31 09:05:32.000000000 +0000 +++ syslog-ng-3.13.2/modules/riemann/riemann.c 2017-12-06 06:39:39.000000000 +0000 @@ -46,6 +46,7 @@ LogTemplate *host; LogTemplate *service; LogTemplate *event_time; + gint event_time_unit; LogTemplate *state; LogTemplate *description; LogTemplate *metric; @@ -116,6 +117,12 @@ self->fields.event_time = log_template_ref(value); } +void riemann_dd_set_event_time_unit(LogDriver *d, gint unit) +{ + RiemannDestDriver *self = (RiemannDestDriver *)d; + + self->fields.event_time_unit = unit; +} void riemann_dd_set_field_state(LogDriver *d, LogTemplate *value) @@ -364,6 +371,7 @@ { self->fields.event_time = log_template_new(cfg, NULL); log_template_compile(self->fields.event_time, "${UNIXTIME}", NULL); + self->fields.event_time_unit = RIEMANN_EVENT_FIELD_TIME; } _value_pairs_always_exclude_properties(self); @@ -561,7 +569,7 @@ self->super.seq_num, str); riemann_dd_field_integer_maybe_add(event, msg, self->fields.event_time, &self->template_options, - RIEMANN_EVENT_FIELD_TIME, + self->fields.event_time_unit, self->super.seq_num, str); riemann_dd_field_string_maybe_add(event, msg, self->fields.description, &self->template_options, diff -Nru syslog-ng-3.11.1/modules/riemann/riemann-grammar.ym syslog-ng-3.13.2/modules/riemann/riemann-grammar.ym --- syslog-ng-3.11.1/modules/riemann/riemann-grammar.ym 2017-07-31 09:05:32.000000000 +0000 +++ syslog-ng-3.13.2/modules/riemann/riemann-grammar.ym 2017-12-06 06:39:39.000000000 +0000 @@ -33,6 +33,7 @@ #include "cfg-grammar.h" #include "cfg-parser.h" #include "plugin.h" +#include "riemann/event.h" } %name-prefix "riemann_" @@ -48,6 +49,8 @@ %token KW_STATE %token KW_SERVICE %token KW_EVENT_TIME +%token KW_SECONDS +%token KW_MICROSECONDS %token KW_DESCRIPTION %token KW_METRIC %token KW_TTL @@ -56,6 +59,7 @@ %token KW_CA_FILE %token KW_CERT_FILE %token KW_KEY_FILE +%token KW_TLS %% @@ -90,7 +94,7 @@ { riemann_dd_set_field_service(last_driver, $3); } - | KW_EVENT_TIME '(' template_content ')' + | KW_EVENT_TIME '(' template_content event_time_unit ')' { riemann_dd_set_field_event_time(last_driver, $3); } @@ -114,13 +118,7 @@ { riemann_dd_set_field_tags(last_driver, $3); } - | KW_TYPE '(' LL_IDENTIFIER riemann_type_options ')' - { - CHECK_ERROR(riemann_dd_set_connection_type(last_driver, $3), @3, - "Unknown Riemann connection type: %s", $3); - free($3); - } - | KW_TYPE '(' LL_STRING riemann_type_options ')' + | KW_TYPE '(' string riemann_tls_options ')' { CHECK_ERROR(riemann_dd_set_connection_type(last_driver, $3), @3, "Unknown Riemann connection type: %s", $3); @@ -144,9 +142,24 @@ } | dest_driver_option | threaded_dest_driver_option + | KW_TLS '(' riemann_tls_options ')' | { last_template_options = riemann_dd_get_template_options(last_driver); } template_option ; + +event_time_unit + : KW_SECONDS { riemann_dd_set_event_time_unit(last_driver, RIEMANN_EVENT_FIELD_TIME); } + | KW_MICROSECONDS + { +#if SYSLOG_NG_HAVE_RIEMANN_MICROSECONDS + riemann_dd_set_event_time_unit(last_driver, RIEMANN_EVENT_FIELD_TIME_MICROS); +#else + CHECK_ERROR(0, @1, "Riemann destination was not compiled with microseconds support"); +#endif + } + | { riemann_dd_set_event_time_unit(last_driver, RIEMANN_EVENT_FIELD_TIME); } + ; + attribute_options : attribute_option attribute_options | @@ -161,12 +174,12 @@ | vp_option ; -riemann_type_options - : riemann_type_option riemann_type_options +riemann_tls_options + : riemann_tls_option riemann_tls_options | ; -riemann_type_option +riemann_tls_option : KW_CA_FILE '(' string ')' { riemann_dd_set_tls_cacert(last_driver, $3); free($3); } | KW_CERT_FILE '(' string ')' { riemann_dd_set_tls_cert(last_driver, $3); free($3); } | KW_KEY_FILE '(' string ')' { riemann_dd_set_tls_key(last_driver, $3); free($3); } diff -Nru syslog-ng-3.11.1/modules/riemann/riemann.h syslog-ng-3.13.2/modules/riemann/riemann.h --- syslog-ng-3.11.1/modules/riemann/riemann.h 2017-07-31 09:05:32.000000000 +0000 +++ syslog-ng-3.13.2/modules/riemann/riemann.h 2017-12-06 06:39:39.000000000 +0000 @@ -48,5 +48,5 @@ void riemann_dd_set_tls_key(LogDriver *d, const gchar *path); void riemann_dd_set_flush_lines(LogDriver *d, gint lines); void riemann_dd_set_timeout(LogDriver *d, guint timeout); - +void riemann_dd_set_event_time_unit(LogDriver *d, gint unit); #endif diff -Nru syslog-ng-3.11.1/modules/riemann/riemann-parser.c syslog-ng-3.13.2/modules/riemann/riemann-parser.c --- syslog-ng-3.11.1/modules/riemann/riemann-parser.c 2017-07-31 09:05:32.000000000 +0000 +++ syslog-ng-3.13.2/modules/riemann/riemann-parser.c 2017-12-06 06:39:39.000000000 +0000 @@ -37,6 +37,8 @@ { "host", KW_HOST }, { "service", KW_SERVICE }, { "event_time", KW_EVENT_TIME }, + { "seconds", KW_SECONDS }, + { "microseconds", KW_MICROSECONDS }, { "state", KW_STATE }, { "description", KW_DESCRIPTION }, { "metric", KW_METRIC }, @@ -51,6 +53,8 @@ { "cacert", KW_CA_FILE, KWS_OBSOLETE, "The cacert() option is deprecated in favour of ca-file()" }, { "cert", KW_CERT_FILE, KWS_OBSOLETE, "The cert() option is deprecated in favour of cert-file()" }, + { "tls", KW_TLS }, + { NULL } }; diff -Nru syslog-ng-3.11.1/modules/riemann/riemann-parser.h syslog-ng-3.13.2/modules/riemann/riemann-parser.h --- syslog-ng-3.11.1/modules/riemann/riemann-parser.h 2017-07-31 09:05:32.000000000 +0000 +++ syslog-ng-3.13.2/modules/riemann/riemann-parser.h 2017-12-06 06:39:39.000000000 +0000 @@ -25,7 +25,6 @@ #define SNG_RIEMANN_PARSER_H_INCLUDED #include "cfg-parser.h" -#include "cfg-lexer.h" #include "riemann.h" extern CfgParser riemann_parser; diff -Nru syslog-ng-3.11.1/modules/riemann/riemann-plugin.c syslog-ng-3.13.2/modules/riemann/riemann-plugin.c --- syslog-ng-3.11.1/modules/riemann/riemann-plugin.c 2017-07-31 09:05:32.000000000 +0000 +++ syslog-ng-3.13.2/modules/riemann/riemann-plugin.c 2017-12-06 06:39:39.000000000 +0000 @@ -37,9 +37,9 @@ }; gboolean -riemann_module_init(GlobalConfig *cfg, CfgArgs *args G_GNUC_UNUSED) +riemann_module_init(PluginContext *context, CfgArgs *args G_GNUC_UNUSED) { - plugin_register(cfg, &riemann_plugin, 1); + plugin_register(context, &riemann_plugin, 1); return TRUE; } diff -Nru syslog-ng-3.11.1/modules/snmptrapd-parser/Makefile.am syslog-ng-3.13.2/modules/snmptrapd-parser/Makefile.am --- syslog-ng-3.11.1/modules/snmptrapd-parser/Makefile.am 2017-07-31 09:05:32.000000000 +0000 +++ syslog-ng-3.13.2/modules/snmptrapd-parser/Makefile.am 2017-12-06 06:39:39.000000000 +0000 @@ -28,7 +28,7 @@ modules_snmptrapd_parser_libsnmptrapd_parser_la_LDFLAGS = $(MODULE_LDFLAGS) modules_snmptrapd_parser_libsnmptrapd_parser_la_DEPENDENCIES= $(MODULE_DEPS_LIBS) -modules/snmptrapd-parser modules/snmptrapd-parser/ mod-snmptrapd-parser mod-file: modules/snmptrapd-parser/libsnmptrapd-parser.la -.PHONY: modules/snmptrapd-parser/ mod-snmptrapd-parser mod-file +modules/snmptrapd-parser modules/snmptrapd-parser/ mod-snmptrapd-parser: modules/snmptrapd-parser/libsnmptrapd-parser.la +.PHONY: modules/snmptrapd-parser/ mod-snmptrapd-parser include modules/snmptrapd-parser/tests/Makefile.am diff -Nru syslog-ng-3.11.1/modules/snmptrapd-parser/snmptrapd-header-parser.c syslog-ng-3.13.2/modules/snmptrapd-parser/snmptrapd-header-parser.c --- syslog-ng-3.11.1/modules/snmptrapd-parser/snmptrapd-header-parser.c 2017-07-31 09:05:32.000000000 +0000 +++ syslog-ng-3.13.2/modules/snmptrapd-parser/snmptrapd-header-parser.c 2017-12-06 06:39:39.000000000 +0000 @@ -263,6 +263,7 @@ if (!scan_std_timestamp(self->input, (gint *)self->input_len, &tm)) return FALSE; + tm.tm_isdst = -1; stamp->tv_sec = cached_mktime(&tm); stamp->zone_offset = get_local_timezone_ofs(stamp->tv_sec); diff -Nru syslog-ng-3.11.1/modules/snmptrapd-parser/snmptrapd-parser-parser.h syslog-ng-3.13.2/modules/snmptrapd-parser/snmptrapd-parser-parser.h --- syslog-ng-3.11.1/modules/snmptrapd-parser/snmptrapd-parser-parser.h 2017-07-31 09:05:32.000000000 +0000 +++ syslog-ng-3.13.2/modules/snmptrapd-parser/snmptrapd-parser-parser.h 2017-12-06 06:39:39.000000000 +0000 @@ -24,7 +24,6 @@ #define SNMPTRAPD_PARSER_PARSER_H_INCLUDED #include "cfg-parser.h" -#include "cfg-lexer.h" #include "parser/parser-expr.h" extern CfgParser snmptrapd_parser_parser; diff -Nru syslog-ng-3.11.1/modules/snmptrapd-parser/snmptrapd-parser-plugin.c syslog-ng-3.13.2/modules/snmptrapd-parser/snmptrapd-parser-plugin.c --- syslog-ng-3.11.1/modules/snmptrapd-parser/snmptrapd-parser-plugin.c 2017-07-31 09:05:32.000000000 +0000 +++ syslog-ng-3.13.2/modules/snmptrapd-parser/snmptrapd-parser-plugin.c 2017-12-06 06:39:39.000000000 +0000 @@ -36,9 +36,9 @@ }; gboolean -snmptrapd_parser_module_init(GlobalConfig *cfg, CfgArgs *args) +snmptrapd_parser_module_init(PluginContext *context, CfgArgs *args) { - plugin_register(cfg, snmptrapd_parser_plugins, G_N_ELEMENTS(snmptrapd_parser_plugins)); + plugin_register(context, snmptrapd_parser_plugins, G_N_ELEMENTS(snmptrapd_parser_plugins)); return TRUE; } diff -Nru syslog-ng-3.11.1/modules/snmptrapd-parser/tests/test_snmptrapd_parser.c syslog-ng-3.13.2/modules/snmptrapd-parser/tests/test_snmptrapd_parser.c --- syslog-ng-3.11.1/modules/snmptrapd-parser/tests/test_snmptrapd_parser.c 2017-07-31 09:05:32.000000000 +0000 +++ syslog-ng-3.13.2/modules/snmptrapd-parser/tests/test_snmptrapd_parser.c 2017-12-06 06:39:39.000000000 +0000 @@ -125,7 +125,7 @@ void setup(void) { - configuration = cfg_new_snippet(0x0390); + configuration = cfg_new_snippet(); app_startup(); } @@ -155,6 +155,7 @@ { ".snmp.iso.3.6.1.6.3.1.1.4.1.0", "iso.3.6.1.4.1.8072.2.3.0.1" }, { ".snmp.iso.3.6.1.4.1.8072.2.3.2.1", "60" }, { ".snmp.iso.3.6.1.4.1.8072.2.1.3", "" }, + { "DATE", "May 10 12:46:14" }, }; assert_log_message_name_values(input, expected, SIZE_OF_ARRAY(expected)); @@ -163,7 +164,7 @@ Test(snmptrapd_parser, test_general_v1_message_with_oids) { const gchar *input = - "2017-05-10 13:23:16 localhost [UDP: [127.0.0.1]:53831->[127.0.0.1]:162]: iso.3.6.1.4.1.8072.2.3.1\n" + "2017-11-10 13:23:16 localhost [UDP: [127.0.0.1]:53831->[127.0.0.1]:162]: iso.3.6.1.4.1.8072.2.3.1\n" "\t Enterprise Specific Trap (.17) Uptime: 18:41:07.83\n" "iso.3.6.1.4.1.8072.2.1.1 = INTEGER: 123456"; @@ -175,7 +176,8 @@ { ".snmp.type", "Enterprise Specific Trap" }, { ".snmp.subtype", ".17" }, { ".snmp.uptime", "18:41:07.83" }, - { ".snmp.iso.3.6.1.4.1.8072.2.1.1", "123456" } + { ".snmp.iso.3.6.1.4.1.8072.2.1.1", "123456" }, + { "DATE", "Nov 10 13:23:16" } }; assert_log_message_name_values(input, expected, SIZE_OF_ARRAY(expected)); diff -Nru syslog-ng-3.11.1/modules/snmptrapd-parser/tests/test_varbindlist_scanner.c syslog-ng-3.13.2/modules/snmptrapd-parser/tests/test_varbindlist_scanner.c --- syslog-ng-3.11.1/modules/snmptrapd-parser/tests/test_varbindlist_scanner.c 2017-07-31 09:05:32.000000000 +0000 +++ syslog-ng-3.13.2/modules/snmptrapd-parser/tests/test_varbindlist_scanner.c 2017-12-06 06:39:39.000000000 +0000 @@ -22,6 +22,9 @@ #include #include "varbindlist-scanner.h" +#include "apphook.h" +#include "scratch-buffers.h" + #define SIZE_OF_ARRAY(array) (sizeof(array) / sizeof((array)[0])) typedef struct @@ -52,9 +55,7 @@ { VarBindListScanner *scanner = varbindlist_scanner_new(); - VarBindListScanner *cloned = varbindlist_scanner_clone(scanner); - varbindlist_scanner_free(scanner); - return cloned; + return scanner; } static void @@ -185,3 +186,18 @@ expect_varbindlist(input, expected, SIZE_OF_ARRAY(expected)); } + +static void +setup(void) +{ + app_startup(); +} + +static void +teardown(void) +{ + scratch_buffers_explicit_gc(); + app_shutdown(); +} + +TestSuite(varbindlist_scanner, .init = setup, .fini = teardown); diff -Nru syslog-ng-3.11.1/modules/snmptrapd-parser/varbindlist-scanner.c syslog-ng-3.13.2/modules/snmptrapd-parser/varbindlist-scanner.c --- syslog-ng-3.11.1/modules/snmptrapd-parser/varbindlist-scanner.c 2017-07-31 09:05:32.000000000 +0000 +++ syslog-ng-3.13.2/modules/snmptrapd-parser/varbindlist-scanner.c 2017-12-06 06:39:39.000000000 +0000 @@ -68,39 +68,23 @@ scanner->input_pos = type_end - scanner->input + 1; } -static KVScanner * -_clone(KVScanner *s) -{ - VarBindListScanner *scanner = varbindlist_scanner_new(); - return &scanner->super; -} - -static void -_free(KVScanner *s) -{ - VarBindListScanner *self = (VarBindListScanner *) s; - varbindlist_scanner_deinit(self); -} - void varbindlist_scanner_init(VarBindListScanner *self) { memset(self, 0, sizeof(VarBindListScanner)); - kv_scanner_init_instance(&self->super, '=', "\t", FALSE); + kv_scanner_init(&self->super, '=', "\t", FALSE); kv_scanner_set_extract_annotation_func(&self->super, _extract_type); kv_scanner_set_valid_key_character_func(&self->super, _is_valid_key_character); kv_scanner_set_stop_character(&self->super, '\n'); self->varbind_type = g_string_sized_new(16); - self->super.clone = _clone; - self->super.free_fn = _free; } void varbindlist_scanner_deinit(VarBindListScanner *self) { - kv_scanner_free_method(&self->super); g_string_free(self->varbind_type, TRUE); + kv_scanner_deinit(&self->super); } gboolean diff -Nru syslog-ng-3.11.1/modules/snmptrapd-parser/varbindlist-scanner.h syslog-ng-3.13.2/modules/snmptrapd-parser/varbindlist-scanner.h --- syslog-ng-3.11.1/modules/snmptrapd-parser/varbindlist-scanner.h 2017-07-31 09:05:32.000000000 +0000 +++ syslog-ng-3.13.2/modules/snmptrapd-parser/varbindlist-scanner.h 2017-12-06 06:39:39.000000000 +0000 @@ -39,19 +39,6 @@ kv_scanner_input(&self->super, input); } -static inline VarBindListScanner * -varbindlist_scanner_clone(VarBindListScanner *self) -{ - return (VarBindListScanner *)kv_scanner_clone(&self->super); -} - -static inline void -varbindlist_scanner_free(VarBindListScanner *self) -{ - if (self) - kv_scanner_free(&self->super); -} - static inline const gchar * varbindlist_scanner_get_current_key(VarBindListScanner *self) { @@ -76,4 +63,11 @@ void varbindlist_scanner_init(VarBindListScanner *self); void varbindlist_scanner_deinit(VarBindListScanner *self); +static inline void +varbindlist_scanner_free(VarBindListScanner *self) +{ + varbindlist_scanner_deinit(self); + g_free(self); +} + #endif diff -Nru syslog-ng-3.11.1/modules/stardate/Makefile.am syslog-ng-3.13.2/modules/stardate/Makefile.am --- syslog-ng-3.11.1/modules/stardate/Makefile.am 2017-07-31 09:05:32.000000000 +0000 +++ syslog-ng-3.13.2/modules/stardate/Makefile.am 2017-12-06 06:39:39.000000000 +0000 @@ -13,7 +13,7 @@ modules_stardate_libstardate_la_LDFLAGS = $(MODULE_LDFLAGS) -lm modules_stardate_libstardate_la_DEPENDENCIES= $(MODULE_DEPS_LIBS) -modules/stardate modules/stardate/ mod-stardate mod-file: modules/stardate/libstardate.la -.PHONY: modules/stardate/ mod-stardate mod-file +modules/stardate modules/stardate/ mod-stardate: modules/stardate/libstardate.la +.PHONY: modules/stardate/ mod-stardate include modules/stardate/tests/Makefile.am diff -Nru syslog-ng-3.11.1/modules/stardate/stardate-plugin.c syslog-ng-3.13.2/modules/stardate/stardate-plugin.c --- syslog-ng-3.11.1/modules/stardate/stardate-plugin.c 2017-07-31 09:05:32.000000000 +0000 +++ syslog-ng-3.13.2/modules/stardate/stardate-plugin.c 2017-12-06 06:39:39.000000000 +0000 @@ -33,9 +33,9 @@ }; gboolean -stardate_module_init(GlobalConfig *cfg, CfgArgs *args) +stardate_module_init(PluginContext *context, CfgArgs *args) { - plugin_register(cfg, stardate_plugins, G_N_ELEMENTS(stardate_plugins)); + plugin_register(context, stardate_plugins, G_N_ELEMENTS(stardate_plugins)); return TRUE; } diff -Nru syslog-ng-3.11.1/modules/stardate/tests/test_stardate.c syslog-ng-3.13.2/modules/stardate/tests/test_stardate.c --- syslog-ng-3.11.1/modules/stardate/tests/test_stardate.c 2017-07-31 09:05:32.000000000 +0000 +++ syslog-ng-3.13.2/modules/stardate/tests/test_stardate.c 2017-12-06 06:39:39.000000000 +0000 @@ -48,7 +48,7 @@ } void -test_stardate() +test_stardate(void) { stardate_assert("2012-07-15T00:00:00", 1, "2012.5"); // 2012.01.01 + 365/2 day stardate_assert("2013-07-01T00:00:00", 2, "2013.49"); @@ -66,7 +66,7 @@ { app_startup(); init_template_tests(); - plugin_load_module("stardate", configuration, NULL); + cfg_load_module(configuration, "stardate"); test_stardate(); diff -Nru syslog-ng-3.11.1/modules/syslogformat/syslog-format.c syslog-ng-3.13.2/modules/syslogformat/syslog-format.c --- syslog-ng-3.11.1/modules/syslogformat/syslog-format.c 2017-07-31 09:05:32.000000000 +0000 +++ syslog-ng-3.13.2/modules/syslogformat/syslog-format.c 2017-12-06 06:39:39.000000000 +0000 @@ -37,8 +37,13 @@ static const char aix_fwd_string[] = "Message forwarded from "; static const char repeat_msg_string[] = "last message repeated"; -static NVHandle is_synced; -static NVHandle cisco_seqid; +static struct +{ + gboolean initialized; + NVHandle is_synced; + NVHandle cisco_seqid; + NVHandle raw_message; +} handles; static gboolean log_msg_parse_pri(LogMessage *self, const guchar **data, gint *length, guint flags, guint16 default_pri) @@ -196,7 +201,7 @@ if (*src != ' ') return FALSE; - log_msg_set_value(self, cisco_seqid, (gchar *) *data, *length - left - 1); + log_msg_set_value(self, handles.cisco_seqid, (gchar *) *data, *length - left - 1); *data = src; *length = left; @@ -401,25 +406,56 @@ } static inline void -__set_zone_offset(LogStamp *const timestamp, glong const assumed_timezone) +__determine_recv_timezone_offset(LogStamp *const timestamp, glong const recv_timezone_ofs) { - if(timestamp->zone_offset == -1) - { - timestamp->zone_offset = assumed_timezone; - } - if (timestamp->zone_offset == -1) - { - timestamp->zone_offset = get_local_timezone_ofs(timestamp->tv_sec); - } + if (!log_stamp_is_timezone_set(timestamp)) + timestamp->zone_offset = recv_timezone_ofs; + + if (!log_stamp_is_timezone_set(timestamp)) + timestamp->zone_offset = get_local_timezone_ofs(timestamp->tv_sec); } -static inline time_t -__get_normalized_time(LogStamp const timestamp, gint const normalized_hour, gint const unnormalized_hour) +static void +__fixup_hour_in_struct_tm_within_transition_periods(LogStamp *stamp, struct tm *tm, glong recv_timezone_ofs) { - return timestamp.tv_sec - + get_local_timezone_ofs(timestamp.tv_sec) - - (normalized_hour - unnormalized_hour) * 3600 - - timestamp.zone_offset; + /* save the tm_hour value as received from the client */ + gint unnormalized_hour = tm->tm_hour; + + /* NOTE: mktime() returns the time assuming that the timestamp we + * received was in local time. */ + + /* tell cached_mktime() that we have no clue whether Daylight Saving is enabled or not */ + tm->tm_isdst = -1; + stamp->tv_sec = cached_mktime(tm); + + /* We need to determine the timezone we want to assume the message was + * received from. This depends on the recv-time-zone() setting and the + * the tv_sec value as converted by mktime() above. */ + __determine_recv_timezone_offset(stamp, recv_timezone_ofs); + + /* save the tm_hour as adjusted by mktime() */ + gint normalized_hour = tm->tm_hour; + + /* fix up the tv_sec value by transposing it into the target timezone: + * + * First we add the local time zone offset then substract the target time + * zone offset. This is not trivial however, as we have to determine + * exactly what the local timezone offset is at the current second, as + * used by mktime(). It is composed of these values: + * + * 1) get_local_timezone_ofs() + * 2) then in transition periods, mktime() will change tm->tm_hour + * according to its understanding (e.g. sprint time, 02:01 is changed + * to 03:01), which is an additional factor that needs to be taken care + * of. This is the (normalized_hour - unnormalized_hour) part below + * + */ + stamp->tv_sec = stamp->tv_sec + /* these two components are the zone offset as used by mktime() */ + + get_local_timezone_ofs(stamp->tv_sec) + - (normalized_hour - unnormalized_hour) * 3600 + /* this is the zone offset value we want to be */ + - stamp->zone_offset; } /* FIXME: this function should really be exploded to a lot of smaller functions... (Bazsi) */ @@ -439,14 +475,14 @@ if (G_UNLIKELY(src[0] == '*')) { if (!(parse_flags & LP_NO_PARSE_DATE)) - log_msg_set_value(self, is_synced, "0", 1); + log_msg_set_value(self, handles.is_synced, "0", 1); src++; left--; } else if (G_UNLIKELY(src[0] == '.')) { if (!(parse_flags & LP_NO_PARSE_DATE)) - log_msg_set_value(self, is_synced, "1", 1); + log_msg_set_value(self, handles.is_synced, "1", 1); src++; left--; } @@ -489,18 +525,9 @@ return FALSE; } -static void -_normalize_time(LogStamp *stamp, struct tm *tm, glong assume_timezone) -{ - tm->tm_isdst = -1; - gint unnormalized_hour = tm->tm_hour; - stamp->tv_sec = cached_mktime(tm); - __set_zone_offset(stamp, assume_timezone); - stamp->tv_sec = __get_normalized_time(*stamp, tm->tm_hour, unnormalized_hour); -} static gboolean -log_msg_parse_date(LogMessage *self, const guchar **data, gint *length, guint parse_flags, glong assume_timezone) +log_msg_parse_date(LogMessage *self, const guchar **data, gint *length, guint parse_flags, glong recv_timezone_ofs) { struct tm tm; @@ -521,7 +548,7 @@ } else { - _normalize_time(stamp, &tm, assume_timezone); + __fixup_hour_in_struct_tm_within_transition_periods(stamp, &tm, recv_timezone_ofs); } return TRUE; @@ -602,7 +629,6 @@ if ((flags & LP_STORE_LEGACY_MSGHDR)) { log_msg_set_value(self, LM_V_LEGACY_MSGHDR, (gchar *) *data, *length - left); - self->flags |= LF_LEGACY_MSGHDR; } *data = src; *length = left; @@ -635,6 +661,47 @@ } } +typedef struct _IPv6Heuristics +{ + gint8 current_segment; + gint8 digits_in_segment; + gboolean heuristic_failed; +} IPv6Heuristics; + +static gboolean +ipv6_heuristics_feed_gchar(IPv6Heuristics *self, gchar c) +{ + if (self->heuristic_failed) + return FALSE; + + if (c != ':' && !g_ascii_isxdigit(c)) + { + self->heuristic_failed = TRUE; + return FALSE; + } + + if (g_ascii_isxdigit(c)) + { + if (++self->digits_in_segment > 4) + { + self->heuristic_failed = TRUE; + return FALSE; + } + } + + if (c == ':') + { + self->digits_in_segment = 0; + if (++self->current_segment >= 8) + { + self->heuristic_failed = TRUE; + return FALSE; + } + } + + return TRUE; +} + static void log_msg_parse_hostname(LogMessage *self, const guchar **data, gint *length, const guchar **hostname_start, int *hostname_len, @@ -646,6 +713,8 @@ gchar hostname_buf[256]; gint dst = 0; + IPv6Heuristics ipv6_heuristics = {0}; + src = *data; left = *length; @@ -655,8 +724,15 @@ oldsrc = src; oldleft = left; - while (left && *src != ' ' && *src != ':' && *src != '[' && dst < sizeof(hostname_buf) - 1) + while (left && *src != ' ' && *src != '[' && dst < sizeof(hostname_buf) - 1) { + ipv6_heuristics_feed_gchar(&ipv6_heuristics, *src); + + if (*src == ':' && ipv6_heuristics.heuristic_failed) + { + break; + } + if (G_UNLIKELY((flags & LP_CHECK_HOSTNAME) && (invalid_chars[((guint) *src) >> 8] & (1 << (((guint) *src) % 8))))) { break; @@ -1186,6 +1262,9 @@ while (length > 0 && (data[length - 1] == '\n' || data[length - 1] == '\0')) length--; + if (parse_options->flags & LP_STORE_RAW_MESSAGE) + log_msg_set_value(self, handles.raw_message, (gchar *) data, length); + if (parse_options->flags & LP_NOPARSE) { log_msg_set_value(self, LM_V_MESSAGE, (gchar *) data, length); @@ -1230,13 +1309,12 @@ void syslog_format_init(void) { - static gboolean handles_initialized = FALSE; - - if (!handles_initialized) + if (!handles.initialized) { - is_synced = log_msg_get_value_handle(".SDATA.timeQuality.isSynced"); - cisco_seqid = log_msg_get_value_handle(".SDATA.meta.sequenceId"); - handles_initialized = TRUE; + handles.is_synced = log_msg_get_value_handle(".SDATA.timeQuality.isSynced"); + handles.cisco_seqid = log_msg_get_value_handle(".SDATA.meta.sequenceId"); + handles.raw_message = log_msg_get_value_handle("RAWMSG"); + handles.initialized = TRUE; } _init_parse_hostname_invalid_chars(); diff -Nru syslog-ng-3.11.1/modules/syslogformat/syslog-format-plugin.c syslog-ng-3.13.2/modules/syslogformat/syslog-format-plugin.c --- syslog-ng-3.11.1/modules/syslogformat/syslog-format-plugin.c 2017-07-31 09:05:32.000000000 +0000 +++ syslog-ng-3.13.2/modules/syslogformat/syslog-format-plugin.c 2017-12-06 06:39:39.000000000 +0000 @@ -32,10 +32,10 @@ .parse = &syslog_format_handler }; -static MsgFormatHandler * -syslog_format_construct(Plugin *self, GlobalConfig *cfg, gint plugin_type, const gchar *plugin_name) +static gpointer +syslog_format_construct(Plugin *self) { - return &syslog_handler; + return (gpointer) &syslog_handler; } static Plugin syslog_format_plugins[] = @@ -43,7 +43,7 @@ { .type = LL_CONTEXT_FORMAT, .name = "syslog", - .construct = (gpointer (*)(Plugin *self, GlobalConfig *cfg, gint plugin_type, const gchar *plugin_name)) syslog_format_construct, + .construct = syslog_format_construct, }, { .type = LL_CONTEXT_PARSER, @@ -53,10 +53,10 @@ }; gboolean -syslogformat_module_init(GlobalConfig *cfg, CfgArgs *args) +syslogformat_module_init(PluginContext *context, CfgArgs *args) { syslog_format_init(); - plugin_register(cfg, syslog_format_plugins, G_N_ELEMENTS(syslog_format_plugins)); + plugin_register(context, syslog_format_plugins, G_N_ELEMENTS(syslog_format_plugins)); return TRUE; } diff -Nru syslog-ng-3.11.1/modules/syslogformat/syslog-parser-parser.h syslog-ng-3.13.2/modules/syslogformat/syslog-parser-parser.h --- syslog-ng-3.11.1/modules/syslogformat/syslog-parser-parser.h 2017-07-31 09:05:32.000000000 +0000 +++ syslog-ng-3.13.2/modules/syslogformat/syslog-parser-parser.h 2017-12-06 06:39:39.000000000 +0000 @@ -25,7 +25,6 @@ #define SYSLOG_PARSER_PARSER_H_INCLUDED #include "cfg-parser.h" -#include "cfg-lexer.h" #include "parser/parser-expr.h" extern CfgParser syslog_parser_parser; diff -Nru syslog-ng-3.11.1/modules/systemd-journal/journald-subsystem.c syslog-ng-3.13.2/modules/systemd-journal/journald-subsystem.c --- syslog-ng-3.11.1/modules/systemd-journal/journald-subsystem.c 2017-07-31 09:05:32.000000000 +0000 +++ syslog-ng-3.13.2/modules/systemd-journal/journald-subsystem.c 2017-12-06 06:39:39.000000000 +0000 @@ -33,7 +33,7 @@ }; gboolean -load_journald_subsystem() +load_journald_subsystem(void) { return TRUE; } @@ -96,7 +96,7 @@ static SD_JOURNAL_GET_REALTIME_USEC sd_journal_get_realtime_usec; static GModule * -_journald_module_open() +_journald_module_open(void) { for (gint i = 0; (journald_libraries[i] != NULL) && !journald_module; i++) journald_module = g_module_open(journald_libraries[i], 0); @@ -105,7 +105,7 @@ } static gboolean -_load_journald_symbols() +_load_journald_symbols(void) { if (!LOAD_SYMBOL(journald_module, sd_journal_open)) return FALSE; @@ -147,7 +147,7 @@ } gboolean -load_journald_subsystem() +load_journald_subsystem(void) { if (!journald_module) { @@ -243,7 +243,7 @@ } Journald * -journald_new() +journald_new(void) { Journald *self = g_new0(Journald, 1); return self; diff -Nru syslog-ng-3.11.1/modules/systemd-journal/journald-subsystem.h syslog-ng-3.13.2/modules/systemd-journal/journald-subsystem.h --- syslog-ng-3.11.1/modules/systemd-journal/journald-subsystem.h 2017-07-31 09:05:32.000000000 +0000 +++ syslog-ng-3.13.2/modules/systemd-journal/journald-subsystem.h 2017-12-06 06:39:39.000000000 +0000 @@ -47,8 +47,8 @@ void journald_foreach_data(Journald *self, FOREACH_DATA_CALLBACK func, gpointer user_data); -gboolean load_journald_subsystem(); -Journald *journald_new(); +gboolean load_journald_subsystem(void); +Journald *journald_new(void); void journald_free(Journald *self); int journald_open(Journald *self, int flags); diff -Nru syslog-ng-3.11.1/modules/systemd-journal/journal-reader.c syslog-ng-3.13.2/modules/systemd-journal/journal-reader.c --- syslog-ng-3.11.1/modules/systemd-journal/journal-reader.c 2017-07-31 09:05:32.000000000 +0000 +++ syslog-ng-3.13.2/modules/systemd-journal/journal-reader.c 2017-12-06 06:39:39.000000000 +0000 @@ -317,6 +317,36 @@ return TRUE; } +static gboolean +_seek_to_tail(JournalReader *self) +{ + gint rc = journald_seek_tail(self->journal); + + if (rc != 0) + { + msg_error("Failed to seek to the end position of the journal", + evt_tag_errno("error", -rc)); + return FALSE; + } + + msg_debug("Seeking to the journal to the end position"); + + return TRUE; +} + +static gboolean +_skip_old_records(JournalReader *self) +{ + if (!_seek_to_tail(self)) + return FALSE; + if (journald_next(self->journal) <= 0) + { + msg_error("Can't move cursor to the next position after seek to tail."); + return FALSE; + } + return TRUE; +} + static inline gboolean _seek_to_saved_state(JournalReader *self) { @@ -345,7 +375,9 @@ if (!_load_state(self)) { _alloc_state(self); - return _seek_to_head(self); + if (self->super.options->read_old_records) + return _seek_to_head(self); + return _skip_old_records(self); } return _seek_to_saved_state(self); } @@ -565,12 +597,12 @@ } void -journal_reader_set_options(LogPipe *s, LogPipe *control, JournalReaderOptions *options, gint stats_level, - gint stats_source, const gchar *stats_id, const gchar *stats_instance) +journal_reader_set_options(LogPipe *s, LogPipe *control, JournalReaderOptions *options, + const gchar *stats_id, const gchar *stats_instance) { JournalReader *self = (JournalReader *) s; - log_source_set_options(&self->super, &options->super, stats_level, stats_source, stats_id, stats_instance, + log_source_set_options(&self->super, &options->super, stats_id, stats_instance, (options->flags & JR_THREADED), TRUE, control->expr_node); log_pipe_unref(self->control); @@ -649,9 +681,12 @@ journal_reader_options_defaults(JournalReaderOptions *options) { log_source_options_defaults(&options->super); + options->super.stats_level = STATS_LEVEL0; + options->super.stats_source = SCS_JOURNALD; options->fetch_limit = DEFAULT_FETCH_LIMIT; options->default_pri = DEFAULT_PRIO; options->max_field_size = DEFAULT_FIELD_SIZE; + options->super.read_old_records = TRUE; } void diff -Nru syslog-ng-3.11.1/modules/systemd-journal/journal-reader.h syslog-ng-3.13.2/modules/systemd-journal/journal-reader.h --- syslog-ng-3.11.1/modules/systemd-journal/journal-reader.h 2017-07-31 09:05:32.000000000 +0000 +++ syslog-ng-3.13.2/modules/systemd-journal/journal-reader.h 2017-12-06 06:39:39.000000000 +0000 @@ -43,7 +43,7 @@ JournalReader *journal_reader_new(GlobalConfig *cfg, Journald *journal); void journal_reader_set_persist_name(JournalReader *self, gchar *persist_name); -void journal_reader_set_options(LogPipe *s, LogPipe *control, JournalReaderOptions *options, gint stats_level, gint stats_source, const gchar *stats_id, const gchar *stats_instance); +void journal_reader_set_options(LogPipe *s, LogPipe *control, JournalReaderOptions *options, const gchar *stats_id, const gchar *stats_instance); void journal_reader_options_init(JournalReaderOptions *options, GlobalConfig *cfg, const gchar *group_name); void journal_reader_options_defaults(JournalReaderOptions *options); diff -Nru syslog-ng-3.11.1/modules/systemd-journal/systemd-journal.c syslog-ng-3.13.2/modules/systemd-journal/systemd-journal.c --- syslog-ng-3.11.1/modules/systemd-journal/systemd-journal.c 2017-07-31 09:05:32.000000000 +0000 +++ syslog-ng-3.13.2/modules/systemd-journal/systemd-journal.c 2017-12-06 06:39:39.000000000 +0000 @@ -51,7 +51,7 @@ journal_reader_options_init(&self->reader_options, cfg, self->super.super.group); - journal_reader_set_options((LogPipe *)self->reader, &self->super.super.super, &self->reader_options, 0, SCS_JOURNALD, + journal_reader_set_options((LogPipe *)self->reader, &self->super.super.super, &self->reader_options, self->super.super.id, "journal"); log_pipe_append((LogPipe *)self->reader, &self->super.super.super); diff -Nru syslog-ng-3.11.1/modules/systemd-journal/systemd-journal-parser.h syslog-ng-3.13.2/modules/systemd-journal/systemd-journal-parser.h --- syslog-ng-3.11.1/modules/systemd-journal/systemd-journal-parser.h 2017-07-31 09:05:32.000000000 +0000 +++ syslog-ng-3.13.2/modules/systemd-journal/systemd-journal-parser.h 2017-12-06 06:39:39.000000000 +0000 @@ -25,7 +25,6 @@ #define AFPROG_PARSER_H_INCLUDED #include "cfg-parser.h" -#include "cfg-lexer.h" #include "driver.h" extern CfgParser systemd_journal_parser; diff -Nru syslog-ng-3.11.1/modules/systemd-journal/systemd-journal-plugin.c syslog-ng-3.13.2/modules/systemd-journal/systemd-journal-plugin.c --- syslog-ng-3.11.1/modules/systemd-journal/systemd-journal-plugin.c 2017-07-31 09:05:32.000000000 +0000 +++ syslog-ng-3.13.2/modules/systemd-journal/systemd-journal-plugin.c 2017-12-06 06:39:39.000000000 +0000 @@ -39,14 +39,14 @@ }; gboolean -systemd_journal_module_init(GlobalConfig *cfg, CfgArgs *args) +systemd_journal_module_init(PluginContext *context, CfgArgs *args) { if (!load_journald_subsystem()) { msg_error("Can't find systemd-journal on this system"); return FALSE; } - plugin_register(cfg, systemd_journal_plugins, G_N_ELEMENTS(systemd_journal_plugins)); + plugin_register(context, systemd_journal_plugins, G_N_ELEMENTS(systemd_journal_plugins)); return TRUE; } diff -Nru syslog-ng-3.11.1/modules/systemd-journal/tests/journald-mock.c syslog-ng-3.13.2/modules/systemd-journal/tests/journald-mock.c --- syslog-ng-3.11.1/modules/systemd-journal/tests/journald-mock.c 2017-07-31 09:05:32.000000000 +0000 +++ syslog-ng-3.13.2/modules/systemd-journal/tests/journald-mock.c 2017-12-06 06:39:39.000000000 +0000 @@ -179,7 +179,7 @@ } Journald * -journald_mock_new() +journald_mock_new(void) { Journald *self = g_new0(Journald, 1); diff -Nru syslog-ng-3.11.1/modules/systemd-journal/tests/journald-mock.h syslog-ng-3.13.2/modules/systemd-journal/tests/journald-mock.h --- syslog-ng-3.11.1/modules/systemd-journal/tests/journald-mock.h 2017-07-31 09:05:32.000000000 +0000 +++ syslog-ng-3.13.2/modules/systemd-journal/tests/journald-mock.h 2017-12-06 06:39:39.000000000 +0000 @@ -28,7 +28,7 @@ typedef struct _MockEntry MockEntry; -Journald *journald_mock_new(); +Journald *journald_mock_new(void); MockEntry *mock_entry_new(const gchar *cursor); diff -Nru syslog-ng-3.11.1/modules/systemd-journal/tests/test-source.c syslog-ng-3.13.2/modules/systemd-journal/tests/test-source.c --- syslog-ng-3.11.1/modules/systemd-journal/tests/test-source.c 2017-07-31 09:05:32.000000000 +0000 +++ syslog-ng-3.13.2/modules/systemd-journal/tests/test-source.c 2017-12-06 06:39:39.000000000 +0000 @@ -51,7 +51,7 @@ self->current_test_case->init(self->current_test_case, self, self->journald_mock, self->reader, &self->options); } journal_reader_options_init(&self->options, configuration, "test"); - journal_reader_set_options((LogPipe *)self->reader, &self->super, &self->options, 3, SCS_JOURNALD, "test", "1"); + journal_reader_set_options((LogPipe *)self->reader, &self->super, &self->options, "test", "1"); log_pipe_append((LogPipe *)self->reader, &self->super); assert_true(log_pipe_init((LogPipe *)self->reader), ASSERTION_ERROR("Can't initialize reader")); return TRUE; diff -Nru syslog-ng-3.11.1/modules/systemd-journal/tests/test_systemd_journal.c syslog-ng-3.13.2/modules/systemd-journal/tests/test_systemd_journal.c --- syslog-ng-3.11.1/modules/systemd-journal/tests/test_systemd_journal.c 2017-07-31 09:05:32.000000000 +0000 +++ syslog-ng-3.13.2/modules/systemd-journal/tests/test_systemd_journal.c 2017-12-06 06:39:39.000000000 +0000 @@ -214,7 +214,7 @@ } void -test_journald_mock() +test_journald_mock(void) { Journald *journald = journald_mock_new(); gint result = journald_open(journald, 0); @@ -241,7 +241,7 @@ void -test_journald_helper() +test_journald_helper(void) { Journald *journald = journald_mock_new(); journald_open(journald, 0); @@ -333,7 +333,7 @@ assert_gint(msg->pri, options->default_pri, ASSERTION_ERROR("Bad default prio")); assert_gint(options->fetch_limit, 10, ASSERTION_ERROR("Bad default fetch_limit")); assert_gint(options->max_field_size, 64 * 1024, ASSERTION_ERROR("Bad max field size")); - assert_gpointer(options->prefix, NULL, ASSERTION_ERROR("Bad default prefix value")); + assert_string(options->prefix, ".journald.", ASSERTION_ERROR("Bad default prefix value")); assert_string(options->recv_time_zone, configuration->recv_time_zone, ASSERTION_ERROR("Bad default timezone")); test_source_finish_tc(src); } @@ -499,7 +499,7 @@ } void -test_journal_reader() +test_journal_reader(void) { TestSource *src = test_source_new(configuration); TestCase tc_default_working = { _test_default_working_init, _test_default_working_test, NULL, NULL }; @@ -527,7 +527,7 @@ { app_startup(); main_thread_handle = get_thread_id(); - configuration = cfg_new_snippet(0x306); + configuration = cfg_new_snippet(); configuration->threaded = FALSE; configuration->state = persist_state_new(TEST_PERSIST_FILE_NAME); configuration->keep_hostname = TRUE; diff -Nru syslog-ng-3.11.1/modules/system-source/system-expand.sh syslog-ng-3.13.2/modules/system-source/system-expand.sh --- syslog-ng-3.11.1/modules/system-source/system-expand.sh 2017-07-31 09:05:32.000000000 +0000 +++ syslog-ng-3.13.2/modules/system-source/system-expand.sh 2017-12-06 06:39:39.000000000 +0000 @@ -29,7 +29,7 @@ create_config () { local cfg="$1" cat >"${cfg}" <str, sysblock->len); + result = TRUE; exit: - g_string_free(sysblock, TRUE); return result; } + +CfgBlockGenerator * +system_source_generator_new(gint context, const gchar *name) +{ + CfgBlockGenerator *self = g_new0(CfgBlockGenerator, 1); + + cfg_block_generator_init_instance(self, context, name); + self->generate = system_source_generate; + return self; +} + +gpointer +system_source_construct(Plugin *p) +{ + return system_source_generator_new(p->type, p->name); +} + +Plugin system_plugins[] = +{ + { + .type = LL_CONTEXT_SOURCE | LL_CONTEXT_FLAG_GENERATOR, + .name = "system", + .construct = system_source_construct + } +}; + gboolean -system_source_module_init(GlobalConfig *cfg, CfgArgs *args) +system_source_module_init(PluginContext *context, CfgArgs *args) { - cfg_lexer_register_block_generator(cfg->lexer, - cfg_lexer_lookup_context_type_by_name("source"), - "system", system_generate_system, - cfg, NULL); + plugin_register(context, system_plugins, 1); return TRUE; } + const ModuleInfo module_info = { .canonical_name = "system-source", .version = SYSLOG_NG_VERSION, .description = "The system-source module provides support for determining the system log sources at run time.", .core_revision = SYSLOG_NG_SOURCE_REVISION, - .plugins = NULL, - .plugins_len = 0, + .plugins = system_plugins, + .plugins_len = G_N_ELEMENTS(system_plugins), }; diff -Nru syslog-ng-3.11.1/modules/tagsparser/CMakeLists.txt syslog-ng-3.13.2/modules/tagsparser/CMakeLists.txt --- syslog-ng-3.11.1/modules/tagsparser/CMakeLists.txt 1970-01-01 00:00:00.000000000 +0000 +++ syslog-ng-3.13.2/modules/tagsparser/CMakeLists.txt 2017-12-06 06:39:39.000000000 +0000 @@ -0,0 +1,23 @@ +set(CSVPARSER_SOURCES + tags-parser.c + tags-parser.h + tags-parser-parser.c + tags-parser-parser.h + tags-parser-plugin.c + ${CMAKE_CURRENT_BINARY_DIR}/tags-parser-grammar.h + ${CMAKE_CURRENT_BINARY_DIR}/tags-parser-grammar.c +) + +generate_y_from_ym(modules/tagsparser/tags-parser-grammar) + +bison_target(CSVParserGrammar + ${CMAKE_CURRENT_BINARY_DIR}/tags-parser-grammar.y + ${CMAKE_CURRENT_BINARY_DIR}/tags-parser-grammar.c + COMPILE_FLAGS ${BISON_FLAGS}) + +include_directories (${CMAKE_CURRENT_BINARY_DIR}) +include_directories (${CMAKE_CURRENT_SOURCE_DIR}) +add_library(tags-parser MODULE ${CSVPARSER_SOURCES}) +target_link_libraries(tags-parser PRIVATE syslog-ng) + +install(TARGETS tags-parser LIBRARY DESTINATION lib/syslog-ng/ COMPONENT tags-parser) diff -Nru syslog-ng-3.11.1/modules/tagsparser/Makefile.am syslog-ng-3.13.2/modules/tagsparser/Makefile.am --- syslog-ng-3.11.1/modules/tagsparser/Makefile.am 1970-01-01 00:00:00.000000000 +0000 +++ syslog-ng-3.13.2/modules/tagsparser/Makefile.am 2017-12-06 06:39:39.000000000 +0000 @@ -0,0 +1,31 @@ +module_LTLIBRARIES += modules/tagsparser/libtags-parser.la +modules_tagsparser_libtags_parser_la_SOURCES = \ + modules/tagsparser/tags-parser.c \ + modules/tagsparser/tags-parser.h \ + modules/tagsparser/tags-parser-grammar.y \ + modules/tagsparser/tags-parser-parser.c \ + modules/tagsparser/tags-parser-parser.h \ + modules/tagsparser/tags-parser-plugin.c + +modules_tagsparser_libtags_parser_la_CPPFLAGS = \ + $(AM_CPPFLAGS) \ + -I$(top_srcdir)/modules/tagsparser \ + -I$(top_builddir)/modules/tagsparser +modules_tagsparser_libtags_parser_la_LIBADD = \ + $(MODULE_DEPS_LIBS) +modules_tagsparser_libtags_parser_la_LDFLAGS = \ + $(MODULE_LDFLAGS) +modules_tagsparser_libtags_parser_la_DEPENDENCIES = \ + $(MODULE_DEPS_LIBS) + +BUILT_SOURCES += \ + modules/tagsparser/tags-parser-grammar.y \ + modules/tagsparser/tags-parser-grammar.c \ + modules/tagsparser/tags-parser-grammar.h +EXTRA_DIST += \ + modules/tagsparser/tags-parser-grammar.ym + +modules/tagsparser modules/tagsparser/ mod-tags-parser: modules/tagsparser/libtags-parser.la +.PHONY: modules/tagsparser/ mod-tags-parser + +include modules/tagsparser/tests/Makefile.am diff -Nru syslog-ng-3.11.1/modules/tagsparser/tags-parser.c syslog-ng-3.13.2/modules/tagsparser/tags-parser.c --- syslog-ng-3.11.1/modules/tagsparser/tags-parser.c 1970-01-01 00:00:00.000000000 +0000 +++ syslog-ng-3.13.2/modules/tagsparser/tags-parser.c 2017-12-06 06:39:39.000000000 +0000 @@ -0,0 +1,78 @@ +/* + * Copyright (c) 2002-2017 Balabit + * Copyright (c) 1998-2017 Balázs Scheidler + * + * This program is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 as published + * by the Free Software Foundation, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + * + * As an additional exemption you are allowed to compile & link against the + * OpenSSL libraries as published by the OpenSSL project. See the file + * COPYING for details. + * + */ + +#include "tags-parser.h" +#include "scanner/list-scanner/list-scanner.h" +#include "parser/parser-expr.h" +#include "scratch-buffers.h" + +#include + +typedef struct _TagsParser +{ + LogParser super; +} TagsParser; + +static gboolean +_process(LogParser *s, LogMessage **pmsg, const LogPathOptions *path_options, const gchar *input, + gsize input_len) +{ + LogMessage *msg = log_msg_make_writable(pmsg, path_options); + + ListScanner scanner; + list_scanner_init(&scanner); + list_scanner_input_va(&scanner, input, NULL); + + while (list_scanner_scan_next(&scanner)) + { + log_msg_set_tag_by_name(msg, list_scanner_get_current_value(&scanner)); + } + + list_scanner_deinit(&scanner); + return TRUE; +} + +static LogPipe * +tags_parser_clone(LogPipe *s) +{ + TagsParser *self = (TagsParser *) s; + TagsParser *cloned; + + cloned = (TagsParser *) tags_parser_new(s->cfg); + cloned->super.template = log_template_ref(self->super.template); + return &cloned->super.super; +} + +/* + * Parse comma-separated values from a log message. + */ +LogParser * +tags_parser_new(GlobalConfig *cfg) +{ + TagsParser *self = g_new0(TagsParser, 1); + + log_parser_init_instance(&self->super, cfg); + self->super.super.clone = tags_parser_clone; + self->super.process = _process; + return &self->super; +} diff -Nru syslog-ng-3.11.1/modules/tagsparser/tags-parser-grammar.ym syslog-ng-3.13.2/modules/tagsparser/tags-parser-grammar.ym --- syslog-ng-3.11.1/modules/tagsparser/tags-parser-grammar.ym 1970-01-01 00:00:00.000000000 +0000 +++ syslog-ng-3.13.2/modules/tagsparser/tags-parser-grammar.ym 2017-12-06 06:39:39.000000000 +0000 @@ -0,0 +1,83 @@ +/* + * Copyright (c) 2002-2017 Balabit + * Copyright (c) 1998-2017 Balázs Scheidler + * + * This program is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 as published + * by the Free Software Foundation, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + * + * As an additional exemption you are allowed to compile & link against the + * OpenSSL libraries as published by the OpenSSL project. See the file + * COPYING for details. + * + */ + +%code top { +#include "tags-parser-parser.h" + +} + + +%code { + +#include "tags-parser.h" +#include "cfg-parser.h" +#include "cfg-grammar.h" +#include "tags-parser-grammar.h" +#include "syslog-names.h" +#include "messages.h" + +} + +%name-prefix "tags_parser_" + +/* this parameter is needed in order to instruct bison to use a complete + * argument list for yylex/yyerror */ + +%lex-param {CfgLexer *lexer} +%parse-param {CfgLexer *lexer} +%parse-param {LogParser **instance} +%parse-param {gpointer arg} + +/* INCLUDE_DECLS */ + +%token KW_TAGS_PARSER + +%type parser_expr_tags + +%% + +start + : LL_CONTEXT_PARSER parser_expr_tags { YYACCEPT; } + ; + + +parser_expr_tags + : KW_TAGS_PARSER '(' + { + last_parser = *instance = tags_parser_new(configuration); + } + parser_tags_opts ')' { $$ = last_parser; } + ; + +parser_tags_opts + : parser_tags_opt parser_tags_opts + | + ; + +parser_tags_opt + : parser_opt + ; + +/* INCLUDE_RULES */ + +%% diff -Nru syslog-ng-3.11.1/modules/tagsparser/tags-parser.h syslog-ng-3.13.2/modules/tagsparser/tags-parser.h --- syslog-ng-3.11.1/modules/tagsparser/tags-parser.h 1970-01-01 00:00:00.000000000 +0000 +++ syslog-ng-3.13.2/modules/tagsparser/tags-parser.h 2017-12-06 06:39:39.000000000 +0000 @@ -0,0 +1,32 @@ +/* + * Copyright (c) 2002-2017 Balabit + * Copyright (c) 1998-2017 Balázs Scheidler + * + * This program is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 as published + * by the Free Software Foundation, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + * + * As an additional exemption you are allowed to compile & link against the + * OpenSSL libraries as published by the OpenSSL project. See the file + * COPYING for details. + * + */ + +#ifndef TAGS_PARSER_H_INCLUDED +#define TAGS_PARSER_H_INCLUDED + +#include "parser/parser-expr.h" + +LogParser *tags_parser_new(GlobalConfig *cfg); + + +#endif diff -Nru syslog-ng-3.11.1/modules/tagsparser/tags-parser-parser.c syslog-ng-3.13.2/modules/tagsparser/tags-parser-parser.c --- syslog-ng-3.11.1/modules/tagsparser/tags-parser-parser.c 1970-01-01 00:00:00.000000000 +0000 +++ syslog-ng-3.13.2/modules/tagsparser/tags-parser-parser.c 2017-12-06 06:39:39.000000000 +0000 @@ -0,0 +1,49 @@ +/* + * Copyright (c) 2002-2017 Balabit + * Copyright (c) 1998-2017 Balázs Scheidler + * + * This program is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 as published + * by the Free Software Foundation, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + * + * As an additional exemption you are allowed to compile & link against the + * OpenSSL libraries as published by the OpenSSL project. See the file + * COPYING for details. + * + */ + +#include "tags-parser.h" +#include "cfg-parser.h" +#include "tags-parser-grammar.h" + +extern int tags_parser_debug; + +int tags_parser_parse(CfgLexer *lexer, LogParser **instance, gpointer arg); + +static CfgLexerKeyword tags_parser_keywords[] = +{ + { "tags_parser", KW_TAGS_PARSER }, + { NULL } +}; + +CfgParser tags_parser_parser = +{ +#if SYSLOG_NG_ENABLE_DEBUG + .debug_flag = &tags_parser_debug, +#endif + .name = "tags_parser", + .keywords = tags_parser_keywords, + .parse = (gint (*)(CfgLexer *, gpointer *, gpointer)) tags_parser_parse, + .cleanup = (void (*)(gpointer)) log_pipe_unref, +}; + +CFG_PARSER_IMPLEMENT_LEXER_BINDING(tags_parser_, LogParser **) diff -Nru syslog-ng-3.11.1/modules/tagsparser/tags-parser-parser.h syslog-ng-3.13.2/modules/tagsparser/tags-parser-parser.h --- syslog-ng-3.11.1/modules/tagsparser/tags-parser-parser.h 1970-01-01 00:00:00.000000000 +0000 +++ syslog-ng-3.13.2/modules/tagsparser/tags-parser-parser.h 2017-12-06 06:39:39.000000000 +0000 @@ -0,0 +1,35 @@ +/* + * Copyright (c) 2002-2017 Balabit + * Copyright (c) 1998-2017 Balázs Scheidler + * + * This program is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 as published + * by the Free Software Foundation, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + * + * As an additional exemption you are allowed to compile & link against the + * OpenSSL libraries as published by the OpenSSL project. See the file + * COPYING for details. + * + */ + +#ifndef TAGS_PARSER_PARSER_H_INCLUDED +#define TAGS_PARSER_PARSER_H_INCLUDED + +#include "cfg-parser.h" +#include "cfg-lexer.h" +#include "parser/parser-expr.h" + +extern CfgParser tags_parser_parser; + +CFG_PARSER_DECLARE_LEXER_BINDING(tags_parser_, LogParser **) + +#endif diff -Nru syslog-ng-3.11.1/modules/tagsparser/tags-parser-plugin.c syslog-ng-3.13.2/modules/tagsparser/tags-parser-plugin.c --- syslog-ng-3.11.1/modules/tagsparser/tags-parser-plugin.c 1970-01-01 00:00:00.000000000 +0000 +++ syslog-ng-3.13.2/modules/tagsparser/tags-parser-plugin.c 2017-12-06 06:39:39.000000000 +0000 @@ -0,0 +1,55 @@ +/* + * Copyright (c) 2002-2017 Balabit + * Copyright (c) 1998-2017 Balázs Scheidler + * + * This program is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 as published + * by the Free Software Foundation, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + * + * As an additional exemption you are allowed to compile & link against the + * OpenSSL libraries as published by the OpenSSL project. See the file + * COPYING for details. + * + */ + +#include "cfg-parser.h" +#include "tags-parser.h" +#include "plugin.h" +#include "plugin-types.h" + +extern CfgParser tags_parser_parser; + +static Plugin tags_parser_plugins[] = +{ + { + .type = LL_CONTEXT_PARSER, + .name = "tags-parser", + .parser = &tags_parser_parser, + }, +}; + +gboolean +tags_parser_module_init(PluginContext *context, CfgArgs *args) +{ + plugin_register(context, tags_parser_plugins, G_N_ELEMENTS(tags_parser_plugins)); + return TRUE; +} + +const ModuleInfo module_info = +{ + .canonical_name = "tags_parser", + .version = SYSLOG_NG_VERSION, + .description = "The tags_parser module provides parsing support for restoring message tags as produced by the TAGS macro.", + .core_revision = SYSLOG_NG_SOURCE_REVISION, + .plugins = tags_parser_plugins, + .plugins_len = G_N_ELEMENTS(tags_parser_plugins), +}; diff -Nru syslog-ng-3.11.1/modules/tagsparser/tests/Makefile.am syslog-ng-3.13.2/modules/tagsparser/tests/Makefile.am --- syslog-ng-3.11.1/modules/tagsparser/tests/Makefile.am 1970-01-01 00:00:00.000000000 +0000 +++ syslog-ng-3.13.2/modules/tagsparser/tests/Makefile.am 2017-12-06 06:39:39.000000000 +0000 @@ -0,0 +1,16 @@ +if ENABLE_CRITERION + +modules_tagsparser_tests_TESTS = modules/tagsparser/tests/test_tagsparser + +check_PROGRAMS += \ + ${modules_tagsparser_tests_TESTS} + +modules_tagsparser_tests_test_tagsparser_CFLAGS = \ + $(TEST_CFLAGS) -I$(top_srcdir)/modules/tagsparser +modules_tagsparser_tests_test_tagsparser_LDADD = \ + $(TEST_LDADD) +modules_tagsparser_tests_test_tagsparser_LDFLAGS = \ + $(PREOPEN_SYSLOGFORMAT) \ + -dlpreopen $(top_builddir)/modules/tagsparser/libtags-parser.la + +endif diff -Nru syslog-ng-3.11.1/modules/tagsparser/tests/test_tagsparser.c syslog-ng-3.13.2/modules/tagsparser/tests/test_tagsparser.c --- syslog-ng-3.11.1/modules/tagsparser/tests/test_tagsparser.c 1970-01-01 00:00:00.000000000 +0000 +++ syslog-ng-3.13.2/modules/tagsparser/tests/test_tagsparser.c 2017-12-06 06:39:39.000000000 +0000 @@ -0,0 +1,90 @@ +/* + * Copyright (c) 2017 Balabit + * + * This program is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 as published + * by the Free Software Foundation, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + * + * As an additional exemption you are allowed to compile & link against the + * OpenSSL libraries as published by the OpenSSL project. See the file + * COPYING for details. + */ + + +#include +#include +#include "tags-parser.h" +#include "apphook.h" +#include "msg_parse_lib.h" +#include "template_lib.h" + +void +setup(void) +{ + configuration = cfg_new_snippet(); + app_startup(); +} + +void +teardown(void) +{ + app_shutdown(); + cfg_free(configuration); +} + +TestSuite(tagsparser, .init = setup, .fini = teardown); + +Test(tagsparser, input_list_is_transferred_to_a_list_of_tags) +{ + LogParser *tags_parser = tags_parser_new(configuration); + + log_pipe_init((LogPipe *)tags_parser); + + LogMessage *msg = log_msg_new_empty(); + log_msg_set_value(msg, LM_V_MESSAGE, "foo,bar,baz", -1); + log_msg_set_tag_by_name(msg, "tag-already-set"); + + LogPathOptions path_options = LOG_PATH_OPTIONS_INIT; + cr_assert(log_parser_process_message(tags_parser, &msg, &path_options)); + + assert_log_message_has_tag(msg, "foo"); + assert_log_message_has_tag(msg, "bar"); + assert_log_message_has_tag(msg, "baz"); + assert_log_message_has_tag(msg, "tag-already-set"); + + log_pipe_deinit((LogPipe *)tags_parser); + log_pipe_unref((LogPipe *)tags_parser); + log_msg_unref(msg); +} + +Test(tagsparser, template_argument_uses_that_instead_of_MSG) +{ + LogParser *tags_parser = tags_parser_new(configuration); + LogTemplate *template = compile_template("${PROGRAM}", FALSE); + + log_pipe_init((LogPipe *) tags_parser); + + LogMessage *msg = log_msg_new_empty(); + log_msg_set_value(msg, LM_V_PROGRAM, "foo,bar,baz", -1); + + log_parser_set_template(tags_parser, template); + LogPathOptions path_options = LOG_PATH_OPTIONS_INIT; + cr_assert(log_parser_process_message(tags_parser, &msg, &path_options)); + + assert_log_message_has_tag(msg, "foo"); + assert_log_message_has_tag(msg, "bar"); + assert_log_message_has_tag(msg, "baz"); + + log_pipe_deinit((LogPipe *)tags_parser); + log_pipe_unref((LogPipe *)tags_parser); + log_msg_unref(msg); +} diff -Nru syslog-ng-3.11.1/modules/xml/CMakeLists.txt syslog-ng-3.13.2/modules/xml/CMakeLists.txt --- syslog-ng-3.11.1/modules/xml/CMakeLists.txt 1970-01-01 00:00:00.000000000 +0000 +++ syslog-ng-3.13.2/modules/xml/CMakeLists.txt 2017-12-06 06:39:39.000000000 +0000 @@ -0,0 +1,32 @@ +set(xml_HEADERS + "xml-parser.h" + "xml.h" + "${CMAKE_CURRENT_BINARY_DIR}/xml-grammar.h" +) + +set(xml_SOURCES + "xml-plugin.c" + "xml-parser.c" + "xml.c" + "${CMAKE_CURRENT_BINARY_DIR}/xml-grammar.c" +) + +generate_y_from_ym(modules/xml/xml-grammar) + +bison_target(xmlGrammar + ${CMAKE_CURRENT_BINARY_DIR}/xml-grammar.y + ${CMAKE_CURRENT_BINARY_DIR}/xml-grammar.c +COMPILE_FLAGS ${BISON_FLAGS}) + +option(ENABLE_xml "Enable xml ON") + +if (ENABLE_xml) + include_directories (${CMAKE_CURRENT_BINARY_DIR}) + include_directories (${CMAKE_CURRENT_SOURCE_DIR}) + add_library(xml MODULE ${xml_SOURCES}) + target_link_libraries(xml PRIVATE syslog-ng) + + install(TARGETS xml + LIBRARY DESTINATION lib/syslog-ng/ + COMPONENT xml) +endif() diff -Nru syslog-ng-3.11.1/modules/xml/Makefile.am syslog-ng-3.13.2/modules/xml/Makefile.am --- syslog-ng-3.11.1/modules/xml/Makefile.am 1970-01-01 00:00:00.000000000 +0000 +++ syslog-ng-3.13.2/modules/xml/Makefile.am 2017-12-06 06:39:39.000000000 +0000 @@ -0,0 +1,30 @@ +module_LTLIBRARIES += modules/xml/libxml.la +modules_xml_libxml_la_SOURCES = \ + modules/xml/xml-grammar.y \ + modules/xml/xml-parser.c \ + modules/xml/xml-parser.h \ + modules/xml/xml-plugin.c \ + modules/xml/xml.h \ + modules/xml/xml.c + + +BUILT_SOURCES += \ + modules/xml/xml-grammar.y \ + modules/xml/xml-grammar.c \ + modules/xml/xml-grammar.h + +EXTRA_DIST += \ + modules/xml/xml-grammar.ym + +modules_xml_libxml_la_CPPFLAGS = \ + $(AM_CPPFLAGS) \ + -I$(top_srcdir)/modules/xml \ + -I$(top_builddir)/modules/xml +modules_xml_libxml_la_LIBADD = $(MODULE_DEPS_LIBS) +modules_xml_libxml_la_LDFLAGS = $(MODULE_LDFLAGS) +modules_xml_libxml_la_DEPENDENCIES= $(MODULE_DEPS_LIBS) + +modules/xml modules/xml/ mod-xml: modules/xml/libxml.la +.PHONY: modules/xml/ mod-xml + +include modules/xml/tests/Makefile.am diff -Nru syslog-ng-3.11.1/modules/xml/tests/Makefile.am syslog-ng-3.13.2/modules/xml/tests/Makefile.am --- syslog-ng-3.11.1/modules/xml/tests/Makefile.am 1970-01-01 00:00:00.000000000 +0000 +++ syslog-ng-3.13.2/modules/xml/tests/Makefile.am 2017-12-06 06:39:39.000000000 +0000 @@ -0,0 +1,15 @@ +if ENABLE_CRITERION + +modules_xml_tests_TESTS = \ + modules/xml/tests/test_xml_parser + +check_PROGRAMS += ${modules_xml_tests_TESTS} + +modules_xml_tests_test_xml_parser_CFLAGS = $(TEST_CFLAGS) -I$(top_srcdir)/modules/xml +modules_xml_tests_test_xml_parser_LDADD = $(TEST_LDADD) +modules_xml_tests_test_xml_parser_LDFLAGS = \ + $(PREOPEN_SYSLOGFORMAT) \ + -dlpreopen $(top_builddir)/modules/xml/libxml.la +modules_xml_tests_test_xml_parser_DEPENDENCIES = $(top_builddir)/modules/xml/libxml.la + +endif diff -Nru syslog-ng-3.11.1/modules/xml/tests/test_xml_parser.c syslog-ng-3.13.2/modules/xml/tests/test_xml_parser.c --- syslog-ng-3.11.1/modules/xml/tests/test_xml_parser.c 1970-01-01 00:00:00.000000000 +0000 +++ syslog-ng-3.13.2/modules/xml/tests/test_xml_parser.c 2017-12-06 06:39:39.000000000 +0000 @@ -0,0 +1,353 @@ +/* + * Copyright (c) 2017 Balabit + * + * This program is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 as published + * by the Free Software Foundation, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + * + * As an additional exemption you are allowed to compile & link against the + * OpenSSL libraries as published by the OpenSSL project. See the file + * COPYING for details. + */ + + +#include +#include +#include "msg_parse_lib.h" +#include "xml.h" +#include "apphook.h" +#include "scratch-buffers.h" + +void +setup(void) +{ + configuration = cfg_new_snippet(); + app_startup(); +} + +void +teardown(void) +{ + scratch_buffers_explicit_gc(); + app_shutdown(); + cfg_free(configuration); +} + +typedef struct +{ + gboolean forward_invalid; + gboolean strip_whitespaces; + GList *exclude_tags; +} XMLParserTestOptions; + +static LogParser * +_construct_xml_parser(XMLParserTestOptions options) +{ + LogParser *xml_parser = xml_parser_new(configuration); + xml_parser_set_forward_invalid(xml_parser, options.forward_invalid); + xml_parser_set_strip_whitespaces(xml_parser, options.strip_whitespaces); + xml_parser_set_exclude_tags(xml_parser, options.exclude_tags); + + LogPipe *cloned = xml_parser_clone(&xml_parser->super); + log_pipe_init(cloned); + log_pipe_unref(&xml_parser->super); + return (LogParser *)cloned; +} + +TestSuite(xmlparser, .init = setup, .fini = teardown); + +typedef struct +{ + const gchar *input; +} XMLFailTestCase; + +ParameterizedTestParameters(xmlparser, invalid_inputs) +{ + static XMLFailTestCase test_cases[] = + { + {"simple string"}, + {""}, + {""}, + {""}, + {"closewrongorder"}, + {""}, + {""}, + {""}, + {""}, + {">"}, + }; + + return cr_make_param_array(XMLFailTestCase, test_cases, sizeof(test_cases) / sizeof(test_cases[0])); +} + +ParameterizedTest(XMLFailTestCase *test_case, xmlparser, invalid_inputs) +{ + LogParser *xml_parser = _construct_xml_parser((XMLParserTestOptions) {}); + + LogMessage *msg = log_msg_new_empty(); + log_msg_set_value(msg, LM_V_MESSAGE, test_case->input, -1); + + LogPathOptions path_options = LOG_PATH_OPTIONS_INIT; + cr_assert_not(log_parser_process_message(xml_parser, &msg, &path_options)); + + log_pipe_deinit((LogPipe *)xml_parser); + log_pipe_unref((LogPipe *)xml_parser); + log_msg_unref(msg); +} + +typedef struct +{ + const gchar *input; + const gchar *key; + const gchar *value; +} ValidXMLTestCase; + +ParameterizedTestParameters(xmlparser, valid_inputs) +{ + static ValidXMLTestCase test_cases[] = + { + {"value1", ".xml.tag1", "value1"}, + {"value1", ".xml.tag1._attr", "attr_value"}, + {"value2", ".xml.tag1.tag2", "value2"}, + {"part1value2part2", ".xml.tag1", "part1part2"}, + {"value", ".xml.tag1.tag12.tag121", "value"}, + {"value", ".xml.tag1.tag12.tag121._attr1", "1"}, + {"value", ".xml.tag1.tag12.tag121._attr2", "2"}, + {"t11.1t11.2", ".xml.tag1.tag1", "t11.1t11.2"}, + }; + + return cr_make_param_array(ValidXMLTestCase, test_cases, sizeof(test_cases) / sizeof(test_cases[0])); +} + + +ParameterizedTest(ValidXMLTestCase *test_cases, xmlparser, valid_inputs) +{ + LogParser *xml_parser = _construct_xml_parser((XMLParserTestOptions) {}); + + LogMessage *msg = log_msg_new_empty(); + log_msg_set_value(msg, LM_V_MESSAGE, test_cases->input, -1); + + LogPathOptions path_options = LOG_PATH_OPTIONS_INIT; + log_parser_process_message(xml_parser, &msg, &path_options); + + const gchar *value = log_msg_get_value_by_name(msg, test_cases->key, NULL); + + cr_assert_str_eq(value, test_cases->value, "key: %s | value: %s != %s (expected)", test_cases->key, value, + test_cases->value); + + log_pipe_deinit((LogPipe *)xml_parser); + log_pipe_unref((LogPipe *)xml_parser); + log_msg_unref(msg); +} + +Test(xml_parser, test_drop_invalid) +{ + setup(); + + LogParser *xml_parser = _construct_xml_parser((XMLParserTestOptions) {}); + + LogMessage *msg = log_msg_new_empty(); + log_msg_set_value(msg, LM_V_MESSAGE, "", -1); + + LogPathOptions path_options = LOG_PATH_OPTIONS_INIT; + xml_parser_set_forward_invalid(xml_parser, FALSE); + cr_assert_not(log_parser_process_message(xml_parser, &msg, &path_options)); + + xml_parser_set_forward_invalid(xml_parser, TRUE); + cr_assert(log_parser_process_message(xml_parser, &msg, &path_options)); + + log_pipe_deinit((LogPipe *)xml_parser); + log_pipe_unref((LogPipe *)xml_parser); + log_msg_unref(msg); + + teardown(); +} + +typedef struct +{ + const gchar *input; + gchar *pattern; + const gchar *key; + const gchar *value; +} SingleExcludeTagTestCase; + +ParameterizedTestParameters(xmlparser, single_exclude_tags) +{ + static SingleExcludeTagTestCase test_cases[] = + { + /* Negative */ + {"Text", "longtag", ".xml.longtag", ""}, + {"Text", "longt?g", ".xml.longtag", ""}, + {"Text", "?ongtag", ".xml.longtag", ""}, + {"Text", "longta?", ".xml.longtag", ""}, + {"Text", "lon?ta?", ".xml.longtag", ""}, + {"Text", "longt*", ".xml.longtag", ""}, + {"Text", "*tag", ".xml.longtag", ""}, + {"Text", "lo*gtag", ".xml.longtag", ""}, + {"Text", "long*ag", ".xml.longtag", ""}, + {"Text", "*", ".xml.longtag", ""}, + /* Positive */ + {"Text", "longtag_break", ".xml.longtag", "Text"}, + {"Text", "longt?g_break", ".xml.longtag", "Text"}, + {"Text", "?ongtag_break", ".xml.longtag", "Text"}, + {"Text", "longta?_break", ".xml.longtag", "Text"}, + {"Text", "lon?ta?_break", ".xml.longtag", "Text"}, + {"Text", "break_longt*", ".xml.longtag", "Text"}, + {"Text", "lo*gtag_break", ".xml.longtag", "Text"}, + {"Text", "break_long*ag", ".xml.longtag", "Text"}, + {"Text", "*tag_break", ".xml.longtag", "Text"}, + /* Complex */ + {"OuterInner", "inner", ".xml.longtag", "Outer"}, + {"OuterInner", "inner", ".xml.longtag.inner", ""}, + { + "excude1TextnotexcludeTextexcude2Text", + "exclude", ".xml.exclude", "" + }, + { + "excude1TextnotexcludeTextexcude2Text", + "exclude", ".xml.exclude", "" + }, + { + "excude1TextnotexcludeTextexcude2Text", + "exclude", ".xml.notexclude.exclude", "" + }, + { + "excude1TextnotexcludeTextexcude2Text", + "exclude", ".xml.notexclude", "notexcludeText" + }, + }; + + return cr_make_param_array(SingleExcludeTagTestCase, test_cases, sizeof(test_cases) / sizeof(test_cases[0])); +} + +ParameterizedTest(SingleExcludeTagTestCase *test_cases, xmlparser, single_exclude_tags) +{ + GList *exclude_tags = NULL; + exclude_tags = g_list_append(exclude_tags, test_cases->pattern); + + LogParser *xml_parser = _construct_xml_parser((XMLParserTestOptions) + { + .exclude_tags = exclude_tags + }); + + LogMessage *msg = log_msg_new_empty(); + log_msg_set_value(msg, LM_V_MESSAGE, test_cases->input, -1); + + LogPathOptions path_options = LOG_PATH_OPTIONS_INIT; + log_parser_process_message(xml_parser, &msg, &path_options); + + const gchar *value = log_msg_get_value_by_name(msg, test_cases->key, NULL); + cr_assert_str_eq(value, test_cases->value, "key: %s | value: %s, should be %s", test_cases->key, value, + test_cases->value); + + log_pipe_deinit((LogPipe *)xml_parser); + log_pipe_unref((LogPipe *)xml_parser); + log_msg_unref(msg); + + g_list_free(exclude_tags); +} + +Test(xml_parser, test_multiple_exclude_tags) +{ + setup(); + + GList *exclude_tags = NULL; + exclude_tags = g_list_append(exclude_tags, "tag1"); + exclude_tags = g_list_append(exclude_tags, "tag2"); + exclude_tags = g_list_append(exclude_tags, "inner*"); + + LogParser *xml_parser = _construct_xml_parser((XMLParserTestOptions) + { + .exclude_tags = exclude_tags + }); + + LogMessage *msg = log_msg_new_empty(); + log_msg_set_value(msg, LM_V_MESSAGE, + "Text1Text2Text3TextInner", -1); + + const gchar *value; + LogPathOptions path_options = LOG_PATH_OPTIONS_INIT; + log_parser_process_message(xml_parser, &msg, &path_options); + + value = log_msg_get_value_by_name(msg, ".xml.tag1", NULL); + cr_assert_str_eq(value, ""); + value = log_msg_get_value_by_name(msg, ".xml.tag2", NULL); + cr_assert_str_eq(value, ""); + value = log_msg_get_value_by_name(msg, ".xml.tag3", NULL); + cr_assert_str_eq(value, "Text3"); + value = log_msg_get_value_by_name(msg, ".xml.tag3.innertag", NULL); + cr_assert_str_eq(value, ""); + + log_pipe_deinit((LogPipe *)xml_parser); + log_pipe_unref((LogPipe *)xml_parser); + log_msg_unref(msg); + + g_list_free(exclude_tags); + + teardown(); +} + +Test(xml_parser, shouldreverse) +{ + GList *with_wildcard; + + with_wildcard = NULL; + with_wildcard = g_list_append(with_wildcard, "tag1"); + with_wildcard = g_list_append(with_wildcard, "tag2"); + with_wildcard = g_list_append(with_wildcard, "tag*"); + cr_assert(joker_or_wildcard(with_wildcard)); + g_list_free(with_wildcard); + + GList *with_joker = NULL; + with_joker = g_list_append(with_joker, "tag1"); + with_joker = g_list_append(with_joker, "t?g2"); + with_joker = g_list_append(with_joker, "tag3"); + cr_assert(joker_or_wildcard(with_joker)); + g_list_free(with_joker); + + GList *no_joker_or_wildcard = NULL; + no_joker_or_wildcard = g_list_append(no_joker_or_wildcard, "tag1"); + no_joker_or_wildcard = g_list_append(no_joker_or_wildcard, "tag2"); + no_joker_or_wildcard = g_list_append(no_joker_or_wildcard, "tag3"); + cr_assert_not(joker_or_wildcard(no_joker_or_wildcard)); + g_list_free(no_joker_or_wildcard); + +} + +Test(xml_parser, test_strip_whitespaces) +{ + setup(); + + LogParser *xml_parser = _construct_xml_parser((XMLParserTestOptions) + { + .strip_whitespaces = TRUE + }); + + LogMessage *msg = log_msg_new_empty(); + log_msg_set_value(msg, LM_V_MESSAGE, + " \n\t part1 part2 \n\n", -1); + + const gchar *value; + LogPathOptions path_options = LOG_PATH_OPTIONS_INIT; + log_parser_process_message(xml_parser, &msg, &path_options); + + value = log_msg_get_value_by_name(msg, ".xml.tag", NULL); + cr_assert_str_eq(value, "part1part2"); + + log_pipe_deinit((LogPipe *)xml_parser); + log_pipe_unref((LogPipe *)xml_parser); + log_msg_unref(msg); + + teardown(); +} diff -Nru syslog-ng-3.11.1/modules/xml/xml.c syslog-ng-3.13.2/modules/xml/xml.c --- syslog-ng-3.11.1/modules/xml/xml.c 1970-01-01 00:00:00.000000000 +0000 +++ syslog-ng-3.13.2/modules/xml/xml.c 2017-12-06 06:39:39.000000000 +0000 @@ -0,0 +1,377 @@ +/* + * Copyright (c) 2017 Balabit + * + * This program is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 as published + * by the Free Software Foundation, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + * + * As an additional exemption you are allowed to compile & link against the + * OpenSSL libraries as published by the OpenSSL project. See the file + * COPYING for details. + * + */ + +#include "xml.h" +#include "scratch-buffers.h" + +typedef struct +{ + LogMessage *msg; + GString *key; + gboolean pop_next_time; + XMLParser *parser; +} InserterState; + +static void +remove_trailing_dot(gchar *str) +{ + g_assert(strlen(str)); + if (str[strlen(str)-1] == '.') + str[strlen(str)-1] = 0; +} + +static void +msg_add_attributes(LogMessage *msg, GString *key, const gchar **names, const gchar **values) +{ + GString *attr_key; + + if (names[0]) + { + attr_key = scratch_buffers_alloc(); + g_string_assign(attr_key, key->str); + g_string_append(attr_key, "._"); + } + else + return; + + gint base_index = attr_key->len; + gint attrs = 0; + + while (names[attrs]) + { + attr_key = g_string_overwrite(attr_key, base_index, names[attrs]); + log_msg_set_value_by_name(msg, attr_key->str, values[attrs], -1); + attrs++; + } +} + +static gboolean +tag_matches_patterns(const GPtrArray *patterns, const gint tag_length, + const gchar *element_name, const gchar *reversed_name) +{ + for (int i = 0; i < patterns->len; i++) + if (g_pattern_match((GPatternSpec *)g_ptr_array_index(patterns, i), + tag_length, element_name, reversed_name)) + { + return TRUE; + } + + return FALSE; +} + +static GMarkupParser skip = {}; + +static void +start_element_cb(GMarkupParseContext *context, + const gchar *element_name, + const gchar **attribute_names, + const gchar **attribute_values, + gpointer user_data, + GError **error) +{ + InserterState *state = (InserterState *)user_data; + + gchar *reversed = NULL; + guint tag_length = strlen(element_name); + + if (state->parser->matchstring_shouldreverse) + { + reversed = g_utf8_strreverse(element_name, tag_length); + } + + if (tag_matches_patterns(state->parser->exclude_patterns, tag_length, element_name, reversed)) + { + msg_debug("xml: subtree skipped", evt_tag_str("tag", element_name)); + state->pop_next_time = 1; + g_markup_parse_context_push(context, &skip, NULL); + g_free(reversed); + return; + } + + g_string_append_c(state->key, '.'); + g_string_append(state->key, element_name); + msg_add_attributes(state->msg, state->key, attribute_names, attribute_values); + + g_free(reversed); +} + +static gint +before_last_dot(GString *str) +{ + const gchar *s = str->str; + gchar *pos = strrchr(s, '.'); + return (pos-s); +} + +static void +end_element_cb(GMarkupParseContext *context, + const gchar *element_name, + gpointer user_data, + GError **error) +{ + InserterState *state = (InserterState *)user_data; + + if (state->pop_next_time) + { + g_markup_parse_context_pop(context); + state->pop_next_time = 0; + return; + } + g_string_truncate(state->key, before_last_dot(state->key)); +} + +static GString * +_append_strip(const gchar *current, const gchar *text, gsize text_len) +{ + gchar *text_to_append = NULL; + text_to_append = g_strndup(text, text_len); + g_strstrip(text_to_append); + + if (!text_to_append[0]) + { + g_free(text_to_append); + return NULL; + } + + GString *value = scratch_buffers_alloc(); + g_string_assign(value, current); + g_string_append(value, text_to_append); + g_free(text_to_append); + + return value; +} + +static GString * +_append_text(const gchar *current, const gchar *text, gsize text_len, XMLParser *parser) +{ + if (parser->strip_whitespaces) + { + return _append_strip(current, text, text_len); + } + else + { + GString *value = scratch_buffers_alloc(); + g_string_assign(value, current); + g_string_append_len(value, text, text_len); + return value; + } +} + +static void +text_cb(GMarkupParseContext *context, + const gchar *text, + gsize text_len, + gpointer user_data, + GError **error) +{ + if (text_len == 0) + return; + + InserterState *state = (InserterState *)user_data; + const gchar *current_value = log_msg_get_value_by_name(state->msg, state->key->str, NULL); + + GString *value = _append_text(current_value, text, text_len, state->parser); + if (value) + log_msg_set_value_by_name(state->msg, state->key->str, value->str, value->len); +} + + +static GMarkupParser xml_scanner = +{ + .start_element = start_element_cb, + .end_element = end_element_cb, + .text = text_cb +}; + +static gboolean +xml_parser_process(LogParser *s, LogMessage **pmsg, + const LogPathOptions *path_options, + const gchar *input, gsize input_len) +{ + XMLParser *self = (XMLParser *) s; + LogMessage *msg = log_msg_make_writable(pmsg, path_options); + + GString *key = scratch_buffers_alloc(); + key = g_string_append(key, self->prefix); + + InserterState state = { .msg = msg, .key = key, .parser = self }; + GMarkupParseContext *xml_ctx = g_markup_parse_context_new(&xml_scanner, 0, &state, NULL); + + GError *error = NULL; + g_markup_parse_context_parse(xml_ctx, input, input_len, &error); + if (error) + goto err; + + g_markup_parse_context_end_parse(xml_ctx, &error); + if (error) + goto err; + + g_markup_parse_context_free(xml_ctx); + return TRUE; + +err: + msg_error("xml: error", evt_tag_str("str", error->message)); + g_error_free(error); + g_markup_parse_context_free(xml_ctx); + return self->forward_invalid; +} + +static void +_compile_and_add(gpointer tag_glob, gpointer exclude_patterns) +{ + g_ptr_array_add(exclude_patterns, g_pattern_spec_new(tag_glob)); +} + +void +xml_parser_set_exclude_tags(LogParser *s, GList *exclude_tags) +{ + XMLParser *self = (XMLParser *) s; + + g_list_free_full(self->exclude_tags, g_free); + self->exclude_tags = g_list_copy_deep(exclude_tags, ((GCopyFunc)g_strdup), NULL); + self->matchstring_shouldreverse = joker_or_wildcard(exclude_tags); +} + +void +xml_parser_set_forward_invalid(LogParser *s, gboolean setting) +{ + XMLParser *self = (XMLParser *) s; + self->forward_invalid = setting; +} + +void +xml_parser_set_strip_whitespaces(LogParser *s, gboolean setting) +{ + XMLParser *self = (XMLParser *) s; + self->strip_whitespaces = setting; +} + + +void +xml_parser_set_prefix(LogParser *s, const gchar *prefix) +{ + XMLParser *self = (XMLParser *) s; + + g_free(self->prefix); + self->prefix = g_strdup(prefix); +} + +LogPipe * +xml_parser_clone(LogPipe *s) +{ + XMLParser *self = (XMLParser *) s; + XMLParser *cloned; + + cloned = (XMLParser *) xml_parser_new(s->cfg); + + xml_parser_set_prefix(&cloned->super, self->prefix); + log_parser_set_template(&cloned->super, log_template_ref(self->super.template)); + xml_parser_set_forward_invalid(&cloned->super, self->forward_invalid); + xml_parser_set_strip_whitespaces(&cloned->super, self->strip_whitespaces); + xml_parser_set_exclude_tags(&cloned->super, self->exclude_tags); + cloned->matchstring_shouldreverse = self->matchstring_shouldreverse; + + return &cloned->super.super; +} + +static void +xml_parser_free(LogPipe *s) +{ + XMLParser *self = (XMLParser *) s; + g_free(self->prefix); + self->prefix = NULL; + g_list_free_full(self->exclude_tags, g_free); + self->exclude_tags = NULL; + g_ptr_array_free(self->exclude_patterns, TRUE); + self->exclude_patterns = NULL; + + log_parser_free_method(s); +} + +/* + For some patterns, GPatternSpec stores the pattern as reversed + string. In such cases, the matching must be executed against the + reversed matchstring. If one uses g_pattern_match_string, glib will + reverse the string internally in these cases, but it is suboptimal if + the same matchstring must be matched against different patterns, + because memory is allocated each time and string is copied as + reversed, though it would be enough to execute this reverse once. For + that reason one can use g_pattern_match(), which accepts both the + matchstring and a reversed matchstring as parameters. + + Though there are cases when no reverse is needed at all. This is + decided in the constructor of GPatternSpec, but at this time of + writing this information is not exported, and cannot be extracted in + any safe way, because GPatternSpec is forward declared. + + This function below is an oversimplified/safe version of the logic + used glib to decide if the pattern will be reversed or not. One need + to note the worst case scenario is if syslog-ng will not reverse the + matchstring, though it should because in that case number of extra + memory allocations and string reversals scale linearly with the number + of patterns. We need to avoid not pre-reversing, when glib would. + */ +gboolean +joker_or_wildcard(GList *patterns) +{ + gboolean retval = FALSE; + GList *pattern = patterns; + while (pattern != NULL) + { + gchar *str = ((gchar *)pattern->data); + if (strpbrk(str, "*?")) + { + retval = TRUE; + break; + } + pattern = g_list_next(pattern); + } + + return retval; +} + +static gboolean +xml_parser_init(LogPipe *s) +{ + XMLParser *self = (XMLParser *)s; + remove_trailing_dot(self->prefix); + g_list_foreach(self->exclude_tags, _compile_and_add, self->exclude_patterns); + return log_parser_init_method(s); +} + + +LogParser * +xml_parser_new(GlobalConfig *cfg) +{ + XMLParser *self = g_new0(XMLParser, 1); + + log_parser_init_instance(&self->super, cfg); + self->super.super.init = xml_parser_init; + self->super.super.free_fn = xml_parser_free; + self->super.super.clone = xml_parser_clone; + self->super.process = xml_parser_process; + self->forward_invalid = TRUE; + + xml_parser_set_prefix(&self->super, ".xml"); + self->exclude_patterns = g_ptr_array_new_with_free_func((GDestroyNotify)g_pattern_spec_free); + return &self->super; +} diff -Nru syslog-ng-3.11.1/modules/xml/xml-grammar.ym syslog-ng-3.13.2/modules/xml/xml-grammar.ym --- syslog-ng-3.11.1/modules/xml/xml-grammar.ym 1970-01-01 00:00:00.000000000 +0000 +++ syslog-ng-3.13.2/modules/xml/xml-grammar.ym 2017-12-06 06:39:39.000000000 +0000 @@ -0,0 +1,94 @@ +/* + * Copyright (c) 2017 Balabit + * + * This program is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 as published + * by the Free Software Foundation, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + * + * As an additional exemption you are allowed to compile & link against the + * OpenSSL libraries as published by the OpenSSL project. See the file + * COPYING for details. + * + */ + +%code top { +#include "xml-parser.h" +} + + +%code { +#include "xml.h" +#include "cfg-parser.h" +#include "cfg-grammar.h" +#include "xml-grammar.h" +#include "syslog-names.h" +#include "messages.h" +#include "plugin.h" + +#include + +} + +%name-prefix "xml_" + +/* this parameter is needed in order to instruct bison to use a complete + * argument list for yylex/yyerror */ + +%lex-param {CfgLexer *lexer} +%parse-param {CfgLexer *lexer} +%parse-param {LogParser **instance} +%parse-param {gpointer arg} + +/* INCLUDE_DECLS */ + +%token KW_XML +%token KW_PREFIX +%token KW_DROP_INVALID +%token KW_EXCLUDE_TAGS +%token KW_STRIP_WHITESPACES + +%type parser_xml +%% + +start + : LL_CONTEXT_PARSER parser_xml { YYACCEPT; } + ; + +parser_xml + : KW_XML '(' + { + last_parser = *instance = (LogParser *) xml_parser_new(configuration); + } + + xml_options + ')' + { + $$ = last_parser; + } + ; + +xml_options + : xml_opt xml_options + | + ; + +xml_opt + : KW_PREFIX '(' string ')' { xml_parser_set_prefix(last_parser, $3); free($3); } + | KW_DROP_INVALID '(' yesno ')' { xml_parser_set_forward_invalid(last_parser, !$3); }; + | KW_EXCLUDE_TAGS '(' string_list ')' { xml_parser_set_exclude_tags(last_parser, $3); g_list_free_full($3, free); } + | KW_STRIP_WHITESPACES '(' yesno ')' { xml_parser_set_strip_whitespaces(last_parser, $3); } + | parser_opt + ; + +/* INCLUDE_RULES */ + +%% diff -Nru syslog-ng-3.11.1/modules/xml/xml.h syslog-ng-3.13.2/modules/xml/xml.h --- syslog-ng-3.11.1/modules/xml/xml.h 1970-01-01 00:00:00.000000000 +0000 +++ syslog-ng-3.13.2/modules/xml/xml.h 2017-12-06 06:39:39.000000000 +0000 @@ -0,0 +1,48 @@ +/* + * Copyright (c) 2017 Balabit + * + * This program is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 as published + * by the Free Software Foundation, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + * + * As an additional exemption you are allowed to compile & link against the + * OpenSSL libraries as published by the OpenSSL project. See the file + * COPYING for details. + * + */ + +#ifndef XML_H_INCLUDED +#define XML_H_INCLUDED + +#include "parser/parser-expr.h" + +typedef struct +{ + LogParser super; + gchar *prefix; + gboolean forward_invalid; + GList *exclude_tags; + GPtrArray *exclude_patterns; + gboolean matchstring_shouldreverse; + gboolean strip_whitespaces; +} XMLParser; + +LogParser * xml_parser_new(GlobalConfig *cfg); +LogPipe * xml_parser_clone(LogPipe *s); +void xml_parser_set_prefix(LogParser *s, const gchar *prefix); +void xml_parser_set_forward_invalid(LogParser *s, gboolean setting); +void xml_parser_set_exclude_tags(LogParser *s, GList *exclude_tags); +void xml_parser_set_strip_whitespaces(LogParser *s, gboolean setting); + +gboolean joker_or_wildcard(GList *patterns); + +#endif diff -Nru syslog-ng-3.11.1/modules/xml/xml-parser.c syslog-ng-3.13.2/modules/xml/xml-parser.c --- syslog-ng-3.11.1/modules/xml/xml-parser.c 1970-01-01 00:00:00.000000000 +0000 +++ syslog-ng-3.13.2/modules/xml/xml-parser.c 2017-12-06 06:39:39.000000000 +0000 @@ -0,0 +1,52 @@ +/* + * Copyright (c) 2017 Balabit + * + * This program is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 as published + * by the Free Software Foundation, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + * + * As an additional exemption you are allowed to compile & link against the + * OpenSSL libraries as published by the OpenSSL project. See the file + * COPYING for details. + * + */ + +#include "xml.h" +#include "cfg-parser.h" +#include "xml-grammar.h" + +extern int xml_debug; + +int xml_parse(CfgLexer *lexer, LogParser **instance, gpointer arg); + +static CfgLexerKeyword xml_keywords[] = +{ + { "xml", KW_XML }, + { "prefix", KW_PREFIX }, + { "drop_invalid", KW_DROP_INVALID }, + { "exclude_tags", KW_EXCLUDE_TAGS }, + { "strip_whitespaces", KW_STRIP_WHITESPACES }, + { NULL } +}; + +CfgParser xml_parser = +{ +#if ENABLE_DEBUG + .debug_flag = &xml_debug, +#endif + .name = "xml", + .keywords = xml_keywords, + .parse = (gint (*)(CfgLexer *, gpointer *, gpointer)) xml_parse, + .cleanup = (void (*)(gpointer)) log_pipe_unref, +}; + +CFG_PARSER_IMPLEMENT_LEXER_BINDING(xml_, LogParser **) diff -Nru syslog-ng-3.11.1/modules/xml/xml-parser.h syslog-ng-3.13.2/modules/xml/xml-parser.h --- syslog-ng-3.11.1/modules/xml/xml-parser.h 1970-01-01 00:00:00.000000000 +0000 +++ syslog-ng-3.13.2/modules/xml/xml-parser.h 2017-12-06 06:39:39.000000000 +0000 @@ -0,0 +1,34 @@ +/* + * Copyright (c) 2017 Balabit + * + * This program is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 as published + * by the Free Software Foundation, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + * + * As an additional exemption you are allowed to compile & link against the + * OpenSSL libraries as published by the OpenSSL project. See the file + * COPYING for details. + * + */ + +#ifndef xml_PARSER_H_INCLUDED +#define xml_PARSER_H_INCLUDED + +#include "cfg-parser.h" +#include "cfg-lexer.h" +#include "parser/parser-expr.h" + +extern CfgParser xml_parser; + +CFG_PARSER_DECLARE_LEXER_BINDING(xml_, LogParser **) + +#endif diff -Nru syslog-ng-3.11.1/modules/xml/xml-plugin.c syslog-ng-3.13.2/modules/xml/xml-plugin.c --- syslog-ng-3.11.1/modules/xml/xml-plugin.c 1970-01-01 00:00:00.000000000 +0000 +++ syslog-ng-3.13.2/modules/xml/xml-plugin.c 2017-12-06 06:39:39.000000000 +0000 @@ -0,0 +1,53 @@ +/* + * Copyright (c) 2017 Balabit + * + * This program is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 as published + * by the Free Software Foundation, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + * + * As an additional exemption you are allowed to compile & link against the + * OpenSSL libraries as published by the OpenSSL project. See the file + * COPYING for details. + * + */ + +#include "cfg-parser.h" +#include "plugin.h" +#include "plugin-types.h" + +extern CfgParser xml_parser; + +static Plugin xml_plugins[] = +{ + { + .type = LL_CONTEXT_PARSER, + .name = "xml", + .parser = &xml_parser, + }, +}; + +gboolean +xml_module_init(PluginContext *context, CfgArgs *args) +{ + plugin_register(context, xml_plugins, G_N_ELEMENTS(xml_plugins)); + return TRUE; +} + +const ModuleInfo module_info = +{ + .canonical_name = "xml", + .version = SYSLOG_NG_VERSION, + .description = "Parses xml into messages", + .core_revision = SYSLOG_NG_SOURCE_REVISION, + .plugins = xml_plugins, + .plugins_len = G_N_ELEMENTS(xml_plugins), +}; diff -Nru syslog-ng-3.11.1/NEWS.md syslog-ng-3.13.2/NEWS.md --- syslog-ng-3.11.1/NEWS.md 2017-07-31 09:05:32.000000000 +0000 +++ syslog-ng-3.13.2/NEWS.md 2017-12-06 06:39:39.000000000 +0000 @@ -1,82 +1,85 @@ -3.11.1 +3.13.2 - + -# Features - * Add geoip2 parser and template function. - It is based on the libmaxminddb(MaxMindDB). - It will replace the old geoip parser and template function, - so they are deprecated from 3.11 (but still available). +# Fixes + * Missing manpages from release tarball (#1793) + * Package syslog-ng-mod-json is removed from (#1794) + * Drop syslog-ng-abi virtual packages (#1797) - * Add SSL support to AMQP. +# Credits - * Add template option to apache-accesslog-parser. +syslog-ng is developed as a community project, and as such it relies +on volunteers, to do the work necessarily to produce syslog-ng. - * Add configurable event time to Riemann destination. +Reporting bugs, testing changes, writing code or simply providing +feedback are all important contributions, so please if you are a user +of syslog-ng, contribute. - * Add drop-unmatched() option to dbparser. +We would like to thank the following people for their contribution: +Andras Mitzki, Gergely Nagy, Laszlo Budai, Laszlo Varady, Peter Czanik. - * Add Ubuntu Xenial to the bundled docker images. - * Support multi-instance support for Solaris 10 and 11. +3.13.1 - * Support multi-instance for systemd. + - * Add configurable timeout to HTTP destination. +# Features - * Add prefix() option to cisco-parser. + * Add app-parser() framework (automatic parsing of log messages) (#1689) + * Support microseconds in Riemann destination (#1710) + * Add osquery destination as an SCL plugin (#1728) + * Add network load balancer destination (#1706) + * Add possibility to only signal re-open of file handles (SIGUSR1) (#1530) + * It is possible from now to limit the number of registered dynamic counters (#1743) + * Add $(binary) template function (#1679) + * Add experimental transport for transferring messages in whole between syslog-ng instances (EWMM) (#1689) + * Docker based build and debian package generation (#1783) + * Add auto-parse(yes/no) to app-paser(), system() and default-network-drivers() (#1788) + * Add Graylog2 destination and $(format-gelf) template function (#1680) # Bugfixes - * Fix a memory usage counter underflow for threaded destination drivers - and writers. - - * Fix a potential crash in AMQP. - - * Fix a potential crash during reload. - - * Fix a reload/shutdown issue. - Under heavy load, worker might never exit from the fetch loop from the - queue. - - * Fix a potential crash in afsocket destination during reload. - - * Fix a counter registration bug. - In some cases not all the required counters are registered. - - * Fix a build issue on FreeBSD. - - * Fix a memory leak in diskq plugin. - - * Fix systemd-journal error codes validation. - - * Fix a potential crash in diskq when it is used with file - destination and the file is reaped. - - * Fix a memory leak in HTTP destination - - * Fix ENABLE_DEBUG in dbparser. - - * Fix a unit tests that caused build issue on 32 bit platforms. + * Exit when a read fails on an included config file instead of + starting up with an empty configuration. (#1721) + * Fix double free (#1720) + * Add missing discarded counter to groupingby (#1748) + * Fix a reference leak in Python destination (#1716) + * Fix timezone issue in snmptrapd parser (#1746) + * Fix potential crash in stdin driver (#1741) + * Fix a crash when initializing new config fails for socket with keep_alive off (#1723) + * Fix filter evaluation in case of contexts with multiple elements (#1718) + * Various grouping-by fixes (#1718) + * Fix potential use after free around dns-cache during shutdown (#1666) + * Fix access to indirect values within Java destination (#1732) + * Fix a crash in affile (#1725) + * Fix a memory leak (#1724) + * Fix a crash when getent is used empty group (#1691) + * Fix jvm-options() (#1704) + * Fix a crash in Python language binding (#1694) + * Fix a crash in afmongodb (#1765) + * Fix a memory leak in afmongodb (#1766) + * Fix name-to-GID calculation in the $(getent) template function (#1764) + * Fix a crash when redis is configured without the command() option (#1767) + * Fix a race condition in kv-parser() (#1789) # Other changes - * The eventlog library is part of syslog-ng from now. + * Cleanup diskq related warning messages (#1752) + * Provide tls block for tls options in amqp(), http(), riemann() destination drivers (#1715) + * It it possible from now to register blocks and generators as plugins (#1657) + * Drop compatiblity with configurations below 3.0 (#1709) + * Do not change permissions of a file by default (#1782) + * Allow source files to specify permissions locally (#1782) + * Minor performance improvement (#1729) + * The current config version can be queried with "--version" (#1740) + * Increase the performance of kv-parser() (#1789) - * Improve error messages when the config cannot be initialized. +# Notes to the developers - * Improve source suspended/resumed debug messages. - - * Rename syslog-debun to syslog-ng-debun. - - * Update manpages to v3.11 - - * Remove tgz2build directory. - -# Notes to the Developers - - * Rewrite merge-grammar script from Perl to Python. + * Change configure default option for jsonc and mongoc from auto to internal (#1735) + * Disable ASLR when running unit tests (#1753) # Credits @@ -88,9 +91,8 @@ of syslog-ng, contribute. We would like to thank the following people for their contribution: - -Andras Mitzki, Antal Nemes, Attila Szalay, Balazs Scheidler, Fabien Wernli, -Gabor Nagy, Giuseppe D'Anna, Janos Szigetvari, Laszlo Budai, Laszlo Varady, -Lorand Muzamel, Mate Farkas, Noemi Vanyi, Peter Czanik, Tamas Nagy, -Tibor Bodnar, Tomasz Kazimierczak, Zoltan Pallagi +Andras Mitzki, Antal Nemes, Attila Szalay, Balazs Scheidler, Gabor Nagy, +Jakub Jankowski, Janos Szigetvari, Laszlo Budai, Laszlo Varady, Laszlo Szemere, +Marton Illes, Mate Farkas, Peter Kokai, Pontus Andersson, Sam Stephenson, +Sebastian Roland, Viktor Juhasz, Zoltan Pallagi. diff -Nru syslog-ng-3.11.1/packaging/debian/changelog syslog-ng-3.13.2/packaging/debian/changelog --- syslog-ng-3.11.1/packaging/debian/changelog 1970-01-01 00:00:00.000000000 +0000 +++ syslog-ng-3.13.2/packaging/debian/changelog 2017-12-06 06:39:39.000000000 +0000 @@ -0,0 +1,1508 @@ +syslog-ng (3.13.1-1) unstable; urgency=medium + + * upstream upgrade to 3.13.1 + + -- Balazs Scheidler Thu, 30 Nov 2017 21:17:14 -0800 + +syslog-ng (3.11.1-1) unstable; urgency=medium + + * test release + + -- Laszlo Budai Tue, 08 Aug 2017 11:37:22 +0200 + +syslog-ng (3.10.1-3) unstable; urgency=medium + + * [6318b4b] getent module conflicts with old incubator package. + The getent module was moved from the incubator and therefore + contains the same files. (Closes: #869159) + + -- SZALAY Attila Tue, 25 Jul 2017 22:06:15 +0200 + +syslog-ng (3.10.1-2) unstable; urgency=medium + + * [a776121] Added new plugins. + - getent + - stardate + - mod-value-pairs + - snmptrapd-parser + * [b030059] Added scl to the .install file + * [e4f5ac4] Bump the debhelper compat level to 10 + * [4e27f27] Fixed debhelper dependency + * [ff8e0ff] Install new scl files and explicitly mention skipped ones + * [50b4c13] Fixed 32 bit compile issues. + This patch is suggested by upstream in github issue 1545. + * [ae5e271] Remove obsoleted files from debian/ + * [cccc2bb] Added the new packages to the testing + * [8661982] Removed unneeded prebuild step + + -- SZALAY Attila Tue, 04 Jul 2017 22:05:34 +0200 + +syslog-ng (3.10.1-1) unstable; urgency=medium + + * [e47c9a6] Re-generated openssl patch to make the gbp pq happy + And a patch were a next session start before the previous + is finished can be called weird anyway. + * [114f0e0] Try again using tagged git release as orig.tar.gz + Now, after some time I'm a bit more confident that using a naked git + release is better than the full-featured and all-including release. + First, it is much smaller. Especially because it does not contain all + of the third party libraries which are not used in Debian. Second + reason is that this can be followed much easily, because this is the + same as any particular state in the git repo, so a snapshot can be more + easily used if this is the daily routine. + * [9c410bb] New upstream version 3.10.1 (closes: #866056) + * [fa5c024] Preparing for upstream version 3.10.X + * [c0f99c0] Updated the patches to the new upstream version + This mainly means deleting patches which already + merged upstream. + * [a7b8153] Added new build dependency (autoconf-archive) + * [9a197e2] Removed version fixation + * [f52837d] Upgrade test config version + * [bf45a65] Upgraded default config version to 3.10 + * [fc82e19] Added a new test to test the default config + + -- SZALAY Attila Fri, 30 Jun 2017 22:15:28 +0200 + +syslog-ng (3.8.1-10) unstable; urgency=medium + + * Fix segfault in X509_STORE_CTX_get_app_data(ctx) (closes: #850743). + + -- Laszlo Boszormenyi (GCS) Sun, 05 Feb 2017 08:34:41 +0000 + +syslog-ng (3.8.1-9) unstable; urgency=medium + + * Fix build with OpenSSL 1.1 (closes: #848786). + + -- Laszlo Boszormenyi (GCS) Thu, 22 Dec 2016 10:44:32 +0000 + +syslog-ng (3.8.1-8) unstable; urgency=medium + + * [ee388fd] Declaring breaks because of file moving (Closes: 847708) + * [1ebe21f] Switch to unstable repo + * [18653b3] Added testing upgrade capability + + -- SZALAY Attila Sun, 11 Dec 2016 18:32:35 +0100 + +syslog-ng (3.8.1-7) unstable; urgency=medium + + * [45109e3] Moved templates depending on json to mod-json (Closes: #845799) + * [023a862] Added some more testcases to autopkg + + -- SZALAY Attila Tue, 06 Dec 2016 23:44:35 +0100 + +syslog-ng (3.8.1-6) unstable; urgency=medium + + * [41f337f] Updated configuration. + Removed the deprecated defines from scl.conf + and upgraded the version of the configuration + file. (Closes: #843937) + + -- SZALAY Attila Fri, 18 Nov 2016 16:23:17 +0100 + +syslog-ng (3.8.1-5) unstable; urgency=medium + + * [05e9749] Revert export method to head. + Much cleaner and can be changed in parameter list + if needed + * [6b49e04] Added basic test to check if syslog-ng can start + * [80260f3] Added tzdata dependency, needed by a testcase. + Because tzdata is neither essential nor build-essential + package explicit build-dependency is needed. (Closes: #839449) + * [e68e244] Upgraded ABI version to 3.8 + * [1241045] Temporally stay with the libssl-1.0 until upstream fix this + (Closes: #828565) + * [c8dc698] Added dependency to lsb-base as lintian suggested + + -- SZALAY Attila Sat, 05 Nov 2016 19:09:39 +0100 + +syslog-ng (3.8.1-4) experimental; urgency=medium + + * [6b459d5] Bumped policy version to 3.9.8 + * [de6480c] Added patch to fix man page line breaking issue + * [221a51e] Added new module: add-contextual-data + * [6733853] Removing unnecessary parts. + Removing commented out parts and also + parts which are obsoleted. + * [bb61029] Fixed Vcs field in debian/control + * [3d07696] Changed export method to Workspace. + With this change it is possible to build a debian package + from syslog-ng with the help of git-buildpackage and without + committing the change first. + * [f7a25e3] Enforce re-generating the man pages + * [abc4899] Remove unneeded files from build stage dir. + To make the --list-missing more practical. + + -- SZALAY Attila Sun, 11 Sep 2016 19:02:02 +0200 + +syslog-ng (3.8.1-3) experimental; urgency=medium + + * [e1adb55] Fixed debian/changelog wrapping + * [c3d1395] Do not use embedded libraries when possible + * [6f73327] Follow the upstream decision to change mongodb library + * [f893b95] Added patch to fix compile issue with system provided mongodbc + * [46ff5cd] Enabled rabbitmq module + + -- SZALAY Attila Fri, 02 Sep 2016 22:02:48 +0200 + +syslog-ng (3.8.1-2) experimental; urgency=medium + + * [fc743d9] Added upstream patch fixing hurd-i386 compilation + * [0efe489] Do not try to install systemd related things on kfreebsd + + -- SZALAY Attila Tue, 30 Aug 2016 21:42:18 +0200 + +syslog-ng (3.8.1-1) experimental; urgency=medium + + * [469c62c] Revert to the old watch file. + The tags does not work, because the downloaded archive does not + contain some essential part of the distribution. + * [b1f13dc] Imported Upstream version 3.8.1 + * [da4ae60] Added import-orig options to exclude the .git files and the + debian directory + * [c29eaa1] Removed test patches + * [f7197f1] Added new dependencies needed by new test cases + * [cdfc0cc] Removed datadir which is not needed any more + * [e16ea28] Added new files to the appropriate package. + Also removed hack installing system init script. + * [da85f54] Added native connector to the dev package + + -- SZALAY Attila Fri, 26 Aug 2016 23:38:45 +0200 + +syslog-ng (3.7.3-2) experimental; urgency=medium + + * [db0cb33] Removed unneeded file mode change. + The install type is changed to script for that file, so this is not needed + any more. + + -- SZALAY Attila Thu, 11 Aug 2016 22:24:11 +0200 + +syslog-ng (3.7.3-1) unstable; urgency=low + + * New upstream release (Closes: #802888, #794585, #804667). + * Adapt to upstream changes handling PYSETUP_OPTIONS. + * I do not know how that files appeared there, but now definitively not + there. (Closes: #801546) + * Check if we handled everything installed by the upstream installer. + + -- SZALAY Attila Sat, 16 Jul 2016 09:55:58 +0200 + +syslog-ng (3.7.1-3) experimental; urgency=medium + + * [d340beb] Re-add debian directory cleanup. + For some reason neither in the quilt format will the upstream files + removed from the debian directory. So we should do it by hand. + + -- SZALAY Attila Thu, 08 Oct 2015 21:51:09 +0200 + +syslog-ng (3.7.1-2) experimental; urgency=medium + + * [bec27e5] Removed get-orig-source target. + The git tree should contains the whole module and not just the + debian directory. therefore I added it and as a consequence + this target is obsoleted. + * [f11f92a] Remove README.markdown. + This file is violate the quilt package + policy + * [4bd2761] debian/rules: Switched to autoreconf from autogen.sh + * [e367348] Fixed autoreconf and automake running + * [9b38bc4] debian/control: Added needed dependency for testing + * [b8398e1] debian/control: Temporally remove syslog-ng-amqp + + -- SZALAY Attila Sat, 03 Oct 2015 18:31:11 +0200 + +syslog-ng (3.7.1-1) experimental; urgency=medium + + [ Gergely Nagy ] + * New upstream release. + * Transition to libsystemd-dev (Closes: #779765). + * Add a libriemann-client-dev (>= 1.6.0~) build-dependency (instead of + an unversioned one), because upstream needs the new version. + * Add python-dev, pep8 and pylint to build-depends, to be able to build + the python module. + * Explicitly disable Java for now. + * debian/watch updated to pull releases from GitHub. + * Updated the syslog-ng-core contents, to include new core modules. + * Updated the syslog-ng-mod-geoip contents, the module has been renamed. + * Added a new syslog-ng-mod-python package. + * Use dh-exec to install tty10.conf, instead of doing a crazy dance in + debian/rules. + + -- Gergely Nagy Wed, 09 Sep 2015 16:44:34 +0200 + +syslog-ng (3.6.1+git20141206-g4d90138-4) experimental; urgency=medium + + [ Gergely Nagy ] + * Run the test suite with VERBOSE=1, so we see the actual test results. + * Add a Replaces: to syslog-ng-mod-journal, for smooth upgrades. + + -- Gergely Nagy Sat, 13 Dec 2014 14:16:59 +0100 + +syslog-ng (3.6.1+git20141206-g4d90138-3) experimental; urgency=low + + [ Gergely Nagy ] + * Move the systemd-journal() source to a separate package, which is + depended on by syslog-ng-core on linux-any. This allows building the + binaries without gross hacks on all architectures. + + -- Gergely Nagy Sun, 07 Dec 2014 22:26:10 +0100 + +syslog-ng (3.6.1+git20141206-g4d90138-2) experimental; urgency=low + + [ Gergely Nagy ] + * Only force systemd on Linux, disable it everywhere else. This should + allow syslog-ng to build again on non-linux architectures. + + -- Gergely Nagy Sun, 07 Dec 2014 15:39:57 +0100 + +syslog-ng (3.6.1+git20141206-g4d90138-1) experimental; urgency=low + + [ Gergely Nagy ] + * New snapshot release, based on upstream git commit 4d90138. + + * In scl.conf, include scl/*/*.conf, not just plugin.conf, so that all + SCL plugins are included. + * Use an updated systemd service file, that does not pull in + syslog.socket (we're reading directly from the Journal, and do not + need the forwarding socket). + * Update the Vcs-* fields in debian/control, packaging was moved to a + separate repository. + + -- Gergely Nagy Sun, 07 Dec 2014 12:27:51 +0100 + +syslog-ng (3.6.1-1) experimental; urgency=low + + [ Gergely Nagy ] + * New upstream stable release. + + Uploading to experimental, due to the Jessie freeze. + * Standards-Version bumped to 3.9.6 (no changes necessary). + * Homepage changed to www.syslog-ng.org. + * Updated copyrights in debian/copyright. + * Dropped the Lintian overrides, they're not needed anymore. + * Major packaging cleanup: + + Dropped all triggers, because they're not used anymore (since + 3.5.6-2). + + Allow parallel building. + + Enabled the test suite. + + Greatly simplified the packaging, dropping support for ancient + distributions like Ubuntu Lucid. + + Use a virtual package for ABI tracking. + + Switched the packaging to a git-buildpackage compatible workflow. + + -- Gergely Nagy Mon, 10 Nov 2014 09:27:55 +0100 + +syslog-ng (3.6.0~alpha1-1) experimental; urgency=medium + + [ Gergely Nagy ] + * New upstream alpha release. + + -- Gergely Nagy Thu, 31 Jul 2014 12:30:12 +0200 + +syslog-ng (3.5.6-2) unstable; urgency=high + + [ Gergely Nagy ] + * Use dh_installinit --restart-after-upgrade instead of hand-coding + essentially the same thing, badly. + * Urgency high, as this moderates the effect of #757903. + + -- Gergely Nagy Wed, 13 Aug 2014 13:57:15 +0200 + +syslog-ng (3.5.6-1) unstable; urgency=high + + [ Gergely Nagy ] + * New upstream release, fixing a major memory leak (thus the urgency) + * Loosen the shlibs dependency on syslog-ng-core, so that + syslog-ng-incubator need not be rebuilt for every single syslog-ng + upload. + * Fixed a typo in debian/rules. + + -- Gergely Nagy Mon, 11 Aug 2014 11:07:34 +0200 + +syslog-ng (3.5.5-2) unstable; urgency=high + + [ Gergely Nagy ] + * Explicitly disable linux capability support on non-linux platforms, + instead of relying on auto-detection (which doesn't always work). + + -- Gergely Nagy Sat, 26 Jul 2014 13:53:39 +0200 + +syslog-ng (3.5.5-1) unstable; urgency=high + + [ Gergely Nagy ] + * New upstream release, fixing major leaks (hence the urgency) + * Build-Depend on libjson-c-dev | libjson0-dev. (Closes: #745014) + * Add /var/log/error to the logrotate file. (Closes: #747020) + * Include libsyslog-ng-test.a and the related pkg-config file in the + syslog-ng-dev package. + * Added an upstart init script (mostly for the benefit of older Ubuntu + releases and backports). + * syslog-ng-mod-redis no longer (mistakenly) recommends geoip-database. + + -- Gergely Nagy Wed, 23 Jul 2014 18:44:55 +0200 + +syslog-ng (3.5.4.1-1) unstable; urgency=medium + + [ Gergely Nagy ] + * New upstream release. + * Handle the shlibs file correctly, and install it to the syslog-ng-core + package. + + -- Gergely Nagy Wed, 19 Mar 2014 09:14:08 +0100 + +syslog-ng (3.5.3-1) unstable; urgency=medium + + [ Gergely Nagy ] + * New upstream release. + + Based on 3.5/master, which includes a couple of bison3 fixes. + + -- Gergely Nagy Wed, 25 Dec 2013 15:29:45 +0100 + +syslog-ng (3.5.2-1) unstable; urgency=high + + [ Gergely Nagy ] + * New upstream release. + + Fix the system() source on older Linux kernels (Closes: #729991) + + Fix kernel timestamp computation on 32-bit systems (Closes: #729575) + * Added a missing GPL-2+ license block to debian/copyright. + * Correctly install the pkg-config file to /usr/lib/pkgconfig. + * Updated the Vcs-* fields to point to debian.org resources. + * Updated the package descriptions to be more similar to the upstream + one. + * Urgency set to high, due to the RC bugfix on 32-bit architectures. + + -- Gergely Nagy Mon, 02 Dec 2013 15:19:51 +0100 + +syslog-ng (3.5.1-1) unstable; urgency=low + + [ Gergely Nagy ] + * New upstream release. + + Support auto-loading modules (Closes: #650814) + + The SMTP module is available in syslog-ng-mod-smtp (Closes: #722746) + + New modules: amqp, geoip, stomp, redis and smtp. + + Multi-line input support (indented multiline and regexp-based) + + Template type hinting for the MongoDB destination and $(format-json) + + Support for unit suffixes in the configuration file + + New filters, template functions and other miscellaneous changes + * New (team) maintainer, Laszlo Boszormenyi, Attila Szalay and myself + added to Uploaders. + * Ship /var/lib/syslog-ng in the syslog-ng-core package, instead of + creating it in the init script. Thanks Michael Biebl + for the report & assistance. (Closes: #699942, #719910) + * Use dh-systemd for proper systemd-related maintainer scripts. Based on + a patch by Michael Biebl . (Closes: #713982, + #690067) + * Do not wait for syslog-ng to settle down during installation / update. + This also fixes installing via debootstrap and a fake + start-stop-daemon. (Closes: #714254) + + -- Gergely Nagy Mon, 04 Nov 2013 15:27:37 +0100 + +syslog-ng (3.3.9-1) unstable; urgency=low + + * New upstream release. + * Include missed ivykis header (closes: #708793). + + -- Laszlo Boszormenyi (GCS) Sun, 26 May 2013 09:06:21 +0200 + +syslog-ng (3.3.6-2) unstable; urgency=low + + [ Gergely Nagy ] + * Use /dev/ttyva on kFreeBSD as the target of the d_console_all + destination (closes: #697042). + * Use the standard /var/log/mail.{info,err,warn} location for the + various mail-related logs (closes: #692056). + * Don't mark systemd symlinks in /etc as conffiles. + * Instead of installing systemd service file symlinks, install a + conffile, that includes the real service file (closes: #690067). + * Do not forcibly remove the systemd service files, that code is not + needed anymore. + + -- Laszlo Boszormenyi (GCS) Sat, 02 Mar 2013 16:03:18 +0100 + +syslog-ng (3.3.6-1) unstable; urgency=low + + * New upstream release: + - fixes disconnect on charset decoding error when using UDP sources + (closes: #674099), + - use upstream, packaged ivykis. + * Backport upstream fix of cfg-lexer to fix glob-based include order. + + [ Gergely Nagy ] + * Add NEWS.Debian, with a note about OpenSSL changing the default dir + hashing from MD5 to SHA1, and its effect on syslog-ng users. + * Fix build-indep and multiple builds in a row + * Explicitly remove systemd unit and service files from /etc upon purge + (closes: #674020). + + -- Laszlo Boszormenyi (GCS) Wed, 05 Sep 2012 01:57:50 +0200 + +syslog-ng (3.3.5-2) unstable; urgency=low + + [ Gergely Nagy ] + * Fix FTBFS on non-Linux architectures (closes: #672457). + + -- Laszlo Boszormenyi (GCS) Sun, 13 May 2012 00:42:42 +0200 + +syslog-ng (3.3.5-1) unstable; urgency=low + + [ Gergely Nagy ] + * New upstream release. + + afsocket: handle DNS failures as if it was a connection failure + (Closes: #660897) + * All patches dropped, they're applied upstream. + * Include upstream man pages, as they're DFSG-free now. + * Update debian/copyright for 1.0 of the spec. + * Bump Standards-Version to 3.9.3 (no changes required) + * Fix squeeze->wheezy install-remove-install upgrade path. + (Closes: #665905) + * Fix the init script to create /dev/xconsole properly on GNU/kFreeBSD. + + -- Laszlo Boszormenyi (GCS) Thu, 03 May 2012 08:23:46 +0000 + +syslog-ng (3.3.5-1~mhp1) unstable; urgency=low + + [ Gergely Nagy ] + * New upstream release. + + afsocket: handle DNS failures as if it was a connection failure + (Closes: #660897) + * All patches dropped, they're applied upstream. + * Include upstream man pages, as they're DFSG-free now. + * Update debian/copyright for 1.0 of the spec. + * Bump Standards-Version to 3.9.3 (no changes required) + * Fix squeeze->wheezy install-remove-install upgrade path. + (Closes: #665905) + * Fix the init script to create /dev/xconsole properly on GNU/kFreeBSD. + + -- Gergely Nagy Mon, 16 Apr 2012 15:22:59 +0200 + +syslog-ng (3.3.4.dfsg-2~mhp1) unstable; urgency=low + + [ Gergely Nagy ] + * Packaging synced with GCS. + * Patches applied: + + Fix framing issues with the syslog protocol, based on a patch by + Zoltan Fried . + + afsql: Fix a deadlock when using explicit commits. + + afmongodb: Fix a deadlock at deinit time. + + -- Gergely Nagy Fri, 10 Feb 2012 13:38:13 +0100 + +syslog-ng (3.3.4.dfsg-1) unstable; urgency=low + + * New upstream release: + - remove backported patches as this release contains them, + - fix FTBFS on Hurd, patch from Svante Signell + (closes: #648987). + * Add dfsg target to make the source DFSG compliant. + * Use debhelper compatibility level 9 for hardening flags to be effective + (closes: #655163). + * Make the package multiarch. + + [ Gergely Nagy ] + * Introduced a syslog-ng-dbg package. + * Init script updates: + + Silence mknod errors, they're not interesting, and adds noise on + kFreeBSD. + + Use set -e. + + Use s-s-d's --oknodo options instead of checking the existence of a + pidfile ourselves. + * Refresh debian/copyright. + + -- Laszlo Boszormenyi (GCS) Wed, 01 Feb 2012 14:21:11 +0000 + +syslog-ng (3.3.4.dfsg-1~mhp1) unstable; urgency=low + + * New upstream release. + + [ Gergely Nagy ] + * Applied a patch to fix framing issues with the syslog protocol, based + on a patch by Zoltan Fried . + + -- Gergely Nagy Fri, 27 Jan 2012 14:47:07 +0100 + +syslog-ng (3.3.3.dfsg-1~mhp2+g511e939) unstable; urgency=low + + * New snapshost release, based on upstream commit 511e939. + + [ Gergely Nagy ] + * Change the package versioning scheme and the way Revision is + assembled: the version now includes the git commit id it is based on, + and so does the revision (which now also includes the distribution + version it was built for, not only in the version). + + -- Gergely Nagy Thu, 29 Dec 2011 10:23:55 +0100 + +syslog-ng (3.3.3.dfsg-1~mhp1) unstable; urgency=low + + * New snapshot release, based on upstream commit cd059ea. + + [ Gergely Nagy ] + * Dropped the previous two patches, they're applied upstream. + + -- Gergely Nagy Thu, 01 Dec 2011 11:46:17 +0100 + +syslog-ng (3.3.3.dfsg-1~mhp0) unstable; urgency=low + + * New upstream release. + + [ Gergely Nagy ] + * Refresh debian/copyright. + * Fix reusable rewrite rules, patch from Zoltan Fried + . + * Fix FTBFS on Hurd, patch from Svante Signell + . (Closes: #648987) + + -- Gergely Nagy Fri, 18 Nov 2011 15:18:37 +0100 + +syslog-ng (3.3.2.dfsg-1~mhp0) unstable; urgency=low + + * New upstream release. + + [ Gergely Nagy ] + * Introduced a syslog-ng-dbg package. + * Init script updates: + + Silence mknod errors, they're not interesting, and adds noise on + kFreeBSD. + + Use set -e. + + Use s-s-d's --oknodo options instead of checking the existence of a + pidfile ourselves. + + -- Gergely Nagy Sun, 13 Nov 2011 19:49:36 +0100 + +syslog-ng (3.3.2.dfsg~0-1~mhp3) unstable; urgency=low + + * New upstream snapshot, based on commit 8239b58. + * Packaging synced with GCS. + + -- Gergely Nagy Wed, 09 Nov 2011 23:41:12 +0100 + +syslog-ng (3.3.1.dfsg-1) unstable; urgency=low + + * New upstream release with important fixes from upstream git tree with + non-free manpages removed. + * Drop syslog-ng.conf(5) (closes: #496521). + * syslog-ng(8) is generated, and does not mention -Q anymore + (closes: #616069). + * Supports CAP_SYSLOG on recent kernels (closes: #630172). + * Does not use g_timeout_add_seconds anymore (closes: #609154). + + [ Gergely Nagy ] + * Update debian/copyright to DEP-5 format. + * Simplified the logrotate file by merging identical entries. + * Include local configuration files from /etc/syslog-ng/conf.d/ (Closes: + #609050). + * Update syslog-ng.conf to be fully 3.3 compliant. + * Compress both source and binaries (except the syslog-ng meta + package) with xz, instead of gzip. + * Use dpkg triggers to restart syslog-ng when appropriate. + * Include DFSG-free manual pages for all binaries. + * Build with Hardening enabled. + * Mention syslog(3) in /etc/default/syslog-ng, instead of + (Closes: #608605) + * Support 'status' in the init script. + Patch from Peter Eisentraut (Closes: #644458) + * Build-Depend on libevtlog-dev (>= 0.2.12-5~) for correct shlibs. + * Use [linux-any] in Build-Depends instead of hardcoded links. + (Closes: #634715) + * Use $SYSLOGNG_OPTS in the init script when reloading syslog-ng. + (Closes: #589081) + + -- Laszlo Boszormenyi (GCS) Tue, 11 Oct 2011 14:30:48 +0200 + +syslog-ng (3.2.4-1) unstable; urgency=high + + * New upstream release, fixing infinite loop via PCRE and global. No CVE + number yet, Vigil@nce id is 10648. + * Remove all patches, they were applied upstream. + + -- Laszlo Boszormenyi (GCS) Mon, 16 May 2011 22:02:46 +0200 + +syslog-ng (3.1.3-3) unstable; urgency=high + + * Fix capability support for unix streams and files when dir_owner() and/or + dir_group() is used (closes: #608791). Urgency set to high to fix this + grave bug which can break logging. + + -- Laszlo Boszormenyi (GCS) Tue, 01 Feb 2011 19:26:21 +0100 + +syslog-ng (3.1.3-2) unstable; urgency=high + + * Security fix on kFreeBSD archs, don't set 7777 rigths on logfiles + (closes: #608491). + + -- Laszlo Boszormenyi (GCS) Sat, 01 Jan 2011 21:46:47 +0100 + +syslog-ng (3.1.3-1) unstable; urgency=medium + + * Medium urgency due to the number of serious bugs fixed. + * New upstream version, fixing configuration version detection + (closes: #603617). + + -- Laszlo Boszormenyi (GCS) Sat, 27 Nov 2010 12:23:55 +0100 + +syslog-ng (3.1.2-3) unstable; urgency=low + + * Apply upstream patch for config file version detection. + * Correct debian/watch . + + -- Laszlo Boszormenyi (GCS) Sun, 14 Nov 2010 07:53:04 +0100 + +syslog-ng (3.1.2-2) unstable; urgency=low + + * Don't set options on reload as it's not needed (closes: #599276). + + -- Laszlo Boszormenyi (GCS) Thu, 04 Nov 2010 18:24:36 +0100 + +syslog-ng (3.1.2-1) unstable; urgency=low + + * New upstream release. + * Update to Standards-Version 3.9.1 . + * Build depend on libcap-dev to add capability support on Linux archs. + * Disable statistics logging (closes: #586749) and restore logging to + /var/log/syslog . + + -- Laszlo Boszormenyi (GCS) Wed, 04 Aug 2010 17:17:51 +0000 + +syslog-ng (3.1.1-3) unstable; urgency=low + + * Update initscript not to fail if syslog-ng is already running or stopped. + * Don't just enable SSL support, but make it really built. + * Don't leave files behind on remove and purge. + + -- Laszlo Boszormenyi (GCS) Sat, 29 May 2010 07:38:34 +0000 + +syslog-ng (3.1.1-2) unstable; urgency=low + + * Add missing messages filter and add rotate of error log (closes: #579620). + * Enable SSL support. + * Update debian/copyright and add OpenSSL exception. + * Enable support for spoofed source addresses and for TCP wrappers. + * Suggest libdbd-mysql, libdbd-pgsql and libdbd-sqlite3 for SQL logging + (closes: 582948). + + -- Laszlo Boszormenyi (GCS) Sun, 23 May 2010 09:41:25 +0000 + +syslog-ng (3.1.1-1) unstable; urgency=low + + * New upstream release. + * Correct program_override for kernel messages (closes: #576550). + + -- Laszlo Boszormenyi (GCS) Sat, 17 Apr 2010 10:35:50 +0000 + +syslog-ng (3.1.0-1) unstable; urgency=low + + * New upstream release. + * Fix path of syslog logfile (closes: #575722) and use tty10 instead of + vc/10 to log on console. + * Provide syslog-ng in initscript (closes: #575723). + + -- Laszlo Boszormenyi (GCS) Sun, 28 Mar 2010 19:47:36 +0000 + +syslog-ng (3.0.5-3) unstable; urgency=low + + * Correct log socket path on kFreeBSD (closes: #574781). + * Clean up packaging a bit, correct watch file. + + -- Laszlo Boszormenyi (GCS) Sun, 21 Mar 2010 19:49:48 +0000 + +syslog-ng (3.0.5-2) unstable; urgency=low + + * Updated configuration to be 3.0 compilant (closes: #574496) and use + source, destination and filter prefixes in their names. + * Update logcheck ignore file (closes: #499526), thanks to Gábor Gombás. + * Version 3.0 is available in Sid now (closes: #556941). + + -- Laszlo Boszormenyi (GCS) Fri, 19 Mar 2010 17:09:49 +0000 + +syslog-ng (3.0.5-1) unstable; urgency=low + + * New upstream release, new maintainer. + + -- Laszlo Boszormenyi (GCS) Sun, 14 Mar 2010 12:57:49 +0000 + +syslog-ng (3.0.1-1) experimental; urgency=low + + * New upstream version + + -- SZALAY Attila Mon, 23 Feb 2009 20:47:41 +0100 + +syslog-ng (2.0.9-4.1) unstable; urgency=high + + * Non-maintainer upload; high priority due to the following security fix. + * Add chdir() before chroot(), and exit if either fails. (Closes: #505791) + * Fix typo in postrm. (Closes: #505797) + * Fix path to DocBook XML DTD. (Closes: #477223) + + -- Ben Hutchings Sun, 23 Nov 2008 20:26:06 +0000 + +syslog-ng (2.0.9-4) unstable; urgency=low + + * Fixed init script to check /usr/sbin/syslog-ng instead of /sbin/syslog-ng. (Closes: #492363) + * Added /dev/xconsole creation into restart and reload too. (Closes: #492585) + * Added missing last paragraph to the README. (Closes: #477224) + * Fixed documentation build problem. (Closes: #477223) + + -- SZALAY Attila Sun, 27 Jul 2008 23:19:03 +0200 + +syslog-ng (2.0.9-3) unstable; urgency=low + + * Linked glib and libevtlog dinamically. (Closes: #482981) + I do not agree with this change and I beleive that it will cause + more problem than would have solved but I want that syslog-ng to go to + lenny. + * Fixed a possible probem in upgrading if /etc/syslog-ng is not exists. + * Changed install root dir /usr + + -- SZALAY Attila Thu, 24 Jul 2008 22:57:26 +0200 + +syslog-ng (2.0.9-2) unstable; urgency=low + + * Moved syslog-ng.persist file to /var/lib/syslog-ng. (Closes: #483369) + + -- SZALAY Attila Wed, 23 Jul 2008 00:01:20 +0200 + +syslog-ng (2.0.9-1) unstable; urgency=low + + * New upstream version. (Closes: #397650, #447105) + * Merged upstream patch to fix a possible segfault if optional file source + is in use. + * Added $remote_fs to LSB dependencies in init script to made it able to + stop correctly. (Closes: #475456) + + -- SZALAY Attila Sun, 20 Apr 2008 13:46:25 +0200 + +syslog-ng (2.0.8~1-1) unstable; urgency=low + + * New upstream version. + - This version is not the official 2.0.8 but close to them. + * Changed to git-based packaging to understand this and made it possible + to team-maintaining syslog-ng. + + -- SZALAY Attila Sun, 3 Feb 2008 15:57:09 +0100 + +syslog-ng (2.0.6-3) unstable; urgency=low + + * Fixed make distclean line to made it able to compile in buildd's. + + -- SZALAY Attila Sun, 06 Jan 2008 22:55:33 +0100 + +syslog-ng (2.0.6-2) unstable; urgency=low + + * Raise standard version to 3.7.3 + * Do not ignore make distcleans errors. + * Fixed a copy&paste bug in syslog-ng.conf.5 man page. + (Closes: #414441) (The patch have been lost when I switch + to version 2.0) + * Changed syslog-ng reloading method in logrotate script to + conform more init methods. (Closes: #417611) + * Fixed the link to the reference guide. (Closes: #450582) + * Added LDFLAGS="-Wl,--as-needed" to configure.in + + -- SZALAY Attila Wed, 26 Dec 2007 01:06:08 +0100 + +syslog-ng (2.0.6-1) unstable; urgency=high + + * New upstream version. + * This release addresses the following security issue: + - A remote attacker can cause a denial of service (crash) + via a crafted log message that is missing a whitespace + at the end of the timestamp (CVE-2007-6437; Closes: #457334) + + -- SZALAY Attila Sat, 22 Dec 2007 15:54:58 +0100 + +syslog-ng (2.0.5-3) unstable; urgency=low + + * Added watchfile. + * Added anonymizer patch created by Micah Anderson. (Closes: #449569) + + -- SZALAY Attila Thu, 08 Nov 2007 00:16:38 +0100 + +syslog-ng (2.0.5-2) unstable; urgency=low + + * Changed init information printing method to lsb. (applied the patch from + Michael Biebl ) (Closes: #419165) + * When removing syslog-ng stop it in prerm. (Closes: #436521) + * Added a new option into the default config to circumvent a logging bug + in gconfd. (Closes: #409620) + + -- SZALAY Attila Sun, 21 Oct 2007 22:42:09 +0200 + +syslog-ng (2.0.5-1) unstable; urgency=low + + * New upstream version. + + -- SZALAY Attila Fri, 14 Sep 2007 23:46:07 +0200 + +syslog-ng (2.0.0-1) unstable; urgency=low + + * New upstream version. I hope it's really fix it. (Closes: #384021) + * Remove util-linux dependecy. This dependency won't needed because + util-linux is essential. (Closes: #398640) + + -- SZALAY Attila Fri, 17 Nov 2006 09:37:45 +0100 + +syslog-ng (2.0rc3-3) unstable; urgency=low + + * This is a try-only version. + * Removed versioned dependency to util-linux. + + -- SZALAY Attila Tue, 14 Nov 2006 22:02:07 +0100 + +syslog-ng (2.0rc3-2) unstable; urgency=medium + + * Fixed NULL dereference when (Closes: #384021) + + -- SZALAY Attila Wed, 25 Oct 2006 22:06:48 +0200 + +syslog-ng (2.0rc3-1) unstable; urgency=low + + * New upstream version. + * Print a message in reload function. (Closes: #384174) + + -- SZALAY Attila Wed, 20 Sep 2006 22:07:27 +0200 + +syslog-ng (2.0rc1-2) unstable; urgency=low + + * Added upstream fix about filters in powerpc. (Closes: #380207) + * Added upstream fix to prevent DOS with zero size UDP packets. + * Created and modified logcheck rules by artin f. krafft added (Closes: #380628) + + -- SZALAY Attila Wed, 2 Aug 2006 16:38:26 +0200 + +syslog-ng (2.0rc1-1) unstable; urgency=low + + * New upstream version. + - Bazsi swear that this release really fix facility and priority + problems. (Closes: #350120, #350344, #374056) + - Do not reconnect to target immediately but wait for time_reopen first. + (Closes: #352695) + - dir_gid was not initialized because of a typo, thus dir_group() did + not take effect, fixed. (Closes: #351095) + * Added logcheck rules created by martin f krafft with two one exception (Closes: #369489, #376750, #355213) + - I do not remove Log statistics line from logcheck.ignore.paranoid. + + -- SZALAY Attila Tue, 18 Jul 2006 23:37:28 +0000 + +syslog-ng (1.9.11-1.1) unstable; urgency=low + + * Non-maintainer upload + * Update license file (Closes: #375236) + * Updated Standard Version to 3.7.2 + * Fix invoke-rc.d call to remove lintian warnings + + -- Pierre Chifflier Mon, 10 Jul 2006 21:51:03 +0200 + +syslog-ng (1.9.11-1) unstable; urgency=low + + * New upstream version + - Fixed log facility and priority detecting. (Closes: #350120, #350344, #357071, #367256) + * Added bison to Build-Dependency. (Closes: #368765) + + -- SZALAY Attila Thu, 25 May 2006 11:21:50 +0200 + +syslog-ng (1.9.9-2) unstable; urgency=low + + * Switch to the latest snapshot version, with some un-released + upstream bug-fixes. (Closes: #352362) + * Fixed misspelled KERNEL_RINGBUF_SIZE. Again. (Closes: #324813) + * Stop syslog-ng when removing. (Closes: #356002) + * Added some new logckeck lines. (Closes: #357692) + * Disable statistic messages in default config file. (Closes: #355833) + + -- SZALAY Attila Thu, 30 Mar 2006 18:25:11 +0200 + +syslog-ng (1.9.9-1) unstable; urgency=low + + * New upstream version. + - Added missing macro definitions. (Closes: #349571) + - Fixed Source reference counting. (Closes: #351312) + + -- SZALAY Attila Tue, 28 Feb 2006 22:34:33 +0100 + +syslog-ng (1.9.8.1+20060128-1) unstable; urgency=low + + * New upstream version. (Closes: #349697, #349840, #350014) + * Added html documentatuin again. (Closes: #344028) + * Added NEWS file to the package. (Closes: #349912) + + -- SZALAY Attila Sat, 28 Jan 2006 17:51:38 +0100 + +syslog-ng (1.9.8.1) unstable; urgency=low + + * Added flex to Build-depends. + + -- SZALAY Attila Mon, 23 Jan 2006 19:50:19 +0000 + +syslog-ng (1.9.8) unstable; urgency=low + + * New upstream version + * First not experimental version. + * Added pkg-confg and libglib2.0-0 dependencies. (Closes: #344795) + * Fixed config file place back to /etc/syslog-ng/ (Closes: #336981) + + -- SZALAY Attila Sat, 21 Jan 2006 16:33:19 +0000 + +syslog-ng (1.9.6) experimental; urgency=low + + * New upstream version. + * Upstream version changed a lot so 3rd party patches dropped out. + + -- SZALAY Attila Tue, 20 Sep 2005 19:49:18 +0000 + +syslog-ng (1.6.8-1) unstable; urgency=low + + * New upstream version. + * Debian patch cleaned up. If something needed dropped out please tell me! + * Create /dev/xconsole if not exists. (Closes: #312690) + * Check the config file for syntax errors before reload. (Closes: #294888) + * Fixed a typo in syslog-ng.conf (Closes: #312114) + * Created a directory. Put debian specific patches into it. + * Added the new version of syslog-ng-annon patch. (Closes: #303808) + + -- SZALAY Attila Thu, 9 Jun 2005 20:10:54 +0000 + +syslog-ng (1.6.7-2) unstable; urgency=high + + * Added syslog-ng-anon IP anonymizing patch, see + /usr/share/doc/README.syslog-ng-anon for more information (Closes: #303808) + * Restart syslog-ng manually and start it only if installed and not upgraded. (Closes: #297190) + Set urgency to high because of this. + * In int change start-stop-damon call parameter from --exec to --name to + enable restart syslog-ng after upgrade. + + -- SZALAY Attila Tue, 24 May 2005 11:43:11 +0200 + +syslog-ng (1.6.7-1) unstable; urgency=low + + * New upstream version. (Closes: #301617, #304894, #304966, #282782) + * Check if CONSOLE_LOG_LEVEL and KERNEL_RINGBUF_SIZE has value and not + complain about wrong value, if not. (Closes: #296315, #304215) + * Removed unneeded code from postrm. (This code was to remove divertion, + but syslog-ng does not divert any file any more.) + * Removed KERNEL_RINGBUF_SIZE option. (Closes: #298022) + * Added AC_PREREQ(2.50) to configure.in. (Closes: #299543) + + -- SZALAY Attila Sun, 22 May 2005 01:13:49 +0200 + +syslog-ng (1.6.5-2.2) unstable; urgency=low + + * Fixed missing space in versioned-depends on util-linux + * Fixed improper UTF-8 conversion of debian/changelog, thanks + cjwatson@debian.org + + -- Micah Anderson Tue, 10 May 2005 14:49:20 -0500 + +syslog-ng (1.6.5-2.1) unstable; urgency=high + + * Non-maintainer upload to fix security hole for sarge + * Added upstream patch to fix log messages getting dropped which allowed + certain forms of attacks to be performed without getting logged. + (Closes: #304894) + * Changed debian/control to use a versioned depends on util-linux + to fix lintian error + * Converted debian/changelog to be valid UTF-8 by to fix lintian + error + * Updated documentation: doc/syslog-ng.conf.5, doc/syslog-ng.8 to fix + outdated information and typos and language clarification on klogd + in doc/sgml/syslog-ng.sgml + + -- Micah Anderson Mon, 9 May 2005 23:41:48 -0500 + +syslog-ng (1.6.5-2) unstable; urgency=low + + * Checks if UDP ends in NL or NUL. Closes: #282782 + * Merged in _second_ version of Loic's syslog-ng.conf. Closes: #268686 + * Made kernel logging parameters configureable through /etc/defaults/syslog-ng. Closes: #283091 + + -- Magosányi Árpád (mag) Sat, 11 Dec 2004 22:16:43 +0100 + +syslog-ng (1.6.5-1) unstable; urgency=low + + * New upstream version + + -- Magosányi Árpád (mag) Tue, 2 Nov 2004 01:53:53 +0100 + +syslog-ng (1.6.4-2) unstable; urgency=low + + * Added patch from Loic Minier to make init script more sane. Closes: #268820 + * Added PATH to init script. Closes: #262224 + * Only one instance of html documentation. Patch from Loic Minier. Closes: #268685 + * Stops only once in prerm. Closes: #268848 + * New syslog-ng.conf. Closes: #268686 + * Added Nate Campi's FAQ. Closes: #268998 + + -- Magosányi Árpád (mag) Mon, 13 Sep 2004 17:19:50 +0200 + +syslog-ng (1.6.4-1) unstable; urgency=low + + * New upstream version + + -- Magosányi Árpád (mag) Sat, 24 Jul 2004 17:45:51 +0200 + +syslog-ng (1.6.2-4) unstable; urgency=low + + * fixed permissions of default syslog-ng.conf. Closes: #242531 + * added Nate Campi's expanded syslog-ng.conf to docs. Closes: #241783 + * fixed cut-and-paste errors in manpage of syslog-ng.conf. Closes: #260845 + + -- Magosányi Árpád (mag) Sat, 12 Jun 2004 23:27:45 +0200 + +syslog-ng (1.6.2-3) unstable; urgency=low + + * changed manpage to better reflect -v. Closes: #228377 + * fixed build-depends, hopefully correctly now:( Closes: #237668 + + -- Magosányi Árpád (mag) Sat, 13 Mar 2004 18:35:37 +0100 + +syslog-ng (1.6.2-2) unstable; urgency=low + + * Automake build-dependency added. Closes: #237668 + + -- Magosányi Árpád (mag) Fri, 12 Mar 2004 21:44:56 +0100 + +syslog-ng (1.6.2-1) unstable; urgency=low + + * New upstream version: + * added PRI macro + * fixed a problem in PIX log parsing, + * have a FAQ. documented STATS (#192054) + * (1.6.0rc4-4) Now you can tell that destination file permissions shall not changed. closes: #65456 + * (1.6.0rc4-2) removed logrotate configuration for ppp.log. Closes: #207411 + * (1.6.0rc4-2) corrected documentation of match in syslog-ng.conf(5) . Closes: #206819 + + -- Magosányi Árpád (mag) Fri, 12 Mar 2004 15:04:15 +0100 + +syslog-ng (1.6.0rc4-4) unstable; urgency=low + + * Now you can tell that destination file permissions shall not changed. closes: 65456 + * rolled back changes related to gnu arch (gnu arch is a good idea, but + the changes were not.) + * Regenerating non-source documentation. + + -- Magosányi Árpád (mag) Thu, 11 Dec 2003 23:05:11 +0100 + +syslog-ng (1.6.0rc4-3) unstable; urgency=low + + * debian/rules changes to utilize gnu arch (tla) + + -- Magosányi Árpád (mag) Wed, 15 Oct 2003 17:05:20 +0200 + +syslog-ng (1.6.0rc4-2) unstable; urgency=low + + * documentation patch with faq. Closes: #192054 + * removed logrotate configuration for ppp.log. Closes: #207411 + * corrected documentation of match in syslog-ng.conf(5) . Closes: #206819 + * added documentation to faq about log ownership. closes: #65456 + + -- Magosányi Árpád (mag) Tue, 14 Oct 2003 16:30:01 +0200 + +syslog-ng (1.6.0rc4-1) unstable; urgency=low + + * New upstream version + * New libol version + * removed duplicate restart in postinst. Closes: #204631 + * added Mag as co-maintainer + * incremented Standards-Version to 3.6.1 + * language fix in postinst, thanks to Marcus Crafter . + Closes: #171792 + * cut reference to future features. Closes: #215197 + + -- Magosányi Árpád (mag) Tue, 14 Oct 2003 13:30:34 +0200 + +syslog-ng (1.6.0rc1+20030310-2) unstable; urgency=low + + * Forward port bugfix. Log every new log. + * Remove unwanted 'x' char from conffile. Closes: #184985 + + -- Szalay Attila Sun, 16 Mar 2003 11:02:16 +0000 + +syslog-ng (1.6.0rc1+20030310-1) unstable; urgency=low + + * New upstream version. Closes: #184026. + * Set gconfd as bad hostname. Closes: #107189. + * Fix a typo in postinst srcipt (becouse->because). Closes: #170499. + + -- Szalay Attila Tue, 11 Mar 2003 05:42:29 +0000 + +syslog-ng (1.5.23-1) unstable; urgency=low + + * New upstream version. + * Change file ownership in /var/log/news dir to news.news. Closes: #169621 + + -- SZALAY Attila Thu, 21 Nov 2002 00:08:56 +0100 + +syslog-ng (1.5.22-1) unstable; urgency=low + + * New upstream version. + * Close buffer overflow bug. See changelog for 1.5.21-1. Closes: #164487 + * Wait a second to flushing buffers, but after that syslog-ng exit. + Closes: #164504, #164703 + + -- SZALAY Attila Wed, 16 Oct 2002 22:55:51 +0200 + +syslog-ng (1.5.21-2) unstable; urgency=low + + * Rewrite debian/syslog-ng.conffiles. That file disappear somewhere + between woody and sid. Closes: #165030 + + -- SZALAY Attila Wed, 16 Oct 2002 17:22:13 +0200 + +syslog-ng (1.5.21-1) unstable; urgency=low + + * New upstream version. + * security fix, decrement 'left' counter when appending a constant character Close: #164487 + * implemented a workaround for Linux 2.2 and 2.4 (unix domain sockets and recvfrom) + * Change --with-debug to --enable debug, reflect to upstream changes. + + -- SZALAY Attila Sun, 13 Oct 2002 19:00:00 +0200 + +syslog-ng (1.5.20-1) unstable; urgency=low + + * New upstream version. + * Upstream fix mixing message bug. Closes: #147161 + + -- SZALAY Attila Sun, 8 Sep 2002 08:56:56 +0200 + +syslog-ng (1.5.19-3) unstable; urgency=low + + * Change to --compare-versions. Close: #156112, #156136 + * Include example written by from Jörg Sommer . + Close: #156114 + * Change the if statement from `timeout <= 0' to `timeout > 0' and + therefore log STATS message only if timeout > 0. Close: #156045 + * Becouse I'm change main.c touch main.c.x to not break compile. + + -- SZALAY Attila Sun, 11 Aug 2002 17:15:43 +0200 + +syslog-ng (1.5.19-2) unstable; urgency=low + + * Include ignore files for logcheck. + * Move examples files to right directory. + + -- SZALAY Attila Thu, 8 Aug 2002 15:28:04 +0200 + +syslog-ng (1.5.19-1) unstable; urgency=low + + * New upstream version. + * Doesn't touch main.c, so scsh doesn't needed. Close: #150118 + * Change to unix-stream, becouse programs like it more. :) + + -- SZALAY Attila Sat, 3 Aug 2002 21:06:54 +0200 + +syslog-ng (1.5.18-1) unstable; urgency=low + + * New upstream version. + * Remove dependency of automake becouse upstream author upgrade to woody. :) + * Read /proc/kmsg directly again. It's eliminate all the problem around klogd. + * Upgrade Standards-Version to 3.5.6.0 + + -- SZALAY Attila Thu, 6 Jun 2002 08:34:02 +0200 + +syslog-ng (1.5.15-1.1) unstable; urgency=high + + * Non-maintainer upload + * Modified init script to optionally restart klogd. This is + the 'wrong' fix for #129819, but better than doing nothing + at all with woody release approaching. + + -- Stephen Frost Sun, 28 Apr 2002 05:14:42 -0400 + +syslog-ng (1.5.15-1) unstable; urgency=high + + * New upstream version. + * Doesn't drop connections to the floor on reload. Closes: #129819, #132708 + + -- SZALAY Attila Mon, 4 Mar 2002 21:29:11 +0100 + +syslog-ng (1.5.13-2) unstable; urgency=low + + * Now 0 or less frequency for STAT will disable it. Closes: #122482 + * Bugfix. When reload STAT timer set the value before reload not the new. + + -- SZALAY Attila Tue, 25 Dec 2001 01:56:38 +0100 + +syslog-ng (1.5.13-1) unstable; urgency=low + + * New upstream version. + + -- SZALAY Attila Sun, 4 Nov 2001 08:41:15 +0100 + +syslog-ng (1.5.9-2) unstable; urgency=low + + * Oooopss. Now really remove /proc/kmsg from src. Closes: #111176 + + -- SZALAY Attila Wed, 5 Sep 2001 09:43:41 +0200 + +syslog-ng (1.5.9-1) unstable; urgency=low + + * New upstream version. Now log if a message cannnot write to a destination + (for example if network is broken or HDD is too slow) + * Change priority to extra. Closes: #110116 + * Remove klogctl from ditribution, becouse unneeded. (see dmesg) Closes: #101997 + * Now syslog-ng work together with klogd. (Change /dev/log from stream-oriented + connection to datagram-oriented.) (It was done earlyer, but becouse I + doesn't have time I can't test it) Closes: #94383 + * Becouse of the above I must remove reading /proc/kmsg. And becouse of this + syslog-ng now recommend klogd. (again) + * And again becouse af the above, I can't revert the changes about /dev/log. + Closes: #108111 + * Becouse now klogd read /proc/kmsg this bug not bug any more. :) Closes: #90166 + * This is honeymoon release. :) + + -- SZALAY Attila Sun, 2 Sep 2001 16:22:19 +0200 + +syslog-ng (1.5.8-2) unstable; urgency=low + + * Include libtool in Build-depend. Closes: #105872 + + -- SZALAY Attila Thu, 19 Jul 2001 16:15:50 +0200 + +syslog-ng (1.5.8-1) unstable; urgency=low + + * New upstream version. Now record wich connection is broken, and + record when connection is reestablished. Closes: #92588 + * Put debhelper into build-depend. Closes: #104302 + * syslog-ng just recommend logrotate. Closes: #92129 + * Use autoconf/automaker for building. Closes: #99126 + + -- SZALAY Attila Fri, 13 Jul 2001 12:58:14 +0200 + +syslog-ng (1.5.6-1) unstable; urgency=low + + * New upstream version. Applied the patch, therfore Closes: #94898 + + -- SZALAY Attila Fri, 4 May 2001 23:11:07 +0200 + +syslog-ng (1.5.5a-1) unstable; urgency=low + + * New upstream version. + Hopefully fixed -HUP problem. Closes: #65455 + * Put flex, autoconf and m4 into build-depend. Closes: #91875 + * In logrotate files put { into the log file names line. Closes: #95614 + * Apply the cosmeting init script patch. Closes: #92094 + + -- SZALAY Attila Thu, 3 May 2001 11:37:52 +0200 + +syslog-ng (1.5.4-3) unstable; urgency=low + + * Now really remove doc/syslog-ng/INSTALL.gz (I hope) + * Now uucp filter filtering messages from uucp. Closes: #90610 + + -- SZALAY Attila Wed, 21 Mar 2001 23:04:57 +0100 + +syslog-ng (1.5.4-2) unstable; urgency=low + + * Change '==' to '=' in postinst. Closes: #87863 + * I forgot to link it to sysklogd. Now it's done Closes: #75643 + * Remove doc/syslog-ng/INSTALL.gz. Closes: #88281 + * Disable logrotate script when removed. Closes: #77314 + * Full upload, becouse I made a mistake with .orig.tgz + + -- SZALAY Attila Thu, 15 Mar 2001 22:37:25 +0100 + +syslog-ng (1.5.4-1) unstable; urgency=low + + * New upstream version. + * Now syslog-ng read /proc/kmsg and therefore it not need klog any more. + (Of course we loose Ooops decoding :(( + Closes: #86074, #80793, #85118, #78316, #78620 + + -- SZALAY Attila Tue, 20 Feb 2001 22:02:40 +0100 + +syslog-ng (1.4.10-1) unstable; urgency=low + + * New upstream version. + * Change Recommend line from kernel-log-daemon to linux-kernel-log-daemon + + -- SZALAY Attila Tue, 5 Dec 2000 09:21:39 +0100 + +syslog-ng (1.4.9a-1) unstable; urgency=low + + * New upstream version. (Solve a DoS attack.) + + -- SZALAY Attila Sun, 26 Nov 2000 16:12:14 +0100 + +syslog-ng (1.4.8-1) unstable; urgency=low + + * New upstream version + * Clean some bugreport. + * syslog-ng no longer contain klogd. Closes: #70784 + * It's a network problem, not syslog-ng. Closes: #60747 + * This bug solved upstream somewhere between 1.4.5 and 1.4.8. Closes: #74594 + * syslog-ng no longer renames /etc/init.d/sysklogd to + /etc/init.d/sysklogd.syslog-ng. Closes: #74864 + + -- SZALAY Attila Wed, 8 Nov 2000 15:11:45 +0100 + +syslog-ng (1.4.7-2) unstable; urgency=low + + * Change depend line to Recommend. But now syslog-ng Conflicts with sysklogd. + It's a bit bad, beacause I loose klogd, for a while. Closes: #74513 + + -- SZALAY Attila Sat, 21 Oct 2000 12:29:05 +0200 + +syslog-ng (1.4.7-1) unstable; urgency=low + + * New upstream version. (It's solve memory leak!) + * Provide virtual package: system-log-daemon. Closes: #67603 + * Replace chars under chr(32) with spaces. Closes: #69026 + * syslog-ng now Conflicts with other system-log-daemons: Closes: #72122, #72195, #72483 + * Old, closed bugs: Closes: #55275, #58415 + * Put some notifempy and missingok to logrotate file. Closes: #72308 + * I Depend on kernel-log daemon now becouse installing it before sysklogd + split is dangerous + + -- SZALAY Attila Sun, 8 Oct 2000 17:34:17 +0200 + +syslog-ng (1.4.5-1) unstable; urgency=low + + * New upstream version. Closes: #67752 + + -- SZALAY Attila Thu, 10 Aug 2000 18:01:39 +0200 + +syslog-ng (1.4.4-1) unstable; urgency=low + + * New upstream version. + * Change logfile-s ownership to root.adm + * Restart syslog-ng in postinst. Closes: #64692 + * log local2.* to /var/log/ppp.log Closes: #63741 + + -- SZALAY Attila Sat, 10 Jun 2000 11:06:01 +0200 + +syslog-ng (1.4.3-1) unstable; urgency=low + + * New upstream version. + * Test the existence of conffiles. Closes: #62229 + + -- SZALAY Attila Sat, 10 Jun 2000 10:44:50 +0200 + +syslog-ng (1.4.0rc3-2) frozen unstable; urgency=low + + * Fix a typo in syslog-ng.conf Closes: #59361 + + -- SZALAY Attila Mon, 6 Mar 2000 09:51:04 +0100 + +syslog-ng (1.4.0rc3-1) frozen unstable; urgency=high + + * New upstream version + * This version is from the new stable branch, hopefully + without bug. :)) + * It's should compile in Alpha. Closes: #5575, #53728 + + -- SZALAY Attila Sun, 27 Feb 2000 23:09:22 +0100 + +syslog-ng (1.3.17-1) unstable; urgency=low + + * New upstream version. + + -- SZALAY Attila Sat, 19 Feb 2000 12:39:04 +0100 + +syslog-ng (1.3.14-1) unstable; urgency=low + + * New upstream version. Now it run with 2.3.X kernels. + + -- SZALAY Attila Tue, 8 Feb 2000 13:18:33 +0100 + +syslog-ng (1.3.13-1) frozen; urgency=low + + * New upstream version, with bugfix (notable in sun port), + and documentation upgrades. + + -- SZALAY Attila Tue, 18 Jan 2000 23:15:49 +0100 + +syslog-ng (1.3.12-2) unstable; urgency=low + + * move dpkg-divert to postinst, preventing deadlock. Closes: #54608 + * But it's not protect sysklogd to go to unconfigurable state + when upgrade (update-rc fails becouse the divert) + (may it's a bug in update-rc, or it must handle in postinst?) + (and therfore its bug in debhelper? :)) + + -- SZALAY Attila Tue, 11 Jan 2000 12:02:14 +0100 + +syslog-ng (1.3.12-1) unstable; urgency=low + + * New upstream version. + * Look for diversions, and if doesn't exists, make it! + (Even when upgrade). Closes: #53731 + * Write warning about remote logging into README.Debian, and + to console, when install syslog-ng, and in sysklogd remote + logging was enabled. Closes: #53170 + + -- SZALAY Attila Thu, 6 Jan 2000 12:51:24 +0100 + +syslog-ng (1.3.10-3) unstable; urgency=low + + * Write a warning message about remote logging + * Make the first steps to write comments into conf file. + + -- SZALAY Attila Wed, 22 Dec 1999 01:44:10 +0100 + +syslog-ng (1.3.10-2) unstable; urgency=high + + * Remove a buggy line from syslog-ng.conf, what is inhibit + syslog-ng to start. Closes: #53162 + + -- SZALAY Attila Mon, 20 Dec 1999 20:41:40 +0100 + +syslog-ng (1.3.10-1) unstable; urgency=low + + * New upstream version, with fixing a bug in pipe handling. + * Now syslog-ng usable with Debian default compatible + /etc/syslog-ng/syslog-ng.conf. Closes: #52638 + + -- SZALAY Attila Sun, 19 Dec 1999 10:56:42 +0100 + +syslog-ng (1.3.9-1) unstable; urgency=low + + * New upstream version. + + -- SZALAY Attila Fri, 17 Dec 1999 22:38:46 +0100 + +syslog-ng (1.3.8-1) unstable; urgency=low + + * New upstream version. + + -- SZALAY Attila Wed, 15 Dec 1999 22:49:44 +0100 + +syslog-ng (1.3.7-2) unstable; urgency=low + + * Rewrite /etc/syslog-ng/syslog-ng.conf to be really compatible + with Debian default. + * Remove v from tar -xzvf in debian/rules + + -- SZALAY Attila Mon, 13 Dec 1999 20:58:44 +0100 + +syslog-ng (1.3.7-1) unstable; urgency=low + + * New upstream version. + * Restart sysklogd when remove syslog-ng. + * replace --prefix with DESTDIR Closes: #52573 + * Change to rfakeroot from rsudo. + + -- SZALAY Attila Sun, 12 Dec 1999 23:54:34 +0100 + +syslog-ng (1.3.6-2) unstable; urgency=low + + * Fix some bug. + + -- SZALAY Attila Thu, 9 Dec 1999 00:57:47 +0100 + +syslog-ng (1.3.6-1) unstable; urgency=low + + * New upstream version. + * Changed to development branch + * Change to logrotate + + -- SZALAY Attila Wed, 8 Dec 1999 00:23:46 +0100 + +syslog-ng (1.2.3-1) unstable; urgency=low + + * New upstream version. + + -- SZALAY Attila Tue, 7 Dec 1999 16:30:38 +0100 + +syslog-ng (1.2.2-1) unstable; urgency=low + + * Initial Release. + + -- SZALAY Attila Thu, 2 Dec 1999 01:38:28 +0200 diff -Nru syslog-ng-3.11.1/packaging/debian/compat syslog-ng-3.13.2/packaging/debian/compat --- syslog-ng-3.11.1/packaging/debian/compat 1970-01-01 00:00:00.000000000 +0000 +++ syslog-ng-3.13.2/packaging/debian/compat 2017-12-06 06:39:39.000000000 +0000 @@ -0,0 +1 @@ +10 diff -Nru syslog-ng-3.11.1/packaging/debian/control syslog-ng-3.13.2/packaging/debian/control --- syslog-ng-3.11.1/packaging/debian/control 1970-01-01 00:00:00.000000000 +0000 +++ syslog-ng-3.13.2/packaging/debian/control 2017-12-06 06:39:39.000000000 +0000 @@ -0,0 +1,840 @@ +Source: syslog-ng +Section: admin +Priority: extra +Maintainer: syslog-ng maintainers +Uploaders: Laszlo Boszormenyi (GCS) , + SZALAY Attila +Build-Depends: debhelper (>= 9~), + dh-autoreconf, + automake (>= 1:1.11.1), + autoconf-archive, + tzdata, + pkg-config, flex, bison, + xsltproc, docbook-xsl, + libesmtp-dev, + libivykis-dev (>= 0.36.1~), + libnet1-dev, + libglib2.0-dev, + libdbi-dev | libdbi0-dev, + libssl-dev, + libmongoc-dev, + libbson-dev, + libjson-c-dev | libjson0-dev, + libwrap0-dev, + libpcre3-dev, + libcap-dev [linux-any], + dh-systemd (>= 1.3), + libsystemd-daemon-dev [linux-any] | libsystemd-dev [linux-any], + libsystemd-journal-dev (>= 195) | libsystemd-dev [linux-any], + libgeoip-dev, + libhiredis-dev, + libriemann-client-dev (>= 1.6.0~), + librabbitmq-dev (>= 0.5.3~), + python, python-dev, pylint, dh-python, + pep8 | python-pep8, + python-setuptools, + dh-exec, + python-nose, python-ply, + libxml2-utils, geoip-database, + libcurl4-openssl-dev, + libmaxminddb-dev, + openjdk-7-jdk | openjdk-8-jdk, + gradle (>=2.2.1), + criterion-dev +Build-Conflicts: autoconf2.13 +Standards-Version: 3.9.8 +Homepage: http://www.syslog-ng.org/ +Vcs-Git: https://github.com/gcsideal/syslog-ng-debian.git +Vcs-Browser: https://github.com/gcsideal/syslog-ng-debian + +Package: syslog-ng +Architecture: all +Multi-Arch: foreign +Depends: ${misc:Depends}, syslog-ng-core (>= ${source:Upstream-Version}), ${sng:CoreModules} +Recommends: ${sng:Modules} +Description: Enhanced system logging daemon (metapackage) + syslog-ng is an enhanced log daemon, supporting a wide range of input + and output methods: syslog, unstructured text, message queues, + databases (SQL and NoSQL alike) and more. + . + Key features: + . + * receive and send RFC3164 and RFC5424 style syslog messages + * work with any kind of unstructured data + * receive and send JSON formatted messages + * classify and structure logs with builtin parsers (csv-parser(), + db-parser(), etc.) + * normalize, crunch and process logs as they flow through the system + * hand on messages for further processing using message queues (like + AMQP), files or databases (like PostgreSQL or MongoDB). + . + This package is a metapackage, depending on the rest of syslog-ng, + including all available plugins. It can be safely removed, if only + parts of syslog-ng need to be installed. + +Package: syslog-ng-dbg +Architecture: any +Multi-Arch: same +Section: debug +Depends: syslog-ng-core (= ${binary:Version}), ${misc:Depends} +Description: Enhanced system logging daemon (debug symbols) + syslog-ng is an enhanced log daemon, supporting a wide range of input + and output methods: syslog, unstructured text, message queues, + databases (SQL and NoSQL alike) and more. + . + Key features: + . + * receive and send RFC3164 and RFC5424 style syslog messages + * work with any kind of unstructured data + * receive and send JSON formatted messages + * classify and structure logs with builtin parsers (csv-parser(), + db-parser(), etc.) + * normalize, crunch and process logs as they flow through the system + * hand on messages for further processing using message queues (like + AMQP), files or databases (like PostgreSQL or MongoDB). + . + This package contains debug symbols for the whole of syslog-ng, + including the modules. + +Package: syslog-ng-dev +Section: libdevel +Architecture: any +Depends: syslog-ng-core (= ${binary:Version}), + ${misc:Depends}, ${perl:Depends}, + pkg-config, perl, flex, bison, + libglib2.0-dev, libivykis-dev (>= 0.30) +Description: Enhanced system logging daemon (development files) + syslog-ng is an enhanced log daemon, supporting a wide range of input + and output methods: syslog, unstructured text, message queues, + databases (SQL and NoSQL alike) and more. + . + Key features: + . + * receive and send RFC3164 and RFC5424 style syslog messages + * work with any kind of unstructured data + * receive and send JSON formatted messages + * classify and structure logs with builtin parsers (csv-parser(), + db-parser(), etc.) + * normalize, crunch and process logs as they flow through the system + * hand on messages for further processing using message queues (like + AMQP), files or databases (like PostgreSQL or MongoDB). + . + This package contains the headers and tools needed to build + third-party plugins against syslog-ng, the next generation system + logging daemon. + +Package: syslog-ng-core +Architecture: any +Multi-Arch: foreign +Depends: ${shlibs:Depends}, ${misc:Depends}, util-linux (>= 2.12-10), lsb-base (>= 3.0-6) +Recommends: logrotate +Suggests: ${sng:CoreModules}, ${sng:Modules} +Provides: system-log-daemon, linux-kernel-log-daemon +Conflicts: system-log-daemon, linux-kernel-log-daemon +Replaces: syslog-ng (<< 3.3.0~), libsyslog-ng-dev, syslog-ng-mod-json (<< 3.13.1~) +Breaks: syslog-ng (<< 3.3.0~), libsyslog-ng-dev, syslog-ng-mod-json (<< 3.13.1~) +Description: Enhanced system logging daemon (core) + syslog-ng is an enhanced log daemon, supporting a wide range of input + and output methods: syslog, unstructured text, message queues, + databases (SQL and NoSQL alike) and more. + . + Key features: + . + * receive and send RFC3164 and RFC5424 style syslog messages + * work with any kind of unstructured data + * receive and send JSON formatted messages + * classify and structure logs with builtin parsers (csv-parser(), + db-parser(), etc.) + * normalize, crunch and process logs as they flow through the system + * hand on messages for further processing using message queues (like + AMQP), files or databases (like PostgreSQL or MongoDB). + . + This package provides the core syslog-ng, with all the plugins + required for a standard installation. + +Package: syslog-ng-mod-mongodb +Architecture: any +Multi-Arch: foreign +Depends: ${shlibs:Depends}, ${misc:Depends} +Suggests: mongodb-server +Description: Enhanced system logging daemon (MongoDB plugin) + syslog-ng is an enhanced log daemon, supporting a wide range of input + and output methods: syslog, unstructured text, message queues, + databases (SQL and NoSQL alike) and more. + . + Key features: + . + * receive and send RFC3164 and RFC5424 style syslog messages + * work with any kind of unstructured data + * receive and send JSON formatted messages + * classify and structure logs with builtin parsers (csv-parser(), + db-parser(), etc.) + * normalize, crunch and process logs as they flow through the system + * hand on messages for further processing using message queues (like + AMQP), files or databases (like PostgreSQL or MongoDB). + . + This package provides the MongoDB destination plugin, which allows + one to log system messages to MongoDB. + +Package: syslog-ng-mod-sql +Architecture: any +Multi-Arch: foreign +Depends: ${shlibs:Depends}, ${misc:Depends} +Suggests: syslog-ng-mod-mysql, syslog-ng-mod-pgsql, syslog-ng-mod-sqlite3, syslog-ng-mod-freetds +Description: Enhanced system logging daemon (SQL plugin) + syslog-ng is an enhanced log daemon, supporting a wide range of input + and output methods: syslog, unstructured text, message queues, + databases (SQL and NoSQL alike) and more. + . + Key features: + . + * receive and send RFC3164 and RFC5424 style syslog messages + * work with any kind of unstructured data + * receive and send JSON formatted messages + * classify and structure logs with builtin parsers (csv-parser(), + db-parser(), etc.) + * normalize, crunch and process logs as they flow through the system + * hand on messages for further processing using message queues (like + AMQP), files or databases (like PostgreSQL or MongoDB). + . + This package provides the SQL destination plugin, which allows one to + log system messages to a multitude of SQL databases (including, but + not limited to MySQL, PostgreSQL and SQLite). + +Package: syslog-ng-mod-mysql +Architecture: any +Multi-Arch: foreign +Depends: syslog-ng-mod-sql, libdbd-mysql +Description: Enhanced system logging daemon (SQL plugin) + syslog-ng is an enhanced log daemon, supporting a wide range of input + and output methods: syslog, unstructured text, message queues, + databases (SQL and NoSQL alike) and more. + . + Key features: + . + * receive and send RFC3164 and RFC5424 style syslog messages + * work with any kind of unstructured data + * receive and send JSON formatted messages + * classify and structure logs with builtin parsers (csv-parser(), + db-parser(), etc.) + * normalize, crunch and process logs as they flow through the system + * hand on messages for further processing using message queues (like + AMQP), files or databases (like PostgreSQL or MongoDB). + . + This package provides the SQL destination plugin, which allows one to + log system messages to MySQL databases. + +Package: syslog-ng-mod-pgsql +Architecture: any +Multi-Arch: foreign +Depends: syslog-ng-mod-sql, libdbd-pgsql +Description: Enhanced system logging daemon (SQL plugin) + syslog-ng is an enhanced log daemon, supporting a wide range of input + and output methods: syslog, unstructured text, message queues, + databases (SQL and NoSQL alike) and more. + . + Key features: + . + * receive and send RFC3164 and RFC5424 style syslog messages + * work with any kind of unstructured data + * receive and send JSON formatted messages + * classify and structure logs with builtin parsers (csv-parser(), + db-parser(), etc.) + * normalize, crunch and process logs as they flow through the system + * hand on messages for further processing using message queues (like + AMQP), files or databases (like PostgreSQL or MongoDB). + . + This package provides the SQL destination plugin, which allows one to + log system messages to PostgreSQL databases. + +Package: syslog-ng-mod-sqlite3 +Architecture: any +Multi-Arch: foreign +Depends: syslog-ng-mod-sql, libdbd-sqlite3 +Description: Enhanced system logging daemon (SQL plugin) + syslog-ng is an enhanced log daemon, supporting a wide range of input + and output methods: syslog, unstructured text, message queues, + databases (SQL and NoSQL alike) and more. + . + Key features: + . + * receive and send RFC3164 and RFC5424 style syslog messages + * work with any kind of unstructured data + * receive and send JSON formatted messages + * classify and structure logs with builtin parsers (csv-parser(), + db-parser(), etc.) + * normalize, crunch and process logs as they flow through the system + * hand on messages for further processing using message queues (like + AMQP), files or databases (like PostgreSQL or MongoDB). + . + This package provides the SQL destination plugin, which allows one to + log system messages to SQLite databases. + +Package: syslog-ng-mod-freetds +Architecture: any +Multi-Arch: foreign +Depends: syslog-ng-mod-sql, libdbd-freetds +Description: Enhanced system logging daemon (SQL plugin) + syslog-ng is an enhanced log daemon, supporting a wide range of input + and output methods: syslog, unstructured text, message queues, + databases (SQL and NoSQL alike) and more. + . + Key features: + . + * receive and send RFC3164 and RFC5424 style syslog messages + * work with any kind of unstructured data + * receive and send JSON formatted messages + * classify and structure logs with builtin parsers (csv-parser(), + db-parser(), etc.) + * normalize, crunch and process logs as they flow through the system + * hand on messages for further processing using message queues (like + AMQP), files or databases (like PostgreSQL or MongoDB). + . + This package provides the SQL destination plugin, which allows one to + log system messages to MSSql/FreeTDS databases. + +Package: syslog-ng-mod-smtp +Architecture: any +Multi-Arch: foreign +Depends: ${shlibs:Depends}, ${misc:Depends} +Description: Enhanced system logging daemon (SMTP plugin) + syslog-ng is an enhanced log daemon, supporting a wide range of input + and output methods: syslog, unstructured text, message queues, + databases (SQL and NoSQL alike) and more. + . + Key features: + . + * receive and send RFC3164 and RFC5424 style syslog messages + * work with any kind of unstructured data + * receive and send JSON formatted messages + * classify and structure logs with builtin parsers (csv-parser(), + db-parser(), etc.) + * normalize, crunch and process logs as they flow through the system + * hand on messages for further processing using message queues (like + AMQP), files or databases (like PostgreSQL or MongoDB). + . + This package provides the SMTP destination plugin, which allows one + to send email messages from within syslog-ng itself. + +Package: syslog-ng-mod-amqp +Architecture: any +Multi-Arch: foreign +Depends: ${shlibs:Depends}, ${misc:Depends} +Suggests: rabbitmq-server +Description: Enhanced system logging daemon (AMQP plugin) + syslog-ng is an enhanced log daemon, supporting a wide range of input + and output methods: syslog, unstructured text, message queues, + databases (SQL and NoSQL alike) and more. + . + Key features: + . + * receive and send RFC3164 and RFC5424 style syslog messages + * work with any kind of unstructured data + * receive and send JSON formatted messages + * classify and structure logs with builtin parsers (csv-parser(), + db-parser(), etc.) + * normalize, crunch and process logs as they flow through the system + * hand on messages for further processing using message queues (like + AMQP), files or databases (like PostgreSQL or MongoDB). + . + This package provides the AMQP destination plugin, which allows one + to publish log messages through the AMQP protocol. + +Package: syslog-ng-mod-geoip +Architecture: any +Multi-Arch: foreign +Depends: ${shlibs:Depends}, ${misc:Depends} +Recommends: geoip-database +Description: Enhanced system logging daemon (GeoIP plugin) + syslog-ng is an enhanced log daemon, supporting a wide range of input + and output methods: syslog, unstructured text, message queues, + databases (SQL and NoSQL alike) and more. + . + Key features: + . + * receive and send RFC3164 and RFC5424 style syslog messages + * work with any kind of unstructured data + * receive and send JSON formatted messages + * classify and structure logs with builtin parsers (csv-parser(), + db-parser(), etc.) + * normalize, crunch and process logs as they flow through the system + * hand on messages for further processing using message queues (like + AMQP), files or databases (like PostgreSQL or MongoDB). + . + This package provides the GeoIP template function plugin, which + allows one to do non-DNS IP-to-country resolving from syslog-ng + templates. + +Package: syslog-ng-mod-redis +Architecture: any +Multi-Arch: foreign +Depends: ${shlibs:Depends}, ${misc:Depends} +Description: Enhanced system logging daemon (Redis plugin) + syslog-ng is an enhanced log daemon, supporting a wide range of input + and output methods: syslog, unstructured text, message queues, + databases (SQL and NoSQL alike) and more. + . + Key features: + . + * receive and send RFC3164 and RFC5424 style syslog messages + * work with any kind of unstructured data + * receive and send JSON formatted messages + * classify and structure logs with builtin parsers (csv-parser(), + db-parser(), etc.) + * normalize, crunch and process logs as they flow through the system + * hand on messages for further processing using message queues (like + AMQP), files or databases (like PostgreSQL or MongoDB). + . + This package provides the Redis destination plugin, which allows one + to issue Redis commands from within syslog-ng. + +Package: syslog-ng-mod-stomp +Architecture: any +Multi-Arch: foreign +Depends: ${shlibs:Depends}, ${misc:Depends} +Suggests: activemq +Description: Enhanced system logging daemon (STOMP plugin) + syslog-ng is an enhanced log daemon, supporting a wide range of input + and output methods: syslog, unstructured text, message queues, + databases (SQL and NoSQL alike) and more. + . + Key features: + . + * receive and send RFC3164 and RFC5424 style syslog messages + * work with any kind of unstructured data + * receive and send JSON formatted messages + * classify and structure logs with builtin parsers (csv-parser(), + db-parser(), etc.) + * normalize, crunch and process logs as they flow through the system + * hand on messages for further processing using message queues (like + AMQP), files or databases (like PostgreSQL or MongoDB). + . + This package provides the STOMP destination plugin, which allows one + to publish log messages through the STOMP protocol. + +Package: syslog-ng-mod-riemann +Architecture: any +Multi-Arch: foreign +Depends: ${shlibs:Depends}, ${misc:Depends} +Description: Enhanced system logging daemon (Riemann destination) + syslog-ng is an enhanced log daemon, supporting a wide range of input + and output methods: syslog, unstructured text, message queues, + databases (SQL and NoSQL alike) and more. + . + Key features: + . + * receive and send RFC3164 and RFC5424 style syslog messages + * work with any kind of unstructured data + * receive and send JSON formatted messages + * classify and structure logs with builtin parsers (csv-parser(), + db-parser(), etc.) + * normalize, crunch and process logs as they flow through the system + * hand on messages for further processing using message queues (like + AMQP), files or databases (like PostgreSQL or MongoDB). + . + This package provides the Riemann destination, allowing one to push + events to a Riemann server from within syslog-ng. + +Package: syslog-ng-mod-graphite +Architecture: any +Multi-Arch: foreign +Depends: ${shlibs:Depends}, ${misc:Depends} +Suggests: graphite-web +Description: Enhanced system logging daemon (graphite plugin) + syslog-ng is an enhanced log daemon, supporting a wide range of input + and output methods: syslog, unstructured text, message queues, + databases (SQL and NoSQL alike) and more. + . + Key features: + . + * receive and send RFC3164 and RFC5424 style syslog messages + * work with any kind of unstructured data + * receive and send JSON formatted messages + * classify and structure logs with builtin parsers (csv-parser(), + db-parser(), etc.) + * normalize, crunch and process logs as they flow through the system + * hand on messages for further processing using message queues (like + AMQP), files or databases (like PostgreSQL or MongoDB). + . + This package provides the graphite plugin, that adds a new template + function, $(graphite-output), which makes it possible to easily send + metrics to Graphite from within syslog-ng. + +Package: syslog-ng-mod-python +Architecture: any +Multi-Arch: foreign +Depends: ${shlibs:Depends}, ${misc:Depends}, ${python:Depends} +Description: Enhanced system logging daemon (Python plugin) + syslog-ng is an enhanced log daemon, supporting a wide range of input + and output methods: syslog, unstructured text, message queues, + databases (SQL and NoSQL alike) and more. + . + Key features: + . + * receive and send RFC3164 and RFC5424 style syslog messages + * work with any kind of unstructured data + * receive and send JSON formatted messages + * classify and structure logs with builtin parsers (csv-parser(), + db-parser(), etc.) + * normalize, crunch and process logs as they flow through the system + * hand on messages for further processing using message queues (like + AMQP), files or databases (like PostgreSQL or MongoDB). + . + This package provides the Python plugin, that allows one to write + syslog-ng plugins in Python. + +Package: syslog-ng-mod-add-contextual-data +Architecture: any +Multi-Arch: foreign +Depends: ${shlibs:Depends}, ${misc:Depends} +Description: Enhanced system logging daemon (add-contextual-data plugin) + syslog-ng is an enhanced log daemon, supporting a wide range of input + and output methods: syslog, unstructured text, message queues, + databases (SQL and NoSQL alike) and more. + . + Key features: + . + * receive and send RFC3164 and RFC5424 style syslog messages + * work with any kind of unstructured data + * receive and send JSON formatted messages + * classify and structure logs with builtin parsers (csv-parser(), + db-parser(), etc.) + * normalize, crunch and process logs as they flow through the system + * hand on messages for further processing using message queues (like + AMQP), files or databases (like PostgreSQL or MongoDB). + . + This package provides the add-contextual-data module for syslog-ng. + With this module syslog-ng can use an external database file to + append custom name-value pairs on incoming logs (to enrich messages). + The database is a file that containing `` records. + Currently only `CSV` format is supported. It is like `geoip parser` + where the selector is `$HOST`, but the user can define + the selector, and also the database contents. + +Package: syslog-ng-mod-getent +Architecture: any +Multi-Arch: foreign +Depends: ${shlibs:Depends}, ${misc:Depends} +Conflicts: syslog-ng-mod-basicfuncs-plus ( << 0.6.0) +Description: Enhanced system logging daemon (getent plugin) + syslog-ng is an enhanced log daemon, supporting a wide range of input + and output methods: syslog, unstructured text, message queues, + databases (SQL and NoSQL alike) and more. + . + Key features: + . + * receive and send RFC3164 and RFC5424 style syslog messages + * work with any kind of unstructured data + * receive and send JSON formatted messages + * classify and structure logs with builtin parsers (csv-parser(), + db-parser(), etc.) + * normalize, crunch and process logs as they flow through the system + * hand on messages for further processing using message queues (like + AMQP), files or databases (like PostgreSQL or MongoDB). + . + This package provides getent module which allows querying the Name Service + Switch library to convert UIDs to names, protocol names to port number and + much more. + +Package: syslog-ng-mod-stardate +Architecture: any +Multi-Arch: foreign +Depends: ${shlibs:Depends}, ${misc:Depends} +Description: Enhanced system logging daemon (stardate plugin) + syslog-ng is an enhanced log daemon, supporting a wide range of input + and output methods: syslog, unstructured text, message queues, + databases (SQL and NoSQL alike) and more. + . + Key features: + . + * receive and send RFC3164 and RFC5424 style syslog messages + * work with any kind of unstructured data + * receive and send JSON formatted messages + * classify and structure logs with builtin parsers (csv-parser(), + db-parser(), etc.) + * normalize, crunch and process logs as they flow through the system + * hand on messages for further processing using message queues (like + AMQP), files or databases (like PostgreSQL or MongoDB). + . + This package provides a stardate-like date formatting module which formats + the date with months and days as fragments of the year. For example, it + formats 2017.06.15 as something like 2017.500. + +Package: syslog-ng-mod-map-value-pairs +Architecture: any +Multi-Arch: foreign +Depends: ${shlibs:Depends}, ${misc:Depends} +Description: Enhanced system logging daemon (map-value-pairs plugin) + syslog-ng is an enhanced log daemon, supporting a wide range of input + and output methods: syslog, unstructured text, message queues, + databases (SQL and NoSQL alike) and more. + . + Key features: + . + * receive and send RFC3164 and RFC5424 style syslog messages + * work with any kind of unstructured data + * receive and send JSON formatted messages + * classify and structure logs with builtin parsers (csv-parser(), + db-parser(), etc.) + * normalize, crunch and process logs as they flow through the system + * hand on messages for further processing using message queues (like + AMQP), files or databases (like PostgreSQL or MongoDB). + . + With this package, it is possible to copy key-value pairs and do some other + conversion and alteration in key-value pairs. + +Package: syslog-ng-mod-snmptrapd-parser +Architecture: any +Multi-Arch: foreign +Depends: ${shlibs:Depends}, ${misc:Depends} +Description: Enhanced system logging daemon (snmptrapd-parser plugin) + syslog-ng is an enhanced log daemon, supporting a wide range of input + and output methods: syslog, unstructured text, message queues, + databases (SQL and NoSQL alike) and more. + . + Key features: + . + * receive and send RFC3164 and RFC5424 style syslog messages + * work with any kind of unstructured data + * receive and send JSON formatted messages + * classify and structure logs with builtin parsers (csv-parser(), + db-parser(), etc.) + * normalize, crunch and process logs as they flow through the system + * hand on messages for further processing using message queues (like + AMQP), files or databases (like PostgreSQL or MongoDB). + . + This parser module can parse SNMP trap messages and convert it to key-value + pairs. + +Package: syslog-ng-mod-geoip2 +Architecture: any +Multi-Arch: foreign +Depends: ${shlibs:Depends}, ${misc:Depends} +Description: Enhanced system logging daemon (GeoIP2 plugin) + syslog-ng is an enhanced log daemon, supporting a wide range of input + and output methods: syslog, unstructured text, message queues, + databases (SQL and NoSQL alike) and more. + . + Key features: + . + * receive and send RFC3164 and RFC5424 style syslog messages + * work with any kind of unstructured data + * receive and send JSON formatted messages + * classify and structure logs with builtin parsers (csv-parser(), + db-parser(), etc.) + * normalize, crunch and process logs as they flow through the system + * hand on messages for further processing using message queues (like + AMQP), files or databases (like PostgreSQL or MongoDB). + . + This package provides the GeoIP2 template function plugin, which + allows one to do non-DNS IP-to-country resolving from syslog-ng + templates. GeoIP2 uses MaxMind DB. + +Package: syslog-ng-mod-pacctformat +Architecture: any +Multi-Arch: foreign +Depends: ${shlibs:Depends}, ${misc:Depends} +Description: Enhanced system logging daemon (getent) + syslog-ng is an enhanced log daemon, supporting a wide range of input + and output methods: syslog, unstructured text, message queues, + databases (SQL and NoSQL alike) and more. + . + Key features: + . + * receive and send RFC3164 and RFC5424 style syslog messages + * work with any kind of unstructured data + * receive and send JSON formatted messages + * classify and structure logs with builtin parsers (csv-parser(), + db-parser(), etc.) + * normalize, crunch and process logs as they flow through the system + * hand on messages for further processing using message queues (like + AMQP), files or databases (like PostgreSQL or MongoDB). + . + This package provides the pacctformat module for syslog-ng. + +Package: syslog-ng-mod-java +Architecture: any +Multi-Arch: foreign +Depends: syslog-ng-core (= ${binary:Version}), default-jre +Recommends: syslog-ng-mod-java-common-lib +Description: Enhanced system logging daemon (Java destination) + syslog-ng is an enhanced log daemon, supporting a wide range of input + and output methods: syslog, unstructured text, message queues, + databases (SQL and NoSQL alike) and more. + . + Key features: + . + * receive and send RFC3164 and RFC5424 style syslog messages + * work with any kind of unstructured data + * receive and send JSON formatted messages + * classify and structure logs with builtin parsers (csv-parser(), + db-parser(), etc.) + * normalize, crunch and process logs as they flow through the system + * hand on messages for further processing using message queues (like + AMQP), files or databases (like PostgreSQL or MongoDB). + . + This package provides the Java destination, allowing one to write + destination drivers without having to touch C, in Java. + +Package: syslog-ng-mod-java-common-lib +Architecture: any +Multi-Arch: foreign +Depends: syslog-ng-core (= ${binary:Version}), syslog-ng-mod-java +Description: Enhanced system logging daemon (Java module common library) + syslog-ng is an enhanced log daemon, supporting a wide range of input + and output methods: syslog, unstructured text, message queues, + databases (SQL and NoSQL alike) and more. + . + Key features: + . + * receive and send RFC3164 and RFC5424 style syslog messages + * work with any kind of unstructured data + * receive and send JSON formatted messages + * classify and structure logs with builtin parsers (csv-parser(), + db-parser(), etc.) + * normalize, crunch and process logs as they flow through the system + * hand on messages for further processing using message queues (like + AMQP), files or databases (like PostgreSQL or MongoDB). + . + This package provides common libraries for simplifying the creation + of Java destinations. + +Package: syslog-ng-mod-elastic +Architecture: any +Multi-Arch: foreign +Depends: syslog-ng-core (= ${binary:Version}), syslog-ng-mod-java-common-lib, syslog-ng-mod-java +Description: Enhanced system logging daemon (Elasticsearch destination) + syslog-ng is an enhanced log daemon, supporting a wide range of input + and output methods: syslog, unstructured text, message queues, + databases (SQL and NoSQL alike) and more. + . + Key features: + . + * receive and send RFC3164 and RFC5424 style syslog messages + * work with any kind of unstructured data + * receive and send JSON formatted messages + * classify and structure logs with builtin parsers (csv-parser(), + db-parser(), etc.) + * normalize, crunch and process logs as they flow through the system + * hand on messages for further processing using message queues (like + AMQP), files or databases (like PostgreSQL or MongoDB). + . + This package provides the Elasticsearch destination, allowing one to + send syslog messages to Elasticsearch. + +Package: syslog-ng-mod-hdfs +Architecture: any +Multi-Arch: foreign +Depends: syslog-ng-core (= ${binary:Version}), syslog-ng-mod-java-common-lib, syslog-ng-mod-java +Description: Enhanced system logging daemon (HDFS destination) + syslog-ng is an enhanced log daemon, supporting a wide range of input + and output methods: syslog, unstructured text, message queues, + databases (SQL and NoSQL alike) and more. + . + Key features: + . + * receive and send RFC3164 and RFC5424 style syslog messages + * work with any kind of unstructured data + * receive and send JSON formatted messages + * classify and structure logs with builtin parsers (csv-parser(), + db-parser(), etc.) + * normalize, crunch and process logs as they flow through the system + * hand on messages for further processing using message queues (like + AMQP), files or databases (like PostgreSQL or MongoDB). + . + This package provides the HDFS destination, allowing one to send + messages to HDFS. + + +Package: syslog-ng-mod-kafka +Architecture: any +Multi-Arch: foreign +Depends: syslog-ng-core (= ${binary:Version}), syslog-ng-mod-java-common-lib, syslog-ng-mod-java +Description: Enhanced system logging daemon (Kafka destination) + syslog-ng is an enhanced log daemon, supporting a wide range of input + and output methods: syslog, unstructured text, message queues, + databases (SQL and NoSQL alike) and more. + . + Key features: + . + * receive and send RFC3164 and RFC5424 style syslog messages + * work with any kind of unstructured data + * receive and send JSON formatted messages + * classify and structure logs with builtin parsers (csv-parser(), + db-parser(), etc.) + * normalize, crunch and process logs as they flow through the system + * hand on messages for further processing using message queues (like + AMQP), files or databases (like PostgreSQL or MongoDB). + . + This package provides the Apache Kafka destination, allowing one to send + messages to Kafka. + +Package: syslog-ng-mod-java-http +Architecture: any +Multi-Arch: foreign +Depends: syslog-ng-core (= ${binary:Version}), syslog-ng-mod-java-common-lib, syslog-ng-mod-java +Description: Enhanced system logging daemon (HTTP destination implemented in Java) + syslog-ng is an enhanced log daemon, supporting a wide range of input + and output methods: syslog, unstructured text, message queues, + databases (SQL and NoSQL alike) and more. + . + Key features: + . + * receive and send RFC3164 and RFC5424 style syslog messages + * work with any kind of unstructured data + * receive and send JSON formatted messages + * classify and structure logs with builtin parsers (csv-parser(), + db-parser(), etc.) + * normalize, crunch and process logs as they flow through the system + * hand on messages for further processing using message queues (like + AMQP), files or databases (like PostgreSQL or MongoDB). + . + This package provides an HTTP destination, allowing one to send syslog messages as HTTP + PUT messages to an http server. + +Package: syslog-ng-mod-http +Architecture: any +Multi-Arch: foreign +Depends: ${shlibs:Depends}, ${misc:Depends} +Description: Enhanced system logging daemon (HTTP destination) + syslog-ng is an enhanced log daemon, supporting a wide range of input + and output methods: syslog, unstructured text, message queues, + databases (SQL and NoSQL alike) and more. + . + Key features: + . + * receive and send RFC3164 and RFC5424 style syslog messages + * work with any kind of unstructured data + * receive and send JSON formatted messages + * classify and structure logs with builtin parsers (csv-parser(), + db-parser(), etc.) + * normalize, crunch and process logs as they flow through the system + * hand on messages for further processing using message queues (like + AMQP), files or databases (like PostgreSQL or MongoDB). + . + This package provides an HTTP destination, allowing one to send syslog messages as HTTP + PUT messages to an http server. + +Package: syslog-ng-mod-json +Architecture: any +Multi-Arch: foreign +Depends: ${shlibs:Depends}, ${misc:Depends} +Description: Enhanced system logging daemon (HTTP destination) + syslog-ng is an enhanced log daemon, supporting a wide range of input + and output methods: syslog, unstructured text, message queues, + databases (SQL and NoSQL alike) and more. + . + Key features: + . + * receive and send RFC3164 and RFC5424 style syslog messages + * work with any kind of unstructured data + * receive and send JSON formatted messages + * classify and structure logs with builtin parsers (csv-parser(), + db-parser(), etc.) + * normalize, crunch and process logs as they flow through the system + * hand on messages for further processing using message queues (like + AMQP), files or databases (like PostgreSQL or MongoDB). + . + This package provides a transitional package for syslog-ng-mod-json which is + part of syslog-ng-core from 3.13.1 . + diff -Nru syslog-ng-3.11.1/packaging/debian/copyright syslog-ng-3.13.2/packaging/debian/copyright --- syslog-ng-3.11.1/packaging/debian/copyright 1970-01-01 00:00:00.000000000 +0000 +++ syslog-ng-3.13.2/packaging/debian/copyright 2017-12-06 06:39:39.000000000 +0000 @@ -0,0 +1,428 @@ +Format: http://www.debian.org/doc/packaging-manuals/copyright-format/1.0/ +Upstream-Name: syslog-ng +Upstream-Contact: Syslog-ng users' and developers' mailing list +Source: git://github.com/balabit/syslog-ng.git +Copyright: Copyright (C) Balázs Scheidler + Copyright (C) BalaBit IT Security Ltd. + +Files: * +Copyright: Copyright (C) Balázs Scheidler + Copyright (C) BalaBit IT Security Ltd. +License: GPL-2+ with OpenSSL exception + +Files: lib/* + libtest/* + syslog-ng/* + syslog-ng-ctl/* +Copyright: Copyright (C) Balázs Scheidler + Copyright (C) BalaBit IT Security Ltd. +License: LGPL-2.1+ with OpenSSL exception + +Files: lib/ack-tracker.h + lib/bookmark.h + lib/early_ack_tracker.c + lib/host-id.* + lib/late_ack_tracker.c + lib/ringbuffer.* + lib/template/common-template-typedefs.h +Copyright: Copyright (C) BalaBit IT Ltd. + Copyright (C) Laszlo Budai +License: LGPL-2.1+ with OpenSSL exception + +Files: lib/compat/time.h + lib/filter/filter-in-list.* + lib/logproto-indented-multiline-server.* + lib/logthrdestdrv.* + lib/scratch-buffers.* + lib/tests/test_cfg_tree.c + lib/type-hinting.* + lib/value-pairs.* + lib/vptransform.* + scl/graphite/* +Copyright: Copyright (C) BalaBit IT Security Ltd. + Copyright (C) Gergely Nagy +License: LGPL-2.1+ with OpenSSL exception + +Files: lib/pathutils.* + lib/persistable-state-presenter.* + lib/presented-persistable-state.h + lib/rcptid.* + lib/rewrite/rewrite-groupset.c + lib/run-id.* + lib/tests/test_rcptid.c + lib/tests/test_runid.c + libtest/config_parse_lib.* +Copyright: Copyright (C) BalaBit IT Security Ltd. + Copyright (C) Viktor Tusa + Copyright (C) Viktor Juhasz +License: LGPL-2.1+ with OpenSSL exception + +Files: lib/persistable-state-header.h +Copyright: Copyright (C) BalaBit IT Security Ltd. + Copyright (C) Viktor Tusa + Copyright (C) Viktor Juhasz + Copyright (C) Balázs Scheidler +License: LGPL-2.1+ with OpenSSL exception + +Files: lib/rewrite/rewrite-groupset.h + libtest/persist_lib.* +Copyright: Copyright (C) BalaBit IT Security Ltd. + Copyright (C) Viktor Tusa +License: LGPL-2.1+ with OpenSSL exception + +Files: lib/uuid.* +Copyright: Copyright (C) BalaBit IT Security Ltd. + Copyright (C) Balázs Scheidler + Copyright (C) Gergely Nagy +License: LGPL-2.1+ with OpenSSL exception + +Files: lib/cache.* + lib/compat/glib.h + lib/compat/inet_aton.c + lib/compat/lfs.h + lib/compat/pio.h + lib/compat/socket.h + lib/compat/string.h + lib/compat/strtok_r.c + lib/control/control-server.* + lib/control/control-server-unix.c + lib/hostname.h + lib/hostname-unix.c + lib/host-resolve.* + lib/reloc.* + lib/template/tests/test_template_compile.c + lib/tests/test_cache.c + lib/tests/test_cfg_lexer_subst.c + lib/tests/test_hostname.c + lib/tests/test_host_resolve.c + lib/tests/test_log_message.c + lib/tests/test_parse_number.c + lib/tests/test_reloc.c + lib/tests/test_type_hints.c + lib/thread-utils.h + lib/versioning.h + scl/nodejs/* +Copyright: Copyright (C) BalaBit IT Security Ltd. +License: LGPL-2.1+ with OpenSSL exception + +Files: lib/ivykis/* +Copyright: Copyright (C) Lennert Buytenhek +License: LGPL-2.1+ + +Files: lib/ivykis/lib/man3/* lib/ivykis/modules/man3/* +Copyright: Copyright (C) Lennert Buytenhek +License: ivykis-man + Permission is granted to distribute possibly modified copies + of this page provided the header is included verbatim, + and in case of nontrivial modification author and date + of the modification is added to the header. + +Files: lib/jsonc/* +Copyright: Copyright (C) Metaparadigm Pte. Ltd + Copyright (C) Eric Haszlakiewicz +License: Expat + +Files: lib/jsonc/debug.h + lib/jsonc/json.h + lib/jsonc/json_object.* + lib/jsonc/json_object_iterator.* + lib/jsonc/linkhash.* +Copyright: Copyright (C) Hewlett-Packard Development Company, L.P + Copyright (C) Metaparadigm Pte. Ltd + Copyright (C) Eric Haszlakiewicz +License: Expat + +Files: lib/jsonc/json_tokener.c + lib/jsonc/printbuf.* +Copyright: Copyright (C) Yahoo! Inc. + Copyright (C) Metaparadigm Pte. Ltd + Copyright (C) Eric Haszlakiewicz +License: Expat + +Files: modules/* +Copyright: Copyright (C) Balázs Scheidler + Copyright (C) BalaBit IT Security Ltd. +License: GPL-2+ with OpenSSL exception + +Files: modules/afamqp/* +Copyright: Copyright (C) BalaBit IT Security Ltd. + Copyright (C) Nagy, Attila + Copyright (C) Gergely Nagy +License: GPL-2+ with OpenSSL exception + +Files: modules/afamqp/rabbitmq-c/* +Copyright: Copyright (C) VMWare, Inc. and Tony Garnock-Jones +License: Expat + +Files: modules/afamqp/rabbitmq-c/codegen/* +Copyright: Copyright (C) VMWare, Inc. +License: MPL + +Files: modules/afamqp/rabbitmq-c/librabbitmq/win32/msinttypes/stdint.h + modules/afamqp/rabbitmq-c/tests/win32/msinttypes/inttypes.h +Copyright: Copyright (C) Alexander Chemeris +License: BSD-3-clause + +Files: modules/afmongodb/* + modules/afsmtp/* + modules/afsocket/unix-credentials.* + modules/json/json-parser.* + modules/json/json-parser-parser.* + modules/json/json-plugin.* + modules/json/tests/test_format_json.c + modules/linux-kmsg-format/* + modules/kvformat/tests/test_format_welf.c + modules/python/python-dest.* + modules/python/python-parser.* + modules/python/python-plugin.c + modules/python/python-value-pairs.* + modules/riemann/* + modules/system-source/* +Copyright: Copyright (c) BalaBit IT Ltd. + Copyright (C) Gergely Nagy +License: GPL-2+ with OpenSSL exception + +Files: modules/afmongodb/libmongo-client/* +Copyright: Copyright (C) Gergely Nagy +License: Apache-2.0 + +Files: modules/afsocket/systemd-syslog-source.* +Copyright: Copyright (C) BalaBit IT Ltd. + Copyright (C) Tibor Benke + Copyright (C) Balázs Scheidler +License: GPL-2+ with OpenSSL exception + +Files: modules/afsocket/transport-unix-socket.c + modules/basicfuncs/cond-funcs.c +Copyright: Copyright (C) BalaBit IT Ltd. + Copyright (C) Gergely Nagy + Copyright (C) Balázs Scheidler +License: GPL-2+ with OpenSSL exception + +Files: modules/afstomp/* +Copyright: Copyright (C) Nagy, Attila + Copyright (C) BalaBit IT Ltd. + Copyright (C) Viktor Tusa +License: GPL-2+ with OpenSSL exception + +Files: modules/afstomp/stomp.* +Copyright: Copyright (C) Viktor Tusa +License: GPL-2+ with OpenSSL exception + +Files: modules/basicfuncs/str-funcs.c +Copyright: Copyright (C) BalaBit IT Ltd. + Copyright (C) Viktor Tusa + Copyright (C) Balázs Scheidler +License: GPL-2+ with OpenSSL exception + +Files: modules/redis/* +Copyright: Copyright (C) Tihamer Petrovics + Copyright (C) BalaBit IT Ltd. +License: GPL-2+ with OpenSSL exception + +Files: modules/cryptofuncs/* +Copyright: Copyright (c) BalaBit IT Ltd. + Copyright (C) Gergely Nagy + Copyright (C) Peter Gyongyosi +License: GPL-2+ with OpenSSL exception + +Files: modules/dbparser/patternize.* +Copyright: Copyright (C) Péter Gyöngyösi + Copyright (C) BalaBit IT Security Ltd. +License: GPL-2+ with OpenSSL exception + +Files: modules/geoip/* + scl/* +Copyright: Copyright (C) BalaBit IT Security Ltd. +License: GPL-2+ with OpenSSL exception + +Files: modules/geoip/geoip-parser.* + modules/geoip/geoip-parser-parser.* + modules/geoip/geoip-plugin.c +Copyright: Copyright (C) Gergely Nagy +License: GPL-2+ with OpenSSL exception + +Files: modules/graphite/* +Copyright: Copyright (C) BalaBit IT Ltd. + Copyright (C) Viktor Tusa +License: GPL-2+ with OpenSSL exception + +Files: modules/java-modules/http/src/main/java/org/syslog_ng/http/HTTPDestinationOptions.java +Copyright: Copyright (C) BalaBit IT Security Ltd. + Copyright (C) Adam Arsenault + Copyright (C) Viktor Juhasz +License: GPL-2+ with OpenSSL exception + +Files: modules/json/format-json.c +Copyright: Copyright (c) BalaBit IT Ltd. + Copyright (C) Balint Kovacs + Copyright (C) Gergely Nagy +License: GPL-2+ with OpenSSL exception + +Files: modules/systemd-journal/* + modules/java-modules/* + modules/java/* +Copyright: Copyright (C) BalaBit IT Security Ltd. + Copyright (C) Viktor Juhasz +License: GPL-2+ with OpenSSL exception + +Files: modules/kvformat/* +Copyright: Copyright (C) BalaBit IT Security Ltd. +License: GPL-2+ with OpenSSL exception + +Files: scl/syslogconf/convert-syslogconf.awk +Copyright: Jonathan W. Marks +License: GPL-2+ with OpenSSL exception + +Files: scl/rewrite/cc-mask.conf +Copyright: Copyright (C) Márton Illés +License: GPL-2+ with OpenSSL exception + +Files: debian/* +Copyright: Copyright (C) 2011-2015 Gergely Nagy , + Copyright (C) 2010-2012 Laszlo Boszormenyi (GCS) +License: GPL-2+ + +License: GPL-2+ + This program is free software; you can redistribute it and/or modify it + under the terms of the GNU General Public License version 2 as published + by the Free Software Foundation, or (at your option) any later version. + . + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + . + You should have received a copy of the GNU Lesser General Public + License along with this library; if not, write to the Free Software + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + . + On Debian systems, the complete text of the GNU General Public + License can be found in the file `/usr/share/common-licenses/GPL-2'. + +License: GPL-2+ with OpenSSL exception + This program is free software; you can redistribute it and/or modify it + under the terms of the GNU General Public License version 2 as published + by the Free Software Foundation, or (at your option) any later version. + . + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + . + You should have received a copy of the GNU Lesser General Public + License along with this library; if not, write to the Free Software + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + . + As an additional exemption you are allowed to compile & link against the + OpenSSL libraries as published by the OpenSSL project. See the file + COPYING for details. + . + On Debian systems, the complete text of the GNU General Public + License can be found in the file `/usr/share/common-licenses/GPL-2'. + +License: LGPL-2.1+ + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + . + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + . + You should have received a copy of the GNU Lesser General Public + License along with this library; if not, write to the Free Software + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + . + On Debian systems, the complete text of the GNU Lesser General Public + License can be found in the file `/usr/share/common-licenses/LGPL-2.1'. + +License: LGPL-2.1+ with OpenSSL exception + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + . + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + . + You should have received a copy of the GNU Lesser General Public + License along with this library; if not, write to the Free Software + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + . + As an additional exemption you are allowed to compile & link against the + OpenSSL libraries as published by the OpenSSL project. See the file + COPYING for details. + . + On Debian systems, the complete text of the GNU Lesser General Public + License can be found in the file `/usr/share/common-licenses/LGPL-2.1'. + +License: Apache-2.0 + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + . + http://www.apache.org/licenses/LICENSE-2.0 + . + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. + . + On Debian systems, the complete text of the Apache License can be found in + the file `/usr/share/common-licenses/Apache-2.0'. + +License: Expat + Permission is hereby granted, free of charge, to any person + obtaining a copy of this software and associated documentation + files (the "Software"), to deal in the Software without + restriction, including without limitation the rights to use, copy, + modify, merge, publish, distribute, sublicense, and/or sell copies + of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + . + The above copyright notice and this permission notice shall be + included in all copies or substantial portions of the Software. + . + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, + EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF + MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND + NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS + BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN + ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN + CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + SOFTWARE. + +License: MPL + The complete text of the Mozilla Public License can be found in + the `MPL' file in the same directory as this file. + +License: BSD-3-clause + Redistribution and use in source and binary forms, with or without + modification, are permitted provided that the following conditions are met: + . + 1. Redistributions of source code must retain the above copyright notice, + this list of conditions and the following disclaimer. + . + 2. Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in the + documentation and/or other materials provided with the distribution. + . + 3. The name of the author may be used to endorse or promote products + derived from this software without specific prior written permission. + . + THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED + WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF + MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO + EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; + OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, + WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR + OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF + ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. diff -Nru syslog-ng-3.11.1/packaging/debian/gbp.conf syslog-ng-3.13.2/packaging/debian/gbp.conf --- syslog-ng-3.11.1/packaging/debian/gbp.conf 1970-01-01 00:00:00.000000000 +0000 +++ syslog-ng-3.13.2/packaging/debian/gbp.conf 2017-12-06 06:39:39.000000000 +0000 @@ -0,0 +1,14 @@ +[DEFAULT] +debian-branch = debian/unstable +debian-tag = debian/syslog-ng-%(version)s +upstream-branch = upstream/3.10.x + +overlay = True + +[buildpackage] +export-dir = ../build-area/ +tarball-dir = ../ + +[import-orig] +filter = .git +filter = debian/* diff -Nru syslog-ng-3.11.1/packaging/debian/Makefile.am syslog-ng-3.13.2/packaging/debian/Makefile.am --- syslog-ng-3.11.1/packaging/debian/Makefile.am 1970-01-01 00:00:00.000000000 +0000 +++ syslog-ng-3.13.2/packaging/debian/Makefile.am 2017-12-06 06:39:39.000000000 +0000 @@ -0,0 +1,72 @@ +EXTRA_DIST += \ + packaging/debian/syslog-ng-mod-java.install \ + packaging/debian/syslog-ng-mod-mongodb.preinst \ + packaging/debian/syslog-ng-mod-common.maintscript \ + packaging/debian/syslog-ng-mod-kafka.install \ + packaging/debian/syslog-ng-mod-http.install \ + packaging/debian/syslog-ng-mod-java-http.install \ + packaging/debian/syslog-ng-mod-elastic.install \ + packaging/debian/syslog-ng-mod-mongodb.postinst \ + packaging/debian/syslog-ng-mod-geoip.install \ + packaging/debian/watch \ + packaging/debian/syslog-ng-mod-sql.preinst \ + packaging/debian/syslog-ng-core.syslog-ng.logcheck.ignore.paranoid \ + packaging/debian/syslog-ng-core.postrm \ + packaging/debian/tools \ + packaging/debian/tools/list-modules.sh \ + packaging/debian/changelog \ + packaging/debian/syslog-ng-mod-amqp.install \ + packaging/debian/syslog-ng-dev.install \ + packaging/debian/syslog-ng-mod-sql.postrm \ + packaging/debian/syslog-ng.conf \ + packaging/debian/syslog-ng-core.syslog-ng.init \ + packaging/debian/syslog-ng-mod-java-common-lib.install \ + packaging/debian/tty10.linux.conf \ + packaging/debian/syslog-ng-mod-sql.postinst \ + packaging/debian/scl.conf \ + packaging/debian/syslog-ng-core.syslog-ng.logrotate \ + packaging/debian/syslog-ng-mod-smtp.install \ + packaging/debian/syslog-ng-core.prerm \ + packaging/debian/syslog-ng-core.install \ + packaging/debian/syslog-ng-core.manpages \ + packaging/debian/rules \ + packaging/debian/syslog-ng-mod-hdfs.install \ + packaging/debian/man \ + packaging/debian/man/update-patterndb.1 \ + packaging/debian/syslog-ng-core.syslog-ng.logcheck.ignore.server \ + packaging/debian/syslog-ng-mod-python.install \ + packaging/debian/README.source \ + packaging/debian/syslog-ng-mod-mongodb.install \ + packaging/debian/syslog-ng-core.syslog-ng.default \ + packaging/debian/syslog-ng-mod-stomp.install \ + packaging/debian/syslog-ng-mod-mongodb.postrm \ + packaging/debian/gbp.conf \ + packaging/debian/syslog-ng-mod-riemann.install \ + packaging/debian/syslog-ng-mod-redis.install \ + packaging/debian/syslog-ng-core.syslog-ng.logcheck.violations.ignore \ + packaging/debian/syslog-ng-mod-sql.install \ + packaging/debian/control \ + packaging/debian/syslog-ng-mod-http.install \ + packaging/debian/tty10.kfreebsd.conf \ + packaging/debian/source \ + packaging/debian/source/patch-header \ + packaging/debian/source/format \ + packaging/debian/source/options \ + packaging/debian/compat \ + packaging/debian/syslog-ng-core.preinst \ + packaging/debian/syslog-ng-core.dirs \ + packaging/debian/syslog-ng-core.syslog-ng.upstart \ + packaging/debian/syslog-ng-mod-graphite.install \ + packaging/debian/syslog-ng-mod-add-contextual-data.install \ + packaging/debian/syslog-ng-mod-getent.install \ + packaging/debian/syslog-ng-mod-stardate.install \ + packaging/debian/syslog-ng-mod-map-value-pairs.install \ + packaging/debian/syslog-ng-mod-pacctformat.install \ + packaging/debian/syslog-ng-mod-snmptrapd-parser.install \ + packaging/debian/syslog-ng-mod-geoip2.install \ + packaging/debian/syslog-ng-mod-java-http.install \ + packaging/debian/syslog-ng.systemd + + + +MAINTAINERCLEANFILES = packaging/debian/control packaging/debian/rules packaging/debian/changelog diff -Nru syslog-ng-3.11.1/packaging/debian/man/update-patterndb.1 syslog-ng-3.13.2/packaging/debian/man/update-patterndb.1 --- syslog-ng-3.11.1/packaging/debian/man/update-patterndb.1 1970-01-01 00:00:00.000000000 +0000 +++ syslog-ng-3.13.2/packaging/debian/man/update-patterndb.1 2017-12-06 06:39:39.000000000 +0000 @@ -0,0 +1,31 @@ +.TH "UPDATE\-PATTERNDB" "1" "September 2011" "syslog-ng" "syslog-ng manual" +.SH "NAME" +update\-patterndb \- Merge patterndb files into a single database. +.SH "SYNOPSIS" +\fBupdate\-patterndb\fR +.SH "DESCRIPTION" +.PP +This program can be used to merge the various patterndb files under +\fI/etc/syslog\-ng/patterndb.d\fR into a system\-wide patterndb file, +\fI/var/lib/syslog\-ng/patterndb.xml\fR. + +It is a thin wrapper around +.BR pdbtool "(1)'s merge command." +.SH "SEE ALSO" +.BR pdbtool (1) + +For the full documentation of \fBsyslog-ng\fR, see \fBThe syslog-ng +Administrator Guide\fR, available from +.IP +.B http://www.balabit.com/support/documentation/ +.PP +.SH "AUTHOR" +.PP +This manual page was written by Gergely Nagy +. +.SH "COPYRIGHT" +.PP +Copyright \(co 2011 Gergely Nagy +. Published under the GNU General +Public License version 3, or at your opinion, any later version as +published by the FSF. diff -Nru syslog-ng-3.11.1/packaging/debian/MPL syslog-ng-3.13.2/packaging/debian/MPL --- syslog-ng-3.11.1/packaging/debian/MPL 1970-01-01 00:00:00.000000000 +0000 +++ syslog-ng-3.13.2/packaging/debian/MPL 2017-12-06 06:39:39.000000000 +0000 @@ -0,0 +1,470 @@ + MOZILLA PUBLIC LICENSE + Version 1.1 + + --------------- + +1. Definitions. + + 1.0.1. "Commercial Use" means distribution or otherwise making the + Covered Code available to a third party. + + 1.1. "Contributor" means each entity that creates or contributes to + the creation of Modifications. + + 1.2. "Contributor Version" means the combination of the Original + Code, prior Modifications used by a Contributor, and the Modifications + made by that particular Contributor. + + 1.3. "Covered Code" means the Original Code or Modifications or the + combination of the Original Code and Modifications, in each case + including portions thereof. + + 1.4. "Electronic Distribution Mechanism" means a mechanism generally + accepted in the software development community for the electronic + transfer of data. + + 1.5. "Executable" means Covered Code in any form other than Source + Code. + + 1.6. "Initial Developer" means the individual or entity identified + as the Initial Developer in the Source Code notice required by Exhibit + A. + + 1.7. "Larger Work" means a work which combines Covered Code or + portions thereof with code not governed by the terms of this License. + + 1.8. "License" means this document. + + 1.8.1. "Licensable" means having the right to grant, to the maximum + extent possible, whether at the time of the initial grant or + subsequently acquired, any and all of the rights conveyed herein. + + 1.9. "Modifications" means any addition to or deletion from the + substance or structure of either the Original Code or any previous + Modifications. When Covered Code is released as a series of files, a + Modification is: + A. Any addition to or deletion from the contents of a file + containing Original Code or previous Modifications. + + B. Any new file that contains any part of the Original Code or + previous Modifications. + + 1.10. "Original Code" means Source Code of computer software code + which is described in the Source Code notice required by Exhibit A as + Original Code, and which, at the time of its release under this + License is not already Covered Code governed by this License. + + 1.10.1. "Patent Claims" means any patent claim(s), now owned or + hereafter acquired, including without limitation, method, process, + and apparatus claims, in any patent Licensable by grantor. + + 1.11. "Source Code" means the preferred form of the Covered Code for + making modifications to it, including all modules it contains, plus + any associated interface definition files, scripts used to control + compilation and installation of an Executable, or source code + differential comparisons against either the Original Code or another + well known, available Covered Code of the Contributor's choice. The + Source Code can be in a compressed or archival form, provided the + appropriate decompression or de-archiving software is widely available + for no charge. + + 1.12. "You" (or "Your") means an individual or a legal entity + exercising rights under, and complying with all of the terms of, this + License or a future version of this License issued under Section 6.1. + For legal entities, "You" includes any entity which controls, is + controlled by, or is under common control with You. For purposes of + this definition, "control" means (a) the power, direct or indirect, + to cause the direction or management of such entity, whether by + contract or otherwise, or (b) ownership of more than fifty percent + (50%) of the outstanding shares or beneficial ownership of such + entity. + +2. Source Code License. + + 2.1. The Initial Developer Grant. + The Initial Developer hereby grants You a world-wide, royalty-free, + non-exclusive license, subject to third party intellectual property + claims: + (a) under intellectual property rights (other than patent or + trademark) Licensable by Initial Developer to use, reproduce, + modify, display, perform, sublicense and distribute the Original + Code (or portions thereof) with or without Modifications, and/or + as part of a Larger Work; and + + (b) under Patents Claims infringed by the making, using or + selling of Original Code, to make, have made, use, practice, + sell, and offer for sale, and/or otherwise dispose of the + Original Code (or portions thereof). + + (c) the licenses granted in this Section 2.1(a) and (b) are + effective on the date Initial Developer first distributes + Original Code under the terms of this License. + + (d) Notwithstanding Section 2.1(b) above, no patent license is + granted: 1) for code that You delete from the Original Code; 2) + separate from the Original Code; or 3) for infringements caused + by: i) the modification of the Original Code or ii) the + combination of the Original Code with other software or devices. + + 2.2. Contributor Grant. + Subject to third party intellectual property claims, each Contributor + hereby grants You a world-wide, royalty-free, non-exclusive license + + (a) under intellectual property rights (other than patent or + trademark) Licensable by Contributor, to use, reproduce, modify, + display, perform, sublicense and distribute the Modifications + created by such Contributor (or portions thereof) either on an + unmodified basis, with other Modifications, as Covered Code + and/or as part of a Larger Work; and + + (b) under Patent Claims infringed by the making, using, or + selling of Modifications made by that Contributor either alone + and/or in combination with its Contributor Version (or portions + of such combination), to make, use, sell, offer for sale, have + made, and/or otherwise dispose of: 1) Modifications made by that + Contributor (or portions thereof); and 2) the combination of + Modifications made by that Contributor with its Contributor + Version (or portions of such combination). + + (c) the licenses granted in Sections 2.2(a) and 2.2(b) are + effective on the date Contributor first makes Commercial Use of + the Covered Code. + + (d) Notwithstanding Section 2.2(b) above, no patent license is + granted: 1) for any code that Contributor has deleted from the + Contributor Version; 2) separate from the Contributor Version; + 3) for infringements caused by: i) third party modifications of + Contributor Version or ii) the combination of Modifications made + by that Contributor with other software (except as part of the + Contributor Version) or other devices; or 4) under Patent Claims + infringed by Covered Code in the absence of Modifications made by + that Contributor. + +3. Distribution Obligations. + + 3.1. Application of License. + The Modifications which You create or to which You contribute are + governed by the terms of this License, including without limitation + Section 2.2. The Source Code version of Covered Code may be + distributed only under the terms of this License or a future version + of this License released under Section 6.1, and You must include a + copy of this License with every copy of the Source Code You + distribute. You may not offer or impose any terms on any Source Code + version that alters or restricts the applicable version of this + License or the recipients' rights hereunder. However, You may include + an additional document offering the additional rights described in + Section 3.5. + + 3.2. Availability of Source Code. + Any Modification which You create or to which You contribute must be + made available in Source Code form under the terms of this License + either on the same media as an Executable version or via an accepted + Electronic Distribution Mechanism to anyone to whom you made an + Executable version available; and if made available via Electronic + Distribution Mechanism, must remain available for at least twelve (12) + months after the date it initially became available, or at least six + (6) months after a subsequent version of that particular Modification + has been made available to such recipients. You are responsible for + ensuring that the Source Code version remains available even if the + Electronic Distribution Mechanism is maintained by a third party. + + 3.3. Description of Modifications. + You must cause all Covered Code to which You contribute to contain a + file documenting the changes You made to create that Covered Code and + the date of any change. You must include a prominent statement that + the Modification is derived, directly or indirectly, from Original + Code provided by the Initial Developer and including the name of the + Initial Developer in (a) the Source Code, and (b) in any notice in an + Executable version or related documentation in which You describe the + origin or ownership of the Covered Code. + + 3.4. Intellectual Property Matters + (a) Third Party Claims. + If Contributor has knowledge that a license under a third party's + intellectual property rights is required to exercise the rights + granted by such Contributor under Sections 2.1 or 2.2, + Contributor must include a text file with the Source Code + distribution titled "LEGAL" which describes the claim and the + party making the claim in sufficient detail that a recipient will + know whom to contact. If Contributor obtains such knowledge after + the Modification is made available as described in Section 3.2, + Contributor shall promptly modify the LEGAL file in all copies + Contributor makes available thereafter and shall take other steps + (such as notifying appropriate mailing lists or newsgroups) + reasonably calculated to inform those who received the Covered + Code that new knowledge has been obtained. + + (b) Contributor APIs. + If Contributor's Modifications include an application programming + interface and Contributor has knowledge of patent licenses which + are reasonably necessary to implement that API, Contributor must + also include this information in the LEGAL file. + + (c) Representations. + Contributor represents that, except as disclosed pursuant to + Section 3.4(a) above, Contributor believes that Contributor's + Modifications are Contributor's original creation(s) and/or + Contributor has sufficient rights to grant the rights conveyed by + this License. + + 3.5. Required Notices. + You must duplicate the notice in Exhibit A in each file of the Source + Code. If it is not possible to put such notice in a particular Source + Code file due to its structure, then You must include such notice in a + location (such as a relevant directory) where a user would be likely + to look for such a notice. If You created one or more Modification(s) + You may add your name as a Contributor to the notice described in + Exhibit A. You must also duplicate this License in any documentation + for the Source Code where You describe recipients' rights or ownership + rights relating to Covered Code. You may choose to offer, and to + charge a fee for, warranty, support, indemnity or liability + obligations to one or more recipients of Covered Code. However, You + may do so only on Your own behalf, and not on behalf of the Initial + Developer or any Contributor. You must make it absolutely clear than + any such warranty, support, indemnity or liability obligation is + offered by You alone, and You hereby agree to indemnify the Initial + Developer and every Contributor for any liability incurred by the + Initial Developer or such Contributor as a result of warranty, + support, indemnity or liability terms You offer. + + 3.6. Distribution of Executable Versions. + You may distribute Covered Code in Executable form only if the + requirements of Section 3.1-3.5 have been met for that Covered Code, + and if You include a notice stating that the Source Code version of + the Covered Code is available under the terms of this License, + including a description of how and where You have fulfilled the + obligations of Section 3.2. The notice must be conspicuously included + in any notice in an Executable version, related documentation or + collateral in which You describe recipients' rights relating to the + Covered Code. You may distribute the Executable version of Covered + Code or ownership rights under a license of Your choice, which may + contain terms different from this License, provided that You are in + compliance with the terms of this License and that the license for the + Executable version does not attempt to limit or alter the recipient's + rights in the Source Code version from the rights set forth in this + License. If You distribute the Executable version under a different + license You must make it absolutely clear that any terms which differ + from this License are offered by You alone, not by the Initial + Developer or any Contributor. You hereby agree to indemnify the + Initial Developer and every Contributor for any liability incurred by + the Initial Developer or such Contributor as a result of any such + terms You offer. + + 3.7. Larger Works. + You may create a Larger Work by combining Covered Code with other code + not governed by the terms of this License and distribute the Larger + Work as a single product. In such a case, You must make sure the + requirements of this License are fulfilled for the Covered Code. + +4. Inability to Comply Due to Statute or Regulation. + + If it is impossible for You to comply with any of the terms of this + License with respect to some or all of the Covered Code due to + statute, judicial order, or regulation then You must: (a) comply with + the terms of this License to the maximum extent possible; and (b) + describe the limitations and the code they affect. Such description + must be included in the LEGAL file described in Section 3.4 and must + be included with all distributions of the Source Code. Except to the + extent prohibited by statute or regulation, such description must be + sufficiently detailed for a recipient of ordinary skill to be able to + understand it. + +5. Application of this License. + + This License applies to code to which the Initial Developer has + attached the notice in Exhibit A and to related Covered Code. + +6. Versions of the License. + + 6.1. New Versions. + Netscape Communications Corporation ("Netscape") may publish revised + and/or new versions of the License from time to time. Each version + will be given a distinguishing version number. + + 6.2. Effect of New Versions. + Once Covered Code has been published under a particular version of the + License, You may always continue to use it under the terms of that + version. You may also choose to use such Covered Code under the terms + of any subsequent version of the License published by Netscape. No one + other than Netscape has the right to modify the terms applicable to + Covered Code created under this License. + + 6.3. Derivative Works. + If You create or use a modified version of this License (which you may + only do in order to apply it to code which is not already Covered Code + governed by this License), You must (a) rename Your license so that + the phrases "Mozilla", "MOZILLAPL", "MOZPL", "Netscape", + "MPL", "NPL" or any confusingly similar phrase do not appear in your + license (except to note that your license differs from this License) + and (b) otherwise make it clear that Your version of the license + contains terms which differ from the Mozilla Public License and + Netscape Public License. (Filling in the name of the Initial + Developer, Original Code or Contributor in the notice described in + Exhibit A shall not of themselves be deemed to be modifications of + this License.) + +7. DISCLAIMER OF WARRANTY. + + COVERED CODE IS PROVIDED UNDER THIS LICENSE ON AN "AS IS" BASIS, + WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, + WITHOUT LIMITATION, WARRANTIES THAT THE COVERED CODE IS FREE OF + DEFECTS, MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE OR NON-INFRINGING. + THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE COVERED CODE + IS WITH YOU. SHOULD ANY COVERED CODE PROVE DEFECTIVE IN ANY RESPECT, + YOU (NOT THE INITIAL DEVELOPER OR ANY OTHER CONTRIBUTOR) ASSUME THE + COST OF ANY NECESSARY SERVICING, REPAIR OR CORRECTION. THIS DISCLAIMER + OF WARRANTY CONSTITUTES AN ESSENTIAL PART OF THIS LICENSE. NO USE OF + ANY COVERED CODE IS AUTHORIZED HEREUNDER EXCEPT UNDER THIS DISCLAIMER. + +8. TERMINATION. + + 8.1. This License and the rights granted hereunder will terminate + automatically if You fail to comply with terms herein and fail to cure + such breach within 30 days of becoming aware of the breach. All + sublicenses to the Covered Code which are properly granted shall + survive any termination of this License. Provisions which, by their + nature, must remain in effect beyond the termination of this License + shall survive. + + 8.2. If You initiate litigation by asserting a patent infringement + claim (excluding declatory judgment actions) against Initial Developer + or a Contributor (the Initial Developer or Contributor against whom + You file such action is referred to as "Participant") alleging that: + + (a) such Participant's Contributor Version directly or indirectly + infringes any patent, then any and all rights granted by such + Participant to You under Sections 2.1 and/or 2.2 of this License + shall, upon 60 days notice from Participant terminate prospectively, + unless if within 60 days after receipt of notice You either: (i) + agree in writing to pay Participant a mutually agreeable reasonable + royalty for Your past and future use of Modifications made by such + Participant, or (ii) withdraw Your litigation claim with respect to + the Contributor Version against such Participant. If within 60 days + of notice, a reasonable royalty and payment arrangement are not + mutually agreed upon in writing by the parties or the litigation claim + is not withdrawn, the rights granted by Participant to You under + Sections 2.1 and/or 2.2 automatically terminate at the expiration of + the 60 day notice period specified above. + + (b) any software, hardware, or device, other than such Participant's + Contributor Version, directly or indirectly infringes any patent, then + any rights granted to You by such Participant under Sections 2.1(b) + and 2.2(b) are revoked effective as of the date You first made, used, + sold, distributed, or had made, Modifications made by that + Participant. + + 8.3. If You assert a patent infringement claim against Participant + alleging that such Participant's Contributor Version directly or + indirectly infringes any patent where such claim is resolved (such as + by license or settlement) prior to the initiation of patent + infringement litigation, then the reasonable value of the licenses + granted by such Participant under Sections 2.1 or 2.2 shall be taken + into account in determining the amount or value of any payment or + license. + + 8.4. In the event of termination under Sections 8.1 or 8.2 above, + all end user license agreements (excluding distributors and resellers) + which have been validly granted by You or any distributor hereunder + prior to termination shall survive termination. + +9. LIMITATION OF LIABILITY. + + UNDER NO CIRCUMSTANCES AND UNDER NO LEGAL THEORY, WHETHER TORT + (INCLUDING NEGLIGENCE), CONTRACT, OR OTHERWISE, SHALL YOU, THE INITIAL + DEVELOPER, ANY OTHER CONTRIBUTOR, OR ANY DISTRIBUTOR OF COVERED CODE, + OR ANY SUPPLIER OF ANY OF SUCH PARTIES, BE LIABLE TO ANY PERSON FOR + ANY INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES OF ANY + CHARACTER INCLUDING, WITHOUT LIMITATION, DAMAGES FOR LOSS OF GOODWILL, + WORK STOPPAGE, COMPUTER FAILURE OR MALFUNCTION, OR ANY AND ALL OTHER + COMMERCIAL DAMAGES OR LOSSES, EVEN IF SUCH PARTY SHALL HAVE BEEN + INFORMED OF THE POSSIBILITY OF SUCH DAMAGES. THIS LIMITATION OF + LIABILITY SHALL NOT APPLY TO LIABILITY FOR DEATH OR PERSONAL INJURY + RESULTING FROM SUCH PARTY'S NEGLIGENCE TO THE EXTENT APPLICABLE LAW + PROHIBITS SUCH LIMITATION. SOME JURISDICTIONS DO NOT ALLOW THE + EXCLUSION OR LIMITATION OF INCIDENTAL OR CONSEQUENTIAL DAMAGES, SO + THIS EXCLUSION AND LIMITATION MAY NOT APPLY TO YOU. + +10. U.S. GOVERNMENT END USERS. + + The Covered Code is a "commercial item," as that term is defined in + 48 C.F.R. 2.101 (Oct. 1995), consisting of "commercial computer + software" and "commercial computer software documentation," as such + terms are used in 48 C.F.R. 12.212 (Sept. 1995). Consistent with 48 + C.F.R. 12.212 and 48 C.F.R. 227.7202-1 through 227.7202-4 (June 1995), + all U.S. Government End Users acquire Covered Code with only those + rights set forth herein. + +11. MISCELLANEOUS. + + This License represents the complete agreement concerning subject + matter hereof. If any provision of this License is held to be + unenforceable, such provision shall be reformed only to the extent + necessary to make it enforceable. This License shall be governed by + California law provisions (except to the extent applicable law, if + any, provides otherwise), excluding its conflict-of-law provisions. + With respect to disputes in which at least one party is a citizen of, + or an entity chartered or registered to do business in the United + States of America, any litigation relating to this License shall be + subject to the jurisdiction of the Federal Courts of the Northern + District of California, with venue lying in Santa Clara County, + California, with the losing party responsible for costs, including + without limitation, court costs and reasonable attorneys' fees and + expenses. The application of the United Nations Convention on + Contracts for the International Sale of Goods is expressly excluded. + Any law or regulation which provides that the language of a contract + shall be construed against the drafter shall not apply to this + License. + +12. RESPONSIBILITY FOR CLAIMS. + + As between Initial Developer and the Contributors, each party is + responsible for claims and damages arising, directly or indirectly, + out of its utilization of rights under this License and You agree to + work with Initial Developer and Contributors to distribute such + responsibility on an equitable basis. Nothing herein is intended or + shall be deemed to constitute any admission of liability. + +13. MULTIPLE-LICENSED CODE. + + Initial Developer may designate portions of the Covered Code as + "Multiple-Licensed". "Multiple-Licensed" means that the Initial + Developer permits you to utilize portions of the Covered Code under + Your choice of the NPL or the alternative licenses, if any, specified + by the Initial Developer in the file described in Exhibit A. + +EXHIBIT A -Mozilla Public License. + + ``The contents of this file are subject to the Mozilla Public License + Version 1.1 (the "License"); you may not use this file except in + compliance with the License. You may obtain a copy of the License at + http://www.mozilla.org/MPL/ + + Software distributed under the License is distributed on an "AS IS" + basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the + License for the specific language governing rights and limitations + under the License. + + The Original Code is ______________________________________. + + The Initial Developer of the Original Code is ________________________. + Portions created by ______________________ are Copyright (C) ______ + _______________________. All Rights Reserved. + + Contributor(s): ______________________________________. + + Alternatively, the contents of this file may be used under the terms + of the _____ license (the "[___] License"), in which case the + provisions of [______] License are applicable instead of those + above. If you wish to allow use of your version of this file only + under the terms of the [____] License and not to allow others to use + your version of this file under the MPL, indicate your decision by + deleting the provisions above and replace them with the notice and + other provisions required by the [___] License. If you do not delete + the provisions above, a recipient may use your version of this file + under either the MPL or the [___] License." + + [NOTE: The text of this Exhibit A may differ slightly from the text of + the notices in the Source Code files of the Original Code. You should + use the text of this Exhibit A rather than the text found in the + Original Code Source Code for Your Modifications.] + diff -Nru syslog-ng-3.11.1/packaging/debian/not-installed syslog-ng-3.13.2/packaging/debian/not-installed --- syslog-ng-3.11.1/packaging/debian/not-installed 1970-01-01 00:00:00.000000000 +0000 +++ syslog-ng-3.13.2/packaging/debian/not-installed 2017-12-06 06:39:39.000000000 +0000 @@ -0,0 +1,4 @@ +usr/share/syslog-ng/include/scl/pacct/plugin.conf +usr/share/syslog-ng/include/scl/elasticsearch/plugin.conf +usr/share/syslog-ng/include/scl/kafka/plugin.conf +usr/share/syslog-ng/include/scl/hdfs/plugin.conf \ No newline at end of file diff -Nru syslog-ng-3.11.1/packaging/debian/README.source syslog-ng-3.13.2/packaging/debian/README.source --- syslog-ng-3.11.1/packaging/debian/README.source 1970-01-01 00:00:00.000000000 +0000 +++ syslog-ng-3.13.2/packaging/debian/README.source 2017-12-06 06:39:39.000000000 +0000 @@ -0,0 +1,87 @@ +syslog-ng Debian sources +======================== + +This is the Debian packaging of syslog-ng. It is a non-trivial +packaging, not for the faint of heart, but rest assured, every quirk, +every strange solution is there for a reason, and this document is +here to explain the details. + +Packaging quirks +---------------- + +Most of the quirks we do happen in `debian/rules`, and they're also +documented there. If there is conflict between this document and +`debian/rules`, the latter is to be trusted. + +### Maintainer scripts + +Both syslog-ng-core, and a few of the older modules have maintainer +scripts, for various purposes. + +In the case of **syslog-ng-core**, the `postrm` takes care of +disabling (on remove) or removing (on purge) the logrotate +configuration files, and also removes the control socket and the +persist file, along with the `/var/lib/syslog-ng` directory, if it is +empty. + +The `preinst` for **syslog-ng-core** restores any disabled logrotate +configs, and if upgrading from a version that had symlinked conffiles, +removes those too, before unpacking the upgrade. + +And the last maintainer script of **syslog-ng-core**, the `prerm` +stops the `syslog.socket` if using systemd, so that we do not get +re-enabled by socket activation during remove. + +Some module packages, namely **syslog-ng-mod-json**, +**syslog-ng-mod-sql**, and **syslog-ng-mod-mongodb** also have a +`postinst`, which removes the old activation conffile that shipped +with syslog-ng versions prior to 3.4 + +### Platform-specific tweaks + +By default, console output shall be directed to the tenth TTY device. +On GNU/Linux, this is `/dev/tty10`, while on GNU/kFreeBSD, it is +`/dev/ttya`. We get around this by using a platform-specific +configuration snippet, that declares a syslog-ng variable with the +appropriate value. + +On kFreeBSD, we install one version, on Linux, another. This is done +from debian/syslog-ng-core.install, via `dh-exec`. + +This way, the main configuration file remains the same on all +architectures, only this little snippet changes, which makes it easier +to maintain the whole. + +### Shared library ABI versions + +Upstream builds a `libsyslog-ng-$MAJOR.so.$N` shared library, which we +ship in `syslog-ng-core`, because it is not a general purpose library. + +### Control variables + +We have three custom control variables, which are referenced by +`debian/control`: **${sng:CoreModules}**, and **${sng:Modules}**. They will be +used for dependencies. + +The `syslog-ng` meta package has to depend on core modules, because at +some point in the past, they were part of the monolithic `syslog-ng` +package, and for smooth upgrades, we need to keep all formerly +installed modules installed. Being a meta package, it also recommends +the other modules. + +The list of Core modules is a hard-coded list (**sql**, **mongodb**, +**json**), but the optional modules are generated at build time, by +looking at `debian/control` and finding all packages with names +starting with `syslog-ng-mod-`. + +We use the `debian/tools/list-modules.sh` script to construct these +lists for us, and in `debian/rules`, we override `dh_gencontrol` to +pass these along. + + -- Gergely Nagy Fri, 07 Nov 2014 08:44:36 +0100 + + diff -Nru syslog-ng-3.11.1/packaging/debian/rules syslog-ng-3.13.2/packaging/debian/rules --- syslog-ng-3.11.1/packaging/debian/rules 1970-01-01 00:00:00.000000000 +0000 +++ syslog-ng-3.13.2/packaging/debian/rules 2017-12-06 06:39:39.000000000 +0000 @@ -0,0 +1,192 @@ +#! /usr/bin/make -f +## debian/rules file for syslog-ng 3.3+ +## (C) 2010-2012 Laszlo Boszormenyi (GCS) +## (C) 2011-2014 Gergely Nagy +## +## Released under the GPLv2+, see /usr/share/common-licenses/GPL-2 on +## Debian systems. + +# For my own sanity, when debian/rules is ran without any argument, +# display something meaningful, instead of just running the first +# override. +help: + sensible-pager debian/README.source + +## +#* Environment setup +# +# If DEB_BUILD_OPTIONS has "debug" in it, we want to pass +# --enable-debug to configure. +# +# We also want to build in a separate build directory: +# debian/build-tree, because it's just so much easier to ignore files +# in there. +# +# By the way, if one wants to pass extra flags to configure, that can +# be done with EXTRA_CONFIGURE_OPTS, we don't override it, only append +# to it. +## +ifneq (,$(filter debug,$(DEB_BUILD_OPTIONS))) +EXTRA_CONFIGURE_OPTS += --enable-debug +endif + +# We want to support building from a git tree, where the syslog-ng +# sources are in a submodule, in syslog-ng-*. Since we do not wish to +# update the rules for every major version if it can be helped, figure +# it out from the changelog instead. +UMAJOR = $(shell dpkg-parsechangelog | sed -n '/^Version:/s/^Version: //p' | cut -d. -f1,2) + +export DH_OPTIONS += -O-Bdebian/build-tree --dbg-package=syslog-ng-dbg + +CFLAGS ?= $(shell dpkg-buildflags --get CFLAGS) +LDFLAGS ?= $(shell dpkg-buildflags --get LDFLAGS) + + +# We want to enforce systemd support on Linux, but disable it +# everywhere else. +ifeq ($(shell dpkg-architecture -qDEB_HOST_ARCH_OS),linux) +SYSTEMD_CONFIGURE_OPTS = --enable-systemd --with-systemd-journal=system +else +SYSTEMD_CONFIGURE_OPTS = --disable-systemd +endif + +# If DH_QUIET is set, then we want silent mode. +# If DH_VERBOSE is set, we do not want silent mode. +# If neither is set, we want the default: verbose mode. +SILENT_MODE = --disable-silent-rules +ifneq (,${DH_QUIET}) +SILENT_MODE = --enable-silent-rules +endif +ifneq (,${DH_VERBOSE}) +SILENT_MODE = --disable-silent-rules +endif + +## +#* Overrides for dh_auto* +## + +# Oh, the joys of configure! +# We pass down all appropriate options, along with EXTRA_CONFIGURE_OPTS. +# This also sets SOURCE_REVISION to the debian package version. +override_dh_auto_configure: + install -d debian/build-tree + -rm -rf doc/man/*.? + SOURCE_REVISION="$(shell dpkg-parsechangelog | \ + sed -n '/^Version:/s/^Version: //p')"; \ + dh_auto_configure -- \ + --build=$(dpkg-architecture -qDEB_BUILD_GNU_TYPE) \ + --prefix=/usr \ + --mandir=/usr/share/man \ + --sysconfdir=/etc/syslog-ng \ + --localstatedir=/var/lib/syslog-ng \ + --libdir=/usr/lib/syslog-ng \ + ${SILENT_MODE} \ + \ + --enable-dynamic-linking \ + --enable-ssl \ + --enable-spoof-source \ + --enable-tcp-wrapper \ + --enable-sql \ + --enable-mongodb \ + --enable-json \ + --enable-riemann \ + --enable-java \ + --enable-manpages \ + --enable-amqp \ + --enable-pacct \ + --enable-python \ + \ + --with-mongoc=system \ + --with-ivykis=system \ + --with-jsonc=system \ + --with-librabbitmq-client=system \ + \ + --with-module-dir='$${exec_prefix}/lib/syslog-ng/${UMAJOR}' \ + --with-systemdsystemunitdir="/lib/systemd/system" \ + \ + SOURCE_REVISION="$${SOURCE_REVISION}" \ + ${SYSTEMD_CONFIGURE_OPTS} \ + ${EXTRA_CONFIGURE_OPTS} + +# The pkg-config .pc file is installed into ${libdir}/pkgconfig, but +# we override libdir above to place everything useful there. We want +# the .pc file elsewhere, though, so do that here at install time. +# +# Similarly, we want to install python modules to their proper place, +# and this is a great time to tell the build system where that is. +# Also removing .la files, these files don't needed and just confuse +# the list-missing option +override_dh_auto_install: + dh_auto_install -- pkgconfigdir=/usr/lib/pkgconfig \ + PYSETUP_OPTIONS="--install-layout=deb --root=$(CURDIR)/debian/tmp/" + find . -name \*.la | xargs --no-run-if-empty rm + +# To get better test results, and actually see failing tests, we need +# to pass VERBOSE=1 to make when running the tests. Do that here. +override_dh_auto_test: + dh_auto_test -- VERBOSE=1 + +## +#* Overrides for other debhelper commands +# +# Below are overrides for individual debhelper commands. +## + +# Install the NEWS file as upstream changelog. +# Rationale: the ChangeLog file is an old artifact from the Arch +# times. It is not updated, and is obsolete. +override_dh_installchangelogs: + dh_installchangelogs NEWS.md + +# Init files and whatnot were moved to syslog-ng-core, but we want to +# retain the old filenames. +override_dh_installinit: + dh_installinit --name syslog-ng --restart-after-upgrade + +# Logrotate and Logcheck files were moved from syslog-ng to +# syslog-ng-core too, and like in init's case, we want to keep the old +# name. +override_dh_installlogrotate: + dh_installlogrotate --name syslog-ng + +override_dh_installlogcheck: + dh_installlogcheck --name syslog-ng + +# dh_makeshlibs wants to be clever and treat plugins as shared libs. +# Slap it in the face, and tell it not to. We also do not need any +# script modifications, as our single shared lib is in a private +# directory. On the other hand, we do want correct dependencies on +# anything that build-depends on syslog-ng-dev, so lets make a correct +# shlibs file for that, shall we? +override_dh_makeshlibs: + dh_makeshlibs -n -Xusr/lib/syslog-ng/${UMAJOR} + +# Since syslog-ng depends on all the modules, and syslog-ng-core +# suggests the same set, and modules can come and go as new versions +# of syslog-ng come out, lets make our life easy, and provide a custom +# sng:Modules substvar, which has all the module packages listed. We +# also provide sng:CoreModules, which lists core modules that were +# part of syslog-ng (or it depended on them) previously, in 3.3. +override_dh_gencontrol: + dh_gencontrol -- -Vsng:Modules=$(shell debian/tools/list-modules.sh optional) \ + -Vsng:CoreModules=$(shell debian/tools/list-modules.sh core) + +# Sadly, dh_python2 barfs on --dbg-package=, so we work it around by +# clearing DH_OPTIONS here. +override_dh_python2: + DH_OPTIONS="" dh_python2 + +## +#* Other, non-override targets +## + +# By default, the arch:all syslog-ng package does not need anything +# built, so build-indep shall be empty. This avoids triggering another +# build attempt, which would fail due to autoreconf being run +# twice. It would also fail if no build-deps were installed (since the +# package has no build-dep-indeps, rightly so). +build-indep: ; + +# And for the rest, there is debhelper! +%: + dh $@ --with autoreconf,systemd,python2 --parallel --list-missing diff -Nru syslog-ng-3.11.1/packaging/debian/scl.conf syslog-ng-3.13.2/packaging/debian/scl.conf --- syslog-ng-3.11.1/packaging/debian/scl.conf 1970-01-01 00:00:00.000000000 +0000 +++ syslog-ng-3.13.2/packaging/debian/scl.conf 2017-12-06 06:39:39.000000000 +0000 @@ -0,0 +1,28 @@ +############################################################################# +# Copyright (c) 2010-2014 BalaBit IT Ltd, Budapest, Hungary +# +# This program is free software; you can redistribute it and/or modify it +# under the terms of the GNU General Public License version 2 as published +# by the Free Software Foundation, or (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA +# +# As an additional exemption you are allowed to compile & link against the +# OpenSSL libraries as published by the OpenSSL project. See the file +# COPYING for details. +# +############################################################################# +# +# This file is placed into /etc/syslog-ng in order to make it trivial to +# include in user written syslog-ng.conf files. It sets up 'scl-root' and +# `include-path`, then includes all SCL supplied plugins. +# + +@include 'scl/*/*.conf' diff -Nru syslog-ng-3.11.1/packaging/debian/source/format syslog-ng-3.13.2/packaging/debian/source/format --- syslog-ng-3.11.1/packaging/debian/source/format 1970-01-01 00:00:00.000000000 +0000 +++ syslog-ng-3.13.2/packaging/debian/source/format 2017-12-06 06:39:39.000000000 +0000 @@ -0,0 +1 @@ +3.0 (quilt) diff -Nru syslog-ng-3.11.1/packaging/debian/source/options syslog-ng-3.13.2/packaging/debian/source/options --- syslog-ng-3.11.1/packaging/debian/source/options 1970-01-01 00:00:00.000000000 +0000 +++ syslog-ng-3.13.2/packaging/debian/source/options 2017-12-06 06:39:39.000000000 +0000 @@ -0,0 +1,2 @@ +single-debian-patch +compression = "xz" diff -Nru syslog-ng-3.11.1/packaging/debian/source/patch-header syslog-ng-3.13.2/packaging/debian/source/patch-header --- syslog-ng-3.11.1/packaging/debian/source/patch-header 1970-01-01 00:00:00.000000000 +0000 +++ syslog-ng-3.13.2/packaging/debian/source/patch-header 2017-12-06 06:39:39.000000000 +0000 @@ -0,0 +1,9 @@ +Description: Debian-specific changes mixed together. + This patch contains all the Debian-specific changes mixed together. To + review them separately, please inspect the Git history (see the + Vcs-Git field in debian/control); the patches against upstream are all + on the patched branch. + . + For more information, please see debian/README.source. +Origin: Debian + diff -Nru syslog-ng-3.11.1/packaging/debian/syslog-ng.conf syslog-ng-3.13.2/packaging/debian/syslog-ng.conf --- syslog-ng-3.11.1/packaging/debian/syslog-ng.conf 1970-01-01 00:00:00.000000000 +0000 +++ syslog-ng-3.13.2/packaging/debian/syslog-ng.conf 2017-12-06 06:39:39.000000000 +0000 @@ -0,0 +1,161 @@ +@version: 3.11 +@include "scl.conf" + +# Syslog-ng configuration file, compatible with default Debian syslogd +# installation. + +# First, set some global options. +options { chain_hostnames(off); flush_lines(0); use_dns(no); use_fqdn(no); + owner("root"); group("adm"); perm(0640); stats_freq(0); + bad_hostname("^gconfd$"); +}; + +######################## +# Sources +######################## +# This is the default behavior of sysklogd package +# Logs may come from unix stream, but not from another machine. +# +source s_src { + system(); + internal(); +}; + +# If you wish to get logs from remote machine you should uncomment +# this and comment the above source line. +# +#source s_net { tcp(ip(127.0.0.1) port(1000)); }; + +######################## +# Destinations +######################## +# First some standard logfile +# +destination d_auth { file("/var/log/auth.log"); }; +destination d_cron { file("/var/log/cron.log"); }; +destination d_daemon { file("/var/log/daemon.log"); }; +destination d_kern { file("/var/log/kern.log"); }; +destination d_lpr { file("/var/log/lpr.log"); }; +destination d_mail { file("/var/log/mail.log"); }; +destination d_syslog { file("/var/log/syslog"); }; +destination d_user { file("/var/log/user.log"); }; +destination d_uucp { file("/var/log/uucp.log"); }; + +# This files are the log come from the mail subsystem. +# +destination d_mailinfo { file("/var/log/mail.info"); }; +destination d_mailwarn { file("/var/log/mail.warn"); }; +destination d_mailerr { file("/var/log/mail.err"); }; + +# Logging for INN news system +# +destination d_newscrit { file("/var/log/news/news.crit"); }; +destination d_newserr { file("/var/log/news/news.err"); }; +destination d_newsnotice { file("/var/log/news/news.notice"); }; + +# Some 'catch-all' logfiles. +# +destination d_debug { file("/var/log/debug"); }; +destination d_error { file("/var/log/error"); }; +destination d_messages { file("/var/log/messages"); }; + +# The root's console. +# +destination d_console { usertty("root"); }; + +# Virtual console. +# +destination d_console_all { file(`tty10`); }; + +# The named pipe /dev/xconsole is for the nsole' utility. To use it, +# you must invoke nsole' with the -file' option: +# +# $ xconsole -file /dev/xconsole [...] +# +destination d_xconsole { pipe("/dev/xconsole"); }; + +# Send the messages to an other host +# +#destination d_net { tcp("127.0.0.1" port(1000) log_fifo_size(1000)); }; + +# Debian only +destination d_ppp { file("/var/log/ppp.log"); }; + +######################## +# Filters +######################## +# Here's come the filter options. With this rules, we can set which +# message go where. + +filter f_dbg { level(debug); }; +filter f_info { level(info); }; +filter f_notice { level(notice); }; +filter f_warn { level(warn); }; +filter f_err { level(err); }; +filter f_crit { level(crit .. emerg); }; + +filter f_debug { level(debug) and not facility(auth, authpriv, news, mail); }; +filter f_error { level(err .. emerg) ; }; +filter f_messages { level(info,notice,warn) and + not facility(auth,authpriv,cron,daemon,mail,news); }; + +filter f_auth { facility(auth, authpriv) and not filter(f_debug); }; +filter f_cron { facility(cron) and not filter(f_debug); }; +filter f_daemon { facility(daemon) and not filter(f_debug); }; +filter f_kern { facility(kern) and not filter(f_debug); }; +filter f_lpr { facility(lpr) and not filter(f_debug); }; +filter f_local { facility(local0, local1, local3, local4, local5, + local6, local7) and not filter(f_debug); }; +filter f_mail { facility(mail) and not filter(f_debug); }; +filter f_news { facility(news) and not filter(f_debug); }; +filter f_syslog3 { not facility(auth, authpriv, mail) and not filter(f_debug); }; +filter f_user { facility(user) and not filter(f_debug); }; +filter f_uucp { facility(uucp) and not filter(f_debug); }; + +filter f_cnews { level(notice, err, crit) and facility(news); }; +filter f_cother { level(debug, info, notice, warn) or facility(daemon, mail); }; + +filter f_ppp { facility(local2) and not filter(f_debug); }; +filter f_console { level(warn .. emerg); }; + +######################## +# Log paths +######################## +log { source(s_src); filter(f_auth); destination(d_auth); }; +log { source(s_src); filter(f_cron); destination(d_cron); }; +log { source(s_src); filter(f_daemon); destination(d_daemon); }; +log { source(s_src); filter(f_kern); destination(d_kern); }; +log { source(s_src); filter(f_lpr); destination(d_lpr); }; +log { source(s_src); filter(f_syslog3); destination(d_syslog); }; +log { source(s_src); filter(f_user); destination(d_user); }; +log { source(s_src); filter(f_uucp); destination(d_uucp); }; + +log { source(s_src); filter(f_mail); destination(d_mail); }; +#log { source(s_src); filter(f_mail); filter(f_info); destination(d_mailinfo); }; +#log { source(s_src); filter(f_mail); filter(f_warn); destination(d_mailwarn); }; +#log { source(s_src); filter(f_mail); filter(f_err); destination(d_mailerr); }; + +log { source(s_src); filter(f_news); filter(f_crit); destination(d_newscrit); }; +log { source(s_src); filter(f_news); filter(f_err); destination(d_newserr); }; +log { source(s_src); filter(f_news); filter(f_notice); destination(d_newsnotice); }; +#log { source(s_src); filter(f_cnews); destination(d_console_all); }; +#log { source(s_src); filter(f_cother); destination(d_console_all); }; + +#log { source(s_src); filter(f_ppp); destination(d_ppp); }; + +log { source(s_src); filter(f_debug); destination(d_debug); }; +log { source(s_src); filter(f_error); destination(d_error); }; +log { source(s_src); filter(f_messages); destination(d_messages); }; + +log { source(s_src); filter(f_console); destination(d_console_all); + destination(d_xconsole); }; +log { source(s_src); filter(f_crit); destination(d_console); }; + +# All messages send to a remote site +# +#log { source(s_src); destination(d_net); }; + +### +# Include all config files in /etc/syslog-ng/conf.d/ +### +@include "/etc/syslog-ng/conf.d/*.conf" diff -Nru syslog-ng-3.11.1/packaging/debian/syslog-ng-core.dirs syslog-ng-3.13.2/packaging/debian/syslog-ng-core.dirs --- syslog-ng-3.11.1/packaging/debian/syslog-ng-core.dirs 1970-01-01 00:00:00.000000000 +0000 +++ syslog-ng-3.13.2/packaging/debian/syslog-ng-core.dirs 2017-12-06 06:39:39.000000000 +0000 @@ -0,0 +1,2 @@ +/etc/syslog-ng/conf.d/ +/var/lib/syslog-ng/ diff -Nru syslog-ng-3.11.1/packaging/debian/syslog-ng-core.install syslog-ng-3.13.2/packaging/debian/syslog-ng-core.install --- syslog-ng-3.11.1/packaging/debian/syslog-ng-core.install 1970-01-01 00:00:00.000000000 +0000 +++ syslog-ng-3.13.2/packaging/debian/syslog-ng-core.install 2017-12-06 06:39:39.000000000 +0000 @@ -0,0 +1,58 @@ +#! /usr/bin/dh-exec + +etc/syslog-ng/* +usr/bin/* +usr/sbin/* +usr/lib/syslog-ng/libsyslog-ng-*.so.* +usr/lib/syslog-ng/libevtlog-*.so.* +usr/lib/syslog-ng/*/libsdjournal.so +usr/lib/syslog-ng/*/libaffile.so +usr/lib/syslog-ng/*/libafprog.so +usr/lib/syslog-ng/*/libafsocket.so +usr/lib/syslog-ng/*/libafuser.so +usr/lib/syslog-ng/*/libbasicfuncs.so +usr/lib/syslog-ng/*/libconfgen.so +usr/lib/syslog-ng/*/libcryptofuncs.so +usr/lib/syslog-ng/*/libcsvparser.so +usr/lib/syslog-ng/*/libdbparser.so +usr/lib/syslog-ng/*/libkvformat.so +usr/lib/syslog-ng/*/libtags-parser.so +usr/lib/syslog-ng/*/liblinux-kmsg-format.so +usr/lib/syslog-ng/*/libpseudofile.so +usr/lib/syslog-ng/*/libsyslogformat.so +usr/lib/syslog-ng/*/libsystem-source.so +usr/lib/syslog-ng/*/libdate.so +usr/lib/syslog-ng/*/libcef.so +usr/lib/syslog-ng/*/libdisk-buffer.so +usr/lib/syslog-ng/*/libxml.so +usr/lib/syslog-ng/*/libappmodel.so +usr/lib/syslog-ng/*/libjson-plugin.so +usr/share/syslog-ng/include/scl/system/* +usr/share/syslog-ng/include/scl/syslogconf/* +usr/share/syslog-ng/include/scl/rewrite/* +usr/share/syslog-ng/include/scl/mbox/* +usr/share/syslog-ng/include/scl/apache/* +usr/share/syslog-ng/include/scl/loggly/* +usr/share/syslog-ng/include/scl/logmatic/* +usr/share/syslog-ng/include/scl/solaris/* +usr/share/syslog-ng/include/scl/cisco/* +usr/share/syslog-ng/include/scl/windowseventlog/* +usr/share/syslog-ng/include/scl/loadbalancer/* +usr/share/syslog-ng/include/scl/iptables/* +usr/share/syslog-ng/include/scl/default-network-drivers/* +usr/share/syslog-ng/include/scl/sudo/* +usr/share/syslog-ng/include/scl/nodejs/* +usr/share/syslog-ng/include/scl/osquery/* +usr/share/syslog-ng/include/scl/ewmm/* +usr/share/syslog-ng/include/scl/graylog2/* +usr/share/syslog-ng/xsd/* + +#Templates with json dependencies +usr/share/syslog-ng/include/scl/cim/* +[!kfreebsd-any] debian/syslog-ng.systemd => lib/systemd/system/syslog-ng.service + +debian/syslog-ng.conf /etc/syslog-ng/ +debian/scl.conf /etc/syslog-ng/ + +[kfreebsd-any] debian/tty10.kfreebsd.conf => /usr/share/syslog-ng/include/scl/system/tty10.conf +[!kfreebsd-any] debian/tty10.linux.conf => /usr/share/syslog-ng/include/scl/system/tty10.conf diff -Nru syslog-ng-3.11.1/packaging/debian/syslog-ng-core.manpages syslog-ng-3.13.2/packaging/debian/syslog-ng-core.manpages --- syslog-ng-3.11.1/packaging/debian/syslog-ng-core.manpages 1970-01-01 00:00:00.000000000 +0000 +++ syslog-ng-3.13.2/packaging/debian/syslog-ng-core.manpages 2017-12-06 06:39:39.000000000 +0000 @@ -0,0 +1,8 @@ +debian/man/*.1 +debian/tmp/usr/share/man/man1/loggen.1 +debian/tmp/usr/share/man/man1/dqtool.1 +debian/tmp/usr/share/man/man1/syslog-ng-debun.1 +debian/tmp/usr/share/man/man1/pdbtool.1 +debian/tmp/usr/share/man/man1/syslog-ng-ctl.1 +debian/tmp/usr/share/man/man5/syslog-ng.conf.5 +debian/tmp/usr/share/man/man8/syslog-ng.8 diff -Nru syslog-ng-3.11.1/packaging/debian/syslog-ng-core.NEWS syslog-ng-3.13.2/packaging/debian/syslog-ng-core.NEWS --- syslog-ng-3.11.1/packaging/debian/syslog-ng-core.NEWS 1970-01-01 00:00:00.000000000 +0000 +++ syslog-ng-3.13.2/packaging/debian/syslog-ng-core.NEWS 2017-12-06 06:39:39.000000000 +0000 @@ -0,0 +1,12 @@ +syslog-ng (3.3.6-1) unstable; urgency=low + + Between Squeeze and Wheezy OpenSSL changed the default certificate + directory hashing algorithm from MD5 to SHA1, which may affect syslog-ng + users who use TLS sources or destinations. + + Due to the change in OpenSSL, certificate verification may fail, and one + will need to update their certificate directories by calling c_rehash in + them. If you're experiencing verification failures after upgrading + syslog-ng from Squeeze, consider rehashing your certificate directories. + + -- Gergely Nagy Fri, 17 Aug 2012 11:05:39 +0200 diff -Nru syslog-ng-3.11.1/packaging/debian/syslog-ng-core.postrm syslog-ng-3.13.2/packaging/debian/syslog-ng-core.postrm --- syslog-ng-3.11.1/packaging/debian/syslog-ng-core.postrm 1970-01-01 00:00:00.000000000 +0000 +++ syslog-ng-3.13.2/packaging/debian/syslog-ng-core.postrm 2017-12-06 06:39:39.000000000 +0000 @@ -0,0 +1,22 @@ +#! /bin/sh + +set -e + +if [ "$1" = "remove" ]; then + [ -f /etc/logrotate.d/syslog-ng ] && mv -f /etc/logrotate.d/syslog-ng /etc/logrotate.d/syslog-ng.disabled + + rm -f /var/lib/syslog-ng/syslog-ng.ctl /var/lib/syslog-ng/syslog-ng.persist + [ -d /var/lib/syslog-ng/ ] && rmdir --ignore-fail-on-non-empty /var/lib/syslog-ng/ +fi + +# remove disabled files on purge or complete overwrite. +if [ "$1" = "purge" -o "$1" = "disappear" ]; then + [ -f /etc/logrotate.d/syslog-ng.disabled ] && rm -f /etc/logrotate.d/syslog-ng.disabled + + rm -f /var/lib/syslog-ng/syslog-ng.ctl /var/lib/syslog-ng/syslog-ng.persist + [ -d /var/lib/syslog-ng/ ] && rmdir --ignore-fail-on-non-empty /var/lib/syslog-ng/ +fi + +#DEBHELPER# + +exit 0 diff -Nru syslog-ng-3.11.1/packaging/debian/syslog-ng-core.preinst syslog-ng-3.13.2/packaging/debian/syslog-ng-core.preinst --- syslog-ng-3.11.1/packaging/debian/syslog-ng-core.preinst 1970-01-01 00:00:00.000000000 +0000 +++ syslog-ng-3.13.2/packaging/debian/syslog-ng-core.preinst 2017-12-06 06:39:39.000000000 +0000 @@ -0,0 +1,31 @@ +#! /bin/sh + +set -e + +if [ "$1" = "install" ]; then + if [ -f /etc/logrotate.d/syslog-ng.disabled ]; then + if [ -n "$2" ]; then + mv -f /etc/logrotate.d/syslog-ng.disabled /etc/logrotate.d/syslog-ng + elif [ ! -f /etc/logrotate.d/syslog-ng ]; then + mv -f /etc/logrotate.d/syslog-ng.disabled /etc/logrotate.d/syslog-ng + fi + fi +fi + +if [ "$1" = "upgrade" ] && + (dpkg --compare-versions "$2" lt "3.3.5-3" || + (dpkg --compare-versions "$2" gt "3.3.5-4" && + (dpkg --compare-versions "$2" lt "3.3.9-1~" || dpkg --compare-versions "$2" lt "3.4.2-1~"))) +then + # Some versions of the package installed symlink conffiles + # which don't work (#690067) + for file_to_remove in /etc/systemd/system/multi-user.target.wants/syslog-ng.service /etc/systemd/system/syslog.service; do + if [ -L $file_to_remove ]; then + rm $file_to_remove + fi + done +fi + +#DEBHELPER# + +exit 0 diff -Nru syslog-ng-3.11.1/packaging/debian/syslog-ng-core.prerm syslog-ng-3.13.2/packaging/debian/syslog-ng-core.prerm --- syslog-ng-3.11.1/packaging/debian/syslog-ng-core.prerm 1970-01-01 00:00:00.000000000 +0000 +++ syslog-ng-3.13.2/packaging/debian/syslog-ng-core.prerm 2017-12-06 06:39:39.000000000 +0000 @@ -0,0 +1,12 @@ +#! /bin/sh + +set -e + +# Stop the socket on remove so syslog-ng is not restarted via socket activation +if [ -x "/usr/bin/deb-systemd-invoke" ] && [ "$1" = remove ]; then + deb-systemd-invoke stop syslog.socket || true +fi + +#DEBHELPER# + +exit 0 diff -Nru syslog-ng-3.11.1/packaging/debian/syslog-ng-core.syslog-ng.default syslog-ng-3.13.2/packaging/debian/syslog-ng-core.syslog-ng.default --- syslog-ng-3.11.1/packaging/debian/syslog-ng-core.syslog-ng.default 1970-01-01 00:00:00.000000000 +0000 +++ syslog-ng-3.13.2/packaging/debian/syslog-ng-core.syslog-ng.default 2017-12-06 06:39:39.000000000 +0000 @@ -0,0 +1,12 @@ +# If a variable is not set here, then the corresponding +# parameter will not be changed. +# If a variables is set, then every invocation of +# syslog-ng's init script will set them using dmesg. + +# log level of messages which should go to console +# see syslog(3) for details +# +#CONSOLE_LOG_LEVEL=1 + +# Command line options to syslog-ng +#SYSLOGNG_OPTS="--no-caps" diff -Nru syslog-ng-3.11.1/packaging/debian/syslog-ng-core.syslog-ng.init syslog-ng-3.13.2/packaging/debian/syslog-ng-core.syslog-ng.init --- syslog-ng-3.11.1/packaging/debian/syslog-ng-core.syslog-ng.init 1970-01-01 00:00:00.000000000 +0000 +++ syslog-ng-3.13.2/packaging/debian/syslog-ng-core.syslog-ng.init 2017-12-06 06:39:39.000000000 +0000 @@ -0,0 +1,149 @@ +#! /bin/sh +### BEGIN INIT INFO +# Provides: syslog-ng +# Required-Start: $local_fs $network $time $remote_fs +# Required-Stop: $local_fs $network $time $remote_fs +# Default-Start: 2 3 4 5 +# Default-Stop: 0 1 6 +# Short-Description: Starting system logging daemon +# Description: Starting syslog-NG, the next generation +# syslog daemon. +### END INIT INFO# + +set -e + +SYSLOGNG_OPTS="" + +#we source /etc/default/syslog-ng if exists +[ -r /etc/default/syslog-ng ] && . /etc/default/syslog-ng + +# stop syslog-ng before changing its PID file! +PIDFILE="/var/run/syslog-ng.pid" + +SYSLOGNG="/usr/sbin/syslog-ng" +NAME="syslog-ng" + +PATH=/sbin:/bin:/usr/sbin:/usr/bin +test -f $SYSLOGNG || exit 0 + +# Define LSB log_* functions. +# Depend on lsb-base (>= 3.0-6) to ensure that this file is present. +. /lib/lsb/init-functions + +case "x$CONSOLE_LOG_LEVEL" in + x[1-8]) + dmesg -n $CONSOLE_LOG_LEVEL + ;; + x) + ;; + *) + log_warning_msg "CONSOLE_LOG_LEVEL is of unaccepted value." + ;; +esac + +create_xconsole() { + XCONSOLE=/dev/xconsole + if [ "$(uname -s)" = "GNU/kFreeBSD" ]; then + XCONSOLE=/var/run/xconsole + ln -sf $XCONSOLE /dev/xconsole + fi + if [ ! -e $XCONSOLE ]; then + mknod -m 640 $XCONSOLE p + chown root:adm $XCONSOLE + [ -x /sbin/restorecon ] && /sbin/restorecon $XCONSOLE + fi +} + +create_pidfiledir() { + if [ ! -d /var/run/syslog-ng ] + then + mkdir -p /var/run/syslog-ng + fi +} + +syslogng_wait() { + if [ "$2" -ne 0 ]; then + return 1 + fi + + if [ -n "$DPKG_MAINTSCRIPT_PACKAGE" ]; then + return 0 + fi + + RET=1 + for i in $(seq 1 30); do + status=0 + syslog-ng-ctl stats >/dev/null 2>&1 || status=$? + if [ "$status" != "$1" ]; then + RET=0 + break + fi + sleep 1s + done + return $RET +} + +syslogng_start() { + log_daemon_msg "Starting system logging" "$NAME" + create_pidfiledir + create_xconsole + start-stop-daemon --start --oknodo --quiet --exec "$SYSLOGNG" \ + --pidfile "$PIDFILE" -- -p "$PIDFILE" $SYSLOGNG_OPTS + syslogng_wait 1 $? + RET="$?" + log_end_msg $RET + return $RET +} + +syslogng_stop() { + log_daemon_msg "Stopping system logging" "$NAME" + start-stop-daemon --stop --oknodo --quiet --name "$NAME" --retry 3 \ + --pidfile "$PIDFILE" + syslogng_wait 0 $? + RET="$?" + log_end_msg $RET + return $RET +} + +syslogng_reload() { + log_daemon_msg "Reload system logging" "$NAME" + if $SYSLOGNG -s $SYSLOGNG_OPTS + then + start-stop-daemon --stop --signal 1 --quiet --exec "$SYSLOGNG" \ + --pidfile "$PIDFILE" + syslogng_wait 1 $? + RET="$?" + log_end_msg $RET + return $RET + else + log_end_msg 1 + return 1 + fi +} + + +case "$1" in + start) + syslogng_start || exit 1 + ;; + stop) + syslogng_stop || exit 1 + ;; + reload|force-reload) + syslogng_reload || exit 1 + ;; + restart) + syslogng_stop + syslogng_start || exit 1 + ;; + status) + status_of_proc "$SYSLOGNG" "$NAME" && exit 0 || exit $? + ;; + *) + echo "Usage: /etc/init.d/$NAME {start|stop|restart|reload|force-reload|status}" >&2 + exit 1 + ;; +esac + +exit 0 + diff -Nru syslog-ng-3.11.1/packaging/debian/syslog-ng-core.syslog-ng.logcheck.ignore.paranoid syslog-ng-3.13.2/packaging/debian/syslog-ng-core.syslog-ng.logcheck.ignore.paranoid --- syslog-ng-3.11.1/packaging/debian/syslog-ng-core.syslog-ng.logcheck.ignore.paranoid 1970-01-01 00:00:00.000000000 +0000 +++ syslog-ng-3.13.2/packaging/debian/syslog-ng-core.syslog-ng.logcheck.ignore.paranoid 2017-12-06 06:39:39.000000000 +0000 @@ -0,0 +1,2 @@ +^\w{3} [ :[:digit:]]{11} [._[:alnum:]-]+ syslog-ng\[[[:digit:]]{1,5}\]: Log statistics;( (processed='(source|destination|center)\([-_[:alnum:]]+\)=[[:digit:]]+'|dropped='pipe\([-/_[:alnum:]]+\)=[[:digit:]]+'|dropped='(ud|tc)p\(AF_INET\([.[:digit:]]{7,15}:[[:digit:]]{1,5}\)\)=[[:digit:]]+'),)+[^,]*$ +^\w{3} [ :[:digit:]]{11} [._[:alnum:]-]+ syslog-ng\[[[:digit:]]{1,5}\]: STATS: dropped 0$ diff -Nru syslog-ng-3.11.1/packaging/debian/syslog-ng-core.syslog-ng.logcheck.ignore.server syslog-ng-3.13.2/packaging/debian/syslog-ng-core.syslog-ng.logcheck.ignore.server --- syslog-ng-3.11.1/packaging/debian/syslog-ng-core.syslog-ng.logcheck.ignore.server 1970-01-01 00:00:00.000000000 +0000 +++ syslog-ng-3.13.2/packaging/debian/syslog-ng-core.syslog-ng.logcheck.ignore.server 2017-12-06 06:39:39.000000000 +0000 @@ -0,0 +1,5 @@ +^\w{3} [ :[:digit:]]{11} [._[:alnum:]-]+ syslog-ng\[[[:digit:]]{1,5}\]: new configuration initialized$ +^\w{3} [ :[:digit:]]{11} [._[:alnum:]-]+ syslog-ng\[[[:digit:]]{1,5}\]: Configuration reload request received, reloading configuration;$ +^\w{3} [ :[:digit:]]{11} [._[:alnum:]-]+ syslog-ng\[[[:digit:]]{1,5}\]: Duplicate stats counter; (counter='[^']+'(, )?)$ +^\w{3} [ :[:digit:]]{11} [._[:alnum:]-]+ syslog-ng\[[[:digit:]]{1,5}\]: Changing permissions on special file /dev/xconsole$ +^\w{3} [ :[:digit:]]{11} [._[:alnum:]-]+ syslog-ng\[[[:digit:]]{1,5}\]: Cannot open file /dev/xconsole for writing \(No such file or directory\)$ diff -Nru syslog-ng-3.11.1/packaging/debian/syslog-ng-core.syslog-ng.logcheck.violations.ignore syslog-ng-3.13.2/packaging/debian/syslog-ng-core.syslog-ng.logcheck.violations.ignore --- syslog-ng-3.11.1/packaging/debian/syslog-ng-core.syslog-ng.logcheck.violations.ignore 1970-01-01 00:00:00.000000000 +0000 +++ syslog-ng-3.13.2/packaging/debian/syslog-ng-core.syslog-ng.logcheck.violations.ignore 2017-12-06 06:39:39.000000000 +0000 @@ -0,0 +1 @@ +^\w{3} [ :[:digit:]]{11} [._[:alnum:]-]+ syslog-ng\[[[:digit:]]{1,5}\]: Log statistics;( (processed='(source|destination|center)\([-_[:alnum:]]+\)=[[:digit:]]+'|dropped='pipe\([-/_[:alnum:]]+\)=[[:digit:]]+'|dropped='(ud|tc)p\(AF_INET\([.[:digit:]]{7,15}:[[:digit:]]{1,5}\)\)=[[:digit:]]+'),)+[^,]*$ diff -Nru syslog-ng-3.11.1/packaging/debian/syslog-ng-core.syslog-ng.logrotate syslog-ng-3.13.2/packaging/debian/syslog-ng-core.syslog-ng.logrotate --- syslog-ng-3.11.1/packaging/debian/syslog-ng-core.syslog-ng.logrotate 1970-01-01 00:00:00.000000000 +0000 +++ syslog-ng-3.13.2/packaging/debian/syslog-ng-core.syslog-ng.logrotate 2017-12-06 06:39:39.000000000 +0000 @@ -0,0 +1,38 @@ +/var/log/syslog +{ + rotate 7 + daily + missingok + notifempty + delaycompress + compress + postrotate + invoke-rc.d syslog-ng reload > /dev/null + endscript +} + +/var/log/mail.info +/var/log/mail.warn +/var/log/mail.err +/var/log/mail.log +/var/log/daemon.log +/var/log/kern.log +/var/log/auth.log +/var/log/user.log +/var/log/lpr.log +/var/log/cron.log +/var/log/debug +/var/log/messages +/var/log/error +{ + rotate 4 + weekly + missingok + notifempty + compress + delaycompress + sharedscripts + postrotate + invoke-rc.d syslog-ng reload > /dev/null + endscript +} diff -Nru syslog-ng-3.11.1/packaging/debian/syslog-ng-core.syslog-ng.upstart syslog-ng-3.13.2/packaging/debian/syslog-ng-core.syslog-ng.upstart --- syslog-ng-3.11.1/packaging/debian/syslog-ng-core.syslog-ng.upstart 1970-01-01 00:00:00.000000000 +0000 +++ syslog-ng-3.13.2/packaging/debian/syslog-ng-core.syslog-ng.upstart 2017-12-06 06:39:39.000000000 +0000 @@ -0,0 +1,32 @@ +# syslog-ng - system logging daemon +# +# syslog-ng is an replacement for the traditional syslog daemon, logging messages from applications + +description "system logging daemon" + +start on filesystem +stop on runlevel [06] + +expect fork +respawn + +script + CONF="/etc/syslog-ng/syslog-ng.conf" + CTRL="/var/lib/syslog-ng/syslog-ng.ctl" + OPTS="" + + # Allow override of command/conf and opts by /etc/default/syslog-ng + if [ -f /etc/default/$UPSTART_JOB ]; then + . /etc/default/$UPSTART_JOB + fi + + if ! [ -r "$CONF" ] ; then + echo "Could not read ${CONF}: exiting" + exit 1 + fi + + exec /usr/sbin/syslog-ng --process-mode=background \ + -f $CONF -c $CTRL \ + -p /var/run/syslog-ng.pid $OPTS + +end script diff -Nru syslog-ng-3.11.1/packaging/debian/syslog-ng-dev.install syslog-ng-3.13.2/packaging/debian/syslog-ng-dev.install --- syslog-ng-3.11.1/packaging/debian/syslog-ng-dev.install 1970-01-01 00:00:00.000000000 +0000 +++ syslog-ng-3.13.2/packaging/debian/syslog-ng-dev.install 2017-12-06 06:39:39.000000000 +0000 @@ -0,0 +1,8 @@ +usr/include/syslog-ng/* +usr/lib/syslog-ng/libsyslog-ng.so +usr/lib/syslog-ng/syslog-ng/libtest/libsyslog-ng-test.a +usr/lib/syslog-ng/libsyslog-ng-native-connector.a +usr/lib/**/syslog-ng.pc +usr/lib/**/syslog-ng-test.pc +usr/lib/**/syslog-ng-native-connector.pc +usr/share/syslog-ng/tools diff -Nru syslog-ng-3.11.1/packaging/debian/syslog-ng-java-http.install syslog-ng-3.13.2/packaging/debian/syslog-ng-java-http.install --- syslog-ng-3.11.1/packaging/debian/syslog-ng-java-http.install 1970-01-01 00:00:00.000000000 +0000 +++ syslog-ng-3.13.2/packaging/debian/syslog-ng-java-http.install 2017-12-06 06:39:39.000000000 +0000 @@ -0,0 +1 @@ +usr/lib/syslog-ng/*/java-modules/http.jar diff -Nru syslog-ng-3.11.1/packaging/debian/syslog-ng-mod-add-contextual-data.install syslog-ng-3.13.2/packaging/debian/syslog-ng-mod-add-contextual-data.install --- syslog-ng-3.11.1/packaging/debian/syslog-ng-mod-add-contextual-data.install 1970-01-01 00:00:00.000000000 +0000 +++ syslog-ng-3.13.2/packaging/debian/syslog-ng-mod-add-contextual-data.install 2017-12-06 06:39:39.000000000 +0000 @@ -0,0 +1 @@ +usr/lib/syslog-ng/*/libadd-contextual-data.so diff -Nru syslog-ng-3.11.1/packaging/debian/syslog-ng-mod-amqp.docs syslog-ng-3.13.2/packaging/debian/syslog-ng-mod-amqp.docs --- syslog-ng-3.11.1/packaging/debian/syslog-ng-mod-amqp.docs 1970-01-01 00:00:00.000000000 +0000 +++ syslog-ng-3.13.2/packaging/debian/syslog-ng-mod-amqp.docs 2017-12-06 06:39:39.000000000 +0000 @@ -0,0 +1 @@ +debian/MPL diff -Nru syslog-ng-3.11.1/packaging/debian/syslog-ng-mod-amqp.install syslog-ng-3.13.2/packaging/debian/syslog-ng-mod-amqp.install --- syslog-ng-3.11.1/packaging/debian/syslog-ng-mod-amqp.install 1970-01-01 00:00:00.000000000 +0000 +++ syslog-ng-3.13.2/packaging/debian/syslog-ng-mod-amqp.install 2017-12-06 06:39:39.000000000 +0000 @@ -0,0 +1 @@ +usr/lib/syslog-ng/*/libafamqp.so diff -Nru syslog-ng-3.11.1/packaging/debian/syslog-ng-mod-common.maintscript syslog-ng-3.13.2/packaging/debian/syslog-ng-mod-common.maintscript --- syslog-ng-3.11.1/packaging/debian/syslog-ng-mod-common.maintscript 1970-01-01 00:00:00.000000000 +0000 +++ syslog-ng-3.13.2/packaging/debian/syslog-ng-mod-common.maintscript 2017-12-06 06:39:39.000000000 +0000 @@ -0,0 +1,35 @@ +#! /bin/sh +## Common preinst, postinst and postrm script for syslog-ng-mod-* +## packages. Some of the modules in syslog-ng-3.3 came with a +## 00load-$mod config file, which are being removed in 3.4. This file +## does the necessary dpkg-maintscript-helper voodoo to get rid of +## them. +## +## To avoid duplication, only one file is written, the rest are +## symlinked to it. + +set -e + +case "${DPKG_MAINTSCRIPT_PACKAGE}" in + syslog-ng-mod-json) + modname="tfjson" + ;; + syslog-ng-mod-sql|syslog-ng-mod-mongodb) + modname="${DPKG_MAINTSCRIPT_PACKAGE#syslog-ng-mod-}" + ;; + *) + echo "rm_conffile voodoo unsupported for package ${DPKG_MAINTSCRIPT_PACKAGE}!" >&2 + exit 1 + ;; +esac + +if [ -x "/usr/bin/dpkg-maintscript-helper" ]; then + if dpkg-maintscript-helper supports rm_conffile; then + dpkg-maintscript-helper rm_conffile \ + /etc/syslog-ng/conf.d/00load-${modname}.conf 3.4.0~ -- "$@" + fi +fi + +#DEBHELPER# + +exit 0 diff -Nru syslog-ng-3.11.1/packaging/debian/syslog-ng-mod-elastic.install syslog-ng-3.13.2/packaging/debian/syslog-ng-mod-elastic.install --- syslog-ng-3.11.1/packaging/debian/syslog-ng-mod-elastic.install 1970-01-01 00:00:00.000000000 +0000 +++ syslog-ng-3.13.2/packaging/debian/syslog-ng-mod-elastic.install 2017-12-06 06:39:39.000000000 +0000 @@ -0,0 +1,4 @@ +usr/lib/syslog-ng/*/java-modules/elastic.jar +usr/lib/syslog-ng/*/java-modules/elastic-v2.jar +usr/lib/syslog-ng/*/java-modules/elastic-jest-client/*.jar +usr/share/syslog-ng/include/scl/elasticsearch/* diff -Nru syslog-ng-3.11.1/packaging/debian/syslog-ng-mod-geoip2.install syslog-ng-3.13.2/packaging/debian/syslog-ng-mod-geoip2.install --- syslog-ng-3.11.1/packaging/debian/syslog-ng-mod-geoip2.install 1970-01-01 00:00:00.000000000 +0000 +++ syslog-ng-3.13.2/packaging/debian/syslog-ng-mod-geoip2.install 2017-12-06 06:39:39.000000000 +0000 @@ -0,0 +1 @@ +usr/lib/syslog-ng/*/libgeoip2-plugin.so diff -Nru syslog-ng-3.11.1/packaging/debian/syslog-ng-mod-geoip.install syslog-ng-3.13.2/packaging/debian/syslog-ng-mod-geoip.install --- syslog-ng-3.11.1/packaging/debian/syslog-ng-mod-geoip.install 1970-01-01 00:00:00.000000000 +0000 +++ syslog-ng-3.13.2/packaging/debian/syslog-ng-mod-geoip.install 2017-12-06 06:39:39.000000000 +0000 @@ -0,0 +1 @@ +usr/lib/syslog-ng/*/libgeoip-plugin.so diff -Nru syslog-ng-3.11.1/packaging/debian/syslog-ng-mod-getent.install syslog-ng-3.13.2/packaging/debian/syslog-ng-mod-getent.install --- syslog-ng-3.11.1/packaging/debian/syslog-ng-mod-getent.install 1970-01-01 00:00:00.000000000 +0000 +++ syslog-ng-3.13.2/packaging/debian/syslog-ng-mod-getent.install 2017-12-06 06:39:39.000000000 +0000 @@ -0,0 +1 @@ +usr/lib/syslog-ng/*/libtfgetent.so diff -Nru syslog-ng-3.11.1/packaging/debian/syslog-ng-mod-graphite.install syslog-ng-3.13.2/packaging/debian/syslog-ng-mod-graphite.install --- syslog-ng-3.11.1/packaging/debian/syslog-ng-mod-graphite.install 1970-01-01 00:00:00.000000000 +0000 +++ syslog-ng-3.13.2/packaging/debian/syslog-ng-mod-graphite.install 2017-12-06 06:39:39.000000000 +0000 @@ -0,0 +1,2 @@ +usr/lib/syslog-ng/*/libgraphite.so +usr/share/syslog-ng/include/scl/graphite/* diff -Nru syslog-ng-3.11.1/packaging/debian/syslog-ng-mod-hdfs.install syslog-ng-3.13.2/packaging/debian/syslog-ng-mod-hdfs.install --- syslog-ng-3.11.1/packaging/debian/syslog-ng-mod-hdfs.install 1970-01-01 00:00:00.000000000 +0000 +++ syslog-ng-3.13.2/packaging/debian/syslog-ng-mod-hdfs.install 2017-12-06 06:39:39.000000000 +0000 @@ -0,0 +1,2 @@ +usr/lib/syslog-ng/*/java-modules/hdfs.jar +usr/share/syslog-ng/include/scl/hdfs/* diff -Nru syslog-ng-3.11.1/packaging/debian/syslog-ng-mod-http.install syslog-ng-3.13.2/packaging/debian/syslog-ng-mod-http.install --- syslog-ng-3.11.1/packaging/debian/syslog-ng-mod-http.install 1970-01-01 00:00:00.000000000 +0000 +++ syslog-ng-3.13.2/packaging/debian/syslog-ng-mod-http.install 2017-12-06 06:39:39.000000000 +0000 @@ -0,0 +1 @@ +usr/lib/syslog-ng/*/libhttp.so diff -Nru syslog-ng-3.11.1/packaging/debian/syslog-ng-mod-java-common-lib.install syslog-ng-3.13.2/packaging/debian/syslog-ng-mod-java-common-lib.install --- syslog-ng-3.11.1/packaging/debian/syslog-ng-mod-java-common-lib.install 1970-01-01 00:00:00.000000000 +0000 +++ syslog-ng-3.13.2/packaging/debian/syslog-ng-mod-java-common-lib.install 2017-12-06 06:39:39.000000000 +0000 @@ -0,0 +1,2 @@ +usr/lib/syslog-ng/*/java-modules/syslog-ng-common.jar +usr/lib/syslog-ng/*/java-modules/log4j*.jar diff -Nru syslog-ng-3.11.1/packaging/debian/syslog-ng-mod-java-http.install syslog-ng-3.13.2/packaging/debian/syslog-ng-mod-java-http.install --- syslog-ng-3.11.1/packaging/debian/syslog-ng-mod-java-http.install 1970-01-01 00:00:00.000000000 +0000 +++ syslog-ng-3.13.2/packaging/debian/syslog-ng-mod-java-http.install 2017-12-06 06:39:39.000000000 +0000 @@ -0,0 +1 @@ +usr/lib/syslog-ng/*/java-modules/http.jar diff -Nru syslog-ng-3.11.1/packaging/debian/syslog-ng-mod-java.install syslog-ng-3.13.2/packaging/debian/syslog-ng-mod-java.install --- syslog-ng-3.11.1/packaging/debian/syslog-ng-mod-java.install 1970-01-01 00:00:00.000000000 +0000 +++ syslog-ng-3.13.2/packaging/debian/syslog-ng-mod-java.install 2017-12-06 06:39:39.000000000 +0000 @@ -0,0 +1,2 @@ +usr/lib/syslog-ng/*/libmod-java.so +usr/lib/syslog-ng/*/java-modules/syslog-ng-core.jar diff -Nru syslog-ng-3.11.1/packaging/debian/syslog-ng-mod-kafka.install syslog-ng-3.13.2/packaging/debian/syslog-ng-mod-kafka.install --- syslog-ng-3.11.1/packaging/debian/syslog-ng-mod-kafka.install 1970-01-01 00:00:00.000000000 +0000 +++ syslog-ng-3.13.2/packaging/debian/syslog-ng-mod-kafka.install 2017-12-06 06:39:39.000000000 +0000 @@ -0,0 +1,2 @@ +usr/lib/syslog-ng/*/java-modules/kafka.jar +usr/share/syslog-ng/include/scl/kafka/* diff -Nru syslog-ng-3.11.1/packaging/debian/syslog-ng-mod-map-value-pairs.install syslog-ng-3.13.2/packaging/debian/syslog-ng-mod-map-value-pairs.install --- syslog-ng-3.11.1/packaging/debian/syslog-ng-mod-map-value-pairs.install 1970-01-01 00:00:00.000000000 +0000 +++ syslog-ng-3.13.2/packaging/debian/syslog-ng-mod-map-value-pairs.install 2017-12-06 06:39:39.000000000 +0000 @@ -0,0 +1 @@ +usr/lib/syslog-ng/*/libmap-value-pairs.so diff -Nru syslog-ng-3.11.1/packaging/debian/syslog-ng-mod-mongodb.install syslog-ng-3.13.2/packaging/debian/syslog-ng-mod-mongodb.install --- syslog-ng-3.11.1/packaging/debian/syslog-ng-mod-mongodb.install 1970-01-01 00:00:00.000000000 +0000 +++ syslog-ng-3.13.2/packaging/debian/syslog-ng-mod-mongodb.install 2017-12-06 06:39:39.000000000 +0000 @@ -0,0 +1 @@ +usr/lib/syslog-ng/*/libafmongodb.so diff -Nru syslog-ng-3.11.1/packaging/debian/syslog-ng-mod-mongodb.postinst syslog-ng-3.13.2/packaging/debian/syslog-ng-mod-mongodb.postinst --- syslog-ng-3.11.1/packaging/debian/syslog-ng-mod-mongodb.postinst 1970-01-01 00:00:00.000000000 +0000 +++ syslog-ng-3.13.2/packaging/debian/syslog-ng-mod-mongodb.postinst 2017-12-06 06:39:39.000000000 +0000 @@ -0,0 +1,35 @@ +#! /bin/sh +## Common preinst, postinst and postrm script for syslog-ng-mod-* +## packages. Some of the modules in syslog-ng-3.3 came with a +## 00load-$mod config file, which are being removed in 3.4. This file +## does the necessary dpkg-maintscript-helper voodoo to get rid of +## them. +## +## To avoid duplication, only one file is written, the rest are +## symlinked to it. + +set -e + +case "${DPKG_MAINTSCRIPT_PACKAGE}" in + syslog-ng-mod-json) + modname="tfjson" + ;; + syslog-ng-mod-sql|syslog-ng-mod-mongodb) + modname="${DPKG_MAINTSCRIPT_PACKAGE#syslog-ng-mod-}" + ;; + *) + echo "rm_conffile voodoo unsupported for package ${DPKG_MAINTSCRIPT_PACKAGE}!" >&2 + exit 1 + ;; +esac + +if [ -x "/usr/bin/dpkg-maintscript-helper" ]; then + if dpkg-maintscript-helper supports rm_conffile; then + dpkg-maintscript-helper rm_conffile \ + /etc/syslog-ng/conf.d/00load-${modname}.conf 3.4.0~ -- "$@" + fi +fi + +#DEBHELPER# + +exit 0 diff -Nru syslog-ng-3.11.1/packaging/debian/syslog-ng-mod-mongodb.postrm syslog-ng-3.13.2/packaging/debian/syslog-ng-mod-mongodb.postrm --- syslog-ng-3.11.1/packaging/debian/syslog-ng-mod-mongodb.postrm 1970-01-01 00:00:00.000000000 +0000 +++ syslog-ng-3.13.2/packaging/debian/syslog-ng-mod-mongodb.postrm 2017-12-06 06:39:39.000000000 +0000 @@ -0,0 +1,35 @@ +#! /bin/sh +## Common preinst, postinst and postrm script for syslog-ng-mod-* +## packages. Some of the modules in syslog-ng-3.3 came with a +## 00load-$mod config file, which are being removed in 3.4. This file +## does the necessary dpkg-maintscript-helper voodoo to get rid of +## them. +## +## To avoid duplication, only one file is written, the rest are +## symlinked to it. + +set -e + +case "${DPKG_MAINTSCRIPT_PACKAGE}" in + syslog-ng-mod-json) + modname="tfjson" + ;; + syslog-ng-mod-sql|syslog-ng-mod-mongodb) + modname="${DPKG_MAINTSCRIPT_PACKAGE#syslog-ng-mod-}" + ;; + *) + echo "rm_conffile voodoo unsupported for package ${DPKG_MAINTSCRIPT_PACKAGE}!" >&2 + exit 1 + ;; +esac + +if [ -x "/usr/bin/dpkg-maintscript-helper" ]; then + if dpkg-maintscript-helper supports rm_conffile; then + dpkg-maintscript-helper rm_conffile \ + /etc/syslog-ng/conf.d/00load-${modname}.conf 3.4.0~ -- "$@" + fi +fi + +#DEBHELPER# + +exit 0 diff -Nru syslog-ng-3.11.1/packaging/debian/syslog-ng-mod-mongodb.preinst syslog-ng-3.13.2/packaging/debian/syslog-ng-mod-mongodb.preinst --- syslog-ng-3.11.1/packaging/debian/syslog-ng-mod-mongodb.preinst 1970-01-01 00:00:00.000000000 +0000 +++ syslog-ng-3.13.2/packaging/debian/syslog-ng-mod-mongodb.preinst 2017-12-06 06:39:39.000000000 +0000 @@ -0,0 +1,35 @@ +#! /bin/sh +## Common preinst, postinst and postrm script for syslog-ng-mod-* +## packages. Some of the modules in syslog-ng-3.3 came with a +## 00load-$mod config file, which are being removed in 3.4. This file +## does the necessary dpkg-maintscript-helper voodoo to get rid of +## them. +## +## To avoid duplication, only one file is written, the rest are +## symlinked to it. + +set -e + +case "${DPKG_MAINTSCRIPT_PACKAGE}" in + syslog-ng-mod-json) + modname="tfjson" + ;; + syslog-ng-mod-sql|syslog-ng-mod-mongodb) + modname="${DPKG_MAINTSCRIPT_PACKAGE#syslog-ng-mod-}" + ;; + *) + echo "rm_conffile voodoo unsupported for package ${DPKG_MAINTSCRIPT_PACKAGE}!" >&2 + exit 1 + ;; +esac + +if [ -x "/usr/bin/dpkg-maintscript-helper" ]; then + if dpkg-maintscript-helper supports rm_conffile; then + dpkg-maintscript-helper rm_conffile \ + /etc/syslog-ng/conf.d/00load-${modname}.conf 3.4.0~ -- "$@" + fi +fi + +#DEBHELPER# + +exit 0 diff -Nru syslog-ng-3.11.1/packaging/debian/syslog-ng-mod-pacctformat.install syslog-ng-3.13.2/packaging/debian/syslog-ng-mod-pacctformat.install --- syslog-ng-3.11.1/packaging/debian/syslog-ng-mod-pacctformat.install 1970-01-01 00:00:00.000000000 +0000 +++ syslog-ng-3.13.2/packaging/debian/syslog-ng-mod-pacctformat.install 2017-12-06 06:39:39.000000000 +0000 @@ -0,0 +1,2 @@ +usr/lib/syslog-ng/*/libpacctformat.so +usr/share/syslog-ng/include/scl/pacct/* diff -Nru syslog-ng-3.11.1/packaging/debian/syslog-ng-mod-python.install syslog-ng-3.13.2/packaging/debian/syslog-ng-mod-python.install --- syslog-ng-3.11.1/packaging/debian/syslog-ng-mod-python.install 1970-01-01 00:00:00.000000000 +0000 +++ syslog-ng-3.13.2/packaging/debian/syslog-ng-mod-python.install 2017-12-06 06:39:39.000000000 +0000 @@ -0,0 +1,2 @@ +usr/lib/syslog-ng/*/libmod-python.so +usr/lib/python* diff -Nru syslog-ng-3.11.1/packaging/debian/syslog-ng-mod-redis.install syslog-ng-3.13.2/packaging/debian/syslog-ng-mod-redis.install --- syslog-ng-3.11.1/packaging/debian/syslog-ng-mod-redis.install 1970-01-01 00:00:00.000000000 +0000 +++ syslog-ng-3.13.2/packaging/debian/syslog-ng-mod-redis.install 2017-12-06 06:39:39.000000000 +0000 @@ -0,0 +1 @@ +usr/lib/syslog-ng/*/libredis.so diff -Nru syslog-ng-3.11.1/packaging/debian/syslog-ng-mod-riemann.install syslog-ng-3.13.2/packaging/debian/syslog-ng-mod-riemann.install --- syslog-ng-3.11.1/packaging/debian/syslog-ng-mod-riemann.install 1970-01-01 00:00:00.000000000 +0000 +++ syslog-ng-3.13.2/packaging/debian/syslog-ng-mod-riemann.install 2017-12-06 06:39:39.000000000 +0000 @@ -0,0 +1 @@ +usr/lib/syslog-ng/*/libriemann.so diff -Nru syslog-ng-3.11.1/packaging/debian/syslog-ng-mod-smtp.install syslog-ng-3.13.2/packaging/debian/syslog-ng-mod-smtp.install --- syslog-ng-3.11.1/packaging/debian/syslog-ng-mod-smtp.install 1970-01-01 00:00:00.000000000 +0000 +++ syslog-ng-3.13.2/packaging/debian/syslog-ng-mod-smtp.install 2017-12-06 06:39:39.000000000 +0000 @@ -0,0 +1 @@ +usr/lib/syslog-ng/*/libafsmtp.so diff -Nru syslog-ng-3.11.1/packaging/debian/syslog-ng-mod-snmptrapd-parser.install syslog-ng-3.13.2/packaging/debian/syslog-ng-mod-snmptrapd-parser.install --- syslog-ng-3.11.1/packaging/debian/syslog-ng-mod-snmptrapd-parser.install 1970-01-01 00:00:00.000000000 +0000 +++ syslog-ng-3.13.2/packaging/debian/syslog-ng-mod-snmptrapd-parser.install 2017-12-06 06:39:39.000000000 +0000 @@ -0,0 +1,2 @@ +usr/lib/syslog-ng/*/libsnmptrapd-parser.so +usr/share/syslog-ng/include/scl/snmptrap/snmptrapd-source.conf diff -Nru syslog-ng-3.11.1/packaging/debian/syslog-ng-mod-sql.install syslog-ng-3.13.2/packaging/debian/syslog-ng-mod-sql.install --- syslog-ng-3.11.1/packaging/debian/syslog-ng-mod-sql.install 1970-01-01 00:00:00.000000000 +0000 +++ syslog-ng-3.13.2/packaging/debian/syslog-ng-mod-sql.install 2017-12-06 06:39:39.000000000 +0000 @@ -0,0 +1 @@ +usr/lib/syslog-ng/*/libafsql.so diff -Nru syslog-ng-3.11.1/packaging/debian/syslog-ng-mod-sql.postinst syslog-ng-3.13.2/packaging/debian/syslog-ng-mod-sql.postinst --- syslog-ng-3.11.1/packaging/debian/syslog-ng-mod-sql.postinst 1970-01-01 00:00:00.000000000 +0000 +++ syslog-ng-3.13.2/packaging/debian/syslog-ng-mod-sql.postinst 2017-12-06 06:39:39.000000000 +0000 @@ -0,0 +1,35 @@ +#! /bin/sh +## Common preinst, postinst and postrm script for syslog-ng-mod-* +## packages. Some of the modules in syslog-ng-3.3 came with a +## 00load-$mod config file, which are being removed in 3.4. This file +## does the necessary dpkg-maintscript-helper voodoo to get rid of +## them. +## +## To avoid duplication, only one file is written, the rest are +## symlinked to it. + +set -e + +case "${DPKG_MAINTSCRIPT_PACKAGE}" in + syslog-ng-mod-json) + modname="tfjson" + ;; + syslog-ng-mod-sql|syslog-ng-mod-mongodb) + modname="${DPKG_MAINTSCRIPT_PACKAGE#syslog-ng-mod-}" + ;; + *) + echo "rm_conffile voodoo unsupported for package ${DPKG_MAINTSCRIPT_PACKAGE}!" >&2 + exit 1 + ;; +esac + +if [ -x "/usr/bin/dpkg-maintscript-helper" ]; then + if dpkg-maintscript-helper supports rm_conffile; then + dpkg-maintscript-helper rm_conffile \ + /etc/syslog-ng/conf.d/00load-${modname}.conf 3.4.0~ -- "$@" + fi +fi + +#DEBHELPER# + +exit 0 diff -Nru syslog-ng-3.11.1/packaging/debian/syslog-ng-mod-sql.postrm syslog-ng-3.13.2/packaging/debian/syslog-ng-mod-sql.postrm --- syslog-ng-3.11.1/packaging/debian/syslog-ng-mod-sql.postrm 1970-01-01 00:00:00.000000000 +0000 +++ syslog-ng-3.13.2/packaging/debian/syslog-ng-mod-sql.postrm 2017-12-06 06:39:39.000000000 +0000 @@ -0,0 +1,35 @@ +#! /bin/sh +## Common preinst, postinst and postrm script for syslog-ng-mod-* +## packages. Some of the modules in syslog-ng-3.3 came with a +## 00load-$mod config file, which are being removed in 3.4. This file +## does the necessary dpkg-maintscript-helper voodoo to get rid of +## them. +## +## To avoid duplication, only one file is written, the rest are +## symlinked to it. + +set -e + +case "${DPKG_MAINTSCRIPT_PACKAGE}" in + syslog-ng-mod-json) + modname="tfjson" + ;; + syslog-ng-mod-sql|syslog-ng-mod-mongodb) + modname="${DPKG_MAINTSCRIPT_PACKAGE#syslog-ng-mod-}" + ;; + *) + echo "rm_conffile voodoo unsupported for package ${DPKG_MAINTSCRIPT_PACKAGE}!" >&2 + exit 1 + ;; +esac + +if [ -x "/usr/bin/dpkg-maintscript-helper" ]; then + if dpkg-maintscript-helper supports rm_conffile; then + dpkg-maintscript-helper rm_conffile \ + /etc/syslog-ng/conf.d/00load-${modname}.conf 3.4.0~ -- "$@" + fi +fi + +#DEBHELPER# + +exit 0 diff -Nru syslog-ng-3.11.1/packaging/debian/syslog-ng-mod-sql.preinst syslog-ng-3.13.2/packaging/debian/syslog-ng-mod-sql.preinst --- syslog-ng-3.11.1/packaging/debian/syslog-ng-mod-sql.preinst 1970-01-01 00:00:00.000000000 +0000 +++ syslog-ng-3.13.2/packaging/debian/syslog-ng-mod-sql.preinst 2017-12-06 06:39:39.000000000 +0000 @@ -0,0 +1,35 @@ +#! /bin/sh +## Common preinst, postinst and postrm script for syslog-ng-mod-* +## packages. Some of the modules in syslog-ng-3.3 came with a +## 00load-$mod config file, which are being removed in 3.4. This file +## does the necessary dpkg-maintscript-helper voodoo to get rid of +## them. +## +## To avoid duplication, only one file is written, the rest are +## symlinked to it. + +set -e + +case "${DPKG_MAINTSCRIPT_PACKAGE}" in + syslog-ng-mod-json) + modname="tfjson" + ;; + syslog-ng-mod-sql|syslog-ng-mod-mongodb) + modname="${DPKG_MAINTSCRIPT_PACKAGE#syslog-ng-mod-}" + ;; + *) + echo "rm_conffile voodoo unsupported for package ${DPKG_MAINTSCRIPT_PACKAGE}!" >&2 + exit 1 + ;; +esac + +if [ -x "/usr/bin/dpkg-maintscript-helper" ]; then + if dpkg-maintscript-helper supports rm_conffile; then + dpkg-maintscript-helper rm_conffile \ + /etc/syslog-ng/conf.d/00load-${modname}.conf 3.4.0~ -- "$@" + fi +fi + +#DEBHELPER# + +exit 0 diff -Nru syslog-ng-3.11.1/packaging/debian/syslog-ng-mod-stardate.install syslog-ng-3.13.2/packaging/debian/syslog-ng-mod-stardate.install --- syslog-ng-3.11.1/packaging/debian/syslog-ng-mod-stardate.install 1970-01-01 00:00:00.000000000 +0000 +++ syslog-ng-3.13.2/packaging/debian/syslog-ng-mod-stardate.install 2017-12-06 06:39:39.000000000 +0000 @@ -0,0 +1 @@ +usr/lib/syslog-ng/*/libstardate.so diff -Nru syslog-ng-3.11.1/packaging/debian/syslog-ng-mod-stomp.install syslog-ng-3.13.2/packaging/debian/syslog-ng-mod-stomp.install --- syslog-ng-3.11.1/packaging/debian/syslog-ng-mod-stomp.install 1970-01-01 00:00:00.000000000 +0000 +++ syslog-ng-3.13.2/packaging/debian/syslog-ng-mod-stomp.install 2017-12-06 06:39:39.000000000 +0000 @@ -0,0 +1 @@ +usr/lib/syslog-ng/*/libafstomp.so diff -Nru syslog-ng-3.11.1/packaging/debian/syslog-ng.systemd syslog-ng-3.13.2/packaging/debian/syslog-ng.systemd --- syslog-ng-3.11.1/packaging/debian/syslog-ng.systemd 1970-01-01 00:00:00.000000000 +0000 +++ syslog-ng-3.13.2/packaging/debian/syslog-ng.systemd 2017-12-06 06:39:39.000000000 +0000 @@ -0,0 +1,16 @@ +[Unit] +Description=System Logger Daemon +Documentation=man:syslog-ng(8) + +[Service] +Type=notify +ExecStart=/usr/sbin/syslog-ng -F $SYSLOGNG_OPTS +ExecReload=/bin/kill -HUP $MAINPID +EnvironmentFile=-/etc/default/syslog-ng +EnvironmentFile=-/etc/sysconfig/syslog-ng +StandardOutput=journal +StandardError=journal +Restart=on-failure + +[Install] +WantedBy=multi-user.target diff -Nru syslog-ng-3.11.1/packaging/debian/tests/baseconfig syslog-ng-3.13.2/packaging/debian/tests/baseconfig --- syslog-ng-3.11.1/packaging/debian/tests/baseconfig 1970-01-01 00:00:00.000000000 +0000 +++ syslog-ng-3.13.2/packaging/debian/tests/baseconfig 2017-12-06 06:39:39.000000000 +0000 @@ -0,0 +1,17 @@ +systemctl stop syslog-ng +/usr/sbin/syslog-ng --syntax-only --cfgfile /etc/syslog-ng/syslog-ng.conf +/usr/sbin/syslog-ng --no-caps --process-mode=background --cfgfile /etc/syslog-ng/syslog-ng.conf --persist-file=/tmp/persist_file --pidfile=/tmp/syslog-ng.pid --control=/tmp/syslog-ng.control + +sleep 2 + +PID=$(cat /tmp/syslog-ng.pid) + +echo "Syslog-ng pid is $PID" + +if [ ! -L /proc/$PID/exe ] +then + echo "syslog-ng could not start" + exit 1 +fi + +kill $PID diff -Nru syslog-ng-3.11.1/packaging/debian/tests/basic syslog-ng-3.13.2/packaging/debian/tests/basic --- syslog-ng-3.11.1/packaging/debian/tests/basic 1970-01-01 00:00:00.000000000 +0000 +++ syslog-ng-3.13.2/packaging/debian/tests/basic 2017-12-06 06:39:39.000000000 +0000 @@ -0,0 +1,35 @@ +#!/bin/sh -e + +rm -f /tmp/input +rm -f /tmp/output.log + +echo "Starting syslog-ng" +/usr/sbin/syslog-ng --no-caps --process-mode=background --cfgfile /$(pwd)/debian/tests/config.syslog --persist-file=/tmp/persist_file --pidfile=/tmp/syslog-ng.pid --control=/tmp/syslog-ng.control + +sleep 2 + +PID=$(cat /tmp/syslog-ng.pid) + +echo "Syslog-ng pid is $PID" + +if [ ! -L /proc/$PID/exe ] +then + echo "syslog-ng could not start" + exit 1 +fi + +echo "Sending a log message" +logger -u /tmp/input almafa + +sleep 1 + +kill $PID + +grep -q almafa /tmp/output.log +if [ $? -eq 1 ] +then + echo "Logged message could not found" + exit 1 +fi + +echo "Sent message has been found in the log. Good" \ No newline at end of file diff -Nru syslog-ng-3.11.1/packaging/debian/tests/config.syslog syslog-ng-3.13.2/packaging/debian/tests/config.syslog --- syslog-ng-3.11.1/packaging/debian/tests/config.syslog 1970-01-01 00:00:00.000000000 +0000 +++ syslog-ng-3.13.2/packaging/debian/tests/config.syslog 2017-12-06 06:39:39.000000000 +0000 @@ -0,0 +1,8 @@ +@version: 3.11 +@include "scl.conf" + +source s_src { unix-dgram("/tmp/input"); }; + +destination d_output { file("/tmp/output.log"); }; + +log { source(s_src); destination(d_output); }; diff -Nru syslog-ng-3.11.1/packaging/debian/tests/control syslog-ng-3.13.2/packaging/debian/tests/control --- syslog-ng-3.11.1/packaging/debian/tests/control 1970-01-01 00:00:00.000000000 +0000 +++ syslog-ng-3.13.2/packaging/debian/tests/control 2017-12-06 06:39:39.000000000 +0000 @@ -0,0 +1,63 @@ +Tests: basic +Depends: syslog-ng-core + +Tests: basic +Depends: syslog-ng + +Tests: basic +Depends: @ + +Tests: basic +Depends: syslog-ng-core, syslog-ng-mod-json + +Tests: basic +Depends: syslog-ng-core, syslog-ng-mod-mongodb + +Tests: basic +Depends: syslog-ng-core, syslog-ng-mod-sql + +Tests: basic +Depends: syslog-ng-core, syslog-ng-mod-smtp + +Tests: basic +Depends: syslog-ng-core, syslog-ng-mod-amqp + +Tests: basic +Depends: syslog-ng-core, syslog-ng-mod-geoip + +Tests: basic +Depends: syslog-ng-core, syslog-ng-mod-redis + +Tests: basic +Depends: syslog-ng-core, syslog-ng-mod-stomp + +Tests: basic +Depends: syslog-ng-core, syslog-ng-mod-riemann + +Tests: basic +Depends: syslog-ng-core, syslog-ng-mod-graphite + +Tests: basic +Depends: syslog-ng-core, syslog-ng-mod-python + +Tests: basic +Depends: syslog-ng-core, syslog-ng-mod-add-contextual-data + +Tests: basic +Depends: syslog-ng-core, syslog-ng-mod-getent + +Tests: basic +Depends: syslog-ng-core, syslog-ng-mod-stardate + +Tests: basic +Depends: syslog-ng-core, syslog-ng-mod-map-value-pairs + +Tests: basic +Depends: syslog-ng-core, syslog-ng-mod-snmptrapd-parser + +Tests: upgrade +Restrictions: needs-root +Depends: apt-utils + +Tests: baseconfig +Restrictions: needs-root diff -Nru syslog-ng-3.11.1/packaging/debian/tests/upgrade syslog-ng-3.13.2/packaging/debian/tests/upgrade --- syslog-ng-3.11.1/packaging/debian/tests/upgrade 1970-01-01 00:00:00.000000000 +0000 +++ syslog-ng-3.13.2/packaging/debian/tests/upgrade 2017-12-06 06:39:39.000000000 +0000 @@ -0,0 +1,26 @@ +#!/bin/sh -e + +orig_version=$(apt-cache policy syslog-ng | grep "500$" | awk '{print $1}') + +apt_line="" +for pkg in syslog-ng \ + syslog-ng-core \ + syslog-ng-mod-journal \ + syslog-ng-mod-json \ + syslog-ng-mod-mongodb \ + syslog-ng-mod-sql \ + syslog-ng-mod-smtp \ + syslog-ng-mod-amqp \ + syslog-ng-mod-geoip \ + syslog-ng-mod-redis \ + syslog-ng-mod-stomp \ + syslog-ng-mod-riemann \ + syslog-ng-mod-graphite \ + syslog-ng-mod-python \ + syslog-ng-mod-add-contextual-data +do + apt_line="$apt_line $pkg=$orig_version" +done + +apt-get install -y $apt_line 2>/dev/null +apt-get -u -y dist-upgrade diff -Nru syslog-ng-3.11.1/packaging/debian/tools/list-modules.sh syslog-ng-3.13.2/packaging/debian/tools/list-modules.sh --- syslog-ng-3.11.1/packaging/debian/tools/list-modules.sh 1970-01-01 00:00:00.000000000 +0000 +++ syslog-ng-3.13.2/packaging/debian/tools/list-modules.sh 2017-12-06 06:39:39.000000000 +0000 @@ -0,0 +1,26 @@ +#! /bin/sh + +CORE_MODULES="syslog-ng-mod-sql syslog-ng-mod-mongodb" +ALL_MODULES=$(echo $(grep "^Package: syslog-ng-mod-" debian/control | cut -d: -f 2)) + +case "$1" in + "core") + echo ${CORE_MODULES} | tr ' ' ',' + ;; + "all") + echo ${ALL_MODULES} | tr ' ' ',' + ;; + "optional"|"") + OPTIONAL_MODULES="" + for mod in ${ALL_MODULES}; do + if ! (echo "${CORE_MODULES}" | grep -q ${mod}); then + OPTIONAL_MODULES="${OPTIONAL_MODULES}${mod} " + fi + done + OPTIONAL_MODULES=$(echo ${OPTIONAL_MODULES}) + echo ${OPTIONAL_MODULES} | tr ' ' ',' + ;; + *) + exit 1 + ;; +esac diff -Nru syslog-ng-3.11.1/packaging/debian/tty10.kfreebsd.conf syslog-ng-3.13.2/packaging/debian/tty10.kfreebsd.conf --- syslog-ng-3.11.1/packaging/debian/tty10.kfreebsd.conf 1970-01-01 00:00:00.000000000 +0000 +++ syslog-ng-3.13.2/packaging/debian/tty10.kfreebsd.conf 2017-12-06 06:39:39.000000000 +0000 @@ -0,0 +1 @@ +@define tty10 "/dev/ttyva" diff -Nru syslog-ng-3.11.1/packaging/debian/tty10.linux.conf syslog-ng-3.13.2/packaging/debian/tty10.linux.conf --- syslog-ng-3.11.1/packaging/debian/tty10.linux.conf 1970-01-01 00:00:00.000000000 +0000 +++ syslog-ng-3.13.2/packaging/debian/tty10.linux.conf 2017-12-06 06:39:39.000000000 +0000 @@ -0,0 +1 @@ +@define tty10 "/dev/tty10" diff -Nru syslog-ng-3.11.1/packaging/debian/watch syslog-ng-3.13.2/packaging/debian/watch --- syslog-ng-3.11.1/packaging/debian/watch 1970-01-01 00:00:00.000000000 +0000 +++ syslog-ng-3.13.2/packaging/debian/watch 2017-12-06 06:39:39.000000000 +0000 @@ -0,0 +1,3 @@ +version=3 + +https://github.com/balabit/syslog-ng/tags .*/syslog-ng-([\d\.]+)\.tar\.gz diff -Nru syslog-ng-3.11.1/packaging/rhel/syslog-ng.conf syslog-ng-3.13.2/packaging/rhel/syslog-ng.conf --- syslog-ng-3.11.1/packaging/rhel/syslog-ng.conf 1970-01-01 00:00:00.000000000 +0000 +++ syslog-ng-3.13.2/packaging/rhel/syslog-ng.conf 2017-12-06 06:39:39.000000000 +0000 @@ -0,0 +1,70 @@ +@version:3.13 +@include "scl.conf" + +# syslog-ng configuration file. +# +# This should behave pretty much like the original syslog on RedHat. But +# it could be configured a lot smarter. +# +# See syslog-ng(8) and syslog-ng.conf(5) for more information. +# +# Note: it also sources additional configuration files (*.conf) +# located in /etc/syslog-ng/conf.d/ + +options { + flush_lines (0); + time_reopen (10); + log_fifo_size (1000); + chain_hostnames (off); + use_dns (no); + use_fqdn (no); + create_dirs (no); + keep_hostname (yes); +}; + +source s_sys { + system(); + internal(); + # udp(ip(0.0.0.0) port(514)); +}; + +destination d_cons { file("/dev/console"); }; +destination d_mesg { file("/var/log/messages"); }; +destination d_auth { file("/var/log/secure"); }; +destination d_mail { file("/var/log/maillog" flush_lines(10)); }; +destination d_spol { file("/var/log/spooler"); }; +destination d_boot { file("/var/log/boot.log"); }; +destination d_cron { file("/var/log/cron"); }; +destination d_kern { file("/var/log/kern"); }; +destination d_mlal { usertty("*"); }; + +filter f_kernel { facility(kern); }; +filter f_default { level(info..emerg) and + not (facility(mail) + or facility(authpriv) + or facility(cron)); }; +filter f_auth { facility(authpriv); }; +filter f_mail { facility(mail); }; +filter f_emergency { level(emerg); }; +filter f_news { facility(uucp) or + (facility(news) + and level(crit..emerg)); }; +filter f_boot { facility(local7); }; +filter f_cron { facility(cron); }; + +#log { source(s_sys); filter(f_kernel); destination(d_cons); }; +log { source(s_sys); filter(f_kernel); destination(d_kern); }; +log { source(s_sys); filter(f_default); destination(d_mesg); }; +log { source(s_sys); filter(f_auth); destination(d_auth); }; +log { source(s_sys); filter(f_mail); destination(d_mail); }; +log { source(s_sys); filter(f_emergency); destination(d_mlal); }; +log { source(s_sys); filter(f_news); destination(d_spol); }; +log { source(s_sys); filter(f_boot); destination(d_boot); }; +log { source(s_sys); filter(f_cron); destination(d_cron); }; + + +# Source additional configuration files (.conf extension only) +@include "/etc/syslog-ng/conf.d/*.conf" + + +# vim:ft=syslog-ng:ai:si:ts=4:sw=4:et: diff -Nru syslog-ng-3.11.1/packaging/rhel/syslog-ng.logrotate syslog-ng-3.13.2/packaging/rhel/syslog-ng.logrotate --- syslog-ng-3.11.1/packaging/rhel/syslog-ng.logrotate 1970-01-01 00:00:00.000000000 +0000 +++ syslog-ng-3.13.2/packaging/rhel/syslog-ng.logrotate 2017-12-06 06:39:39.000000000 +0000 @@ -0,0 +1,12 @@ +/var/log/cron +/var/log/maillog +/var/log/messages +/var/log/secure +/var/log/spooler +{ + missingok + sharedscripts + postrotate + /bin/kill -HUP `cat /var/run/syslogd.pid 2> /dev/null` 2> /dev/null || true + endscript +} diff -Nru syslog-ng-3.11.1/packaging/rhel/syslog-ng.service syslog-ng-3.13.2/packaging/rhel/syslog-ng.service --- syslog-ng-3.11.1/packaging/rhel/syslog-ng.service 1970-01-01 00:00:00.000000000 +0000 +++ syslog-ng-3.13.2/packaging/rhel/syslog-ng.service 2017-12-06 06:39:39.000000000 +0000 @@ -0,0 +1,16 @@ +[Unit] +Description=System Logger Daemon +Documentation=man:syslog-ng(8) + +[Service] +Type=notify +ExecStart=/usr/sbin/syslog-ng -F $SYSLOGNG_OPTS -p /var/run/syslogd.pid +ExecReload=/bin/kill -HUP $MAINPID +EnvironmentFile=-/etc/default/syslog-ng +EnvironmentFile=-/etc/sysconfig/syslog-ng +StandardOutput=journal +StandardError=journal +Restart=on-failure + +[Install] +WantedBy=multi-user.target diff -Nru syslog-ng-3.11.1/packaging/rhel/syslog-ng.spec syslog-ng-3.13.2/packaging/rhel/syslog-ng.spec --- syslog-ng-3.11.1/packaging/rhel/syslog-ng.spec 1970-01-01 00:00:00.000000000 +0000 +++ syslog-ng-3.13.2/packaging/rhel/syslog-ng.spec 2017-12-06 06:39:39.000000000 +0000 @@ -0,0 +1,1116 @@ +# %global evtlog_ver 0.2.13 +%global ivykis_ver 0.36.1 + +Name: syslog-ng +Version: 3.12.1 +Release: 7%{?dist} +Summary: Next-generation syslog server + +Group: System Environment/Daemons +License: GPLv2+ +URL: http://www.balabit.com/network-security/syslog-ng +Source0: https://github.com/balabit/syslog-ng/releases/download/syslog-ng-%{version}/%{name}-%{version}.tar.gz + +# Patch0: syslog-ng-3.7.0beta2-syslog-ng.service.patch +# Patch1: syslog-ng-3.4.0beta1-tests-functional-control.py.patch +# Patch2: syslog-ng-3.3.6-tests-functional-sql-test.patch + +BuildRequires: systemd-units +BuildRequires: pkgconfig +BuildRequires: libtool +BuildRequires: bison, flex +BuildRequires: libxslt +# BuildRequires: eventlog-devel >= %{evtlog_ver} +BuildRequires: glib2-devel >= 2.10.1 +BuildRequires: ivykis-devel >= %{ivykis_ver} +BuildRequires: json-c-devel +BuildRequires: libcap-devel +BuildRequires: libdbi-devel +BuildRequires: libnet-devel +BuildRequires: openssl-devel +BuildRequires: pcre-devel >= 6.1 +BuildRequires: tcp_wrappers-devel +BuildRequires: libuuid-devel +BuildRequires: libesmtp-devel +BuildRequires: libmongo-client-devel +BuildRequires: GeoIP-devel +BuildRequires: systemd-devel +BuildRequires: hiredis-devel +BuildRequires: riemann-c-client-devel +BuildRequires: python-devel +BuildRequires: java-devel +#BuildRequires: gradle +BuildRequires: syslog-ng-java-deps +BuildRequires: libcurl-devel +BuildRequires: mongo-c-driver-devel +BuildRequires: cyrus-sasl-devel +BuildRequires: libmaxminddb-devel + +# Test suite +#BuildRequires: python +#BuildRequires: python-unittest2 +#BuildRequires: python-nose +#BuildRequires: python-ply +#BuildRequires: python-pep8 +#BuildRequires: pylint +#BuildRequires: python-six +# Test suite: the SQL tests +#BuildRequires: libdbi-dbd-sqlite + +Requires: logrotate +Requires: ivykis >= %{ivykis_ver} +Requires(post): systemd-units +Requires(preun): systemd-units +Requires(postun): systemd-units + +Provides: syslog +# merge separate syslog-vim package into one +Provides: syslog-ng-vim = %{version}-%{release} +Obsoletes: syslog-ng-vim < 2.0.8-1 + +# Fedora 17’s unified filesystem (/usr-move) +Conflicts: filesystem < 3 + +Obsoletes: syslog-ng-json + +%description +syslog-ng is an enhanced log daemon, supporting a wide range of input and +output methods: syslog, unstructured text, message queues, databases (SQL +and NoSQL alike) and more. + +Key features: + + * receive and send RFC3164 and RFC5424 style syslog messages + * work with any kind of unstructured data + * receive and send JSON formatted messages + * classify and structure logs with builtin parsers (csv-parser(), + db-parser(), ...) + * normalize, crunch and process logs as they flow through the system + * hand on messages for further processing using message queues (like + AMQP), files or databases (like PostgreSQL or MongoDB). + + +%package libdbi +Summary: libdbi support for %{name} +Group: Development/Libraries +Requires: %{name}%{?_isa} = %{version}-%{release} + +%description libdbi +This module supports a large number of database systems via libdbi. + + +%package mongodb +Summary: mongodb support for %{name} +Group: Development/Libraries +Requires: %{name}%{?_isa} = %{version}-%{release} + +%description mongodb +This module supports the mongodb database via libmongo-client. + + +%package smtp +Summary: smtp support for %{name} +Group: Development/Libraries +Requires: %{name}%{?_isa} = %{version}-%{release} + +%description smtp +This module supports sending e-mail alerts through an smtp server. + + +%package java +Summary: Java destination support for syslog-ng +Group: System/Libraries +Requires: %{name} = %{version} + +%description java +This package provides java destination support for syslog-ng. + + +%package geoip +Summary: geoip support for %{name} +Group: Development/Libraries +Requires: %{name}%{?_isa} = %{version}-%{release} + +%description geoip +This package provides GeoIP support for syslog-ng + + +%package redis +Summary: redis support for %{name} +Group: Development/Libraries +Requires: %{name}%{?_isa} = %{version}-%{release} + +%description redis +This module supports the redis key-value store via hiredis. + +%package riemann +Summary: riemann support for %{name} +Group: Development/Libraries +Requires: %{name}%{?_isa} = %{version}-%{release} + +%description riemann +This module supports the riemann monitoring server. + +%package http +Summary: HTTP support for %{name} +Group: Development/Libraries +Requires: %{name}%{?_isa} = %{version}-%{release} + +%description http +This module supports the HTTP destination. + +%package python +Summary: Python destination support for syslog-ng +Group: System/Libraries +Requires: %{name} = %{version} + +%description python +This package provides python destination support for syslog-ng. + +%package devel +Summary: Development files for %{name} +Group: Development/Libraries +Requires: %{name}%{?_isa} = %{version}-%{release} + +%description devel +The %{name}-devel package contains libraries and header files for +developing applications that use %{name}. + + +%prep +%setup -q +# %patch0 -p1 +# %patch1 -p1 +# %patch2 -p1 + +# fix perl path +%{__sed} -i 's|^#!/usr/local/bin/perl|#!%{__perl}|' contrib/relogger.pl + +# fix executable perms on contrib files +%{__chmod} -c a-x contrib/syslog2ng + +# fix authors file +/usr/bin/iconv -f iso8859-1 -t utf-8 AUTHORS > AUTHORS.conv && \ + %{__mv} -f AUTHORS.conv AUTHORS + + +%build + +# hack to enable gradle-2.6, where necessary +export PATH=/opt/gradle/bin:$PATH + +export GEOIP_LIBS=-lGeoIP +%configure \ + --prefix=%{_prefix} \ + --sysconfdir=%{_sysconfdir}/%{name} \ + --localstatedir=%{_sharedstatedir}/%{name} \ + --datadir=%{_datadir} \ + --with-module-dir=/%{_libdir}/%{name} \ + --with-systemdsystemunitdir=%{_unitdir} \ + --with-ivykis=system \ + --with-mongoc=system \ + --with-embedded-crypto \ + --enable-manpages \ + --enable-ipv6 \ + --enable-tcp-wrapper \ + --enable-spoof-source \ + --with-linux-caps=auto \ + --enable-sql \ + --enable-json \ + --enable-ssl \ + --enable-smtp \ + --enable-geoip \ + --enable-shared \ + --disable-static \ + --enable-dynamic-linking \ + --enable-systemd \ + --enable-redis \ + --disable-amqp \ + --with-librabbitmq-client=no \ + --enable-python \ + --enable-java \ + --enable-riemann + +# remove rpath +# sed -i 's|^hardcode_libdir_flag_spec=.*|hardcode_libdir_flag_spec=""|g' libtool +# sed -i 's|^runpath_var=LD_RUN_PATH|runpath_var=DIE_RPATH_DIE|g' libtool + +# disable broken test by setting a different target +sed -i 's/libs build/libs assemble/' Makefile + +make %{_smp_mflags} + + +%install +make DESTDIR=%{buildroot} install + +%{__install} -d -m 755 %{buildroot}%{_sysconfdir}/%{name}/conf.d +%{__install} -p -m 644 packaging/rhel/syslog-ng.conf %{buildroot}%{_sysconfdir}/%{name}/syslog-ng.conf + +%{__install} -d -m 755 %{buildroot}%{_sysconfdir}/logrotate.d +%{__install} -p -m 644 packaging/rhel/syslog-ng.logrotate %{buildroot}%{_sysconfdir}/logrotate.d/syslog + +%{__install} -p -m 644 packaging/rhel/syslog-ng.service %{buildroot}%{_unitdir}/%{name}.service + + +# create the local state dir +%{__install} -d -m 755 %{buildroot}/%{_sharedstatedir}/%{name} + +# install the main library header files +%{__install} -d -m 755 %{buildroot}%{_includedir}/%{name} +%{__install} -p -m 644 config.h %{buildroot}%{_includedir}/%{name} +%{__install} -p -m 644 lib/*.h %{buildroot}%{_includedir}/%{name} + +# install vim files +%{__install} -d -m 755 %{buildroot}%{_datadir}/%{name} +%{__install} -p -m 644 contrib/syslog-ng.vim %{buildroot}%{_datadir}/%{name} +for vimver in 73 ; do + %{__install} -d -m 755 %{buildroot}%{_datadir}/vim/vim$vimver/syntax + cd %{buildroot}%{_datadir}/vim/vim$vimver/syntax + ln -s ../../../%{name}/syslog-ng.vim . + cd - +done + +find %{buildroot} -name "*.la" -exec rm -f {} \; + +# remove some extra testing related files +rm %{buildroot}/%{_libdir}/pkgconfig/syslog-ng-test.pc +rm %{buildroot}/%{_libdir}/syslog-ng/libtest/libsyslog-ng-test.a + +# remove unused service file +rm %{buildroot}/usr/lib/systemd/system/syslog-ng@.service + +# %check +# LD_LIBRARY_PATH=%{buildroot}/%{_libdir}:%{buildroot}/%{_libdir}/%{name} VERBOSE=1 make check + +%post +ldconfig +%systemd_post syslog-ng.service + +%preun +%systemd_preun syslog-ng.service + +%postun +ldconfig +%systemd_postun_with_restart syslog-ng.service + + +%triggerun -- syslog-ng < 3.2.3 +if /sbin/chkconfig --level 3 %{name} ; then + /bin/systemctl enable %{name}.service >/dev/null 2>&1 || : +fi + + +%triggerin -- vim-common +VIMVERNEW=`rpm -q --qf='%%{epoch}:%%{version}\n' vim-common | sort | tail -n 1 | sed -e 's/[0-9]*://' | sed -e 's/\.[0-9]*$//' | sed -e 's/\.//'` +[ -d %{_datadir}/vim/vim${VIMVERNEW}/syntax ] && \ + cd %{_datadir}/vim/vim${VIMVERNEW}/syntax && \ + ln -sf ../../../%{name}/syslog-ng.vim . || : + +%triggerun -- vim-common +VIMVEROLD=`rpm -q --qf='%%{epoch}:%%{version}\n' vim-common | sort | head -n 1 | sed -e 's/[0-9]*://' | sed -e 's/\.[0-9]*$//' | sed -e 's/\.//'` +[ $2 = 0 ] && rm -f %{_datadir}/vim/vim${VIMVEROLD}/syntax/syslog-ng.vim || : + +%triggerpostun -- vim-common +VIMVEROLD=`rpm -q --qf='%%{epoch}:%%{version}\n' vim-common | sort | head -n 1 | sed -e 's/[0-9]*://' | sed -e 's/\.[0-9]*$//' | sed -e 's/\.//'` +VIMVERNEW=`rpm -q --qf='%%{epoch}:%%{version}\n' vim-common | sort | tail -n 1 | sed -e 's/[0-9]*://' | sed -e 's/\.[0-9]*$//' | sed -e 's/\.//'` +if [ $1 = 1 ]; then + rm -f %{_datadir}/vim/vim${VIMVEROLD}/syntax/syslog-ng.vim || : + [ -d %{_datadir}/vim/vim${VIMVERNEW}/syntax ] && \ + cd %{_datadir}/vim/vim${VIMVERNEW}/syntax && \ + ln -sf ../../../%{name}/syslog-ng.vim . || : +fi + + +%files +%doc AUTHORS COPYING NEWS.md +# %doc doc/security/*.txt +%doc contrib/{relogger.pl,syslog2ng,syslog-ng.conf.doc} + +%dir %{_sysconfdir}/%{name} +%dir %{_sysconfdir}/%{name}/conf.d +%dir %{_sysconfdir}/%{name}/patterndb.d +%config(noreplace) %{_sysconfdir}/%{name}/%{name}.conf +%config(noreplace) %{_sysconfdir}/%{name}/scl.conf +%config(noreplace) %{_sysconfdir}/logrotate.d/syslog +%{_unitdir}/%{name}.service + +%dir %{_sharedstatedir}/%{name} +%{_sbindir}/%{name} +%{_sbindir}/%{name}-debun +%{_sbindir}/syslog-ng-ctl +%{_bindir}/loggen +%{_bindir}/pdbtool +%{_bindir}/dqtool +%{_bindir}/update-patterndb +%{_libdir}/lib%{name}-3.12.so.* +%{_libdir}/libevtlog-3.12.so.* +%{_libdir}/%{name}/*.so +%exclude %{_libdir}/%{name}/libafsql.so +%exclude %{_libdir}/%{name}/libafmongodb.so +%exclude %{_libdir}/%{name}/libredis.so +%exclude %{_libdir}/%{name}/libafsmtp.so +%exclude %{_libdir}/%{name}/libgeoip-plugin.so +%exclude %{_libdir}/%{name}/libgeoip2-plugin.so +%exclude %{_libdir}/%{name}/libriemann.so +%exclude %{_libdir}/%{name}/libhttp.so +%exclude %{_libdir}/%{name}/libmod-python.so +%exclude %{_libdir}/%{name}/libmod-java.so + +%dir %{_datadir}/%{name} +%{_datadir}/%{name}/syslog-ng.vim +%ghost %{_datadir}/vim/ + +# scl files +%{_datadir}/%{name}/include/ + +# uhm, some better places for those? +%{_datadir}/%{name}/xsd/ + +%{_mandir}/man1/loggen.1* +%{_mandir}/man1/pdbtool.1* +%{_mandir}/man1/dqtool.1* +%{_mandir}/man1/syslog-ng-debun.1* +%{_mandir}/man1/syslog-ng-ctl.1* +%{_mandir}/man5/syslog-ng.conf.5* +%{_mandir}/man8/syslog-ng.8* + +%files libdbi +%{_libdir}/%{name}/libafsql.so + +%files mongodb +%{_libdir}/%{name}/libafmongodb.so + +%files redis +%{_libdir}/%{name}/libredis.so + +%files smtp +%{_libdir}/%{name}/libafsmtp.so + +%files java +%attr(755,root,root) %{_libdir}/syslog-ng/libmod-java.so +%dir %{_libdir}/%{name}/java-modules/ +%{_libdir}/%{name}/java-modules/* + +%files geoip +%{_libdir}/%{name}/libgeoip-plugin.so +%{_libdir}/%{name}/libgeoip2-plugin.so + +%files riemann +%{_libdir}/%{name}/libriemann.so + +%files http +%{_libdir}/%{name}/libhttp.so + +%files python +/usr/lib/python2.7/site-packages/syslogng-1.0-py2.7.egg-info +%dir /usr/lib/python2.7/site-packages/syslogng/ +%dir /usr/lib/python2.7/site-packages/syslogng/debuggercli/ +/usr/lib/python2.7/site-packages/syslogng/* +/usr/lib/python2.7/site-packages/syslogng/debuggercli/* +%{_libdir}/%{name}/libmod-python.so + +%files devel +%{_libdir}/libsyslog-ng.so +%{_libdir}/libevtlog.so +%{_libdir}/libsyslog-ng-native-connector.a +%{_includedir}/%{name}/ +%{_libdir}/pkgconfig/syslog-ng.pc +%{_libdir}/pkgconfig/syslog-ng-native-connector.pc +%{_libdir}/pkgconfig/syslog-ng-add-contextual-data.pc +%{_datadir}/%{name}/tools/ + +%changelog +* Thu Sep 21 2017 Peter Czanik - 3.12.1-1 +- update to 3.12.1 +- re-enabled AMQP (does not fix compilation on Fedora) + +* Wed Sep 13 2017 Peter Czanik - 3.11.1-5 +- update to latest git head +- disable AMQP (rabbitmq) support temporarily + +* Wed Jul 26 2017 Peter Czanik - 3.11.1-2 +- update to 3.11.1 +- commented out "remove rpath" fixes for now + +* Mon Jun 19 2017 Peter Czanik - 3.10.1-1 +- update to 3.10.1 + +* Tue Jan 17 2017 Peter Czanik - 3.9.1-2 +- update to git head +- rename libcurl.so to libhttp.so +- add libtfgetent.so + +* Fri Dec 23 2016 Peter Czanik - 3.9.1-1 +- update to 3.9.1 + +* Fri Dec 2 2016 Peter Czanik - 3.8.1-3 +- update to git head +- add pkgconfig file for add-contextual-data + +* Tue Sep 6 2016 Peter Czanik - 3.8.1-2 +- move curl (HTTP) support into a subpackage + to reduce number of dependencies in core package +- re-enable riemann support +- use local cache of JAR dependencies + (no Internet necessary) + +* Thu Aug 25 2016 Peter Czanik - 3.8.1-1 +- update to 3.8.1 +- enable curl (HTTP) support +- JAR filelist changes + +* Thu Jul 28 2016 Peter Czanik - 3.8.0beta1-1 +- update to 3.8 beta1 + +* Fri Mar 18 2016 Peter Czanik - 3.8.0alpha0-1 +- disable riemann to ease test builds +- update to 3.8 git head +- remove syslog-ng-3.4.0beta1-tests-functional-control.py.patch +- remove syslog-ng-3.3.6-tests-functional-sql-test.patch +- bump config version +- disable "make check" (pylint fails) + +* Thu Nov 5 2015 Peter Czanik - 3.7.2-2 +- added missing "Obsoletes: syslog-ng-json" as JSON support + is now moved to the core + +* Wed Oct 28 2015 Peter Czanik - 3.7.2-1 +- update to 3.7.2 + +* Tue Aug 18 2015 Peter Czanik - 3.7.1-2 +- update to 3.7.1 +- require syslog-ng-java-hack for building +- hack Makefile to disable failing test +- add path to gradle-2.6 + +* Thu Jul 23 2015 Peter Czanik - 3.7.0beta2-1 +- update to 3.7.0beta2 +- re-enable man pages +- require gradle (for Java modules) +- update syslog-ng.service patch + +* Tue Apr 21 2015 Peter Czanik - 3.7.0beta1-5 +- update to 3.7.0beta1 +- temp: disable man pages (missing from release) +- temp: disable smp build +- add python support +- add java support +- move json support to the core package due to system() +- update configuration version to 3.7 +- add BuildRequires to fix "make check" + +* Tue Dec 16 2014 Peter Czanik - 3.6.2-1 +- update to syslog-ng 3.6.2 (bugfix release) +- disabled "make check" temporarily due to a false positive + +* Fri Nov 14 2014 Peter Czanik - 3.6.1-1 +- update to syslog-ng 3.6.1 +- enable riemann-c-client support + +* Fri Sep 26 2014 Peter Czanik - 3.6.0rc1-1 +- update to syslog-ng 3.6.0rc1 +- removed --enable-pcre, as it's always required +- configuration file version bump to 3.6 + +* Thu Aug 21 2014 Kevin Fenzi - 3.5.6-3 +- Rebuild for rpm bug 1131960 + +* Mon Aug 18 2014 Fedora Release Engineering - 3.5.6-2 +- Rebuilt for https://fedoraproject.org/wiki/Fedora_21_22_Mass_Rebuild + +* Tue Aug 5 2014 Peter Czanik - 3.5.6-1 +- Update to syslog-ng 3.5.6 (bugfix release) + +* Wed Jul 23 2014 Peter Czanik - 3.5.5-1 +- Update to syslog-ng 3.5.5 (bugfix release) + +* Sun Jun 08 2014 Fedora Release Engineering - 3.5.4.1-3 +- Rebuilt for https://fedoraproject.org/wiki/Fedora_21_Mass_Rebuild + +* Fri May 23 2014 Peter Czanik - 3.5.4.1-2 +- enable SCL in syslog-ng.conf +- use system() in syslog-ng.conf +- move JSON, SMTP and GeoIP support to separate subpackages + due to dependencies + +* Tue Mar 18 2014 Jose Pedro Oliveira - 3.5.4.1-1 +- Update to syslog-ng 3.5.4.1 + +* Sat Feb 22 2014 Jose Pedro Oliveira - 3.5.3-4 +- Upstream patch: add support for the Tzif3 timezone files + (syslog-ng-3.5.3-support-Tzif3-format-timezone-files.patch) + +* Tue Feb 11 2014 Matthias Runge - 3.5.3-3 +- rebuild due libdbi bump + +* Wed Jan 22 2014 Jose Pedro Oliveira - 3.5.3-2 +- Bump configuration file version to 3.5 +- Rebuild for libdbi soname bump + +* Wed Dec 25 2013 Jose Pedro Oliveira - 3.5.3-1 +- Update to syslog-ng 3.5.3 + +* Fri Nov 29 2013 Jose Pedro Oliveira - 3.5.2-1 +- Update to syslog-ng 3.5.2 + +* Thu Nov 21 2013 Jose Pedro Oliveira - 3.5.1-2 +- New upstream package description (Balabit; Peter Czanik) + +* Mon Nov 4 2013 Jose Pedro Oliveira - 3.5.1-1 +- Update to syslog-ng 3.5.1 (first stable release of branch 3.5) +- New build requirement: libxslt (--enable-man-pages) + +* Thu Oct 24 2013 Jose Pedro Oliveira - 3.5.0-0.rc1.1 +- Update to syslog-ng 3.5.0 rc 1 +- Re-enabled parallel build + +* Sat Oct 19 2013 Jose Pedro Oliveira - 3.5.0-0.beta3.1 +- Update to syslog-ng 3.5.0 beta 3 +- Updated source0 URL +- syslog-ng.service patch rebased (syslog-ng-3.5.0-syslog-ng.service.patch) +- New BR: systemd-devel +- New subpackage: syslog-ng-redis (new BR: hiredis-devel) +- Disabled parallel build (currently fails) + +* Thu Oct 17 2013 Jose Pedro Oliveira - 3.4.4-1 +- Update to syslog-ng 3.4.4 + +* Tue Aug 13 2013 Jose Pedro Oliveira - 3.4.3-1 +- Update to syslog-ng 3.4.3 + +* Sun Aug 04 2013 Fedora Release Engineering - 3.4.1-2 +- Rebuilt for https://fedoraproject.org/wiki/Fedora_20_Mass_Rebuild + +* Thu Jan 31 2013 Jose Pedro Oliveira - 3.4.1-1 +- Update to syslog-ng 3.4.1 (first stable version of branch 3.4) + +* Sat Jan 19 2013 Jose Pedro Oliveira - 3.4.0-0.1.rc2 +- Update to syslog-ng 3.4.0 rc2 +- Bumped the eventlog version requirement to 0.2.13 +- Bumped the ivykis version requirement to 0.36.1 +- New build requirement: GeoIP-devel (--enable-geoip) +- New build requirement: libuuid-devel +- New build requirement: libesmtp-devel (--enable-smtp) +- New build requirement: libmongo-client--devel (--with-libmongo-client=system) +- Splitted the mongodb support into a subpackage +- Rebased the syslog-ng-3.2.5-tests-functional-control.py.patch patch +- Disable the AMQP support (until it builds with an external librabbitmq library) + +* Sat Jan 19 2013 Jose Pedro Oliveira - 3.3.8-2 +- Corrected bogus dates in the changelog section + +* Thu Jan 17 2013 Jose Pedro Oliveira - 3.3.8-1 +- Update to 3.3.8 +- Use the new --with-embedded-crypto configure's option in order to + avoid shipping a ld.so.conf file + +* Fri Nov 30 2012 Jose Pedro Oliveira - 3.3.7-3 +- Introduce the new systemd-rpm macros (#850332) + +* Fri Nov 30 2012 Jose Pedro Oliveira - 3.3.7-2 +- Rename ivykis-ver to ivykis_ver (invalid character) + +* Tue Oct 30 2012 Jose Pedro Oliveira - 3.3.7-1 +- Update to 3.3.7 + +* Thu Oct 18 2012 Jose Pedro Oliveira - 3.3.7-0.1.rc2 +- Update to 3.3.7 RC2 (aka syslog-ng-3.3.6.91-20121008-v3.3.6.91.tar.gz) +- Create and own the /etc/syslog-ng/conf.d directory +- syslog-ng.conf: now sources additional configuration files located at + /etc/syslog-ng/conf.d ; these files must have a .conf extension +- syslog-ng.conf: make the s_sys source more compliant with the one + generated by generate-system-source.sh +- syslog-ng.conf: retab +- Bump the minimal ivykis version requirement to 0.30.4 + +* Mon Aug 27 2012 Jose Pedro Oliveira - 3.3.6-1 +- Update to 3.3.6 +- Now builds with an external (and unpatched) version of the ivykis library (>= 0.30.1) +- Enable JSON support (BR json-c-devel). +- Enable Linux caps (BR libcap-devel). +- BR bison and flex +- syslog-ng.conf: rename the now obsolete long_hostnames option to chain_hostnames +- install a ld.so conf file so that the private shared library - + libsyslog-ng-crypto - can be found. +- Unconditionally run "systemctl daemon-reload" on the %%postun scriptlet + (https://bugzilla.redhat.com/show_bug.cgi?id=700766#c25) + +* Sat Jul 21 2012 Fedora Release Engineering - 3.2.5-16 +- Rebuilt for https://fedoraproject.org/wiki/Fedora_18_Mass_Rebuild + +* Tue Jun 19 2012 Jose Pedro Oliveira - 3.2.5-15 +- Remove the ExecStartPre line from the service file (#833551) + +* Thu Apr 26 2012 Jose Pedro Oliveira - 3.2.5-14 +- Improve syslog-ng-3.2.5-tests-functional-sql-test.patch + +* Thu Apr 26 2012 Jose Pedro Oliveira - 3.2.5-13 +- Add a conflict with the filesystem package (due to the /usr-move) + +* Mon Apr 16 2012 Jose Pedro Oliveira - 3.2.5-12 +- No longer disable the SSL tests. + +* Mon Apr 16 2012 Jose Pedro Oliveira - 3.2.5-11 +- Correct the path in syslog-ng-3.2.5-syslog-ng.service.patch. + +* Mon Apr 16 2012 Jose Pedro Oliveira - 3.2.5-10 +- Enable SSL. + +* Sun Apr 15 2012 Jose Pedro Oliveira - 3.2.5-9 +- Fedora 17’s unified filesystem (/usr-move) + http://fedoraproject.org/wiki/Features/UsrMove + +* Sun Apr 15 2012 Jose Pedro Oliveira - 3.2.5-8 +- Resolve the file conflict with rsyslog (#811058). +- Don't tag the syslog-ng.service file as a configuration file. + +* Fri Mar 30 2012 Jon Ciesla - 3.2.5-7 +- Rebuild for updated libnet. + +* Fri Feb 10 2012 Petr Pisar - 3.2.5-6 +- Rebuild against PCRE 8.30 + +* Sun Jan 15 2012 Jose Pedro Oliveira - 3.2.5-5 +- Improve test coverage: remove a couple of errors and really run the SQL test. + Patches: syslog-ng-3.2.5-tests-functional-control.py.patch and + syslog-ng-3.2.5-tests-functional-sql-test.patch. + +* Sat Jan 14 2012 Fedora Release Engineering - 3.2.5-4 +- Rebuilt for https://fedoraproject.org/wiki/Fedora_17_Mass_Rebuild + +* Thu Dec 15 2011 Jose Pedro Oliveira - 3.2.5-3 +- Drop the sysconfig configuration file (use syslog-ng.service instead) +- Make the syslog-ng.service file a configuration file +- Drop Vim 7.2 support + +* Wed Dec 14 2011 Jose Pedro Oliveira - 3.2.5-2 +- Fix the freeze problems caused by the /dev/log unix socket type mismatch (#742624) + + syslog-ng.conf: change /dev/log from unix-stream to unix-dgram + + upstream patch syslog-ng-3.3.4-afunix.c-diagnostic-messages.patch +- Move the SCL files to the main RPM (#742624 comments >= 28) + +* Tue Nov 1 2011 Jose Pedro Oliveira - 3.2.5-1 +- Update to 3.2.5 + +* Tue Oct 25 2011 Jose Pedro Oliveira - 3.2.4-11 +- New 3.2.5 pre-release tarball + https://lists.balabit.hu/pipermail/syslog-ng/2011-October/017491.html +- Updated patch syslog-ng-3.2.5-syslog-ng.service.patch + +* Sat Oct 22 2011 Jose Pedro Oliveira - 3.2.4-10 +- 3.2.5 pre-release: changelog and tarball from + https://lists.balabit.hu/pipermail/syslog-ng/2011-October/017462.html + Patches dropped: + syslog-ng-3.2.4-systemd-acquired-fd.patch + syslog-ng-3.2.4-chain-hostnames-processing.patch +- New configure option: --with-systemdsystemunitdir +- Patched the included syslog-ng.service file + syslog-ng-3.2.5-syslog-ng.service.patch + +* Mon Oct 10 2011 Jose Pedro Oliveira - 3.2.4-9 +- Patch syslog-ng-3.2.4-systemd-acquired-fd.patch (see bug #742624) + +* Mon Oct 10 2011 Jose Pedro Oliveira - 3.2.4-8 +- disable linux-caps support for the time being (see bug #718439) + +* Wed Aug 31 2011 Jose Pedro Oliveira - 3.2.4-7 +- Fixed the syslog-ng.service configuration file: + * Sockets setting (#734569) + * StandardOutput setting (#734591) + +* Mon Jun 27 2011 Jose Pedro Oliveira - 3.2.4-6 +- Patch syslog-ng-3.2.4-chain-hostnames-processing.patch (#713965) + +* Mon Jun 20 2011 Jose Pedro Oliveira - 3.2.4-5 +- Enabled support for capability management (--enable-linux-caps) + +* Tue May 17 2011 Jose Pedro Oliveira - 3.2.4-4 +- Enabled SQL support (subpackage syslog-ng-libdbi) + +* Mon May 16 2011 Jose Pedro Oliveira - 3.2.4-3 +- Updated the homepage URL +- Syslog-ng data directory in %%{_datadir}/%%{name} +- Include the main library header files in the devel subpackage + +* Thu May 12 2011 Jose Pedro Oliveira - 3.2.4-2 +- No need to create the directory /etc/syslog-ng in the install section +- Enable the test suite (but excluding the SQL and SSL tests) + +* Wed May 11 2011 Jose Pedro Oliveira - 3.2.4-1 +- Update to 3.2.4 + +* Mon May 9 2011 Jose Pedro Oliveira - 3.2.3-5 +- Overrided the default _localstatedir value (configure --localstatedir) + (value hardcoded in update-patterndb) +- Manually created the patterndb.d configuration directory (update-patterndb) + (see also https://bugzilla.balabit.com/show_bug.cgi?id=119 comments >= 4) +- Dropped support for Vim 7.0 and 7.1 + +* Mon May 9 2011 Jose Pedro Oliveira - 3.2.3-4 +- Dropped the bison and flex build requirements +- Corrected a couple of macro references in changelog entries (rpmlint) + +* Mon May 9 2011 Jose Pedro Oliveira - 3.2.3-3 +- Added the build requirement systemd-units (macro %%_unitdir) + https://fedoraproject.org/wiki/Packaging:Guidelines:Systemd +- Dropped the redefinition of the %%_localstatedir macro +- Use %%global instead of %%define +- Minor modifications of the %%post, %%preun and %%postun scripts + https://fedoraproject.org/wiki/Packaging:ScriptletSnippets#Systemd +- Expanded tabs to spaces (also added a vim modeline) + +* Fri May 6 2011 Jose Pedro Oliveira - 3.2.3-2 +- Fix systemd-related scriptlets (Bill Nottingham) +- Explicitly add --enable-systemd to configure's command line + +* Mon May 2 2011 Jose Pedro Oliveira - 3.2.3-1 +- updated to 3.2.3 final +- cleaned the sysconfig file + +* Thu Apr 28 2011 Jose Pedro Oliveira - 3.2.3-0.20110424.4 +- downgrade the pcre minimal required version from 7.3 to 6.1 (#651823#c26) +- better compliance with the package guidelines + (https://fedoraproject.org/wiki/Packaging:ScriptletSnippets#Systemd) + +* Thu Apr 28 2011 Matthias Runge - 3.2.3-0.20110424.3 +- honor pidfile +- disable ssl +- disable sql + +* Tue Apr 26 2011 Matthias Runge - 3.2.3-0.20110424.2 +- drop support for fedora without systemd + +* Mon Apr 25 2011 Jose Pedro Oliveira - 3.2.3-0.20110424.1 +- change NVR to alert users that we have been using a syslog-ng v3.2 git snapshot + (for systemd support) + +* Mon Apr 25 2011 Jose Pedro Oliveira - 3.2.2-4 +- re-introduces the "Provides: syslog" (#651823 comments 13, 15 and 21) +- rename the logrotate.d file back to syslog (#651823 comments 12, 15, 16 and 21) +- cleans the sysconfig and logrotate file mess (#651823 comments 17, 20 and 21) +- spec code cleanup (#651823 comments 10 and 11) +- dropped duplicated eventlog-devel BR + +* Thu Apr 21 2011 Matthias Runge - 3.2.2-3 +- systemd fixup +- more spec file cleanup, +- incorporate fixes from Jose Pedro Oliveira (#651823 comments 7 and 8) + +* Wed Apr 20 2011 Matthias Runge - 3.2.2-2 +- spec cleanup + +* Wed Apr 13 2011 Matthias Runge - 3.2.2-1 +- update to 3.2.2 +- built from git snapshot + +* Wed Apr 06 2011 Matthias Runge - 3.2.1-3 +- install to /sbin +- native systemd start script + +* Thu Mar 17 2011 Matthias Runge - 3.2.1-2 +- finally move libs to correct place +- split out -devel subpackage + +* Fri Mar 04 2011 Matthias Runge - 3.2.1-1 +- update to syslog-ng 3.2.1 + +* Sat Jul 24 2010 Doug Warner - 3.1.1-1 +- update for syslog-ng 3.1.1 +- supports the new syslog protocol standards +- log statements can be embedded into each other +- the encoding of source files can be set for proper character conversion +- can read, process, and rewrite structured messages (e.g., Apache webserver + logs) using templates and regular expressions +- support for patterndb v2 and v3 format, along with a bunch of new + parsers: ANYSTRING, IPv6, IPvANY and FLOAT. +- added a new "pdbtool" utility to manage patterndb files: convert them + from v1 or v2 format, merge mulitple patterndb files into one and look + up matching patterns given a specific message. +- support for message tags: tags can be assigned to log messages as they + enter syslog-ng: either by the source driver or via patterndb. + Later it these tags can be used for efficient filtering. +- added support for rewriting structured data +- added pcre support in the binary packages of syslog-ng + +* Tue Sep 15 2009 Ray Van Dolson - 2.1.4-8 +- Adjust eventlog build requirement + +* Tue Sep 15 2009 Ray Van Dolson - 2.1.4-7 +- Branch sync + +* Tue Sep 15 2009 Ray Van Dolson - 2.1.4-6 +- Branch sync + +* Tue Sep 15 2009 Ray Van Dolson - 2.1.4-5 +- Rebuilding for tag issue + +* Thu Aug 20 2009 Ray Van Dolson - 2.1.4-4 +- libnet linking (bug#518150) + +* Tue Aug 18 2009 Ray Van Dolson - 2.1.4-3 +- Init script fix (bug#517339) + +* Sun Jul 26 2009 Fedora Release Engineering - 2.1.4-2 +- Rebuilt for https://fedoraproject.org/wiki/Fedora_12_Mass_Rebuild + +* Tue Mar 24 2009 Douglas E. Warner - 2.1.4-1 +- update to 2.1.4 +- enabling mixed linking to compile only non-system libs statically +- lots of packaging updates to be able to build on RHEL4,5, Fedora9+ and be + parallel-installable with rsyslog and/or sysklogd on those platforms +- removing BR for flex & byacc to try to prevent files from being regenerated +- fixing build error with cfg-lex.l and flex 2.5.4 +- Fixed a possible DoS condition triggered by a destination port unreachable + ICMP packet received from a UDP destination. syslog-ng started eating all + available memory and CPU until it crashed if this happened. +- Fixed the rate at which files regular were read using the file() source. +- Report connection breaks as a write error instead of reporting POLLERR as + the write error path reports more sensible information in the logs. + +* Wed Feb 25 2009 Fedora Release Engineering - 2.0.10-2 +- Rebuilt for https://fedoraproject.org/wiki/Fedora_11_Mass_Rebuild + +* Tue Dec 02 2008 Douglas E. Warner 2.0.10-1 +- update to 2.0.10 +- fix for CVE-2008-5110 + +* Mon Sep 15 2008 Peter Vrabec 2.0.8-3 +- do not conflicts with rsyslog, both rsyslog and syslog-ng use + same pidfile and logrotate file (#441664) + +* Sat Sep 6 2008 Tom "spot" Callaway 2.0.8-2 +- fix license tag + +* Thu Jan 31 2008 Douglas E. Warner 2.0.8-1 +- updated to 2.0.8 +- removed logrotate patch + +* Tue Jan 29 2008 Douglas E. Warner 2.0.7-2 +- added patch from git commit a8b9878ab38b10d24df7b773c8c580d341b22383 + to fix log rotation (bug#430057) + +* Tue Jan 08 2008 Douglas E. Warner 2.0.7-1 +- updated to 2.0.7 +- force regeneration to avoid broken paths from upstream (#265221) +- adding loggen binary + +* Mon Dec 17 2007 Douglas E. Warner 2.0.6-1 +- updated to 2.0.6 +- fixes DoS in ZSA-2007-029 + +* Thu Nov 29 2007 Peter Vrabec 2.0.5-3 +- add conflicts (#400661) + +* Wed Aug 29 2007 Fedora Release Engineering - 2.0.5-2 +- Rebuild for selinux ppc32 issue. + +* Thu Jul 26 2007 Jose Pedro Oliveira - 2.0.5-1 +- Update to 2.0.5 + +* Thu Jun 7 2007 Jose Pedro Oliveira - 2.0.4-4 +- Add support for vim 7.1. + +* Thu May 31 2007 Jose Pedro Oliveira - 2.0.4-3 +- Increase the number of unix-stream max-connections (10 -> 32). + +* Sat May 26 2007 Jose Pedro Oliveira - 2.0.4-2 +- New upstream download location + (https://lists.balabit.hu/pipermail/syslog-ng/2007-May/010258.html) + +* Tue May 22 2007 Jose Pedro Oliveira - 2.0.4-1 +- Update to 2.0.4. + +* Mon Mar 26 2007 Jose Pedro Oliveira - 2.0.3-1 +- Update to 2.0.3. + +* Fri Mar 23 2007 Jose Pedro Oliveira - 2.0.3-0.20070323 +- Update to latest snapshot (2007-03-23). + +* Fri Mar 9 2007 Jose Pedro Oliveira - 2.0.3-0.20070309 +- Enable support for TCP wrappers (--enable-tcp-wrapper). +- Optional support for spoofed source addresses (--enable-spoof-source) + (disabled by default; build requires libnet). + +* Sun Feb 25 2007 Jose Pedro Oliveira - 2.0.2-2 +- Dynamic link glib2 and eventlog (--enable-dynamic-linking). + For Fedora Core 6 (and above) both packages install their dynamic + libraries in /lib. + +* Mon Jan 29 2007 Jose Pedro Oliveira - 2.0.2-1 +- Update to 2.0.2. + +* Thu Jan 4 2007 Jose Pedro Oliveira - 2.0.1-1 +- Update to 2.0.1. + +* Fri Dec 15 2006 Jose Pedro Oliveira - 2.0.0-1 +- Updated the init script patch: LSB Description and Short-Description. + +* Fri Nov 3 2006 Jose Pedro Oliveira - 2.0.0-0 +- Update to 2.0.0. + +* Sun Sep 10 2006 Jose Pedro Oliveira - 1.6.11-3 +- Rebuild for FC6. + +* Sun Jun 4 2006 Jose Pedro Oliveira - 1.6.11-2 +- Install the vim syntax file. + +* Fri May 5 2006 Jose Pedro Oliveira - 1.6.11-1 +- Update to 1.6.11. + +* Sun Apr 2 2006 Jose Pedro Oliveira - 1.6.10-2 +- Build option to support the syslog-ng spoof-source feature + (the feature spoof-source is disabled by default). + +* Thu Mar 30 2006 Jose Pedro Oliveira - 1.6.10-1 +- Update to 1.6.10. +- The postscript documentation has been dropped (upstream). + +* Wed Feb 15 2006 Jose Pedro Oliveira - 1.6.9-3 +- Rebuild. + +* Mon Dec 19 2005 Jose Pedro Oliveira - 1.6.9-2 +- Provides syslog instead of sysklogd (#172885). + +* Wed Nov 30 2005 Jose Pedro Oliveira - 1.6.9-1 +- Build conflict statement + (see: https://lists.balabit.hu/pipermail/syslog-ng/2005-June/007630.html) + +* Wed Nov 23 2005 Jose Pedro Oliveira - 1.6.9-0 +- Update to 1.6.9. +- The libol support library is now included in the syslog-ng tarball. + +* Wed Jun 22 2005 Jose Pedro Oliveira - 1.6.8-2 +- BuildRequire which, since it's not part of the default buildgroup + (Konstantin Ryabitsev). + +* Fri May 27 2005 Jose Pedro Oliveira - 1.6.8-1 +- Update to 1.6.8. + +* Thu May 26 2005 Jose Pedro Oliveira - 1.6.7-3 +- Shipping the sysklogd logrotate file and using the same pidfile + as suggested by Jeremy Katz. +- Patching the init script: no default runlevels. +- Removed the triggers to handle the logrotate file (no longer needed). +- The SELinux use_syslogng boolean has been dropped (rules enabled). + +* Sat May 07 2005 Jose Pedro Oliveira - 1.6.7-2.fc4 +- Increased libol required version to 0.3.16 + (https://lists.balabit.hu/pipermail/syslog-ng/2005-May/007385.html). + +* Sat Apr 09 2005 Jose Pedro Oliveira - 0:1.6.7-0.fdr.1 +- Update to 1.6.7. +- The Red Hat/Fedora Core configuration files are now included in the + syslog-ng tarball (directory: contrib/fedora-packaging). + +* Fri Mar 25 2005 Jose Pedro Oliveira - 0:1.6.6-0.fdr.4 +- Logrotate file conflict: just comment/uncomment contents of the syslog + logrotate file using triggers. + +* Tue Feb 15 2005 Jose Pedro Oliveira - 0:1.6.6-0.fdr.3 +- Require logrotate. +- Documentation updates (upstream). + +* Sat Feb 05 2005 Jose Pedro Oliveira - 0:1.6.6-0.fdr.2 +- Added contrib/relogger.pl (missing in syslog-ng-1.6.6). +- Requires libol 0.3.15. +- Added %%trigger scripts to handle the logrotate file. + +* Fri Feb 04 2005 Jose Pedro Oliveira - 0:1.6.6-0.fdr.1 +- Update to 1.6.6. +- Patches no longer needed. + +* Fri Feb 04 2005 Jose Pedro Oliveira - 0:1.6.5-0.fdr.7 +- Took ownership of the configuration directory (/etc/syslog-ng/). +- Updated the syslog-ng(8) manpage (upstream patch). +- Updated the configuration file: /proc/kmsg is a file not a pipe. +- Patched two contrib files: syslog2ng and syslog-ng.conf.RedHat. +- Logrotate file inline replacement: perl --> sed (bug 1332 comment 23). + +* Tue Jan 25 2005 Jose Pedro Oliveira - 0:1.6.5-0.fdr.6 +- Logrotate problem: only one logrotate file for syslog and syslog-ng. +- Configuration file: don't sync d_mail destination (/var/log/maillog). + +* Mon Jan 24 2005 Jose Pedro Oliveira - 0:1.6.5-0.fdr.5 +- SIGHUP handling upstream patch (syslog-ng-1.6.5+20050121.tar.gz). +- Static linking /usr libraries (patch already upstream). + +* Thu Sep 30 2004 Jose Pedro Oliveira - 0:1.6.5-0.fdr.4 +- make: do not strip the binaries during installation (install vs install-strip) + (bug 1332 comment 18). +- install: preserve timestamps (option -p) (bug 1332 comment 18). + +* Wed Sep 1 2004 Jose Pedro Oliveira 0:1.6.5-0.fdr.3 +- use the tcp_wrappers static library instead (bug 1332 comment 15). + +* Wed Sep 1 2004 Jose Pedro Oliveira 0:1.6.5-0.fdr.2 +- added missing build requirement: flex (bug 1332 comment 13). + +* Wed Aug 25 2004 Jose Pedro Oliveira 0:1.6.5-0.fdr.1 +- update to 1.65. +- removed the syslog-ng.doc.patch patch (already upstream). +- removed the syslog-ng.conf.solaris documentation file. + +* Wed Apr 21 2004 Jose Pedro Oliveira 0:1.6.2-0.fdr.3 +- removed Conflits: +- changed the %%post and %%preun scripts +- splitted Requires( ... , ... ) into Requires( ... ) + +* Fri Mar 5 2004 Jose Pedro Oliveira 0:1.6.2-0.fdr.2 +- corrected the source URL + +* Sat Feb 28 2004 Jose Pedro Oliveira 0:1.6.2-0.fdr.1 +- changed packaged name to be compliant with fedora.us naming conventions + +* Fri Feb 27 2004 Jose Pedro Oliveira 0:1.6.2-0.fdr.0.2 +- updated to version 1.6.2 +- undo "Requires: tcp_wrappers" - tcp_wrappers is a static lib + +* Sat Feb 7 2004 Jose Pedro Oliveira 0:1.6.1-0.fdr.2 +- make %{?_smp_mflags} +- Requires: tcp_wrappers + +* Sat Jan 10 2004 Jose Pedro Oliveira 0:1.6.1-0.fdr.1 +- first release for fedora.us + +* Fri Jan 9 2004 Jose Pedro Oliveira 1.6.1-1.1tux +- updated to version 1.6.1 + +* Tue Oct 7 2003 Jose Pedro Oliveira 1.6.0rc4-1.1tux +- updated to version 1.6.0rc4 + +* Tue Aug 26 2003 Jose Pedro Oliveira 1.6.0rc3-1.4tux +- installation scripts improved +- conflits line + +* Sat Aug 16 2003 Jose Pedro Oliveira 1.6.0rc3-1.3tux +- install-strip + +* Tue Jul 22 2003 Jose Pedro Oliveira 1.6.0rc3-1.2tux +- missing document: contrib/syslog-ng.conf.doc + +* Thu Jun 12 2003 Jose Pedro Oliveira 1.6.0rc3-1.1tux +- Version 1.6.0rc3 + +* Sat Apr 12 2003 Jose Pedro Oliveira 1.6.0rc2 snapshot +- Reorganized specfile +- Corrected the scripts (%%post, %%postun, and %%preun) +- Commented the mysql related lines; create an option for future inclusion + +* Thu Feb 27 2003 Richard E. Perlotto II 1.6.0rc1-1 +- Updated for new version + +* Mon Feb 17 2003 Richard E. Perlotto II 1.5.26-1 +- Updated for new version + +* Fri Dec 20 2002 Richard E. Perlotto II 1.5.24-1 +- Updated for new version + +* Fri Dec 13 2002 Richard E. Perlotto II 1.5.23-2 +- Corrected the mass of errors that occured with rpmlint +- Continue to clean up for the helpful hints on how to write to a database + +* Sun Dec 08 2002 Richard E. Perlotto II 1.5.23-1 +- Updated file with notes and PGP signatures + +# vim:set ai ts=4 sw=4 sts=4 et: diff -Nru syslog-ng-3.11.1/README.md syslog-ng-3.13.2/README.md --- syslog-ng-3.11.1/README.md 2017-07-31 09:05:32.000000000 +0000 +++ syslog-ng-3.13.2/README.md 2017-12-06 06:39:39.000000000 +0000 @@ -16,7 +16,7 @@ file: ``` -@version: 3.11 +@version: 3.13 @include "scl.conf" log { @@ -28,7 +28,7 @@ This one also processes logs from the network (TCP/514 by default): ``` -@version: 3.11 +@version: 3.13 @include "scl.conf" log { @@ -42,7 +42,7 @@ Structured/application logging, local submission via JSON, output in key=value format. ``` -@version: 3.11 +@version: 3.13 @include "scl.conf" log { @@ -130,6 +130,9 @@ $ ./configure && make && make install +If you don't have a configure script (because of cloning from git, for example), +run `./autogen.sh` to generate it. + Some of the functionality is compiled only in case the required development libraries are present. The configure script displays a summary of enabled features at the end of its run. diff -Nru syslog-ng-3.11.1/scl/cim/adapter.conf syslog-ng-3.13.2/scl/cim/adapter.conf --- syslog-ng-3.11.1/scl/cim/adapter.conf 1970-01-01 00:00:00.000000000 +0000 +++ syslog-ng-3.13.2/scl/cim/adapter.conf 2017-12-06 06:39:39.000000000 +0000 @@ -0,0 +1,26 @@ +############################################################################# +# Copyright (c) 2017 Balabit +# +# This program is free software; you can redistribute it and/or modify it +# under the terms of the GNU General Public License version 2 as published +# by the Free Software Foundation, or (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA +# +# As an additional exemption you are allowed to compile & link against the +# OpenSSL libraries as published by the OpenSSL project. See the file +# COPYING for details. +# +############################################################################# + + +application cim[syslog] { + parser { json-parser(prefix('.cim.') marker('@cim:')); }; +}; diff -Nru syslog-ng-3.11.1/scl/cisco/plugin.conf syslog-ng-3.13.2/scl/cisco/plugin.conf --- syslog-ng-3.11.1/scl/cisco/plugin.conf 2017-07-31 09:05:32.000000000 +0000 +++ syslog-ng-3.13.2/scl/cisco/plugin.conf 2017-12-06 06:39:39.000000000 +0000 @@ -128,3 +128,7 @@ }; }; }; + +application cisco[syslog-raw] { + parser { cisco-parser(); }; +}; diff -Nru syslog-ng-3.11.1/scl/default-network-drivers/plugin.conf syslog-ng-3.13.2/scl/default-network-drivers/plugin.conf --- syslog-ng-3.11.1/scl/default-network-drivers/plugin.conf 1970-01-01 00:00:00.000000000 +0000 +++ syslog-ng-3.13.2/scl/default-network-drivers/plugin.conf 2017-12-06 06:39:39.000000000 +0000 @@ -0,0 +1,86 @@ +############################################################################# +# Copyright (c) 2017 Balazs Scheidler +# Copyright (c) 2017 Balabit +# +# This program is free software; you can redistribute it and/or modify it +# under the terms of the GNU General Public License version 2 as published +# by the Free Software Foundation, or (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA +# +# As an additional exemption you are allowed to compile & link against the +# OpenSSL libraries as published by the OpenSSL project. See the file +# COPYING for details. +# +############################################################################# + +block source default-network-drivers( + udp-port(514) + tcp-port(514) + rfc5424-tls-port(6514) + rfc5424-tcp-port(601) + log-msg-size(65536) + flags()) { + + channel { + source { + network(transport(tcp) + port(`tcp-port`) + log-msg-size(`log-msg-size`) + flags(no-parse, `flags`)); + network(transport(udp) + port(`udp-port`) + log-msg-size(`log-msg-size`) + flags(no-parse, `flags`)); + }; + channel { + parser { app-parser(topic(syslog-raw) `__VARARGS__`); }; + flags(final); + }; + channel { + parser { + syslog-parser(flags(syslog-protocol)); + }; + channel { + parser { ewmm-parser(); }; + flags(final); + }; + channel { + parser { app-parser(topic(syslog) `__VARARGS__`); }; + flags(final); + }; + channel { + flags(final); + }; + flags(final); + }; + }; + + + channel { + source { + syslog(transport(tls) tls(`tls`) + port(`rfc5424-tls-port`) + flags(`flags`) + log-msg-size(`log-msg-size`)); + syslog(transport(tcp) + port(`rfc5424-tcp-port`) + flags(`flags`) + log-msg-size(`log-msg-size`)); + }; + channel { + parser { app-parser(topic(syslog) `__VARARGS__`); }; + flags(final); + }; + channel { + flags(final); + }; + }; +}; diff -Nru syslog-ng-3.11.1/scl/elasticsearch/plugin.conf syslog-ng-3.13.2/scl/elasticsearch/plugin.conf --- syslog-ng-3.11.1/scl/elasticsearch/plugin.conf 2017-07-31 09:05:32.000000000 +0000 +++ syslog-ng-3.13.2/scl/elasticsearch/plugin.conf 2017-12-06 06:39:39.000000000 +0000 @@ -36,7 +36,7 @@ ) { java( - class_path("`module-path`/java-modules/*.jar:`client_lib_dir`/*.jar") + class_path("`java-module-dir`/*.jar:`client_lib_dir`/*.jar") class_name("org.syslog_ng.elasticsearch.ElasticSearchDestination") option("index", `index`) option("type", `type`) @@ -80,7 +80,7 @@ ) { java( - class_path("`module-path`/java-modules/*.jar:`module-path`/java-modules/elastic-jest-client/*.jar:`client_lib_dir`/*.jar") + class_path("`java-module-dir`/*.jar:`java-module-dir`/elastic-jest-client/*.jar:`client_lib_dir`/*.jar") class_name("org.syslog_ng.elasticsearch_v2.ElasticSearchDestination") option("index", `index`) option("type", `type`) diff -Nru syslog-ng-3.11.1/scl/ewmm/ewmm.conf syslog-ng-3.13.2/scl/ewmm/ewmm.conf --- syslog-ng-3.11.1/scl/ewmm/ewmm.conf 1970-01-01 00:00:00.000000000 +0000 +++ syslog-ng-3.13.2/scl/ewmm/ewmm.conf 2017-12-06 06:39:39.000000000 +0000 @@ -0,0 +1,65 @@ +############################################################################# +# Copyright (c) 2017 Balabit +# +# This program is free software; you can redistribute it and/or modify it +# under the terms of the GNU General Public License version 2 as published +# by the Free Software Foundation, or (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA +# +# As an additional exemption you are allowed to compile & link against the +# OpenSSL libraries as published by the OpenSSL project. See the file +# COPYING for details. +# +############################################################################# + +# This is the experimental transport for transferring messages in whole +# between syslog-ng instances. +# +# EWMM stands for "enterprise wide message model", which is also kind of an +# experimental name, but so far it stuck. +# +# Format: +# - program name should be "@syslog-ng" which is used to recognize this message +# - name-values are encoded as JSON in the MSG field +# - name-value pairs that start with "._" should be hop-by-hop fields only +# to transmit syslog-ng <> syslog-ng information and is not considered +# part of the original message. +# - regexp numeric matches ($0 .. $255) are not transmitted +# + +block parser ewmm-parser() { + channel { + filter { program("@syslog-ng" type(string)); }; + + # NOTE: this will probably overwrite all builtin + # name value pairs, including $MSG + rewrite { + unset(value("PROGRAM")); + unset(value("RAWMSG")); + }; + parser { json-parser(); }; + parser { tags-parser(template("${._TAGS}")); }; + rewrite { + # remove hop-by-hop fields + unset(value("._TAGS")); + }; + }; +}; + +template-function "format-ewmm" "<$PRI>1 $ISODATE $LOGHOST @syslog-ng - - ${SDATA:--} $(format-json --leave-initial-dot --scope all-nv-pairs --exclude 0* --exclude 1* --exclude 2* --exclude 3* --exclude 4* --exclude 5* --exclude 6* --exclude 7* --exclude 8* --exclude 9* --exclude SOURCE --exclude .SDATA.* ._TAGS=${TAGS})\n"; + +block destination syslog-ng(server('127.0.0.1') transport(tcp) port(514)) { + network("`server`" transport(`transport`) port(`port`) + template("$(format-ewmm)") + frac-digits(3) + `__VARARGS__` + ); +}; diff -Nru syslog-ng-3.11.1/scl/graylog2/plugin.conf syslog-ng-3.13.2/scl/graylog2/plugin.conf --- syslog-ng-3.11.1/scl/graylog2/plugin.conf 1970-01-01 00:00:00.000000000 +0000 +++ syslog-ng-3.13.2/scl/graylog2/plugin.conf 2017-12-06 06:39:39.000000000 +0000 @@ -0,0 +1,31 @@ +############################################################################# +# Copyright (c) 2017 Balabit +# Copyright (c) 2016 avcbvamorec +# +# This program is free software; you can redistribute it and/or modify it +# under the terms of the GNU General Public License version 2 as published +# by the Free Software Foundation, or (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA +# +# As an additional exemption you are allowed to compile & link against the +# OpenSSL libraries as published by the OpenSSL project. See the file +# COPYING for details. +# +############################################################################# + +template-function "format-gelf" "$(format-json version='1.1' host='${HOST}' short_message='${MSG}' level=int(${LEVEL_NUM}) timestamp=int64(${R_UNIXTIME}) _program='${PROGRAM}' _pid=int(${PID}) _facility='${FACILITY}' _class='${.classifier.class}' --key .* --key _*)$(binary 0x00)"; + +block destination graylog2(host("127.0.0.1") port(12201) template("$(format-gelf)")) { + network("`host`" + port(`port`) + transport(tcp) + template("`template`")); +}; diff -Nru syslog-ng-3.11.1/scl/hdfs/plugin.conf syslog-ng-3.13.2/scl/hdfs/plugin.conf --- syslog-ng-3.11.1/scl/hdfs/plugin.conf 2017-07-31 09:05:32.000000000 +0000 +++ syslog-ng-3.13.2/scl/hdfs/plugin.conf 2017-12-06 06:39:39.000000000 +0000 @@ -31,10 +31,12 @@ client_lib_dir("") kerberos_principal("") kerberos_keytab_file("") + template("") + hdfs_append_enabled("") ) { java( - class_path("`module-path`/java-modules/*.jar:`client_lib_dir`/*.jar") + class_path("`java-module-dir`/*.jar:`client_lib_dir`/*.jar") class_name("org.syslog_ng.hdfs.HdfsDestination") option("hdfs_uri", `hdfs_uri`) option("hdfs_file", `hdfs_file`) @@ -43,6 +45,8 @@ option("hdfs_max_filename_length", `hdfs_max_filename_length`) option("kerberos_principal", `kerberos_principal`) option("kerberos_keytab_file", `kerberos_keytab_file`) + option("template", `template`) + option("hdfs_append_enabled", `hdfs_append_enabled`) `__VARARGS__` ); }; diff -Nru syslog-ng-3.11.1/scl/iptables/iptables.conf syslog-ng-3.13.2/scl/iptables/iptables.conf --- syslog-ng-3.11.1/scl/iptables/iptables.conf 1970-01-01 00:00:00.000000000 +0000 +++ syslog-ng-3.13.2/scl/iptables/iptables.conf 2017-12-06 06:39:39.000000000 +0000 @@ -0,0 +1,32 @@ +############################################################################# +# Copyright (c) 2017 Balabit +# +# This program is free software; you can redistribute it and/or modify it +# under the terms of the GNU General Public License version 2 as published +# by the Free Software Foundation, or (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA +# +# As an additional exemption you are allowed to compile & link against the +# OpenSSL libraries as published by the OpenSSL project. See the file +# COPYING for details. +# +############################################################################# + +block parser iptables-parser(prefix('.iptables.')) { + kv-parser(prefix(`prefix`)); +}; + +application iptables[syslog] { + filter { facility(kern) and + program("kernel" type(string)) and + message("PROTO=" type(string) flags(substring)); }; + parser { iptables-parser(); }; +}; diff -Nru syslog-ng-3.11.1/scl/kafka/plugin.conf syslog-ng-3.13.2/scl/kafka/plugin.conf --- syslog-ng-3.11.1/scl/kafka/plugin.conf 2017-07-31 09:05:32.000000000 +0000 +++ syslog-ng-3.13.2/scl/kafka/plugin.conf 2017-12-06 06:39:39.000000000 +0000 @@ -31,7 +31,7 @@ ) { java( - class_path("`module-path`/java-modules/*.jar:`client_lib_dir`/*.jar") + class_path("`java-module-dir`/*.jar:`client_lib_dir`/*.jar") class_name("org.syslog_ng.kafka.KafkaDestination") option("topic", `topic`) option("key", `key`) diff -Nru syslog-ng-3.11.1/scl/loadbalancer/gen-loadbalancer.sh syslog-ng-3.13.2/scl/loadbalancer/gen-loadbalancer.sh --- syslog-ng-3.11.1/scl/loadbalancer/gen-loadbalancer.sh 1970-01-01 00:00:00.000000000 +0000 +++ syslog-ng-3.13.2/scl/loadbalancer/gen-loadbalancer.sh 2017-12-06 06:39:39.000000000 +0000 @@ -0,0 +1,56 @@ +#!/bin/sh +############################################################################# +# Copyright (c) 2017 Balabit +# +# This program is free software; you can redistribute it and/or modify it +# under the terms of the GNU General Public License version 2 as published +# by the Free Software Foundation, or (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA +# +# As an additional exemption you are allowed to compile & link against the +# OpenSSL libraries as published by the OpenSSL project. See the file +# COPYING for details. +# +############################################################################# + +TARGETS=$confgen_targets +TARGET_PARAMS=$confgen_parameters + +target_cnt=$(echo $TARGETS | wc -w) +target_id=0 +echo 'channel {' +for target in $TARGETS +do +# other_targets=$(echo $TARGETS | sed -e s/\\b${target}\\b//) + echo ' channel {' + echo ' filter {' + echo -n ' "' + echo -n $target_id + echo -n '" == "$(% ${R_MSEC} ' + echo -n $target_cnt + echo ')"' + echo ' };' + echo ' destination {' + echo -n ' network("' + echo -n $target + echo -n '" ' + echo -n $TARGET_PARAMS +#echo -n 'failover-servers("' +#echo -n $other_targets +#echo -n '")' + echo ' );' + echo ' };' + echo ' flags(final);' + echo ' };' + target_id=$((target_id+1)) +done +echo '};' + diff -Nru syslog-ng-3.11.1/scl/loadbalancer/plugin.conf syslog-ng-3.13.2/scl/loadbalancer/plugin.conf --- syslog-ng-3.11.1/scl/loadbalancer/plugin.conf 1970-01-01 00:00:00.000000000 +0000 +++ syslog-ng-3.13.2/scl/loadbalancer/plugin.conf 2017-12-06 06:39:39.000000000 +0000 @@ -0,0 +1,32 @@ +############################################################################# +# Copyright (c) 2017 Balabit +# +# This program is free software; you can redistribute it and/or modify it +# under the terms of the GNU General Public License version 2 as published +# by the Free Software Foundation, or (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA +# +# As an additional exemption you are allowed to compile & link against the +# OpenSSL libraries as published by the OpenSSL project. See the file +# COPYING for details. +# +############################################################################# + +@module confgen context(destination) name(genlb) exec("`scl-root`/loadbalancer/gen-loadbalancer.sh") + + +block destination network-load-balancer(targets()) { + genlb( + targets(`targets`) + parameters(`__VARARGS__`) + ) +}; + diff -Nru syslog-ng-3.11.1/scl/Makefile.am syslog-ng-3.13.2/scl/Makefile.am --- syslog-ng-3.11.1/scl/Makefile.am 2017-07-31 09:05:32.000000000 +0000 +++ syslog-ng-3.13.2/scl/Makefile.am 2017-12-06 06:39:39.000000000 +0000 @@ -9,14 +9,22 @@ solaris \ mbox \ elasticsearch \ + graylog2 \ kafka \ hdfs \ + iptables \ apache \ cisco \ + default-network-drivers \ + ewmm \ + sudo \ loggly \ logmatic \ snmptrap \ - osquery + osquery \ + windowseventlog \ + loadbalancer + SCL_CONFIGS = scl.conf syslog-ng.conf EXTRA_DIST += $(addprefix scl/,$(SCL_CONFIGS) $(SCL_SUBDIRS)) diff -Nru syslog-ng-3.11.1/scl/osquery/plugin.conf syslog-ng-3.13.2/scl/osquery/plugin.conf --- syslog-ng-3.11.1/scl/osquery/plugin.conf 2017-07-31 09:05:32.000000000 +0000 +++ syslog-ng-3.13.2/scl/osquery/plugin.conf 2017-12-06 06:39:39.000000000 +0000 @@ -27,3 +27,21 @@ parser { json-parser (prefix("`prefix`")); }; }; }; + +template t_osquery { + template("\"${ISODATE}\",\"${HOST}\",\"${LEVEL_NUM}\",\"${FACILITY}\",\"${PROGRAM}\",\"${ESCAPED_MESSAGE}\"\n"); + template_escape(no); +}; + +block destination osquery(pipe("/var/osquery/syslog_pipe")) { + channel { + rewrite { + set("$MESSAGE", value("ESCAPED_MESSAGE")); + subst("\"","\"\"", value("ESCAPED_MESSAGE"), flags(global)); + }; + destination { + pipe(`pipe` template(t_osquery)); + `__VARARGS__`; + }; + }; +}; diff -Nru syslog-ng-3.11.1/scl/scl.conf syslog-ng-3.13.2/scl/scl.conf --- syslog-ng-3.11.1/scl/scl.conf 2017-07-31 09:05:32.000000000 +0000 +++ syslog-ng-3.13.2/scl/scl.conf 2017-12-06 06:39:39.000000000 +0000 @@ -26,3 +26,5 @@ # @include 'scl/*/*.conf' + +@define java-module-dir "`module-install-dir`/java-modules" diff -Nru syslog-ng-3.11.1/scl/sudo/sudo.conf syslog-ng-3.13.2/scl/sudo/sudo.conf --- syslog-ng-3.11.1/scl/sudo/sudo.conf 1970-01-01 00:00:00.000000000 +0000 +++ syslog-ng-3.13.2/scl/sudo/sudo.conf 2017-12-06 06:39:39.000000000 +0000 @@ -0,0 +1,31 @@ +############################################################################# +# Copyright (c) 2017 Balabit +# +# This program is free software; you can redistribute it and/or modify it +# under the terms of the GNU General Public License version 2 as published +# by the Free Software Foundation, or (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA +# +# As an additional exemption you are allowed to compile & link against the +# OpenSSL libraries as published by the OpenSSL project. See the file +# COPYING for details. +# +############################################################################# + +block parser sudo-parser(prefix('.sudo.')) { + kv-parser(prefix(`prefix`) pair-separator(';') extract-stray-words-into('0')); + csv-parser(columns("`prefix`SUBJECT") template("$(list-head $0)") delimiters(' ')); +}; + +application sudo[syslog] { + filter { program("sudo" type(string)); }; + parser { sudo-parser(); }; +}; diff -Nru syslog-ng-3.11.1/scl/syslog-ng.conf syslog-ng-3.13.2/scl/syslog-ng.conf --- syslog-ng-3.11.1/scl/syslog-ng.conf 2017-07-31 09:05:32.000000000 +0000 +++ syslog-ng-3.13.2/scl/syslog-ng.conf 2017-12-06 06:39:39.000000000 +0000 @@ -3,7 +3,7 @@ # single file called /var/log/messages. # -@version: 3.11 +@version: 3.13 @include "scl.conf" source s_local { @@ -12,11 +12,12 @@ }; source s_network { - udp(); + default-network-drivers(); }; destination d_local { file("/var/log/messages"); + file("/var/log/messages-kv.log" template("$ISODATE $HOST $(format-welf --scope all-nv-pairs)\n") frac-digits(3)); }; log { diff -Nru syslog-ng-3.11.1/scl/system/plugin.conf syslog-ng-3.13.2/scl/system/plugin.conf --- syslog-ng-3.11.1/scl/system/plugin.conf 2017-07-31 09:05:32.000000000 +0000 +++ syslog-ng-3.13.2/scl/system/plugin.conf 2017-12-06 06:39:39.000000000 +0000 @@ -21,10 +21,9 @@ ############################################################################# # -# This SCL module loads the "system-source" plugin explicitly (as it doesn't -# autoload right now). If the compiled plugin doesn't support your -# operating system, you can always define a block here to substitute for the -# compiled version. +# This SCL module is a placeholder to override the contents of the system() +# source. If the compiled plugin doesn't support your operating system, you +# can always define a block here to substitute for the compiled version. # # e.g. just create a "block source system { ... }" block in this file, and # comment out the system-source module invocation. This way even if @@ -35,5 +34,5 @@ # This is the mailing list address where developers are lurking: # syslog-ng@lists.balabit.hu. # - -@module system-source +# Alternatively, you can open an issue on github.com/balabit/syslog-ng +# diff -Nru syslog-ng-3.11.1/scl/windowseventlog/plugin.conf syslog-ng-3.13.2/scl/windowseventlog/plugin.conf --- syslog-ng-3.11.1/scl/windowseventlog/plugin.conf 1970-01-01 00:00:00.000000000 +0000 +++ syslog-ng-3.13.2/scl/windowseventlog/plugin.conf 2017-12-06 06:39:39.000000000 +0000 @@ -0,0 +1,31 @@ +############################################################################# +# Copyright (c) 2017 Balabit +# +# This program is free software; you can redistribute it and/or modify it +# under the terms of the GNU General Public License version 2 as published +# by the Free Software Foundation, or (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA +# +# As an additional exemption you are allowed to compile & link against the +# OpenSSL libraries as published by the OpenSSL project. See the file +# COPYING for details. +# +############################################################################# + + +block parser windows-eventlog-parser() { + channel { + parser { + db-parser(file("windowseventlog.xml") drop-unmatched(yes)); + }; + }; +}; + diff -Nru syslog-ng-3.11.1/scl/windowseventlog/windowseventlog.xml syslog-ng-3.13.2/scl/windowseventlog/windowseventlog.xml --- syslog-ng-3.11.1/scl/windowseventlog/windowseventlog.xml 1970-01-01 00:00:00.000000000 +0000 +++ syslog-ng-3.13.2/scl/windowseventlog/windowseventlog.xml 2017-12-06 06:39:39.000000000 +0000 @@ -0,0 +1,235 @@ + + + + Microsoft_Windows_security_auditing. + + + + @ESTRING:::@ Security Microsoft Windows security auditing.: [Success Audit] An account was successfully logged on. + +Subject: + Security ID: @NLSTRING:@ + Account Name: @NLSTRING:@ + Account Domain: @NLSTRING:.win.SubjectDomainName@ + Logon ID: @NLSTRING:@ + +Logon Type: @NLSTRING:.win.LogonType@ + +New Logon: + Security ID: @NLSTRING:@ + Account Name: @NLSTRING:.win.TargetUserName@ + Account Domain: @NLSTRING:.win.TargetDomainName@ + Logon ID: @NLSTRING:.win.TargetLogonId@ + Logon GUID: @NLSTRING:.win.LogonGuid@ + +Process Information: + Process ID: @NLSTRING:.win.ProcessId@ + Process Name: @NLSTRING:.win.ProcessName@ + +Network Information: + Workstation Name: @NLSTRING:.win.WorkstationName@ + Source Network Address: @NLSTRING:.win.IpAddress@ + Source Port: @NLSTRING:.win.IpPort@ + +Detailed Authentication Information: + Logon Process: @NLSTRING:.win.LogonProcessName@ + Authentication Package: @NLSTRING:.win.AuthenticationPackageName@ + Transited Services: @NLSTRING:.win.TransmittedServices@ + Package Name (NTLM only): @NLSTRING:.win.LmPackageName@ + Key Length: @NLSTRING:.win.KeyLength@ + +This event is generated when a logon session is created. It is generated on the computer that was accessed. + +The subject fields indicate the account on the local system which requested the logon. This is most commonly a service such as the Server service, or a local process such as Winlogon.exe or Services.exe. + +The logon type field indicates the kind of logon that occurred. The most common types are 2 (interactive) and 3 (network). + +The New Logon fields indicate the account for whom the new logon was created, i.e. the account that was logged on. + +The network fields indicate where a remote logon request originated. Workstation name is not always available and may be left blank in some cases. + +The authentication information fields provide detailed information about this specific logon request. + - Logon GUID is a unique identifier that can be used to correlate this event with a KDC event. + - Transited services indicate which intermediate services have participated in this logon request. + - Package name indicates which sub-protocol was used among the NTLM protocols. + - Key length indicates the length of the generated session key. This will be 0 if no session key was requested. (EventID @ESTRING:.win.EventID:)@ + + + + + + BSP-WIN2K8R2-EN\Administrator: Security Microsoft Windows security auditing.: [Success Audit] An account was successfully logged on. + +Subject: + Security ID: NT AUTHORITY\SYSTEM + Account Name: BSP-WIN2K8R2-EN$ + Account Domain: BSP + Logon ID: 0x3e7 + +Logon Type: 10 + +New Logon: + Security ID: BSP-WIN2K8R2-EN\Administrator + Account Name: Administrator + Account Domain: BSP-WIN2K8R2-EN + Logon ID: 0xdeadbeef + Logon GUID: {00000000-0000-0000-0000-000000000000} + +Process Information: + Process ID: 0xabc + Process Name: C:\Windows\System32\winlogon.exe + +Network Information: + Workstation Name: BSP-WIN2K8R2-EN + Source Network Address: 10.20.30.40 + Source Port: 56789 + +Detailed Authentication Information: + Logon Process: User32 + Authentication Package: Negotiate + Transited Services: - + Package Name (NTLM only): - + Key Length: 0 + +This event is generated when a logon session is created. It is generated on the computer that was accessed. + +The subject fields indicate the account on the local system which requested the logon. This is most commonly a service such as the Server service, or a local process such as Winlogon.exe or Services.exe. + +The logon type field indicates the kind of logon that occurred. The most common types are 2 (interactive) and 3 (network). + +The New Logon fields indicate the account for whom the new logon was created, i.e. the account that was logged on. + +The network fields indicate where a remote logon request originated. Workstation name is not always available and may be left blank in some cases. + +The authentication information fields provide detailed information about this specific logon request. + - Logon GUID is a unique identifier that can be used to correlate this event with a KDC event. + - Transited services indicate which intermediate services have participated in this logon request. + - Package name indicates which sub-protocol was used among the NTLM protocols. + - Key length indicates the length of the generated session key. This will be 0 if no session key was requested. (EventID 4624) + + 4624 + Administrator + BSP + 10.20.30.40 + 56789 + BSP-WIN2K8R2-EN + 0xdeadbeef + C:\Windows\System32\winlogon.exe + 0xabc + 10 + BSP-WIN2K8R2-EN + {00000000-0000-0000-0000-000000000000} + Negotiate + User32 + - + - + 0 + + + + + + + @ESTRING:::@ Security Microsoft Windows security auditing.: [Success Audit] An account was logged off. + +Subject: + Security ID: @NLSTRING:.win.TargetUserSid@ + Account Name: @NLSTRING:.win.TargetUserName@ + Account Domain: @NLSTRING:.win.TargetDomainName@ + Logon ID: @NLSTRING:.win.TargetLogonId@ + +Logon Type: @NLSTRING:.win.LogonType@ + +This event is generated when a logon session is destroyed. It may be positively correlated with a logon event using the Logon ID value. Logon IDs are only unique between reboots on the same computer. (EventID @ESTRING:.win.EventID:)@ + + + + + + BSP-WIN2K8R2-EN\Administrator: Security Microsoft Windows security auditing.: [Success Audit] An account was logged off. + +Subject: + Security ID: BSP-WIN2K8R2-EN\Administrator + Account Name: Administrator + Account Domain: BSP-WIN2K8R2-EN + Logon ID: 0xdeadbeef + +Logon Type: 10 + +This event is generated when a logon session is destroyed. It may be positively correlated with a logon event using the Logon ID value. Logon IDs are only unique between reboots on the same computer. (EventID 4634) + + 4634 + BSP-WIN2K8R2-EN\Administrator + Administrator + BSP-WIN2K8R2-EN + 10 + 0xdeadbeef + + + + + + + @ESTRING:::@ Security Microsoft Windows security auditing.: [Success Audit] A new process has been created. + +Subject: + Security ID: @NLSTRING:.win.TargetUserSid@ + Account Name: @NLSTRING:.win.TargetUserName@ + Account Domain: @NLSTRING:.win.SubjectDomainName@ + Logon ID: @NLSTRING:.win.TargetLogonId@ + +Process Information: + New Process ID: @NLSTRING:.win.NewProcessId@ + New Process Name: @NLSTRING:.win.NewProcessName@ + Token Elevation Type: @NLSTRING:@ + Creator Process ID: @NLSTRING:.win.ParentProcessId@ + +Token Elevation Type indicates the type of token that was assigned to the new process in accordance with User Account Control policy. + +Type 1 is a full token with no privileges removed or groups disabled. A full token is only used if User Account Control is disabled or if the user is the built-in Administrator account or a service account. + +Type 2 is an elevated token with no privileges removed or groups disabled. An elevated token is used when User Account Control is enabled and the user chooses to start the program using Run as administrator. An elevated token is also used when an application is configured to always require administrative privilege or to always require maximum privilege, and the user is a member of the Administrators group. + +Type 3 is a limited token with administrative privileges removed and administrative groups disabled. The limited token is used when User Account Control is enabled, the application does not require administrative privilege, and the user does not choose to start the program using Run as administrator. (EventID @ESTRING:.win.EventID:)@ + + + + + + BSP\BSP-WIN2K8R2-EN$: Security Microsoft Windows security auditing.: [Success Audit] A new process has been created. + +Subject: + Security ID: NT AUTHORITY\SYSTEM + Account Name: BSP-WIN2K8R2-EN$ + Account Domain: BSP + Logon ID: 0x3e7 + +Process Information: + New Process ID: 0x8ec + New Process Name: C:\Windows\System32\smss.exe + Token Elevation Type: TokenElevationTypeDefault (1) + Creator Process ID: 0xe8 + +Token Elevation Type indicates the type of token that was assigned to the new process in accordance with User Account Control policy. + +Type 1 is a full token with no privileges removed or groups disabled. A full token is only used if User Account Control is disabled or if the user is the built-in Administrator account or a service account. + +Type 2 is an elevated token with no privileges removed or groups disabled. An elevated token is used when User Account Control is enabled and the user chooses to start the program using Run as administrator. An elevated token is also used when an application is configured to always require administrative privilege or to always require maximum privilege, and the user is a member of the Administrators group. + +Type 3 is a limited token with administrative privileges removed and administrative groups disabled. The limited token is used when User Account Control is enabled, the application does not require administrative privilege, and the user does not choose to start the program using Run as administrator. (EventID 4688) + + 4688 + NT AUTHORITY\SYSTEM + BSP-WIN2K8R2-EN$ + BSP + 0x3e7 + 0x8ec + C:\Windows\System32\smss.exe + 0xe8 + + + + + + + diff -Nru syslog-ng-3.11.1/syslog-ng/main.c syslog-ng-3.13.2/syslog-ng/main.c --- syslog-ng-3.11.1/syslog-ng/main.c 2017-07-31 09:05:32.000000000 +0000 +++ syslog-ng-3.13.2/syslog-ng/main.c 2017-12-06 06:39:39.000000000 +0000 @@ -136,6 +136,7 @@ installer_version = SYSLOG_NG_VERSION; } printf(SYSLOG_NG_PACKAGE_NAME " " SYSLOG_NG_COMBINED_VERSION "\n" + "Config version: " VERSION_CURRENT_VER_ONLY "\n" "Installer-Version: %s\n" "Revision: " SYSLOG_NG_SOURCE_REVISION "\n", installer_version); @@ -306,6 +307,6 @@ app_shutdown(); z_mem_trace_dump(); g_process_finish(); + reloc_deinit(); return rc; } - diff -Nru syslog-ng-3.11.1/syslog-ng-ctl/syslog-ng-ctl.c syslog-ng-3.13.2/syslog-ng-ctl/syslog-ng-ctl.c --- syslog-ng-3.11.1/syslog-ng-ctl/syslog-ng-ctl.c 2017-07-31 09:05:32.000000000 +0000 +++ syslog-ng-3.13.2/syslog-ng-ctl/syslog-ng-ctl.c 2017-12-06 06:39:39.000000000 +0000 @@ -137,7 +137,7 @@ }; static const gchar * -_stats_command_builder() +_stats_command_builder(void) { return stats_options_reset_is_set ? "RESET_STATS" : "STATS"; } @@ -160,6 +160,12 @@ return _dispatch_command("RELOAD"); } +static gint +slng_reopen(int argc, char *argv[], const gchar *mode) +{ + return _dispatch_command("REOPEN"); +} + const static gint QUERY_COMMAND = 0; static gboolean query_is_get_sum = FALSE; static gboolean query_reset = FALSE; @@ -216,7 +222,7 @@ } static gint -_get_query_list_cmd() +_get_query_list_cmd(void) { if (query_is_get_sum) return -1; @@ -228,7 +234,7 @@ } static gint -_get_query_get_cmd() +_get_query_get_cmd(void) { if (query_is_get_sum) { @@ -258,13 +264,13 @@ } static gboolean -_is_query_params_empty() +_is_query_params_empty(void) { return raw_query_params == NULL; } static gchar * -_shift_query_command_out_of_params() +_shift_query_command_out_of_params(void) { if (raw_query_params[QUERY_COMMAND] != NULL) return *(raw_query_params++); @@ -302,7 +308,7 @@ } static gchar * -_get_dispatchable_query_command() +_get_dispatchable_query_command(void) { gint query_cmd; @@ -383,6 +389,7 @@ { "trace", verbose_options, "Enable/query trace messages", slng_verbose }, { "stop", no_options, "Stop syslog-ng process", slng_stop }, { "reload", no_options, "Reload syslog-ng", slng_reload }, + { "reopen", no_options, "Re-open of log destination files", slng_reopen }, { "query", query_options, "Query syslog-ng statistics. Possible commands: list, get, get --sum", slng_query }, { "show-license-info", license_options, "Show information about the license", slng_license }, { NULL, NULL }, diff -Nru syslog-ng-3.11.1/tests/build-log-cflags-propagation.sh syslog-ng-3.13.2/tests/build-log-cflags-propagation.sh --- syslog-ng-3.11.1/tests/build-log-cflags-propagation.sh 2017-07-31 09:05:32.000000000 +0000 +++ syslog-ng-3.13.2/tests/build-log-cflags-propagation.sh 2017-12-06 06:39:39.000000000 +0000 @@ -116,7 +116,7 @@ gcc -DHAVE_CONFIG_H -I\. -I\.\./\.\. -I\.\./\.\./src/include -I\.\./\.\./src/include |\ gcc -DHAVE_CONFIG_H -I\. -I\.\. +-D_GNU_SOURCE -I\.\./src/include -I\.\./src/include |\ gcc( -std=gnu99)? -DHAVE_CONFIG_H -I\. -I\.\./\.\./\.\./\.\./lib/ivykis/src |\ -gcc( -std=gnu99)? -DHAVE_CONFIG_H -I\. -I\.\./\.\./\.\./\.\./lib/ivykis/test |\ +gcc( -std=gnu99)? -DHAVE_CONFIG_H -I\. -I\.\./\.\./\.\./\.\./lib/ivykis/test(.mt)? |\ gcc( -std=gnu99)? -DHAVE_CONFIG_H -I\. -I\.\./\.\./\.\./\.\./\.\./lib/ivykis/contrib/iv_getaddrinfo |\ gcc -std=gnu99 -DHAVE_CONFIG_H -I\. -I\.\./\.\./\.\./\.\./\.\./lib/ivykis/contrib/kojines \ )" "$@" diff -Nru syslog-ng-3.11.1/tests/copyright/policy syslog-ng-3.13.2/tests/copyright/policy --- syslog-ng-3.11.1/tests/copyright/policy 2017-07-31 09:05:32.000000000 +0000 +++ syslog-ng-3.13.2/tests/copyright/policy 2017-12-06 06:39:39.000000000 +0000 @@ -32,6 +32,9 @@ tests/functional/test\.conf$ scripts/update-patterndb$ (contrib|debian) +packaging/debian +packaging/debian/(man|source) +packaging/rhel doc/ChangeLog\.[0-9]$ (\.gitmodules|AUTHORS|COPYING|INSTALL|VERSION|aclocal\.m4|compile|configure|depcomp|install-sh|libtool|ltmain\.sh|missing|test-driver|ylwrap)$ .*/[^/.]*$ @@ -58,9 +61,10 @@ tests modules/java/(tools|[^/]*$) modules/java-modules/(dummy|elastic|elastic-v2|hdfs|http|kafka|[^/]*$) -modules/(afamqp|affile|afmongodb|afprog|afsmtp|afsocket|afsql|afstomp|afstreams|afuser|basicfuncs|cef|confgen|cryptofuncs|csvparser|date|diskq|dbparser|geoip|geoip2|graphite|json|kvformat|linux-kmsg-format|pacctformat|pseudofile|python|redis|riemann|syslogformat|systemd-journal|getent|system-source|stardate|snmptrapd-parser|[^/]*$) -modules/(add-contextual-data|map-value-pairs|[^/]*$) +modules/(afamqp|affile|afmongodb|afprog|afsmtp|afsocket|afsql|afstomp|afstreams|afuser|basicfuncs|cef|confgen|cryptofuncs|csvparser|date|diskq|dbparser|geoip|geoip2|graphite|json|kvformat|linux-kmsg-format|pacctformat|pseudofile|python|redis|riemann|syslogformat|systemd-journal|getent|system-source|stardate|snmptrapd-parser|xml|[^/]*$) +modules/(add-contextual-data|tagsparser|map-value-pairs|appmodel|[^/]*$) scl scripts GPLv2+_SSL,non-balabit modules/http + diff -Nru syslog-ng-3.11.1/tests/functional/test_file_source.py syslog-ng-3.13.2/tests/functional/test_file_source.py --- syslog-ng-3.11.1/tests/functional/test_file_source.py 2017-07-31 09:05:32.000000000 +0000 +++ syslog-ng-3.13.2/tests/functional/test_file_source.py 2017-12-06 06:39:39.000000000 +0000 @@ -26,7 +26,7 @@ from messagecheck import * from control import * -config_poll = """@version: 3.11 +config_poll = """@version: 3.13 options { ts_format(iso); chain_hostnames(no); keep_hostname(yes); threaded(yes); }; @@ -43,7 +43,7 @@ """ % locals() -config_auto = """@version: 3.11 +config_auto = """@version: 3.13 options { ts_format(iso); chain_hostnames(no); keep_hostname(yes); threaded(yes); }; diff -Nru syslog-ng-3.11.1/tests/functional/test_filters.py syslog-ng-3.13.2/tests/functional/test_filters.py --- syslog-ng-3.11.1/tests/functional/test_filters.py 2017-07-31 09:05:32.000000000 +0000 +++ syslog-ng-3.13.2/tests/functional/test_filters.py 2017-12-06 06:39:39.000000000 +0000 @@ -25,7 +25,7 @@ from messagegen import * from messagecheck import * -config = """@version: 3.11 +config = """@version: 3.13 options { ts_format(iso); chain_hostnames(no); keep_hostname(yes); threaded(yes); }; diff -Nru syslog-ng-3.11.1/tests/functional/test_input_drivers.py syslog-ng-3.13.2/tests/functional/test_input_drivers.py --- syslog-ng-3.11.1/tests/functional/test_input_drivers.py 2017-07-31 09:05:32.000000000 +0000 +++ syslog-ng-3.13.2/tests/functional/test_input_drivers.py 2017-12-06 06:39:39.000000000 +0000 @@ -25,7 +25,7 @@ from messagegen import * from messagecheck import * -config = """@version: 3.11 +config = """@version: 3.13 options { ts_format(iso); chain_hostnames(no); keep_hostname(yes); threaded(yes); }; diff -Nru syslog-ng-3.11.1/tests/functional/test_map_value_pairs.py syslog-ng-3.13.2/tests/functional/test_map_value_pairs.py --- syslog-ng-3.11.1/tests/functional/test_map_value_pairs.py 2017-07-31 09:05:32.000000000 +0000 +++ syslog-ng-3.13.2/tests/functional/test_map_value_pairs.py 2017-12-06 06:39:39.000000000 +0000 @@ -27,7 +27,7 @@ from control import flush_files, stop_syslogng import os -config = """@version: 3.11 +config = """@version: 3.13 options { keep-hostname(yes); }; diff -Nru syslog-ng-3.11.1/tests/functional/test_performance.py syslog-ng-3.13.2/tests/functional/test_performance.py --- syslog-ng-3.11.1/tests/functional/test_performance.py 2017-07-31 09:05:32.000000000 +0000 +++ syslog-ng-3.13.2/tests/functional/test_performance.py 2017-12-06 06:39:39.000000000 +0000 @@ -25,7 +25,7 @@ from messagegen import * from messagecheck import * -config = """@version: 3.11 +config = """@version: 3.13 options { ts_format(iso); chain_hostnames(no); keep_hostname(yes); threaded(yes); }; diff -Nru syslog-ng-3.11.1/tests/functional/test_python.py syslog-ng-3.13.2/tests/functional/test_python.py --- syslog-ng-3.11.1/tests/functional/test_python.py 2017-07-31 09:05:32.000000000 +0000 +++ syslog-ng-3.13.2/tests/functional/test_python.py 2017-12-06 06:39:39.000000000 +0000 @@ -27,7 +27,7 @@ from control import flush_files, stop_syslogng import os -config = """@version: 3.11 +config = """@version: 3.13 options { keep-hostname(yes); }; diff -Nru syslog-ng-3.11.1/tests/functional/test_sql.py syslog-ng-3.13.2/tests/functional/test_sql.py --- syslog-ng-3.11.1/tests/functional/test_sql.py 2017-07-31 09:05:32.000000000 +0000 +++ syslog-ng-3.13.2/tests/functional/test_sql.py 2017-12-06 06:39:39.000000000 +0000 @@ -26,7 +26,7 @@ from messagecheck import * from control import flush_files, stop_syslogng -config = """@version: 3.11 +config = """@version: 3.13 options { ts_format(iso); chain_hostnames(no); keep_hostname(yes); threaded(yes); }; diff -Nru syslog-ng-3.11.1/tests/unit/test_hostid.c syslog-ng-3.13.2/tests/unit/test_hostid.c --- syslog-ng-3.11.1/tests/unit/test_hostid.c 2017-07-31 09:05:32.000000000 +0000 +++ syslog-ng-3.13.2/tests/unit/test_hostid.c 2017-12-06 06:39:39.000000000 +0000 @@ -35,9 +35,9 @@ #include static GlobalConfig * -_create_cfg() +_create_cfg(void) { - GlobalConfig *cfg = cfg_new_snippet(0x0302); + GlobalConfig *cfg = cfg_new_snippet(); return cfg; } diff -Nru syslog-ng-3.11.1/tests/unit/test_logwriter.c syslog-ng-3.13.2/tests/unit/test_logwriter.c --- syslog-ng-3.11.1/tests/unit/test_logwriter.c 2017-07-31 09:05:32.000000000 +0000 +++ syslog-ng-3.13.2/tests/unit/test_logwriter.c 2017-12-06 06:39:39.000000000 +0000 @@ -166,7 +166,7 @@ queue = log_queue_fifo_new(1000, NULL); writer = log_writer_new(c.writer_flags, configuration); - log_writer_set_options(writer, NULL, &opt, 0, 0, NULL, NULL); + log_writer_set_options(writer, NULL, &opt, NULL, NULL); log_writer_set_queue(writer, queue); log_writer_format_log(writer, msg, result_msg); cr_assert_str_eq(result_msg->str, c.expected_value, "Expected: %s, actual: %s", c.expected_value, result_msg->str); @@ -176,7 +176,7 @@ Test(logwriter, test_logwriter) { - configuration = cfg_new_snippet(0x0300); + configuration = cfg_new_snippet(); LogWriterTestCase test_cases[] = { {MSG_SYSLOG_STR, TRUE, NULL, LW_SYSLOG_PROTOCOL, EXPECTED_MSG_SYSLOG_STR}, @@ -200,7 +200,7 @@ putenv("TZ=MET-1METDST"); tzset(); - plugin_load_module("syslogformat", configuration, NULL); + cfg_load_module(configuration, "syslogformat"); msg_format_options_defaults(&parse_options); msg_format_options_init(&parse_options, configuration); diff -Nru syslog-ng-3.11.1/tests/unit/test_msgparse.c syslog-ng-3.13.2/tests/unit/test_msgparse.c --- syslog-ng-3.11.1/tests/unit/test_msgparse.c 2017-07-31 09:05:32.000000000 +0000 +++ syslog-ng-3.13.2/tests/unit/test_msgparse.c 2017-12-06 06:39:39.000000000 +0000 @@ -1067,6 +1067,68 @@ run_parameterized_test(params); } +Test(msgparse, test_ip_in_host) +{ + struct msgparse_params params[] = + { + (struct msgparse_params) + { + .msg = "<0>Jan 10 01:00:00 1.2.3.4 prg0", + .parse_flags = LP_EXPECT_HOSTNAME, + .expected_stamp_sec = _get_epoch_with_bsd_year(0, 10, 1, 0, 0), + .expected_stamp_ofs = 3600, + .expected_program = "prg0", + .expected_host = "1.2.3.4" + }, + (struct msgparse_params) + { + .msg = "<0>Jan 10 01:00:00 0000:BABA:BA00:DAB:BABA:BABA:BABA:BAB0 prg0", + .parse_flags = LP_EXPECT_HOSTNAME, + .expected_stamp_sec = _get_epoch_with_bsd_year(0, 10, 1, 0, 0), + .expected_stamp_ofs = 3600, + .expected_program = "prg0", + .expected_host = "0000:BABA:BA00:DAB:BABA:BABA:BABA:BAB0" + }, + (struct msgparse_params) + { + .msg = "<0>Jan 10 01:00:00 0001:BABA:BA00:DAB::BAB0 prg0", + .parse_flags = LP_EXPECT_HOSTNAME, + .expected_stamp_sec = _get_epoch_with_bsd_year(0, 10, 1, 0, 0), + .expected_stamp_ofs = 3600, + .expected_program = "prg0", + .expected_host = "0001:BABA:BA00:DAB::BAB0" + }, + { + .msg = "<0>Jan 10 01:00:00 0002:: prg0: msgtxt", + .parse_flags = LP_EXPECT_HOSTNAME, + .expected_stamp_sec = _get_epoch_with_bsd_year(0, 10, 1, 0, 0), + .expected_stamp_ofs = 3600, + .expected_program = "prg0", + .expected_host = "0002::", + .expected_msg = "msgtxt" + }, + (struct msgparse_params) + { + .msg = "<0>Jan 10 01:00:00 prg0", // No ip no msg + .parse_flags = LP_EXPECT_HOSTNAME, + .expected_stamp_sec = _get_epoch_with_bsd_year(0, 10, 1, 0, 0), + .expected_stamp_ofs = 3600, + .expected_program = "prg0", + .expected_host = "" + }, + (struct msgparse_params) + { + .msg = "<0>Jan 10 01:00:00 prg0: msgtxt", // program name with message, no ip + .expected_stamp_sec = _get_epoch_with_bsd_year(0, 10, 1, 0, 0), + .expected_stamp_ofs = 3600, + .expected_program = "prg0", + .expected_msg = "msgtxt" + }, + {NULL} + }; + run_parameterized_test(params); +} + Test(msgparse, test_simple_message) { struct msgparse_params params[] = diff -Nru syslog-ng-3.11.1/tests/unit/test_thread_wakeup.c syslog-ng-3.13.2/tests/unit/test_thread_wakeup.c --- syslog-ng-3.11.1/tests/unit/test_thread_wakeup.c 2017-07-31 09:05:32.000000000 +0000 +++ syslog-ng-3.13.2/tests/unit/test_thread_wakeup.c 2017-12-06 06:39:39.000000000 +0000 @@ -122,7 +122,7 @@ } int -test_accept_wakeup() +test_accept_wakeup(void) { struct sockaddr_un s; @@ -173,7 +173,7 @@ } int -test_read_wakeup() +test_read_wakeup(void) { gint pair[2]; diff -Nru syslog-ng-3.11.1/.travis.yml syslog-ng-3.13.2/.travis.yml --- syslog-ng-3.11.1/.travis.yml 2017-07-31 09:05:32.000000000 +0000 +++ syslog-ng-3.13.2/.travis.yml 2017-12-06 06:39:39.000000000 +0000 @@ -6,6 +6,9 @@ os: linux +cache: + apt: true + install: - curl -4 http://download.opensuse.org/repositories/home:/laszlo_budai:/syslog-ng/xUbuntu_12.04/Release.key | sudo apt-key add - - echo "deb http://download.opensuse.org/repositories/home:/laszlo_budai:/syslog-ng/xUbuntu_12.04 ./" | sudo tee --append /etc/apt/sources.list.d/syslog-ng-obs.list @@ -37,6 +40,8 @@ libxml2-utils - sudo pip install -r requirements.txt before_script: + - echo 'Europe/Budapest' | sudo tee /etc/timezone + - sudo dpkg-reconfigure --frontend noninteractive tzdata - ./autogen.sh - unset PYTHON_CFLAGS # HACK - CONFIGURE_FLAGS=" @@ -55,9 +60,13 @@ --disable-sql --enable-pacct --enable-manpages + --with-python=2 --with-docbook=/usr/share/xml/docbook/stylesheet/docbook-xsl/manpages/docbook.xsl --enable-extra-warnings " + - if [ "$CC" = "clang" ]; then + CONFIGURE_FLAGS="$CONFIGURE_FLAGS --disable-mongodb" ; + fi - ./configure $CONFIGURE_FLAGS script: - . tests/build-log-cflags-propagation.sh; @@ -106,7 +115,8 @@ astyle before_script: script: - - scripts/style-checker.sh check + - scripts/style-checker.sh format + - git diff --exit-code - env: B=copyright-check sudo: false compiler: gcc diff -Nru syslog-ng-3.11.1/VERSION syslog-ng-3.13.2/VERSION --- syslog-ng-3.11.1/VERSION 2017-07-31 09:05:32.000000000 +0000 +++ syslog-ng-3.13.2/VERSION 2017-12-06 06:39:39.000000000 +0000 @@ -1 +1 @@ -3.11.1 +3.13.2