From: Pieter Lexis Date: Mon, 16 Jan 2017 11:37:13 +0000 (+0100) Subject: Refuse to start with chroot set in a systemd env X-Git-Tag: rec-4.1.0-alpha1~277^2 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=refs%2Fpull%2F4912%2Fhead;p=thirdparty%2Fpdns.git Refuse to start with chroot set in a systemd env Closes #4848 --- diff --git a/docs/markdown/authoritative/settings.md b/docs/markdown/authoritative/settings.md index bf5bef67d6..c49f1ab9d0 100644 --- a/docs/markdown/authoritative/settings.md +++ b/docs/markdown/authoritative/settings.md @@ -142,6 +142,9 @@ When setting `chroot`, all other paths in the config (except for [`config-dir`](#config-dir) and [`module-dir`](#module-dir)) set in the configuration are relative to the new root. +When running on a system where systemd manages services, `chroot` does not work out of the box, as PowerDNS cannot use the `NOTIFY_SOCKET`. +Either don't `chroot` on these systems or set the 'Type' of the this service to 'simple' instead of 'notify' (refer to the systemd documentation on how to modify unit-files) + ## `config-dir` * Path diff --git a/docs/markdown/recursor/settings.md b/docs/markdown/recursor/settings.md index 95f4b57aa5..5e242458f0 100644 --- a/docs/markdown/recursor/settings.md +++ b/docs/markdown/recursor/settings.md @@ -129,6 +129,9 @@ in the configuration are relative to the new root. When using `chroot` and the API ([`webserver`](#webserver)), [`api-readonly`](#api-readonly) must be set and [`api-config-dir`](#api-config-dir) unset. +When running on a system where systemd manages services, `chroot` does not work out of the box, as PowerDNS cannot use the `NOTIFY_SOCKET`. +Either do not `chroot` on these systems or set the 'Type' of this service to 'simple' instead of 'notify' (refer to the systemd documentation on how to modify unit-files) + ## `client-tcp-timeout` * Integer * Default: 2 diff --git a/pdns/common_startup.cc b/pdns/common_startup.cc index 66f06fcdcb..13b7860ff7 100644 --- a/pdns/common_startup.cc +++ b/pdns/common_startup.cc @@ -498,6 +498,14 @@ void mainthread() stubParseResolveConf(); if(!::arg()["chroot"].empty()) { +#ifdef HAVE_SYSTEMD + char *ns; + ns = getenv("NOTIFY_SOCKET"); + if (ns != nullptr) { + L<