Merge pull request #2483 from wipedlifepotato/openssl

openbsd: fix a issue from IRC chat
This commit is contained in:
orignal
2026-08-16 20:07:04 -04:00
committed by GitHub
2 changed files with 19 additions and 2 deletions
+18 -2
View File
@@ -12,10 +12,10 @@
#ifdef __OpenBSD__
# include<unistd.h>
# include<filesystem>
#endif
#include "Daemon.h"
#include "Config.h"
#include "Log.h"
#include "FS.h"
@@ -140,15 +140,31 @@ namespace util
};
auto unveil_path = [](std::string path, std::string rules = "r")
{
// https://stackoverflow.com/questions/83439/remove-spaces-from-stdstring-in-c
path.erase(remove_if(path.begin(), path.end(), isspace), path.end());
if(path=="")
{
LogPrint(eLogDebug, "empty path for unveil");
return;
}
if ( (!std::filesystem::exists(path) && !std::filesystem::is_directory(path)) )
{
{
std::ofstream f{path};
if(!f)
{
LogPrint(eLogError, "can't create an empty file " + path);
throw std::runtime_error("Can't create a file and it's not directory");
}
}
}
if ( unveil(path.c_str(), rules.c_str()) == -1 )
{
LogPrint(eLogError, "Can't unveil " + path + " with rules " + rules);
throw std::runtime_error("can't unveil");
bool ignore_unveil;
i2p::config::GetOption("openbsd.unveil_ignore", ignore_unveil);
if(!ignore_unveil)
throw std::runtime_error("can't unveil");
}
LogPrint(eLogInfo, "unveil " + path + " with rules " + rules);
};
+1
View File
@@ -410,6 +410,7 @@ namespace config {
("openbsd.unveil_file", value<std::string>()->default_value(""), "OpenBSD file with unveil rules")
("openbsd.unveil_enabled", value<bool>()->default_value(true), "use unveil rues")
("openbsd.pledge_enabled", value<bool>()->default_value(true), "use pledge rules")
("openbsd.unveil_ignore", value<bool>()->default_value(false), "ignore unveil errors")
;
#endif