Skip to content

Commit 581f16e

Browse files
committed
Apply default umask in SetupEnvironment()
This change makes all filesystem artifacts--files and directories--being created with the default umask.
1 parent 8a6219e commit 581f16e

File tree

4 files changed

+7
-4
lines changed

4 files changed

+7
-4
lines changed

src/i2p.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -336,7 +336,7 @@ void Session::GenerateAndSavePrivateKey(const Sock& sock)
336336
{
337337
DestGenerate(sock);
338338

339-
// umask is set to 077 in init.cpp, which is ok.
339+
// umask is set to 0077 in util/system.cpp, which is ok.
340340
if (!WriteBinaryFile(m_private_key_file,
341341
std::string(m_private_key.begin(), m_private_key.end()))) {
342342
throw std::runtime_error(

src/init.cpp

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -816,8 +816,6 @@ bool AppInitBasicSetup(const ArgsManager& args)
816816
}
817817

818818
#ifndef WIN32
819-
umask(077);
820-
821819
// Clean shutdown on SIGTERM
822820
registerSignalHandler(SIGTERM, HandleSIGTERM);
823821
registerSignalHandler(SIGINT, HandleSIGTERM);

src/rpc/request.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ bool GenerateAuthCookie(std::string *cookie_out)
8686
std::string cookie = COOKIEAUTH_USER + ":" + HexStr(rand_pwd);
8787

8888
/** the umask determines what permissions are used to create this file -
89-
* these are set to 077 in init.cpp.
89+
* these are set to 0077 in util/system.cpp.
9090
*/
9191
std::ofstream file;
9292
fs::path filepath_tmp = GetAuthCookieFile(true);

src/util/system.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1360,6 +1360,11 @@ void SetupEnvironment()
13601360
SetConsoleCP(CP_UTF8);
13611361
SetConsoleOutputCP(CP_UTF8);
13621362
#endif
1363+
1364+
#ifndef WIN32
1365+
constexpr mode_t private_umask = 0077;
1366+
umask(private_umask);
1367+
#endif
13631368
}
13641369

13651370
bool SetupNetworking()

0 commit comments

Comments
 (0)