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:
parent
7d2b57e019
commit
c7e9118bb6
1 changed files with 20 additions and 4 deletions
|
@ -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
|
||||
{
|
||||
|
|
Loading…
Reference in a new issue