From 538a16d15016b9be9885e94e9b94a4cbfb760501 Mon Sep 17 00:00:00 2001 From: Ron Yorston Date: Tue, 24 Mar 2015 08:27:45 +0000 Subject: 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. --- coreutils/test.c | 4 ---- win32/mingw.c | 3 +++ 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) } #if ENABLE_PLATFORM_MINGW32 -#undef R_OK -#define R_OK S_IREAD -#undef W_OK -#define W_OK S_IWRITE if (mode == FILEX) { char *p; 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) { int err; WIN32_FILE_ATTRIBUTE_DATA fdata; + mode_t usermode; if (!(err = get_file_attr(file_name, &fdata))) { int len = strlen(file_name); @@ -265,6 +266,8 @@ static int do_lstat(int follow, const char *file_name, struct mingw_stat *buf) FindClose(handle); } } + usermode = buf->st_mode & S_IRWXU; + buf->st_mode |= (usermode >> 3) | ((usermode >> 6) & ~S_IWOTH); /* * Assume a block is 4096 bytes and calculate number of 512 byte -- cgit v1.2.3-55-g6feb