Control: tags -1 moreinfo

Hi Matija,

could you please test the attached refreshed script and report if it
works as expected for your use case?

Lorenzo

Attachment: pdns-recursor
Description: Binary data

--- pdns-recursor-sysv	2024-03-25 10:29:15.941311479 +0100
+++ pdns-recursor	2024-03-26 11:05:37.467659608 +0100
@@ -12,7 +12,7 @@
 #
 # Authors:	Matthijs Möhlmann <matth...@cacholong.nl>
 #           Christoph Haas <h...@debian.org>
-# 
+#
 # Thanks to:
 # Thomas Hood <jdth...@aglu.demon.nl>
 #
@@ -27,15 +27,21 @@
 DESC="PowerDNS Recursor"
 NAME=pdns_recursor
 DAEMON=/usr/sbin/$NAME
+PDNS_USER=pdns
 # Derive the socket-dir setting from /etc/powerdns/recursor.conf
-# or fall back to the default /var/run if not specified there.
+# or fall back to the default /var/run/pdns-recursor if not specified there.
 PIDDIR=$(awk -F= '/^socket-dir=/ {print $2}' /etc/powerdns/recursor.conf)
-if [ -z "$PIDDIR" ]; then PIDDIR=/var/run; fi
+if [ -z "$PIDDIR" ]; then PIDDIR=/var/run/pdns-recursor; fi
 PIDFILE=$PIDDIR/$NAME.pid
 
+#create sockedir
+install --owner=$PDNS_USER --group=$PDNS_USER -d $PIDDIR
+
 # Gracefully exit if the package has been removed.
 test -x $DAEMON || exit 0
 
+ulimit -n 16384
+
 # Read config file if it is present.
 if [ -r /etc/default/pdns-recursor ]; then
   . /etc/default/pdns-recursor
@@ -46,7 +52,8 @@
 #  0 if daemon has been started / was already running
 #  >0 if daemon could not be started
   start-stop-daemon --start --oknodo --quiet --pidfile $PIDFILE --exec $DAEMON --test > /dev/null || return 0
-  start-stop-daemon --start --oknodo --quiet --pidfile $PIDFILE --exec $DAEMON -- --daemon=yes || return 2
+  start-stop-daemon --start --oknodo --quiet --pidfile $PIDFILE --exec $DAEMON -- \
+    --daemon --setuid=$PDNS_USER --setgid=$PDNS_USER 2>/dev/null || return 2
 }
 
 start_resolvconf() {
@@ -62,7 +69,7 @@
 #  1 if daemon was already stopped
 #  2 if daemon could not be stopped
 #  other if a failure occured
-  start-stop-daemon --stop --quiet --pidfile $PIDFILE --name $NAME
+  start-stop-daemon --stop --quiet --pidfile $PIDFILE --name $NAME --user $PDNS_USER
   RETVAL="$?"
   [ "$RETVAL" = 2 ] && return 2
   rm -f $PIDFILE
@@ -84,10 +91,6 @@
 
 case "$1" in
   start)
-    if [ "$START" != "yes" ]; then
-      echo "Not starting $DESC -- disabled."
-      exit 0
-    fi
     echo -n "Starting $DESC: $NAME ..."
     start
     case "$?" in
@@ -126,10 +129,6 @@
     esac
   ;;
   restart|force-reload)
-    if [ "$START" != "yes" ]; then
-      $0 stop
-      exit 0
-    fi
     echo -n "Restarting $DESC ..."
     stop
     case "$?" in
@@ -172,5 +171,3 @@
 esac
 
 exit 0
-
-

Reply via email to