From 75336810381e4cdc25d0beab7c19abb910cea3ab Mon Sep 17 00:00:00 2001 From: Pieter Lexis Date: Mon, 16 Jan 2017 12:37:13 +0100 Subject: [PATCH] Refuse to start with chroot set in a systemd env Closes #4848 --- docs/markdown/authoritative/settings.md | 3 +++ docs/markdown/recursor/settings.md | 3 +++ pdns/common_startup.cc | 8 ++++++++ pdns/pdns_recursor.cc | 8 ++++++++ 4 files changed, 22 insertions(+) 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<