util: add a function to set umask to 077

Useful to ensure files are written without group/other read rights.
This commit is contained in:
moneromooo-monero 2016-04-06 19:59:34 +01:00
parent e7c8a32a28
commit 7385c036bd
No known key found for this signature in database
GPG Key ID: 686F07454D6CEFC3
2 changed files with 11 additions and 0 deletions

View File

@ -413,4 +413,13 @@ std::string get_nix_version_display_string()
}
return false;
}
void set_strict_default_file_permissions(bool strict)
{
#if defined(__MINGW32__) || defined(__MINGW__)
// no clue about the odd one out
#else
mode_t mode = strict ? 077 : 0;
umask(mode);
#endif
}
}

View File

@ -158,4 +158,6 @@ namespace tools
/*! \brief where the installed handler is stored */
static std::function<void(int)> m_handler;
};
void set_strict_default_file_permissions(bool strict);
}