diff options
author | Ron Yorston <rmy@pobox.com> | 2019-01-07 07:54:40 +0000 |
---|---|---|
committer | Ron Yorston <rmy@pobox.com> | 2019-01-07 07:54:40 +0000 |
commit | a85653040477ec4e8a722de3af5afd04ee66bd59 (patch) | |
tree | 22c36324fd4cf68764f0df846321bc5a12a611fb /libbb | |
parent | 1fec4ebbdb930f6b8989be2e10c0f673803ac830 (diff) | |
download | busybox-w32-a85653040477ec4e8a722de3af5afd04ee66bd59.tar.gz busybox-w32-a85653040477ec4e8a722de3af5afd04ee66bd59.tar.bz2 busybox-w32-a85653040477ec4e8a722de3af5afd04ee66bd59.zip |
win32: implement umask(2)
umask() in the Microsoft C runtime takes different arguments to
umask(2). Implement a fake umask(2) that remembers the mask and
calls the Microsoft umask() with an appropriate value.
Since the mask won't be inherited by children use an environment
variable to pass any value set by the shell built-in umask.
Diffstat (limited to 'libbb')
-rw-r--r-- | libbb/appletlib.c | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/libbb/appletlib.c b/libbb/appletlib.c index 8a66b3303..ba52ef581 100644 --- a/libbb/appletlib.c +++ b/libbb/appletlib.c | |||
@@ -1081,6 +1081,15 @@ void FAST_FUNC run_applet_no_and_exit(int applet_no, const char *name, char **ar | |||
1081 | applet_name = name; | 1081 | applet_name = name; |
1082 | #if ENABLE_PLATFORM_MINGW32 | 1082 | #if ENABLE_PLATFORM_MINGW32 |
1083 | strcpy(bb_applet_name, applet_name); | 1083 | strcpy(bb_applet_name, applet_name); |
1084 | |||
1085 | { | ||
1086 | const char *vmask; | ||
1087 | unsigned int mask; | ||
1088 | |||
1089 | vmask = getenv("BB_UMASK"); | ||
1090 | if (vmask && sscanf(vmask, "%o", &mask) == 1) | ||
1091 | umask((mode_t)(mask&0777)); | ||
1092 | } | ||
1084 | #endif | 1093 | #endif |
1085 | 1094 | ||
1086 | /* Special case. POSIX says "test --help" | 1095 | /* Special case. POSIX says "test --help" |