From 7385c036bdd2e9254be99024ddcec639b668f68a Mon Sep 17 00:00:00 2001 From: moneromooo-monero Date: Wed, 6 Apr 2016 19:59:34 +0100 Subject: util: add a function to set umask to 077 Useful to ensure files are written without group/other read rights. --- src/common/util.cpp | 9 +++++++++ src/common/util.h | 2 ++ 2 files changed, 11 insertions(+) (limited to 'src') diff --git a/src/common/util.cpp b/src/common/util.cpp index 6f75e5bad..2337f5766 100644 --- a/src/common/util.cpp +++ b/src/common/util.cpp @@ -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 + } } diff --git a/src/common/util.h b/src/common/util.h index 7554b1df7..ed1c16cb0 100644 --- a/src/common/util.h +++ b/src/common/util.h @@ -158,4 +158,6 @@ namespace tools /*! \brief where the installed handler is stored */ static std::function m_handler; }; + + void set_strict_default_file_permissions(bool strict); } -- cgit v1.2.3 From ed61a2ccc1bc38a8e58ecef17e5831d1e406cd0b Mon Sep 17 00:00:00 2001 From: moneromooo-monero Date: Wed, 6 Apr 2016 20:00:25 +0100 Subject: simplewallet: set strict umask at start --- src/simplewallet/simplewallet.cpp | 1 + 1 file changed, 1 insertion(+) (limited to 'src') diff --git a/src/simplewallet/simplewallet.cpp b/src/simplewallet/simplewallet.cpp index aa571755f..3d1410f43 100644 --- a/src/simplewallet/simplewallet.cpp +++ b/src/simplewallet/simplewallet.cpp @@ -2807,6 +2807,7 @@ int main(int argc, char* argv[]) std::string lang = i18n_get_language(); tools::sanitize_locale(); + tools::set_strict_default_file_permissions(true); string_tools::set_module_name_and_folder(argv[0]); -- cgit v1.2.3