From e03b358ff07a2e51d466dd5cb1aa6c861a5350bb Mon Sep 17 00:00:00 2001 From: Joachim Nilsson Date: Sun, 2 Oct 2016 11:42:40 +0200 Subject: [PATCH] Fix #46: Set correct umask() before makedir() and chmod() Signed-off-by: Joachim Nilsson --- plugins/bootmisc.c | 4 ++++ plugins/dbus.c | 4 ++++ plugins/x11-common.c | 4 ++++ 3 files changed, 12 insertions(+) diff --git a/plugins/bootmisc.c b/plugins/bootmisc.c index 30d7a7f8..225c6d14 100644 --- a/plugins/bootmisc.c +++ b/plugins/bootmisc.c @@ -43,6 +43,8 @@ static void setup(void *UNUSED(arg)) { int gid; + umask(0); + _d("Setting up FHS structure in /var ..."); makedir("/var/cache", 0755); makedir("/var/games", 0755); @@ -104,6 +106,8 @@ static void setup(void *UNUSED(arg)) makedir("/var/run/sshd", 01755); /* OpenSSH */ makefifo("/dev/xconsole", 0640); /* sysklogd */ chown("/dev/xconsole", 0, getgroup("tty")); + + umask(022); } static plugin_t plugin = { diff --git a/plugins/dbus.c b/plugins/dbus.c index ceab30bd..8b95bbb5 100644 --- a/plugins/dbus.c +++ b/plugins/dbus.c @@ -31,6 +31,8 @@ static void setup(void *UNUSED(arg)) { + umask(0); + _d("Starting D-Bus ..."); makedir("/var/run/dbus", 0755); makedir("/var/lock/subsys", 0755); @@ -38,6 +40,8 @@ static void setup(void *UNUSED(arg)) run("dbus-uuidgen --ensure"); erase("/var/run/dbus/pid"); run_interactive("dbus-daemon --system", "Starting D-Bus"); + + umask(022); } static plugin_t plugin = { diff --git a/plugins/x11-common.c b/plugins/x11-common.c index 9b9cbe9a..b096a345 100644 --- a/plugins/x11-common.c +++ b/plugins/x11-common.c @@ -37,6 +37,8 @@ static void setup(void *UNUSED(arg)) #endif char line[LINE_SIZE]; + umask(0); + makedir("/var/run/console", 01777); snprintf(line, sizeof(line), "/var/run/console/%s", username); touch(line); @@ -54,6 +56,8 @@ static void setup(void *UNUSED(arg)) if (fexist("/sbin/restorecon")) run("/sbin/restorecon /tmp/.ICE-unix /tmp/.X11-unix"); + + umask(022); } static plugin_t plugin = {