From: Pieter Lexis Date: Thu, 6 Jun 2019 12:44:44 +0000 (+0200) Subject: rec: Ensure control socket can be created when running in systemd X-Git-Tag: dnsdist-1.4.0-rc1~110^2~1 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=0524add91a67c73bd91f439a19913238f95e6d86;p=thirdparty%2Fpdns.git rec: Ensure control socket can be created when running in systemd This moves the default of the socket-dir to /var/run/pdns-recursor. --- diff --git a/builder-support/debian/recursor/debian-buster/pdns-recursor.init b/builder-support/debian/recursor/debian-buster/pdns-recursor.init index 63390cf448..61fc03220d 100644 --- a/builder-support/debian/recursor/debian-buster/pdns-recursor.init +++ b/builder-support/debian/recursor/debian-buster/pdns-recursor.init @@ -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. diff --git a/builder-support/debian/recursor/debian-jessie/pdns-recursor.init b/builder-support/debian/recursor/debian-jessie/pdns-recursor.init index 63390cf448..61fc03220d 100644 --- a/builder-support/debian/recursor/debian-jessie/pdns-recursor.init +++ b/builder-support/debian/recursor/debian-jessie/pdns-recursor.init @@ -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. diff --git a/builder-support/debian/recursor/debian-stretch/pdns-recursor.init b/builder-support/debian/recursor/debian-stretch/pdns-recursor.init index 63390cf448..61fc03220d 100644 --- a/builder-support/debian/recursor/debian-stretch/pdns-recursor.init +++ b/builder-support/debian/recursor/debian-stretch/pdns-recursor.init @@ -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. diff --git a/builder-support/debian/recursor/ubuntu-trusty/pdns-recursor.init b/builder-support/debian/recursor/ubuntu-trusty/pdns-recursor.init index 63390cf448..61fc03220d 100644 --- a/builder-support/debian/recursor/ubuntu-trusty/pdns-recursor.init +++ b/builder-support/debian/recursor/ubuntu-trusty/pdns-recursor.init @@ -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. diff --git a/builder-support/specs/pdns-recursor.init b/builder-support/specs/pdns-recursor.init index 0e0214cb70..f787ae3f2b 100644 --- a/builder-support/specs/pdns-recursor.init +++ b/builder-support/specs/pdns-recursor.init @@ -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: " diff --git a/pdns/pdns_recursor.cc b/pdns/pdns_recursor.cc index 491ae26bd9..82d4de2fb3 100644 --- a/pdns/pdns_recursor.cc +++ b/pdns/pdns_recursor.cc @@ -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") = "/"; } diff --git a/pdns/rec_control.cc b/pdns/rec_control.cc index 56f6776c36..cf5bbecf82 100644 --- a/pdns/rec_control.cc +++ b/pdns/rec_control.cc @@ -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()) { diff --git a/pdns/recursordist/pdns-recursor.service.in b/pdns/recursordist/pdns-recursor.service.in index ce9472c767..b17cb59ef3 100644 --- a/pdns/recursordist/pdns-recursor.service.in +++ b/pdns/recursordist/pdns-recursor.service.in @@ -13,6 +13,7 @@ Group=@service_group@ Type=notify Restart=on-failure StartLimitInterval=0 +RuntimeDirectory=pdns-recursor # Tuning LimitNOFILE=16384