From: Remi Gacogne Date: Mon, 14 Aug 2023 10:15:53 +0000 (+0200) Subject: ixfrdist: Call `getpwuid()` before going multi-threaded X-Git-Tag: rec-5.0.0-alpha1~62^2~1 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=b862ecc96e67e581aded6b08af6f3930978ee7b7;p=thirdparty%2Fpdns.git ixfrdist: Call `getpwuid()` before going multi-threaded --- diff --git a/pdns/ixfrdist.cc b/pdns/ixfrdist.cc index bab9120539..d5fb195354 100644 --- a/pdns/ixfrdist.cc +++ b/pdns/ixfrdist.cc @@ -1186,6 +1186,7 @@ struct IXFRDistConfiguration ComboAddress wsAddr; std::string wsLogLevel{"normal"}; std::string workDir; + const struct passwd* userInfo{nullptr}; uint32_t axfrMaxRecords{0}; uint16_t keep{0}; uint16_t axfrTimeout{0}; @@ -1386,6 +1387,8 @@ static std::optional parseConfiguration(int argc, char** } else { configuration.uid = pw->pw_uid; } + //NOLINTNEXTLINE(concurrency-mt-unsafe): only one thread at this point + configuration.userInfo = getpwuid(configuration.uid); } } @@ -1475,14 +1478,13 @@ int main(int argc, char** argv) { g_log<uid<<": "<uid); - if (pw == nullptr) { + if (configuration->userInfo == nullptr) { if (setgroups(0, nullptr) < 0) { g_log<pw_name, configuration->gid) < 0) { + if (initgroups(configuration->userInfo->pw_name, configuration->gid) < 0) { g_log<