From 191f2e478b42a30440443b1e19eddc0a3135fc0c Mon Sep 17 00:00:00 2001 From: bert hubert Date: Thu, 17 Sep 2015 16:33:04 +0200 Subject: [PATCH] implement pid-file configuration switch, defaults to on & document it. Close #2671. --- docs/markdown/authoritative/settings.md | 6 ++++++ docs/markdown/recursor/settings.md | 6 ++++++ pdns/common_startup.cc | 1 + pdns/pdns_recursor.cc | 3 +++ pdns/receiver.cc | 3 +++ 5 files changed, 19 insertions(+) diff --git a/docs/markdown/authoritative/settings.md b/docs/markdown/authoritative/settings.md index 932d3b786..b96901550 100644 --- a/docs/markdown/authoritative/settings.md +++ b/docs/markdown/authoritative/settings.md @@ -787,3 +787,9 @@ The port where webserver to listen on. See ["Performance Monitoring"](../common/ * Default: no If the webserver should print arguments. See ["Performance Monitoring"](../common/logging.md#performance-monitoring). + +## `write-pid` +* Boolean +* Default: yes + +If a PID file should be written. Available since 4.0. diff --git a/docs/markdown/recursor/settings.md b/docs/markdown/recursor/settings.md index ec02ddfec..8e6225d15 100644 --- a/docs/markdown/recursor/settings.md +++ b/docs/markdown/recursor/settings.md @@ -617,3 +617,9 @@ recursor is installed on a system. Available since version 3.1.5. By default, PowerDNS replies to the 'version.bind' query with its version number. Security conscious users may wish to override the reply PowerDNS issues. + +## `write-pid` +* Boolean +* Default: yes + +If a PID file should be written. Available since 4.0. diff --git a/pdns/common_startup.cc b/pdns/common_startup.cc index c510e28a0..89d45d471 100644 --- a/pdns/common_startup.cc +++ b/pdns/common_startup.cc @@ -54,6 +54,7 @@ void declareArguments() { ::arg().set("local-port","The port on which we listen")="53"; ::arg().setSwitch("experimental-dnsupdate","Enable/Disable DNS update (RFC2136) support. Default is no.")="no"; + ::arg().setSwitch("write-pid","Write a PID file")="yes"; ::arg().set("allow-dnsupdate-from","A global setting to allow DNS updates from these IP ranges.")="127.0.0.0/8,::1"; ::arg().setSwitch("forward-dnsupdate","A global setting to allow DNS update packages that are for a Slave domain, to be forwarded to the master.")="yes"; ::arg().setSwitch("log-dns-details","If PDNS should log DNS non-erroneous details")="no"; diff --git a/pdns/pdns_recursor.cc b/pdns/pdns_recursor.cc index c981885dc..a822fc132 100644 --- a/pdns/pdns_recursor.cc +++ b/pdns/pdns_recursor.cc @@ -470,6 +470,8 @@ int arecvfrom(char *data, int len, int flags, const ComboAddress& fromaddr, int string s_pidfname; static void writePid(void) { + if(!::arg().mustDo("write-pid")) + return; ofstream of(s_pidfname.c_str(), std::ios_base::app); if(of) of<< Utility::getpid() <