From a6c5fd4eb35a68a7a5cb01426df3f85ef0d20975 Mon Sep 17 00:00:00 2001 From: Ron Yorston Date: Mon, 13 Feb 2023 15:26:39 +0000 Subject: win32: skip ACL check in stat(2) when running as root Commit 88965fe20 (win32: use ACL check to clarify write permission) added code to check if a file had write permission due to an ACL entry. When running with elevated privileges this check is unnecessary as "user" permissions will be sufficient. This also prevents write permission for "other" being set without respecting umask. --- win32/mingw.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/win32/mingw.c b/win32/mingw.c index 4d07a24e5..712728bd6 100644 --- a/win32/mingw.c +++ b/win32/mingw.c @@ -557,7 +557,8 @@ static uid_t file_owner(HANDLE fh, struct mingw_stat *buf) uid = (uid_t)ptr[6]; } - if (uid != DEFAULT_UID && impersonate != INVALID_HANDLE_VALUE) { + if (uid != DEFAULT_UID && impersonate != INVALID_HANDLE_VALUE && + getuid() != 0) { static GENERIC_MAPPING mapping = { FILE_GENERIC_READ, FILE_GENERIC_WRITE, FILE_GENERIC_EXECUTE, FILE_ALL_ACCESS -- cgit v1.2.3-55-g6feb