From: Otto Moerbeek Date: Fri, 10 Jan 2020 11:30:37 +0000 (+0100) Subject: Give an explcit messsage if something is wrong with socket-dir. X-Git-Tag: rec-4.3.0-rc1~6^2~1 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=1153fe0c05488432750762263de7ababb5a6d38e;p=thirdparty%2Fpdns.git Give an explcit messsage if something is wrong with socket-dir. (cherry picked from commit 0127f6bdccd1a694c5441e914eaa5550ec6d6e0b) --- diff --git a/pdns/pdns_recursor.cc b/pdns/pdns_recursor.cc index 5e7374d8c1..5f1a2a2183 100644 --- a/pdns/pdns_recursor.cc +++ b/pdns/pdns_recursor.cc @@ -3812,6 +3812,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); @@ -4214,6 +4235,8 @@ static int serviceMain(int argc, char*argv[]) g_log<