diff --git a/plugins/bootmisc.c b/plugins/bootmisc.c index 0477847d..ebe8e00d 100644 --- a/plugins/bootmisc.c +++ b/plugins/bootmisc.c @@ -99,11 +99,14 @@ static void bootclean(void) */ static void setup(void *arg) { + mode_t prev; + /* Cleanup stale files, if any still linger on. */ bootclean(); + prev = umask(0); + _d("Setting up FHS structure in /var ..."); - umask(0); makedir("/var/cache", 0755); makedir("/var/db", 0755); /* _PATH_VARDB on some systems */ makedir("/var/games", 0755); @@ -177,7 +180,7 @@ static void setup(void *arg) /* Void Linux has a uuidd that runs as uuid:uuid and needs /run/uuid */ mksubsys("/var/run/uuidd", 0755, "uuidd", "uuidd"); - umask(022); + umask(prev); } static plugin_t plugin = { diff --git a/plugins/dbus.c b/plugins/dbus.c index 9533fab2..848e6e4c 100644 --- a/plugins/dbus.c +++ b/plugins/dbus.c @@ -39,8 +39,9 @@ static void setup(void *arg) { - char *cmd; char line[256]; + mode_t prev; + char *cmd; cmd = which(DAEMON); if (!cmd) { @@ -48,7 +49,7 @@ static void setup(void *arg) return; } - umask(0); + prev =umask(0); mksubsys("/var/run/dbus", 0755, DAEMONUSER, DAEMONUSER); if (whichp("dbus-uuidgen")) @@ -64,7 +65,7 @@ static void setup(void *arg) _pe("Failed registering %s", DAEMON); free(cmd); - umask(022); + umask(prev); } static plugin_t plugin = { diff --git a/plugins/urandom.c b/plugins/urandom.c index ab96209e..fa179065 100644 --- a/plugins/urandom.c +++ b/plugins/urandom.c @@ -37,10 +37,11 @@ static void setup(void *arg) #ifdef RANDOMSEED if (!fexist(RANDOMSEED)) { int ret = 1; + mode_t prev; FILE *fp; print_desc("Bootstrapping random seed", NULL); - umask(077); + prev = umask(077); fp = fopen(RANDOMSEED, "w"); if (fp) { int iter = 128; @@ -57,7 +58,7 @@ static void setup(void *arg) ret = fclose(fp); } print_result(ret); - umask(0); + umask(prev); } print_desc("Initializing random number generator", NULL); @@ -68,10 +69,14 @@ static void setup(void *arg) static void save(void *arg) { #ifdef RANDOMSEED - umask(077); + mode_t prev; + + prev = umask(077); + print_desc("Saving random seed", NULL); print_result(512 != copyfile("/dev/urandom", RANDOMSEED, 512, 0)); - umask(0); + + umask(prev); #endif } diff --git a/plugins/x11-common.c b/plugins/x11-common.c index 7cf386dc..5eb5be50 100644 --- a/plugins/x11-common.c +++ b/plugins/x11-common.c @@ -32,13 +32,14 @@ static void setup(void *arg) { + const char *username = "nobody"; + char line[LINE_SIZE]; + mode_t prev; #ifdef PAM_CONSOLE int fd; #endif - char line[LINE_SIZE]; - const char *username = "nobody"; - umask(0); + prev = umask(0); makedir("/var/run/console", 01777); snprintf(line, sizeof(line), "/var/run/console/%s", username); @@ -58,7 +59,7 @@ static void setup(void *arg) if (whichp("restorecon")) run("restorecon /tmp/.ICE-unix /tmp/.X11-unix"); - umask(022); + umask(prev); } static plugin_t plugin = {