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: auth-4.3.0-beta1~28^2~1 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=0127f6bdccd1a694c5441e914eaa5550ec6d6e0b;p=thirdparty%2Fpdns.git Give an explcit messsage if something is wrong with socket-dir. --- 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<