diff options
author | Mike Gilbert <floppym@gentoo.org> | 2013-09-26 20:39:41 +0200 |
---|---|---|
committer | Lennart Poettering <lennart@poettering.net> | 2013-09-26 20:39:44 +0200 |
commit | 90dc8c2ea2cebf2dd195abe4768205a831fd32cb (patch) | |
tree | 6fdf3c25d4f62cae4873c53aa7f5be07e4e7ad75 /src/core | |
parent | 299404a19f26aa4f203042d8285ee0b7afa5bf40 (diff) |
main: set umask before creating any files
This avoids a problem when we inherit a non-zero umask from the
initramfs. This would cause /run/systemd to be created with the wrong
mode.
Diffstat (limited to 'src/core')
-rw-r--r-- | src/core/main.c | 10 |
1 files changed, 5 insertions, 5 deletions
diff --git a/src/core/main.c b/src/core/main.c index 72bd542af0..0629d142ff 100644 --- a/src/core/main.c +++ b/src/core/main.c @@ -1265,6 +1265,10 @@ int main(int argc, char *argv[]) { log_show_color(isatty(STDERR_FILENO) > 0); + /* Disable the umask logic */ + if (getpid() == 1) + umask(0); + if (getpid() == 1 && detect_container(NULL) <= 0) { /* Running outside of a container as PID 1 */ @@ -1438,14 +1442,10 @@ int main(int argc, char *argv[]) { if (serialization) assert_se(fdset_remove(fds, fileno(serialization)) >= 0); - if (arg_running_as == SYSTEMD_SYSTEM) { + if (arg_running_as == SYSTEMD_SYSTEM) /* Become a session leader if we aren't one yet. */ setsid(); - /* Disable the umask logic */ - umask(0); - } - /* Move out of the way, so that we won't block unmounts */ assert_se(chdir("/") == 0); |