Skip to content

Commit

Permalink
Add dnsdist user when installing RPMs
Browse files Browse the repository at this point in the history
  • Loading branch information
pieterlexis committed Apr 18, 2016
1 parent 533aca9 commit bab5401
Show file tree
Hide file tree
Showing 2 changed files with 40 additions and 3 deletions.
39 changes: 37 additions & 2 deletions build-scripts/build-dnsdist-rpm
Expand Up @@ -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 \'

Expand Down Expand Up @@ -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
Expand All @@ -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
Expand Down
4 changes: 3 additions & 1 deletion pdns/dnsdistdist/contrib/dnsdist.init.centos6
Expand Up @@ -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
Expand All @@ -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
Expand Down

0 comments on commit bab5401

Please sign in to comment.