File dcc.spec of Package dcc

#
# spec file for package dcc
#
# Copyright (c) 2024 SUSE LLC
#
# 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 https://bugs.opensuse.org/
#


%define    nag_plugins %{_usr}/lib/nagios/plugins
%define    nrpe_cfg    %{_sysconfdir}/nagios/nrpe.cfg
%define    dcc_tmp     %{_var}/run/dcc.map
%if 0%{?suse_version} < 1600
%bcond_without nagios
%else
%bcond_with nagios
%endif
Name:           dcc
Version:        2.3.169
Release:        0
Summary:        Distributed Checksum Clearinghouse
License:        SUSE-Permissive
Group:          Productivity/Networking/Email/Utilities
URL:            https://www.dcc-servers.net/dcc
Source:         https://www.dcc-servers.net/src/dcc/dcc.tar.Z#/%{name}-%{version}.tar.Z
Source2:        cleanDCC.cron
Source3:        dcc-apache2.conf
Source4:        dcc_conf.mod
Source5:        dcc-nagios.cron
Source6:        %{name}.sysusers
Source7:        dccifd.service
Source8:        dccifd.sysconfig
Source9:        dcc-cleanup.service
Source10:       dcc-cleanup.timer
BuildRequires:  sysuser-tools
Requires:       group(vscan)
Requires:       user(vscan)
%sysusers_requires

%description
The DCC or Distributed Checksum Clearinghouse is an anti-spam content filter
that runs on a variety of operating systems. As of mid-2006, it involves
millions of users, tens of thousands of clients and more than 250 servers
collecting and counting checksums related to more than 300 million mail
messages on week days. The counts can be used by SMTP servers and mail user
agents to detect and reject or filter spam or unsolicited bulk mail. DCC
servers exchange or "flood" common checksums. The checksums include values that
are constant across common variations in bulk messages, including
"personalizations."

The idea of the DCC is that if mail recipients could compare the mail they
receive, they could recognize unsolicited bulk mail. A DCC server totals
reports of checksums of messages from clients and answers queries about the
total counts for checksums of mail messages. A DCC client reports the checksums
for a mail message to a server and is told the total number of recipients of
mail with each checksum. If one of the totals is higher than a threshold set by
the client and according to local whitelists the message is unsolicited, the
DCC client can log, discard, or reject the message.

%package www
Summary:        DCC Webinterface
Group:          Productivity/Networking/Email/Utilities
Requires:       %{name} = %{version}
Requires:       apache
Requires:       apache2-mod_perl

%description www
This package contains the webinterface for users to configure their
DCC settings.

%if %{with nagios}
%package nagios
Summary:        DCC Nagios plugin
Group:          Productivity/Networking/Email/Utilities
Requires:       %{name} = %{version}
Requires:       cron
Requires:       nagios-plugins

%description nagios
This package contains a nagios plugin which monitors the dccifd service.
%endif

%package server
Summary:        DCC server components
Group:          Productivity/Networking/Email/Utilities
Requires:       %{name} = %{version}

%description server
Server components (dbclean, dccd) for DCC (Distributed Checksum Clearinghouse).

%prep
%autosetup

%build
./configure --disable-dccm \
            --bindir=%{_bindir} \
            --disable-sys-inst \
            --homedir=%{_sharedstatedir}/dcc \
            --libexecdir=%{_libexecdir}/%{name} \
            --mandir=%{_mandir} \
            --with-cgibin=/srv/www/dcc/cgi-bin \
            --with-installroot=%{buildroot} \
            --with-rundir=/run/dcc
%make_build OPTIMIZE='%{optflags}'

%sysusers_generate_pre %{SOURCE6} %{name}


%install
%make_install
install -d -m755 %{buildroot}/%{_sbindir}
install -Dm755 %{SOURCE2} %{buildroot}/%{_libexecdir}/dcc/dcc-cleanup
%if %{with nagios}
install -Dm755 %{SOURCE5} %{buildroot}/%{_sysconfdir}/cron.d/dcc-nagios
install -d -m755 %{buildroot}/%{nag_plugins}
ln -sf %{_libexecdir}/dcc/dcc-nagios %{buildroot}/%{nag_plugins}/check_dcc
%endif
install -Dm644 %{SOURCE3} %{buildroot}/%{_sysconfdir}/apache2/conf.d/dcc-include.conf
touch %{buildroot}/%{_sysconfdir}/apache2/dcc-webusers
install -d -m755 %{buildroot}/%{_mandir}/man8
install -m644 *.8 %{buildroot}/%{_mandir}/man8/
sed -i -f %{SOURCE4} %{buildroot}%{_sharedstatedir}/dcc/dcc_conf
install -Dm644 %{SOURCE6} %{buildroot}%{_sysusersdir}/%{name}-user.conf
install -d %{buildroot}%{_unitdir}
sed s?__LIBEXECDIR__?%{_libexecdir}? %{SOURCE7} > %{buildroot}%{_unitdir}/dccifd.service
ln -s %{_sbindir}/service %{buildroot}%{_sbindir}/rcdccifd
install -d %{buildroot}%{_localstatedir}/log
ln -s %{_sharedstatedir}/dcc/log %{buildroot}%{_localstatedir}/log/dcc
install -Dm644 %{SOURCE8} %{buildroot}%{_fillupdir}/sysconfig.dccifd
sed s?__LIBEXECDIR__?%{_libexecdir}? %{SOURCE9} > %{buildroot}%{_unitdir}/dcc-cleanup.service
install -m644 %{SOURCE10} %{buildroot}%{_unitdir}
ln -s %{_sbindir}/service %{buildroot}%{_sbindir}/rcdcc-cleanup


%pre -f %{name}.pre
%service_add_pre dccifd.service dcc-cleanup.service dcc-cleanup.timer

%post
%{fillup_only -n dccifd}
%service_add_post dccifd.service dcc-cleanup.service dcc-cleanup.timer

%if %{with nagios}
%post nagios
if [ -w %{nrpe_cfg} ] && [ $1 -eq 1 ]; then
   echo "debug: check_dcc in nrpe.cfg eingetragen"
   echo "command[check_dcc]=%{nag_plugins}/check_dcc -m %{dcc_tmp}" >> %{nrpe_cfg}
fi
%endif

%preun
%service_del_preun dccifd.service dcc-cleanup.service dcc-cleanup.timer

%postun
%service_del_postun dccifd.service dcc-cleanup.service dcc-cleanup.timer

%if %{with nagios}
%postun nagios
if [ -w %{nrpe_cfg} ] && [ $1 -eq 0 ]; then  # Package uninstall
   echo "debug: check_dcc aus nrpe.cfg entfernt."
   sed -i -e '/^command\[check_dcc\]=/d' %{nrpe_cfg}
fi
if [ -f %{dcc_tmp} ]; then
   rm -rf %{dcc_tmp}
fi
%endif

%files
%{_mandir}/man8/*.8%{?ext_man}
%license LICENSE
%doc CHANGES
%{_sbindir}/rcdccifd
%{_sbindir}/rcdcc-cleanup
%{_bindir}/cdcc
%{_bindir}/dccif-test
%{_bindir}/dccproc
%defattr(-,vscan,root)
%dir %{_sharedstatedir}/dcc
%dir %{_sharedstatedir}/dcc/log
%{_localstatedir}/log/dcc
%{_libexecdir}/dcc
%exclude %{_libexecdir}/dcc/dbclean
%exclude %{_libexecdir}/dcc/dccd
%config %{_sharedstatedir}/dcc/map.txt
%config(noreplace) %{_sharedstatedir}/dcc/map
%config(noreplace) %{_sharedstatedir}/dcc/dcc_conf
%config(noreplace) %{_sharedstatedir}/dcc/whiteclnt
%config(noreplace) %{_sharedstatedir}/dcc/whitecommon
%config(noreplace) %{_sharedstatedir}/dcc/whitelist
%config(noreplace) %{_sharedstatedir}/dcc/grey_flod
%config(noreplace) %{_sharedstatedir}/dcc/grey_whitelist
%config(noreplace) %{_sharedstatedir}/dcc/flod
%config(noreplace) %{_sharedstatedir}/dcc/ids
%{_sysusersdir}/%{name}-user.conf
%{_unitdir}/dccifd.service
%{_fillupdir}/sysconfig.dccifd
%{_unitdir}/dcc-cleanup.service
%{_unitdir}/dcc-cleanup.timer

%files www
%dir %{_sysconfdir}/apache2
%dir %{_sysconfdir}/apache2/conf.d
%dir /srv/www
%dir /srv/www/dcc
%dir /srv/www/dcc/cgi-bin
%config(noreplace) %{_sysconfdir}/apache2/conf.d/dcc-include.conf
%ghost %attr(0640,root,root) %config(noreplace) %{_sysconfdir}/apache2/dcc-webusers
%attr(0644,root,root) /srv/www/dcc/cgi-bin/*

%if %{with nagios}
%files nagios
%dir /%{_usr}/lib/nagios
%dir /%{_usr}/lib/nagios/plugins
%{nag_plugins}/check_dcc
%attr(644,root,root) %config %{_sysconfdir}/cron.d/dcc-nagios
%endif

%files server
%{_libexecdir}/dcc/dbclean
%{_libexecdir}/dcc/dccd

%changelog
openSUSE Build Service is sponsored by