Subject: bug#32305: mingw vs do_chown in gzip

From: Bdale Garbee <[email-masked]>
Date: Mon, 30 Jul 2018 11:31:50 +0800

Paul Eggert <[email-masked]> writes:

> Yes, that must be it. I installed the attached into gzip master on Savannah; 
> does it fix things for you?

That fixes the compilation of gzip.c, but of course causes a link
failure since it leaves two calls to function do_chown() that is no
longer defined.

The hack I used to build the Debian gzip 1.9-1 upload I did last night
is to conditionally add two bogus typedefs and elide the function
content if __MINGW32__ is defined.  So far, that seems to work ok.  My
patch is attached to this email.

It does feel like an "ugly" approach, but I just got confused trying to
unwind how the configure code which learns there are no *chown()
functions in the mingw environment didn't actually cause the right
things to happen in the build.  Since apparently I'm the first person to
stumble over this since you added do_chown shortly after the gzip 1.6
release, I doubt it's worth much more time from either of us to come up
with a "cleaner" patch...

Feel free to use some or all of my patch, but I am also happy to update
may packaging for Debian if you choose to put more time in this and
develop a better solution. 

Regards,

Bdale

--- gzip-1.9/gzip.c	2018-01-07 13:05:21.000000000 +0800
+++ /tmp/gzip.c	2018-07-29 14:37:00.228844928 +0800
@@ -1910,6 +1910,11 @@
     return OK;
 }
 
+#ifdef __MINGW32__
+typedef int uid_t;
+typedef int gid_t;
+#endif
+
 /* Change the owner and group of a file.  FD is a file descriptor for
    the file and NAME its name.  Change it to user UID and to group GID.
    If UID or GID is -1, though, do not change the corresponding user
@@ -1917,13 +1922,15 @@
 static void
 do_chown (int fd, char const *name, uid_t uid, gid_t gid)
 {
-#ifndef NO_CHOWN
+#ifndef __MINGW32__
+#ifndef NO_CHOWN 
 # if HAVE_FCHOWN
   ignore_value (fchown (fd, uid, gid));
 # else
   ignore_value (chown (name, uid, gid));
 # endif
 #endif
+#endif
 }
 
 /* ========================================================================