Loading src/backend.cpp +4 −1 Original line number Diff line number Diff line Loading @@ -2061,7 +2061,10 @@ void BinDb::zero_record_locked(const std::string& store_id, std::uint64_t record // Mark as deleted: single byte write (type = REC_EMPTY) // body_size stays intact so load/vacuum can skip over the record std::uint8_t empty_type = REC_EMPTY; (void)::pwrite(fd, &empty_type, 1, static_cast<off_t>(record_offset)); if (::pwrite(fd, &empty_type, 1, static_cast<off_t>(record_offset)) < 0) { ::close(fd); return; } ::close(fd); mmap_store(store_id); Loading src/server.cpp +13 −7 Original line number Diff line number Diff line Loading @@ -620,9 +620,11 @@ int HttpServer::run() { std::cerr << "setsid() failed: " << strerror(errno) << "\n"; return 1; } (void)freopen("/dev/null", "r", stdin); (void)freopen("/dev/null", "w", stdout); (void)freopen("/dev/null", "w", stderr); if (!freopen("/dev/null", "r", stdin)) std::cerr << "freopen stdin failed\n"; if (!freopen("/dev/null", "w", stdout)) std::cerr << "freopen stdout failed\n"; if (!freopen("/dev/null", "w", stderr)) {} } else { std::cout << "mediadb started on " << proto << "://" << addr_ << ":" << port_ << "\n"; } Loading Loading @@ -681,9 +683,11 @@ void HttpServer::drop_privileges(const std::string& username, const std::string& namespace fs = std::filesystem; try { for (auto& entry : fs::recursive_directory_iterator(db_dir)) { (void)chown(entry.path().c_str(), pw->pw_uid, pw->pw_gid); if (chown(entry.path().c_str(), pw->pw_uid, pw->pw_gid) != 0) std::cerr << "chown failed: " << entry.path() << "\n"; } (void)chown(db_dir.c_str(), pw->pw_uid, pw->pw_gid); if (chown(db_dir.c_str(), pw->pw_uid, pw->pw_gid) != 0) std::cerr << "chown failed: " << db_dir << "\n"; } catch (...) { // best-effort; directory may not exist yet } Loading @@ -694,9 +698,11 @@ void HttpServer::drop_privileges(const std::string& username, const std::string& const auto& cpath = g_Cluster->getConfig().store_path; try { for (auto& entry : fs::recursive_directory_iterator(cpath)) { (void)chown(entry.path().c_str(), pw->pw_uid, pw->pw_gid); if (chown(entry.path().c_str(), pw->pw_uid, pw->pw_gid) != 0) std::cerr << "chown failed: " << entry.path() << "\n"; } (void)chown(cpath.c_str(), pw->pw_uid, pw->pw_gid); if (chown(cpath.c_str(), pw->pw_uid, pw->pw_gid) != 0) std::cerr << "chown failed: " << cpath << "\n"; } catch (...) { // best-effort } Loading Loading
src/backend.cpp +4 −1 Original line number Diff line number Diff line Loading @@ -2061,7 +2061,10 @@ void BinDb::zero_record_locked(const std::string& store_id, std::uint64_t record // Mark as deleted: single byte write (type = REC_EMPTY) // body_size stays intact so load/vacuum can skip over the record std::uint8_t empty_type = REC_EMPTY; (void)::pwrite(fd, &empty_type, 1, static_cast<off_t>(record_offset)); if (::pwrite(fd, &empty_type, 1, static_cast<off_t>(record_offset)) < 0) { ::close(fd); return; } ::close(fd); mmap_store(store_id); Loading
src/server.cpp +13 −7 Original line number Diff line number Diff line Loading @@ -620,9 +620,11 @@ int HttpServer::run() { std::cerr << "setsid() failed: " << strerror(errno) << "\n"; return 1; } (void)freopen("/dev/null", "r", stdin); (void)freopen("/dev/null", "w", stdout); (void)freopen("/dev/null", "w", stderr); if (!freopen("/dev/null", "r", stdin)) std::cerr << "freopen stdin failed\n"; if (!freopen("/dev/null", "w", stdout)) std::cerr << "freopen stdout failed\n"; if (!freopen("/dev/null", "w", stderr)) {} } else { std::cout << "mediadb started on " << proto << "://" << addr_ << ":" << port_ << "\n"; } Loading Loading @@ -681,9 +683,11 @@ void HttpServer::drop_privileges(const std::string& username, const std::string& namespace fs = std::filesystem; try { for (auto& entry : fs::recursive_directory_iterator(db_dir)) { (void)chown(entry.path().c_str(), pw->pw_uid, pw->pw_gid); if (chown(entry.path().c_str(), pw->pw_uid, pw->pw_gid) != 0) std::cerr << "chown failed: " << entry.path() << "\n"; } (void)chown(db_dir.c_str(), pw->pw_uid, pw->pw_gid); if (chown(db_dir.c_str(), pw->pw_uid, pw->pw_gid) != 0) std::cerr << "chown failed: " << db_dir << "\n"; } catch (...) { // best-effort; directory may not exist yet } Loading @@ -694,9 +698,11 @@ void HttpServer::drop_privileges(const std::string& username, const std::string& const auto& cpath = g_Cluster->getConfig().store_path; try { for (auto& entry : fs::recursive_directory_iterator(cpath)) { (void)chown(entry.path().c_str(), pw->pw_uid, pw->pw_gid); if (chown(entry.path().c_str(), pw->pw_uid, pw->pw_gid) != 0) std::cerr << "chown failed: " << entry.path() << "\n"; } (void)chown(cpath.c_str(), pw->pw_uid, pw->pw_gid); if (chown(cpath.c_str(), pw->pw_uid, pw->pw_gid) != 0) std::cerr << "chown failed: " << cpath << "\n"; } catch (...) { // best-effort } Loading