aboutsummaryrefslogtreecommitdiff
path: root/toys
diff options
context:
space:
mode:
Diffstat (limited to 'toys')
-rw-r--r--toys/mdev.c3
-rw-r--r--toys/mkfifo.c3
-rw-r--r--toys/touch.c4
-rw-r--r--toys/toysh.c1
4 files changed, 4 insertions, 7 deletions
diff --git a/toys/mdev.c b/toys/mdev.c
index dff2e5c2..6e69a770 100644
--- a/toys/mdev.c
+++ b/toys/mdev.c
@@ -7,7 +7,7 @@
*
* Not in SUSv3.
-USE_MDEV(NEWTOY(mdev, "s", TOYFLAG_USR|TOYFLAG_BIN))
+USE_MDEV(NEWTOY(mdev, "s", TOYFLAG_USR|TOYFLAG_BIN|TOYFLAG_UMASK))
config MDEV
bool "mdev"
@@ -166,7 +166,6 @@ found_device:
}
sprintf(temp, "/dev/%s", device_name);
- umask(0);
if (mknod(temp, mode | type, makedev(major, minor)) && errno != EEXIST)
perror_exit("mknod %s failed", temp);
diff --git a/toys/mkfifo.c b/toys/mkfifo.c
index 0f57ca5d..39ec51ad 100644
--- a/toys/mkfifo.c
+++ b/toys/mkfifo.c
@@ -4,7 +4,7 @@
*
* See http://www.opengroup.org/onlinepubs/009695399/utilities/mkfifo.html
-USE_MKFIFO(NEWTOY(mkfifo, "<1m:", TOYFLAG_BIN))
+USE_MKFIFO(NEWTOY(mkfifo, "<1m:", TOYFLAG_BIN|TOYFLAG_UMASK))
config MKFIFO
bool "mkfifo"
@@ -40,7 +40,6 @@ void mkfifo_main(void)
error_exit("Invalid mode");
} else mode = 0644;
- umask(0);
for (i = 0; (arg = toys.optargs[i]); i++)
if (mkfifo(arg, mode))
perror_exit(arg);
diff --git a/toys/touch.c b/toys/touch.c
index c8cba76b..bead28fb 100644
--- a/toys/touch.c
+++ b/toys/touch.c
@@ -6,7 +6,7 @@
*
* See http://www.opengroup.org/onlinepubs/009695399/utilities/touch.html
-USE_TOUCH(NEWTOY(touch, "l#t:r:mca", TOYFLAG_BIN))
+USE_TOUCH(NEWTOY(touch, "l#t:r:mca", TOYFLAG_BIN|TOYFLAG_UMASK))
config TOUCH
bool "touch"
@@ -86,9 +86,7 @@ void touch_main(void)
if (stat(arg, &sb)) {
if (!(toys.optflags & OPT_NOCREATE)) {
- int temp = umask(0);
xcreate(arg, O_CREAT, 0644);
- if (CFG_TOYBOX_FREE) umask(temp);
if (stat(arg, &sb))
goto error;
}
diff --git a/toys/toysh.c b/toys/toysh.c
index e2800681..17467fad 100644
--- a/toys/toysh.c
+++ b/toys/toysh.c
@@ -296,6 +296,7 @@ static void run_pipeline(struct pipeline *line)
tl->toy_main();
cmd->pid = toys.exitval;
free(toys.optargs);
+ if (toys.old_umask) umask(toys.old_umask);
memcpy(&toys, &temp, sizeof(struct toy_context));
} else {
int status;