plugins: restore previous umask() after plugin ops

Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
This commit is contained in:
Joachim Wiberg committed 2021-03-14 11:04:29 +01:00
1 parent 03d8ef9c8f
commit 959c9fe5aa
4 files changed
+23 -13

No files matched your search

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