]> git.ipfire.org Git - thirdparty/pdns.git/commitdiff
rec: Ensure control socket can be created when running in systemd
authorPieter Lexis <pieter.lexis@powerdns.com>
Thu, 6 Jun 2019 12:44:44 +0000 (14:44 +0200)
committerPieter Lexis <pieter.lexis@powerdns.com>
Fri, 7 Jun 2019 08:57:06 +0000 (10:57 +0200)
This moves the default of the socket-dir to /var/run/pdns-recursor.

builder-support/debian/recursor/debian-buster/pdns-recursor.init
builder-support/debian/recursor/debian-jessie/pdns-recursor.init
builder-support/debian/recursor/debian-stretch/pdns-recursor.init
builder-support/debian/recursor/ubuntu-trusty/pdns-recursor.init
builder-support/specs/pdns-recursor.init
pdns/pdns_recursor.cc
pdns/rec_control.cc
pdns/recursordist/pdns-recursor.service.in

index 63390cf4489fb0676a70485a68e2063fce0c10f8..61fc03220d4e5294a130d3bf59d7df0891c78ff7 100644 (file)
@@ -30,7 +30,7 @@ DAEMON=/usr/sbin/$NAME
 # Derive the socket-dir setting from /etc/powerdns/recursor.conf
 # or fall back to the default /var/run 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; mkdir -p $PIDDIR; fi
 PIDFILE=$PIDDIR/$NAME.pid
 
 # Gracefully exit if the package has been removed.
index 63390cf4489fb0676a70485a68e2063fce0c10f8..61fc03220d4e5294a130d3bf59d7df0891c78ff7 100644 (file)
@@ -30,7 +30,7 @@ DAEMON=/usr/sbin/$NAME
 # Derive the socket-dir setting from /etc/powerdns/recursor.conf
 # or fall back to the default /var/run 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; mkdir -p $PIDDIR; fi
 PIDFILE=$PIDDIR/$NAME.pid
 
 # Gracefully exit if the package has been removed.
index 63390cf4489fb0676a70485a68e2063fce0c10f8..61fc03220d4e5294a130d3bf59d7df0891c78ff7 100644 (file)
@@ -30,7 +30,7 @@ DAEMON=/usr/sbin/$NAME
 # Derive the socket-dir setting from /etc/powerdns/recursor.conf
 # or fall back to the default /var/run 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; mkdir -p $PIDDIR; fi
 PIDFILE=$PIDDIR/$NAME.pid
 
 # Gracefully exit if the package has been removed.
index 63390cf4489fb0676a70485a68e2063fce0c10f8..61fc03220d4e5294a130d3bf59d7df0891c78ff7 100644 (file)
@@ -30,7 +30,7 @@ DAEMON=/usr/sbin/$NAME
 # Derive the socket-dir setting from /etc/powerdns/recursor.conf
 # or fall back to the default /var/run 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; mkdir -p $PIDDIR; fi
 PIDFILE=$PIDDIR/$NAME.pid
 
 # Gracefully exit if the package has been removed.
index 0e0214cb70523989f0c19b7e9d148ad4bfbc194b..f787ae3f2b3cb4c8b9534152b40192882b270838 100644 (file)
@@ -18,8 +18,7 @@
 RETVAL=0
 
 PIDDIR=$(awk -F= '/^socket-dir=/ {print $2}' /etc/pdns-recursor/recursor.conf)
-if [ -z "$PIDDIR" ]; then PIDDIR=/var/run; fi
-mkdir -p "$PIDDIR"
+if [ -z "$PIDDIR" ]; then PIDDIR=/var/run; mkdir -p $PIDDIR; fi
 
 start() {
        echo -n $"Starting pdns-recursor: "
index 491ae26bd95d34a0c4e3a5c62b2130bd90c0e4cc..82d4de2fb3e1725318a3281a719929598e9d25c3 100644 (file)
@@ -4439,7 +4439,7 @@ int main(int argc, char **argv)
     ::arg().set("socket-group","Group of socket")="";
     ::arg().set("socket-mode", "Permissions for socket")="";
 
-    ::arg().set("socket-dir",string("Where the controlsocket will live, ")+LOCALSTATEDIR+" when unset and not chrooted" )="";
+    ::arg().set("socket-dir",string("Where the controlsocket will live, ")+LOCALSTATEDIR+"/pdns-recursor when unset and not chrooted" )="";
     ::arg().set("delegation-only","Which domains we only accept delegations from")="";
     ::arg().set("query-local-address","Source IP address for sending queries")="0.0.0.0";
     ::arg().set("query-local-address6","Source IPv6 address for sending queries. IF UNSET, IPv6 WILL NOT BE USED FOR OUTGOING QUERIES")="";
@@ -4593,7 +4593,7 @@ int main(int argc, char **argv)
 
     if (::arg()["socket-dir"].empty()) {
       if (::arg()["chroot"].empty())
-        ::arg().set("socket-dir") = LOCALSTATEDIR;
+        ::arg().set("socket-dir") = std::string(LOCALSTATEDIR) + "/pdns-recursor";
       else
         ::arg().set("socket-dir") = "/";
     }
index 56f6776c36140649bfb886358b7eaa34b5019ed1..cf5bbecf82d59abe1e6503f541473ce1ec2dac6a 100644 (file)
@@ -39,7 +39,7 @@ static void initArguments(int argc, char** argv)
 {
   arg().set("config-dir","Location of configuration directory (recursor.conf)")=SYSCONFDIR;
 
-  arg().set("socket-dir",string("Where the controlsocket will live, ")+LOCALSTATEDIR+" when unset and not chrooted" )="";
+  arg().set("socket-dir",string("Where the controlsocket will live, ")+LOCALSTATEDIR+"/pdns-recursor when unset and not chrooted" )="";
   arg().set("chroot","switch to chroot jail")="";
   arg().set("process","When controlling multiple recursors, the target process number")="";
   arg().set("timeout", "Number of seconds to wait for the recursor to respond")="5";
@@ -72,7 +72,7 @@ static void initArguments(int argc, char** argv)
 
   if (::arg()["socket-dir"].empty()) {
     if (::arg()["chroot"].empty())
-      ::arg().set("socket-dir") = LOCALSTATEDIR;
+      ::arg().set("socket-dir") = std::string(LOCALSTATEDIR) + "/pdns-recursor";
     else
       ::arg().set("socket-dir") = ::arg()["chroot"] + "/";
   } else if (!::arg()["chroot"].empty()) {
index ce9472c7678c812077633ee1436f893361effe42..b17cb59ef3c74867687e6b7524c22fa951eac825 100644 (file)
@@ -13,6 +13,7 @@ Group=@service_group@
 Type=notify
 Restart=on-failure
 StartLimitInterval=0
+RuntimeDirectory=pdns-recursor
 
 # Tuning
 LimitNOFILE=16384