aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--include/mingw.h5
-rw-r--r--libbb/appletlib.c9
-rw-r--r--shell/ash.c3
-rw-r--r--win32/mingw.c14
4 files changed, 31 insertions, 0 deletions
diff --git a/include/mingw.h b/include/mingw.h
index b712e4ec0..2dc3ddfd7 100644
--- a/include/mingw.h
+++ b/include/mingw.h
@@ -243,6 +243,11 @@ NOIMPL(mingw_sendto,SOCKET s UNUSED_PARAM, const char *buf UNUSED_PARAM, int len
243#define S_IWOTH (S_IWGRP >> 3) 243#define S_IWOTH (S_IWGRP >> 3)
244#define S_IXOTH (S_IXGRP >> 3) 244#define S_IXOTH (S_IXGRP >> 3)
245 245
246mode_t mingw_umask(mode_t mode);
247#define umask mingw_umask
248
249#define DEFAULT_UMASK 0002
250
246IMPL(fchmod,int,0,int fildes UNUSED_PARAM, mode_t mode UNUSED_PARAM); 251IMPL(fchmod,int,0,int fildes UNUSED_PARAM, mode_t mode UNUSED_PARAM);
247NOIMPL(fchown,int fd UNUSED_PARAM, uid_t uid UNUSED_PARAM, gid_t gid UNUSED_PARAM); 252NOIMPL(fchown,int fd UNUSED_PARAM, uid_t uid UNUSED_PARAM, gid_t gid UNUSED_PARAM);
248int mingw_mkdir(const char *path, int mode); 253int mingw_mkdir(const char *path, int mode);
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"
diff --git a/shell/ash.c b/shell/ash.c
index 5195a8557..d9a4a8cfa 100644
--- a/shell/ash.c
+++ b/shell/ash.c
@@ -14489,6 +14489,9 @@ umaskcmd(int argc UNUSED_PARAM, char **argv UNUSED_PARAM)
14489 if (!isdigit(modestr[0])) 14489 if (!isdigit(modestr[0]))
14490 mask ^= 0777; 14490 mask ^= 0777;
14491 umask(mask); 14491 umask(mask);
14492#if ENABLE_PLATFORM_MINGW32
14493 setvareq(xasprintf("BB_UMASK=0%o", mask), VEXPORT|VNOSAVE);
14494#endif
14492 } 14495 }
14493 return 0; 14496 return 0;
14494} 14497}
diff --git a/win32/mingw.c b/win32/mingw.c
index 8d1da5199..c72a306ac 100644
--- a/win32/mingw.c
+++ b/win32/mingw.c
@@ -318,6 +318,20 @@ static inline int get_file_attr(const char *fname, WIN32_FILE_ATTRIBUTE_DATA *fd
318 } 318 }
319} 319}
320 320
321#undef umask
322mode_t mingw_umask(mode_t new_mode)
323{
324 static mode_t old_mode = DEFAULT_UMASK;
325 mode_t tmp_mode;
326
327 tmp_mode = old_mode;
328 old_mode = new_mode;
329
330 umask((new_mode & S_IWUSR) ? _S_IWRITE : 0);
331
332 return tmp_mode;
333}
334
321/* 335/*
322 * Examine a file's contents to determine if it can be executed. This 336 * Examine a file's contents to determine if it can be executed. This
323 * should be a last resort: in most cases it's much more efficient to 337 * should be a last resort: in most cases it's much more efficient to