changeset 370:5380552644e2

RHEL7 systemd and /var/run on tmpfs
author Carl Byington <carl@five-ten-sg.com>
date Tue, 07 Feb 2017 18:09:52 -0800
parents f15c694c31d2
children df7dc6b2b153
files ChangeLog Makefile.am NEWS configure.in dnsbl-tmpfs.conf dnsbl.service.rc dnsbl.spec.in
diffstat 7 files changed, 99 insertions(+), 25 deletions(-) [+]
line wrap: on
line diff
--- a/ChangeLog	Tue Jan 17 14:13:41 2017 -0800
+++ b/ChangeLog	Tue Feb 07 18:09:52 2017 -0800
@@ -1,3 +1,6 @@
+6.49 2017-02-07
+    RHEL7 systemd and /var/run on tmpfs.
+
 6.48 2016-12-17
     Add dkim white/black listing
 
--- a/Makefile.am	Tue Jan 17 14:13:41 2017 -0800
+++ b/Makefile.am	Tue Feb 07 18:09:52 2017 -0800
@@ -2,18 +2,23 @@
 
 SUBDIRS = src man html info
 hackdir = $(sysconfdir)/dnsbl
-hack_SCRIPTS = dnsbl
+hack_SCRIPTS = dnsbl dnsbl.service dnsbl-tmpfs.conf
 hack_DATA = dnsbl.conf hosts-ignore.conf html-tags.conf tld.conf dnsblnogrey
 htmldir = ${datadir}/doc/@PACKAGE@-@VERSION@
 html_DATA = AUTHORS COPYING ChangeLog NEWS README
-CLEANFILES = dnsbl xml/dnsbl xml/Makefile
-EXTRA_DIST = $(hack_DATA) dnsbl.spec make-tld-conf.py xml/header.sgml xml/header.xml xml/Makefile.am xml/Makefile.in xml/dnsbl.in
+CLEANFILES = dnsbl dnsbl.service dnsbl-tmpfs.conf xml/dnsbl xml/Makefile
+EXTRA_DIST = dnsbl-tmpfs.conf dnsbl.rc dnsbl.service.rc $(hack_DATA) dnsbl.spec make-tld-conf.py xml/header.sgml xml/header.xml xml/Makefile.am xml/Makefile.in xml/dnsbl.in
 
 dnsbl: dnsbl.rc
 	   cat dnsbl.rc                         | \
 	       sed -e "s,SBINDIR,$(sbindir),g"  | \
 	       sed -e "s,SYSCONFDIR,$(sysconfdir),g" >dnsbl
 
+dnsbl.service: dnsbl.service.rc
+	   cat dnsbl.service.rc                 | \
+	       sed -e "s,SBINDIR,$(sbindir),g"  | \
+	       sed -e "s,SYSCONFDIR,$(sysconfdir),g" >dnsbl.service
+
 chkconfig: dnsbl
 	   /usr/bin/getent passwd dnsbl >/dev/null || /usr/sbin/useradd -r -d $(sysconfdir)/dnsbl -M -c "dnsbl pseudo-user" -s /sbin/nologin dnsbl >/dev/null
 	   mv -f $(sysconfdir)/dnsbl/dnsbl /etc/rc.d/init.d
--- a/NEWS	Tue Jan 17 14:13:41 2017 -0800
+++ b/NEWS	Tue Feb 07 18:09:52 2017 -0800
@@ -1,3 +1,4 @@
+6.49 2017-02-07 RHEL7 systemd and /var/run on tmpfs
 6.48 2016-12-17 Add dkim white/black listing
 6.47 2016-09-21 Better smtp verify logging
 6.46 2016-09-19 Enable smtp verify logging
--- a/configure.in	Tue Jan 17 14:13:41 2017 -0800
+++ b/configure.in	Tue Feb 07 18:09:52 2017 -0800
@@ -1,6 +1,6 @@
 
 AC_PREREQ(2.59)
-AC_INIT(dnsbl,6.48,carl@five-ten-sg.com)
+AC_INIT(dnsbl,6.49,carl@five-ten-sg.com)
 AC_CONFIG_SRCDIR([config.h.in])
 AC_CONFIG_HEADER([config.h])
 AC_CONFIG_MACRO_DIR([m4])
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dnsbl-tmpfs.conf	Tue Feb 07 18:09:52 2017 -0800
@@ -0,0 +1,1 @@
+d	/var/run/dnsbl 	750 dnsbl root
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dnsbl.service.rc	Tue Feb 07 18:09:52 2017 -0800
@@ -0,0 +1,17 @@
+[Unit]
+Description = Sendmail milter for spam control
+Wants = sendmail.service
+After = syslog.target
+After = local-fs.target
+After = network.target
+Before = sendmail.service
+
+[Service]
+Type = forking
+UMask = 0022
+User = dnsbl
+WorkingDirectory = SYSCONFDIR/dnsbl
+ExecStart = SBINDIR/dnsbl -d 10 -b /var/dcc/dccifd -r /var/run/dnsbl/dnsbl.resolver.sock -p local:/var/run/dnsbl/dnsbl.sock
+
+[Install]
+WantedBy = multi-user.target
--- a/dnsbl.spec.in	Tue Jan 17 14:13:41 2017 -0800
+++ b/dnsbl.spec.in	Tue Feb 07 18:09:52 2017 -0800
@@ -17,15 +17,22 @@
 Requires(post,preun):   /sbin/service
 BuildRequires:          sendmail-devel >= 8.12.1
 BuildRequires:          glibc-devel
-%if 0%{?fedora} >= 14
-BuildRequires:          glibc-static
-%endif
-%if 0%{?el6}
+%if "%{?dist}" == ".el6"
 BuildRequires:          glibc-static
 %endif
 Requires:               sendmail >= 8.12.1
 Requires:               sendmail-cf
 Requires:               spamassassin
+%if "%{?dist}" == ".el7"
+Requires(pre):  systemd-sysv, shadow-utils
+Requires(post): systemd-units
+Requires(preun):  systemd-units
+Requires(postun): systemd-units
+Requires:       coreutils
+Requires:       systemd-units
+BuildRequires:  systemd-units
+BuildRequires:  glibc-static
+%endif
 
 
 %description
@@ -57,13 +64,24 @@
 make %{?_smp_mflags}
 
 %install
-rm -rf $RPM_BUILD_ROOT
-make DESTDIR=$RPM_BUILD_ROOT install
-mkdir -p $RPM_BUILD_ROOT/etc/rc.d/init.d
-mv -f $RPM_BUILD_ROOT%{_sysconfdir}/%{name}/%{name} $RPM_BUILD_ROOT/etc/rc.d/init.d
-mkdir -p $RPM_BUILD_ROOT/var/run/%{name}
-mkdir -p $RPM_BUILD_ROOT%{_sysconfdir}/%{name}/autowhite
-mkdir -p $RPM_BUILD_ROOT%{_sysconfdir}/%{name}/.spamassassin
+rm -rf %{buildroot}
+make DESTDIR=%{buildroot} install
+mkdir -p %{buildroot}%{_sysconfdir}/%{name}/autowhite
+mkdir -p %{buildroot}%{_sysconfdir}/%{name}/.spamassassin
+%if "%{?dist}" == ".el7"
+install -m 644 -D %{buildroot}%{_sysconfdir}/%{name}/%{name}.service \
+    %{buildroot}%{_unitdir}/%{name}.service
+install -m 755 -d %{buildroot}%{_prefix}/lib/tmpfiles.d
+install -m 644    %{buildroot}%{_sysconfdir}/%{name}/%{name}-tmpfs.conf \
+    %{buildroot}%{_prefix}/lib/tmpfiles.d/%{name}.conf
+%else
+install -m 755 -D %{buildroot}%{_sysconfdir}/%{name}/%{name} \
+    %{buildroot}%{_initrddir}/%{name}
+%endif
+mkdir -p %{buildroot}/var/run/%{name}
+rm -f  %{buildroot}%{_sysconfdir}/%{name}/%{name}
+rm -f  %{buildroot}%{_sysconfdir}/%{name}/%{name}.service
+rm -f  %{buildroot}%{_sysconfdir}/%{name}/%{name}-tmpfs.conf
 
 
 %pre
@@ -71,23 +89,44 @@
 
 
 %post
+if [ $1 = 1 ]; then
+    # initial install
+%if "%{?dist}" == ".el7"
+    /bin/systemctl daemon-reload &>/dev/null || :
+%else
 /sbin/chkconfig --add %{name}
+%endif
 echo Remember to edit %{_sysconfdir}/%{name}/%{name}.conf and add the following line to your sendmail.mc:
 echo "INPUT_MAIL_FILTER(\`dnsbl', \`S=local:/var/run/dnsbl/dnsbl.sock, F=T, T=C:30s;S:5m;R:5m;E:5m')"
 echo
-
+fi
 
 %preun
-[ $1 = 0 ] && /sbin/service %{name} stop    || :
-[ $1 = 0 ] && /sbin/chkconfig --del %{name} || :
+if [ $1 = 0 ]; then
+    # package removal, not upgrade
+%if "%{?dist}" == ".el7"
+    /bin/systemctl --no-reload disable %{name}.service &>/dev/null || :
+    /bin/systemctl stop %{name}.service &>/dev/null || :
+%else
+    /sbin/service %{name} stop || :
+    /sbin/chkconfig --del %{name}
+%endif
+fi
 
 
 %postun
-[ $1 = 0 ] && userdel %{name} || :
+if [ $1 -ge 1 ]; then
+    # package upgrade, not uninstall
+%if "%{?dist}" == ".el7"
+    /bin/systemctl try-restart %{name}.service &>/dev/null || :
+%else
+    /sbin/service %{name} restart || :
+%endif
+fi
 
 
 %clean
-rm -rf $RPM_BUILD_ROOT
+rm -rf %{buildroot}
 
 
 %files
@@ -98,11 +137,19 @@
 %docdir %{_datadir}/doc/%{name}-%{version}
 %{_datadir}/doc/%{name}-%{version}
 %config(noreplace) %attr(0750,%{name},root) %{_sysconfdir}/%{name}
-/etc/rc.d/init.d/%{name}
+%if "%{?dist}" == ".el7"
+%{_prefix}/lib/tmpfiles.d/%{name}.conf
+%{_unitdir}/%{name}.service
+%else
+%{_initrddir}/%{name}
+%endif
 %dir %attr(0750,%{name},root) /var/run/%{name}
 
 
 %changelog
+* Tue Feb 07 2017 Carl Byington <carl@five-ten-sg.com> - 6.49-1
+- RHEL7 systemd and /var/run is on tmpfs
+
 * Tue Dec 20 2016 Carl Byington <carl@five-ten-sg.com> - 6.48-1
 - allow dkim whitelisting.