File ulogd.spec of Package ulogd

#
# spec file for package ulogd (Version 1.24)
#
# Copyright (c) 2009 SUSE LINUX Products GmbH, Nuernberg, Germany.
#
# All modifications and additions to the file contributed by third parties
# remain the property of their copyright owners, unless otherwise agreed
# upon. The license for this file, and modifications and additions to the
# file, is the same license as for the pristine package itself (unless the
# license for the pristine package is not an Open Source License, in which
# case the license is the MIT License). An "Open Source License" is a
# license that conforms to the Open Source Definition (Version 1.9)
# published by the Open Source Initiative.

# Please submit bugfixes or comments via http://bugs.opensuse.org/
#

# norootforbuild


Name:           ulogd
%if 0%{?suse_version} >= 1100
BuildRequires:  libmysqlclient-devel sqlite3-devel
%else
BuildRequires:  mysql-devel sqlite-devel
%endif
BuildRequires:  libpcap-devel postgresql-devel
%define ulogd_user ulogd
%define ulogd_group ulogd
%define apparmor_policy_dir %{_sysconfdir}/apparmor.d
Version:        1.24
Release:        138
License:        GPL v2 or later
Summary:        Netfilter ULOG target log daemon
Group:          System/Daemons
AutoReqProv:    on
Requires:       logrotate
Url:            http://www.netfilter.org/projects/ulogd/
Source0:        http://ftp.netfilter.org/pub/ulogd/%{name}-%{version}.tar.bz2
Source1:        http://ftp.netfilter.org/pub/ulogd/%{name}-%{version}.tar.bz2.sig
Source2:        ulogd.a4.pdf
Source3:        ulogd.init
Source4:        ulogd.logrotate
Source5:        ulogd.apparmor
Patch1:         %{name}-%{version}-build.dif
Patch2:         %{name}-%{version}-config.dif
Patch3:         %{name}-%{version}-mysql-table.dif
Patch4:         %{name}-%{version}-pgsql-table.dif
Patch5:         %{name}-%{version}-sqlite3-table.dif
Patch6:         %{name}-%{version}-fixes-base.dif
Patch7:         %{name}-%{version}-fixes-mysql.dif
Patch8:         %{name}-%{version}-fixes-pgsql.dif
Patch9:         %{name}-%{version}-fixes-sqlite3.dif
Patch10:        %{name}-%{version}-fixes-pcap.dif
Patch11:        %{name}-%{version}-user-option.dif
Patch12:        %{name}-%{version}-bnc420313.dif
BuildRoot:      %{_tmppath}/%{name}-%{version}-build
PreReq:         %insserv_prereq %fillup_prereq /usr/sbin/useradd /usr/sbin/groupadd /usr/sbin/usermod

%package sqlite
License:        GPL v2 or later
Summary:        SQLite output plugin for ulogd
Requires:       ulogd
Group:          System/Daemons

%package mysql
License:        GPL v2 or later
Summary:        MySQL output plugin for ulogd
Requires:       ulogd
Group:          System/Daemons

%package pgsql
License:        GPL v2 or later
Summary:        PostgreSQL output plugin for ulogd
Requires:       ulogd
Group:          System/Daemons

%package pcap
License:        GPL v2 or later
Summary:        PCAP output plugin for ulogd
Requires:       ulogd
Group:          System/Daemons

%package -n libipulog-devel
License:        GPL v2 or later
Summary:        Netfilter ULOG target library
Group:          Development/Libraries/Other

%description
Ulogd is an universal logging daemon for the ULOG target of netfilter,
the Linux 2.4/2.6 firewalling subsystem. Ulogd is able to log packets
in various formats to different targets (text files, databases, etc..).
It has an easy-to-use plugin interface to add new protocols and new
output targets.



Authors:
--------
    Harald Welte <laforge@gnumonks.org>

%description sqlite
ulogd-sqlite is a output plugin for ulogd. It enables logging of
firewall information into a SQLite database.



Authors:
--------
    Harald Welte <laforge@gnumonks.org>

%description mysql
ulogd-mysql is a output plugin for ulogd. It enables logging of
firewall information into a MySQL database.



Authors:
--------
    Harald Welte <laforge@gnumonks.org>

%description pgsql
Ulogd-pgsql is a output plugin for ulogd. It enables logging of
firewall information into a PostgreSQL database.



Authors:
--------
    Harald Welte <laforge@gnumonks.org>

%description pcap
Ulogd-pcap is a output plugin for ulogd. It enables logging of firewall
information to pcap-style files (like tcpdump).



Authors:
--------
    Harald Welte <laforge@gnumonks.org>

%description -n libipulog-devel
Libipulog is a little library which provides a convenient way to
receive netfilter ULOG target log messages.



Authors:
--------
    Harald Welte <laforge@gnumonks.org>

%prep
%setup -q
cp -a doc/pgsql.table   doc/pgsql.table.ipaddr-as-string
cp -a doc/sqlite3.table doc/sqlite3.table.ipaddr-as-string
%patch1 -p0
%patch2 -p0
%patch3 -p0
%patch4 -p0
%patch5 -p0
%patch6 -p0
%patch7 -p0
%patch8 -p0
%patch9 -p0
%patch10 -p0
%patch11 -p0
%patch12 -p0

%build
autoconf
export CFLAGS="$RPM_OPT_FLAGS -fPIC"
%configure \
	--with-sqlite3=%{_prefix} \
	--with-mysql=%{_prefix} \
	--with-pgsql=%{_prefix} \
	--with-mysql-log-ip-as-string \
	--with-pgsql-log-ip-as-string \
	--with-sqlite3-log-ip-as-string
make
rm -f ulogd
export CFLAGS="$RPM_OPT_FLAGS -fPIE"
export LDFLAGS="-pie"
make ulogd

%install
install -d -m0755 %{buildroot}/%{_sysconfdir}/logrotate.d
install -d -m0755 %{buildroot}/%{_sysconfdir}/init.d
install -d -m0755 %{buildroot}/%{_includedir}/libipulog
install -d -m0755 %{buildroot}/%{_sbindir}/sbin
install -d -m0755 %{buildroot}/%{_libdir}/ulogd
install -d -m0755 %{buildroot}/%{_localstatedir}/lib/ulogd
install -d -m0755 %{buildroot}/%{_localstatedir}/log/ulogd
install -d -m0755 %{buildroot}/%{apparmor_policy_dir}
make DESTDIR=%{buildroot} install
#
install -m0754 $RPM_SOURCE_DIR/ulogd.init \
               %{buildroot}/%{_sysconfdir}/init.d/ulogd
ln -sf         %{_sysconfdir}/init.d/ulogd \
               %{buildroot}/%{_sbindir}/rculogd
install -m0644 $RPM_SOURCE_DIR/ulogd.logrotate \
               %{buildroot}/%{_sysconfdir}/logrotate.d/ulogd
install -m0644 libipulog/include/libipulog/libipulog.h \
               %{buildroot}/%{_includedir}/libipulog/libipulog.h
install -m0644 libipulog/libipulog.a \
               %{buildroot}/%{_libdir}/libipulog.a
install -m0644 $RPM_SOURCE_DIR/ulogd.apparmor \
               %{buildroot}/%{apparmor_policy_dir}/usr.sbin.ulogd

%clean
rm -rf %{buildroot}

%pre
%if %{?ulogd_group:1}0
/usr/sbin/groupadd -r %{ulogd_group} 2> /dev/null || :
%endif
%if %{?ulogd_user:1}0
/usr/sbin/useradd -r %{?ulogd_group:-g %ulogd_group}%{!?ulogd_group:-g nogroup} -s /bin/false -c "ulog daemon" -d /var/lib/ulog %ulogd_user 2> /dev/null ||:
/usr/sbin/usermod -s /bin/false -d /var/lib/ulog %ulogd_user 2> /dev/null ||:
%endif

%post
%{fillup_and_insserv -f ulogd}

%preun
%stop_on_removal ulogd

%postun
%restart_on_update ulogd
%{insserv_cleanup}

%files
%defattr(-,root,root)
%attr(0755,root,root) %{_sbindir}/ulogd
%attr(0755,root,root) %{_sbindir}/rculogd
%if %{?ulogd_user:1}0
%if %{?ulogd_group:1}0
%attr(0640,root,%ulogd_group) %config(noreplace) %{_sysconfdir}/ulogd.conf
%else
%attr(0640,%ulogd_user,root) %config(noreplace) %{_sysconfdir}/ulogd.conf
%endif
%else
%attr(0640,root,root) %config(noreplace) %{_sysconfdir}/ulogd.conf
%endif
%config(noreplace) %{_sysconfdir}/logrotate.d/ulogd
%dir %{apparmor_policy_dir}
%config(noreplace) %{apparmor_policy_dir}/usr.sbin.ulogd
%dir %{_libdir}/ulogd
%{_libdir}/ulogd/ulogd_BASE.so
%{_libdir}/ulogd/ulogd_LOCAL.so
%{_libdir}/ulogd/ulogd_LOGEMU.so
%{_libdir}/ulogd/ulogd_OPRINT.so
%{_libdir}/ulogd/ulogd_PWSNIFF.so
%{_libdir}/ulogd/ulogd_SYSLOG.so
%{_sysconfdir}/init.d/ulogd
%dir %{_localstatedir}/lib/ulogd
%if %{?ulogd_user:1}0
%attr(0750,%{ulogd_user},%{?ulogd_group}%{!?ulogd_group:root}) %dir %{_localstatedir}/log/ulogd
%else
%dir %{_localstatedir}/log/ulogd
%endif
%doc COPYING AUTHORS README ulogd.conf
%doc doc/ulogd.txt $RPM_SOURCE_DIR/ulogd.a4.pdf doc/ulogd.html
%doc doc/sqlite3.table
%doc doc/mysql.table
%doc doc/pgsql.table
%doc doc/sqlite3.table.ipaddr-as-string
%doc doc/mysql.table.ipaddr-as-string
%doc doc/pgsql.table.ipaddr-as-string

%files sqlite
%defattr(-,root,root)
%{_libdir}/ulogd/ulogd_SQLITE3.so

%files mysql
%defattr(-,root,root)
%{_libdir}/ulogd/ulogd_MYSQL.so

%files pgsql
%defattr(-,root,root)
%{_libdir}/ulogd/ulogd_PGSQL.so

%files pcap
%defattr(-,root,root)
%{_libdir}/ulogd/ulogd_PCAP.so

%files -n libipulog-devel
%defattr(-,root,root)
%doc libipulog/ulog_test.c
%{_libdir}/libipulog.a
%{_includedir}/libipulog

%changelog
* Tue Jan 27 2009 mt@suse.de
- Fixed log file owner/group in logrotate file (bnc#468419).
* Tue Aug 26 2008 mt@suse.de
- Added -L,-l filter as workaround to db lib lists (bnc#420313).
- Added logrotate to rpm requires for ulogd [rpmlint]
- Added $remote_fs to Required-Start/Stop in init script [rpmlint]
- Updated Copyright/License statements in spec and init script
- Adopted BuildRequires to use current db devel package names
- Removed explicit db requires from plugin packages; rpm is able
  to find the dependencies itself [rpmlint]
- Renamed libipulog package to libipulog-devel - it provides a
  static library only [rpmlint].
* Thu Jul 26 2007 prusnak@suse.cz
- changed libpcap to libpcap-devel in BuildRequires
* Sun Jun 10 2007 ro@suse.de
- remove requires for mysql-shared from ulogd-mysql
  (requirement for library is done automatically anyway)
* Fri Jun 01 2007 mt@suse.de
- Fixed to use -pie for ulogd only, not for plugins
* Thu May 31 2007 mt@suse.de
- Updated to ulogd 1.24, providing several bugfixes, like and
  off-by-one-column fix in sqlite3 plugin, pcap header fix for
  some architectures, memory leak fix for postgresql plugin,
  reconnect support for mysql plugin, ...
- Merged build related changes from into ulogd-1.24-build.dif.
  Obsolete patches: ulogd-1.23.dif, ulogd-1.23-lib64.dif
  New patch file: ulogd-1.24-build.dif
- Splitted ulogd-1.23-strfix.dif into separate files.
  New patches: ulogd-1.24-fixes-{base,mysql,pgsql,sqlite3}.dif,
- Added sync option fix for the pcap plugin.
  New patch: ulogd-1.24-fixes-pcap.dif
- Changed to compile with --with-*-log-ip-as-string, implemented
  fallback support for old db formats. Prepared the psql,sqlite3
  sql scripts. New patches: ulogd-1.24-{pgsql,sqlite3}-table.dif
- Fixed mysql.table.ipaddr-as-string sql script; no default value
  for id is allowed when also auto_increment is set.
  New patch file: ulogd-1.24-mysql-table.dif
- Implemented an global "user" option allowing to set the user
  to run as in the config file. Adopted spec, config and logrotate
  file to run as ulogd user and store log in /var/log/ulogd/.
  New patch file: ulogd-1.24-user-option.dif
- Added apparmor policy for ulogd - enabled by default.
* Wed Jan 10 2007 mt@suse.de
- Bug #229970: fixed several string length calculations
  New patch file: ulogd-1.23-strfix.dif
- Fixed _init / _fini functions to reset the dbh pointer on
  initialization failures, added checks if stmt/dbh pointer
  are initialized in output functions. Changed to run _fini
  functions before the log file is closed, because they may
  log (eg. the sqlite3 plugin).
  New patch file: ulogd-1.23-cleanup.dif
- Changed to use more usefull default path in ulogd.conf.in
  New patch file: ulogd-1.23-config.dif
* Thu Jun 22 2006 ro@suse.de
- remove selfprovides
* Tue May 02 2006 mt@suse.de
- Bug #155647: fixed ip column format in doc/pgsql.table
  to match the compiled in type.
  New patch file: ulogd-1.23-pgsql-table.dif
* Wed Jan 25 2006 mls@suse.de
- converted neededforbuild to BuildRequires
* Wed Jul 27 2005 mt@suse.de
- updated to ulogd-1.23, adopted patches
- added logrotate file, fixed init script
- added sqlite (sqlite3) plugin sub-package
* Fri Apr 29 2005 mt@suse.de
- updated to ulogd-1.21, adopted patches
* Tue Aug 31 2004 ro@suse.de
- added directory to filelist
* Tue Aug 31 2004 ro@suse.de
- fix lib64 issue in configure
* Thu May 27 2004 mt@suse.de
- initial package
openSUSE Build Service is sponsored by