diff options
author | Denys Vlasenko | 2015-10-07 16:56:20 +0200 |
---|---|---|
committer | Denys Vlasenko | 2015-10-07 16:56:20 +0200 |
commit | 6283f9828320ef5e0be0b060b7f26522b529ed42 (patch) | |
tree | 9b11416a3cdd3655f2854debe868e4c19d232a88 /shell/hush.c | |
parent | 9c5410023a9d1920c336ed4d9ceaad586ce43328 (diff) | |
download | busybox-6283f9828320ef5e0be0b060b7f26522b529ed42.zip busybox-6283f9828320ef5e0be0b060b7f26522b529ed42.tar.gz |
hush: fix umask: umask(022) was setting umask(755)
Based on the patch by Rich Felker <dalias@libc.org>
function old new delta
builtin_umask 121 161 +40
umaskcmd 318 279 -39
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
Diffstat (limited to 'shell/hush.c')
-rw-r--r-- | shell/hush.c | 10 |
1 files changed, 7 insertions, 3 deletions
diff --git a/shell/hush.c b/shell/hush.c index 752080a..8b8d5fc 100644 --- a/shell/hush.c +++ b/shell/hush.c @@ -8970,10 +8970,14 @@ static int FAST_FUNC builtin_umask(char **argv) if (argv[0]) { mode_t old_mask = mask; - mask ^= 0777; + /* numeric umasks are taken as-is */ + /* symbolic umasks are inverted: "umask a=rx" calls umask(222) */ + if (!isdigit(argv[0][0])) + mask ^= 0777; rc = bb_parse_mode(argv[0], &mask); - mask ^= 0777; - if (rc == 0) { + if (!isdigit(argv[0][0])) + mask ^= 0777; + if (rc == 0 || (unsigned)mask > 0777) { mask = old_mask; /* bash messages: * bash: umask: 'q': invalid symbolic mode operator |