aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRon Yorston <rmy@pobox.com>2015-03-24 08:27:45 +0000
committerRon Yorston <rmy@pobox.com>2015-03-24 08:27:45 +0000
commit538a16d15016b9be9885e94e9b94a4cbfb760501 (patch)
treedfbde972f95e05e0557ffd45bb5bd050a150e98f
parentf2cfa8d515d7c7f594ced5bfe748a5b5773590cb (diff)
downloadbusybox-w32-538a16d15016b9be9885e94e9b94a4cbfb760501.tar.gz
busybox-w32-538a16d15016b9be9885e94e9b94a4cbfb760501.tar.bz2
busybox-w32-538a16d15016b9be9885e94e9b94a4cbfb760501.zip
test: fix access check bug; tweak fake file mode
Changing the fake uid from 0 to 1000 uncovered a problem with file access checks in test. Previously the tests were short-circuited because it thought we were root. With a non-root user the tests were performed, but the mode bits had been redefined for WIN32. Also adjust the fake file mode returned by stat so that the user and group modes are identical. Other users have the same modes as user but without write permission.
-rw-r--r--coreutils/test.c4
-rw-r--r--win32/mingw.c3
2 files changed, 3 insertions, 4 deletions
diff --git a/coreutils/test.c b/coreutils/test.c
index 6b16ffeb1..9e709a709 100644
--- a/coreutils/test.c
+++ b/coreutils/test.c
@@ -643,10 +643,6 @@ static int filstat(char *nm, enum token mode)
643 } 643 }
644 644
645#if ENABLE_PLATFORM_MINGW32 645#if ENABLE_PLATFORM_MINGW32
646#undef R_OK
647#define R_OK S_IREAD
648#undef W_OK
649#define W_OK S_IWRITE
650 if (mode == FILEX) { 646 if (mode == FILEX) {
651 char *p; 647 char *p;
652 648
diff --git a/win32/mingw.c b/win32/mingw.c
index 4b5701b2d..fe45589c2 100644
--- a/win32/mingw.c
+++ b/win32/mingw.c
@@ -228,6 +228,7 @@ static int do_lstat(int follow, const char *file_name, struct mingw_stat *buf)
228{ 228{
229 int err; 229 int err;
230 WIN32_FILE_ATTRIBUTE_DATA fdata; 230 WIN32_FILE_ATTRIBUTE_DATA fdata;
231 mode_t usermode;
231 232
232 if (!(err = get_file_attr(file_name, &fdata))) { 233 if (!(err = get_file_attr(file_name, &fdata))) {
233 int len = strlen(file_name); 234 int len = strlen(file_name);
@@ -265,6 +266,8 @@ static int do_lstat(int follow, const char *file_name, struct mingw_stat *buf)
265 FindClose(handle); 266 FindClose(handle);
266 } 267 }
267 } 268 }
269 usermode = buf->st_mode & S_IRWXU;
270 buf->st_mode |= (usermode >> 3) | ((usermode >> 6) & ~S_IWOTH);
268 271
269 /* 272 /*
270 * Assume a block is 4096 bytes and calculate number of 512 byte 273 * Assume a block is 4096 bytes and calculate number of 512 byte