aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRon Yorston <rmy@pobox.com>2023-01-11 12:36:16 +0000
committerRon Yorston <rmy@pobox.com>2023-01-11 12:36:16 +0000
commit857b0732b9268c049e94bb3220fbb078f662ab02 (patch)
treec0df8adb377476dba441b251b31e725211f7df75
parent4ea671b358ec15331a961be092a777c8a82d1642 (diff)
downloadbusybox-w32-857b0732b9268c049e94bb3220fbb078f662ab02.tar.gz
busybox-w32-857b0732b9268c049e94bb3220fbb078f662ab02.tar.bz2
busybox-w32-857b0732b9268c049e94bb3220fbb078f662ab02.zip
win32: fix permissions of read-only directory
Commit 15fcbd19c8 (win32: special case for devices files in stat(2)) caused write permissions on directories to respect the read-only attribute. This is incorrect: the read-only attribute doesn't apply to directories in the same way as to normal files. Give directories write permission unconditionally, as before, though respecting umask. (GitHub issue #280)
-rw-r--r--win32/mingw.c2
1 files changed, 1 insertions, 1 deletions
diff --git a/win32/mingw.c b/win32/mingw.c
index 8216f2e53..a2a736d52 100644
--- a/win32/mingw.c
+++ b/win32/mingw.c
@@ -345,7 +345,7 @@ static inline mode_t file_attr_to_st_mode(DWORD attr)
345{ 345{
346 mode_t fMode = S_IRUSR|S_IRGRP|S_IROTH; 346 mode_t fMode = S_IRUSR|S_IRGRP|S_IROTH;
347 if (attr & FILE_ATTRIBUTE_DIRECTORY) 347 if (attr & FILE_ATTRIBUTE_DIRECTORY)
348 fMode |= S_IFDIR|S_IXUSR|S_IXGRP|S_IXOTH; 348 fMode |= (S_IFDIR|S_IRWXU|S_IRWXG|S_IRWXO) & ~(current_umask & 0022);
349 else if (attr & FILE_ATTRIBUTE_DEVICE) 349 else if (attr & FILE_ATTRIBUTE_DEVICE)
350 fMode |= S_IFCHR|S_IWUSR|S_IWGRP|S_IWOTH; 350 fMode |= S_IFCHR|S_IWUSR|S_IWGRP|S_IWOTH;
351 else 351 else