diff --git a/src/i2p.cpp b/src/i2p.cpp index d4139bb8e55..8e98440747f 100644 --- a/src/i2p.cpp +++ b/src/i2p.cpp @@ -336,7 +336,7 @@ void Session::GenerateAndSavePrivateKey(const Sock& sock) { DestGenerate(sock); - // umask is set to 077 in init.cpp, which is ok. + // umask is set to 0077 in util/system.cpp, which is ok. if (!WriteBinaryFile(m_private_key_file, std::string(m_private_key.begin(), m_private_key.end()))) { throw std::runtime_error( diff --git a/src/init.cpp b/src/init.cpp index c4a07069e77..73ae36e4f78 100644 --- a/src/init.cpp +++ b/src/init.cpp @@ -816,8 +816,6 @@ bool AppInitBasicSetup(const ArgsManager& args) } #ifndef WIN32 - umask(077); - // Clean shutdown on SIGTERM registerSignalHandler(SIGTERM, HandleSIGTERM); registerSignalHandler(SIGINT, HandleSIGTERM); diff --git a/src/rpc/request.cpp b/src/rpc/request.cpp index f554ee21161..6f37fe2a99f 100644 --- a/src/rpc/request.cpp +++ b/src/rpc/request.cpp @@ -86,7 +86,7 @@ bool GenerateAuthCookie(std::string *cookie_out) std::string cookie = COOKIEAUTH_USER + ":" + HexStr(rand_pwd); /** the umask determines what permissions are used to create this file - - * these are set to 077 in init.cpp. + * these are set to 0077 in util/system.cpp. */ std::ofstream file; fs::path filepath_tmp = GetAuthCookieFile(true); diff --git a/src/util/system.cpp b/src/util/system.cpp index 0cea283ecea..e72c9701571 100644 --- a/src/util/system.cpp +++ b/src/util/system.cpp @@ -1360,6 +1360,11 @@ void SetupEnvironment() SetConsoleCP(CP_UTF8); SetConsoleOutputCP(CP_UTF8); #endif + +#ifndef WIN32 + constexpr mode_t private_umask = 0077; + umask(private_umask); +#endif } bool SetupNetworking()