Loading src/authdb.cpp +21 −0 Original line number Diff line number Diff line Loading @@ -31,6 +31,7 @@ #include <mutex> #include <shared_mutex> #include <fstream> #include <filesystem> #include <thread> #include <map> #include <memory> Loading Loading @@ -756,6 +757,26 @@ int main(int argc,char *argv[]){ if (getuid() == 0) { struct passwd *pw = getpwnam("authdb"); if (pw) { /* Chown data files created while running as root (e.g. blocks.bin) */ if (!backendPath.empty()) { namespace fs = std::filesystem; fs::path parentDir = fs::path(backendPath).parent_path(); if (fs::is_directory(parentDir)) { for (auto &entry : fs::recursive_directory_iterator(parentDir)) { chown(entry.path().c_str(), pw->pw_uid, pw->pw_gid); } chown(parentDir.c_str(), pw->pw_uid, pw->pw_gid); } } if (clusterEnabled && !ccfg.store_path.empty()) { namespace fs = std::filesystem; if (fs::is_directory(ccfg.store_path)) { for (auto &entry : fs::recursive_directory_iterator(ccfg.store_path)) { chown(entry.path().c_str(), pw->pw_uid, pw->pw_gid); } chown(ccfg.store_path.c_str(), pw->pw_uid, pw->pw_gid); } } if (setgid(pw->pw_gid) != 0) { std::cerr << "setgid failed" << std::endl; return 1; Loading Loading
src/authdb.cpp +21 −0 Original line number Diff line number Diff line Loading @@ -31,6 +31,7 @@ #include <mutex> #include <shared_mutex> #include <fstream> #include <filesystem> #include <thread> #include <map> #include <memory> Loading Loading @@ -756,6 +757,26 @@ int main(int argc,char *argv[]){ if (getuid() == 0) { struct passwd *pw = getpwnam("authdb"); if (pw) { /* Chown data files created while running as root (e.g. blocks.bin) */ if (!backendPath.empty()) { namespace fs = std::filesystem; fs::path parentDir = fs::path(backendPath).parent_path(); if (fs::is_directory(parentDir)) { for (auto &entry : fs::recursive_directory_iterator(parentDir)) { chown(entry.path().c_str(), pw->pw_uid, pw->pw_gid); } chown(parentDir.c_str(), pw->pw_uid, pw->pw_gid); } } if (clusterEnabled && !ccfg.store_path.empty()) { namespace fs = std::filesystem; if (fs::is_directory(ccfg.store_path)) { for (auto &entry : fs::recursive_directory_iterator(ccfg.store_path)) { chown(entry.path().c_str(), pw->pw_uid, pw->pw_gid); } chown(ccfg.store_path.c_str(), pw->pw_uid, pw->pw_gid); } } if (setgid(pw->pw_gid) != 0) { std::cerr << "setgid failed" << std::endl; return 1; Loading