]> git.ipfire.org Git - thirdparty/coreutils.git/commitdiff
chown: port to mingw and MSVC 14
authorPaul Eggert <eggert@cs.ucla.edu>
Fri, 1 Sep 2023 16:11:32 +0000 (09:11 -0700)
committerPaul Eggert <eggert@cs.ucla.edu>
Fri, 1 Sep 2023 22:10:44 +0000 (15:10 -0700)
* 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

index be86072da3bec8ce62834dd742f9fcbcaba1d910..fd718214f516f5cafcf278a75bc21faa7624ea78 100644 (file)
@@ -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;