throw PDNSException("dnssec-keydir " + getArg("dnssec-keydir") + " does not exist");
}
d_dnssec = true;
- dirHandle.reset();
}
if (s_rc == 0) { // first instance gets to open everything
initialize();
return;
}
- auto dirp = std::unique_ptr<DIR, decltype(&closedir)>(opendir(dirname.c_str()), closedir);
std::vector<std::string> files;
- if (!dirp) {
- errlog("Error opening the included directory %s!", dirname.c_str());
- g_outputBuffer = "Error opening the included directory " + dirname + "!";
- return;
- }
-
- struct dirent* ent = nullptr;
- // NOLINTNEXTLINE(concurrency-mt-unsafe): readdir is thread-safe nowadays and readdir_r is deprecated
- while ((ent = readdir(dirp.get())) != nullptr) {
- // NOLINTNEXTLINE(cppcoreguidelines-pro-bounds-array-to-pointer-decay): this is what dirent is
- if (ent->d_name[0] == '.') {
- continue;
+ {
+ auto dirHandle = std::unique_ptr<DIR, decltype(&closedir)>(opendir(dirname.c_str()), closedir);
+ if (!dirHandle) {
+ errlog("Error opening the included directory %s!", dirname.c_str());
+ g_outputBuffer = "Error opening the included directory " + dirname + "!";
+ return;
}
- if (boost::ends_with(ent->d_name, ".conf")) {
- std::ostringstream namebuf;
- namebuf << dirname << "/" << ent->d_name;
-
- if (stat(namebuf.str().c_str(), &st) || !S_ISREG(st.st_mode)) {
+ struct dirent* ent = nullptr;
+ // NOLINTNEXTLINE(concurrency-mt-unsafe): readdir is thread-safe nowadays and readdir_r is deprecated
+ while ((ent = readdir(dirHandle.get())) != nullptr) {
+ // NOLINTNEXTLINE(cppcoreguidelines-pro-bounds-array-to-pointer-decay): this is what dirent is
+ if (ent->d_name[0] == '.') {
continue;
}
- files.push_back(namebuf.str());
+ if (boost::ends_with(ent->d_name, ".conf")) {
+ std::ostringstream namebuf;
+ namebuf << dirname << "/" << ent->d_name;
+
+ if (stat(namebuf.str().c_str(), &st) || !S_ISREG(st.st_mode)) {
+ continue;
+ }
+
+ files.push_back(namebuf.str());
+ }
}
}
- dirp.reset();
std::sort(files.begin(), files.end());
g_included = true;
/missing
/testrunner
/dnsdist
+/fuzz_target_dnsdistcache
/*.pb.cc
/*.pb.h
/dnsdist.service
static void cleanUpDomain(const DNSName& domain, const uint16_t& keep, const string& workdir) {
string dir = workdir + "/" + domain.toString();
- auto dirHandle = std::unique_ptr<DIR, decltype(&closedir)>(opendir(dir.c_str()), closedir);
- if (!dirHandle) {
- return;
- }
vector<uint32_t> zoneVersions;
- struct dirent* entry = nullptr;
- // NOLINTNEXTLINE(concurrency-mt-unsafe): readdir is thread-safe nowadays and readdir_r is deprecated
- while ((entry = readdir(dirHandle.get())) != nullptr) {
- // NOLINTNEXTLINE(cppcoreguidelines-pro-bounds-array-to-pointer-decay): this is what dirent is
- if (strcmp(entry->d_name, ".") == 0 || strcmp(entry->d_name, "..") == 0) {
- continue;
+ {
+ auto dirHandle = std::unique_ptr<DIR, decltype(&closedir)>(opendir(dir.c_str()), closedir);
+ if (!dirHandle) {
+ return;
+ }
+
+ struct dirent* entry = nullptr;
+ // NOLINTNEXTLINE(concurrency-mt-unsafe): readdir is thread-safe nowadays and readdir_r is deprecated
+ while ((entry = readdir(dirHandle.get())) != nullptr) {
+ // NOLINTNEXTLINE(cppcoreguidelines-pro-bounds-array-to-pointer-decay): this is what dirent is
+ if (strcmp(entry->d_name, ".") == 0 || strcmp(entry->d_name, "..") == 0) {
+ continue;
+ }
+ // NOLINTNEXTLINE(cppcoreguidelines-pro-bounds-array-to-pointer-decay): this is what dirent is
+ zoneVersions.push_back(std::stoi(entry->d_name));
}
- // NOLINTNEXTLINE(cppcoreguidelines-pro-bounds-array-to-pointer-decay): this is what dirent is
- zoneVersions.push_back(std::stoi(entry->d_name));
}
- dirHandle.reset();
+
g_log<<Logger::Info<<"Found "<<zoneVersions.size()<<" versions of "<<domain<<", asked to keep "<<keep<<", ";
if (zoneVersions.size() <= keep) {
g_log<<Logger::Info<<"not cleaning up"<<endl;
uint64_t getOpenFileDescriptors(const std::string&)
{
#ifdef __linux__
- auto dirhdl = std::unique_ptr<DIR, decltype(&closedir)>(opendir(("/proc/"+std::to_string(getpid())+"/fd/").c_str()), closedir);
- if (!dirhdl) {
+ auto dirHandle = std::unique_ptr<DIR, decltype(&closedir)>(opendir(("/proc/"+std::to_string(getpid())+"/fd/").c_str()), closedir);
+ if (!dirHandle) {
return 0;
}
int ret = 0;
struct dirent* entry = nullptr;
// NOLINTNEXTLINE(concurrency-mt-unsafe): readdir is thread-safe nowadays and readdir_r is deprecated
- while ((entry = readdir(dirhdl.get())) != nullptr) {
+ while ((entry = readdir(dirHandle.get())) != nullptr) {
uint32_t num;
try {
// NOLINTNEXTLINE(cppcoreguidelines-pro-bounds-array-to-pointer-decay): this is what dirent is