From 0127f6bdccd1a694c5441e914eaa5550ec6d6e0b Mon Sep 17 00:00:00 2001 From: Otto Moerbeek Date: Fri, 10 Jan 2020 12:30:37 +0100 Subject: [PATCH] Give an explcit messsage if something is wrong with socket-dir. --- pdns/pdns_recursor.cc | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/pdns/pdns_recursor.cc b/pdns/pdns_recursor.cc index f5935938d2..55a7f43e1b 100644 --- a/pdns/pdns_recursor.cc +++ b/pdns/pdns_recursor.cc @@ -3809,6 +3809,27 @@ static void setupNODGlobal() } #endif /* NOD_ENABLED */ +static void checkDir(void) +{ + struct stat st; + string dir(::arg()["socket-dir"]); + string msg; + + if (stat(dir.c_str(), &st) == -1) { + msg = "it does not exist or cannot access"; + } + else if (!S_ISDIR(st.st_mode)) { + msg = "it is not a directory"; + } + else if (access(dir.c_str(), R_OK | W_OK | X_OK) != 0) { + msg = "cannot read, write or search"; + } else { + return; + } + g_log << Logger::Error << "Problem with socket directory " << dir << ": " << msg << "; see https://docs.powerdns.com/recursor/upgrade.html#x-to-4-3-0-or-master" << endl; + _exit(1); +} + static int serviceMain(int argc, char*argv[]) { g_log.setName(s_programname); @@ -4211,6 +4232,8 @@ static int serviceMain(int argc, char*argv[]) g_log<