From: Pieter Lexis Date: Wed, 13 Apr 2016 08:04:01 +0000 (+0200) Subject: Add dnsdist user when installing RPMs X-Git-Tag: dnsdist-1.0.0~3^2~1 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=bab5401008a8e2f788623af52202e4c82977aa1a;p=thirdparty%2Fpdns.git Add dnsdist user when installing RPMs --- diff --git a/build-scripts/build-dnsdist-rpm b/build-scripts/build-dnsdist-rpm index c50fc8220f..71b87577bc 100755 --- a/build-scripts/build-dnsdist-rpm +++ b/build-scripts/build-dnsdist-rpm @@ -40,8 +40,7 @@ SODIUM_CONFIGURE='' # Some RPM platforms use systemd, others sysv, we default to systemd here INIT_BUILDREQUIRES='BuildRequires: systemd-devel' -#INIT_INSTALL='install -d -m 755 %{buildroot}/lib/systemd/system/ && install -m 664 dnsdist.service %{buildroot}/lib/systemd/system/dnsdist.service' -INIT_INSTALL='' +INIT_INSTALL='sed -i "s!/dnsdist!/dnsdist -u dnsdist -g dnsdist!" %{buildroot}/lib/systemd/system/dnsdist.service' INIT_FILES='/lib/systemd/system/dnsdist.service' INIT_CONFIGURE='--enable-systemd --with-systemd=/lib/systemd/system \' @@ -89,6 +88,7 @@ License: GPLv2 Vendor: PowerDNS.COM BV Group: System/DNS Source: dnsdist-${TARBALLVERSION}.tar.bz2 +Requires(pre): shadow-utils BuildRequires: readline-devel BuildRequires: boost-devel BuildRequires: lua-devel @@ -115,6 +115,41 @@ install -d %{buildroot}/%{_sysconfdir}/dnsdist ${INIT_INSTALL} ${DEFAULTS_INSTALL} +%pre +getent group dnsdist >/dev/null || groupadd -r dnsdist +getent passwd dnsdist >/dev/null || \ + useradd -r -g dnsdist -d / -s /sbin/nologin \ + -c "dnsdist user" dnsdist +exit 0 + + +%post +%if 0%{?el6} +/sbin/chkconfig --add %{name} +%else +%systemd_post %{name}.service +%endif + +%preun +%if 0%{?el6} +if [ "\$1" -eq "0" ]; then + # Package removal, not upgrade + /sbin/service %{name} stop > /dev/null 2>&1 || : + /sbin/chkconfig --del %{name} +fi +%else +%systemd_preun %{name}.service +%endif + +%postun +%if 0%{?el6} +if [ "\$1" -ge "1" ] ; then + /sbin/service %{name} condrestart >/dev/null 2>&1 || : +fi +%else +%systemd_postun_with_restart %{name}.service +%endif + %files %{!?_licensedir:%global license %%doc} %license COPYING diff --git a/pdns/dnsdistdist/contrib/dnsdist.init.centos6 b/pdns/dnsdistdist/contrib/dnsdist.init.centos6 index 071fa0b35a..ebd8ce0218 100644 --- a/pdns/dnsdistdist/contrib/dnsdist.init.centos6 +++ b/pdns/dnsdistdist/contrib/dnsdist.init.centos6 @@ -17,6 +17,8 @@ PROG=dnsdist DNSDIST=/usr/bin/${PROG} PIDFILE=/var/run/${PROG}.pid +DNSDIST_USER='dnsdist' +DNSDIST_GROUP='dnsdist' DNSDIST_OPTIONS="" if [ -f /etc/default/${PROG} ]; then @@ -31,7 +33,7 @@ RETVAL=0 do_start() { echo -n "Starting ${PROG}..." - daemon --pidfile=${PIDFILE} $DNSDIST -d -p ${PIDFILE} ${DNSDIST_OPTIONS} + daemon --pidfile=${PIDFILE} $DNSDIST -u ${DNSDIST_USER} -g ${DNSDIST_GROUP} -d -p ${PIDFILE} ${DNSDIST_OPTIONS} ret=$? echo return $ret