fix: use process umask for new files. (#7195)

This commit is contained in:
Josh Grosse
2024-12-27 19:20:33 -05:00
committed by GitHub
parent 8cb527d428
commit b969b0bae1

View File

@@ -32,6 +32,7 @@
#include <shellapi.h> /* CommandLineToArgv() */
#else
#include <arpa/inet.h>
#include <sys/stat.h> /* umask() */
#endif
#define UTF_CPP_CPLUSPLUS 201703L
@@ -193,6 +194,14 @@ bool tr_file_save(std::string_view filename, std::string_view contents, tr_error
{
return false;
}
#ifndef _WIN32
// set file mode per settings umask()
{
auto const val = ::umask(0);
::umask(val);
fchmod(fd, 0666 & ~val);
}
#endif
// Save the contents. This might take >1 pass.
auto ok = true;