aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authoryaworsky <yaworsky>2005-09-16 08:40:43 +0000
committeryaworsky <yaworsky>2005-09-16 08:40:43 +0000
commit9691a996741fec5c5e2d290e72697806b8e4546e (patch)
treed3e49140caeeb80afdf3649608dc6407d2f1d3b8
parentcc936dc1a09d275915f82733611d7c0146846788 (diff)
downloadsyslog-win32-9691a996741fec5c5e2d290e72697806b8e4546e.tar.gz
syslog-win32-9691a996741fec5c5e2d290e72697806b8e4546e.tar.xz
syslog-win32-9691a996741fec5c5e2d290e72697806b8e4546e.zip
Added to repository.
-rw-r--r--ChangeLog28
-rw-r--r--Makefile.am3
-rw-r--r--README221
-rwxr-xr-xautogen.sh7
-rwxr-xr-xbuild.sh100
-rw-r--r--client/Makefile.am25
-rw-r--r--configure.ac77
-rw-r--r--daemon/Makefile.am20
-rw-r--r--etc/Makefile.am1
-rw-r--r--extras/Makefile.am2
-rw-r--r--setup.iss29
-rw-r--r--test/Makefile.am17
-rw-r--r--version.m41
13 files changed, 531 insertions, 0 deletions
diff --git a/ChangeLog b/ChangeLog
new file mode 100644
index 0000000..a8f6e99
--- /dev/null
+++ b/ChangeLog
@@ -0,0 +1,28 @@
+2005-09-16 15:38 yaworsky
+
+ * test/dropcount.c, test/test.c, client/Makefile.am, Makefile.am,
+ README, autogen.sh, build.sh, configure.ac, setup.iss,
+ version.m4, daemon/Makefile.am, etc/Makefile.am,
+ extras/Makefile.am, test/Makefile.am: Added to repository.
+
+2005-09-16 15:36 yaworsky
+
+ * client/logger.c, include/syslog.h: Modified for native win32.
+
+2005-09-16 15:33 yaworsky
+
+ * client/syslog-client.c, daemon/conf.c, daemon/fifo.c,
+ daemon/listener.c, daemon/logrotate.c, daemon/main.c,
+ daemon/names.c, daemon/pathnames.c, daemon/purger.c,
+ daemon/syslogd.c, daemon/syslogd.h, daemon/writer.c, AUTHORS,
+ COPYING, NEWS, TODO, etc/syslog.conf, extras/cross-compile-libs,
+ extras/glib-static-win32.patch: Added to repository.
+
+2005-09-16 10:18 yaworsky
+
+ * client/logger.c: Original source from util-linux-2.12
+
+2005-09-16 10:17 yaworsky
+
+ * include/syslog.h: Taken from Slackware 9.1
+
diff --git a/Makefile.am b/Makefile.am
new file mode 100644
index 0000000..9cd47ca
--- /dev/null
+++ b/Makefile.am
@@ -0,0 +1,3 @@
+EXTRA_DIST = autogen.sh build.sh setup.iss
+SUBDIRS = daemon client test etc extras
+include_HEADERS = include/syslog.h
diff --git a/README b/README
new file mode 100644
index 0000000..c95480e
--- /dev/null
+++ b/README
@@ -0,0 +1,221 @@
+This is an implementation of syslog daemon and client for native win32.
+This stuff is dedicated to those who is writing portable software or
+porting unix software to native win32.
+
+COMPILING
+---------
+
+You need Glib to compile this stuff.
+
+Compiling from CVS:
+
+Run autogen.sh. I used automake 1.8.5, autoconf 2.59 and libtool 1.5.10.
+With earlier versions it may not work because some command line options
+aren't supported.
+Then use configure script as described below.
+
+Compiling from source tarball:
+
+Just use configure && make.
+Option --enable-relocatable affects the location of configuration directory:
+if specified, sysconfdir is prepended with '.'.
+For example, if you run ./configure --sysconfdir=/etc --enable-relocateble
+then syslogd.exe and client will read their configuration file from etc
+subdirectory located in the same directory with executable file.
+
+Building binary distribution:
+
+Use build.sh. It does all you need.
+You should have some packages -- look into the script to see which ones.
+Also, you should have Inno Setup (http://www.jrsoftware.org) with ISPP
+installed on your system.
+
+ on unix:
+
+You should have cross compiler and Wine installed. Wine is required to run
+Inno Setup Compiler and the directory in which you are going to build should
+be accessible via some drive letter.
+Assuming target triplet is i686-pc-mingw32, iscc is in its default directory
+"c:\program files\inno setup 5" and required packages are in "./distfiles":
+
+DISTFILES=distfiles \
+ISCC=c:\\program\ files\\inno\ setup\ 5\\iscc.exe \
+HOST=i686-pc-mingw32 \
+./build.sh
+
+ on windows:
+
+I noticed that Msys has troubles running some native command-line
+applications. So you'll have to run Inno Setup by hand.
+
+DISTFILES=<path to the directory with packages> \
+./build.sh
+
+
+CONFIGURATION
+-------------
+
+The configuration file for client is optional. Its name is syslog.host
+and it should contain host name or address optionally followed by the
+colon and the port number. By default, port is 514.
+This may look a bit ugly but if you have a better idea, send me a patch.
+But keep in mind that client should not have any dependencies like daemon.
+
+The configuration file for daemon has XML format. It is not intended to be
+convinient for human because should be generated by GUI configuration tool.
+The root element is 'conf'.
++-------------+-----------+-------------------------------------------------+
+| Element | Attribute | Description |
++=============+===========+=================================================+
+| source | name | The name of message source. |
+| | type | There are two source types: 'internal' and |
+| | | 'udp'. Internal type corresponds to syslogd |
+| | | itself and 'udp' defines a listening UDP socket.|
+| | interface | Optional. If source type is udp, it defines |
+| | | interface the socket will be bound to. Default |
+| | | is 0.0.0.0. |
+| | port | Optional. If source type is udp, it defines |
+| | | listening port number. Default is 514. |
++-------------+-----------+-------------------------------------------------+
+| destination | name | The name of the destination. |
+| | file | The pattern for the file name. See below. |
+| | rotate | daily/weekly/monthly |
+| | size | Log files are rotated when they grow bigger |
+| | | then size bytes. If size is followed by M, the |
+| | | size if assumed to be in megabytes. If the k is |
+| | | used, the size is in kilobytes. So size 100, |
+| | | size 100k, and size 100M are all valid. |
+| | backlogs | Number of backlog files. |
+| | ifempty | yes/no: rotate the log file even if it is |
+| | | empty; default is yes. |
+| | olddir | Logs are moved to this directory for rotation. |
+| | | If value is a relative path then this directory |
+| | | will be located in the same directory with |
+| | | syslogd executable. |
+| | compresscmd Command (with options) to use to compress log |
+| | | file. |
+| | compressoptions Command line options may be passed to the |
+| | | compression program, if one is in use. Options |
+| | | may contain $PATHNAME and $FILENAME substrings |
+| | | which will be replaced with backlog pathname |
+| | | basename respectively. |
++-------------+-----------+-------------------------------------------------+
+| filter | name | The name of the filter. |
+| | | This element has a set of sub-elements |
+| | | 'facility' and 'priority'. Each of them defines |
+| | | one value with attribute 'value' in numeric |
+| | | form or 'name' in verbose form. |
++-------------+-----------+-------------------------------------------------+
+| logpath | source | The name of the source. |
+| | filter | Optional. The name of the filter. |
+| | destination The name of the destination. |
++-------------+-----------+-------------------------------------------------+
+| purge | directory | Directory to purge. Must be a relative path |
+| | | inside logdir (see configuration options below) |
+| | keep_days | How long to keep files. |
++-------------+-----------+-------------------------------------------------+
+| options | See below | |
++-------------+-----------+-------------------------------------------------+
+
+Format characters for the file name pattern:
+
+ %Y four-digit year
+ %M two-digit month, 01...12
+ %m month, 1...12
+ %D two-digit day of month, 01...31
+ %d day of month, 1...31
+ %W day of week, 1...7, 1 for sunday
+ %F facility name
+ %f facility in numeric form
+ %L priority level name
+ %l priority level in numeric form
+ %H source host name (a 'device', according to RFC3164)
+ %h sender host name (datagram sender, which may be device
+ or relay)
+ %P program name
+ %% % character
+
+Attributes for the element 'options':
+
+ logdir directory for the log files; if value is a relative
+ path then this directory will be located in the same
+ directory where syslogd executable is.
+
+ dns yes/no: use resolver to determine sender host name;
+ default is yes.
+
+ source_encoding convert incoming messages from specified encoding
+ to 'destination_encoding'; do not convert by default.
+
+ destination_encoding see 'source_encoding'
+
+ mark_interval interval in second between emissions of mark message;
+ 0 means do not emit mark messages, this is the
+ default value.
+
+ mark_message content of mark message; "-- MARK --" by default.
+
+ hold number of seconds to hold a single message in queue;
+ minimum is 1, default is 3 seconds.
+ During this time identical messages are coalesced.
+
+
+IMPLEMENTATION
+--------------
+
+There are three basic parts of daemon: listener, message processor and
+message writer. All these parts run in separate threads: the listener
+receives messages as fast as possible and passes them to the message
+processor, the message processor performs time-consuming tasks and
+message writer performs asynchronous output to files.
+
+Datagrams are received by the listener. The listener emits raw messages
+(struct raw_message) which contain content of datagram, sender address
+and reference to a source described in configuration file.
+
+Raw messages are passed to the processing thread via queue.
+Message processing involves the following tasks:
+- parse datagram: pick out PRI, TIMESTAMP, HOSTNAME, TAG an CONTENT
+ according to RFC 3164;
+- convert CONTENT's encoding if specified;
+- determine sender host name if usedns option is set or just convert
+ IP address to string; the result is saved in hostname cache to speed up
+ subsequent resolutions;
+- multiplex message to logpaths and apply filters in logpaths;
+ in other words, messages are multiplexed to logpaths through filters;
+ messages in logpaths are represented with references to message structure
+ and message structure contains reference count;
+
+Because destination file name may be a pattern, further multiplexing is
+performed. Messages with similar HOSTNAME, TAG and CONTENT are coalesced.
+
+Log rotation is initiated at process startup or at writing thread startup.
+
+Old log files are deleted by the purger which is launched at process startup
+or by the writing thread after file is closed.
+
+
++--------+ raw message +-----+ +------+ message +-----------------+
+|listener|------------>|queue|--->|parser|-------->|charset converter|--->
++--------+ +-----+ +------+ +-----------------+
+
+ +------+ +-----------+ +-----------+
+--->|filter|--->|multiplexer|-+->|destination|+
+ +------+ +-----------+ +->+-----------+|+
+ ^ +-> +-----------+|
+ | +-----------+
+ +-------+
+ |logpath|+
+ +-------+|+
+ +-------+|
+ +-------+
+
+
+ +-----------+ +-----+ +--------------+
+destination: >--|multiplexer|-+->|queue|+ ---> |writing thread|+
+ +-----------+ +->+-----+|+ ---> +--------------+|+
+ ^ +-> +-----+| ---> +--------------+|
+ | +-----+ +--------------+
+ +----------------+
+ |filename pattern|
+ +----------------+
diff --git a/autogen.sh b/autogen.sh
new file mode 100755
index 0000000..f8d08ac
--- /dev/null
+++ b/autogen.sh
@@ -0,0 +1,7 @@
+#!/bin/sh
+
+aclocal
+libtoolize --force
+automake --add-missing --force
+autoconf
+./configure $@
diff --git a/build.sh b/build.sh
new file mode 100755
index 0000000..2002fa9
--- /dev/null
+++ b/build.sh
@@ -0,0 +1,100 @@
+#!/bin/sh
+#
+# build syslog-win32 setup from scratch
+#
+# optional environment variables:
+# DISTFILES should point to the directory with packages listed below
+# HOST may contain target triplet for cross-compilation
+# ISCC should point to the Inno Setup Compiler
+#
+
+default_distfiles_dir=distfiles # must be relative path
+unpacked_packages_dir=packages # must be relative path
+
+#
+# packages
+#
+libiconv=libiconv-1.9.1.bin.woe32.zip # http://www.gimp.org/~tml/gimp/win32
+gettext=gettext-runtime-0.13.1.zip # http://www.gimp.org/~tml/gimp/win32
+pkgconfig=pkgconfig-0.15.zip # http://www.gimp.org/~tml/gimp/win32
+glib=glib-2.8.0.zip # ftp://ftp.gtk.org/pub/gtk/v2.8/win32
+glib_dev=glib-dev-2.8.0.zip # ftp://ftp.gtk.org/pub/gtk/v2.8/win32
+
+function packages()
+{
+ echo $libiconv
+ echo $gettext
+ echo $pkgconfig
+ echo $glib
+ echo $glib_dev
+}
+
+workdir=`pwd`
+prefix=$workdir/$unpacked_packages_dir
+bindir=$prefix/bin
+export PATH=$bindir:$PATH
+
+#
+# clean up and create destination directory
+#
+[ -d $unpacked_packages_dir ] && rm -rf $unpacked_packages_dir
+mkdir $unpacked_packages_dir
+
+#
+# unpack packages
+#
+cd $unpacked_packages_dir
+[ -z $DISTFILES ] && DISTFILES=$workdir/$default_distfiles_dir
+for file in `packages` ; do
+ unzip $DISTFILES/$file || exit 1
+done
+cd $workdir
+
+#
+# fix prefix in *.pc files
+#
+export PKG_CONFIG_PATH=$workdir/$unpacked_packages_dir/lib/pkgconfig
+for file in $PKG_CONFIG_PATH/*.pc ; do
+ module=`basename $file`
+ module=${module%.pc}
+ old_prefix=`pkg-config --variable=prefix $module`
+ # old versions of sed haven't -i option
+ sed -e s:$old_prefix:$prefix:g $file >$file.tmp || exit 1
+ mv -f $file.tmp $file
+done
+
+# set OBJDUMP for cross-compilation
+[ -z $HOST ] || export OBJDUMP=$HOST-objdump
+
+#
+# build
+#
+[ -z $HOST ] || export __HOST__=--host=$HOST
+./configure --prefix=$prefix --sysconfdir=/etc --enable-relocatable --enable-debug ${__HOST__} || exit 1
+make
+make install-strip
+
+#
+# strip dll(s)
+#
+if [ -z $HOST ] ; then
+ STRIP=strip
+else
+ STRIP=$HOST-strip
+fi
+$STRIP -s $bindir/libsyslog*.dll
+
+#
+# create setup
+# FIXME: Msys has troubles running Inno Setup
+#
+[ -z "$ISCC" ] && ISCC=iscc.exe
+[ -z $HOST ] || __WINE__=wine
+cat <<EOF >tmp.m4
+changequote([, ])dnl
+define([m4_define], [\$2])dnl
+EOF
+version=`cat tmp.m4 version.m4 | m4`
+echo $version
+rm tmp.m4
+$__WINE__ "$ISCC" setup.iss /dversion=$version /dbindir=$unpacked_packages_dir\\bin
diff --git a/client/Makefile.am b/client/Makefile.am
new file mode 100644
index 0000000..46d41ea
--- /dev/null
+++ b/client/Makefile.am
@@ -0,0 +1,25 @@
+if OS_WIN32
+
+if DEBUG
+AM_CFLAGS = -g
+endif
+
+lib_LTLIBRARIES = libsyslog.la
+bin_PROGRAMS = logger
+
+libsyslog_la_SOURCES = syslog-client.c
+if RELOCATABLE
+libsyslog_la_CPPFLAGS = -DSYSLOG_CONF_DIR=\".$(sysconfdir)\"
+else
+libsyslog_la_CPPFLAGS = -DSYSLOG_CONF_DIR=\"$(sysconfdir)\"
+endif
+libsyslog_la_CPPFLAGS += -I../include
+libsyslog_la_LDFLAGS = -no-undefined
+libsyslog_la_LIBADD = -lws2_32
+
+logger_SOURCES = logger.c
+logger_CPPFLAGS = -I../include
+logger_LDFLAGS = -L.
+logger_LDADD = -lsyslog
+
+endif
diff --git a/configure.ac b/configure.ac
new file mode 100644
index 0000000..e63f8c8
--- /dev/null
+++ b/configure.ac
@@ -0,0 +1,77 @@
+m4_include([version.m4]) dnl
+AC_INIT(syslog-win32, [VERSION_NUMBER])
+
+AC_CANONICAL_BUILD
+AC_CANONICAL_HOST
+
+AM_INIT_AUTOMAKE($PACKAGE_NAME, $PACKAGE_VERSION)
+
+AC_PROG_CC
+AC_PROG_INSTALL
+AC_PROG_LIBTOOL
+
+dnl *************************************************************************
+dnl Check for native win32
+dnl *************************************************************************
+
+AC_MSG_CHECKING([if building for native Win32])
+case "$host" in
+ *-*-mingw*)
+ native_win32="yes"
+ ;;
+ *)
+ native_win32="no"
+ ;;
+esac
+AC_MSG_RESULT($native_win32)
+AM_CONDITIONAL(OS_WIN32, test x"${native_win32}" = xyes)
+
+dnl *************************************************************************
+dnl Parameters
+dnl *************************************************************************
+
+AC_ARG_ENABLE(relocatable,
+ [AC_HELP_STRING([--enable-relocatable],
+ [build relocatable package [default=yes]])],
+ relocatable=$enableval,
+ relocatable=yes)
+
+if test x"${relocatable}" = xyes ; then
+ AC_DEFINE(ENABLE_RELOCATABLE)
+fi
+AM_CONDITIONAL(RELOCATABLE, test x"${relocatable}" = xyes)
+
+AC_ARG_ENABLE([debug],
+ AC_HELP_STRING([--enable-debug],
+ [enable use of debugging code (default=no)]),
+ enable_debug=$enableval,
+ enable_debug=no)
+
+if test x"${enable_debug}" != xno ; then
+ AC_DEFINE([HAVE_DEBUG])
+fi
+AM_CONDITIONAL(DEBUG, test x"${enable_debug}" = xyes)
+
+dnl *************************************************************************
+dnl Check for glib,
+dnl leave CPPFLAGS, LDFLAGS and LIBS set
+dnl *************************************************************************
+
+AM_PATH_GLIB_2_0(2.0.0, ,AC_MSG_ERROR(Cannot find GLIB))
+glib_cflags="$GLIB_CFLAGS"
+glib_libs="$GLIB_LIBS"
+AC_SUBST(glib_cflags)
+AC_SUBST(glib_libs)
+
+dnl *************************************************************************
+
+AC_CONFIG_FILES([
+ Makefile
+ daemon/Makefile
+ client/Makefile
+ test/Makefile
+ etc/Makefile
+ extras/Makefile
+])
+
+AC_OUTPUT
diff --git a/daemon/Makefile.am b/daemon/Makefile.am
new file mode 100644
index 0000000..aa2599a
--- /dev/null
+++ b/daemon/Makefile.am
@@ -0,0 +1,20 @@
+if OS_WIN32
+
+if DEBUG
+AM_CFLAGS = -g
+endif
+
+if RELOCATABLE
+AM_CPPFLAGS = -DSYSLOG_CONF_DIR=\".$(sysconfdir)\"
+else
+AM_CPPFLAGS = -DSYSLOG_CONF_DIR=\"$(sysconfdir)\"
+endif
+
+AM_CPPFLAGS += -I. -I../include $(GLIB_CFLAGS)
+
+bin_PROGRAMS = syslogd
+syslogd_SOURCES = conf.c fifo.c listener.c logrotate.c main.c names.c \
+ pathnames.c purger.c syslogd.c writer.c syslogd.h
+syslogd_LDADD = -lws2_32 $(GLIB_LIBS)
+
+endif
diff --git a/etc/Makefile.am b/etc/Makefile.am
new file mode 100644
index 0000000..8e0b429
--- /dev/null
+++ b/etc/Makefile.am
@@ -0,0 +1 @@
+EXTRA_DIST = syslog.conf
diff --git a/extras/Makefile.am b/extras/Makefile.am
new file mode 100644
index 0000000..4058985
--- /dev/null
+++ b/extras/Makefile.am
@@ -0,0 +1,2 @@
+EXTRA_DIST = cross-compile-libs glib-static-win32.patch
+
diff --git a/setup.iss b/setup.iss
new file mode 100644
index 0000000..55ec18a
--- /dev/null
+++ b/setup.iss
@@ -0,0 +1,29 @@
+[Setup]
+VersionInfoVersion={#version}
+AppVersion={#version}
+AppName=Syslog
+AppVerName=Syslog {#version}
+DefaultDirName={pf}\syslog
+AllowNoIcons=yes
+LicenseFile=COPYING
+OutputDir=.
+OutputBaseFilename=syslog-win32-{#version}
+SolidCompression=yes
+UsePreviousAppDir=no
+
+[Files]
+Source: "{#bindir}\libglib-2.0-0.dll"; DestDir: "{app}"
+Source: "{#bindir}\iconv.dll"; DestDir: "{app}"
+Source: "{#bindir}\intl.dll"; DestDir: "{app}"
+Source: "{#bindir}\syslogd.exe"; DestDir: "{app}"
+Source: "{#bindir}\logger.exe"; DestDir: "{app}"
+Source: "{#bindir}\test.exe"; DestDir: "{app}"
+Source: "{#bindir}\libsyslog-0.dll"; DestDir: "{app}"
+Source: "README"; DestDir: "{app}"
+Source: "etc\syslog.conf"; DestDir: "{app}\etc"
+
+[Run]
+Filename: "{app}\syslogd.exe"; Parameters: "--install"
+
+[UninstallRun]
+Filename: "{app}\syslogd.exe"; Parameters: "--remove"
diff --git a/test/Makefile.am b/test/Makefile.am
new file mode 100644
index 0000000..6df0823
--- /dev/null
+++ b/test/Makefile.am
@@ -0,0 +1,17 @@
+if OS_WIN32
+
+if DEBUG
+AM_CFLAGS = -g
+endif
+
+AM_CPPFLAGS = -I../include
+
+bin_PROGRAMS = dropcount test
+
+dropcount_SOURCES = dropcount.c
+
+test_SOURCES = test.c
+test_LDFLAGS = -L../client
+test_LDADD = -lsyslog
+
+endif
diff --git a/version.m4 b/version.m4
new file mode 100644
index 0000000..aff4a03
--- /dev/null
+++ b/version.m4
@@ -0,0 +1 @@
+m4_define([VERSION_NUMBER], [0.1])