core: be more paranoid when mixing umask and fopen()

Let's be extra careful with the umask when we use simple fopen(), as this
creates files with 0777 by default.
This commit is contained in:
Lennart Poettering
2016-04-12 13:43:32 +02:00
parent 4f4afc88ec
commit 8612da973d
3 changed files with 7 additions and 4 deletions
+3 -1
View File
@@ -55,6 +55,7 @@
#include "string-util.h"
#include "strv.h"
#include "time-util.h"
#include "umask-util.h"
#include "user-util.h"
#include "util.h"
@@ -781,7 +782,8 @@ int update_reboot_param_file(const char *param) {
int r = 0;
if (param) {
r = write_string_file(REBOOT_PARAM_FILE, param, WRITE_STRING_FILE_CREATE);
RUN_WITH_UMASK(0022)
r = write_string_file(REBOOT_PARAM_FILE, param, WRITE_STRING_FILE_CREATE);
if (r < 0)
return log_error_errno(r, "Failed to write reboot param to "REBOOT_PARAM_FILE": %m");
} else