summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichael Biebl <biebl@debian.org>2008-03-29 12:14:46 +0100
committerMichael Biebl <biebl@debian.org>2008-03-29 12:14:46 +0100
commite1bfc41f9a8e6c7ef051686210c0f263bf512372 (patch)
tree403612780ae40da9d69f785bd09d177c69fafca6
parentde624a45c50b87eb153e78cd84cf0eae8dbeddfa (diff)
downloadrsyslog-e1bfc41f9a8e6c7ef051686210c0f263bf512372.tar.gz
Imported Debian patch 1.20.1-1debian/1.20.1-1
-rw-r--r--ChangeLog23
-rw-r--r--Makefile.am13
-rw-r--r--Makefile.in75
-rw-r--r--action.c5
-rw-r--r--action.h4
-rw-r--r--cfsysline.c90
-rw-r--r--cfsysline.h3
-rw-r--r--config.h.in9
-rwxr-xr-xconfigure600
-rw-r--r--configure.ac91
-rw-r--r--debian/changelog29
-rw-r--r--debian/control12
-rw-r--r--debian/patches/no_create_db.patch16
-rw-r--r--debian/patches/series2
-rw-r--r--debian/rsyslog-mysql.config4
-rw-r--r--debian/rsyslog-mysql.dirs1
-rw-r--r--debian/rsyslog-mysql.install2
-rw-r--r--debian/rsyslog-mysql.postinst2
-rw-r--r--debian/rsyslog-pgsql.config16
-rw-r--r--debian/rsyslog-pgsql.install1
-rw-r--r--debian/rsyslog-pgsql.postinst66
-rw-r--r--debian/rsyslog-pgsql.postrm55
-rw-r--r--debian/rsyslog-pgsql.prerm12
-rwxr-xr-xdebian/rules4
-rw-r--r--doc/Makefile.in6
-rw-r--r--doc/features.html6
-rw-r--r--doc/history.html15
-rw-r--r--doc/manual.html2
-rw-r--r--doc/rsconf1_modload.html7
-rw-r--r--doc/rsyslog_conf.html6
-rw-r--r--doc/status.html9
-rw-r--r--expr.c40
-rw-r--r--gss-misc.c210
-rw-r--r--gss-misc.h11
-rw-r--r--linkedlist.c120
-rw-r--r--linkedlist.h1
-rw-r--r--module-template.h75
-rw-r--r--modules.c59
-rw-r--r--modules.h3
-rw-r--r--msg.c80
-rw-r--r--msg.h2
-rw-r--r--omdiscard.c5
-rw-r--r--omfile.c26
-rw-r--r--omfwd.c378
-rw-r--r--omshell.c5
-rw-r--r--omusrmsg.c8
-rw-r--r--parse.c12
-rw-r--r--pidfile.c10
-rw-r--r--plugins/ommysql/Makefile.am3
-rw-r--r--plugins/ommysql/Makefile.in10
-rw-r--r--plugins/ommysql/ommysql.c7
-rw-r--r--plugins/ommysql/ommysql.h6
-rw-r--r--plugins/ompgsql/Makefile.am8
-rw-r--r--plugins/ompgsql/Makefile.in488
-rw-r--r--plugins/ompgsql/createDB.sql37
-rw-r--r--plugins/ompgsql/ompgsql.c304
-rw-r--r--plugins/ompgsql/ompgsql.h30
-rw-r--r--rsyslog.conf.52
-rw-r--r--rsyslog.h1
-rw-r--r--rsyslogd.844
-rwxr-xr-xsrUtils.c2
-rw-r--r--sync.c78
-rw-r--r--sync.h62
-rw-r--r--syslogd.c356
-rw-r--r--syslogd.h3
-rw-r--r--tcpsyslog.c187
-rw-r--r--tcpsyslog.h19
-rw-r--r--template.c7
-rw-r--r--template.h2
69 files changed, 3463 insertions, 424 deletions
diff --git a/ChangeLog b/ChangeLog
index bbca374..358e43a 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,26 @@
+---------------------------------------------------------------------------
+Version 1.20.1 (rgerhards), 2007-12-12
+- corrected a debug setting that survived release. Caused TCP connections
+ to be retried unnecessarily often.
+- When a hostname ACL was provided and DNS resolution for that name failed,
+ ACL processing was stopped at that point. Thanks to mildew for the patch.
+ Fedora Bugzilla: http://bugzilla.redhat.com/show_bug.cgi?id=395911
+- fixed a potential race condition, see link for details:
+ http://rgerhards.blogspot.com/2007/12/rsyslog-race-condition.html
+ Note that the probability of problems from this bug was very remote
+- fixed a memory leak that happend when PostgreSQL date formats were
+ used
+---------------------------------------------------------------------------
+Version 1.20.0 (rgerhards), 2007-12-07
+- an output module for postgres databases has been added. Thanks to
+ sur5r for contributing this code
+- unloading dynamic modules has been cleaned up, we now have a
+ real implementation and not just a dummy "good enough for the time
+ being".
+- enhanced platform independence - thanks to Bartosz Kuzma and Michael
+ Biebl for their very useful contributions
+- some general code cleanup (including warnings on 64 platforms, only)
+---------------------------------------------------------------------------
Version 1.19.12 (rgerhards), 2007-12-03
- cleaned up the build system (thanks to Michael Biebl for the patch)
- fixed a bug where ommysql was still not compiled with -pthread option
diff --git a/Makefile.am b/Makefile.am
index b296a06..1e6cf5a 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -30,10 +30,13 @@ rsyslogd_SOURCES = \
template.h \
outchannel.h \
liblogging-stub.h \
+ sync.c \
+ sync.h \
net.c \
net.h \
msg.c \
msg.h \
+ expr.c \
omshell.c \
omshell.h \
omusrmsg.c \
@@ -58,10 +61,12 @@ rsyslogd_SOURCES = \
iminternal.c \
iminternal.h \
action.c \
- action.h
+ action.h \
+ gss-misc.c \
+ gss-misc.h
rsyslogd_CPPFLAGS = -D_PATH_MODDIR=\"$(pkglibdir)/\" $(pthreads_cflags)
-rsyslogd_LDADD = $(zlib_libs) $(pthreads_libs) -ldl
+rsyslogd_LDADD = $(zlib_libs) $(pthreads_libs) $(gss_libs) $(dl_libs) $(rt_libs)
rsyslogd_LDFLAGS = -export-dynamic
man_MANS = rfc3195d.8 rklogd.8 rsyslogd.8 rsyslog.conf.5
@@ -81,3 +86,7 @@ SUBDIRS = doc
if ENABLE_MYSQL
SUBDIRS += plugins/ommysql
endif
+
+if ENABLE_PGSQL
+SUBDIRS += plugins/ompgsql
+endif
diff --git a/Makefile.in b/Makefile.in
index 54b3e2f..6889fb7 100644
--- a/Makefile.in
+++ b/Makefile.in
@@ -34,6 +34,7 @@ build_triplet = @build@
host_triplet = @host@
sbin_PROGRAMS = rklogd$(EXEEXT) rfc3195d$(EXEEXT) rsyslogd$(EXEEXT)
@ENABLE_MYSQL_TRUE@am__append_1 = plugins/ommysql
+@ENABLE_PGSQL_TRUE@am__append_2 = plugins/ompgsql
subdir = .
DIST_COMMON = README $(am__configure_deps) $(srcdir)/Makefile.am \
$(srcdir)/Makefile.in $(srcdir)/config.h.in \
@@ -64,16 +65,20 @@ am_rsyslogd_OBJECTS = rsyslogd-syslogd.$(OBJEXT) \
rsyslogd-pidfile.$(OBJEXT) rsyslogd-template.$(OBJEXT) \
rsyslogd-outchannel.$(OBJEXT) rsyslogd-stringbuf.$(OBJEXT) \
rsyslogd-srUtils.$(OBJEXT) rsyslogd-parse.$(OBJEXT) \
- rsyslogd-net.$(OBJEXT) rsyslogd-msg.$(OBJEXT) \
+ rsyslogd-sync.$(OBJEXT) rsyslogd-net.$(OBJEXT) \
+ rsyslogd-msg.$(OBJEXT) rsyslogd-expr.$(OBJEXT) \
rsyslogd-omshell.$(OBJEXT) rsyslogd-omusrmsg.$(OBJEXT) \
rsyslogd-omfwd.$(OBJEXT) rsyslogd-tcpsyslog.$(OBJEXT) \
rsyslogd-omfile.$(OBJEXT) rsyslogd-omdiscard.$(OBJEXT) \
rsyslogd-modules.$(OBJEXT) rsyslogd-objomsr.$(OBJEXT) \
rsyslogd-cfsysline.$(OBJEXT) rsyslogd-linkedlist.$(OBJEXT) \
- rsyslogd-iminternal.$(OBJEXT) rsyslogd-action.$(OBJEXT)
+ rsyslogd-iminternal.$(OBJEXT) rsyslogd-action.$(OBJEXT) \
+ rsyslogd-gss-misc.$(OBJEXT)
rsyslogd_OBJECTS = $(am_rsyslogd_OBJECTS)
am__DEPENDENCIES_1 =
-rsyslogd_DEPENDENCIES = $(am__DEPENDENCIES_1) $(am__DEPENDENCIES_1)
+rsyslogd_DEPENDENCIES = $(am__DEPENDENCIES_1) $(am__DEPENDENCIES_1) \
+ $(am__DEPENDENCIES_1) $(am__DEPENDENCIES_1) \
+ $(am__DEPENDENCIES_1)
rsyslogd_LINK = $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) \
--mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) $(rsyslogd_LDFLAGS) \
$(LDFLAGS) -o $@
@@ -107,7 +112,7 @@ RECURSIVE_CLEAN_TARGETS = mostlyclean-recursive clean-recursive \
distclean-recursive maintainer-clean-recursive
ETAGS = etags
CTAGS = ctags
-DIST_SUBDIRS = doc plugins/ommysql
+DIST_SUBDIRS = doc plugins/ommysql plugins/ompgsql
DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST)
distdir = $(PACKAGE)-$(VERSION)
top_distdir = $(distdir)
@@ -148,6 +153,7 @@ F77 = @F77@
FFLAGS = @FFLAGS@
GREP = @GREP@
HAVE_MYSQL_CONFIG = @HAVE_MYSQL_CONFIG@
+HAVE_PGSQL_CONFIG = @HAVE_PGSQL_CONFIG@
INSTALL = @INSTALL@
INSTALL_DATA = @INSTALL_DATA@
INSTALL_PROGRAM = @INSTALL_PROGRAM@
@@ -196,9 +202,11 @@ build_vendor = @build_vendor@
builddir = @builddir@
datadir = @datadir@
datarootdir = @datarootdir@
+dl_libs = @dl_libs@
docdir = @docdir@
dvidir = @dvidir@
exec_prefix = @exec_prefix@
+gss_libs = @gss_libs@
host = @host@
host_alias = @host_alias@
host_cpu = @host_cpu@
@@ -218,11 +226,14 @@ mysql_cflags = @mysql_cflags@
mysql_libs = @mysql_libs@
oldincludedir = @oldincludedir@
pdfdir = @pdfdir@
+pgsql_cflags = @pgsql_cflags@
+pgsql_libs = @pgsql_libs@
prefix = @prefix@
program_transform_name = @program_transform_name@
psdir = @psdir@
pthreads_cflags = @pthreads_cflags@
pthreads_libs = @pthreads_libs@
+rt_libs = @rt_libs@
sbindir = @sbindir@
sharedstatedir = @sharedstatedir@
srcdir = @srcdir@
@@ -260,10 +271,13 @@ rsyslogd_SOURCES = \
template.h \
outchannel.h \
liblogging-stub.h \
+ sync.c \
+ sync.h \
net.c \
net.h \
msg.c \
msg.h \
+ expr.c \
omshell.c \
omshell.h \
omusrmsg.c \
@@ -288,10 +302,12 @@ rsyslogd_SOURCES = \
iminternal.c \
iminternal.h \
action.c \
- action.h
+ action.h \
+ gss-misc.c \
+ gss-misc.h
rsyslogd_CPPFLAGS = -D_PATH_MODDIR=\"$(pkglibdir)/\" $(pthreads_cflags)
-rsyslogd_LDADD = $(zlib_libs) $(pthreads_libs) -ldl
+rsyslogd_LDADD = $(zlib_libs) $(pthreads_libs) $(gss_libs) $(dl_libs) $(rt_libs)
rsyslogd_LDFLAGS = -export-dynamic
man_MANS = rfc3195d.8 rklogd.8 rsyslogd.8 rsyslog.conf.5
EXTRA_DIST = \
@@ -304,7 +320,7 @@ EXTRA_DIST = \
contrib/README \
$(man_MANS)
-SUBDIRS = doc $(am__append_1)
+SUBDIRS = doc $(am__append_1) $(am__append_2)
all: config.h
$(MAKE) $(AM_MAKEFLAGS) all-recursive
@@ -411,6 +427,8 @@ distclean-compile:
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/rfc3195d.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/rsyslogd-action.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/rsyslogd-cfsysline.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/rsyslogd-expr.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/rsyslogd-gss-misc.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/rsyslogd-iminternal.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/rsyslogd-linkedlist.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/rsyslogd-modules.Po@am__quote@
@@ -427,6 +445,7 @@ distclean-compile:
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/rsyslogd-pidfile.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/rsyslogd-srUtils.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/rsyslogd-stringbuf.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/rsyslogd-sync.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/rsyslogd-syslogd.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/rsyslogd-tcpsyslog.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/rsyslogd-template.Po@am__quote@
@@ -551,6 +570,20 @@ rsyslogd-parse.obj: parse.c
@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(rsyslogd_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o rsyslogd-parse.obj `if test -f 'parse.c'; then $(CYGPATH_W) 'parse.c'; else $(CYGPATH_W) '$(srcdir)/parse.c'; fi`
+rsyslogd-sync.o: sync.c
+@am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(rsyslogd_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT rsyslogd-sync.o -MD -MP -MF $(DEPDIR)/rsyslogd-sync.Tpo -c -o rsyslogd-sync.o `test -f 'sync.c' || echo '$(srcdir)/'`sync.c
+@am__fastdepCC_TRUE@ mv -f $(DEPDIR)/rsyslogd-sync.Tpo $(DEPDIR)/rsyslogd-sync.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='sync.c' object='rsyslogd-sync.o' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(rsyslogd_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o rsyslogd-sync.o `test -f 'sync.c' || echo '$(srcdir)/'`sync.c
+
+rsyslogd-sync.obj: sync.c
+@am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(rsyslogd_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT rsyslogd-sync.obj -MD -MP -MF $(DEPDIR)/rsyslogd-sync.Tpo -c -o rsyslogd-sync.obj `if test -f 'sync.c'; then $(CYGPATH_W) 'sync.c'; else $(CYGPATH_W) '$(srcdir)/sync.c'; fi`
+@am__fastdepCC_TRUE@ mv -f $(DEPDIR)/rsyslogd-sync.Tpo $(DEPDIR)/rsyslogd-sync.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='sync.c' object='rsyslogd-sync.obj' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(rsyslogd_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o rsyslogd-sync.obj `if test -f 'sync.c'; then $(CYGPATH_W) 'sync.c'; else $(CYGPATH_W) '$(srcdir)/sync.c'; fi`
+
rsyslogd-net.o: net.c
@am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(rsyslogd_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT rsyslogd-net.o -MD -MP -MF $(DEPDIR)/rsyslogd-net.Tpo -c -o rsyslogd-net.o `test -f 'net.c' || echo '$(srcdir)/'`net.c
@am__fastdepCC_TRUE@ mv -f $(DEPDIR)/rsyslogd-net.Tpo $(DEPDIR)/rsyslogd-net.Po
@@ -579,6 +612,20 @@ rsyslogd-msg.obj: msg.c
@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(rsyslogd_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o rsyslogd-msg.obj `if test -f 'msg.c'; then $(CYGPATH_W) 'msg.c'; else $(CYGPATH_W) '$(srcdir)/msg.c'; fi`
+rsyslogd-expr.o: expr.c
+@am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(rsyslogd_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT rsyslogd-expr.o -MD -MP -MF $(DEPDIR)/rsyslogd-expr.Tpo -c -o rsyslogd-expr.o `test -f 'expr.c' || echo '$(srcdir)/'`expr.c
+@am__fastdepCC_TRUE@ mv -f $(DEPDIR)/rsyslogd-expr.Tpo $(DEPDIR)/rsyslogd-expr.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='expr.c' object='rsyslogd-expr.o' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(rsyslogd_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o rsyslogd-expr.o `test -f 'expr.c' || echo '$(srcdir)/'`expr.c
+
+rsyslogd-expr.obj: expr.c
+@am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(rsyslogd_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT rsyslogd-expr.obj -MD -MP -MF $(DEPDIR)/rsyslogd-expr.Tpo -c -o rsyslogd-expr.obj `if test -f 'expr.c'; then $(CYGPATH_W) 'expr.c'; else $(CYGPATH_W) '$(srcdir)/expr.c'; fi`
+@am__fastdepCC_TRUE@ mv -f $(DEPDIR)/rsyslogd-expr.Tpo $(DEPDIR)/rsyslogd-expr.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='expr.c' object='rsyslogd-expr.obj' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(rsyslogd_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o rsyslogd-expr.obj `if test -f 'expr.c'; then $(CYGPATH_W) 'expr.c'; else $(CYGPATH_W) '$(srcdir)/expr.c'; fi`
+
rsyslogd-omshell.o: omshell.c
@am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(rsyslogd_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT rsyslogd-omshell.o -MD -MP -MF $(DEPDIR)/rsyslogd-omshell.Tpo -c -o rsyslogd-omshell.o `test -f 'omshell.c' || echo '$(srcdir)/'`omshell.c
@am__fastdepCC_TRUE@ mv -f $(DEPDIR)/rsyslogd-omshell.Tpo $(DEPDIR)/rsyslogd-omshell.Po
@@ -747,6 +794,20 @@ rsyslogd-action.obj: action.c
@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(rsyslogd_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o rsyslogd-action.obj `if test -f 'action.c'; then $(CYGPATH_W) 'action.c'; else $(CYGPATH_W) '$(srcdir)/action.c'; fi`
+rsyslogd-gss-misc.o: gss-misc.c
+@am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(rsyslogd_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT rsyslogd-gss-misc.o -MD -MP -MF $(DEPDIR)/rsyslogd-gss-misc.Tpo -c -o rsyslogd-gss-misc.o `test -f 'gss-misc.c' || echo '$(srcdir)/'`gss-misc.c
+@am__fastdepCC_TRUE@ mv -f $(DEPDIR)/rsyslogd-gss-misc.Tpo $(DEPDIR)/rsyslogd-gss-misc.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='gss-misc.c' object='rsyslogd-gss-misc.o' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(rsyslogd_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o rsyslogd-gss-misc.o `test -f 'gss-misc.c' || echo '$(srcdir)/'`gss-misc.c
+
+rsyslogd-gss-misc.obj: gss-misc.c
+@am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(rsyslogd_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT rsyslogd-gss-misc.obj -MD -MP -MF $(DEPDIR)/rsyslogd-gss-misc.Tpo -c -o rsyslogd-gss-misc.obj `if test -f 'gss-misc.c'; then $(CYGPATH_W) 'gss-misc.c'; else $(CYGPATH_W) '$(srcdir)/gss-misc.c'; fi`
+@am__fastdepCC_TRUE@ mv -f $(DEPDIR)/rsyslogd-gss-misc.Tpo $(DEPDIR)/rsyslogd-gss-misc.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='gss-misc.c' object='rsyslogd-gss-misc.obj' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(rsyslogd_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o rsyslogd-gss-misc.obj `if test -f 'gss-misc.c'; then $(CYGPATH_W) 'gss-misc.c'; else $(CYGPATH_W) '$(srcdir)/gss-misc.c'; fi`
+
mostlyclean-libtool:
-rm -f *.lo
diff --git a/action.c b/action.c
index 6dc58c4..621cda5 100644
--- a/action.c
+++ b/action.c
@@ -34,6 +34,7 @@
#include "template.h"
#include "action.h"
#include "modules.h"
+#include "sync.h"
/* object static data (once for all instances) */
@@ -52,6 +53,7 @@ rsRetVal actionDestruct(action_t *pThis)
if(pThis->f_pMsg != NULL)
MsgDestruct(pThis->f_pMsg);
+ SYNC_OBJ_TOOL_EXIT(pThis);
if(pThis->ppTpl != NULL)
free(pThis->ppTpl);
if(pThis->ppMsgs != NULL)
@@ -77,6 +79,7 @@ rsRetVal actionConstruct(action_t **ppThis)
}
pThis->iResumeInterval = glbliActionResumeInterval;
+ SYNC_OBJ_TOOL_INIT(pThis);
finalize_it:
*ppThis = pThis;
@@ -171,7 +174,7 @@ rsRetVal actionDbgPrint(action_t *pThis)
printf("%s: ", modGetStateName(pThis->pMod));
pThis->pMod->dbgPrintInstInfo(pThis->pModData);
- printf("\n\tInstance data: 0x%x\n", (unsigned) pThis->pModData);
+ printf("\n\tInstance data: 0x%lx\n", (unsigned long) pThis->pModData);
printf("\tRepeatedMsgReduction: %d\n", pThis->f_ReduceRepeated);
printf("\tResume Interval: %d\n", pThis->iResumeInterval);
printf("\tSuspended: %d", pThis->bSuspended);
diff --git a/action.h b/action.h
index e7757d7..9a24600 100644
--- a/action.h
+++ b/action.h
@@ -25,6 +25,7 @@
#define ACTION_H_INCLUDED 1
#include "syslogd-types.h"
+#include "sync.h"
/* the following struct defines the action object data structure
*/
@@ -37,7 +38,7 @@ struct action_s {
int iResumeInterval;/* resume interval for this action */
int iNbrResRtry; /* number of retries since last suspend */
struct moduleInfo *pMod;/* pointer to output module handling this selector */
- void *pModData; /* pointer to module data - contents is module-specific */
+ void *pModData; /* pointer to module data - content is module-specific */
int f_ReduceRepeated;/* reduce repeated lines 0 - no, 1 - yes */
int f_prevcount; /* repetition cnt of prevline */
int f_repeatcount; /* number of "repeated" msgs */
@@ -50,6 +51,7 @@ struct action_s {
* content later). This is preserved after the message has been
* processed - it is also used to detect duplicates.
*/
+ SYNC_OBJ_TOOL; /* required for mutex support */
};
typedef struct action_s action_t;
diff --git a/cfsysline.c b/cfsysline.c
index 9b3c703..14f5092 100644
--- a/cfsysline.c
+++ b/cfsysline.c
@@ -376,6 +376,7 @@ static rsRetVal doGetWord(uchar **pp, rsRetVal (*pSetHdlr)(void*, uchar*), void
CHKiRet(rsCStrFinish(pStrB));
CHKiRet(rsCStrConvSzStrAndDestruct(pStrB, &pNewVal, 0));
+ pStrB = NULL;
/* we got the word, now set it */
if(pSetHdlr == NULL) {
@@ -431,6 +432,33 @@ finalize_it:
return iRet;
}
+/* destructor for linked list keys. As we do not use any dynamic memory,
+ * we simply return. However, this entry point must be defined for the
+ * linkedList class to make sure we have not forgotten a destructor.
+ * rgerhards, 2007-11-21
+ */
+static rsRetVal cslchKeyDestruct(void __attribute__((unused)) *pData)
+{
+ return RS_RET_OK;
+}
+
+
+/* Key compare operation for linked list class. This compares two
+ * owner cookies (void *).
+ * rgerhards, 2007-11-21
+ */
+static int cslchKeyCompare(void *pKey1, void *pKey2)
+{
+ if(pKey1 == pKey2)
+ return 0;
+ else
+ if(pKey1 < pKey2)
+ return -1;
+ else
+ return 1;
+}
+
+
/* set data members for this object
*/
rsRetVal cslchSetEntry(cslCmdHdlr_t *pThis, ecslCmdHdrlType eType, rsRetVal (*pHdlr)(), void *pData)
@@ -535,7 +563,7 @@ static rsRetVal cslcConstruct(cslCmd_t **ppThis, int bChainingPermitted)
pThis->bChainingPermitted = bChainingPermitted;
- CHKiRet(llInit(&pThis->llCmdHdlrs, cslchDestruct, NULL, NULL));
+ CHKiRet(llInit(&pThis->llCmdHdlrs, cslchDestruct, cslchKeyDestruct, cslchKeyCompare));
finalize_it:
*ppThis = pThis;
@@ -545,7 +573,7 @@ finalize_it:
/* add a handler entry to a known command
*/
-static rsRetVal cslcAddHdlr(cslCmd_t *pThis, ecslCmdHdrlType eType, rsRetVal (*pHdlr)(), void *pData)
+static rsRetVal cslcAddHdlr(cslCmd_t *pThis, ecslCmdHdrlType eType, rsRetVal (*pHdlr)(), void *pData, void *pOwnerCookie)
{
DEFiRet;
cslCmdHdlr_t *pCmdHdlr = NULL;
@@ -554,7 +582,7 @@ static rsRetVal cslcAddHdlr(cslCmd_t *pThis, ecslCmdHdrlType eType, rsRetVal (*p
CHKiRet(cslchConstruct(&pCmdHdlr));
CHKiRet(cslchSetEntry(pCmdHdlr, eType, pHdlr, pData));
- CHKiRet(llAppend(&pThis->llCmdHdlrs, NULL, pCmdHdlr));
+ CHKiRet(llAppend(&pThis->llCmdHdlrs, pOwnerCookie, pCmdHdlr));
finalize_it:
if(iRet != RS_RET_OK) {
@@ -586,7 +614,8 @@ finalize_it:
* caller does not need to take care of that. The caller must, however,
* free pCmdName if he allocated it dynamically! -- rgerhards, 2007-08-09
*/
-rsRetVal regCfSysLineHdlr(uchar *pCmdName, int bChainingPermitted, ecslCmdHdrlType eType, rsRetVal (*pHdlr)(), void *pData)
+rsRetVal regCfSysLineHdlr(uchar *pCmdName, int bChainingPermitted, ecslCmdHdrlType eType, rsRetVal (*pHdlr)(), void *pData,
+ void *pOwnerCookie)
{
cslCmd_t *pThis;
uchar *pMyCmdName;
@@ -596,7 +625,7 @@ rsRetVal regCfSysLineHdlr(uchar *pCmdName, int bChainingPermitted, ecslCmdHdrlTy
if(iRet == RS_RET_NOT_FOUND) {
/* new command */
CHKiRet(cslcConstruct(&pThis, bChainingPermitted));
- CHKiRet_Hdlr(cslcAddHdlr(pThis, eType, pHdlr, pData)) {
+ CHKiRet_Hdlr(cslcAddHdlr(pThis, eType, pHdlr, pData, pOwnerCookie)) {
cslcDestruct(pThis);
goto finalize_it;
}
@@ -616,7 +645,7 @@ rsRetVal regCfSysLineHdlr(uchar *pCmdName, int bChainingPermitted, ecslCmdHdrlTy
if(pThis->bChainingPermitted == 0 || bChainingPermitted == 0) {
ABORT_FINALIZE(RS_RET_CHAIN_NOT_PERMITTED);
}
- CHKiRet_Hdlr(cslcAddHdlr(pThis, eType, pHdlr, pData)) {
+ CHKiRet_Hdlr(cslcAddHdlr(pThis, eType, pHdlr, pData, pOwnerCookie)) {
cslcDestruct(pThis);
goto finalize_it;
}
@@ -633,6 +662,50 @@ rsRetVal unregCfSysLineHdlrs(void)
}
+/* helper function for unregCfSysLineHdlrs4Owner(). This is used to see if there is
+ * a handler of this owner inside the element and, if so, remove it. Please note that
+ * it keeps track of a pointer to the last linked list entry, as this is needed to
+ * remove an entry from the list.
+ * rgerhards, 2007-11-21
+ */
+DEFFUNC_llExecFunc(unregHdlrsHeadExec)
+{
+ DEFiRet;
+ cslCmd_t *pListHdr = (cslCmd_t*) pData;
+ int iNumElts;
+
+ /* first find element */
+ iRet = llFindAndDelete(&(pListHdr->llCmdHdlrs), pParam);
+
+ /* now go back and check how many elements are left */
+ CHKiRet(llGetNumElts(&(pListHdr->llCmdHdlrs), &iNumElts));
+
+ if(iNumElts == 0) {
+ /* nothing left in header, so request to delete it */
+ iRet = RS_RET_OK_DELETE_LISTENTRY;
+ }
+
+finalize_it:
+ return iRet;
+}
+/* unregister and destroy cfSysLineHandlers for a specific owner. This method is
+ * most importantly used before unloading a loadable module providing some handlers.
+ * The full list of handlers is searched. If the to-be removed handler was the only
+ * handler for a directive name, the directive header, too, is deleted.
+ * rgerhards, 2007-11-21
+ */
+rsRetVal unregCfSysLineHdlrs4Owner(void *pOwnerCookie)
+{
+ DEFiRet;
+ /* we need to walk through all directive names, as the linked list
+ * class does not provide a way to just search the lower-level handlers.
+ */
+ iRet = llExecFunc(&llCmdList, unregHdlrsHeadExec, pOwnerCookie);
+
+ return iRet;
+}
+
+
/* process a cfsysline command (based on handler structure)
* param "p" is a pointer to the command line after the command. Should be
* updated.
@@ -707,8 +780,9 @@ void dbgPrintCfSysLineHandlers(void)
llCookieCmdHdlr = NULL;
while((iRet = llGetNextElt(&pCmd->llCmdHdlrs, &llCookieCmdHdlr, (void*)&pCmdHdlr)) == RS_RET_OK) {
printf("\t\ttype : %d\n", pCmdHdlr->eType);
- printf("\t\tpData: 0x%x\n", (unsigned) pCmdHdlr->pData);
- printf("\t\tHdlr : 0x%x\n", (unsigned) pCmdHdlr->cslCmdHdlr);
+ printf("\t\tpData: 0x%lx\n", (unsigned long) pCmdHdlr->pData);
+ printf("\t\tHdlr : 0x%lx\n", (unsigned long) pCmdHdlr->cslCmdHdlr);
+ printf("\t\tOwner: 0x%lx\n", (unsigned long) llCookieCmdHdlr->pKey);
printf("\n");
}
}
diff --git a/cfsysline.h b/cfsysline.h
index 607ac40..13df135 100644
--- a/cfsysline.h
+++ b/cfsysline.h
@@ -61,8 +61,9 @@ struct cslCmd_s { /* config file sysline parse entry */
typedef struct cslCmd_s cslCmd_t;
/* prototypes */
-rsRetVal regCfSysLineHdlr(uchar *pCmdName, int bChainingPermitted, ecslCmdHdrlType eType, rsRetVal (*pHdlr)(), void *pData);
+rsRetVal regCfSysLineHdlr(uchar *pCmdName, int bChainingPermitted, ecslCmdHdrlType eType, rsRetVal (*pHdlr)(), void *pData, void *pOwnerCookie);
rsRetVal unregCfSysLineHdlrs(void);
+rsRetVal unregCfSysLineHdlrs4Owner(void *pOwnerCookie);
rsRetVal processCfSysLineCommand(uchar *pCmd, uchar **p);
rsRetVal cfsyslineInit(void);
void dbgPrintCfSysLineHandlers(void);
diff --git a/config.h.in b/config.h.in
index 5409826..ff5364b 100644
--- a/config.h.in
+++ b/config.h.in
@@ -51,12 +51,6 @@
/* Define to 1 if you have the <inttypes.h> header file. */
#undef HAVE_INTTYPES_H
-/* Define to 1 if you have the `dl' library (-ldl). */
-#undef HAVE_LIBDL
-
-/* Define to 1 if you have the `rt' library (-lrt). */
-#undef HAVE_LIBRT
-
/* Define to 1 if you have the <locale.h> header file. */
#undef HAVE_LOCALE_H
@@ -284,6 +278,9 @@
/* Define to 1 if your <sys/time.h> declares `struct tm'. */
#undef TM_IN_SYS_TIME
+/* Define if you want to use GSSAPI */
+#undef USE_GSSAPI
+
/* Define if you want to enable zlib support */
#undef USE_NETZIP
diff --git a/configure b/configure
index 240dc98..15c9145 100755
--- a/configure
+++ b/configure
@@ -1,6 +1,6 @@
#! /bin/sh
# Guess values for system-dependent variables and create Makefiles.
-# Generated by GNU Autoconf 2.61 for rsyslog 1.19.12.
+# Generated by GNU Autoconf 2.61 for rsyslog 1.20.1.
#
# Report bugs to <rsyslog@lists.adiscon.com.>.
#
@@ -728,8 +728,8 @@ SHELL=${CONFIG_SHELL-/bin/sh}
# Identity of this package.
PACKAGE_NAME='rsyslog'
PACKAGE_TARNAME='rsyslog'
-PACKAGE_VERSION='1.19.12'
-PACKAGE_STRING='rsyslog 1.19.12'
+PACKAGE_VERSION='1.20.1'
+PACKAGE_STRING='rsyslog 1.20.1'
PACKAGE_BUGREPORT='rsyslog@lists.adiscon.com.'
ac_unique_file="syslogd.c"
@@ -871,8 +871,11 @@ F77
FFLAGS
ac_ct_F77
LIBTOOL
+rt_libs
+dl_libs
LIBOBJS
zlib_libs
+gss_libs
pthreads_libs
pthreads_cflags
HAVE_MYSQL_CONFIG
@@ -880,6 +883,11 @@ ENABLE_MYSQL_TRUE
ENABLE_MYSQL_FALSE
mysql_cflags
mysql_libs
+HAVE_PGSQL_CONFIG
+ENABLE_PGSQL_TRUE
+ENABLE_PGSQL_FALSE
+pgsql_cflags
+pgsql_libs
LTLIBOBJS'
ac_subst_files=''
ac_precious_vars='build_alias
@@ -1399,7 +1407,7 @@ if test "$ac_init_help" = "long"; then
# Omit some internal or obsolete options to make the list less imposing.
# This message is too long to be a string in the A/UX 3.1 sh.
cat <<_ACEOF
-\`configure' configures rsyslog 1.19.12 to adapt to many kinds of systems.
+\`configure' configures rsyslog 1.20.1 to adapt to many kinds of systems.
Usage: $0 [OPTION]... [VAR=VALUE]...
@@ -1469,7 +1477,7 @@ fi
if test -n "$ac_init_help"; then
case $ac_init_help in
- short | recursive ) echo "Configuration of rsyslog 1.19.12:";;
+ short | recursive ) echo "Configuration of rsyslog 1.20.1:";;
esac
cat <<\_ACEOF
@@ -1486,6 +1494,7 @@ Optional Features:
--enable-largefile Enable large file support [default=yes]
--enable-regexp Enable regular expressions support [default=yes]
--enable-zlib Enable zlib compression support [default=yes]
+ --enable-gssapi-krb5 Enable GSSAPI Kerberos 5 support [default=no]
--enable-pthreads Enable multithreading via pthreads [default=yes]
--enable-klogd Integrated klogd functionality [default=yes]
--disable-unix Disable support for unix
@@ -1493,6 +1502,7 @@ Optional Features:
--disable-fsstnd Disable support for FSSTND
--enable-debug Enable debug mode [default=no]
--enable-mysql Enable MySql database support [default=no]
+ --enable-pgsql Enable PostgreSQL database support [default=no]
Optional Packages:
--with-PACKAGE[=ARG] use PACKAGE [ARG=yes]
@@ -1581,7 +1591,7 @@ fi
test -n "$ac_init_help" && exit $ac_status
if $ac_init_version; then
cat <<\_ACEOF
-rsyslog configure 1.19.12
+rsyslog configure 1.20.1
generated by GNU Autoconf 2.61
Copyright (C) 1992, 1993, 1994, 1995, 1996, 1998, 1999, 2000, 2001,
@@ -1595,7 +1605,7 @@ cat >config.log <<_ACEOF
This file contains any messages produced by compilers while
running configure, to aid debugging if configure makes a mistake.
-It was created by rsyslog $as_me 1.19.12, which was
+It was created by rsyslog $as_me 1.20.1, which was
generated by GNU Autoconf 2.61. Invocation command line was
$ $0 $@
@@ -2285,7 +2295,7 @@ fi
# Define the identity of the package.
PACKAGE='rsyslog'
- VERSION='1.19.12'
+ VERSION='1.20.1'
cat >>confdefs.h <<_ACEOF
@@ -4463,7 +4473,7 @@ ia64-*-hpux*)
;;
*-*-irix6*)
# Find out which ABI we are using.
- echo '#line 4466 "configure"' > conftest.$ac_ext
+ echo '#line 4476 "configure"' > conftest.$ac_ext
if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5
(eval $ac_compile) 2>&5
ac_status=$?
@@ -7206,11 +7216,11 @@ else
-e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \
-e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \
-e 's:$: $lt_compiler_flag:'`
- (eval echo "\"\$as_me:7209: $lt_compile\"" >&5)
+ (eval echo "\"\$as_me:7219: $lt_compile\"" >&5)
(eval "$lt_compile" 2>conftest.err)
ac_status=$?
cat conftest.err >&5
- echo "$as_me:7213: \$? = $ac_status" >&5
+ echo "$as_me:7223: \$? = $ac_status" >&5
if (exit $ac_status) && test -s "$ac_outfile"; then
# The compiler can only warn and ignore the option if not recognized
# So say no if there are warnings other than the usual output.
@@ -7496,11 +7506,11 @@ else
-e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \
-e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \
-e 's:$: $lt_compiler_flag:'`
- (eval echo "\"\$as_me:7499: $lt_compile\"" >&5)
+ (eval echo "\"\$as_me:7509: $lt_compile\"" >&5)
(eval "$lt_compile" 2>conftest.err)
ac_status=$?
cat conftest.err >&5
- echo "$as_me:7503: \$? = $ac_status" >&5
+ echo "$as_me:7513: \$? = $ac_status" >&5
if (exit $ac_status) && test -s "$ac_outfile"; then
# The compiler can only warn and ignore the option if not recognized
# So say no if there are warnings other than the usual output.
@@ -7600,11 +7610,11 @@ else
-e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \
-e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \
-e 's:$: $lt_compiler_flag:'`
- (eval echo "\"\$as_me:7603: $lt_compile\"" >&5)
+ (eval echo "\"\$as_me:7613: $lt_compile\"" >&5)
(eval "$lt_compile" 2>out/conftest.err)
ac_status=$?
cat out/conftest.err >&5
- echo "$as_me:7607: \$? = $ac_status" >&5
+ echo "$as_me:7617: \$? = $ac_status" >&5
if (exit $ac_status) && test -s out/conftest2.$ac_objext
then
# The compiler can only warn and ignore the option if not recognized
@@ -9951,7 +9961,7 @@ else
lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
lt_status=$lt_dlunknown
cat > conftest.$ac_ext <<EOF
-#line 9954 "configure"
+#line 9964 "configure"
#include "confdefs.h"
#if HAVE_DLFCN_H
@@ -10051,7 +10061,7 @@ else
lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
lt_status=$lt_dlunknown
cat > conftest.$ac_ext <<EOF
-#line 10054 "configure"
+#line 10064 "configure"
#include "confdefs.h"
#if HAVE_DLFCN_H
@@ -12471,11 +12481,11 @@ else
-e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \
-e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \
-e 's:$: $lt_compiler_flag:'`
- (eval echo "\"\$as_me:12474: $lt_compile\"" >&5)
+ (eval echo "\"\$as_me:12484: $lt_compile\"" >&5)
(eval "$lt_compile" 2>conftest.err)
ac_status=$?
cat conftest.err >&5
- echo "$as_me:12478: \$? = $ac_status" >&5
+ echo "$as_me:12488: \$? = $ac_status" >&5
if (exit $ac_status) && test -s "$ac_outfile"; then
# The compiler can only warn and ignore the option if not recognized
# So say no if there are warnings other than the usual output.
@@ -12575,11 +12585,11 @@ else
-e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \
-e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \
-e 's:$: $lt_compiler_flag:'`
- (eval echo "\"\$as_me:12578: $lt_compile\"" >&5)
+ (eval echo "\"\$as_me:12588: $lt_compile\"" >&5)
(eval "$lt_compile" 2>out/conftest.err)
ac_status=$?
cat out/conftest.err >&5
- echo "$as_me:12582: \$? = $ac_status" >&5
+ echo "$as_me:12592: \$? = $ac_status" >&5
if (exit $ac_status) && test -s out/conftest2.$ac_objext
then
# The compiler can only warn and ignore the option if not recognized
@@ -14139,11 +14149,11 @@ else
-e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \
-e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \
-e 's:$: $lt_compiler_flag:'`
- (eval echo "\"\$as_me:14142: $lt_compile\"" >&5)
+ (eval echo "\"\$as_me:14152: $lt_compile\"" >&5)
(eval "$lt_compile" 2>conftest.err)
ac_status=$?
cat conftest.err >&5
- echo "$as_me:14146: \$? = $ac_status" >&5
+ echo "$as_me:14156: \$? = $ac_status" >&5
if (exit $ac_status) && test -s "$ac_outfile"; then
# The compiler can only warn and ignore the option if not recognized
# So say no if there are warnings other than the usual output.
@@ -14243,11 +14253,11 @@ else
-e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \
-e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \
-e 's:$: $lt_compiler_flag:'`
- (eval echo "\"\$as_me:14246: $lt_compile\"" >&5)
+ (eval echo "\"\$as_me:14256: $lt_compile\"" >&5)
(eval "$lt_compile" 2>out/conftest.err)
ac_status=$?
cat out/conftest.err >&5
- echo "$as_me:14250: \$? = $ac_status" >&5
+ echo "$as_me:14260: \$? = $ac_status" >&5
if (exit $ac_status) && test -s out/conftest2.$ac_objext
then
# The compiler can only warn and ignore the option if not recognized
@@ -16432,11 +16442,11 @@ else
-e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \
-e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \
-e 's:$: $lt_compiler_flag:'`
- (eval echo "\"\$as_me:16435: $lt_compile\"" >&5)
+ (eval echo "\"\$as_me:16445: $lt_compile\"" >&5)
(eval "$lt_compile" 2>conftest.err)
ac_status=$?
cat conftest.err >&5
- echo "$as_me:16439: \$? = $ac_status" >&5
+ echo "$as_me:16449: \$? = $ac_status" >&5
if (exit $ac_status) && test -s "$ac_outfile"; then
# The compiler can only warn and ignore the option if not recognized
# So say no if there are warnings other than the usual output.
@@ -16722,11 +16732,11 @@ else
-e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \
-e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \
-e 's:$: $lt_compiler_flag:'`
- (eval echo "\"\$as_me:16725: $lt_compile\"" >&5)
+ (eval echo "\"\$as_me:16735: $lt_compile\"" >&5)
(eval "$lt_compile" 2>conftest.err)
ac_status=$?
cat conftest.err >&5
- echo "$as_me:16729: \$? = $ac_status" >&5
+ echo "$as_me:16739: \$? = $ac_status" >&5
if (exit $ac_status) && test -s "$ac_outfile"; then
# The compiler can only warn and ignore the option if not recognized
# So say no if there are warnings other than the usual output.
@@ -16826,11 +16836,11 @@ else
-e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \
-e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \
-e 's:$: $lt_compiler_flag:'`
- (eval echo "\"\$as_me:16829: $lt_compile\"" >&5)
+ (eval echo "\"\$as_me:16839: $lt_compile\"" >&5)
(eval "$lt_compile" 2>out/conftest.err)
ac_status=$?
cat out/conftest.err >&5
- echo "$as_me:16833: \$? = $ac_status" >&5
+ echo "$as_me:16843: \$? = $ac_status" >&5
if (exit $ac_status) && test -s out/conftest2.$ac_objext
then
# The compiler can only warn and ignore the option if not recognized
@@ -19539,14 +19549,14 @@ _ACEOF
esac
# Checks for libraries.
-
-{ echo "$as_me:$LINENO: checking for clock_gettime in -lrt" >&5
-echo $ECHO_N "checking for clock_gettime in -lrt... $ECHO_C" >&6; }
-if test "${ac_cv_lib_rt_clock_gettime+set}" = set; then
+save_LIBS=$LIBS
+LIBS=
+{ echo "$as_me:$LINENO: checking for library containing clock_gettime" >&5
+echo $ECHO_N "checking for library containing clock_gettime... $ECHO_C" >&6; }
+if test "${ac_cv_search_clock_gettime+set}" = set; then
echo $ECHO_N "(cached) $ECHO_C" >&6
else
- ac_check_lib_save_LIBS=$LIBS
-LIBS="-lrt $LIBS"
+ ac_func_search_save_LIBS=$LIBS
cat >conftest.$ac_ext <<_ACEOF
/* confdefs.h. */
_ACEOF
@@ -19569,7 +19579,14 @@ return clock_gettime ();
return 0;
}
_ACEOF
-rm -f conftest.$ac_objext conftest$ac_exeext
+for ac_lib in '' rt; do
+ if test -z "$ac_lib"; then
+ ac_res="none required"
+ else
+ ac_res=-l$ac_lib
+ LIBS="-l$ac_lib $ac_func_search_save_LIBS"
+ fi
+ rm -f conftest.$ac_objext conftest$ac_exeext
if { (ac_try="$ac_link"
case "(($ac_try" in
*\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
@@ -19587,37 +19604,44 @@ eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
test ! -s conftest.err
} && test -s conftest$ac_exeext &&
$as_test_x conftest$ac_exeext; then
- ac_cv_lib_rt_clock_gettime=yes
+ ac_cv_search_clock_gettime=$ac_res
else
echo "$as_me: failed program was:" >&5
sed 's/^/| /' conftest.$ac_ext >&5
- ac_cv_lib_rt_clock_gettime=no
+
fi
rm -f core conftest.err conftest.$ac_objext conftest_ipa8_conftest.oo \
- conftest$ac_exeext conftest.$ac_ext
-LIBS=$ac_check_lib_save_LIBS
+ conftest$ac_exeext
+ if test "${ac_cv_search_clock_gettime+set}" = set; then
+ break
fi
-{ echo "$as_me:$LINENO: result: $ac_cv_lib_rt_clock_gettime" >&5
-echo "${ECHO_T}$ac_cv_lib_rt_clock_gettime" >&6; }
-if test $ac_cv_lib_rt_clock_gettime = yes; then
- cat >>confdefs.h <<_ACEOF
-#define HAVE_LIBRT 1
-_ACEOF
-
- LIBS="-lrt $LIBS"
-
+done
+if test "${ac_cv_search_clock_gettime+set}" = set; then
+ :
+else
+ ac_cv_search_clock_gettime=no
+fi
+rm conftest.$ac_ext
+LIBS=$ac_func_search_save_LIBS
fi
+{ echo "$as_me:$LINENO: result: $ac_cv_search_clock_gettime" >&5
+echo "${ECHO_T}$ac_cv_search_clock_gettime" >&6; }
+ac_res=$ac_cv_search_clock_gettime
+if test "$ac_res" != no; then
+ test "$ac_res" = "none required" || LIBS="$ac_res $LIBS"
+fi
-{ echo "$as_me:$LINENO: checking for dlopen in -ldl" >&5
-echo $ECHO_N "checking for dlopen in -ldl... $ECHO_C" >&6; }
-if test "${ac_cv_lib_dl_dlopen+set}" = set; then
+rt_libs=$LIBS
+LIBS=
+{ echo "$as_me:$LINENO: checking for library containing dlopen" >&5
+echo $ECHO_N "checking for library containing dlopen... $ECHO_C" >&6; }
+if test "${ac_cv_search_dlopen+set}" = set; then
echo $ECHO_N "(cached) $ECHO_C" >&6
else
- ac_check_lib_save_LIBS=$LIBS
-LIBS="-ldl $LIBS"
+ ac_func_search_save_LIBS=$LIBS
cat >conftest.$ac_ext <<_ACEOF
/* confdefs.h. */
_ACEOF
@@ -19640,7 +19664,14 @@ return dlopen ();
return 0;
}
_ACEOF
-rm -f conftest.$ac_objext conftest$ac_exeext
+for ac_lib in '' dl; do
+ if test -z "$ac_lib"; then
+ ac_res="none required"
+ else
+ ac_res=-l$ac_lib
+ LIBS="-l$ac_lib $ac_func_search_save_LIBS"
+ fi
+ rm -f conftest.$ac_objext conftest$ac_exeext
if { (ac_try="$ac_link"
case "(($ac_try" in
*\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
@@ -19658,29 +19689,41 @@ eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
test ! -s conftest.err
} && test -s conftest$ac_exeext &&
$as_test_x conftest$ac_exeext; then
- ac_cv_lib_dl_dlopen=yes
+ ac_cv_search_dlopen=$ac_res
else
echo "$as_me: failed program was:" >&5
sed 's/^/| /' conftest.$ac_ext >&5
- ac_cv_lib_dl_dlopen=no
+
fi
rm -f core conftest.err conftest.$ac_objext conftest_ipa8_conftest.oo \
- conftest$ac_exeext conftest.$ac_ext
-LIBS=$ac_check_lib_save_LIBS
+ conftest$ac_exeext
+ if test "${ac_cv_search_dlopen+set}" = set; then
+ break
fi
-{ echo "$as_me:$LINENO: result: $ac_cv_lib_dl_dlopen" >&5
-echo "${ECHO_T}$ac_cv_lib_dl_dlopen" >&6; }
-if test $ac_cv_lib_dl_dlopen = yes; then
- cat >>confdefs.h <<_ACEOF
-#define HAVE_LIBDL 1
-_ACEOF
-
- LIBS="-ldl $LIBS"
+done
+if test "${ac_cv_search_dlopen+set}" = set; then
+ :
+else
+ ac_cv_search_dlopen=no
+fi
+rm conftest.$ac_ext
+LIBS=$ac_func_search_save_LIBS
+fi
+{ echo "$as_me:$LINENO: result: $ac_cv_search_dlopen" >&5
+echo "${ECHO_T}$ac_cv_search_dlopen" >&6; }
+ac_res=$ac_cv_search_dlopen
+if test "$ac_res" != no; then
+ test "$ac_res" = "none required" || LIBS="$ac_res $LIBS"
fi
+dl_libs=$LIBS
+LIBS=$save_LIBS
+
+
+
# Checks for header files.
@@ -23428,6 +23471,236 @@ fi
fi
fi
+#gssapi
+# Check whether --enable-gssapi_krb5 was given.
+if test "${enable_gssapi_krb5+set}" = set; then
+ enableval=$enable_gssapi_krb5; case "${enableval}" in
+ yes) want_gssapi_krb5="yes" ;;
+ no) want_gssapi_krb5="no" ;;
+ *) { { echo "$as_me:$LINENO: error: bad value ${enableval} for --enable-gssapi-krb5" >&5
+echo "$as_me: error: bad value ${enableval} for --enable-gssapi-krb5" >&2;}
+ { (exit 1); exit 1; }; } ;;
+ esac
+else
+ want_gssapi_krb5=no
+
+fi
+
+if test $want_gssapi_krb5 = yes; then
+ { echo "$as_me:$LINENO: checking for gss_acquire_cred in -lgssapi_krb5" >&5
+echo $ECHO_N "checking for gss_acquire_cred in -lgssapi_krb5... $ECHO_C" >&6; }
+if test "${ac_cv_lib_gssapi_krb5_gss_acquire_cred+set}" = set; then
+ echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+ ac_check_lib_save_LIBS=$LIBS
+LIBS="-lgssapi_krb5 $LIBS"
+cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h. */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h. */
+
+/* Override any GCC internal prototype to avoid an error.
+ Use char because int might match the return type of a GCC
+ builtin and then its argument prototype would still apply. */
+#ifdef __cplusplus
+extern "C"
+#endif
+char gss_acquire_cred ();
+int
+main ()
+{
+return gss_acquire_cred ();
+ ;
+ return 0;
+}
+_ACEOF
+rm -f conftest.$ac_objext conftest$ac_exeext
+if { (ac_try="$ac_link"
+case "(($ac_try" in
+ *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+ *) ac_try_echo=$ac_try;;
+esac
+eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
+ (eval "$ac_link") 2>conftest.er1
+ ac_status=$?
+ grep -v '^ *+' conftest.er1 >conftest.err
+ rm -f conftest.er1
+ cat conftest.err >&5
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); } && {
+ test -z "$ac_c_werror_flag" ||
+ test ! -s conftest.err
+ } && test -s conftest$ac_exeext &&
+ $as_test_x conftest$ac_exeext; then
+ ac_cv_lib_gssapi_krb5_gss_acquire_cred=yes
+else
+ echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+ ac_cv_lib_gssapi_krb5_gss_acquire_cred=no
+fi
+
+rm -f core conftest.err conftest.$ac_objext conftest_ipa8_conftest.oo \
+ conftest$ac_exeext conftest.$ac_ext
+LIBS=$ac_check_lib_save_LIBS
+fi
+{ echo "$as_me:$LINENO: result: $ac_cv_lib_gssapi_krb5_gss_acquire_cred" >&5
+echo "${ECHO_T}$ac_cv_lib_gssapi_krb5_gss_acquire_cred" >&6; }
+if test $ac_cv_lib_gssapi_krb5_gss_acquire_cred = yes; then
+
+ if test "${ac_cv_header_gssapi_gssapi_h+set}" = set; then
+ { echo "$as_me:$LINENO: checking for gssapi/gssapi.h" >&5
+echo $ECHO_N "checking for gssapi/gssapi.h... $ECHO_C" >&6; }
+if test "${ac_cv_header_gssapi_gssapi_h+set}" = set; then
+ echo $ECHO_N "(cached) $ECHO_C" >&6
+fi
+{ echo "$as_me:$LINENO: result: $ac_cv_header_gssapi_gssapi_h" >&5
+echo "${ECHO_T}$ac_cv_header_gssapi_gssapi_h" >&6; }
+else
+ # Is the header compilable?
+{ echo "$as_me:$LINENO: checking gssapi/gssapi.h usability" >&5
+echo $ECHO_N "checking gssapi/gssapi.h usability... $ECHO_C" >&6; }
+cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h. */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h. */
+$ac_includes_default
+#include <gssapi/gssapi.h>
+_ACEOF
+rm -f conftest.$ac_objext
+if { (ac_try="$ac_compile"
+case "(($ac_try" in
+ *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+ *) ac_try_echo=$ac_try;;
+esac
+eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
+ (eval "$ac_compile") 2>conftest.er1
+ ac_status=$?
+ grep -v '^ *+' conftest.er1 >conftest.err
+ rm -f conftest.er1
+ cat conftest.err >&5
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); } && {
+ test -z "$ac_c_werror_flag" ||
+ test ! -s conftest.err
+ } && test -s conftest.$ac_objext; then
+ ac_header_compiler=yes
+else
+ echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+ ac_header_compiler=no
+fi
+
+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+{ echo "$as_me:$LINENO: result: $ac_header_compiler" >&5
+echo "${ECHO_T}$ac_header_compiler" >&6; }
+
+# Is the header present?
+{ echo "$as_me:$LINENO: checking gssapi/gssapi.h presence" >&5
+echo $ECHO_N "checking gssapi/gssapi.h presence... $ECHO_C" >&6; }
+cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h. */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h. */
+#include <gssapi/gssapi.h>
+_ACEOF
+if { (ac_try="$ac_cpp conftest.$ac_ext"
+case "(($ac_try" in
+ *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+ *) ac_try_echo=$ac_try;;
+esac
+eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
+ (eval "$ac_cpp conftest.$ac_ext") 2>conftest.er1
+ ac_status=$?
+ grep -v '^ *+' conftest.er1 >conftest.err
+ rm -f conftest.er1
+ cat conftest.err >&5
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); } >/dev/null && {
+ test -z "$ac_c_preproc_warn_flag$ac_c_werror_flag" ||
+ test ! -s conftest.err
+ }; then
+ ac_header_preproc=yes
+else
+ echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+ ac_header_preproc=no
+fi
+
+rm -f conftest.err conftest.$ac_ext
+{ echo "$as_me:$LINENO: result: $ac_header_preproc" >&5
+echo "${ECHO_T}$ac_header_preproc" >&6; }
+
+# So? What about this header?
+case $ac_header_compiler:$ac_header_preproc:$ac_c_preproc_warn_flag in
+ yes:no: )
+ { echo "$as_me:$LINENO: WARNING: gssapi/gssapi.h: accepted by the compiler, rejected by the preprocessor!" >&5
+echo "$as_me: WARNING: gssapi/gssapi.h: accepted by the compiler, rejected by the preprocessor!" >&2;}
+ { echo "$as_me:$LINENO: WARNING: gssapi/gssapi.h: proceeding with the compiler's result" >&5
+echo "$as_me: WARNING: gssapi/gssapi.h: proceeding with the compiler's result" >&2;}
+ ac_header_preproc=yes
+ ;;
+ no:yes:* )
+ { echo "$as_me:$LINENO: WARNING: gssapi/gssapi.h: present but cannot be compiled" >&5
+echo "$as_me: WARNING: gssapi/gssapi.h: present but cannot be compiled" >&2;}
+ { echo "$as_me:$LINENO: WARNING: gssapi/gssapi.h: check for missing prerequisite headers?" >&5
+echo "$as_me: WARNING: gssapi/gssapi.h: check for missing prerequisite headers?" >&2;}
+ { echo "$as_me:$LINENO: WARNING: gssapi/gssapi.h: see the Autoconf documentation" >&5
+echo "$as_me: WARNING: gssapi/gssapi.h: see the Autoconf documentation" >&2;}
+ { echo "$as_me:$LINENO: WARNING: gssapi/gssapi.h: section \"Present But Cannot Be Compiled\"" >&5
+echo "$as_me: WARNING: gssapi/gssapi.h: section \"Present But Cannot Be Compiled\"" >&2;}
+ { echo "$as_me:$LINENO: WARNING: gssapi/gssapi.h: proceeding with the preprocessor's result" >&5
+echo "$as_me: WARNING: gssapi/gssapi.h: proceeding with the preprocessor's result" >&2;}
+ { echo "$as_me:$LINENO: WARNING: gssapi/gssapi.h: in the future, the compiler will take precedence" >&5
+echo "$as_me: WARNING: gssapi/gssapi.h: in the future, the compiler will take precedence" >&2;}
+ ( cat <<\_ASBOX
+## ----------------------------------------- ##
+## Report this to rsyslog@lists.adiscon.com. ##
+## ----------------------------------------- ##
+_ASBOX
+ ) | sed "s/^/$as_me: WARNING: /" >&2
+ ;;
+esac
+{ echo "$as_me:$LINENO: checking for gssapi/gssapi.h" >&5
+echo $ECHO_N "checking for gssapi/gssapi.h... $ECHO_C" >&6; }
+if test "${ac_cv_header_gssapi_gssapi_h+set}" = set; then
+ echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+ ac_cv_header_gssapi_gssapi_h=$ac_header_preproc
+fi
+{ echo "$as_me:$LINENO: result: $ac_cv_header_gssapi_gssapi_h" >&5
+echo "${ECHO_T}$ac_cv_header_gssapi_gssapi_h" >&6; }
+
+fi
+if test $ac_cv_header_gssapi_gssapi_h = yes; then
+
+ { { echo "$as_me:$LINENO: error: GSS-API not ready for primt time yet -- wait for next release" >&5
+echo "$as_me: error: GSS-API not ready for primt time yet -- wait for next release" >&2;}
+ { (exit 1); exit 1; }; };
+
+cat >>confdefs.h <<\_ACEOF
+#define USE_GSSAPI
+_ACEOF
+
+ gss_libs="-lgssapi_krb5"
+
+
+fi
+
+
+
+fi
+
+fi
+
# multithreading via pthreads
# Check whether --enable-pthreads was given.
if test "${enable_pthreads+set}" = set; then
@@ -23824,7 +24097,7 @@ fi
-# SQL support
+# MySQL support
# Check whether --enable-mysql was given.
if test "${enable_mysql+set}" = set; then
enableval=$enable_mysql; case "${enableval}" in
@@ -24122,10 +24395,155 @@ fi
+# PostgreSQL support
+# Check whether --enable-pgsql was given.
+if test "${enable_pgsql+set}" = set; then
+ enableval=$enable_pgsql; case "${enableval}" in
+ yes) enable_pgsql="yes" ;;
+ no) enable_pgsql="no" ;;
+ *) { { echo "$as_me:$LINENO: error: bad value ${enableval} for --enable-pgsql" >&5
+echo "$as_me: error: bad value ${enableval} for --enable-pgsql" >&2;}
+ { (exit 1); exit 1; }; } ;;
+ esac
+else
+ enable_pgsql=no
+
+fi
+
+if test "x$enable_pgsql" = "xyes"; then
+ # Extract the first word of "pg_config", so it can be a program name with args.
+set dummy pg_config; ac_word=$2
+{ echo "$as_me:$LINENO: checking for $ac_word" >&5
+echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6; }
+if test "${ac_cv_prog_HAVE_PGSQL_CONFIG+set}" = set; then
+ echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+ if test -n "$HAVE_PGSQL_CONFIG"; then
+ ac_cv_prog_HAVE_PGSQL_CONFIG="$HAVE_PGSQL_CONFIG" # Let the user override the test.
+else
+as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
+for as_dir in $PATH
+do
+ IFS=$as_save_IFS
+ test -z "$as_dir" && as_dir=.
+ for ac_exec_ext in '' $ac_executable_extensions; do
+ if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
+ ac_cv_prog_HAVE_PGSQL_CONFIG="yes"
+ echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5
+ break 2
+ fi
+done
+done
+IFS=$as_save_IFS
+
+fi
+fi
+HAVE_PGSQL_CONFIG=$ac_cv_prog_HAVE_PGSQL_CONFIG
+if test -n "$HAVE_PGSQL_CONFIG"; then
+ { echo "$as_me:$LINENO: result: $HAVE_PGSQL_CONFIG" >&5
+echo "${ECHO_T}$HAVE_PGSQL_CONFIG" >&6; }
+else
+ { echo "$as_me:$LINENO: result: no" >&5
+echo "${ECHO_T}no" >&6; }
+fi
+
+
+ if test "x${HAVE_PGSQL_CONFIG}" != "xyes"; then
+ { { echo "$as_me:$LINENO: error: pg_config not found in PATH
+See \`config.log' for more details." >&5
+echo "$as_me: error: pg_config not found in PATH
+See \`config.log' for more details." >&2;}
+ { (exit 1); exit 1; }; }
+ fi
+ { echo "$as_me:$LINENO: checking for PQconnectdb in -lpq" >&5
+echo $ECHO_N "checking for PQconnectdb in -lpq... $ECHO_C" >&6; }
+if test "${ac_cv_lib_pq_PQconnectdb+set}" = set; then
+ echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+ ac_check_lib_save_LIBS=$LIBS
+LIBS="-lpq -L`pg_config --libdir`
+ $LIBS"
+cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h. */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h. */
+
+/* Override any GCC internal prototype to avoid an error.
+ Use char because int might match the return type of a GCC
+ builtin and then its argument prototype would still apply. */
+#ifdef __cplusplus
+extern "C"
+#endif
+char PQconnectdb ();
+int
+main ()
+{
+return PQconnectdb ();
+ ;
+ return 0;
+}
+_ACEOF
+rm -f conftest.$ac_objext conftest$ac_exeext
+if { (ac_try="$ac_link"
+case "(($ac_try" in
+ *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+ *) ac_try_echo=$ac_try;;
+esac
+eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
+ (eval "$ac_link") 2>conftest.er1
+ ac_status=$?
+ grep -v '^ *+' conftest.er1 >conftest.err
+ rm -f conftest.er1
+ cat conftest.err >&5
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); } && {
+ test -z "$ac_c_werror_flag" ||
+ test ! -s conftest.err
+ } && test -s conftest$ac_exeext &&
+ $as_test_x conftest$ac_exeext; then
+ ac_cv_lib_pq_PQconnectdb=yes
+else
+ echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+ ac_cv_lib_pq_PQconnectdb=no
+fi
+
+rm -f core conftest.err conftest.$ac_objext conftest_ipa8_conftest.oo \
+ conftest$ac_exeext conftest.$ac_ext
+LIBS=$ac_check_lib_save_LIBS
+fi
+{ echo "$as_me:$LINENO: result: $ac_cv_lib_pq_PQconnectdb" >&5
+echo "${ECHO_T}$ac_cv_lib_pq_PQconnectdb" >&6; }
+if test $ac_cv_lib_pq_PQconnectdb = yes; then
+ pgsql_cflags="-I`pg_config --includedir`"
+ pgsql_libs="`pg_config --libdir` -lpq"
+
+else
+ { { echo "$as_me:$LINENO: error: PgSQL library is missing
+See \`config.log' for more details." >&5
+echo "$as_me: error: PgSQL library is missing
+See \`config.log' for more details." >&2;}
+ { (exit 1); exit 1; }; }
+fi
+
+fi
+ if test x$enable_pgsql = xyes; then
+ ENABLE_PGSQL_TRUE=
+ ENABLE_PGSQL_FALSE='#'
+else
+ ENABLE_PGSQL_TRUE='#'
+ ENABLE_PGSQL_FALSE=
+fi
+
+
+
-ac_config_files="$ac_config_files Makefile doc/Makefile plugins/ommysql/Makefile"
+ac_config_files="$ac_config_files Makefile doc/Makefile plugins/ommysql/Makefile plugins/ompgsql/Makefile"
cat >confcache <<\_ACEOF
# This file is a shell script that caches the results of configure
@@ -24251,6 +24669,13 @@ echo "$as_me: error: conditional \"ENABLE_MYSQL\" was never defined.
Usually this means the macro was only invoked conditionally." >&2;}
{ (exit 1); exit 1; }; }
fi
+if test -z "${ENABLE_PGSQL_TRUE}" && test -z "${ENABLE_PGSQL_FALSE}"; then
+ { { echo "$as_me:$LINENO: error: conditional \"ENABLE_PGSQL\" was never defined.
+Usually this means the macro was only invoked conditionally." >&5
+echo "$as_me: error: conditional \"ENABLE_PGSQL\" was never defined.
+Usually this means the macro was only invoked conditionally." >&2;}
+ { (exit 1); exit 1; }; }
+fi
: ${CONFIG_STATUS=./config.status}
ac_clean_files_save=$ac_clean_files
@@ -24551,7 +24976,7 @@ exec 6>&1
# report actual input values of CONFIG_FILES etc. instead of their
# values after options handling.
ac_log="
-This file was extended by rsyslog $as_me 1.19.12, which was
+This file was extended by rsyslog $as_me 1.20.1, which was
generated by GNU Autoconf 2.61. Invocation command line was
CONFIG_FILES = $CONFIG_FILES
@@ -24604,7 +25029,7 @@ Report bugs to <bug-autoconf@gnu.org>."
_ACEOF
cat >>$CONFIG_STATUS <<_ACEOF
ac_cs_version="\\
-rsyslog config.status 1.19.12
+rsyslog config.status 1.20.1
configured by $0, generated by GNU Autoconf 2.61,
with options \\"`echo "$ac_configure_args" | sed 's/^ //; s/[\\""\`\$]/\\\\&/g'`\\"
@@ -24723,6 +25148,7 @@ do
"Makefile") CONFIG_FILES="$CONFIG_FILES Makefile" ;;
"doc/Makefile") CONFIG_FILES="$CONFIG_FILES doc/Makefile" ;;
"plugins/ommysql/Makefile") CONFIG_FILES="$CONFIG_FILES plugins/ommysql/Makefile" ;;
+ "plugins/ompgsql/Makefile") CONFIG_FILES="$CONFIG_FILES plugins/ompgsql/Makefile" ;;
*) { { echo "$as_me:$LINENO: error: invalid argument: $ac_config_target" >&5
echo "$as_me: error: invalid argument: $ac_config_target" >&2;}
@@ -24928,8 +25354,11 @@ F77!$F77$ac_delim
FFLAGS!$FFLAGS$ac_delim
ac_ct_F77!$ac_ct_F77$ac_delim
LIBTOOL!$LIBTOOL$ac_delim
+rt_libs!$rt_libs$ac_delim
+dl_libs!$dl_libs$ac_delim
LIBOBJS!$LIBOBJS$ac_delim
zlib_libs!$zlib_libs$ac_delim
+gss_libs!$gss_libs$ac_delim
pthreads_libs!$pthreads_libs$ac_delim
pthreads_cflags!$pthreads_cflags$ac_delim
HAVE_MYSQL_CONFIG!$HAVE_MYSQL_CONFIG$ac_delim
@@ -24937,10 +25366,15 @@ ENABLE_MYSQL_TRUE!$ENABLE_MYSQL_TRUE$ac_delim
ENABLE_MYSQL_FALSE!$ENABLE_MYSQL_FALSE$ac_delim
mysql_cflags!$mysql_cflags$ac_delim
mysql_libs!$mysql_libs$ac_delim
+HAVE_PGSQL_CONFIG!$HAVE_PGSQL_CONFIG$ac_delim
+ENABLE_PGSQL_TRUE!$ENABLE_PGSQL_TRUE$ac_delim
+ENABLE_PGSQL_FALSE!$ENABLE_PGSQL_FALSE$ac_delim
+pgsql_cflags!$pgsql_cflags$ac_delim
+pgsql_libs!$pgsql_libs$ac_delim
LTLIBOBJS!$LTLIBOBJS$ac_delim
_ACEOF
- if test `sed -n "s/.*$ac_delim\$/X/p" conf$$subs.sed | grep -c X` = 15; then
+ if test `sed -n "s/.*$ac_delim\$/X/p" conf$$subs.sed | grep -c X` = 23; then
break
elif $ac_last_try; then
{ { echo "$as_me:$LINENO: error: could not make $CONFIG_STATUS" >&5
@@ -25542,12 +25976,14 @@ fi
echo "****************************************************"
echo "rsyslog will be compiled with the following settings:"
echo
-echo "Multithreading support enabled: $enable_pthreads"
-echo "Klogd functionality enabled: $enable_klogd"
-echo "Regular expressions support enabled: $enable_regexp"
-echo "Zlib compression support enabled: $enable_zlib"
-echo "MySql support enabled: $enable_mysql"
-echo "Large file support enabled: $enable_largefile"
-echo "Networking support enabled: $enable_inet"
-echo "Debug mode enabled: $enable_debug"
+echo "Multithreading support enabled: $enable_pthreads"
+echo "Klogd functionality enabled: $enable_klogd"
+echo "Regular expressions support enabled: $enable_regexp"
+echo "Zlib compression support enabled: $enable_zlib"
+echo "MySql support enabled: $enable_mysql"
+echo "PostgreSQL support enabled: $enable_pgsql"
+echo "Large file support enabled: $enable_largefile"
+echo "Networking support enabled: $enable_inet"
+echo "Enable GSSAPI Kerberos 5 support: $want_gssapi_krb5"
+echo "Debug mode enabled: $enable_debug"
diff --git a/configure.ac b/configure.ac
index 8425ea5..5485683 100644
--- a/configure.ac
+++ b/configure.ac
@@ -2,7 +2,7 @@
# Process this file with autoconf to produce a configure script.
AC_PREREQ(2.61)
-AC_INIT([rsyslog],[1.19.12],[rsyslog@lists.adiscon.com.])
+AC_INIT([rsyslog],[1.20.1],[rsyslog@lists.adiscon.com.])
AM_INIT_AUTOMAKE
AC_CONFIG_SRCDIR([syslogd.c])
AC_CONFIG_HEADER([config.h])
@@ -30,8 +30,17 @@ case "${host}" in
esac
# Checks for libraries.
-AC_CHECK_LIB(rt,clock_gettime,,,)
-AC_CHECK_LIB(dl,dlopen,,,)
+save_LIBS=$LIBS
+LIBS=
+AC_SEARCH_LIBS(clock_gettime, rt)
+rt_libs=$LIBS
+LIBS=
+AC_SEARCH_LIBS(dlopen, dl)
+dl_libs=$LIBS
+LIBS=$save_LIBS
+
+AC_SUBST(rt_libs)
+AC_SUBST(dl_libs)
# Checks for header files.
AC_HEADER_RESOLV
@@ -123,6 +132,28 @@ if test "$enable_zlib" = "yes"; then
fi
fi
+#gssapi
+AC_ARG_ENABLE(gssapi_krb5,
+ [AS_HELP_STRING([--enable-gssapi-krb5],[Enable GSSAPI Kerberos 5 support @<:@default=no@:>@])],
+ [case "${enableval}" in
+ yes) want_gssapi_krb5="yes" ;;
+ no) want_gssapi_krb5="no" ;;
+ *) AC_MSG_ERROR(bad value ${enableval} for --enable-gssapi-krb5) ;;
+ esac],
+ [want_gssapi_krb5=no]
+)
+if test $want_gssapi_krb5 = yes; then
+ AC_CHECK_LIB(gssapi_krb5, gss_acquire_cred, [
+ AC_CHECK_HEADER(gssapi/gssapi.h, [
+ AC_MSG_ERROR(GSS-API not ready for primt time yet -- wait for next release);
+ AC_DEFINE(USE_GSSAPI,,
+ Define if you want to use GSSAPI)
+ gss_libs="-lgssapi_krb5"
+ AC_SUBST(gss_libs)
+ ])
+ ])
+fi
+
# multithreading via pthreads
AC_ARG_ENABLE(pthreads,
[AS_HELP_STRING([--enable-pthreads],[Enable multithreading via pthreads @<:@default=yes@:>@])],
@@ -241,7 +272,7 @@ fi
-# SQL support
+# MySQL support
AC_ARG_ENABLE(mysql,
[AS_HELP_STRING([--enable-mysql],[Enable MySql database support @<:@default=no@:>@])],
[case "${enableval}" in
@@ -278,21 +309,55 @@ AM_CONDITIONAL(ENABLE_MYSQL, test x$enable_mysql = xyes)
AC_SUBST(mysql_cflags)
AC_SUBST(mysql_libs)
+# PostgreSQL support
+AC_ARG_ENABLE(pgsql,
+ [AS_HELP_STRING([--enable-pgsql],[Enable PostgreSQL database support @<:@default=no@:>@])],
+ [case "${enableval}" in
+ yes) enable_pgsql="yes" ;;
+ no) enable_pgsql="no" ;;
+ *) AC_MSG_ERROR(bad value ${enableval} for --enable-pgsql) ;;
+ esac],
+ [enable_pgsql=no]
+)
+if test "x$enable_pgsql" = "xyes"; then
+ AC_CHECK_PROG(
+ [HAVE_PGSQL_CONFIG],
+ [pg_config],
+ [yes],,,
+ )
+ if test "x${HAVE_PGSQL_CONFIG}" != "xyes"; then
+ AC_MSG_FAILURE([pg_config not found in PATH])
+ fi
+ AC_CHECK_LIB(
+ [pq],
+ [PQconnectdb],
+ [pgsql_cflags="-I`pg_config --includedir`"
+ pgsql_libs="`pg_config --libdir` -lpq"
+ ],
+ [AC_MSG_FAILURE([PgSQL library is missing])],
+ [-L`pg_config --libdir`]
+ )
+fi
+AM_CONDITIONAL(ENABLE_PGSQL, test x$enable_pgsql = xyes)
+AC_SUBST(pgsql_cflags)
+AC_SUBST(pgsql_libs)
-AC_CONFIG_FILES([Makefile doc/Makefile plugins/ommysql/Makefile])
+AC_CONFIG_FILES([Makefile doc/Makefile plugins/ommysql/Makefile plugins/ompgsql/Makefile])
AC_OUTPUT
echo "****************************************************"
echo "rsyslog will be compiled with the following settings:"
echo
-echo "Multithreading support enabled: $enable_pthreads"
-echo "Klogd functionality enabled: $enable_klogd"
-echo "Regular expressions support enabled: $enable_regexp"
-echo "Zlib compression support enabled: $enable_zlib"
-echo "MySql support enabled: $enable_mysql"
-echo "Large file support enabled: $enable_largefile"
-echo "Networking support enabled: $enable_inet"
-echo "Debug mode enabled: $enable_debug"
+echo "Multithreading support enabled: $enable_pthreads"
+echo "Klogd functionality enabled: $enable_klogd"
+echo "Regular expressions support enabled: $enable_regexp"
+echo "Zlib compression support enabled: $enable_zlib"
+echo "MySql support enabled: $enable_mysql"
+echo "PostgreSQL support enabled: $enable_pgsql"
+echo "Large file support enabled: $enable_largefile"
+echo "Networking support enabled: $enable_inet"
+echo "Enable GSSAPI Kerberos 5 support: $want_gssapi_krb5"
+echo "Debug mode enabled: $enable_debug"
diff --git a/debian/changelog b/debian/changelog
index 1d001f3..f593c8d 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -1,3 +1,32 @@
+rsyslog (1.20.1-1) unstable; urgency=low
+
+ * New upstream release.
+ * debian/rules
+ - Enable the PostgreSQL database support.
+ - Use "install -D" to install the SQL schema file for MySQL and
+ PostgreSQL.
+ * debian/control
+ - Add a Build-Depends on libpq-dev for the PostgreSQL support.
+ - Add the binary package rsyslog-pgsql.
+ * debian/patches/no_create_db.patch
+ - Updated. Only setup the tables. Leave the database creation to
+ dbconfig-common.
+ * debian/rsyslog-pgsql.install
+ - Install the ompgsql.so plugin.
+ * debian/rsyslog-pgsql.config
+ - Preseed the default values for dbconfig-common, database name is
+ "Syslog", database user "rsyslog".
+ * debian/rsyslog-pgsql.{postinst,prerm,postrm}
+ - Use dbconfig-common to setup the PostgreSQL database.
+ - Generate a configuration file /etc/rsyslog.d/pgsql.conf with the values
+ provided by dbconfig-common and use ucf and ucfr to manage this file.
+ * debian/rsyslog-mysql.postinst
+ - Use the new ":ommysql:" output selector instead of ">".
+ * debian/rsyslog-mysql.install
+ - Only install the ommysql.so plugin.
+
+ -- Michael Biebl <biebl@debian.org> Wed, 12 Dec 2007 20:54:41 +0100
+
rsyslog (1.19.12-1) unstable; urgency=low
* New upstream release.
diff --git a/debian/control b/debian/control
index 6bd47a6..3734cb9 100644
--- a/debian/control
+++ b/debian/control
@@ -2,7 +2,7 @@ Source: rsyslog
Section: admin
Priority: extra
Maintainer: Michael Biebl <biebl@debian.org>
-Build-Depends: debhelper (>= 5), quilt, autotools-dev, zlib1g-dev, libmysqlclient15-dev
+Build-Depends: debhelper (>= 5), quilt, autotools-dev, zlib1g-dev, libmysqlclient15-dev, libpq-dev
Standards-Version: 3.7.3
Homepage: http://www.rsyslog.com/
@@ -13,7 +13,7 @@ Replaces: linux-kernel-log-daemon, system-log-daemon
Provides: linux-kernel-log-daemon, system-log-daemon
Depends: ${shlibs:Depends}, ${misc:Depends}, lsb-base (>= 3.0-6)
Recommends: logrotate
-Suggests: rsyslog-mysql
+Suggests: rsyslog-mysql | rsyslog-pgsql
Description: enhanced multi-threaded syslogd
Rsyslog is an enhanced syslogd supporting, amongst others:
* reliable syslog over TCP and RFC 3195
@@ -35,3 +35,11 @@ Depends: ${shlibs:Depends}, ${misc:Depends}, rsyslog (= ${binary:Version}), dbco
Recommends: mysql-server
Description: MySQL output plugin for rsyslog
This plugin allows rsyslog to write the syslog messages into a MySQL database.
+
+Package: rsyslog-pgsql
+Architecture: any
+Depends: ${shlibs:Depends}, ${misc:Depends}, rsyslog (= ${binary:Version}), dbconfig-common, ucf
+Recommends: postgresql
+Description: PostgreSQL output plugin for rsyslog
+ This plugin allows rsyslog to write the syslog messages into a PostgresSQL
+ database.
diff --git a/debian/patches/no_create_db.patch b/debian/patches/no_create_db.patch
index 58d2503..4021e48 100644
--- a/debian/patches/no_create_db.patch
+++ b/debian/patches/no_create_db.patch
@@ -1,7 +1,7 @@
-Index: rsyslog/plugins/ommysql/createDB.sql
+Index: plugins/ommysql/createDB.sql
===================================================================
---- rsyslog.orig/plugins/ommysql/createDB.sql 2007-08-30 01:05:00.000000000 +0200
-+++ rsyslog/plugins/ommysql/createDB.sql 2007-08-30 01:07:50.000000000 +0200
+--- plugins/ommysql/createDB.sql (Revision 994)
++++ plugins/ommysql/createDB.sql (Arbeitskopie)
@@ -1,6 +1,4 @@
-CREATE DATABASE Syslog;
-USE Syslog;
@@ -19,3 +19,13 @@ Index: rsyslog/plugins/ommysql/createDB.sql
(
ID int unsigned not null auto_increment primary key,
SystemEventID int NULL ,
+Index: plugins/ompgsql/createDB.sql
+===================================================================
+--- plugins/ompgsql/createDB.sql (Revision 994)
++++ plugins/ompgsql/createDB.sql (Arbeitskopie)
+@@ -1,5 +1,3 @@
+-CREATE DATABASE "Syslog";
+-\c Syslog;
+ CREATE TABLE SystemEvents
+ (
+ ID serial not null primary key,
diff --git a/debian/patches/series b/debian/patches/series
index a73faf0..b3aa377 100644
--- a/debian/patches/series
+++ b/debian/patches/series
@@ -1,2 +1,2 @@
ignore_non_conf_files.patch -p0
-no_create_db.patch
+no_create_db.patch -p0
diff --git a/debian/rsyslog-mysql.config b/debian/rsyslog-mysql.config
index b9ce31f..9922a80 100644
--- a/debian/rsyslog-mysql.config
+++ b/debian/rsyslog-mysql.config
@@ -1,12 +1,12 @@
#!/bin/sh
# config maintainer script for rsyslog-mysql
-
+
# source debconf stuff
. /usr/share/debconf/confmodule
# source dbconfig-common shell library, and call the hook function
if [ -f /usr/share/dbconfig-common/dpkg/config.mysql ]; then
- . /usr/share/dbconfig-common/dpkg/config.mysql
+ . /usr/share/dbconfig-common/dpkg/config.mysql
dbc_dbname="Syslog"
dbc_dbuser="rsyslog"
diff --git a/debian/rsyslog-mysql.dirs b/debian/rsyslog-mysql.dirs
deleted file mode 100644
index 350e6b9..0000000
--- a/debian/rsyslog-mysql.dirs
+++ /dev/null
@@ -1 +0,0 @@
-usr/share/dbconfig-common/data/rsyslog-mysql/install
diff --git a/debian/rsyslog-mysql.install b/debian/rsyslog-mysql.install
index 2b5a957..0cae021 100644
--- a/debian/rsyslog-mysql.install
+++ b/debian/rsyslog-mysql.install
@@ -1 +1 @@
-debian/tmp/usr/lib/rsyslog/*.so
+debian/tmp/usr/lib/rsyslog/ommysql.so
diff --git a/debian/rsyslog-mysql.postinst b/debian/rsyslog-mysql.postinst
index 30ae5c2..14aae7f 100644
--- a/debian/rsyslog-mysql.postinst
+++ b/debian/rsyslog-mysql.postinst
@@ -41,7 +41,7 @@ case "$1" in
### Changes are preserved
\$ModLoad MySQL
- *.* >$HOST,$DATABASE,$USER,$PASS
+ *.* :ommysql:$HOST,$DATABASE,$USER,$PASS
EOF
ucf --debconf-ok $tempfile /etc/rsyslog.d/mysql.conf
diff --git a/debian/rsyslog-pgsql.config b/debian/rsyslog-pgsql.config
new file mode 100644
index 0000000..d2084ed
--- /dev/null
+++ b/debian/rsyslog-pgsql.config
@@ -0,0 +1,16 @@
+#!/bin/sh
+# config maintainer script for rsyslog-pgsql
+
+# source debconf stuff
+. /usr/share/debconf/confmodule
+
+# source dbconfig-common shell library, and call the hook function
+if [ -f /usr/share/dbconfig-common/dpkg/config.pgsql ]; then
+ . /usr/share/dbconfig-common/dpkg/config.pgsql
+
+ dbc_dbname="Syslog"
+ dbc_dbuser="rsyslog"
+
+ dbc_go rsyslog-pgsql $@
+fi
+
diff --git a/debian/rsyslog-pgsql.install b/debian/rsyslog-pgsql.install
new file mode 100644
index 0000000..e64e899
--- /dev/null
+++ b/debian/rsyslog-pgsql.install
@@ -0,0 +1 @@
+debian/tmp/usr/lib/rsyslog/ompgsql.so
diff --git a/debian/rsyslog-pgsql.postinst b/debian/rsyslog-pgsql.postinst
new file mode 100644
index 0000000..016c72f
--- /dev/null
+++ b/debian/rsyslog-pgsql.postinst
@@ -0,0 +1,66 @@
+#!/bin/sh
+
+set -e
+
+# summary of how this script can be called:
+# * <postinst> `configure' <most-recently-configured-version>
+# * <old-postinst> `abort-upgrade' <new version>
+# * <conflictor's-postinst> `abort-remove' `in-favour' <package>
+# <new-version>
+# * <postinst> `abort-remove'
+# * <deconfigured's-postinst> `abort-deconfigure' `in-favour'
+# <failed-install-package> <version> `removing'
+# <conflicting-package> <version>
+# for details, see http://www.debian.org/doc/debian-policy/ or
+# the debian-policy package
+
+. /usr/share/debconf/confmodule
+. /usr/share/dbconfig-common/dpkg/postinst
+
+
+db_get rsyslog-pgsql/db/dbname
+DATABASE="$RET"
+db_get rsyslog-pgsql/db/app-user
+USER="$RET"
+db_get rsyslog-pgsql/pgsql/app-pass
+PASS="$RET"
+db_get rsyslog-pgsql/remote/host
+HOST="$RET"
+[ -z "$HOST" ] && HOST="localhost"
+
+
+dbc_go rsyslog-pgsql $@
+
+
+case "$1" in
+ configure)
+ tempfile=`tempfile`
+
+ cat <<-EOF > $tempfile
+ ### Configuration file for rsyslog-pgsql
+ ### Changes are preserved
+
+ \$ModLoad ompgsql.so
+ *.* :ompgsql:$HOST,$DATABASE,$USER,$PASS
+ EOF
+
+ ucf --debconf-ok $tempfile /etc/rsyslog.d/pgsql.conf
+ ucfr rsyslog-pgsql /etc/rsyslog.d/pgsql.conf
+ rm -f $tempfile
+
+ invoke-rc.d rsyslog reload
+ ;;
+
+ abort-upgrade|abort-remove|abort-deconfigure)
+ ;;
+
+ *)
+ echo "postinst called with unknown argument \`$1'" >&2
+ exit 1
+ ;;
+esac
+
+
+#DEBHELPER#
+
+exit 0
diff --git a/debian/rsyslog-pgsql.postrm b/debian/rsyslog-pgsql.postrm
new file mode 100644
index 0000000..734b608
--- /dev/null
+++ b/debian/rsyslog-pgsql.postrm
@@ -0,0 +1,55 @@
+#!/bin/sh
+
+set -e
+
+# summary of how this script can be called:
+# * <postrm> `remove'
+# * <postrm> `purge'
+# * <old-postrm> `upgrade' <new-version>
+# * <new-postrm> `failed-upgrade' <old-version>
+# * <new-postrm> `abort-install'
+# * <new-postrm> `abort-install' <old-version>
+# * <new-postrm> `abort-upgrade' <old-version>
+# * <disappearer's-postrm> `disappear' <overwriter>
+# <overwriter-version>
+# for details, see http://www.debian.org/doc/debian-policy/ or
+# the debian-policy package
+
+
+if [ -f /usr/share/debconf/confmodule ]; then
+ . /usr/share/debconf/confmodule
+fi
+if [ -f /usr/share/dbconfig-common/dpkg/postrm ]; then
+ . /usr/share/dbconfig-common/dpkg/postrm
+ dbc_go rsyslog-pgsql $@
+fi
+
+case "$1" in
+ remove|upgrade|failed-upgrade|abort-install|abort-upgrade|disappear)
+ ;;
+ purge)
+ CONFIGFILE=/etc/rsyslog.d/pgsql.conf
+
+ for ext in '~' '%' .bak .ucf-new .ucf-old .ucf-dist; do
+ rm -f $CONFIGFILE$ext
+ done
+
+ rm -f $CONFIGFILE
+
+ if which ucf >/dev/null; then
+ ucf --purge $CONFIGFILE
+ fi
+ if which ucfr >/dev/null; then
+ ucfr --purge rsyslog-pgsql $CONFIGFILE
+ fi
+ ;;
+ *)
+ echo "postrm called with unknown argument \`$1'" >&2
+ exit 1
+ ;;
+esac
+
+
+#DEBHELPER#
+
+exit 0
diff --git a/debian/rsyslog-pgsql.prerm b/debian/rsyslog-pgsql.prerm
new file mode 100644
index 0000000..f595a6b
--- /dev/null
+++ b/debian/rsyslog-pgsql.prerm
@@ -0,0 +1,12 @@
+#!/bin/sh
+
+set -e
+
+. /usr/share/debconf/confmodule
+. /usr/share/dbconfig-common/dpkg/prerm
+
+dbc_go rsyslog-pgsql $@
+
+#DEBHELPER#
+
+exit 0
diff --git a/debian/rules b/debian/rules
index 0c52fdc..febe446 100755
--- a/debian/rules
+++ b/debian/rules
@@ -36,6 +36,7 @@ endif
--mandir=\$${prefix}/share/man \
--infodir=\$${prefix}/share/info \
--enable-mysql \
+ --enable-pgsql \
CFLAGS="$(CFLAGS)"
@@ -70,7 +71,8 @@ install: build
# Add here commands to install the package into debian/rsyslog.
$(MAKE) DESTDIR=$(CURDIR)/debian/tmp install
- cp plugins/ommysql/createDB.sql debian/rsyslog-mysql/usr/share/dbconfig-common/data/rsyslog-mysql/install/mysql
+ install --mode=644 -D plugins/ommysql/createDB.sql debian/rsyslog-mysql/usr/share/dbconfig-common/data/rsyslog-mysql/install/mysql
+ install --mode=644 -D plugins/ompgsql/createDB.sql debian/rsyslog-pgsql/usr/share/dbconfig-common/data/rsyslog-pgsql/install/pgsql
# Build architecture-independent files here.
binary-indep: build install
diff --git a/doc/Makefile.in b/doc/Makefile.in
index 723a251..e239bb6 100644
--- a/doc/Makefile.in
+++ b/doc/Makefile.in
@@ -72,6 +72,7 @@ F77 = @F77@
FFLAGS = @FFLAGS@
GREP = @GREP@
HAVE_MYSQL_CONFIG = @HAVE_MYSQL_CONFIG@
+HAVE_PGSQL_CONFIG = @HAVE_PGSQL_CONFIG@
INSTALL = @INSTALL@
INSTALL_DATA = @INSTALL_DATA@
INSTALL_PROGRAM = @INSTALL_PROGRAM@
@@ -120,9 +121,11 @@ build_vendor = @build_vendor@
builddir = @builddir@
datadir = @datadir@
datarootdir = @datarootdir@
+dl_libs = @dl_libs@
docdir = @docdir@
dvidir = @dvidir@
exec_prefix = @exec_prefix@
+gss_libs = @gss_libs@
host = @host@
host_alias = @host_alias@
host_cpu = @host_cpu@
@@ -142,11 +145,14 @@ mysql_cflags = @mysql_cflags@
mysql_libs = @mysql_libs@
oldincludedir = @oldincludedir@
pdfdir = @pdfdir@
+pgsql_cflags = @pgsql_cflags@
+pgsql_libs = @pgsql_libs@
prefix = @prefix@
program_transform_name = @program_transform_name@
psdir = @psdir@
pthreads_cflags = @pthreads_cflags@
pthreads_libs = @pthreads_libs@
+rt_libs = @rt_libs@
sbindir = @sbindir@
sharedstatedir = @sharedstatedir@
srcdir = @srcdir@
diff --git a/doc/features.html b/doc/features.html
index 6f2e7e8..e3685d1 100644
--- a/doc/features.html
+++ b/doc/features.html
@@ -13,7 +13,8 @@ is going on, you can also subscribe to the <a href="http://lists.adiscon.net/mai
<h2>Current Features</h2>
<ul>
- <li>native support for <a href="rsyslog_mysql.html">writing to MySQL databases</a><li>support for (plain) tcp
+ <li>native support for <a href="rsyslog_mysql.html">writing to MySQL databases</a><li>
+ native support for writing to Postgres databases<li>support for (plain) tcp
based syslog - much better reliability<li>support for sending and receiving
compressed syslog messages<li>ability to configure backup syslog/database
servers - if the primary fails, control is switched to a prioritized list of
@@ -44,7 +45,8 @@ is going on, you can also subscribe to the <a href="http://lists.adiscon.net/mai
supports sub-configuration files, which can be automatically read from
directories. Includes are specified in the main configuration file<li>
supports multiple actions per selector/filter condition<li>
- MySQL functionality as a dynamically loadable plug-in</ul>
+ MySQL and Postgres SQL functionality as a dynamically loadable plug-in<li>
+ modular design for outputs - easily extensible</ul>
<p>&nbsp;</p>
<h2>Upcoming Features</h2>
<p>The list below is something like a repository of ideas we'd like to
diff --git a/doc/history.html b/doc/history.html
index cd43229..4cb6d56 100644
--- a/doc/history.html
+++ b/doc/history.html
@@ -82,7 +82,20 @@ quite happy about that. To facilitate user contributions, we set up a
2.0.0 release. With its appearance, the pace of changes was deliberately reduced,
in order to allow it to mature (see Rainers's
<a href="http://rgerhards.blogspot.com/2007/07/pace-of-changes-in-rsyslog.html">
-blog post</a> on this topic, written a bit early, but covering the essence).<p>Be sure to visit Rainer's <a href="http://rgerhards.blogspot.com/">syslog block</a>
+blog post</a> on this topic, written a bit early, but covering the essence).<p>
+In <b>November 2007</b>, rsyslog became the default syslogd in Fedora 8.
+Obviously, that was something we *really* liked. Community involvement also is
+still growing. There is one sad thing to note: ever since summer, there is an
+extremely hard to find segfault bug. It happens on very rare occasions only and
+never in lab. We are hunting this bug for month now, but still could not get
+hold of it. Unfortunately, this also affects the new features schedule. It makes
+limited sense to implement new features if problems with existing ones are not
+really understood.<p><b>December 2008</b> showed the appearance of a postgres
+output module, contributed by sur5r. With 1.20.0, December is also the first
+time since the bughunt that we introduce other new features. It has been deciced
+that we carefully will add features in order to not affect the overall project
+by these rare bugs. Still, the bughunt is top priortiy, but we need to have more
+data to analyse.<p>Be sure to visit Rainer's <a href="http://rgerhards.blogspot.com/">syslog blog</a>
to get some more insight into the development and futures of rsyslog and syslog in general.
Don't be shy to post to either the blog or the
<a href="http://www.rsyslog.com/PNphpBB2.phtml">rsyslog forums</a>.</p>
diff --git a/doc/manual.html b/doc/manual.html
index 4155390..5a77696 100644
--- a/doc/manual.html
+++ b/doc/manual.html
@@ -5,7 +5,7 @@
<body>
<h1>RSyslog - Documentation</h1>
<p><b><a href="http://www.rsyslog.com/">Rsyslog</a> is an enhanced syslogd
-supporting, among others, <a href="rsyslog_mysql.html">MySQL</a>, <a href="http://wiki.rsyslog.com/index.php/FailoverSyslogServer">failover log destinations</a>, syslog/tcp,
+supporting, among others, <a href="rsyslog_mysql.html">MySQL</a>, PostgreSQL, <a href="http://wiki.rsyslog.com/index.php/FailoverSyslogServer">failover log destinations</a>, syslog/tcp,
fine grain output format control, and the ability to filter on any message part.</b>
It is quite compatible to stock
sysklogd and can be used as a drop-in replacement. Its <a href="features.html">
diff --git a/doc/rsconf1_modload.html b/doc/rsconf1_modload.html
index c9b4294..37623a1 100644
--- a/doc/rsconf1_modload.html
+++ b/doc/rsconf1_modload.html
@@ -8,8 +8,9 @@
<p><b>Default:</b> </p>
<p><b>Description:</b></p>
<p>Dynamically loads a plug-in into rsyslog's address space and activates it.
-The plug-in must obey the rsyslog module API. Currently, only MySQL is available
-as a plugin, but others may create their own. A plug-in must be loaded BEFORE
+The plug-in must obey the rsyslog module API. Currently, only MySQL and Postgres
+output modules are available
+as a plugins, but users may create their own. A plug-in must be loaded BEFORE
any configuration file lines that reference it.</p>
<p>Modules must be present in the system default destination for rsyslog
modules. You can also set the directory via the <a href="rsconf1_moddir.html">
@@ -18,7 +19,7 @@ $ModDir</a> directive.</p>
default module directory is ignored in that case.</p>
<p><b>Sample:</b></p>
<p><code><b>$ModLoad MySQL&nbsp; # load MySQL functionality<br>
-$ModLoad /rsyslog/modules/somemodule.so # load a module via absolute path</b></code></p>
+$ModLoad /rsyslog/modules/ompgsql.so # load the postgres module via absolute path</b></code></p>
<p>[<a href="rsyslog_conf.html">rsyslog.conf overview</a>] [<a href="manual.html">manual
index</a>] [<a href="http://www.rsyslog.com/">rsyslog site</a>]</p>
diff --git a/doc/rsyslog_conf.html b/doc/rsyslog_conf.html
index 266a6dc..3ee2ae6 100644
--- a/doc/rsyslog_conf.html
+++ b/doc/rsyslog_conf.html
@@ -11,6 +11,9 @@ appearance.</b></p>
by a command line option.</p>
<p><a href="http://wiki.rsyslog.com/index.php/Configuration_Samples">
Configuration file examples can be found in the rsyslog wiki</a>.</p>
+<p>There is also one sample file provided together with the documentation set.
+If you do not like to read, be sure to have at least a quick look at
+<a href="rsyslog-example.conf">rsyslog-example.conf</a>. </p>
<p>While rsyslogd contains enhancements over standard syslogd, efforts have been
made to keep the configuration file as compatible as possible. While, for
obvious reasons, <a href="features.html">enhanced features</a> require a
@@ -40,6 +43,9 @@ a description.</p>
<li><a href="rsconf1_filecreatemode.html">$FileCreateMode</a></li>
<li><a href="rsconf1_filegroup.html">$FileGroup</a></li>
<li><a href="rsconf1_fileowner.html">$FileOwner</a></li>
+ <li><a href="rsconf1_gssforwardservicename.html">$GssForwardServiceName</a></li>
+ <li><a href="rsconf1_gsslistenservicename.html">$GssListenServiceName</a></li>
+ <li><a href="rsconf1_gssmode.html">$GssMode</a></li>
<li><a href="rsconf1_includeconfig.html">$IncludeConfig</a></li>
<li><a href="rsconf1_mainmsgqueuesize.html">$MainMsgQueueSize</a></li>
<li><a href="rsconf1_moddir.html">$ModDir</a></li>
diff --git a/doc/status.html b/doc/status.html
index 3027c67..b401a1e 100644
--- a/doc/status.html
+++ b/doc/status.html
@@ -4,11 +4,11 @@
</head>
<body>
<h2>rsyslog status page</h2>
-<p>This page reflects the status as of 2007-12-03.</p>
+<p>This page reflects the status as of 2007-12-07.</p>
<h2>Current Releases</h2>
-<p><b>development:</b> 1.19.12 -
-<a href="http://www.rsyslog.com/Article142.phtml">change log</a> -
-<a href="http://www.rsyslog.com/Downloads-index-req-getit-lid-64.phtml">download</a></p>
+<p><b>development:</b> 1.20.0 -
+<a href="http://www.rsyslog.com/Article145.phtml">change log</a> -
+<a href="http://www.rsyslog.com/Downloads-index-req-getit-lid-65.phtml">download</a></p>
<p><b>stable:</b> 1.0.5 - <a href="http://www.rsyslog.com/Article85.phtml">change log</a> -
<a href="http://www.rsyslog.com/Downloads-index-req-getit-lid-39.phtml">download</a></p>
<p>&nbsp;(<a href="version_naming.html">How are versions named?</a>)</p>
@@ -22,6 +22,7 @@ rsyslog to other platforms. As such,
maintained inside the rsyslog wiki</a>. Platform maintainers perhaps have posted
extra information there. If you do platform-specific work, feel free to add
information to the wiki.</p>
+<p>Rsyslog is the default syslogd in Fedora 8.</p>
<h2>Additional information</h2>
<p><b>Currently supported features are listed on the <a href="features.html">rsyslog features page</a>.</b></p>
<ul>
diff --git a/expr.c b/expr.c
new file mode 100644
index 0000000..4da1036
--- /dev/null
+++ b/expr.c
@@ -0,0 +1,40 @@
+/* expr.c - an expression class.
+ * This module contains all code needed to represent expressions. Most
+ * importantly, that means code to parse and execute them. Expressions
+ * heavily depend on (loadable) functions, so it works in conjunction
+ * with the function manager.
+ *
+ * Module begun 2007-11-30 by Rainer Gerhards
+ *
+ * Copyright 2007 Rainer Gerhards and Adiscon GmbH.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ *
+ * A copy of the GPL can be found in the file "COPYING" in this distribution.
+ */
+
+/* This is the syntax of an expression. I keep it as inline documentation
+ * as this enhances the chance that it is updates should there be a change.
+ *
+ * expr = (simple-string / template-string / function / property) [* expr ]
+ * simple-string = "'" chars "'"
+ * template-string = '"' template-as--1.19.11-and-below '"'
+ * ; string as used in previous $template directive
+ * function = function-name "(" expr ")"
+ * property = [list of property names]
+ */
+
+/* vi:set ai:
+ */
diff --git a/gss-misc.c b/gss-misc.c
new file mode 100644
index 0000000..68197f0
--- /dev/null
+++ b/gss-misc.c
@@ -0,0 +1,210 @@
+#include "config.h"
+#if defined(SYSLOG_INET) && defined(USE_GSSAPI)
+#include "rsyslog.h"
+#include <stdio.h>
+#include <stdarg.h>
+#include <stdlib.h>
+#include <string.h>
+#include <time.h>
+#include <netinet/in.h>
+#include <netdb.h>
+#include <arpa/inet.h>
+#include <fnmatch.h>
+#include <assert.h>
+#include <errno.h>
+#include <ctype.h>
+#include <unistd.h>
+#ifdef USE_PTHREADS
+#include <pthread.h>
+#else
+#include <fcntl.h>
+#endif
+#include <gssapi.h>
+#include "syslogd.h"
+#include "syslogd-types.h"
+#include "srUtils.h"
+#include "net.h"
+#include "omfwd.h"
+#include "template.h"
+#include "msg.h"
+#include "tcpsyslog.h"
+#include "module-template.h"
+#include "gss-misc.h"
+
+
+static void display_status_(char *m, OM_uint32 code, int type)
+{
+ OM_uint32 maj_stat, min_stat, msg_ctx = 0;
+ gss_buffer_desc msg;
+
+ do {
+ maj_stat = gss_display_status(&min_stat, code, type, GSS_C_NO_OID, &msg_ctx, &msg);
+ if (maj_stat != GSS_S_COMPLETE) {
+ logerrorSz("GSS-API error in gss_display_status called from <%s>\n", m);
+ break;
+ } else {
+ char buf[1024];
+ snprintf(buf, sizeof(buf), "GSS-API error %s: %s\n", m, (char *) msg.value);
+ buf[sizeof(buf)/sizeof(char) - 1] = '\0';
+ logerror(buf);
+ }
+ if (msg.length != 0)
+ gss_release_buffer(&min_stat, &msg);
+ } while (msg_ctx);
+}
+
+
+void display_status(char *m, OM_uint32 maj_stat, OM_uint32 min_stat)
+{
+ display_status_(m, maj_stat, GSS_C_GSS_CODE);
+ display_status_(m, min_stat, GSS_C_MECH_CODE);
+}
+
+
+void display_ctx_flags(OM_uint32 flags)
+{
+ if (flags & GSS_C_DELEG_FLAG)
+ dbgprintf("GSS_C_DELEG_FLAG\n");
+ if (flags & GSS_C_MUTUAL_FLAG)
+ dbgprintf("GSS_C_MUTUAL_FLAG\n");
+ if (flags & GSS_C_REPLAY_FLAG)
+ dbgprintf("GSS_C_REPLAY_FLAG\n");
+ if (flags & GSS_C_SEQUENCE_FLAG)
+ dbgprintf("GSS_C_SEQUENCE_FLAG\n");
+ if (flags & GSS_C_CONF_FLAG)
+ dbgprintf("GSS_C_CONF_FLAG\n");
+ if (flags & GSS_C_INTEG_FLAG)
+ dbgprintf("GSS_C_INTEG_FLAG\n");
+}
+
+
+static int read_all(int fd, char *buf, unsigned int nbyte)
+{
+ int ret;
+ char *ptr;
+ fd_set rfds;
+ struct timeval tv;
+
+ FD_ZERO(&rfds);
+ FD_SET(fd, &rfds);
+ tv.tv_sec = 1;
+ tv.tv_usec = 0;
+
+ for (ptr = buf; nbyte; ptr += ret, nbyte -= ret) {
+ if ((ret = select(FD_SETSIZE, &rfds, NULL, NULL, &tv)) <= 0
+ || !FD_ISSET(fd, &rfds))
+ return ret;
+ ret = recv(fd, ptr, nbyte, 0);
+ if (ret < 0) {
+ if (errno == EINTR)
+ continue;
+ return (ret);
+ } else if (ret == 0) {
+ return (ptr - buf);
+ }
+ }
+
+ return (ptr - buf);
+}
+
+
+static int write_all(int fd, char *buf, unsigned int nbyte)
+{
+ int ret;
+ char *ptr;
+
+ for (ptr = buf; nbyte; ptr += ret, nbyte -= ret) {
+ ret = send(fd, ptr, nbyte, 0);
+ if (ret < 0) {
+ if (errno == EINTR)
+ continue;
+ return (ret);
+ } else if (ret == 0) {
+ return (ptr - buf);
+ }
+ }
+
+ return (ptr - buf);
+}
+
+
+int recv_token(int s, gss_buffer_t tok)
+{
+ int ret;
+ unsigned char lenbuf[4];
+ unsigned int len;
+
+ ret = read_all(s, (char *) lenbuf, 4);
+ if (ret < 0) {
+ logerror("GSS-API error reading token length");
+ return -1;
+ } else if (!ret) {
+ return 0;
+ } else if (ret != 4) {
+ logerror("GSS-API error reading token length");
+ return -1;
+ }
+
+ len = ((lenbuf[0] << 24)
+ | (lenbuf[1] << 16)
+ | (lenbuf[2] << 8)
+ | lenbuf[3]);
+ tok->length = ntohl(len);
+
+ tok->value = (char *) malloc(tok->length ? tok->length : 1);
+ if (tok->length && tok->value == NULL) {
+ logerror("Out of memory allocating token data\n");
+ return -1;
+ }
+
+ ret = read_all(s, (char *) tok->value, tok->length);
+ if (ret < 0) {
+ logerror("GSS-API error reading token data");
+ free(tok->value);
+ return -1;
+ } else if (ret != (int) tok->length) {
+ logerror("GSS-API error reading token data");
+ free(tok->value);
+ return -1;
+ }
+
+ return 1;
+}
+
+
+int send_token(int s, gss_buffer_t tok)
+{
+ int ret;
+ unsigned char lenbuf[4];
+ unsigned int len;
+
+ if (tok->length > 0xffffffffUL)
+ abort(); /* TODO: we need to reconsider this, abort() is not really a solution - degrade, but keep running */
+ len = htonl(tok->length);
+ lenbuf[0] = (len >> 24) & 0xff;
+ lenbuf[1] = (len >> 16) & 0xff;
+ lenbuf[2] = (len >> 8) & 0xff;
+ lenbuf[3] = len & 0xff;
+
+ ret = write_all(s, (char *) lenbuf, 4);
+ if (ret < 0) {
+ logerror("GSS-API error sending token length");
+ return -1;
+ } else if (ret != 4) {
+ logerror("GSS-API error sending token length");
+ return -1;
+ }
+
+ ret = write_all(s, tok->value, tok->length);
+ if (ret < 0) {
+ logerror("GSS-API error sending token data");
+ return -1;
+ } else if (ret != (int) tok->length) {
+ logerror("GSS-API error sending token data");
+ return -1;
+ }
+
+ return 0;
+}
+
+#endif /* #if defined(SYSLOG_INET) && defined(USE_GSSAPI) */
diff --git a/gss-misc.h b/gss-misc.h
new file mode 100644
index 0000000..9c879d1
--- /dev/null
+++ b/gss-misc.h
@@ -0,0 +1,11 @@
+#ifndef GSS_MISC_H_INCLUDED
+#define GSS_MISC_H_INCLUDED 1
+
+#include <gssapi.h>
+
+int recv_token(int s, gss_buffer_t tok);
+int send_token(int s, gss_buffer_t tok);
+void display_status(char *m, OM_uint32 maj_stat, OM_uint32 min_stat);
+void display_ctx_flags(OM_uint32 flags);
+
+#endif /* #ifndef GSS_MISC_H_INCLUDED */
diff --git a/linkedlist.c b/linkedlist.c
index b9239b4..bea2cb9 100644
--- a/linkedlist.c
+++ b/linkedlist.c
@@ -229,36 +229,124 @@ finalize_it:
}
-/* find a user element based on the provided key
+/* unlink a requested element. As we have singly-linked lists, the
+ * caller also needs to pass in the previous element (or NULL, if it is the
+ * root element).
+ * rgerhards, 2007-11-21
*/
-rsRetVal llFind(linkedList_t *pThis, void *pKey, void **ppData)
+static rsRetVal llUnlinkElt(linkedList_t *pThis, llElt_t *pElt, llElt_t *pEltPrev)
+{
+ assert(pElt != NULL);
+
+ if(pEltPrev == NULL) { /* root element? */
+ pThis->pRoot = pElt->pNext;
+ } else { /* regular element */
+ pEltPrev->pNext = pElt->pNext;
+ }
+
+ if(pElt == pThis->pLast)
+ pThis->pLast = pEltPrev;
+
+ return RS_RET_OK;
+}
+
+
+/* unlinks and immediately deletes an element. Previous element must
+ * be given (or zero if the root element is to be deleted).
+ * rgerhards, 2007-11-21
+ */
+static rsRetVal llUnlinkAndDelteElt(linkedList_t *pThis, llElt_t *pElt, llElt_t *pEltPrev)
+{
+ DEFiRet;
+
+ assert(pElt != NULL);
+
+ CHKiRet(llUnlinkElt(pThis, pElt, pEltPrev));
+ CHKiRet(llDestroyElt(pThis, pElt));
+
+finalize_it:
+ return iRet;
+}
+
+/* find a user element based on the provided key - this is the
+ * internal variant, which also tracks the last element pointer
+ * before the found element. This is necessary to delete elements.
+ * NULL means there is no element in front of it, aka the found elt
+ * is the root elt.
+ * rgerhards, 2007-11-21
+ */
+static rsRetVal llFindElt(linkedList_t *pThis, void *pKey, llElt_t **ppElt, llElt_t **ppEltPrev)
{
DEFiRet;
llElt_t *pElt;
+ llElt_t *pEltPrev = NULL;
int bFound = 0;
assert(pThis != NULL);
assert(pKey != NULL);
- assert(ppData != NULL);
+ assert(ppElt != NULL);
+ assert(ppEltPrev != NULL);
pElt = pThis->pRoot;
while(pElt != NULL && bFound == 0) {
if(pThis->cmpOp(pKey, pElt->pKey) == 0)
bFound = 1;
- else
+ else {
+ pEltPrev = pElt;
pElt = pElt->pNext;
+ }
}
if(bFound == 1) {
- *ppData = pElt->pData;
- } else {
+ *ppElt = pElt;
+ *ppEltPrev = pEltPrev;
+ } else
iRet = RS_RET_NOT_FOUND;
- }
return iRet;
}
+/* find a user element based on the provided key
+ */
+rsRetVal llFind(linkedList_t *pThis, void *pKey, void **ppData)
+{
+ DEFiRet;
+ llElt_t *pElt;
+ llElt_t *pEltPrev;
+
+ CHKiRet(llFindElt(pThis, pKey, &pElt, &pEltPrev));
+
+ /* if we reach this point, we have found the element */
+ *ppData = pElt->pData;
+
+finalize_it:
+ return iRet;
+}
+
+
+/* find a delete an element based on user-provided key. The element is
+ * delete, the caller does not receive anything. If we need to receive
+ * the element before destruction, we may implement an llFindAndUnlink()
+ * at that time.
+ * rgerhards, 2007-11-21
+ */
+rsRetVal llFindAndDelete(linkedList_t *pThis, void *pKey)
+{
+ DEFiRet;
+ llElt_t *pElt;
+ llElt_t *pEltPrev;
+
+ CHKiRet(llFindElt(pThis, pKey, &pElt, &pEltPrev));
+
+ /* if we reach this point, we have found an element */
+ CHKiRet(llUnlinkAndDelteElt(pThis, pElt, pEltPrev));
+
+finalize_it:
+ return iRet;
+}
+
+
/* provide the count of linked list elements
*/
rsRetVal llGetNumElts(linkedList_t *pThis, int *piCnt)
@@ -279,6 +367,9 @@ rsRetVal llGetNumElts(linkedList_t *pThis, int *piCnt)
* or a pointer to a structure with more data. If the user-supplied
* function does not return RS_RET_OK, this function here terminates.
* rgerhards, 2007-08-02
+ * rgerhards, 2007-11-21: added functionality to delete a list element.
+ * If the called user function returns RS_RET_OK_DELETE_LISTENTRY the current element
+ * is deleted.
*/
rsRetVal llExecFunc(linkedList_t *pThis, rsRetVal (*pFunc)(void*, void*), void* pParam)
{
@@ -286,12 +377,25 @@ rsRetVal llExecFunc(linkedList_t *pThis, rsRetVal (*pFunc)(void*, void*), void*
rsRetVal iRetLL;
void *pData;
linkedListCookie_t llCookie = NULL;
+ linkedListCookie_t llCookiePrev = NULL; /* previous list element (needed for deletion, NULL = at root) */
assert(pThis != NULL);
assert(pFunc != NULL);
while((iRetLL = llGetNextElt(pThis, &llCookie, (void**)&pData)) == RS_RET_OK) {
- CHKiRet(pFunc(pData, pParam));
+ iRet = pFunc(pData, pParam);
+ if(iRet == RS_RET_OK_DELETE_LISTENTRY) {
+ /* delete element */
+ CHKiRet(llUnlinkAndDelteElt(pThis, llCookie, llCookiePrev));
+ /* we need to revert back, as we have just deleted the current element.
+ * So the actual current element is the one before it, which happens to be
+ * stored in llCookiePrev. -- rgerhards, 2007-11-21
+ */
+ llCookie = llCookiePrev;
+ } else if (iRet != RS_RET_OK) {
+ goto finalize_it;
+ }
+ llCookiePrev = llCookie;
}
if(iRetLL != RS_RET_END_OF_LINKEDLIST)
diff --git a/linkedlist.h b/linkedlist.h
index aafbcf8..e4de9c1 100644
--- a/linkedlist.h
+++ b/linkedlist.h
@@ -61,6 +61,7 @@ rsRetVal llFind(linkedList_t *pThis, void *pKey, void **ppData);
rsRetVal llGetKey(llElt_t *pThis, void *ppData);
rsRetVal llGetNumElts(linkedList_t *pThis, int *piCnt);
rsRetVal llExecFunc(linkedList_t *pThis, rsRetVal (*pFunc)(void*, void*), void* pParam);
+rsRetVal llFindAndDelete(linkedList_t *pThis, void *pKey);
/* use the macro below to define a function that will be executed by
* llExecFunc()
*/
diff --git a/module-template.h b/module-template.h
index e3fe06d..13ae4b8 100644
--- a/module-template.h
+++ b/module-template.h
@@ -32,6 +32,28 @@
#define DEF_OMOD_STATIC_DATA \
static rsRetVal (*omsdRegCFSLineHdlr)();
+/* macro to define a unique module id. This must be able to fit in a void*. The
+ * module id must be unique inside a running rsyslogd application. It is used to
+ * track ownership of several objects. Most importantly, when the module is
+ * unloaded the module id value is used to find what needs to be destroyed.
+ * We currently use a pointer to modExit() as the module id. This sounds to be
+ * reasonable save, as each module must have this entry point AND there is no valid
+ * reason for twice this entry point being in memory.
+ * rgerhards, 2007-11-21
+ */
+#define STD_LOADABLE_MODULE_ID ((void*) modExit)
+
+
+/* macro to implement the "modGetID()" interface function
+ * rgerhards 2007-11-21
+ */
+#define DEFmodGetID \
+static rsRetVal modGetID(void **pID) \
+ { \
+ *pID = STD_LOADABLE_MODULE_ID;\
+ return RS_RET_OK;\
+ }
+
/* to following macros are used to generate function headers and standard
* functionality. It works as follows (described on the sample case of
* createInstance()):
@@ -63,6 +85,13 @@ static rsRetVal createInstance(instanceData **ppData)\
}
/* freeInstance()
+ * This is the cleanup function for the module instance. It is called immediately before
+ * the module instance is destroyed (unloaded). The module should do any cleanup
+ * here, e.g. close file, free instantance heap memory and the like. Control will
+ * not be passed back to the module once this function is finished. Keep in mind,
+ * however, that other instances may still be loaded and used. So do not destroy
+ * anything that may be used by another instance. If you have such a ressource, you
+ * currently need to do the instance counting yourself.
*/
#define BEGINfreeInstance \
static rsRetVal freeInstance(void* pModData)\
@@ -265,6 +294,7 @@ static rsRetVal tryResume(instanceData __attribute__((unused)) *pData)\
/* queryEtryPt()
*/
#define BEGINqueryEtryPt \
+DEFmodGetID \
static rsRetVal queryEtryPt(uchar *name, rsRetVal (**pEtryPoint)())\
{\
DEFiRet;
@@ -284,7 +314,7 @@ static rsRetVal queryEtryPt(uchar *name, rsRetVal (**pEtryPoint)())\
* modules. This can be used if no specific handling (e.g. to cover version
* differences) is needed.
*/
-#define CODEqueryEtryPt_STD_OMOD_QUERIES\
+#define CODEqueryEtryPt_STD_OMOD_QUERIES \
if(!strcmp((char*) name, "doAction")) {\
*pEtryPoint = doAction;\
} else if(!strcmp((char*) name, "parseSelectorAct")) {\
@@ -295,6 +325,8 @@ static rsRetVal queryEtryPt(uchar *name, rsRetVal (**pEtryPoint)())\
*pEtryPoint = dbgPrintInstInfo;\
} else if(!strcmp((char*) name, "freeInstance")) {\
*pEtryPoint = freeInstance;\
+ } else if(!strcmp((char*) name, "modExit")) {\
+ *pEtryPoint = modExit;\
} else if(!strcmp((char*) name, "getWriteFDForSelect")) {\
*pEtryPoint = getWriteFDForSelect;\
} else if(!strcmp((char*) name, "onSelectReadyWrite")) {\
@@ -303,12 +335,22 @@ static rsRetVal queryEtryPt(uchar *name, rsRetVal (**pEtryPoint)())\
*pEtryPoint = needUDPSocket;\
} else if(!strcmp((char*) name, "tryResume")) {\
*pEtryPoint = tryResume;\
+ } else if(!strcmp((char*) name, "modGetID")) {\
+ *pEtryPoint = modGetID;\
}
+
/* modInit()
* This has an extra parameter, which is the specific name of the modInit
* function. That is needed for built-in modules, which must have unique
- * names in order to link statically.
+ * names in order to link statically. Please note that this is alwaysy only
+ * the case with modInit() and NO other entry point. The reason is that only
+ * modInit() is visible form a linker/loader point of view. All other entry
+ * points are passed via rsyslog-internal query functions and are defined
+ * static inside the modules source. This is an important concept, as it allows
+ * us to support different interface versions within a single module. (Granted,
+ * we do not currently have different interface versions, so we can not put
+ * it to a test - but our firm believe is that we can do all abstraction needed...)
*
* Extra Comments:
* initialize the module
@@ -316,9 +358,12 @@ static rsRetVal queryEtryPt(uchar *name, rsRetVal (**pEtryPoint)())\
* Later, much more must be done. So far, we only return a pointer
* to the queryEtryPt() function
* TODO: do interface version checking & handshaking
- * iIfVersRequeted is the version of the interface specification that the
+ * iIfVersRequetsed is the version of the interface specification that the
* caller would like to see being used. ipIFVersProvided is what we
* decide to provide.
+ * rgerhards, 2007-11-21: see modExit() comment below for important information
+ * on the need to initialize static data with code. modInit() may be called on a
+ * cached, left-in-memory copy of a previous incarnation.
*/
#define BEGINmodInit(uniqName) \
rsRetVal modInit##uniqName(int iIFVersRequested __attribute__((unused)), int *ipIFVersProvided, rsRetVal (**pQueryEtryPt)(), rsRetVal (*pHostQueryEtryPt)(uchar*, rsRetVal (**)()))\
@@ -342,6 +387,30 @@ finalize_it:\
CHKiRet(pHostQueryEtryPt((uchar*)"regCfSysLineHdlr", &omsdRegCFSLineHdlr));
#endif /* #ifndef MODULE_TEMPLATE_H_INCLUDED */
+
+/* modExit()
+ * This is the counterpart to modInit(). It destroys a module and makes it ready for
+ * unloading. It is similiar to freeInstance() for the instance data. Please note that
+ * this entry point needs to free any module-globale data structures and registrations.
+ * For example, the CfSysLineHandlers a module has registered need to be unregistered
+ * here. This entry point is only called immediately before unloading of the module. So
+ * it is likely to be destroyed. HOWEVER, the caller may decide to keep the module cached.
+ * So a module must never assume that it is actually destroyed. A call to modInit() may
+ * happen immediately after modExit(). So a module can NOT assume that static data elements
+ * are being re-initialized by the loader - this must always be done by module code itself.
+ * It is suggested to do this in modInit(). - rgerhards, 2007-11-21
+ */
+#define BEGINmodExit \
+static rsRetVal modExit(void)\
+{\
+ DEFiRet;
+
+#define CODESTARTmodExit
+
+#define ENDmodExit \
+ return iRet;\
+}
+
/*
* vi:set ai:
*/
diff --git a/modules.c b/modules.c
index 11aad03..f04c4a9 100644
--- a/modules.c
+++ b/modules.c
@@ -42,7 +42,7 @@
#include "modules.h"
static modInfo_t *pLoadedModules = NULL; /* list of currently-loaded modules */
-static modInfo_t *pLoadedModulesLast = NULL; /* tail-pointer */
+static modInfo_t *pLoadedModulesLast = NULL; /* tail-pointer */
static int bCfsyslineInitialized = 0;
@@ -64,8 +64,9 @@ static rsRetVal moduleConstruct(modInfo_t **pThis)
}
-/* Destructs a module objects. The object must not be linked to the
- * linked list of modules.
+/* Destructs a module object. The object must not be linked to the
+ * linked list of modules. Please note that all other dependencies on this
+ * modules must have been removed before (e.g. CfSysLineHandlers!)
*/
static void moduleDestruct(modInfo_t *pThis)
{
@@ -168,25 +169,32 @@ modInfo_t *omodGetNxt(modInfo_t *pThis)
}
-/* unload a module. If this is called with a statically-linked
- * (builtin) module, nothing happens.
- * The module handle is invalid after this function call and
- * MUST NOT be used any more.
- * This is currently a dummy, to be filled when we have a plug-in interface
- * rgerhards, 2007-08-09
+/* Prepare a module for unloading.
+ * This is currently a dummy, to be filled when we have a plug-in
+ * interface - rgerhards, 2007-08-09
+ * rgerhards, 2007-11-21:
+ * When this function is called, all instance-data must already have
+ * been destroyed. In the case of output modules, this happens when the
+ * rule set is being destroyed. When we implement other module types, we
+ * need to think how we handle it there (and if we have any instance data).
*/
-static rsRetVal modUnload(modInfo_t *pThis)
+static rsRetVal modPrepareUnload(modInfo_t *pThis)
{
DEFiRet;
+ void *pModCookie;
assert(pThis != NULL);
- if(pThis->eLinkType == eMOD_LINK_STATIC) {
- ABORT_FINALIZE(RS_RET_OK);
- }
+ /* WARNING - the current code does NOT work and causes an abort - this is acceptable right now
+ * as I am DEVELOPING the working code and will NOT release until it is there. If you use a
+ * CVS snapshot, be aware of this limitation. For now, you can just remove everything up to
+ * (but not including) the END DEVEL comment. That will do the trick. rgerhards, 2007-11-21
+ */
+ CHKiRet(pThis->modGetID(&pModCookie));
+ pThis->modExit(); /* tell the module to get ready for unload */
+ CHKiRet(unregCfSysLineHdlrs4Owner(pModCookie));
- /* TODO: implement code */
- ABORT_FINALIZE(RS_RET_NOT_IMPLEMENTED);
+ /* END DEVEL */
finalize_it:
return iRet;
@@ -263,6 +271,14 @@ rsRetVal doModInit(rsRetVal (*modInit)(int, int*, rsRetVal(**)(), rsRetVal(*)())
moduleDestruct(pNew);
return iRet;
}
+ if((iRet = (*pNew->modQueryEtryPt)((uchar*)"modGetID", &pNew->modGetID)) != RS_RET_OK) {
+ moduleDestruct(pNew);
+ return iRet;
+ }
+ if((iRet = (*pNew->modQueryEtryPt)((uchar*)"modExit", &pNew->modExit)) != RS_RET_OK) {
+ moduleDestruct(pNew);
+ return iRet;
+ }
pNew->pszName = (uchar*) strdup((char*)name); /* we do not care if strdup() fails, we can accept that */
pNew->pModHdlr = pModHdlr;
@@ -306,11 +322,11 @@ void modPrintList(void)
}
dbgprintf(" module.\n");
dbgprintf("Entry points:\n");
- dbgprintf("\tqueryEtryPt: 0x%x\n", (unsigned) pMod->modQueryEtryPt);
- dbgprintf("\tdoAction: 0x%x\n", (unsigned) pMod->mod.om.doAction);
- dbgprintf("\tparseSelectorAct: 0x%x\n", (unsigned) pMod->mod.om.parseSelectorAct);
- dbgprintf("\tdbgPrintInstInfo: 0x%x\n", (unsigned) pMod->dbgPrintInstInfo);
- dbgprintf("\tfreeInstance: 0x%x\n", (unsigned) pMod->freeInstance);
+ dbgprintf("\tqueryEtryPt: 0x%lx\n", (unsigned long) pMod->modQueryEtryPt);
+ dbgprintf("\tdoAction: 0x%lx\n", (unsigned long) pMod->mod.om.doAction);
+ dbgprintf("\tparseSelectorAct: 0x%lx\n", (unsigned long) pMod->mod.om.parseSelectorAct);
+ dbgprintf("\tdbgPrintInstInfo: 0x%lx\n", (unsigned long) pMod->dbgPrintInstInfo);
+ dbgprintf("\tfreeInstance: 0x%lx\n", (unsigned long) pMod->freeInstance);
dbgprintf("\n");
pMod = modGetNxt(pMod); /* done, go next */
}
@@ -332,7 +348,7 @@ rsRetVal modUnloadAndDestructAll(void)
pMod = modGetNxt(pModPrev); /* get next */
/* now we can destroy the previous module */
dbgprintf("Unloading module %s\n", modGetName(pModPrev));
- modUnload(pModPrev);
+ modPrepareUnload(pModPrev);
moduleDestruct(pModPrev);
}
@@ -355,6 +371,7 @@ rsRetVal modUnloadAndDestructDynamic(void)
/* now we can destroy the previous module */
if(pModPrev->eLinkType != eMOD_LINK_STATIC) {
dbgprintf("Unloading module %s\n", modGetName(pModPrev));
+ modPrepareUnload(pModPrev);
moduleDestruct(pModPrev);
} else {
pLoadedModulesLast = pModPrev;
diff --git a/modules.h b/modules.h
index 3f008a6..4782d31 100644
--- a/modules.h
+++ b/modules.h
@@ -62,7 +62,8 @@ typedef struct moduleInfo {
rsRetVal (*needUDPSocket)(void*);/* called when fd is writeable after select() */
rsRetVal (*dbgPrintInstInfo)(void*);/* called before termination or module unload */
rsRetVal (*tryResume)(void*);/* called to see if module actin can be resumed now */
- rsRetVal (*modExit)(); /* called before termination or module unload */
+ rsRetVal (*modExit)(void); /* called before termination or module unload */
+ rsRetVal (*modGetID)(void **); /* get its unique ID from module */
/* below: parse a configuration line - return if processed
* or not. If not, must be parsed to next module.
*/
diff --git a/msg.c b/msg.c
index 632ef9b..5b211b8 100644
--- a/msg.c
+++ b/msg.c
@@ -40,6 +40,50 @@
#include "template.h"
#include "msg.h"
+static syslogCODE rs_prioritynames[] =
+ {
+ { "alert", LOG_ALERT },
+ { "crit", LOG_CRIT },
+ { "debug", LOG_DEBUG },
+ { "emerg", LOG_EMERG },
+ { "err", LOG_ERR },
+ { "error", LOG_ERR }, /* DEPRECATED */
+ { "info", LOG_INFO },
+ { "none", INTERNAL_NOPRI }, /* INTERNAL */
+ { "notice", LOG_NOTICE },
+ { "panic", LOG_EMERG }, /* DEPRECATED */
+ { "warn", LOG_WARNING }, /* DEPRECATED */
+ { "warning", LOG_WARNING },
+ { NULL, -1 }
+ };
+
+static syslogCODE rs_facilitynames[] =
+ {
+ { "auth", LOG_AUTH },
+ { "authpriv", LOG_AUTHPRIV },
+ { "cron", LOG_CRON },
+ { "daemon", LOG_DAEMON },
+ { "ftp", LOG_FTP },
+ { "kern", LOG_KERN },
+ { "lpr", LOG_LPR },
+ { "mail", LOG_MAIL },
+ { "mark", INTERNAL_MARK }, /* INTERNAL */
+ { "news", LOG_NEWS },
+ { "security", LOG_AUTH }, /* DEPRECATED */
+ { "syslog", LOG_SYSLOG },
+ { "user", LOG_USER },
+ { "uucp", LOG_UUCP },
+ { "local0", LOG_LOCAL0 },
+ { "local1", LOG_LOCAL1 },
+ { "local2", LOG_LOCAL2 },
+ { "local3", LOG_LOCAL3 },
+ { "local4", LOG_LOCAL4 },
+ { "local5", LOG_LOCAL5 },
+ { "local6", LOG_LOCAL6 },
+ { "local7", LOG_LOCAL7 },
+ { NULL, -1 }
+ };
+
/* The following functions will support advanced output module
* multithreading, once this is implemented. Currently, we
* include them as hooks only. The idea is that we need to guard
@@ -117,12 +161,16 @@ void MsgDestruct(msg_t * pM)
free(pM->pszRcvdAt3339);
if(pM->pszRcvdAt_MySQL != NULL)
free(pM->pszRcvdAt_MySQL);
+ if(pM->pszRcvdAt_PgSQL != NULL)
+ free(pM->pszRcvdAt_PgSQL);
if(pM->pszTIMESTAMP3164 != NULL)
free(pM->pszTIMESTAMP3164);
if(pM->pszTIMESTAMP3339 != NULL)
free(pM->pszTIMESTAMP3339);
if(pM->pszTIMESTAMP_MySQL != NULL)
free(pM->pszTIMESTAMP_MySQL);
+ if(pM->pszTIMESTAMP_PgSQL != NULL)
+ free(pM->pszTIMESTAMP_PgSQL);
if(pM->pszPRI != NULL)
free(pM->pszPRI);
if(pM->pCSProgName != NULL)
@@ -492,6 +540,18 @@ char *getTimeReported(msg_t *pM, enum tplFormatTypes eFmt)
}
MsgUnlock();
return(pM->pszTIMESTAMP_MySQL);
+ case tplFmtPgSQLDate:
+ MsgLock();
+ if(pM->pszTIMESTAMP_PgSQL == NULL) {
+ if((pM->pszTIMESTAMP_PgSQL = malloc(21)) == NULL) {
+ glblHadMemShortage = 1;
+ MsgUnlock();
+ return "";
+ }
+ formatTimestampToPgSQL(&pM->tTIMESTAMP, pM->pszTIMESTAMP_PgSQL, 21);
+ }
+ MsgUnlock();
+ return(pM->pszTIMESTAMP_PgSQL);
case tplFmtRFC3164Date:
MsgLock();
if(pM->pszTIMESTAMP3164 == NULL) {
@@ -510,7 +570,7 @@ char *getTimeReported(msg_t *pM, enum tplFormatTypes eFmt)
if((pM->pszTIMESTAMP3339 = malloc(33)) == NULL) {
glblHadMemShortage = 1;
MsgUnlock();
- return "";
+ return ""; /* TODO: check this: can it cause a free() of constant memory?) */
}
formatTimestamp3339(&pM->tTIMESTAMP, pM->pszTIMESTAMP3339, 33);
}
@@ -550,6 +610,18 @@ char *getTimeGenerated(msg_t *pM, enum tplFormatTypes eFmt)
}
MsgUnlock();
return(pM->pszRcvdAt_MySQL);
+ case tplFmtPgSQLDate:
+ MsgLock();
+ if(pM->pszRcvdAt_PgSQL == NULL) {
+ if((pM->pszRcvdAt_PgSQL = malloc(21)) == NULL) {
+ glblHadMemShortage = 1;
+ MsgUnlock();
+ return "";
+ }
+ formatTimestampToPgSQL(&pM->tRcvdAt, pM->pszRcvdAt_PgSQL, 21);
+ }
+ MsgUnlock();
+ return(pM->pszRcvdAt_PgSQL);
case tplFmtRFC3164Date:
MsgLock();
if(pM->pszRcvdAt3164 == NULL) {
@@ -1118,7 +1190,7 @@ void MsgSetMSG(msg_t *pMsg, char* pszMSG)
free(pMsg->pszMSG);
pMsg->iLenMSG = strlen(pszMSG);
- if((pMsg->pszMSG = malloc(pMsg->iLenMSG + 1)) != NULL)
+ if((pMsg->pszMSG = (uchar*) malloc(pMsg->iLenMSG + 1)) != NULL)
memcpy(pMsg->pszMSG, pszMSG, pMsg->iLenMSG + 1);
else
dbgprintf("MsgSetMSG could not allocate memory for pszMSG buffer.");
@@ -1133,7 +1205,7 @@ void MsgSetRawMsg(msg_t *pMsg, char* pszRawMsg)
free(pMsg->pszRawMsg);
pMsg->iLenRawMsg = strlen(pszRawMsg);
- if((pMsg->pszRawMsg = malloc(pMsg->iLenRawMsg + 1)) != NULL)
+ if((pMsg->pszRawMsg = (uchar*) malloc(pMsg->iLenRawMsg + 1)) != NULL)
memcpy(pMsg->pszRawMsg, pszRawMsg, pMsg->iLenRawMsg + 1);
else
dbgprintf("Could not allocate memory for pszRawMsg buffer.");
@@ -1537,7 +1609,7 @@ char *MsgGetProp(msg_t *pMsg, struct templateEntry *pTpe,
pSrc = pRes;
while(*pSrc) {
*pB++ = (pTpe->data.field.eCaseConv == tplCaseConvUpper) ?
- toupper(*pSrc) : tolower(*pSrc);
+ (char)toupper((int)*pSrc) : (char)tolower((int)*pSrc);
/* currently only these two exist */
++pSrc;
}
diff --git a/msg.h b/msg.h
index 8f411f7..3ad63b4 100644
--- a/msg.h
+++ b/msg.h
@@ -91,10 +91,12 @@ struct msg {
char *pszRcvdAt3164; /* time as RFC3164 formatted string (always 15 charcters) */
char *pszRcvdAt3339; /* time as RFC3164 formatted string (32 charcters at most) */
char *pszRcvdAt_MySQL; /* rcvdAt as MySQL formatted string (always 14 charcters) */
+ char *pszRcvdAt_PgSQL; /* rcvdAt as PgSQL formatted string (always 21 characters) */
struct syslogTime tTIMESTAMP;/* (parsed) value of the timestamp */
char *pszTIMESTAMP3164; /* TIMESTAMP as RFC3164 formatted string (always 15 charcters) */
char *pszTIMESTAMP3339; /* TIMESTAMP as RFC3339 formatted string (32 charcters at most) */
char *pszTIMESTAMP_MySQL;/* TIMESTAMP as MySQL formatted string (always 14 charcters) */
+ char *pszTIMESTAMP_PgSQL;/* TIMESTAMP as PgSQL formatted string (always 21 characters) */
int msgFlags; /* flags associated with this message */
};
typedef struct msg msg_t; /* new name */
diff --git a/omdiscard.c b/omdiscard.c
index d335003..bcd9ba2 100644
--- a/omdiscard.c
+++ b/omdiscard.c
@@ -111,6 +111,11 @@ CODESTARTgetWriteFDForSelect
ENDgetWriteFDForSelect
+BEGINmodExit
+CODESTARTmodExit
+ENDmodExit
+
+
BEGINqueryEtryPt
CODESTARTqueryEtryPt
CODEqueryEtryPt_STD_OMOD_QUERIES
diff --git a/omfile.c b/omfile.c
index d6cfa86..3691d98 100644
--- a/omfile.c
+++ b/omfile.c
@@ -792,6 +792,11 @@ static rsRetVal resetConfigVariables(uchar __attribute__((unused)) *pp, void __a
}
+BEGINmodExit
+CODESTARTmodExit
+ENDmodExit
+
+
BEGINqueryEtryPt
CODESTARTqueryEtryPt
CODEqueryEtryPt_STD_OMOD_QUERIES
@@ -802,18 +807,17 @@ BEGINmodInit(File)
CODESTARTmodInit
*ipIFVersProvided = 1; /* so far, we only support the initial definition */
CODEmodInit_QueryRegCFSLineHdlr
- CHKiRet(omsdRegCFSLineHdlr((uchar *)"dynafilecachesize", 0, eCmdHdlrInt, (void*) setDynaFileCacheSize, NULL));
- CHKiRet(omsdRegCFSLineHdlr((uchar *)"dirowner", 0, eCmdHdlrUID, NULL, &dirUID));
- CHKiRet(omsdRegCFSLineHdlr((uchar *)"dirgroup", 0, eCmdHdlrGID, NULL, &dirGID));
- CHKiRet(omsdRegCFSLineHdlr((uchar *)"fileowner", 0, eCmdHdlrUID, NULL, &fileUID));
- CHKiRet(omsdRegCFSLineHdlr((uchar *)"filegroup", 0, eCmdHdlrGID, NULL, &fileGID));
- CHKiRet(omsdRegCFSLineHdlr((uchar *)"dircreatemode", 0, eCmdHdlrFileCreateMode, NULL, &fDirCreateMode));
- CHKiRet(omsdRegCFSLineHdlr((uchar *)"filecreatemode", 0, eCmdHdlrFileCreateMode, NULL, &fCreateMode));
- CHKiRet(omsdRegCFSLineHdlr((uchar *)"createdirs", 0, eCmdHdlrBinary, NULL, &bCreateDirs));
- CHKiRet(omsdRegCFSLineHdlr((uchar *)"failonchownfailure", 0, eCmdHdlrBinary, NULL, &bFailOnChown));
- CHKiRet(omsdRegCFSLineHdlr((uchar *)"resetconfigvariables", 1, eCmdHdlrCustomHandler, resetConfigVariables, NULL));
+ CHKiRet(omsdRegCFSLineHdlr((uchar *)"dynafilecachesize", 0, eCmdHdlrInt, (void*) setDynaFileCacheSize, NULL, STD_LOADABLE_MODULE_ID));
+ CHKiRet(omsdRegCFSLineHdlr((uchar *)"dirowner", 0, eCmdHdlrUID, NULL, &dirUID, STD_LOADABLE_MODULE_ID));
+ CHKiRet(omsdRegCFSLineHdlr((uchar *)"dirgroup", 0, eCmdHdlrGID, NULL, &dirGID, STD_LOADABLE_MODULE_ID));
+ CHKiRet(omsdRegCFSLineHdlr((uchar *)"fileowner", 0, eCmdHdlrUID, NULL, &fileUID, STD_LOADABLE_MODULE_ID));
+ CHKiRet(omsdRegCFSLineHdlr((uchar *)"filegroup", 0, eCmdHdlrGID, NULL, &fileGID, STD_LOADABLE_MODULE_ID));
+ CHKiRet(omsdRegCFSLineHdlr((uchar *)"dircreatemode", 0, eCmdHdlrFileCreateMode, NULL, &fDirCreateMode, STD_LOADABLE_MODULE_ID));
+ CHKiRet(omsdRegCFSLineHdlr((uchar *)"filecreatemode", 0, eCmdHdlrFileCreateMode, NULL, &fCreateMode, STD_LOADABLE_MODULE_ID));
+ CHKiRet(omsdRegCFSLineHdlr((uchar *)"createdirs", 0, eCmdHdlrBinary, NULL, &bCreateDirs, STD_LOADABLE_MODULE_ID));
+ CHKiRet(omsdRegCFSLineHdlr((uchar *)"failonchownfailure", 0, eCmdHdlrBinary, NULL, &bFailOnChown, STD_LOADABLE_MODULE_ID));
+ CHKiRet(omsdRegCFSLineHdlr((uchar *)"resetconfigvariables", 1, eCmdHdlrCustomHandler, resetConfigVariables, NULL, STD_LOADABLE_MODULE_ID));
ENDmodInit
-
/*
* vi:set ai:
*/
diff --git a/omfwd.c b/omfwd.c
index 07ff7ac..f21480b 100644
--- a/omfwd.c
+++ b/omfwd.c
@@ -48,6 +48,9 @@
#else
#include <fcntl.h>
#endif
+#ifdef USE_GSSAPI
+#include <gssapi.h>
+#endif
#include "syslogd.h"
#include "syslogd-types.h"
#include "srUtils.h"
@@ -56,11 +59,14 @@
#include "template.h"
#include "msg.h"
#include "tcpsyslog.h"
+#include "cfsysline.h"
#include "module-template.h"
+#ifdef USE_GSSAPI
+#include "gss-misc.h"
+#endif
#ifdef SYSLOG_INET
-//#define INET_SUSPEND_TIME 60 /* equal to 1 minute
-#define INET_SUSPEND_TIME 2 /* equal to 1 minute
+#define INET_SUSPEND_TIME 60 /* equal to 1 minute
* rgerhards, 2005-07-26: This was 3 minutes. As the
* same timer is used for tcp based syslog, we have
* reduced it. However, it might actually be worth
@@ -108,8 +114,21 @@ typedef struct _instanceData {
# ifdef USE_PTHREADS
pthread_mutex_t mtxTCPSend;
# endif
+# ifdef USE_GSSAPI
+ gss_ctx_id_t gss_context;
+ OM_uint32 gss_flags;
+# endif
} instanceData;
+#ifdef USE_GSSAPI
+static char *gss_base_service_name = NULL;
+static enum gss_mode_t {
+ GSSMODE_NONE,
+ GSSMODE_MIC,
+ GSSMODE_ENC
+} gss_mode;
+#endif
+
BEGINcreateInstance
CODESTARTcreateInstance
@@ -141,6 +160,24 @@ CODESTARTfreeInstance
pthread_mutex_destroy(&pData->mtxTCPSend);
}
# endif
+# ifdef USE_GSSAPI
+ if (gss_mode != GSSMODE_NONE) {
+ OM_uint32 maj_stat, min_stat;
+
+ if (pData->gss_context != GSS_C_NO_CONTEXT) {
+ maj_stat = gss_delete_sec_context(&min_stat, pData->gss_context, GSS_C_NO_BUFFER);
+ if (maj_stat != GSS_S_COMPLETE)
+ display_status("deleting context", maj_stat, min_stat);
+ }
+ }
+ /* this is meant to be done when module is unloaded,
+ but since this module is static...
+ */
+ if (gss_base_service_name != NULL) {
+ free(gss_base_service_name);
+ gss_base_service_name = NULL;
+ }
+# endif
ENDfreeInstance
@@ -256,6 +293,153 @@ static int TCPSendCreateSocket(instanceData *pData, struct addrinfo *addrDest)
return -1;
}
+
+#ifdef USE_GSSAPI
+static int TCPSendGSSInit(instanceData *pData)
+{
+ int s = -1;
+ char *base;
+ OM_uint32 maj_stat, min_stat, init_sec_min_stat, *sess_flags, ret_flags;
+ gss_buffer_desc out_tok, in_tok;
+ gss_buffer_t tok_ptr;
+ gss_name_t target_name;
+ gss_ctx_id_t *context;
+
+ assert(pData != NULL);
+
+ base = (gss_base_service_name == NULL) ? "host" : gss_base_service_name;
+ out_tok.length = strlen(pData->f_hname) + strlen(base) + 2;
+ if ((out_tok.value = malloc(out_tok.length)) == NULL)
+ return -1;
+ strcpy(out_tok.value, base);
+ strcat(out_tok.value, "@");
+ strcat(out_tok.value, pData->f_hname);
+ dbgprintf("GSS-API service name: %s\n", out_tok.value);
+
+ tok_ptr = GSS_C_NO_BUFFER;
+ context = &pData->gss_context;
+ *context = GSS_C_NO_CONTEXT;
+
+ maj_stat = gss_import_name(&min_stat, &out_tok, GSS_C_NT_HOSTBASED_SERVICE, &target_name);
+ free(out_tok.value);
+ out_tok.value = NULL;
+ out_tok.length = 0;
+
+ if (maj_stat != GSS_S_COMPLETE) {
+ display_status("parsing name", maj_stat, min_stat);
+ goto fail;
+ }
+
+ sess_flags = &pData->gss_flags;
+ *sess_flags = GSS_C_MUTUAL_FLAG;
+ if (gss_mode == GSSMODE_MIC) {
+ *sess_flags |= GSS_C_INTEG_FLAG;
+ }
+ if (gss_mode == GSSMODE_ENC) {
+ *sess_flags |= GSS_C_CONF_FLAG;
+ }
+ dbgprintf("GSS-API requested context flags:\n");
+ display_ctx_flags(*sess_flags);
+
+ do {
+ maj_stat = gss_init_sec_context(&init_sec_min_stat, GSS_C_NO_CREDENTIAL, context,
+ target_name, GSS_C_NO_OID, *sess_flags, 0, NULL,
+ tok_ptr, NULL, &out_tok, &ret_flags, NULL);
+ if (tok_ptr != GSS_C_NO_BUFFER)
+ free(in_tok.value);
+
+ if (maj_stat != GSS_S_COMPLETE
+ && maj_stat != GSS_S_CONTINUE_NEEDED) {
+ display_status("initializing context", maj_stat, init_sec_min_stat);
+ goto fail;
+ }
+
+ if (s == -1)
+ if ((s = pData->sock = TCPSendCreateSocket(pData, pData->f_addr)) == -1)
+ goto fail;
+
+ if (out_tok.length != 0) {
+ dbgprintf("GSS-API Sending init_sec_context token (length: %d)\n", out_tok.length);
+ if (send_token(s, &out_tok) < 0) {
+ goto fail;
+ }
+ }
+ gss_release_buffer(&min_stat, &out_tok);
+
+ if (maj_stat == GSS_S_CONTINUE_NEEDED) {
+ dbgprintf("GSS-API Continue needed...\n");
+ if (recv_token(s, &in_tok) <= 0) {
+ goto fail;
+ }
+ tok_ptr = &in_tok;
+ }
+ } while (maj_stat == GSS_S_CONTINUE_NEEDED);
+
+ dbgprintf("GSS-API Provided context flags:\n");
+ *sess_flags = ret_flags;
+ display_ctx_flags(*sess_flags);
+
+ dbgprintf("GSS-API Context initialized\n");
+ gss_release_name(&min_stat, &target_name);
+
+ return 0;
+
+ fail:
+ logerror("GSS-API Context initialization failed\n");
+ gss_release_name(&min_stat, &target_name);
+ gss_release_buffer(&min_stat, &out_tok);
+ if (*context != GSS_C_NO_CONTEXT) {
+ gss_delete_sec_context(&min_stat, context, GSS_C_NO_BUFFER);
+ *context = GSS_C_NO_CONTEXT;
+ }
+ if (s != -1)
+ close(s);
+ pData->sock = -1;
+ return -1;
+}
+
+
+static int TCPSendGSSSend(instanceData *pData, char *msg, size_t len)
+{
+ int s;
+ gss_ctx_id_t *context;
+ OM_uint32 maj_stat, min_stat;
+ gss_buffer_desc in_buf, out_buf;
+
+ assert(pData != NULL);
+ assert(msg != NULL);
+ assert(len > 0);
+
+ s = pData->sock;
+ context = &pData->gss_context;
+ in_buf.value = msg;
+ in_buf.length = len;
+ maj_stat = gss_wrap(&min_stat, *context, (gss_mode == GSSMODE_ENC) ? 1 : 0, GSS_C_QOP_DEFAULT,
+ &in_buf, NULL, &out_buf);
+ if (maj_stat != GSS_S_COMPLETE) {
+ display_status("wrapping message", maj_stat, min_stat);
+ goto fail;
+ }
+
+ if (send_token(s, &out_buf) < 0) {
+ goto fail;
+ }
+ gss_release_buffer(&min_stat, &out_buf);
+
+ return 0;
+
+ fail:
+ close(s);
+ pData->sock = -1;
+ TCPSendSetStatus(pData, TCP_SEND_NOTCONNECTED);
+ gss_delete_sec_context(&min_stat, context, GSS_C_NO_BUFFER);
+ *context = GSS_C_NO_CONTEXT;
+ gss_release_buffer(&min_stat, &out_buf);
+ return -1;
+}
+#endif /* #ifdef USE_GSSAPI */
+
+
/* Sends a TCP message. It is first checked if the
* session is open and, if not, it is opened. Then the send
* is tried. If it fails, one silent re-try is made. If the send
@@ -314,9 +498,14 @@ static int TCPSend(instanceData *pData, char *msg, size_t len)
do { /* try to send message */
if(pData->sock <= 0) {
/* we need to open the socket first */
- if((pData->sock = TCPSendCreateSocket(pData, pData->f_addr)) <= 0) {
- return -1;
- }
+# ifdef USE_GSSAPI
+ if(gss_mode != GSSMODE_NONE) {
+ if(TCPSendGSSInit(pData) != 0)
+ return -1;
+ } else
+# endif
+ if((pData->sock = TCPSendCreateSocket(pData, pData->f_addr)) <= 0)
+ return -1;
}
eState = TCPSendGetStatus(pData); /* cache info */
@@ -447,68 +636,91 @@ static int TCPSend(instanceData *pData, char *msg, size_t len)
}
/* frame building complete, on to actual sending */
-
- lenSend = send(pData->sock, msg, len, 0);
- dbgprintf("TCP sent %d bytes, requested %d, msg: '%s'\n", lenSend, len,
- bIsCompressed ? "***compressed***" : msg);
- if((unsigned)lenSend == len) {
- /* all well */
- if(buf != NULL) {
- free(buf);
+# ifdef USE_GSSAPI
+ if(gss_mode != GSSMODE_NONE) {
+ if(TCPSendGSSSend(pData, msg, len) == 0) {
+ if(buf != NULL) {
+ free(buf);
+ }
+ return 0;
+ } else {
+ if(retry == 0) {
+ ++retry;
+ /* try to recover */
+ continue;
+ } else {
+ if(buf != NULL)
+ free(buf);
+ dbgprintf("message not (tcp)send");
+ return -1;
+ }
}
- return 0;
- } else if(lenSend != -1) {
- /* no real error, could "just" not send everything...
- * For the time being, we ignore this...
- * rgerhards, 2005-10-25
- */
- dbgprintf("message not completely (tcp)send, ignoring %d\n", lenSend);
+ } else {
+# endif
+ lenSend = send(pData->sock, msg, len, 0);
+ dbgprintf("TCP sent %d bytes, requested %d, msg: '%s'\n", lenSend, len,
+ bIsCompressed ? "***compressed***" : msg);
+ if((unsigned)lenSend == len) {
+ /* all well */
+ if(buf != NULL) {
+ free(buf);
+ }
+ return 0;
+ } else if(lenSend != -1) {
+ /* no real error, could "just" not send everything...
+ * For the time being, we ignore this...
+ * rgerhards, 2005-10-25
+ */
+ dbgprintf("message not completely (tcp)send, ignoring %d\n", lenSend);
# if USE_PTHREADS
- usleep(1000); /* experimental - might be benefitial in this situation */
+ usleep(1000); /* experimental - might be benefitial in this situation */
# endif
- if(buf != NULL)
- free(buf);
- return 0;
- }
+ if(buf != NULL)
+ free(buf);
+ return 0;
+ }
- switch(errno) {
- case EMSGSIZE:
- dbgprintf("message not (tcp)send, too large\n");
- /* This is not a real error, so it is not flagged as one */
- if(buf != NULL)
- free(buf);
- return 0;
- break;
- case EINPROGRESS:
- case EAGAIN:
- dbgprintf("message not (tcp)send, would block\n");
+ switch(errno) {
+ case EMSGSIZE:
+ dbgprintf("message not (tcp)send, too large\n");
+ /* This is not a real error, so it is not flagged as one */
+ if(buf != NULL)
+ free(buf);
+ return 0;
+ break;
+ case EINPROGRESS:
+ case EAGAIN:
+ dbgprintf("message not (tcp)send, would block\n");
# if USE_PTHREADS
- usleep(1000); /* experimental - might be benefitial in this situation */
+ usleep(1000); /* experimental - might be benefitial in this situation */
# endif
- /* we loose this message, but that's better than loosing
- * all ;)
- */
- /* This is not a real error, so it is not flagged as one */
- if(buf != NULL)
- free(buf);
- return 0;
- break;
- default:
- dbgprintf("message not (tcp)send");
- break;
- }
+ /* we loose this message, but that's better than loosing
+ * all ;)
+ */
+ /* This is not a real error, so it is not flagged as one */
+ if(buf != NULL)
+ free(buf);
+ return 0;
+ break;
+ default:
+ dbgprintf("message not (tcp)send");
+ break;
+ }
- if(retry == 0) {
- ++retry;
- /* try to recover */
- close(pData->sock);
- TCPSendSetStatus(pData, TCP_SEND_NOTCONNECTED);
- pData->sock = -1;
- } else {
- if(buf != NULL)
- free(buf);
- return -1;
+ if(retry == 0) {
+ ++retry;
+ /* try to recover */
+ close(pData->sock);
+ TCPSendSetStatus(pData, TCP_SEND_NOTCONNECTED);
+ pData->sock = -1;
+ } else {
+ if(buf != NULL)
+ free(buf);
+ return -1;
+ }
+# ifdef USE_GSSAPI
}
+# endif
} while(!done); /* warning: do ... while() */
/*NOT REACHED*/
@@ -703,6 +915,7 @@ CODESTARTdoAction
if(TCPSend(pData, psz, l) != 0) {
/* error! */
dbgprintf("error forwarding via tcp, suspending\n");
+ pData->eDestState = eDestFORW_SUSP;
iRet = RS_RET_SUSPENDED;
}
}
@@ -915,16 +1128,63 @@ CODESTARTgetWriteFDForSelect
ENDgetWriteFDForSelect
+BEGINmodExit
+CODESTARTmodExit
+ENDmodExit
+
+
BEGINqueryEtryPt
CODESTARTqueryEtryPt
CODEqueryEtryPt_STD_OMOD_QUERIES
ENDqueryEtryPt
+#ifdef USE_GSSAPI
+static rsRetVal setGSSMode(void *pVal, uchar *mode)
+{
+ if (!strcmp((char *) mode, "none")) {
+ gss_mode = GSSMODE_NONE;
+ free(mode);
+ dbgprintf("GSS-API gssmode set to GSSMODE_NONE\n");
+ } else if (!strcmp((char *) mode, "integrity")) {
+ gss_mode = GSSMODE_MIC;
+ free(mode);
+ dbgprintf("GSS-API gssmode set to GSSMODE_MIC\n");
+ } else if (!strcmp((char *) mode, "encryption")) {
+ gss_mode = GSSMODE_ENC;
+ free(mode);
+ dbgprintf("GSS-API gssmode set to GSSMODE_ENC\n");
+ } else {
+ logerrorSz("unknown gssmode parameter: %s", (char *) mode);
+ free(mode);
+ return RS_RET_ERR;
+ }
+
+ return RS_RET_OK;
+}
+
+
+static rsRetVal resetConfigVariables(uchar __attribute__((unused)) *pp, void __attribute__((unused)) *pVal)
+{
+ gss_mode = GSSMODE_NONE;
+ if (gss_base_service_name != NULL) {
+ free(gss_base_service_name);
+ gss_base_service_name = NULL;
+ }
+ return RS_RET_OK;
+}
+#endif /* #ifdef USE_GSSAPI */
+
+
BEGINmodInit(Fwd)
CODESTARTmodInit
*ipIFVersProvided = 1; /* so far, we only support the initial definition */
CODEmodInit_QueryRegCFSLineHdlr
+# ifdef USE_GSSAPI
+ CHKiRet(omsdRegCFSLineHdlr((uchar *)"gssforwardservicename", 0, eCmdHdlrGetWord, NULL, &gss_base_service_name, STD_LOADABLE_MODULE_ID));
+ CHKiRet(omsdRegCFSLineHdlr((uchar *)"gssmode", 0, eCmdHdlrGetWord, setGSSMode, &gss_mode, STD_LOADABLE_MODULE_ID));
+ CHKiRet(omsdRegCFSLineHdlr((uchar *)"resetconfigvariables", 1, eCmdHdlrCustomHandler, resetConfigVariables, NULL, STD_LOADABLE_MODULE_ID));
+# endif
ENDmodInit
#endif /* #ifdef SYSLOG_INET */
diff --git a/omshell.c b/omshell.c
index 54120ca..41e2899 100644
--- a/omshell.c
+++ b/omshell.c
@@ -134,6 +134,11 @@ CODESTARTgetWriteFDForSelect
ENDgetWriteFDForSelect
+BEGINmodExit
+CODESTARTmodExit
+ENDmodExit
+
+
BEGINqueryEtryPt
CODESTARTqueryEtryPt
CODEqueryEtryPt_STD_OMOD_QUERIES
diff --git a/omusrmsg.c b/omusrmsg.c
index aa8fc8c..2a2f61a 100644
--- a/omusrmsg.c
+++ b/omusrmsg.c
@@ -48,6 +48,9 @@
#else
#include <sys/msgbuf.h>
#endif
+#if HAVE_PATHS_H
+#include <paths.h>
+#endif
#include "srUtils.h"
#include "stringbuf.h"
#include "syslogd-types.h"
@@ -329,6 +332,11 @@ CODESTARTgetWriteFDForSelect
ENDgetWriteFDForSelect
+BEGINmodExit
+CODESTARTmodExit
+ENDmodExit
+
+
BEGINqueryEtryPt
CODESTARTqueryEtryPt
CODEqueryEtryPt_STD_OMOD_QUERIES
diff --git a/parse.c b/parse.c
index 9ee16c9..a4fa0de 100644
--- a/parse.c
+++ b/parse.c
@@ -414,7 +414,11 @@ rsRetVal parsAddrWithBits(rsParsObj *pThis, struct NetAddr **pIP, int *pBits)
memset (&hints, 0, sizeof (struct addrinfo));
hints.ai_family = AF_INET6;
- hints.ai_flags = AI_ADDRCONFIG | AI_NUMERICHOST;
+# ifdef AI_ADDRCONFIG
+ hints.ai_flags = AI_ADDRCONFIG | AI_NUMERICHOST;
+# else
+ hints.ai_flags = AI_NUMERICHOST;
+# endif
switch(getaddrinfo ((char*)pszIP+1, NULL, &hints, &res)) {
case 0:
@@ -449,7 +453,11 @@ rsRetVal parsAddrWithBits(rsParsObj *pThis, struct NetAddr **pIP, int *pBits)
} else { /* now parse IPv4 */
memset (&hints, 0, sizeof (struct addrinfo));
hints.ai_family = AF_INET;
- hints.ai_flags = AI_ADDRCONFIG | AI_NUMERICHOST;
+# ifdef AI_ADDRCONFIG
+ hints.ai_flags = AI_ADDRCONFIG | AI_NUMERICHOST;
+# else
+ hints.ai_flags = AI_NUMERICHOST;
+# endif
switch(getaddrinfo ((char*)pszIP, NULL, &hints, &res)) {
case 0:
diff --git a/pidfile.c b/pidfile.c
index d2cd230..e153a4e 100644
--- a/pidfile.c
+++ b/pidfile.c
@@ -119,8 +119,9 @@ int write_pid (char *pidfile)
pid = getpid();
if (!fprintf(f,"%d\n", pid)) {
- char errStr[1024];
- printf("Can't write pid , %s.\n", strerror_r(errno, errStr, sizeof(errStr)));
+ char errStr[1024];
+ strerror_r(errno, errStr, sizeof(errStr));
+ printf("Can't write pid , %s.\n", errStr);
close(fd);
return 0;
}
@@ -128,8 +129,9 @@ int write_pid (char *pidfile)
#ifndef __sun
if (flock(fd, LOCK_UN) == -1) {
- char errStr[1024];
- printf("Can't unlock pidfile %s, %s.\n", pidfile, strerror_r(errno, errStr, sizeof(errStr)));
+ char errStr[1024];
+ strerror_r(errno, errStr, sizeof(errStr));
+ printf("Can't unlock pidfile %s, %s.\n", pidfile, errStr);
close(fd);
return 0;
}
diff --git a/plugins/ommysql/Makefile.am b/plugins/ommysql/Makefile.am
index e6faa44..6397de5 100644
--- a/plugins/ommysql/Makefile.am
+++ b/plugins/ommysql/Makefile.am
@@ -1,7 +1,6 @@
-pkglibdir = $(libdir)/rsyslog
pkglib_LTLIBRARIES = ommysql.la
-ommysql_la_SOURCES = ommysql.c ommysql.h
+ommysql_la_SOURCES = ommysql.c ommysql.h ../../module-template.h
ommysql_la_CPPFLAGS = $(mysql_cflags) -I$(srcdir)/../.. $(pthreads_cflags)
ommysql_la_LDFLAGS = -module -avoid-version
ommysql_la_LIBADD = $(mysql_libs)
diff --git a/plugins/ommysql/Makefile.in b/plugins/ommysql/Makefile.in
index c88933d..0331b0a 100644
--- a/plugins/ommysql/Makefile.in
+++ b/plugins/ommysql/Makefile.in
@@ -16,6 +16,7 @@
VPATH = @srcdir@
pkgdatadir = $(datadir)/@PACKAGE@
+pkglibdir = $(libdir)/@PACKAGE@
pkgincludedir = $(includedir)/@PACKAGE@
am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd
install_sh_DATA = $(install_sh) -c -m 644
@@ -73,7 +74,6 @@ DIST_SOURCES = $(ommysql_la_SOURCES)
ETAGS = etags
CTAGS = ctags
DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST)
-pkglibdir = $(libdir)/rsyslog
ACLOCAL = @ACLOCAL@
AMTAR = @AMTAR@
AR = @AR@
@@ -103,6 +103,7 @@ F77 = @F77@
FFLAGS = @FFLAGS@
GREP = @GREP@
HAVE_MYSQL_CONFIG = @HAVE_MYSQL_CONFIG@
+HAVE_PGSQL_CONFIG = @HAVE_PGSQL_CONFIG@
INSTALL = @INSTALL@
INSTALL_DATA = @INSTALL_DATA@
INSTALL_PROGRAM = @INSTALL_PROGRAM@
@@ -151,9 +152,11 @@ build_vendor = @build_vendor@
builddir = @builddir@
datadir = @datadir@
datarootdir = @datarootdir@
+dl_libs = @dl_libs@
docdir = @docdir@
dvidir = @dvidir@
exec_prefix = @exec_prefix@
+gss_libs = @gss_libs@
host = @host@
host_alias = @host_alias@
host_cpu = @host_cpu@
@@ -173,11 +176,14 @@ mysql_cflags = @mysql_cflags@
mysql_libs = @mysql_libs@
oldincludedir = @oldincludedir@
pdfdir = @pdfdir@
+pgsql_cflags = @pgsql_cflags@
+pgsql_libs = @pgsql_libs@
prefix = @prefix@
program_transform_name = @program_transform_name@
psdir = @psdir@
pthreads_cflags = @pthreads_cflags@
pthreads_libs = @pthreads_libs@
+rt_libs = @rt_libs@
sbindir = @sbindir@
sharedstatedir = @sharedstatedir@
srcdir = @srcdir@
@@ -187,7 +193,7 @@ top_builddir = @top_builddir@
top_srcdir = @top_srcdir@
zlib_libs = @zlib_libs@
pkglib_LTLIBRARIES = ommysql.la
-ommysql_la_SOURCES = ommysql.c ommysql.h
+ommysql_la_SOURCES = ommysql.c ommysql.h ../../module-template.h
ommysql_la_CPPFLAGS = $(mysql_cflags) -I$(srcdir)/../.. $(pthreads_cflags)
ommysql_la_LDFLAGS = -module -avoid-version
ommysql_la_LIBADD = $(mysql_libs)
diff --git a/plugins/ommysql/ommysql.c b/plugins/ommysql/ommysql.c
index 8cc4f51..02ab68a 100644
--- a/plugins/ommysql/ommysql.c
+++ b/plugins/ommysql/ommysql.c
@@ -233,7 +233,7 @@ CODE_STD_STRING_REQUESTparseSelectorAct(1)
if(*p == '>') {
p++; /* eat '>' '*/
} else if(!strncmp((char*) p, ":ommysql:", sizeof(":ommysql:") - 1)) {
- p += sizeof(":ommysql:"); /* eat indicator sequence */
+ p += sizeof(":ommysql:") - 1; /* eat indicator sequence (-1 because of '\0'!) */
} else {
ABORT_FINALIZE(RS_RET_CONFLINE_UNPROCESSED);
}
@@ -287,6 +287,11 @@ CODE_STD_FINALIZERparseSelectorAct
ENDparseSelectorAct
+BEGINmodExit
+CODESTARTmodExit
+ENDmodExit
+
+
BEGINqueryEtryPt
CODESTARTqueryEtryPt
CODEqueryEtryPt_STD_OMOD_QUERIES
diff --git a/plugins/ommysql/ommysql.h b/plugins/ommysql/ommysql.h
index a8179bf..d8d2d53 100644
--- a/plugins/ommysql/ommysql.h
+++ b/plugins/ommysql/ommysql.h
@@ -24,12 +24,6 @@
#ifndef OMMYSQL_H_INCLUDED
#define OMMYSQL_H_INCLUDED 1
-/* prototypes */
-/* prototypes will be removed as syslogd needs no longer to directly
- * call into the module!
- */
-rsRetVal modInitMySQL(int iIFVersRequested __attribute__((unused)), int *ipIFVersProvided, rsRetVal (**pQueryEtryPt)(), rsRetVal (*pHostQueryEtryPt)(uchar*, rsRetVal (**)()));
-
#endif /* #ifndef OMMYSQL_H_INCLUDED */
/*
* vi:set ai:
diff --git a/plugins/ompgsql/Makefile.am b/plugins/ompgsql/Makefile.am
new file mode 100644
index 0000000..5206b36
--- /dev/null
+++ b/plugins/ompgsql/Makefile.am
@@ -0,0 +1,8 @@
+pkglib_LTLIBRARIES = ompgsql.la
+
+ompgsql_la_SOURCES = ompgsql.c ompgsql.h ../../module-template.h
+ompgsql_la_CPPFLAGS = $(pgsql_cflags) -I$(srcdir)/../..
+ompgsql_la_LDFLAGS = -module -avoid-version
+ompgsql_la_LIBADD = $(pgsql_libs)
+
+EXTRA_DIST = createDB.sql
diff --git a/plugins/ompgsql/Makefile.in b/plugins/ompgsql/Makefile.in
new file mode 100644
index 0000000..3c41da8
--- /dev/null
+++ b/plugins/ompgsql/Makefile.in
@@ -0,0 +1,488 @@
+# Makefile.in generated by automake 1.10 from Makefile.am.
+# @configure_input@
+
+# Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002,
+# 2003, 2004, 2005, 2006 Free Software Foundation, Inc.
+# This Makefile.in is free software; the Free Software Foundation
+# gives unlimited permission to copy and/or distribute it,
+# with or without modifications, as long as this notice is preserved.
+
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY, to the extent permitted by law; without
+# even the implied warranty of MERCHANTABILITY or FITNESS FOR A
+# PARTICULAR PURPOSE.
+
+@SET_MAKE@
+
+VPATH = @srcdir@
+pkgdatadir = $(datadir)/@PACKAGE@
+pkglibdir = $(libdir)/@PACKAGE@
+pkgincludedir = $(includedir)/@PACKAGE@
+am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd
+install_sh_DATA = $(install_sh) -c -m 644
+install_sh_PROGRAM = $(install_sh) -c
+install_sh_SCRIPT = $(install_sh) -c
+INSTALL_HEADER = $(INSTALL_DATA)
+transform = $(program_transform_name)
+NORMAL_INSTALL = :
+PRE_INSTALL = :
+POST_INSTALL = :
+NORMAL_UNINSTALL = :
+PRE_UNINSTALL = :
+POST_UNINSTALL = :
+build_triplet = @build@
+host_triplet = @host@
+subdir = plugins/ompgsql
+DIST_COMMON = $(srcdir)/Makefile.am $(srcdir)/Makefile.in
+ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
+am__aclocal_m4_deps = $(top_srcdir)/configure.ac
+am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
+ $(ACLOCAL_M4)
+mkinstalldirs = $(install_sh) -d
+CONFIG_HEADER = $(top_builddir)/config.h
+CONFIG_CLEAN_FILES =
+am__vpath_adj_setup = srcdirstrip=`echo "$(srcdir)" | sed 's|.|.|g'`;
+am__vpath_adj = case $$p in \
+ $(srcdir)/*) f=`echo "$$p" | sed "s|^$$srcdirstrip/||"`;; \
+ *) f=$$p;; \
+ esac;
+am__strip_dir = `echo $$p | sed -e 's|^.*/||'`;
+am__installdirs = "$(DESTDIR)$(pkglibdir)"
+pkglibLTLIBRARIES_INSTALL = $(INSTALL)
+LTLIBRARIES = $(pkglib_LTLIBRARIES)
+am__DEPENDENCIES_1 =
+ompgsql_la_DEPENDENCIES = $(am__DEPENDENCIES_1)
+am_ompgsql_la_OBJECTS = ompgsql_la-ompgsql.lo
+ompgsql_la_OBJECTS = $(am_ompgsql_la_OBJECTS)
+ompgsql_la_LINK = $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) \
+ $(LIBTOOLFLAGS) --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) \
+ $(ompgsql_la_LDFLAGS) $(LDFLAGS) -o $@
+DEFAULT_INCLUDES = -I. -I$(top_builddir)@am__isrc@
+depcomp = $(SHELL) $(top_srcdir)/depcomp
+am__depfiles_maybe = depfiles
+COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \
+ $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS)
+LTCOMPILE = $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) \
+ --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) \
+ $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS)
+CCLD = $(CC)
+LINK = $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) \
+ --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) $(AM_LDFLAGS) \
+ $(LDFLAGS) -o $@
+SOURCES = $(ompgsql_la_SOURCES)
+DIST_SOURCES = $(ompgsql_la_SOURCES)
+ETAGS = etags
+CTAGS = ctags
+DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST)
+ACLOCAL = @ACLOCAL@
+AMTAR = @AMTAR@
+AR = @AR@
+AUTOCONF = @AUTOCONF@
+AUTOHEADER = @AUTOHEADER@
+AUTOMAKE = @AUTOMAKE@
+AWK = @AWK@
+CC = @CC@
+CCDEPMODE = @CCDEPMODE@
+CFLAGS = @CFLAGS@
+CPP = @CPP@
+CPPFLAGS = @CPPFLAGS@
+CXX = @CXX@
+CXXCPP = @CXXCPP@
+CXXDEPMODE = @CXXDEPMODE@
+CXXFLAGS = @CXXFLAGS@
+CYGPATH_W = @CYGPATH_W@
+DEFS = @DEFS@
+DEPDIR = @DEPDIR@
+ECHO = @ECHO@
+ECHO_C = @ECHO_C@
+ECHO_N = @ECHO_N@
+ECHO_T = @ECHO_T@
+EGREP = @EGREP@
+EXEEXT = @EXEEXT@
+F77 = @F77@
+FFLAGS = @FFLAGS@
+GREP = @GREP@
+HAVE_MYSQL_CONFIG = @HAVE_MYSQL_CONFIG@
+HAVE_PGSQL_CONFIG = @HAVE_PGSQL_CONFIG@
+INSTALL = @INSTALL@
+INSTALL_DATA = @INSTALL_DATA@
+INSTALL_PROGRAM = @INSTALL_PROGRAM@
+INSTALL_SCRIPT = @INSTALL_SCRIPT@
+INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@
+LDFLAGS = @LDFLAGS@
+LIBOBJS = @LIBOBJS@
+LIBS = @LIBS@
+LIBTOOL = @LIBTOOL@
+LN_S = @LN_S@
+LTLIBOBJS = @LTLIBOBJS@
+MAKEINFO = @MAKEINFO@
+MKDIR_P = @MKDIR_P@
+OBJEXT = @OBJEXT@
+PACKAGE = @PACKAGE@
+PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@
+PACKAGE_NAME = @PACKAGE_NAME@
+PACKAGE_STRING = @PACKAGE_STRING@
+PACKAGE_TARNAME = @PACKAGE_TARNAME@
+PACKAGE_VERSION = @PACKAGE_VERSION@
+PATH_SEPARATOR = @PATH_SEPARATOR@
+RANLIB = @RANLIB@
+SED = @SED@
+SET_MAKE = @SET_MAKE@
+SHELL = @SHELL@
+STRIP = @STRIP@
+VERSION = @VERSION@
+abs_builddir = @abs_builddir@
+abs_srcdir = @abs_srcdir@
+abs_top_builddir = @abs_top_builddir@
+abs_top_srcdir = @abs_top_srcdir@
+ac_ct_CC = @ac_ct_CC@
+ac_ct_CXX = @ac_ct_CXX@
+ac_ct_F77 = @ac_ct_F77@
+am__include = @am__include@
+am__leading_dot = @am__leading_dot@
+am__quote = @am__quote@
+am__tar = @am__tar@
+am__untar = @am__untar@
+bindir = @bindir@
+build = @build@
+build_alias = @build_alias@
+build_cpu = @build_cpu@
+build_os = @build_os@
+build_vendor = @build_vendor@
+builddir = @builddir@
+datadir = @datadir@
+datarootdir = @datarootdir@
+dl_libs = @dl_libs@
+docdir = @docdir@
+dvidir = @dvidir@
+exec_prefix = @exec_prefix@
+gss_libs = @gss_libs@
+host = @host@
+host_alias = @host_alias@
+host_cpu = @host_cpu@
+host_os = @host_os@
+host_vendor = @host_vendor@
+htmldir = @htmldir@
+includedir = @includedir@
+infodir = @infodir@
+install_sh = @install_sh@
+libdir = @libdir@
+libexecdir = @libexecdir@
+localedir = @localedir@
+localstatedir = @localstatedir@
+mandir = @mandir@
+mkdir_p = @mkdir_p@
+mysql_cflags = @mysql_cflags@
+mysql_libs = @mysql_libs@
+oldincludedir = @oldincludedir@
+pdfdir = @pdfdir@
+pgsql_cflags = @pgsql_cflags@
+pgsql_libs = @pgsql_libs@
+prefix = @prefix@
+program_transform_name = @program_transform_name@
+psdir = @psdir@
+pthreads_cflags = @pthreads_cflags@
+pthreads_libs = @pthreads_libs@
+rt_libs = @rt_libs@
+sbindir = @sbindir@
+sharedstatedir = @sharedstatedir@
+srcdir = @srcdir@
+sysconfdir = @sysconfdir@
+target_alias = @target_alias@
+top_builddir = @top_builddir@
+top_srcdir = @top_srcdir@
+zlib_libs = @zlib_libs@
+pkglib_LTLIBRARIES = ompgsql.la
+ompgsql_la_SOURCES = ompgsql.c ompgsql.h ../../module-template.h
+ompgsql_la_CPPFLAGS = $(pgsql_cflags) -I$(srcdir)/../..
+ompgsql_la_LDFLAGS = -module -avoid-version
+ompgsql_la_LIBADD = $(pgsql_libs)
+EXTRA_DIST = createDB.sql
+all: all-am
+
+.SUFFIXES:
+.SUFFIXES: .c .lo .o .obj
+$(srcdir)/Makefile.in: $(srcdir)/Makefile.am $(am__configure_deps)
+ @for dep in $?; do \
+ case '$(am__configure_deps)' in \
+ *$$dep*) \
+ cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh \
+ && exit 0; \
+ exit 1;; \
+ esac; \
+ done; \
+ echo ' cd $(top_srcdir) && $(AUTOMAKE) --gnu plugins/ompgsql/Makefile'; \
+ cd $(top_srcdir) && \
+ $(AUTOMAKE) --gnu plugins/ompgsql/Makefile
+.PRECIOUS: Makefile
+Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status
+ @case '$?' in \
+ *config.status*) \
+ cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \
+ *) \
+ echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe)'; \
+ cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe);; \
+ esac;
+
+$(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES)
+ cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
+
+$(top_srcdir)/configure: $(am__configure_deps)
+ cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
+$(ACLOCAL_M4): $(am__aclocal_m4_deps)
+ cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
+install-pkglibLTLIBRARIES: $(pkglib_LTLIBRARIES)
+ @$(NORMAL_INSTALL)
+ test -z "$(pkglibdir)" || $(MKDIR_P) "$(DESTDIR)$(pkglibdir)"
+ @list='$(pkglib_LTLIBRARIES)'; for p in $$list; do \
+ if test -f $$p; then \
+ f=$(am__strip_dir) \
+ echo " $(LIBTOOL) --mode=install $(pkglibLTLIBRARIES_INSTALL) $(INSTALL_STRIP_FLAG) '$$p' '$(DESTDIR)$(pkglibdir)/$$f'"; \
+ $(LIBTOOL) --mode=install $(pkglibLTLIBRARIES_INSTALL) $(INSTALL_STRIP_FLAG) "$$p" "$(DESTDIR)$(pkglibdir)/$$f"; \
+ else :; fi; \
+ done
+
+uninstall-pkglibLTLIBRARIES:
+ @$(NORMAL_UNINSTALL)
+ @list='$(pkglib_LTLIBRARIES)'; for p in $$list; do \
+ p=$(am__strip_dir) \
+ echo " $(LIBTOOL) --mode=uninstall rm -f '$(DESTDIR)$(pkglibdir)/$$p'"; \
+ $(LIBTOOL) --mode=uninstall rm -f "$(DESTDIR)$(pkglibdir)/$$p"; \
+ done
+
+clean-pkglibLTLIBRARIES:
+ -test -z "$(pkglib_LTLIBRARIES)" || rm -f $(pkglib_LTLIBRARIES)
+ @list='$(pkglib_LTLIBRARIES)'; for p in $$list; do \
+ dir="`echo $$p | sed -e 's|/[^/]*$$||'`"; \
+ test "$$dir" != "$$p" || dir=.; \
+ echo "rm -f \"$${dir}/so_locations\""; \
+ rm -f "$${dir}/so_locations"; \
+ done
+ompgsql.la: $(ompgsql_la_OBJECTS) $(ompgsql_la_DEPENDENCIES)
+ $(ompgsql_la_LINK) -rpath $(pkglibdir) $(ompgsql_la_OBJECTS) $(ompgsql_la_LIBADD) $(LIBS)
+
+mostlyclean-compile:
+ -rm -f *.$(OBJEXT)
+
+distclean-compile:
+ -rm -f *.tab.c
+
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/ompgsql_la-ompgsql.Plo@am__quote@
+
+.c.o:
+@am__fastdepCC_TRUE@ $(COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $<
+@am__fastdepCC_TRUE@ mv -f $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$<' object='$@' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(COMPILE) -c $<
+
+.c.obj:
+@am__fastdepCC_TRUE@ $(COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ `$(CYGPATH_W) '$<'`
+@am__fastdepCC_TRUE@ mv -f $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$<' object='$@' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(COMPILE) -c `$(CYGPATH_W) '$<'`
+
+.c.lo:
+@am__fastdepCC_TRUE@ $(LTCOMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $<
+@am__fastdepCC_TRUE@ mv -f $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Plo
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$<' object='$@' libtool=yes @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(LTCOMPILE) -c -o $@ $<
+
+ompgsql_la-ompgsql.lo: ompgsql.c
+@am__fastdepCC_TRUE@ $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(ompgsql_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT ompgsql_la-ompgsql.lo -MD -MP -MF $(DEPDIR)/ompgsql_la-ompgsql.Tpo -c -o ompgsql_la-ompgsql.lo `test -f 'ompgsql.c' || echo '$(srcdir)/'`ompgsql.c
+@am__fastdepCC_TRUE@ mv -f $(DEPDIR)/ompgsql_la-ompgsql.Tpo $(DEPDIR)/ompgsql_la-ompgsql.Plo
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='ompgsql.c' object='ompgsql_la-ompgsql.lo' libtool=yes @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(ompgsql_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o ompgsql_la-ompgsql.lo `test -f 'ompgsql.c' || echo '$(srcdir)/'`ompgsql.c
+
+mostlyclean-libtool:
+ -rm -f *.lo
+
+clean-libtool:
+ -rm -rf .libs _libs
+
+ID: $(HEADERS) $(SOURCES) $(LISP) $(TAGS_FILES)
+ list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \
+ unique=`for i in $$list; do \
+ if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
+ done | \
+ $(AWK) ' { files[$$0] = 1; } \
+ END { for (i in files) print i; }'`; \
+ mkid -fID $$unique
+tags: TAGS
+
+TAGS: $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \
+ $(TAGS_FILES) $(LISP)
+ tags=; \
+ here=`pwd`; \
+ list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \
+ unique=`for i in $$list; do \
+ if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
+ done | \
+ $(AWK) ' { files[$$0] = 1; } \
+ END { for (i in files) print i; }'`; \
+ if test -z "$(ETAGS_ARGS)$$tags$$unique"; then :; else \
+ test -n "$$unique" || unique=$$empty_fix; \
+ $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \
+ $$tags $$unique; \
+ fi
+ctags: CTAGS
+CTAGS: $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \
+ $(TAGS_FILES) $(LISP)
+ tags=; \
+ here=`pwd`; \
+ list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \
+ unique=`for i in $$list; do \
+ if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
+ done | \
+ $(AWK) ' { files[$$0] = 1; } \
+ END { for (i in files) print i; }'`; \
+ test -z "$(CTAGS_ARGS)$$tags$$unique" \
+ || $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \
+ $$tags $$unique
+
+GTAGS:
+ here=`$(am__cd) $(top_builddir) && pwd` \
+ && cd $(top_srcdir) \
+ && gtags -i $(GTAGS_ARGS) $$here
+
+distclean-tags:
+ -rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags
+
+distdir: $(DISTFILES)
+ @srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \
+ topsrcdirstrip=`echo "$(top_srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \
+ list='$(DISTFILES)'; \
+ dist_files=`for file in $$list; do echo $$file; done | \
+ sed -e "s|^$$srcdirstrip/||;t" \
+ -e "s|^$$topsrcdirstrip/|$(top_builddir)/|;t"`; \
+ case $$dist_files in \
+ */*) $(MKDIR_P) `echo "$$dist_files" | \
+ sed '/\//!d;s|^|$(distdir)/|;s,/[^/]*$$,,' | \
+ sort -u` ;; \
+ esac; \
+ for file in $$dist_files; do \
+ if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \
+ if test -d $$d/$$file; then \
+ dir=`echo "/$$file" | sed -e 's,/[^/]*$$,,'`; \
+ if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \
+ cp -pR $(srcdir)/$$file $(distdir)$$dir || exit 1; \
+ fi; \
+ cp -pR $$d/$$file $(distdir)$$dir || exit 1; \
+ else \
+ test -f $(distdir)/$$file \
+ || cp -p $$d/$$file $(distdir)/$$file \
+ || exit 1; \
+ fi; \
+ done
+check-am: all-am
+check: check-am
+all-am: Makefile $(LTLIBRARIES)
+installdirs:
+ for dir in "$(DESTDIR)$(pkglibdir)"; do \
+ test -z "$$dir" || $(MKDIR_P) "$$dir"; \
+ done
+install: install-am
+install-exec: install-exec-am
+install-data: install-data-am
+uninstall: uninstall-am
+
+install-am: all-am
+ @$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am
+
+installcheck: installcheck-am
+install-strip:
+ $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \
+ install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \
+ `test -z '$(STRIP)' || \
+ echo "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'"` install
+mostlyclean-generic:
+
+clean-generic:
+
+distclean-generic:
+ -test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES)
+
+maintainer-clean-generic:
+ @echo "This command is intended for maintainers to use"
+ @echo "it deletes files that may require special tools to rebuild."
+clean: clean-am
+
+clean-am: clean-generic clean-libtool clean-pkglibLTLIBRARIES \
+ mostlyclean-am
+
+distclean: distclean-am
+ -rm -rf ./$(DEPDIR)
+ -rm -f Makefile
+distclean-am: clean-am distclean-compile distclean-generic \
+ distclean-tags
+
+dvi: dvi-am
+
+dvi-am:
+
+html: html-am
+
+info: info-am
+
+info-am:
+
+install-data-am:
+
+install-dvi: install-dvi-am
+
+install-exec-am: install-pkglibLTLIBRARIES
+
+install-html: install-html-am
+
+install-info: install-info-am
+
+install-man:
+
+install-pdf: install-pdf-am
+
+install-ps: install-ps-am
+
+installcheck-am:
+
+maintainer-clean: maintainer-clean-am
+ -rm -rf ./$(DEPDIR)
+ -rm -f Makefile
+maintainer-clean-am: distclean-am maintainer-clean-generic
+
+mostlyclean: mostlyclean-am
+
+mostlyclean-am: mostlyclean-compile mostlyclean-generic \
+ mostlyclean-libtool
+
+pdf: pdf-am
+
+pdf-am:
+
+ps: ps-am
+
+ps-am:
+
+uninstall-am: uninstall-pkglibLTLIBRARIES
+
+.MAKE: install-am install-strip
+
+.PHONY: CTAGS GTAGS all all-am check check-am clean clean-generic \
+ clean-libtool clean-pkglibLTLIBRARIES ctags distclean \
+ distclean-compile distclean-generic distclean-libtool \
+ distclean-tags distdir dvi dvi-am html html-am info info-am \
+ install install-am install-data install-data-am install-dvi \
+ install-dvi-am install-exec install-exec-am install-html \
+ install-html-am install-info install-info-am install-man \
+ install-pdf install-pdf-am install-pkglibLTLIBRARIES \
+ install-ps install-ps-am install-strip installcheck \
+ installcheck-am installdirs maintainer-clean \
+ maintainer-clean-generic mostlyclean mostlyclean-compile \
+ mostlyclean-generic mostlyclean-libtool pdf pdf-am ps ps-am \
+ tags uninstall uninstall-am uninstall-pkglibLTLIBRARIES
+
+# Tell versions [3.59,3.63) of GNU make to not export all variables.
+# Otherwise a system limit (for SysV at least) may be exceeded.
+.NOEXPORT:
diff --git a/plugins/ompgsql/createDB.sql b/plugins/ompgsql/createDB.sql
new file mode 100644
index 0000000..facdcaa
--- /dev/null
+++ b/plugins/ompgsql/createDB.sql
@@ -0,0 +1,37 @@
+CREATE DATABASE "Syslog";
+\c Syslog;
+CREATE TABLE SystemEvents
+(
+ ID serial not null primary key,
+ CustomerID bigint,
+ ReceivedAt timestamp without time zone NULL,
+ DeviceReportedTime timestamp without time zone NULL,
+ Facility smallint NULL,
+ Priority smallint NULL,
+ FromHost varchar(60) NULL,
+ Message text,
+ NTSeverity int NULL,
+ Importance int NULL,
+ EventSource varchar(60),
+ EventUser varchar(60) NULL,
+ EventCategory int NULL,
+ EventID int NULL,
+ EventBinaryData text NULL,
+ MaxAvailable int NULL,
+ CurrUsage int NULL,
+ MinUsage int NULL,
+ MaxUsage int NULL,
+ InfoUnitID int NULL ,
+ SysLogTag varchar(60),
+ EventLogType varchar(60),
+ GenericFileName VarChar(60),
+ SystemID int NULL
+);
+
+CREATE TABLE SystemEventsProperties
+(
+ ID serial not null primary key,
+ SystemEventID int NULL ,
+ ParamName varchar(255) NULL ,
+ ParamValue text NULL
+);
diff --git a/plugins/ompgsql/ompgsql.c b/plugins/ompgsql/ompgsql.c
new file mode 100644
index 0000000..24a68a5
--- /dev/null
+++ b/plugins/ompgsql/ompgsql.c
@@ -0,0 +1,304 @@
+/* ompgsql.c
+ * This is the implementation of the build-in output module for PgSQL.
+ *
+ * NOTE: read comments in module-template.h to understand how this file
+ * works!
+ *
+ * File begun on 2007-10-18 by sur5r (converted from ommysql.c)
+ *
+ * Copyright 2007 Rainer Gerhards and Adiscon GmbH.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ *
+ * A copy of the GPL can be found in the file "COPYING" in this distribution.
+ */
+#include "config.h"
+#include "rsyslog.h"
+#include <stdio.h>
+#include <stdarg.h>
+#include <stdlib.h>
+#include <string.h>
+#include <assert.h>
+#include <signal.h>
+#include <errno.h>
+#include <time.h>
+#include <libpq-fe.h>
+#include "syslogd.h"
+#include "syslogd-types.h"
+#include "srUtils.h"
+#include "template.h"
+#include "ompgsql.h"
+#include "module-template.h"
+
+/* internal structures
+ */
+DEF_OMOD_STATIC_DATA
+
+typedef struct _instanceData {
+ PGconn *f_hpgsql; /* handle to PgSQL */
+ char f_dbsrv[MAXHOSTNAMELEN+1]; /* IP or hostname of DB server*/
+ char f_dbname[_DB_MAXDBLEN+1]; /* DB name */
+ char f_dbuid[_DB_MAXUNAMELEN+1]; /* DB user */
+ char f_dbpwd[_DB_MAXPWDLEN+1]; /* DB user's password */
+ ConnStatusType eLastPgSQLStatus; /* last status from postgres */
+} instanceData;
+
+
+BEGINcreateInstance
+CODESTARTcreateInstance
+ENDcreateInstance
+
+
+BEGINisCompatibleWithFeature
+CODESTARTisCompatibleWithFeature
+ if(eFeat == sFEATURERepeatedMsgReduction)
+ iRet = RS_RET_OK;
+ENDisCompatibleWithFeature
+
+
+/* The following function is responsible for closing a
+ * PgSQL connection.
+ */
+static void closePgSQL(instanceData *pData)
+{
+ assert(pData != NULL);
+
+ if(pData->f_hpgsql != NULL) { /* just to be on the safe side... */
+ PQfinish(pData->f_hpgsql);
+ pData->f_hpgsql = NULL;
+ }
+}
+
+BEGINfreeInstance
+CODESTARTfreeInstance
+ closePgSQL(pData);
+ENDfreeInstance
+
+
+BEGINneedUDPSocket
+CODESTARTneedUDPSocket
+ENDneedUDPSocket
+
+
+BEGINdbgPrintInstInfo
+CODESTARTdbgPrintInstInfo
+ /* nothing special here */
+ENDdbgPrintInstInfo
+
+
+BEGINonSelectReadyWrite
+CODESTARTonSelectReadyWrite
+ENDonSelectReadyWrite
+
+
+BEGINgetWriteFDForSelect
+CODESTARTgetWriteFDForSelect
+ENDgetWriteFDForSelect
+
+
+/* log a database error with descriptive message.
+ * We check if we have a valid handle. If not, we simply
+ * report an error, but can not be specific. RGerhards, 2007-01-30
+ */
+static void reportDBError(instanceData *pData, int bSilent)
+{
+ char errMsg[512];
+ ConnStatusType ePgSQLStatus;
+
+ assert(pData != NULL);
+ bSilent=0;
+
+ /* output log message */
+ errno = 0;
+ if(pData->f_hpgsql == NULL) {
+ logerror("unknown DB error occured - could not obtain PgSQL handle");
+ } else { /* we can ask pgsql for the error description... */
+ ePgSQLStatus = PQstatus(pData->f_hpgsql);
+ snprintf(errMsg, sizeof(errMsg)/sizeof(char), "db error (%d): %s\n", ePgSQLStatus,
+ PQerrorMessage(pData->f_hpgsql));
+ if(bSilent || ePgSQLStatus == pData->eLastPgSQLStatus)
+ dbgprintf("pgsql, DBError(silent): %s\n", errMsg);
+ else {
+ pData->eLastPgSQLStatus = ePgSQLStatus;
+ logerror(errMsg);
+ }
+ }
+
+ return;
+}
+
+
+/* The following function is responsible for initializing a
+ * PgSQL connection.
+ */
+static rsRetVal initPgSQL(instanceData *pData, int bSilent)
+{
+ DEFiRet;
+
+ assert(pData != NULL);
+ assert(pData->f_hpgsql == NULL);
+
+ dbgprintf("host=%s dbname=%s uid=%s\n",pData->f_dbsrv,pData->f_dbname,pData->f_dbuid);
+
+ /* Connect to database */
+ if((pData->f_hpgsql=PQsetdbLogin(pData->f_dbsrv, NULL, NULL, NULL,
+ pData->f_dbname, pData->f_dbuid, pData->f_dbpwd)) == NULL) {
+ reportDBError(pData, bSilent);
+ closePgSQL(pData); /* ignore any error we may get */
+ iRet = RS_RET_SUSPENDED;
+ }
+
+ return iRet;
+}
+
+
+/* The following function writes the current log entry
+ * to an established PgSQL session.
+ */
+rsRetVal writePgSQL(uchar *psz, instanceData *pData)
+{
+ DEFiRet;
+
+ assert(psz != NULL);
+ assert(pData != NULL);
+
+ dbgprintf("writePgSQL: %s", psz);
+
+ /* try insert */
+ PQexec(pData->f_hpgsql, (char*)psz);
+ if(PQstatus(pData->f_hpgsql) != CONNECTION_OK) {
+ /* error occured, try to re-init connection and retry */
+ closePgSQL(pData); /* close the current handle */
+ CHKiRet(initPgSQL(pData, 0)); /* try to re-open */
+ PQexec(pData->f_hpgsql, (char*)psz);
+ if(PQstatus(pData->f_hpgsql) != CONNECTION_OK) { /* re-try insert */
+ /* we failed, giving up for now */
+ reportDBError(pData, 0);
+ closePgSQL(pData); /* free ressources */
+ ABORT_FINALIZE(RS_RET_SUSPENDED);
+ }
+ }
+
+finalize_it:
+ if(iRet == RS_RET_OK) {
+ pData->eLastPgSQLStatus = CONNECTION_OK; /* reset error for error supression */
+ }
+
+ return iRet;
+}
+
+
+BEGINtryResume
+CODESTARTtryResume
+ if(pData->f_hpgsql == NULL) {
+ iRet = initPgSQL(pData, 1);
+ }
+ENDtryResume
+
+BEGINdoAction
+CODESTARTdoAction
+ dbgprintf("\n");
+ iRet = writePgSQL(ppString[0], pData);
+ENDdoAction
+
+
+BEGINparseSelectorAct
+ int iPgSQLPropErr = 0;
+CODESTARTparseSelectorAct
+CODE_STD_STRING_REQUESTparseSelectorAct(1)
+ /* first check if this config line is actually for us
+ * The first test [*p == '>'] can be skipped if a module shall only
+ * support the newer slection syntax [:modname:]. This is in fact
+ * recommended for new modules. Please note that over time this part
+ * will be handled by rsyslogd itself, but for the time being it is
+ * a good compromise to do it at the module level.
+ * rgerhards, 2007-10-15
+ */
+
+ if(!strncmp((char*) p, ":ompgsql:", sizeof(":ompgsql:") - 1)) {
+ p += sizeof(":ompgsql:") - 1; /* eat indicator sequence (-1 because of '\0'!) */
+ } else {
+ ABORT_FINALIZE(RS_RET_CONFLINE_UNPROCESSED);
+ }
+
+ /* ok, if we reach this point, we have something for us */
+ if((iRet = createInstance(&pData)) != RS_RET_OK)
+ goto finalize_it;
+
+
+ /* sur5r 2007-10-18: added support for PgSQL
+ * :ompgsql:server,dbname,userid,password
+ * Now we read the PgSQL connection properties
+ * and verify that the properties are valid.
+ */
+ if(getSubString(&p, pData->f_dbsrv, MAXHOSTNAMELEN+1, ','))
+ iPgSQLPropErr++;
+ dbgprintf("%p:%s\n",p,p);
+ if(*pData->f_dbsrv == '\0')
+ iPgSQLPropErr++;
+ if(getSubString(&p, pData->f_dbname, _DB_MAXDBLEN+1, ','))
+ iPgSQLPropErr++;
+ if(*pData->f_dbname == '\0')
+ iPgSQLPropErr++;
+ if(getSubString(&p, pData->f_dbuid, _DB_MAXUNAMELEN+1, ','))
+ iPgSQLPropErr++;
+ if(*pData->f_dbuid == '\0')
+ iPgSQLPropErr++;
+ if(getSubString(&p, pData->f_dbpwd, _DB_MAXPWDLEN+1, ';'))
+ iPgSQLPropErr++;
+ /* now check for template
+ * We specify that the SQL option must be present in the template.
+ * This is for your own protection (prevent sql injection).
+ */
+ if(*(p-1) == ';')
+ --p; /* TODO: the whole parsing of the MySQL module needs to be re-thought - but this here
+ * is clean enough for the time being -- rgerhards, 2007-07-30
+ * kept it for pgsql -- sur5r, 2007-10-19
+ */
+ CHKiRet(cflineParseTemplateName(&p, *ppOMSR, 0, OMSR_RQD_TPL_OPT_SQL, (uchar*) " StdPgSQLFmt"));
+
+ /* If we detect invalid properties, we disable logging,
+ * because right properties are vital at this place.
+ * Retries make no sense.
+ */
+ if (iPgSQLPropErr) {
+ logerror("Trouble with PgSQL connection properties. -PgSQL logging disabled");
+ ABORT_FINALIZE(RS_RET_INVALID_PARAMS);
+ } else {
+ CHKiRet(initPgSQL(pData, 0));
+ }
+
+CODE_STD_FINALIZERparseSelectorAct
+ENDparseSelectorAct
+
+BEGINmodExit
+CODESTARTmodExit
+ENDmodExit
+
+
+BEGINqueryEtryPt
+CODESTARTqueryEtryPt
+CODEqueryEtryPt_STD_OMOD_QUERIES
+ENDqueryEtryPt
+
+
+BEGINmodInit()
+CODESTARTmodInit
+ *ipIFVersProvided = 1; /* so far, we only support the initial definition */
+CODEmodInit_QueryRegCFSLineHdlr
+ENDmodInit
+/*
+ * vi:set ai:
+ */
diff --git a/plugins/ompgsql/ompgsql.h b/plugins/ompgsql/ompgsql.h
new file mode 100644
index 0000000..8285ac3
--- /dev/null
+++ b/plugins/ompgsql/ompgsql.h
@@ -0,0 +1,30 @@
+/* ompgsql.h
+ * These are the definitions for the build-in PgSQL output module.
+ *
+ * File begun on 2007-10-18 by sur5r (converted from ompgsql.h)
+ *
+ * Copyright 2007 Rainer Gerhards and Adiscon GmbH.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ *
+ * A copy of the GPL can be found in the file "COPYING" in this distribution.
+ */
+#ifndef OMPGSQL_H_INCLUDED
+#define OMPGSQL_H_INCLUDED 1
+
+#endif /* #ifndef OMPGSQL_H_INCLUDED */
+/*
+ * vi:set ai:
+ */
diff --git a/rsyslog.conf.5 b/rsyslog.conf.5
index e1d3659..7f6ca98 100644
--- a/rsyslog.conf.5
+++ b/rsyslog.conf.5
@@ -94,6 +94,8 @@ prepend two at signs ("@@"), the messages will be transmitted via TCP.
Please note that this version of rsyslogd by default does NOT forward messages it has received
from the network to another host. Specify the "-h" option to enable this.
+Using the $GssMode directive TCP messages can be wrapped with GSS-API.
+
.B Example:
.RS
*.* @192.168.0.1
diff --git a/rsyslog.h b/rsyslog.h
index 00f8fad..b6e17d5 100644
--- a/rsyslog.h
+++ b/rsyslog.h
@@ -73,6 +73,7 @@ enum rsRetVal_ /** return value. All methods return this if not specified oth
RS_RET_INVALID_SOURCE = -2019, /**< source (address) invalid for some reason */
RS_RET_ADDRESS_UNKNOWN = -2020, /**< an address is unknown - not necessarily an error */
RS_RET_MALICIOUS_ENTITY = -2021, /**< there is an malicious entity involved */
+ RS_RET_OK_DELETE_LISTENTRY = 1, /**< operation successful, but callee requested the deletion of an entry (special state) */
RS_RET_OK = 0 /**< operation successful */
};
typedef enum rsRetVal_ rsRetVal; /**< friendly type for global return value */
diff --git a/rsyslogd.8 b/rsyslogd.8
index 9dbf62e..0c4fcf3 100644
--- a/rsyslogd.8
+++ b/rsyslogd.8
@@ -1,7 +1,7 @@
.\" Copyright 2004-2005 Rainer Gerhards and Adiscon for the rsyslog modifications
.\" May be distributed under the GNU General Public License
.\"
-.TH RSYSLOGD 8 "17 July 2007" "Version 1.16.1 (devel)" "Linux System Administration"
+.TH RSYSLOGD 8 "11 December 2008" "Version 1.20.1 (devel)" "Linux System Administration"
.SH NAME
rsyslogd \- reliable and extended syslogd
.SH SYNOPSIS
@@ -18,33 +18,38 @@ rsyslogd \- reliable and extended syslogd
.RB [ " \-f "
.I config file
]
+.RB [ " \-g "
+.I port,max-nbr-of-sessions
+]
.RB [ " \-h " ]
+.br
.RB [ " \-i "
.I pid file
]
.RB [ " \-l "
.I hostlist
]
-.br
.RB [ " \-m "
.I interval
]
.RB [ " \-n " ]
.RB [ " \-o " ]
+.br
.RB [ " \-p"
.IB socket
]
-.br
+.RB [ " \-q " ]
+.RB [ " \-Q " ]
.RB [ " \-r "
.I [port]
]
.RB [ " \-s "
.I domainlist
]
+.br
.RB [ " \-t "
.I port,max-nbr-of-sessions
]
-.br
.RB [ " \-v " ]
.RB [ " \-w " ]
.RB [ " \-x " ]
@@ -153,6 +158,12 @@ Specify an alternative configuration file instead of
.IR /etc/rsyslog.conf ","
which is the default.
.TP
+.BI "\-g "
+Identical to -t except that every tcp connection is authenticated
+using gss-api (kerberos 5). Service name may be set using
+$GssListenServiceName or the default "host" will be used. Encryption
+can be used if specified by the client and supported by both sides.
+.TP
.BI "\-h "
By default rsyslogd will not forward messages it receives from remote hosts.
Specifying this switch on the command line will cause the log daemon to
@@ -194,6 +205,15 @@ machine. When specified, no local log socket is opened at all.
You can specify an alternative unix domain socket instead of
.IR /dev/log "."
.TP
+.BI "\-q " "add hostname if DNS fails during ACL processing"
+During ACL processing, hostnames are resolved to IP addreses for
+performance reasons. If DNS fails during that process, the hostname
+is added as wildcard text, which results in proper, but somewhat
+slower operation once DNS is up again.
+.TP
+.BI "\-Q " "do not resolve hostnames during ACL processing"
+Do not resolve hostnames to IP addresses during ACL processing.
+.TP
.BI "\-r " ["port"]
Activates the syslog/udp listener service. The listener
will listen to the specified port. If no port is specified,
@@ -283,15 +303,18 @@ running rsyslogd to another node running rsyslogd (or a
compatible syslog implementation) where they will be
actually logged to a disk file.
-To enable this you have to specify either the
+To enable this you have to specify one of
+.B "\-g"
+,
.B "\-r"
or
.B "\-t"
-option on the command line. The default behavior is that
+options on the command line. The default behavior is that
.B rsyslogd
-won't listen to the network. You can also combine these two
+won't listen to the network. You can also combine these
options if you want rsyslogd to listen to both TCP and UDP
-messages.
+messages. Only one of the TCP listener options can be used.
+The last one specified will take effect.
The strategy is to have rsyslogd listen on a unix domain socket for
locally generated log messages. This behavior will allow rsyslogd to
@@ -478,8 +501,9 @@ If remote logging is enabled, messages can easily be spoofed and replayed.
As the messages are transmitted in clear-text, an attacker might use
the information obtained from the packets for malicious things. Also, an
attacker might reply recorded messages or spoof a sender's IP address,
-which could lead to a wrong preception of system activity. Be sure to think
-about syslog network security before enabling it.
+which could lead to a wrong perception of system activity. These can
+be prevented by using GSS-API authentication and encryption. Be sure
+to think about syslog network security before enabling it.
.LP
.SH DEBUGGING
When debugging is turned on using
diff --git a/srUtils.c b/srUtils.c
index 843e6f7..acd8edd 100755
--- a/srUtils.c
+++ b/srUtils.c
@@ -36,7 +36,7 @@
#include <sys/types.h>
#include <signal.h>
#include <assert.h>
-#include <wait.h>
+#include <sys/wait.h>
#include <ctype.h>
#include "liblogging-stub.h" /* THIS IS A MODIFICATION FOR RSYSLOG! 2004-11-18 rgerards */
#define TRUE 1
diff --git a/sync.c b/sync.c
new file mode 100644
index 0000000..f953915
--- /dev/null
+++ b/sync.c
@@ -0,0 +1,78 @@
+/* synrchonization-related stuff. In theory, that should
+ * help porting to something different from pthreads.
+ *
+ * Copyright 2007 Rainer Gerhards and Adiscon GmbH.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ *
+ * A copy of the GPL can be found in the file "COPYING" in this distribution.
+ */
+
+#include "config.h"
+
+#ifdef USE_PTHREADS
+/* all of this code is compiled only if PTHREADS is supported - otherwise
+ * we do not need syncrhonization objects (and do not have them!).
+ */
+#include <stdlib.h>
+
+#include "rsyslog.h"
+#include "sync.h"
+
+
+void
+SyncObjInit(pthread_mutex_t **mut)
+{
+ *mut = (pthread_mutex_t *) malloc (sizeof (pthread_mutex_t));
+ pthread_mutex_init(*mut, NULL);
+}
+
+
+/* This function destroys the mutex and also sets the mutex object
+ * to NULL. While the later is not strictly necessary, it is a good
+ * aid when debugging problems. As this function is not exepected to
+ * be called quite frequently, the additional overhead can well be
+ * accepted. If this changes over time, setting to NULL may be
+ * reconsidered. - rgerhards, 2007-11-12
+ */
+void
+SyncObjExit(pthread_mutex_t **mut)
+{
+ if(*mut != NULL) {
+ pthread_mutex_destroy(*mut);
+ free(*mut);
+ *mut = NULL;
+ }
+}
+
+#ifndef NDEBUG
+/* lock an object. The synchronization tool (mutex) must be passed in.
+ */
+void
+lockObj(pthread_mutex_t *mut)
+{
+ pthread_mutex_lock(mut);
+}
+
+/* unlock an object. The synchronization tool (mutex) must be passed in.
+ */
+void
+unlockObj(pthread_mutex_t *mut)
+{
+ pthread_mutex_unlock(mut);
+}
+#endif /* #ifndef NDEBUG */
+
+#endif /* #ifdef USE_PTHREADS */
diff --git a/sync.h b/sync.h
new file mode 100644
index 0000000..3637d45
--- /dev/null
+++ b/sync.h
@@ -0,0 +1,62 @@
+/* Definitions syncrhonization-related stuff. In theory, that should
+ * help porting to something different from pthreads.
+ *
+ * Copyright 2007 Rainer Gerhards and Adiscon GmbH.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ *
+ * A copy of the GPL can be found in the file "COPYING" in this distribution.
+ */
+
+#ifndef INCLUDED_SYNC_H
+#define INCLUDED_SYNC_H
+
+#ifdef USE_PTHREADS /* Code to compile for threading support */
+#include <pthread.h>
+
+/* SYNC_OBJ_TOOL definition must be placed in object to be synced!
+ * SYNC_OBJ_TOOL_INIT must be called upon of object construction and
+ * SUNC_OBJ_TOOL_EXIT must be called upon object destruction
+ */
+#define SYNC_OBJ_TOOL pthread_mutex_t *Sync_mut;
+#define SYNC_OBJ_TOOL_INIT(x) SyncObjInit(&((x)->Sync_mut))
+#define SYNC_OBJ_TOOL_EXIT(x) SyncObjExit(&((x)->Sync_mut))
+
+/* If we run in non-debug mode, we use inline code for the mutex
+ * operations. If we run in debug mode, we use functions, because they
+ * are better to trace in the callframe.
+ */
+#ifdef NDEBUG
+#define LockObj(x) pthread_mutex_lock((x)->Sync_mut)
+#define UnlockObj(x) pthread_mutex_unlock((x)->Sync_mut)
+#else
+#define LockObj(x) lockObj((x)->Sync_mut)
+#define UnlockObj(x) unlockObj((x)->Sync_mut)
+#endif
+
+void SyncObjInit(pthread_mutex_t **mut);
+void SyncObjExit(pthread_mutex_t **mut);
+extern void lockObj(pthread_mutex_t *mut);
+extern void unlockObj(pthread_mutex_t *mut);
+
+#else /* Code not to compile for threading support */
+#define SYNC_OBJ_TOOL
+#define SYNC_OBJ_TOOL_INIT
+#define SYNC_OBJ_TOOL_EXIT
+#define LockObj(x)
+#define UnlockObj(x)
+#endif
+
+#endif /* #ifndef INCLUDED_SYNC_H */
diff --git a/syslogd.c b/syslogd.c
index a7ca44d..e9e822e 100644
--- a/syslogd.c
+++ b/syslogd.c
@@ -146,6 +146,7 @@
#include <stdio.h>
#include <stddef.h>
#include <ctype.h>
+#include <limits.h>
#define GNU_SOURCE
#include <string.h>
#include <stdarg.h>
@@ -165,9 +166,11 @@
#include <sys/file.h>
#include <sys/un.h>
#include <sys/time.h>
-#ifdef BSD
+
+#if HAVE_SYS_TIMESPEC_H
# include <sys/timespec.h>
#endif
+
#include <sys/resource.h>
#include <signal.h>
@@ -207,6 +210,7 @@
#include "outchannel.h"
#include "syslogd.h"
#include "net.h" /* struct NetAddr */
+#include "sync.h" /* struct NetAddr */
#include "parse.h"
#include "msg.h"
@@ -238,50 +242,6 @@
#define LOG_FTP (11<<3) /* ftp daemon */
#define INTERNAL_MARK LOG_MAKEPRI((LOG_NFACILITIES<<3), 0)
-syslogCODE rs_prioritynames[] =
- {
- { "alert", LOG_ALERT },
- { "crit", LOG_CRIT },
- { "debug", LOG_DEBUG },
- { "emerg", LOG_EMERG },
- { "err", LOG_ERR },
- { "error", LOG_ERR }, /* DEPRECATED */
- { "info", LOG_INFO },
- { "none", INTERNAL_NOPRI }, /* INTERNAL */
- { "notice", LOG_NOTICE },
- { "panic", LOG_EMERG }, /* DEPRECATED */
- { "warn", LOG_WARNING }, /* DEPRECATED */
- { "warning", LOG_WARNING },
- { NULL, -1 }
- };
-
-syslogCODE rs_facilitynames[] =
- {
- { "auth", LOG_AUTH },
- { "authpriv", LOG_AUTHPRIV },
- { "cron", LOG_CRON },
- { "daemon", LOG_DAEMON },
- { "ftp", LOG_FTP },
- { "kern", LOG_KERN },
- { "lpr", LOG_LPR },
- { "mail", LOG_MAIL },
- { "mark", INTERNAL_MARK }, /* INTERNAL */
- { "news", LOG_NEWS },
- { "security", LOG_AUTH }, /* DEPRECATED */
- { "syslog", LOG_SYSLOG },
- { "user", LOG_USER },
- { "uucp", LOG_UUCP },
- { "local0", LOG_LOCAL0 },
- { "local1", LOG_LOCAL1 },
- { "local2", LOG_LOCAL2 },
- { "local3", LOG_LOCAL3 },
- { "local4", LOG_LOCAL4 },
- { "local5", LOG_LOCAL5 },
- { "local6", LOG_LOCAL6 },
- { "local7", LOG_LOCAL7 },
- { NULL, -1 }
- };
-
#ifndef UTMP_FILE
#ifdef UTMP_FILENAME
@@ -363,7 +323,7 @@ syslogCODE rs_facilitynames[] =
static uchar *ConfFile = (uchar*) _PATH_LOGCONF; /* read-only after startup */
static char *PidFile = _PATH_LOGPID; /* read-only after startup */
static uchar *pModDir = NULL; /* read-only after startup */
-char ctty[] = _PATH_CONSOLE; /* this is read-only */
+char ctty[] = _PATH_CONSOLE; /* this is read-only; used by omfile -- TODO: remove that dependency */
static pid_t myPid; /* our pid for use in self-generated messages, e.g. on startup */
/* mypid is read-only after the initial fork() */
@@ -542,6 +502,8 @@ int send_to_all = 0; /* send message to all IPv4/IPv6 addresses */
static int MarkSeq = 0; /* mark sequence number - modified in domark() only */
static int NoFork = 0; /* don't fork - don't run in daemon mode - read-only after startup */
static int AcceptRemote = 0;/* receive messages that come via UDP - read-only after startup */
+int ACLAddHostnameOnFail = 0; /* add hostname to acl when DNS resolving has failed */
+int ACLDontResolve = 0; /* add hostname to acl instead of resolving it to IP(s) */
int DisableDNS = 0; /* don't look up IP addresses of remote messages */
char **StripDomains = NULL;/* these domains may be stripped before writing logs - r/o after s.u., never touched by init */
char **LocalHosts = NULL;/* these hosts are logged with their hostname - read-only after startup, never touched by init */
@@ -655,6 +617,12 @@ static rsRetVal resetConfigVariables(uchar __attribute__((unused)) *pp, void __a
#ifdef USE_PTHREADS
iMainMsgQueueSize = 10000;
#endif
+#if defined(SYSLOG_INET) && defined(USE_GSSAPI)
+ if (gss_listen_service_name != NULL) {
+ free(gss_listen_service_name);
+ gss_listen_service_name = NULL;
+ }
+#endif
return RS_RET_OK;
}
@@ -682,6 +650,7 @@ static uchar template_WallFmt[] = "\"\r\n\7Message from syslogd@%HOSTNAME% at %t
static uchar template_StdFwdFmt[] = "\"<%PRI%>%TIMESTAMP% %HOSTNAME% %syslogtag%%msg%\"";
static uchar template_StdUsrMsgFmt[] = "\" %syslogtag%%msg%\n\r\"";
static uchar template_StdDBFmt[] = "\"insert into SystemEvents (Message, Facility, FromHost, Priority, DeviceReportedTime, ReceivedAt, InfoUnitID, SysLogTag) values ('%msg%', %syslogfacility%, '%HOSTNAME%', %syslogpriority%, '%timereported:::date-mysql%', '%timegenerated:::date-mysql%', %iut%, '%syslogtag%')\",SQL";
+static uchar template_StdPgSQLFmt[] = "\"insert into SystemEvents (Message, Facility, FromHost, Priority, DeviceReportedTime, ReceivedAt, InfoUnitID, SysLogTag) values ('%msg%', %syslogfacility%, '%HOSTNAME%', %syslogpriority%, '%timereported:::date-pgsql%', '%timegenerated:::date-pgsql%', %iut%, '%syslogtag%')\",STDSQL";
/* end template */
@@ -857,7 +826,8 @@ static rsRetVal AddAllowedSender(struct AllowedSenders **ppRoot, struct AllowedS
}
if (!strchr (iAllow->addr.HostWildcard, '*') &&
- !strchr (iAllow->addr.HostWildcard, '?')) {
+ !strchr (iAllow->addr.HostWildcard, '?') &&
+ ACLDontResolve == 0) {
/* single host - in this case, we pull its IP addresses from DNS
* and add IP-based ACLs.
*/
@@ -866,15 +836,21 @@ static rsRetVal AddAllowedSender(struct AllowedSenders **ppRoot, struct AllowedS
memset (&hints, 0, sizeof (struct addrinfo));
hints.ai_family = AF_UNSPEC;
- hints.ai_flags = AI_ADDRCONFIG;
hints.ai_socktype = SOCK_DGRAM;
+# ifdef AI_ADDRCONFIG /* seems not to be present on all systems */
+ hints.ai_flags = AI_ADDRCONFIG;
+# endif
if (getaddrinfo (iAllow->addr.HostWildcard, NULL, &hints, &res) != 0) {
- logerrorSz("DNS error: Can't resolve \"%s\", not added as allowed sender", iAllow->addr.HostWildcard);
- /* We could use the text name in this case - maybe this could become
- * a user-defined option at some stage.
- */
- return RS_RET_ERR;
+ logerrorSz("DNS error: Can't resolve \"%s\"", iAllow->addr.HostWildcard);
+
+ if (ACLAddHostnameOnFail) {
+ logerrorSz("Adding hostname \"%s\" to ACL as a wildcard entry.", iAllow->addr.HostWildcard);
+ return AddAllowedSenderEntry(ppRoot, ppLast, iAllow, iSignificantBits);
+ } else {
+ logerrorSz("Hostname \"%s\" WON\'T be added to ACL.", iAllow->addr.HostWildcard);
+ return RS_RET_NOENTRY;
+ }
}
for (restmp = res ; res != NULL ; res = res->ai_next) {
@@ -1478,6 +1454,19 @@ int formatTimestampToMySQL(struct syslogTime *ts, char* pDst, size_t iLenDst)
}
+int formatTimestampToPgSQL(struct syslogTime *ts, char *pDst, size_t iLenDst)
+{
+ /* see note in formatTimestampToMySQL, applies here as well */
+ assert(ts != NULL);
+ assert(pDst != NULL);
+
+ if (iLenDst < 21) /* we need 20 bytes + '\n' */
+ return(0);
+
+ return(snprintf(pDst, iLenDst, "%4.4d-%2.2d-%2.2d %2.2d:%2.2d:%2.2d",
+ ts->year, ts->month, ts->day, ts->hour, ts->minute, ts->second));
+}
+
/**
* Format a syslogTimestamp to a RFC3339 timestamp string (as
* specified in syslog-protocol).
@@ -1635,7 +1624,7 @@ void getCurrTime(struct syslogTime *t)
static int usage(void)
{
- fprintf(stderr, "usage: rsyslogd [-46Adhvw] [-l hostlist] [-m markinterval] [-n] [-p path]\n" \
+ fprintf(stderr, "usage: rsyslogd [-46AdhqQvw] [-l hostlist] [-m markinterval] [-n] [-p path]\n" \
" [-s domainlist] [-r[port]] [-tport[,max-sessions]] [-f conffile] [-i pidfile] [-x]\n");
exit(1); /* "good" exit - done to terminate usage() */
}
@@ -2233,8 +2222,6 @@ void printline(char *hname, char *msg, int bParseHost)
return;
}
-time_t now;
-
/* rgerhards 2004-11-09: the following is a function that can be used
* to log a message orginating from the syslogd itself. In sysklogd code,
* this is done by simply calling logmsg(). However, logmsg() is changed in
@@ -2244,7 +2231,8 @@ time_t now;
* function here probably is only an interim solution and that we need to
* think on the best way to do this.
*/
-static void logmsgInternal(int pri, char *msg, int flags)
+static void
+logmsgInternal(int pri, char *msg, int flags)
{
msg_t *pMsg;
@@ -2364,8 +2352,7 @@ int shouldProcessThisMessage(selector_t *f, msg_t *pMsg)
iRet = 1;
} else {
assert(f->f_filter_type == FILTER_PROP); /* assert() just in case... */
- pszPropVal = MsgGetProp(pMsg, NULL,
- f->f_filterData.prop.pCSPropName, &pbMustBeFreed);
+ pszPropVal = MsgGetProp(pMsg, NULL, f->f_filterData.prop.pCSPropName, &pbMustBeFreed);
/* Now do the compares (short list currently ;)) */
switch(f->f_filterData.prop.operation ) {
@@ -2447,6 +2434,13 @@ static rsRetVal callAction(msg_t *pMsg, action_t *pAction)
assert(pMsg != NULL);
assert(pAction != NULL);
+ /* Make sure nodbody else modifies/uses this action object. Right now, this
+ * is important because of "message repeated n times" processing, later it will
+ * become important when we (possibly) have multiple worker threads.
+ * rgerhards, 2007-12-11
+ */
+ LockObj(pAction);
+
/* first, we need to check if this is a disabled
* entry. If so, we must not further process it.
* rgerhards 2005-09-26
@@ -2466,7 +2460,7 @@ static rsRetVal callAction(msg_t *pMsg, action_t *pAction)
}
/* don't output marks to recently written files */
- if ((pMsg->msgFlags & MARK) && (now - pAction->f_time) < MarkInterval / 2) {
+ if ((pMsg->msgFlags & MARK) && (time(NULL) - pAction->f_time) < MarkInterval / 2) {
ABORT_FINALIZE(RS_RET_OK);
}
@@ -2480,14 +2474,15 @@ static rsRetVal callAction(msg_t *pMsg, action_t *pAction)
!strcmp(getAPPNAME(pMsg), getAPPNAME(pAction->f_pMsg))) {
pAction->f_prevcount++;
dbgprintf("msg repeated %d times, %ld sec of %d.\n",
- pAction->f_prevcount, now - pAction->f_time,
+ pAction->f_prevcount, time(NULL) - pAction->f_time,
repeatinterval[pAction->f_repeatcount]);
+ /* use current message, so we have the new timestamp (means we need to discard previous one) */
MsgDestruct(pAction->f_pMsg);
pAction->f_pMsg = MsgAddRef(pMsg);
/* If domark would have logged this by now, flush it now (so we don't hold
* isolated messages), but back off so we'll flush less often in the future.
*/
- if (now > REPEATTIME(pAction)) {
+ if(time(NULL) > REPEATTIME(pAction)) {
iRet = fprintlog(pAction);
BACKOFF(pAction);
}
@@ -2510,6 +2505,7 @@ static rsRetVal callAction(msg_t *pMsg, action_t *pAction)
}
finalize_it:
+ UnlockObj(pAction);
return iRet;
}
@@ -2678,7 +2674,7 @@ static msgQueue *queueInit (void)
static void queueDelete (msgQueue *q)
{
pthread_mutex_destroy (q->mut);
- free (q->mut);
+ free (q->mut);
pthread_cond_destroy (q->notFull);
free (q->notFull);
pthread_cond_destroy (q->notEmpty);
@@ -3064,8 +3060,7 @@ static int parseLegacySyslogMsg(msg_t *pMsg, int flags)
* MSG part of the message (as of RFC 3164).
* rgerhards 2004-12-03
*/
- (void) time(&now);
- if (flags & ADDDATE) {
+ if(flags & ADDDATE) {
getCurrTime(&(pMsg->tTIMESTAMP)); /* use the current time! */
}
@@ -3222,7 +3217,8 @@ static int parseLegacySyslogMsg(msg_t *pMsg, int flags)
* potential for misinterpretation, which we simply can not solve under the
* circumstances given.
*/
-void logmsg(int pri, msg_t *pMsg, int flags)
+void
+logmsg(int pri, msg_t *pMsg, int flags)
{
char *msg;
char PRItext[20];
@@ -3302,15 +3298,20 @@ void logmsg(int pri, msg_t *pMsg, int flags)
* when a message was already repeated but also when a new message
* arrived.
* rgerhards 2007-08-01: interface changed to use action_t
+ * rgerhards, 2007-12-11: please note: THIS METHOD MUST ONLY BE
+ * CALLED AFTER THE CALLER HAS LOCKED THE pAction OBJECT! We do
+ * not do this here. Failing to do so results in all kinds of
+ * "interesting" problems!
*/
-rsRetVal fprintlog(action_t *pAction)
+rsRetVal
+fprintlog(action_t *pAction)
{
msg_t *pMsgSave; /* to save current message pointer, necessary to restore
it in case it needs to be updated (e.g. repeated msgs) */
- pMsgSave = NULL; /* indicate message poiner not saved */
DEFiRet;
int i;
+ pMsgSave = NULL; /* indicate message poiner not saved */
/* first check if this is a regular message or the repeation of
* a previous message. If so, we need to change the message text
* to "last message repeated n times" and then go ahead and write
@@ -3349,7 +3350,7 @@ rsRetVal fprintlog(action_t *pAction)
dbgprintf("Called fprintlog, logging to %s", modGetStateName(pAction->pMod));
- pAction->f_time = now; /* we need this for message repeation processing TODO: why must "now" be global? */
+ time(&pAction->f_time); /* we need this for message repeation processing */
/* When we reach this point, we have a valid, non-disabled action.
* So let's execute it. -- rgerhards, 2007-07-24
@@ -3373,7 +3374,7 @@ rsRetVal fprintlog(action_t *pAction)
}
if(iRet == RS_RET_OK)
- pAction->f_prevcount = 0; /* message process, so we start a new cycle */
+ pAction->f_prevcount = 0; /* message processed, so we start a new cycle */
finalize_it:
/* cleanup */
@@ -3387,12 +3388,12 @@ finalize_it:
if(pMsgSave != NULL) {
/* we had saved the original message pointer. That was
* done because we needed to create a temporary one
- * (most often for "message repeated n time" handling. If so,
+ * (most often for "message repeated n time" handling). If so,
* we need to restore the original one now, so that procesing
* can continue as normal. We also need to discard the temporary
* one, as we do not like memory leaks ;) Please note that the original
* message object will be discarded by our callers, so this is nothing
- * of our buisiness. rgerhards, 2007-07-10
+ * of our business. rgerhards, 2007-07-10
*/
MsgDestruct(pAction->f_pMsg);
pAction->f_pMsg = pMsgSave; /* restore it */
@@ -3402,7 +3403,8 @@ finalize_it:
}
-static void reapchild()
+static void
+reapchild()
{
int saved_errno = errno;
struct sigaction sigAct;
@@ -3425,14 +3427,16 @@ DEFFUNC_llExecFunc(domarkActions)
action_t *pAction = (action_t*) pData;
assert(pAction != NULL);
-
- if (pAction->f_prevcount && now >= REPEATTIME(pAction)) {
+
+ LockObj(pAction);
+ if (pAction->f_prevcount && time(NULL) >= REPEATTIME(pAction)) {
dbgprintf("flush %s: repeated %d times, %d sec.\n",
modGetStateName(pAction->pMod), pAction->f_prevcount,
repeatinterval[pAction->f_repeatcount]);
fprintlog(pAction);
BACKOFF(pAction);
}
+ UnlockObj(pAction);
return RS_RET_OK; /* we ignore errors, we can not do anything either way */
}
@@ -3449,22 +3453,27 @@ DEFFUNC_llExecFunc(domarkActions)
* main thread itself, which is the only thing to make sure rsyslogd will not do
* strange things. The way it originally was seemed to work because mark occurs very
* seldom. However, the code called was anything else but reentrant, so it was like
- * russian roulette.
- * rgerhards, 2005-10-20
+ * russian roulette. - rgerhards, 2005-10-20
+ * rgerhards, 2007-12-11: ... and it still is, if running multithreaded. Because in this
+ * case we run concurrently to the actions... I have now fixed that by using synchronization
+ * macros.
*/
-static void domark(void)
+static void
+domark(void)
{
register selector_t *f;
if (MarkInterval > 0) {
- now = time(NULL);
MarkSeq += TIMERINTVL;
if (MarkSeq >= MarkInterval) {
logmsgInternal(LOG_INFO, "-- MARK --", ADDDATE|MARK);
MarkSeq = 0;
}
- /* see if we need to flush any "message repeated n times"... */
+ /* see if we need to flush any "message repeated n times"...
+ * Note that this interferes with objects running on another thread.
+ * We are using appropriate locking inside the function to handle that.
+ */
for (f = Files; f != NULL ; f = f->f_next) {
llExecFunc(&f->llActList, domarkActions, NULL);
}
@@ -3476,7 +3485,8 @@ static void domark(void)
* domark request. See domark() comments for further details.
* rgerhards, 2005-10-20
*/
-static void domarkAlarmHdlr()
+static void
+domarkAlarmHdlr()
{
struct sigaction sigAct;
@@ -3548,8 +3558,10 @@ void logerror(char *type)
if (errno == 0)
snprintf(buf, sizeof(buf), "%s", type);
- else
- snprintf(buf, sizeof(buf), "%s: %s", type, strerror_r(errno, errStr, sizeof(errStr)));
+ else {
+ strerror_r(errno, errStr, sizeof(errStr));
+ snprintf(buf, sizeof(buf), "%s: %s", type, errStr);
+ }
buf[sizeof(buf)/sizeof(char) - 1] = '\0'; /* just to be on the safe side... */
errno = 0;
logmsgInternal(LOG_SYSLOG|LOG_ERR, buf, ADDDATE);
@@ -3638,8 +3650,6 @@ static void die(int sig)
/* de-init some modules */
modExitIminternal();
- unregCfSysLineHdlrs();
-
/* TODO: this would also be the right place to de-init the builtin output modules. We
* do not currently do that, because the module interface does not allow for
* it. This will come some time later (it's essential with loadable modules).
@@ -3652,6 +3662,12 @@ static void die(int sig)
*/
modUnloadAndDestructAll();
+ /* the following line cleans up CfSysLineHandlers that were not based on loadable
+ * modules. As such, they are not yet cleared.
+ */
+ unregCfSysLineHdlrs();
+
+
/* clean up auxiliary data */
if(pModDir != NULL)
free(pModDir);
@@ -3730,10 +3746,15 @@ static rsRetVal addAllowedSenderLine(char* pName, uchar** ppRestOfConfLine)
}
if((iRet = AddAllowedSender(ppRoot, ppLast, uIP, iBits))
!= RS_RET_OK) {
- logerrorInt("Error %d adding allowed sender entry "
- "- ignoring.", iRet);
- rsParsDestruct(pPars);
- return(iRet);
+ if (iRet == RS_RET_NOENTRY) {
+ logerrorInt("Error %d adding allowed sender entry "
+ "- ignoring.", iRet);
+ } else {
+ logerrorInt("Error %d adding allowed sender entry "
+ "- terminating, nothing more will be added.", iRet);
+ rsParsDestruct(pPars);
+ return(iRet);
+ }
}
free (uIP); /* copy stored in AllowedSenders list */
}
@@ -3788,7 +3809,9 @@ static rsRetVal doIncludeDirectory(uchar *pDirName)
continue; /* these files we are also not interested in */
++iEntriesDone;
/* construct filename */
- iFileNameLen = strnlen(res->d_name, NAME_MAX);
+ iFileNameLen = strlen(res->d_name);
+ if (iFileNameLen > NAME_MAX)
+ iFileNameLen = NAME_MAX;
memcpy(szFullFileName + iDirNameLen, res->d_name, iFileNameLen);
*(szFullFileName + iDirNameLen + iFileNameLen) = '\0';
dbgprintf("including file '%s'\n", szFullFileName);
@@ -4041,6 +4064,9 @@ finalize_it:
/* helper to freeSelectors(), used with llExecFunc() to flush
* pending output. -- rgerhards, 2007-08-02
+ * We do not need to lock the action object here as the processing
+ * queue is already empty and no other threads are running when
+ * we call this function. -- rgerhards, 2007-12-12
*/
DEFFUNC_llExecFunc(freeSelectorsActions)
{
@@ -4073,17 +4099,22 @@ static void freeSelectors(void)
*/
processImInternal();
- /* we need first to flush, then wait for all messages to be processed
- * (stopWoker() does that), then we can free the structures.
+ /* we first wait until all messages are processed (stopWorker() does
+ * that. Then, we go one last time over all actions and flush any
+ * pending "message repeated n times" messages. We must use this sequence
+ * because otherwise we would flush at whatever message is currently being
+ * processed without draining the queue. That would lead to invalid
+ * results. -- rgerhards, 2007-12-12
*/
- for(f = Files ; f != NULL ; f = f->f_next) {
- llExecFunc(&f->llActList, freeSelectorsActions, NULL);
- }
-
# ifdef USE_PTHREADS
stopWorker();
# endif
+ for(f = Files ; f != NULL ; f = f->f_next) {
+ llExecFunc(&f->llActList, freeSelectorsActions, NULL);
+ }
+
+ /* actions flushed and ready for destruction - so do that... */
f = Files;
while (f != NULL) {
fPrev = f;
@@ -4281,8 +4312,10 @@ finalize_it:
char errStr[1024];
if(fCurr != NULL)
selectorDestruct(fCurr);
+
+ strerror_r(errno, errStr, sizeof(errStr));
dbgprintf("error %d processing config file '%s'; os error (if any): %s\n",
- iRet, pConfFile, strerror_r(errno, errStr, sizeof(errStr)));
+ iRet, pConfFile, errStr);
}
return iRet;
}
@@ -4323,8 +4356,7 @@ static void init(void)
}
}
- assert (pAllowedSenders_UDP == NULL &&
- pAllowedSenders_TCP == NULL );
+ assert(pAllowedSenders_UDP == NULL && pAllowedSenders_TCP == NULL);
#endif
/* I was told by an IPv6 expert that calling getservbyname() seems to be
* still valid, at least for the use case we have. So I re-enabled that
@@ -4360,7 +4392,9 @@ static void init(void)
dbgprintf("rsyslog %s.\n", VERSION);
dbgprintf("Called init.\n");
- /* Close all open log files and free log descriptor array. */
+ /* Close all open log files and free log descriptor array. This also frees
+ * all output-modules instance data.
+ */
freeSelectors();
/* Unload all non-static modules */
@@ -4397,7 +4431,7 @@ static void init(void)
* We ignore any errors while doing this - we would be lost anyhow...
*/
selector_t *f = NULL;
- char szTTYNameBuf[TTY_NAME_MAX+1]; /* +1 for NULL character */
+ char szTTYNameBuf[_POSIX_TTY_NAME_MAX+1]; /* +1 for NULL character */
dbgprintf("primary config file could not be opened - using emergency definitions.\n");
cfline((uchar*)"*.ERR\t" _PATH_CONSOLE, &f);
cfline((uchar*)"*.PANIC\t*", &f);
@@ -4458,6 +4492,14 @@ static void init(void)
* need to do that, I recommend controlling that via a
* user-selectable option. rgerhards, 2007-06-21
*/
+# ifdef USE_GSSAPI
+ if(bEnableTCP == 2) {
+ if(TCPSessGSSInit()) {
+ logerror("GSS-API initialization failed\n");
+ bEnableTCP = -1;
+ }
+ }
+# endif
if((sockTCPLstn = create_tcp_socket()) != NULL) {
dbgprintf("Opened %d syslog TCP port(s).\n", *sockTCPLstn);
}
@@ -5639,8 +5681,9 @@ static rsRetVal processSelectAfter(int maxfds, int nfds, fd_set *pReadfds, fd_se
printchopped(LocalHostName, line, iRcvd, fd, funixParseHost[i]);
} else if (iRcvd < 0 && errno != EINTR) {
char errStr[1024];
+ strerror_r(errno, errStr, sizeof(errStr));
dbgprintf("UNIX socket error: %d = %s.\n", \
- errno, strerror_r(errno, errStr, sizeof(errStr)));
+ errno, errStr);
logerror("recvfrom UNIX");
}
FDPROCESSED();
@@ -5678,8 +5721,8 @@ static rsRetVal processSelectAfter(int maxfds, int nfds, fd_set *pReadfds, fd_se
}
} else if (l < 0 && errno != EINTR && errno != EAGAIN) {
char errStr[1024];
- dbgprintf("INET socket error: %d = %s.\n",
- errno, strerror_r(errno, errStr, sizeof(errStr)));
+ strerror_r(errno, errStr, sizeof(errStr));
+ dbgprintf("INET socket error: %d = %s.\n", errno, errStr);
logerror("recvfrom inet");
/* should be harmless */
sleep(1);
@@ -5693,7 +5736,12 @@ static rsRetVal processSelectAfter(int maxfds, int nfds, fd_set *pReadfds, fd_se
for (i = 0; i < *sockTCPLstn; i++) {
if (FD_ISSET(sockTCPLstn[i+1], pReadfds)) {
dbgprintf("New connect on TCP inetd socket: #%d\n", sockTCPLstn[i+1]);
- TCPSessAccept(sockTCPLstn[i+1]);
+# ifdef USE_GSSAPI
+ if(bEnableTCP == 2)
+ TCPSessGSSAccept(sockTCPLstn[i+1]);
+ else
+# endif
+ TCPSessAccept(sockTCPLstn[i+1]);
FDPROCESSED();
}
}
@@ -5709,16 +5757,34 @@ static rsRetVal processSelectAfter(int maxfds, int nfds, fd_set *pReadfds, fd_se
dbgprintf("tcp session socket with new data: #%d\n", fdSess);
/* Receive message */
- state = recv(fdSess, buf, sizeof(buf), 0);
+# ifdef USE_GSSAPI
+ if(bEnableTCP == 2)
+ state = TCPSessGSSRecv(iTCPSess, buf, sizeof(buf));
+ else
+# endif
+ state = recv(fdSess, buf, sizeof(buf), 0);
if(state == 0) {
- /* process any incomplete frames left over */
- TCPSessPrepareClose(iTCPSess);
- /* Session closed */
- TCPSessClose(iTCPSess);
+# ifdef USE_GSSAPI
+ if(bEnableTCP == 2)
+ TCPSessGSSClose(iTCPSess);
+ else {
+# endif
+ /* process any incomplete frames left over */
+ TCPSessPrepareClose(iTCPSess);
+ /* Session closed */
+ TCPSessClose(iTCPSess);
+# ifdef USE_GSSAPI
+ }
+# endif
} else if(state == -1) {
logerrorInt("TCP session %d will be closed, error ignored\n",
fdSess);
- TCPSessClose(iTCPSess);
+# ifdef USE_GSSAPI
+ if(bEnableTCP == 2)
+ TCPSessGSSClose(iTCPSess);
+ else
+# endif
+ TCPSessClose(iTCPSess);
} else {
/* valid data received, process it! */
if(TCPSessDataRcvd(iTCPSess, buf, state) == 0) {
@@ -5728,7 +5794,12 @@ static rsRetVal processSelectAfter(int maxfds, int nfds, fd_set *pReadfds, fd_se
logerrorInt("Tearing down TCP Session %d - see "
"previous messages for reason(s)\n",
iTCPSess);
- TCPSessClose(iTCPSess);
+# ifdef USE_GSSAPI
+ if(bEnableTCP == 2)
+ TCPSessGSSClose(iTCPSess);
+ else
+# endif
+ TCPSessClose(iTCPSess);
}
}
FDPROCESSED();
@@ -5989,27 +6060,30 @@ static rsRetVal loadBuildInModules(void)
* This, I think, is the right thing to do. -- rgerhards, 2007-07-31
*/
#ifdef USE_PTHREADS
- CHKiRet(regCfSysLineHdlr((uchar *)"mainmsgqueuesize", 0, eCmdHdlrInt, NULL, &iMainMsgQueueSize));
+ CHKiRet(regCfSysLineHdlr((uchar *)"mainmsgqueuesize", 0, eCmdHdlrInt, NULL, &iMainMsgQueueSize, NULL));
#endif
- CHKiRet(regCfSysLineHdlr((uchar *)"repeatedmsgreduction", 0, eCmdHdlrBinary, NULL, &bReduceRepeatMsgs));
- CHKiRet(regCfSysLineHdlr((uchar *)"actionexeconlywhenpreviousissuspended", 0, eCmdHdlrBinary, NULL, &bActExecWhenPrevSusp));
- CHKiRet(regCfSysLineHdlr((uchar *)"actionresumeinterval", 0, eCmdHdlrInt, setActionResumeInterval, NULL));
- CHKiRet(regCfSysLineHdlr((uchar *)"controlcharacterescapeprefix", 0, eCmdHdlrGetChar, NULL, &cCCEscapeChar));
- CHKiRet(regCfSysLineHdlr((uchar *)"escapecontrolcharactersonreceive", 0, eCmdHdlrBinary, NULL, &bEscapeCCOnRcv));
- CHKiRet(regCfSysLineHdlr((uchar *)"dropmsgswithmaliciousdnsptrrecords", 0, eCmdHdlrBinary, NULL, &bDropMalPTRMsgs));
- CHKiRet(regCfSysLineHdlr((uchar *)"droptrailinglfonreception", 0, eCmdHdlrBinary, NULL, &bDropTrailingLF));
- CHKiRet(regCfSysLineHdlr((uchar *)"template", 0, eCmdHdlrCustomHandler, doNameLine, (void*)DIR_TEMPLATE));
- CHKiRet(regCfSysLineHdlr((uchar *)"outchannel", 0, eCmdHdlrCustomHandler, doNameLine, (void*)DIR_OUTCHANNEL));
- CHKiRet(regCfSysLineHdlr((uchar *)"allowedsender", 0, eCmdHdlrCustomHandler, doNameLine, (void*)DIR_ALLOWEDSENDER));
- CHKiRet(regCfSysLineHdlr((uchar *)"modload", 0, eCmdHdlrCustomHandler, doModLoad, NULL));
- CHKiRet(regCfSysLineHdlr((uchar *)"includeconfig", 0, eCmdHdlrCustomHandler, doIncludeLine, NULL));
- CHKiRet(regCfSysLineHdlr((uchar *)"umask", 0, eCmdHdlrFileCreateMode, setUmask, NULL));
- CHKiRet(regCfSysLineHdlr((uchar *)"debugprinttemplatelist", 0, eCmdHdlrBinary, NULL, &bDebugPrintTemplateList));
- CHKiRet(regCfSysLineHdlr((uchar *)"debugprintmodulelist", 0, eCmdHdlrBinary, NULL, &bDebugPrintModuleList));
+ CHKiRet(regCfSysLineHdlr((uchar *)"repeatedmsgreduction", 0, eCmdHdlrBinary, NULL, &bReduceRepeatMsgs, NULL));
+ CHKiRet(regCfSysLineHdlr((uchar *)"actionexeconlywhenpreviousissuspended", 0, eCmdHdlrBinary, NULL, &bActExecWhenPrevSusp, NULL));
+ CHKiRet(regCfSysLineHdlr((uchar *)"actionresumeinterval", 0, eCmdHdlrInt, setActionResumeInterval, NULL, NULL));
+ CHKiRet(regCfSysLineHdlr((uchar *)"controlcharacterescapeprefix", 0, eCmdHdlrGetChar, NULL, &cCCEscapeChar, NULL));
+ CHKiRet(regCfSysLineHdlr((uchar *)"escapecontrolcharactersonreceive", 0, eCmdHdlrBinary, NULL, &bEscapeCCOnRcv, NULL));
+ CHKiRet(regCfSysLineHdlr((uchar *)"dropmsgswithmaliciousdnsptrrecords", 0, eCmdHdlrBinary, NULL, &bDropMalPTRMsgs, NULL));
+ CHKiRet(regCfSysLineHdlr((uchar *)"droptrailinglfonreception", 0, eCmdHdlrBinary, NULL, &bDropTrailingLF, NULL));
+ CHKiRet(regCfSysLineHdlr((uchar *)"template", 0, eCmdHdlrCustomHandler, doNameLine, (void*)DIR_TEMPLATE, NULL));
+ CHKiRet(regCfSysLineHdlr((uchar *)"outchannel", 0, eCmdHdlrCustomHandler, doNameLine, (void*)DIR_OUTCHANNEL, NULL));
+ CHKiRet(regCfSysLineHdlr((uchar *)"allowedsender", 0, eCmdHdlrCustomHandler, doNameLine, (void*)DIR_ALLOWEDSENDER, NULL));
+ CHKiRet(regCfSysLineHdlr((uchar *)"modload", 0, eCmdHdlrCustomHandler, doModLoad, NULL, NULL));
+ CHKiRet(regCfSysLineHdlr((uchar *)"includeconfig", 0, eCmdHdlrCustomHandler, doIncludeLine, NULL, NULL));
+ CHKiRet(regCfSysLineHdlr((uchar *)"umask", 0, eCmdHdlrFileCreateMode, setUmask, NULL, NULL));
+ CHKiRet(regCfSysLineHdlr((uchar *)"debugprinttemplatelist", 0, eCmdHdlrBinary, NULL, &bDebugPrintTemplateList, NULL));
+ CHKiRet(regCfSysLineHdlr((uchar *)"debugprintmodulelist", 0, eCmdHdlrBinary, NULL, &bDebugPrintModuleList, NULL));
CHKiRet(regCfSysLineHdlr((uchar *)"debugprintcfsyslinehandlerlist", 0, eCmdHdlrBinary,
- NULL, &bDebugPrintCfSysLineHandlerList));
- CHKiRet(regCfSysLineHdlr((uchar *)"moddir", 0, eCmdHdlrGetWord, NULL, &pModDir));
- CHKiRet(regCfSysLineHdlr((uchar *)"resetconfigvariables", 1, eCmdHdlrCustomHandler, resetConfigVariables, NULL));
+ NULL, &bDebugPrintCfSysLineHandlerList, NULL));
+ CHKiRet(regCfSysLineHdlr((uchar *)"moddir", 0, eCmdHdlrGetWord, NULL, &pModDir, NULL));
+ CHKiRet(regCfSysLineHdlr((uchar *)"resetconfigvariables", 1, eCmdHdlrCustomHandler, resetConfigVariables, NULL, NULL));
+#if defined(SYSLOG_INET) && defined(USE_GSSAPI)
+ CHKiRet(regCfSysLineHdlr((uchar *)"gsslistenservicename", 0, eCmdHdlrGetWord, NULL, &gss_listen_service_name, NULL));
+#endif
finalize_it:
return iRet;
@@ -6096,6 +6170,8 @@ static void mainThread()
tplAddLine(" StdUsrMsgFmt", &pTmp);
pTmp = template_StdDBFmt;
tplLastStaticInit(tplAddLine(" StdDBFmt", &pTmp));
+ pTmp = template_StdPgSQLFmt;
+ tplLastStaticInit(tplAddLine(" StdPgSQLFmt", &pTmp));
dbgprintf("Starting.\n");
init();
@@ -6156,7 +6232,7 @@ int main(int argc, char **argv)
/* END core initializations */
- while ((ch = getopt(argc, argv, "46Aa:dehi:f:l:m:nop:r::s:t:u:vwx")) != EOF) {
+ while ((ch = getopt(argc, argv, "46Aa:dehi:f:g:l:m:nop:qQr::s:t:u:vwx")) != EOF) {
switch((char)ch) {
case '4':
family = PF_INET;
@@ -6189,6 +6265,14 @@ int main(int argc, char **argv)
case 'f': /* configuration file */
ConfFile = (uchar*) optarg;
break;
+ case 'g': /* enable tcp gssapi logging */
+#if defined(SYSLOG_INET) && defined(USE_GSSAPI)
+ configureTCPListen(optarg);
+ bEnableTCP = 2;
+#else
+ fprintf(stderr, "rsyslogd: -g not valid - not compiled with gssapi support");
+#endif
+ break;
case 'h':
NoHops = 0;
break;
@@ -6215,6 +6299,12 @@ int main(int argc, char **argv)
case 'p': /* path to regular log socket */
funixn[0] = optarg;
break;
+ case 'q': /* add hostname if DNS resolving has failed */
+ ACLAddHostnameOnFail = 1;
+ break;
+ case 'Q': /* dont resolve hostnames in ACL to IPs */
+ ACLDontResolve = 1;
+ break;
case 'r': /* accept remote messages */
#ifdef SYSLOG_INET
AcceptRemote = 1;
@@ -6363,7 +6453,7 @@ int main(int argc, char **argv)
*/
for (p = (char *)LocalDomain; *p ; p++)
if (isupper((int) *p))
- *p = tolower(*p);
+ *p = (char)tolower((int)*p);
memset(&sigAct, 0, sizeof (sigAct));
sigemptyset(&sigAct.sa_mask);
diff --git a/syslogd.h b/syslogd.h
index 2295013..c1d765e 100644
--- a/syslogd.h
+++ b/syslogd.h
@@ -59,6 +59,7 @@ void freeAllSockets(int **socks);
int isAllowedSender(struct AllowedSenders *pAllowRoot, struct sockaddr *pFrom, const char *pszFromHost);
void getCurrTime(struct syslogTime *t);
int formatTimestampToMySQL(struct syslogTime *ts, char* pDst, size_t iLenDst);
+int formatTimestampToPgSQL(struct syslogTime *ts, char* pDst, size_t iLenDst);
int formatTimestamp3339(struct syslogTime *ts, char* pBuf, size_t iLenBuf);
int formatTimestamp3164(struct syslogTime *ts, char* pBuf, size_t iLenBuf);
void untty(void);
@@ -67,8 +68,6 @@ rsRetVal cflineParseFileName(uchar* p, uchar *pFileName, omodStringRequest_t *pO
int getSubString(uchar **ppSrc, char *pDst, size_t DstSize, char cSep);
extern int glblHadMemShortage; /* indicates if we had memory shortage some time during the run */
-extern syslogCODE rs_prioritynames[];
-extern syslogCODE rs_facilitynames[];
extern char LocalHostName[];
extern int family;
extern int NoHops;
diff --git a/tcpsyslog.c b/tcpsyslog.c
index d2a4b72..c259166 100644
--- a/tcpsyslog.c
+++ b/tcpsyslog.c
@@ -42,10 +42,15 @@
#if HAVE_FCNTL_H
#include <fcntl.h>
#endif
-
+#if defined(SYSLOG_INET) && defined(USE_GSSAPI)
+#include <gssapi.h>
+#endif
#include "syslogd.h"
#include "syslogd-types.h"
#include "net.h"
+#if defined(SYSLOG_INET) && defined(USE_GSSAPI)
+#include "gss-misc.h"
+#endif
#include "tcpsyslog.h"
/********************************************************************
* ### SYSLOG/TCP CODE ###
@@ -71,7 +76,10 @@ int bEnableTCP = 0; /* read-only after startup */
int *sockTCPLstn = NULL; /* read-only after startup, modified by restart */
struct TCPSession *pTCPSessions;
/* The thread-safeness of the sesion table is doubtful */
-
+#ifdef USE_GSSAPI
+static gss_cred_id_t gss_server_creds;
+char *gss_listen_service_name = NULL;
+#endif
/* configure TCP listener settings. This is called during command
* line parsing. The argument following -t is supplied as an argument.
@@ -155,6 +163,10 @@ static int TCPSessInit(void)
pTCPSessions[i].iMsg = 0; /* just make sure... */
pTCPSessions[i].bAtStrtOfFram = 1; /* indicate frame header expected */
pTCPSessions[i].eFraming = TCP_FRAMING_OCTET_STUFFING; /* just make sure... */
+#ifdef USE_GSSAPI
+ pTCPSessions[i].gss_flags = 0;
+ pTCPSessions[i].gss_context = GSS_C_NO_CONTEXT;
+#endif
}
return(0);
}
@@ -215,6 +227,15 @@ void deinit_tcp_listener(void)
fd = pTCPSessions[iTCPSess].sock;
dbgprintf("Closing TCP Session %d\n", fd);
close(fd);
+ free(pTCPSessions[iTCPSess].fromHost);
+#ifdef USE_GSSAPI
+ if(bEnableTCP == 2) {
+ OM_uint32 maj_stat, min_stat;
+ maj_stat = gss_delete_sec_context(&min_stat, &pTCPSessions[iTCPSess].gss_context, GSS_C_NO_BUFFER);
+ if (maj_stat != GSS_S_COMPLETE)
+ display_status("deleting context", maj_stat, min_stat);
+ }
+#endif
/* now get next... */
iTCPSess = TCPSessGetNxtSess(iTCPSess);
}
@@ -389,7 +410,7 @@ int *create_tcp_socket(void)
* is no more space left in the connection table, the new TCP
* connection is immediately dropped.
*/
-void TCPSessAccept(int fd)
+int TCPSessAccept(int fd)
{
int newConn;
int iSess;
@@ -403,7 +424,7 @@ void TCPSessAccept(int fd)
newConn = accept(fd, (struct sockaddr*) &addr, &addrlen);
if (newConn < 0) {
logerror("tcp accept, ignoring error and connection request");
- return;
+ return -1;
}
/* Add to session list */
@@ -412,7 +433,7 @@ void TCPSessAccept(int fd)
errno = 0;
logerror("too many tcp sessions - dropping incoming request");
close(newConn);
- return;
+ return -1;
}
/* OK, we have a "good" index... */
@@ -423,7 +444,7 @@ void TCPSessAccept(int fd)
* Error message has been generated by cvthname.
*/
close (newConn);
- return;
+ return -1;
}
/* Here we check if a host is permitted to send us
@@ -439,7 +460,7 @@ void TCPSessAccept(int fd)
(char*)fromHost);
}
close(newConn);
- return;
+ return -1;
}
/* OK, we have an allowed sender, so let's continue */
@@ -454,6 +475,7 @@ void TCPSessAccept(int fd)
pTCPSessions[iSess].sock = newConn;
pTCPSessions[iSess].iMsg = 0; /* init msg buffer! */
+ return iSess;
}
@@ -678,6 +700,157 @@ int TCPSessDataRcvd(int iTCPSess, char *pData, int iLen)
}
+#ifdef USE_GSSAPI
+int TCPSessGSSInit(void)
+{
+ gss_buffer_desc name_buf;
+ gss_name_t server_name;
+ OM_uint32 maj_stat, min_stat;
+
+ name_buf.value = (gss_listen_service_name == NULL) ? "host" : gss_listen_service_name;
+ name_buf.length = strlen(name_buf.value) + 1;
+ maj_stat = gss_import_name(&min_stat, &name_buf, GSS_C_NT_HOSTBASED_SERVICE, &server_name);
+ if (maj_stat != GSS_S_COMPLETE) {
+ display_status("importing name", maj_stat, min_stat);
+ return -1;
+ }
+
+ maj_stat = gss_acquire_cred(&min_stat, server_name, 0,
+ GSS_C_NULL_OID_SET, GSS_C_ACCEPT,
+ &gss_server_creds, NULL, NULL);
+ if (maj_stat != GSS_S_COMPLETE) {
+ display_status("acquiring credentials", maj_stat, min_stat);
+ return -1;
+ }
+
+ gss_release_name(&min_stat, &server_name);
+ dbgprintf("GSS-API initialized\n");
+ return 0;
+}
+
+
+int TCPSessGSSAccept(int fd)
+{
+ gss_buffer_desc send_tok, recv_tok;
+ gss_name_t client;
+ gss_OID doid;
+ OM_uint32 maj_stat, min_stat, acc_sec_min_stat;
+ int iSess;
+ gss_ctx_id_t *context;
+ OM_uint32 *sess_flags;
+ int fdSess;
+
+ if ((iSess = TCPSessAccept(fd)) == -1)
+ return -1;
+
+ context = &pTCPSessions[iSess].gss_context;
+ *context = GSS_C_NO_CONTEXT;
+ sess_flags = &pTCPSessions[iSess].gss_flags;
+ fdSess = pTCPSessions[iSess].sock;
+
+ do {
+ if (recv_token(fdSess, &recv_tok) <= 0)
+ return -1;
+
+ maj_stat = gss_accept_sec_context(&acc_sec_min_stat, context, gss_server_creds,
+ &recv_tok, GSS_C_NO_CHANNEL_BINDINGS, &client,
+ NULL, &send_tok, sess_flags, NULL, NULL);
+ if (recv_tok.value) {
+ free(recv_tok.value);
+ recv_tok.value = NULL;
+ }
+ if (send_tok.length != 0) {
+ if (send_token(fdSess, &send_tok) < 0) {
+ return -1;
+ }
+
+ gss_release_buffer(&min_stat, &send_tok);
+ }
+ if (maj_stat != GSS_S_COMPLETE
+ && maj_stat != GSS_S_CONTINUE_NEEDED) {
+ display_status("accepting context", maj_stat,
+ acc_sec_min_stat);
+ if (*context != GSS_C_NO_CONTEXT)
+ gss_delete_sec_context(&min_stat, context,
+ GSS_C_NO_BUFFER);
+ return -1;
+ }
+ } while (maj_stat == GSS_S_CONTINUE_NEEDED);
+
+ maj_stat = gss_display_name(&min_stat, client, &recv_tok, NULL);
+ if (maj_stat != GSS_S_COMPLETE)
+ display_status("displaying name", maj_stat, min_stat);
+ gss_release_name(&min_stat, &client);
+
+ dbgprintf("GSS-API Accepted connection from: %s\n", recv_tok.value);
+ gss_release_buffer(&min_stat, &recv_tok);
+
+ dbgprintf("GSS-API Provided context flags:\n");
+ display_ctx_flags(*sess_flags);
+
+ return 0;
+}
+
+
+int TCPSessGSSRecv(int iSess, void *buf, size_t buf_len)
+{
+ gss_buffer_desc xmit_buf, msg_buf;
+ gss_ctx_id_t *context;
+ OM_uint32 maj_stat, min_stat;
+ int fdSess;
+ int conf_state;
+ int state, len;
+
+ fdSess = pTCPSessions[iSess].sock;
+ if ((state = recv_token(fdSess, &xmit_buf)) <= 0)
+ return state;
+
+ context = &pTCPSessions[iSess].gss_context;
+ maj_stat = gss_unwrap(&min_stat, *context, &xmit_buf, &msg_buf,
+ &conf_state, (gss_qop_t *) NULL);
+ if (maj_stat != GSS_S_COMPLETE) {
+ display_status("unsealing message", maj_stat, min_stat);
+ if (xmit_buf.value) {
+ free(xmit_buf.value);
+ xmit_buf.value = 0;
+ }
+ return (-1);
+ }
+ if (xmit_buf.value) {
+ free(xmit_buf.value);
+ xmit_buf.value = 0;
+ }
+
+ len = msg_buf.length < buf_len ? msg_buf.length : buf_len;
+ memcpy(buf, msg_buf.value, len);
+ gss_release_buffer(&min_stat, &msg_buf);
+
+ return len;
+}
+
+
+void TCPSessGSSClose(int iSess) {
+ OM_uint32 maj_stat, min_stat;
+ gss_ctx_id_t *context;
+
+ if(iSess < 0 || iSess > iTCPSessMax) {
+ errno = 0;
+ logerror("internal error, trying to close an invalid TCP session!");
+ return;
+ }
+
+ context = &pTCPSessions[iSess].gss_context;
+ maj_stat = gss_delete_sec_context(&min_stat, context, GSS_C_NO_BUFFER);
+ if (maj_stat != GSS_S_COMPLETE)
+ display_status("deleting context", maj_stat, min_stat);
+ *context = GSS_C_NO_CONTEXT;
+ pTCPSessions[iSess].gss_flags = 0;
+
+ TCPSessClose(iSess);
+}
+#endif /* #ifdef USE_GSSAPI */
+
+
#endif
/********************************************************************
* ### END OF SYSLOG/TCP CODE ###
diff --git a/tcpsyslog.h b/tcpsyslog.h
index 1cead1a..f8e2fa9 100644
--- a/tcpsyslog.h
+++ b/tcpsyslog.h
@@ -24,6 +24,10 @@
#ifndef TCPSYSLOG_H_INCLUDED
#define TCPSYSLOG_H_INCLUDED 1
+#if defined(SYSLOG_INET) && defined(USE_GSSAPI)
+#include <gssapi.h>
+#endif
+
struct TCPSession {
int sock;
int iMsg; /* index of next char to store in msg */
@@ -32,6 +36,10 @@ struct TCPSession {
TCPFRAMINGMODE eFraming;
char msg[MAXLINE+1];
char *fromHost;
+#if defined(SYSLOG_INET) && defined(USE_GSSAPI)
+ OM_uint32 gss_flags;
+ gss_ctx_id_t gss_context;
+#endif
};
/* static data */
@@ -39,16 +47,25 @@ extern int *sockTCPLstn;
extern char *TCPLstnPort;
extern int bEnableTCP;
extern struct TCPSession *pTCPSessions;
+#if defined(SYSLOG_INET) && defined(USE_GSSAPI)
+extern char *gss_listen_service_name;
+#endif
/* prototypes */
void deinit_tcp_listener(void);
int *create_tcp_socket(void);
int TCPSessGetNxtSess(int iCurr);
-void TCPSessAccept(int fd);
+int TCPSessAccept(int fd);
void TCPSessPrepareClose(int iTCPSess);
void TCPSessClose(int iSess);
int TCPSessDataRcvd(int iTCPSess, char *pData, int iLen);
void configureTCPListen(char *cOptarg);
+#if defined(SYSLOG_INET) && defined(USE_GSSAPI)
+int TCPSessGSSInit(void);
+int TCPSessGSSAccept(int fd);
+int TCPSessGSSRecv(int fd, void *buf, size_t buf_len);
+void TCPSessGSSClose(int sess);
+#endif
#endif /* #ifndef TCPSYSLOG_H_INCLUDED */
/*
diff --git a/template.c b/template.c
index 59e7484..6057109 100644
--- a/template.c
+++ b/template.c
@@ -424,6 +424,8 @@ static void doOptions(unsigned char **pp, struct templateEntry *pTpe)
*/
if(!strcmp((char*)Buf, "date-mysql")) {
pTpe->data.field.eDateFormat = tplFmtMySQLDate;
+ } else if(!strcmp((char*)Buf, "date-pgsql")) {
+ pTpe->data.field.eDateFormat = tplFmtPgSQLDate;
} else if(!strcmp((char*)Buf, "date-rfc3164")) {
pTpe->data.field.eDateFormat = tplFmtRFC3164Date;
} else if(!strcmp((char*)Buf, "date-rfc3339")) {
@@ -924,7 +926,7 @@ void tplPrintList(void)
dbgprintf("\n");
pTpe = pTpl->pEntryRoot;
while(pTpe != NULL) {
- dbgprintf("\tEntry(%x): type %d, ", (unsigned) pTpe, pTpe->eEntryType);
+ dbgprintf("\tEntry(%lx): type %d, ", (unsigned long) pTpe, pTpe->eEntryType);
switch(pTpe->eEntryType) {
case UNDEFINED:
dbgprintf("(UNDEFINED)");
@@ -941,6 +943,9 @@ void tplPrintList(void)
case tplFmtMySQLDate:
dbgprintf("[Format as MySQL-Date] ");
break;
+ case tplFmtPgSQLDate:
+ dbgprintf("[Format as PgSQL-Date] ");
+ break;
case tplFmtRFC3164Date:
dbgprintf("[Format as RFC3164-Date] ");
break;
diff --git a/template.h b/template.h
index e099e58..c5ea8c4 100644
--- a/template.h
+++ b/template.h
@@ -34,7 +34,7 @@ struct template {
enum EntryTypes { UNDEFINED = 0, CONSTANT = 1, FIELD = 2 };
enum tplFormatTypes { tplFmtDefault = 0, tplFmtMySQLDate = 1,
- tplFmtRFC3164Date = 2, tplFmtRFC3339Date = 3 };
+ tplFmtRFC3164Date = 2, tplFmtRFC3339Date = 3, tplFmtPgSQLDate = 4 };
enum tplFormatCaseConvTypes { tplCaseConvNo = 0, tplCaseConvUpper = 1, tplCaseConvLower = 2 };
#include "msg.h"