From 74439d15d7f8eae1d942cd96632f4c1c4c9e9e3a Mon Sep 17 00:00:00 2001 From: Paul Eggert Date: Fri, 1 Sep 2023 09:11:32 -0700 Subject: [PATCH] chown: port to mingw and MSVC 14 MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit * src/chown-core.c (restricted_chown): Don’t assume fchown exists. The Gnulib doc says that nowadays this is needed only for ports to mingw and MSVC 14, but it’s an easy port so let’s do it. --- src/chown-core.c | 13 ++++--------- 1 file changed, 4 insertions(+), 9 deletions(-) diff --git a/src/chown-core.c b/src/chown-core.c index be86072da3..fd718214f5 100644 --- a/src/chown-core.c +++ b/src/chown-core.c @@ -260,16 +260,11 @@ restricted_chown (int cwd_fd, char const *file, else if ((required_uid == (uid_t) -1 || required_uid == st.st_uid) && (required_gid == (gid_t) -1 || required_gid == st.st_gid)) { +#if HAVE_FCHOWN if (fchown (fd, uid, gid) == 0) - { - status = (close (fd) == 0 - ? RC_ok : RC_error); - return status; - } - else - { - status = RC_error; - } + return close (fd) < 0 ? RC_error : RC_ok; +#endif + status = RC_error; } int saved_errno = errno; -- 2.47.2