1
1
Fork 0
mirror of https://github.com/oxen-io/lokinet synced 2023-12-14 06:53:00 +01:00

fix fs stuff

This commit is contained in:
Jeff Becker 2019-06-24 15:34:30 -04:00
parent 7d2b57e019
commit c7e9118bb6
No known key found for this signature in database
GPG key ID: F357B3B42F6F9B05

View file

@ -21,13 +21,29 @@ namespace llarp
EnsurePrivateFile(fs::path pathname)
{
const auto str = pathname.string();
errno = 0;
error_code_t ec = errno_error();
if(fs::exists(pathname, ec)) // file exists
{
fs::permissions(pathname,
~fs::perms::group_all | ~fs::perms::others_all
| fs::perms::owner_read | fs::perms::owner_write,
ec);
auto st = fs::status(pathname, ec);
if(ec)
return ec;
auto perms = st.permissions();
if((perms & fs::perms::others_exec) != fs::perms::none)
perms ^= fs::perms::others_exec;
if((perms & fs::perms::others_write) != fs::perms::none)
perms ^= fs::perms::others_write;
if((perms & fs::perms::others_write) != fs::perms::none)
perms ^= fs::perms::others_write;
if((perms & fs::perms::group_read) != fs::perms::none)
perms ^= fs::perms::group_read;
if((perms & fs::perms::others_read) != fs::perms::none)
perms ^= fs::perms::others_read;
if((perms & fs::perms::owner_exec) != fs::perms::none)
perms ^= fs::perms::owner_exec;
fs::permissions(pathname, perms, ec);
if(ec)
llarp::LogError("failed to set permissions on ", pathname);
}
else if(!ec) // file is not there
{