Skip to content

Commit

Permalink
ported to FreeBSD
Browse files Browse the repository at this point in the history
2008-03-07  Tamas Pal <[email protected]>

    	* configure.in: Added O_LARGEFILE checking macro. Removed linuxism.
    	  Added Freebsd specific options to GLIB_LIBS.
    	* contib/Makefile.am: Added the contents of freebsd-contrib to
    	  EXTRA_DIST
    	* contrib/freebsd-packaging/syslog-ng.conf.example: Added example
    	  config file.
    	* contrib/freebsd-packaging/syslog-ng.rc.d: Added rc.d
    	  file(/etc/init.d for you SysV types:)
    	* tgzbuild/configure_opts: Added --bindir options to install loggen
    	  to its proper place.
    	* tgzbuild/postbuild: Added FreeBSD specific postinst stuff. Added
    	  loggen to Linux's strip.
    	* src/affile.c: Moved O_LARGEFILE declaration to syslog-ng.h
    	* src/afsql.c: Added #include <string.h>.
    	* src/syslog-ng.h: Moved O_LARGEFILE declaration here.
    	* src/afuser.c: Includes util.h ig getutent missing on the system.
  • Loading branch information
bazsi committed Apr 7, 2008
1 parent 6c21294 commit eed3565
Show file tree
Hide file tree
Showing 10 changed files with 214 additions and 8 deletions.
13 changes: 12 additions & 1 deletion configure.in
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,11 @@ AM_PROG_LEX
AC_PROG_MAKE_SET
AC_PROG_RANLIB

AC_SYS_LARGEFILE
dnl ***************************************************************************
dnl How to do static linking?
dnl ***************************************************************************

AC_MSG_CHECKING(how to enable static linking for certain libraries)
ldversion=`ld -V 2>&1 | head -1`
ostype=`uname -s`
Expand Down Expand Up @@ -333,6 +338,12 @@ AM_PATH_GLIB_2_0($GLIB_MIN_VERSION,,
AC_MSG_ERROR(Cannot find GLib library version >= $GLIB_MIN_VERSION: is pkg-config in path?), $GLIB_ADDONS)


case "$ostype" in
FreeBSD)
GLIB_LIBS="$GLIB_LIBS -lintl"
;;
esac

old_LIBS=$LIBS
LIBS="$LD_START_STATIC $GLIB_LIBS $LD_END_STATIC"

Expand Down Expand Up @@ -413,7 +424,7 @@ patheval()
{
OLD=$1
NEW=`eval echo $1`
while /usr/bin/test "x$OLD" != "x$NEW"
while test "x$OLD" != "x$NEW"
do
OLD=$NEW
NEW=`eval echo $OLD`
Expand Down
4 changes: 3 additions & 1 deletion contrib/Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -20,4 +20,6 @@ EXTRA_DIST = README init.d.solaris init.d.HP-UX init.d.RedHat init.d.SuSE \
cygwin-packaging/syslog-ng-config \
solaris-packaging/solaris10_install.txt \
solaris-packaging/syslog-ng.example.xml \
solaris-packaging/syslog-ng.method
solaris-packaging/syslog-ng.method \
freebsd-packaging/syslog-ng.rc.d \
freebsd-packaging/syslog-ng.conf.example
110 changes: 110 additions & 0 deletions contrib/freebsd-packaging/syslog-ng.conf.example
Original file line number Diff line number Diff line change
@@ -0,0 +1,110 @@
# defauld syslogd config converted from freebsd 6.1

options { dir_perm(0755); perm(0644);
chain_hostnames(no);
keep_hostname(yes);
};

# Default local source.
source local {
unix-dgram("/var/run/log");
unix-dgram("/var/run/logpriv" perm(0600));
file("/dev/klog");
udp(ip(0.0.0.0) port(514));
internal();
};

# FILTERS: START
# Filter LEGO bricks to build your castle :)
# syslog level filters
filter f_crit_emerg { level(crit..emerg); };
filter f_err_emerg { level(err..emerg); };
filter f_warn_emerg { level(warning..emerg); };
filter f_debug_emerg { level(debug..emerg); };
filter f_notice_emerg { level(notice..emerg); };
filter f_info_emerg { level(info..emerg); };
filter f_info { level(info); };
filter f_not_authpriv { not facility(authpriv); };
filter f_debug { level(debug); };
filter f_emerg { level(emerg); };

# Facility filters
filter f_mail { facility(mail); };
filter f_kern { facility(kern); };
filter f_auth { facility(auth); };
filter f_lpr { facility(lpr); };
filter f_news { facility(news); };
filter f_kern { facility(kern); };
filter f_security { facility(security); };
filter f_auth{ facility(auth); };
filter f_authpriv { facility(authpriv); };
filter f_ftp { facility(ftp); };
filter f_cron { facility(cron); };

# program filters
filter f_startslip { program("startslip"); };
filter f_ppp { program("ppp"); };
## FILTERS: END

# DESTINATIONS: START
destination d_devconsole { file("/dev/console" create_dirs(yes)); };
destination d_messages { file("/var/log/messages" create_dirs(yes)); };
destination d_maillog { file("/var/log/maillog" create_dirs(yes)); };
destination d_security { file("/var/log/security" create_dirs(yes)); };
destination d_authlog { file("/var/log/auth.log" create_dirs(yes)); };
destination d_ldperr { file("/var/log/lpd-errs" create_dirs(yes)); };
destination d_xferlog { file("/var/log/xferlog" create_dirs(yes)); };
destination d_cron { file("/var/log/cron" create_dirs(yes)); };
destination d_debuglog { file("/var/log/debug.log" create_dirs(yes)); };
destination d_usertty { usertty("*"); };
destination d_slip { file("/var/log/slip.log" create_dirs(yes)); };
destination d_ppp { file("/var/log/ppp.log" create_dirs(yes)); };
# DESTINATIONS: END

# LOGS: START
# *.err;kern.warning;auth.notice;mail.crit /dev/console
log { source(local); filter(f_mail); filter(f_crit_emerg); destination(d_devconsole); };
log { source(local); filter(f_err_emerg); destination(d_devconsole); };
log { source(local); filter(f_kern); filter(f_warn_emerg); destination(d_devconsole); };
log { source(local); filter(f_auth); filter(f_notice_emerg); destination(d_devconsole); };

# *.notice;authpriv.none;kern.debug;lpr.info;mail.crit;news.err /var/log/messages
log { source(local); filter(f_notice_emerg); filter(f_not_authpriv); destination(d_messages); };
log { source(local); filter(f_lpr); filter(f_info); destination(d_messages); };
log { source(local); filter(f_mail); filter(f_crit_emerg); destination(d_messages); };
log { source(local); filter(f_news); filter(f_err_emerg); destination(d_messages); };
log { source(local); filter(f_kern); filter(f_debug_emerg); destination(d_messages); };

# mail.info /var/log/maillog
log { source(local); filter(f_mail); filter(f_info_emerg); destination(d_maillog); };

## security.* /var/log/security
log { source(local); filter(f_security); filter(f_debug_emerg); destination(d_security); };

# auth.info;authpriv.info /var/log/auth.log
log { source(local); filter(f_auth); filter(f_info_emerg); destination(d_authlog); };
log { source(local); filter(f_authpriv); filter(f_info_emerg); destination(d_authlog); };

# lpr.info /var/log/lpd-errs
log { source(local); filter(f_lpr); filter(f_info); destination(d_ldperr); };

# ftp.info /var/log/xferlog
log { source(local); filter(f_ftp); filter(f_info_emerg); destination(d_xferlog); };

# cron.* /var/log/cron
log { source(local); filter(f_cron); filter(f_debug_emerg); destination(d_cron); };

## *.=debug /var/log/debug.log
log { source(local); filter(f_debug); destination(d_debuglog); };

## *.emerg *
log { source(local); filter(f_emerg); destination(d_usertty); };

# !starslip
# *.* /var/log/slip.log
log { source(local); filter(f_startslip); destination(d_slip); };

# !ppp
# *.* /var/log/ppp.log
log { source(local); filter(f_ppp); destination(d_ppp); };
# LOGS: END
66 changes: 66 additions & 0 deletions contrib/freebsd-packaging/syslog-ng.rc.d
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
#!/bin/sh

# startup script for FreeBSD 6.x.
# Written by Tamas Pal <[email protected]>

# PROVIDE: syslogd
# REQUIRE: mountcritremote cleanvar newsyslog
# BEFORE: SERVERS

# Enabling syslog-ng:
# * copy this script to /etc/rc.d or /usr/local/etc/rc.d
# * Edit /etc/rc.conf and add the following lines:
# ----- CUT HERE -----
# syslogd_enable="NO"
# syslogng_enable="YES"
# syslogng_flags=""
# ----- CUT HERE -----
# * Add your extra flags to syslogng_flags EXCEPT the -p <pidfile> and -f
# <conffile> flags. These are added automatically by this script. To set
# their value, change the value of the conf_file and pidfile variables below

. "/etc/rc.subr"

name="syslogng"

rcvar=`set_rcvar`
pidfile="/var/run/syslog-ng.pid"

## CONFIG OPTIONS: START
# modify them according to your environment.
installdir="/opt/syslog-ng"
localstatedir="${installdir}/var"
libpath="${installdir}/lib"
conf_file="${installdir}/etc/syslog-ng.conf"
## CONFIG OPTIONS: END

command="${installdir}/sbin/syslog-ng"
required_files="$conf_file"

start_precmd="syslog_ng_precmd"
extra_commands="reload"

LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$libpath
export LD_LIBRARY_PATH

syslog_ng_precmd() {
if [ ! -d ${localstatedir} ]; then
mkdir -p ${localstatedir}
fi

if [ ! -L /dev/log ]; then
ln -s /var/run/log /dev/log
fi
}

load_rc_config "$name"

case $1 in
start)
syslogng_flags=" -p ${pidfile} -f ${conf_file} ${syslog_ng_flags}"
;;
esac

run_rc_command "$1"

# vim: ft=sh
4 changes: 0 additions & 4 deletions src/affile.c
Original file line number Diff line number Diff line change
Expand Up @@ -35,10 +35,6 @@
#include <time.h>
#include <stdlib.h>

#if !HAVE_O_LARGEFILE
#define O_LARGEFILE 0
#endif

static gboolean
affile_open_file(gchar *name, int flags,
int uid, int gid, int mode,
Expand Down
1 change: 1 addition & 0 deletions src/afsql.c
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
#include "apphook.h"

#include <dbi/dbi.h>
#include <string.h>

typedef struct _AFSqlField
{
Expand Down
4 changes: 4 additions & 0 deletions src/afuser.c
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,10 @@
#include <fcntl.h>
#include <unistd.h>

#ifndef HAVE_GETUTENT
#include "utils.h"
#endif

typedef struct _AFUserDestDriver
{
LogDriver super;
Expand Down
3 changes: 3 additions & 0 deletions src/syslog-ng.h
Original file line number Diff line number Diff line change
Expand Up @@ -63,5 +63,8 @@
# endif
#endif

#if !HAVE_O_LARGEFILE
#define O_LARGEFILE 0
#endif

#endif
2 changes: 1 addition & 1 deletion tgzbuild/configure_opts
Original file line number Diff line number Diff line change
@@ -1 +1 @@
--sysconfdir /opt/syslog-ng/etc --localstatedir=/opt/syslog-ng/var --mandir /opt/syslog-ng/man --sbindir=/opt/syslog-ng/sbin/ --enable-ssl
--sysconfdir /opt/syslog-ng/etc --localstatedir=/opt/syslog-ng/var --mandir /opt/syslog-ng/man --bindir=/opt/syslog-ng/bin/ --sbindir=/opt/syslog-ng/sbin/ --enable-ssl
15 changes: 14 additions & 1 deletion tgzbuild/postbuild
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ case "$ostype" in
mv $1/syslog-ng $1/opt
;;
Linux)
strip $1/syslog-ng/sbin/syslog-ng
strip $1/syslog-ng/sbin/syslog-ng $1/syslog-ng/bin/loggen
mkdir -p $1/syslog-ng/var
mkdir -p $1/syslog-ng/etc
mkdir -p $1/syslog-ng/doc
Expand All @@ -33,9 +33,22 @@ case "$ostype" in
tar xfz doc/reference/syslog-ng.html.tar.gz -C $1/syslog-ng/doc
chown -R root.root $1/syslog-ng/doc
;;
FreeBSD)
strip $1/syslog-ng/sbin/syslog-ng $1/syslog-ng/bin/loggen
mkdir -p $1/syslog-ng/var $1/syslog-ng/etc $1/syslog-ng/doc
cp NEWS $1/syslog-ng/doc
mkdir -p $1/syslog-ng/doc/contrib
cp contrib/freebsd-packaging/syslog-ng.rc.d $1/syslog-ng/doc
cp contrib/freebsd-packaging/syslog-ng.conf.example $1/syslog-ng/etc

gzip -c -9 doc/reference/syslog-ng.txt > $1/syslog-ng/doc/syslog-ng.txt.gz
tar xfz doc/reference/syslog-ng.html.tar.gz -C $1/syslog-ng/doc
chown -R root:wheel $1/syslog-ng/doc
;;
*)

;;
esac

exit 0
# vim: ts=2 et

0 comments on commit eed3565

Please sign in to comment.