- (bal) Build noop setgroups() for cygwin to clean up code (For other
   platforms without the setgroups() requirement, you MUST define
   SETGROUPS_NOOP in the configure.ac) Based on patch by vinschen@redhat.com
diff --git a/ChangeLog b/ChangeLog
index d651601..014950c 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -6,6 +6,9 @@
    - markus@cvs.openbsd.org 2002/06/12 01:09:52
      [ssh.c]
      ssh_connect returns 0 on success
+ - (bal) Build noop setgroups() for cygwin to clean up code (For other
+   platforms without the setgroups() requirement, you MUST define
+   SETGROUPS_NOOP in the configure.ac) Based on patch by vinschen@redhat.com
 
 20020611
  - (bal) ssh-agent.c RCSD fix (|unexpand already done)
@@ -918,4 +921,4 @@
  - (stevesk) entropy.c: typo in debug message
  - (djm) ssh-keygen -i needs seeded RNG; report from markus@
 
-$Id: ChangeLog,v 1.2213 2002/06/12 16:11:12 mouring Exp $
+$Id: ChangeLog,v 1.2214 2002/06/12 16:57:14 mouring Exp $
diff --git a/acconfig.h b/acconfig.h
index bbe5016..713b094 100644
--- a/acconfig.h
+++ b/acconfig.h
@@ -1,4 +1,4 @@
-/* $Id: acconfig.h,v 1.137 2002/05/13 03:15:43 djm Exp $ */
+/* $Id: acconfig.h,v 1.138 2002/06/12 16:57:15 mouring Exp $ */
 
 #ifndef _CONFIG_H
 #define _CONFIG_H
@@ -12,6 +12,9 @@
 /* supported by bsd-setproctitle.c */
 #undef SPT_TYPE
 
+/* setgroups() NOOP allowed */
+#undef SETGROUPS_NOOP
+
 /* SCO workaround */
 #undef BROKEN_SYS_TERMIO_H
 
diff --git a/configure.ac b/configure.ac
index 59d61fd..450e49d 100644
--- a/configure.ac
+++ b/configure.ac
@@ -1,4 +1,4 @@
-# $Id: configure.ac,v 1.65 2002/06/07 14:37:00 mouring Exp $
+# $Id: configure.ac,v 1.66 2002/06/12 16:57:15 mouring Exp $
 
 AC_INIT
 AC_CONFIG_SRCDIR([ssh.c])
@@ -85,6 +85,7 @@
 	AC_DEFINE(IPV4_DEFAULT)
 	AC_DEFINE(IP_TOS_IS_BROKEN)
 	AC_DEFINE(NO_X11_UNIX_SOCKETS)
+	AC_DEFINE(SETGROUPS_NOOP)
 	;;
 *-*-dgux*)
 	AC_DEFINE(IP_TOS_IS_BROKEN)
@@ -569,10 +570,10 @@
 	inet_ntop innetgr login_getcapbool md5_crypt memmove \
 	mkdtemp mmap ngetaddrinfo openpty ogetaddrinfo readpassphrase \
 	realpath recvmsg rresvport_af sendmsg setdtablesize setegid \
-	setenv seteuid setlogin setproctitle setresgid setreuid setrlimit \
-	setsid setvbuf sigaction sigvec snprintf socketpair strerror \
-	strlcat strlcpy strmode strsep sysconf tcgetpgrp truncate utimes \
-	vhangup vsnprintf waitpid __b64_ntop _getpty)
+	setenv seteuid setgroups setlogin setproctitle setresgid setreuid \
+	setrlimit setsid setvbuf sigaction sigvec snprintf socketpair \
+	strerror strlcat strlcpy strmode strsep sysconf tcgetpgrp truncate \
+	utimes vhangup vsnprintf waitpid __b64_ntop _getpty)
 
 dnl IRIX and Solaris 2.5.1 have dirname() in libgen
 AC_CHECK_FUNCS(dirname, [AC_CHECK_HEADERS(libgen.h)] ,[
diff --git a/openbsd-compat/bsd-misc.c b/openbsd-compat/bsd-misc.c
index 237f939..680375c 100644
--- a/openbsd-compat/bsd-misc.c
+++ b/openbsd-compat/bsd-misc.c
@@ -24,7 +24,7 @@
 
 #include "includes.h"
 
-RCSID("$Id: bsd-misc.c,v 1.6 2002/05/08 02:51:32 tim Exp $");
+RCSID("$Id: bsd-misc.c,v 1.7 2002/06/12 16:57:15 mouring Exp $");
 
 char *get_progname(char *argv0)
 {
@@ -118,3 +118,14 @@
 }
 #endif /* HAVE_TRUNCATE */
 
+#if !defined(HAVE_SETGROUPS) && defined(SETGROUPS_NOOP)
+/*
+ * Cygwin setgroups should be a noop.
+ */
+int
+setgroups(size_t size, const git_t *list)
+{
+	return 0;
+}
+#endif 
+
diff --git a/openbsd-compat/bsd-misc.h b/openbsd-compat/bsd-misc.h
index 9475a29..aff2317 100644
--- a/openbsd-compat/bsd-misc.h
+++ b/openbsd-compat/bsd-misc.h
@@ -22,7 +22,7 @@
  * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  */
 
-/* $Id: bsd-misc.h,v 1.4 2002/05/08 02:51:32 tim Exp $ */
+/* $Id: bsd-misc.h,v 1.5 2002/06/12 16:57:15 mouring Exp $ */
 
 #ifndef _BSD_MISC_H
 #define _BSD_MISC_H
@@ -76,4 +76,9 @@
 int truncate (const char *path, off_t length);
 #endif /* HAVE_TRUNCATE */
 
+#if !defined(HAVE_SETGROUPS) && defined(SETGROUPS_NOOP)
+int setgroups(size_t size, const git_t *list);
+#endif
+
+
 #endif /* _BSD_MISC_H */
diff --git a/sshd.c b/sshd.c
index 705d476..9ac43a8 100644
--- a/sshd.c
+++ b/sshd.c
@@ -1018,7 +1018,6 @@
 	if (test_flag)
 		exit(0);
 
-#ifndef HAVE_CYGWIN
 	/*
 	 * Clear out any supplemental groups we may have inherited.  This
 	 * prevents inadvertent creation of files with bad modes (in the
@@ -1028,7 +1027,6 @@
 	 */
 	if (setgroups(0, NULL) < 0)
 		debug("setgroups() failed: %.200s", strerror(errno));
-#endif /* !HAVE_CYGWIN */
 
 	/* Initialize the log (it is reinitialized below in case we forked). */
 	if (debug_flag && !inetd_flag)
diff --git a/uidswap.c b/uidswap.c
index 9377ca4..0a772c7 100644
--- a/uidswap.c
+++ b/uidswap.c
@@ -80,11 +80,9 @@
 		if (user_groupslen < 0)
 			fatal("getgroups: %.100s", strerror(errno));
 	}
-#ifndef HAVE_CYGWIN
 	/* Set the effective uid to the given (unprivileged) uid. */
 	if (setgroups(user_groupslen, user_groups) < 0)
 		fatal("setgroups: %.100s", strerror(errno));
-#endif /* !HAVE_CYGWIN */
 #ifndef SAVED_IDS_WORK_WITH_SETEUID
 	/* Propagate the privileged gid to all of our gids. */
 	if (setgid(getegid()) < 0)
@@ -130,10 +128,8 @@
 	setgid(getgid());
 #endif /* SAVED_IDS_WORK_WITH_SETEUID */
 
-#ifndef HAVE_CYGWIN
 	if (setgroups(saved_egroupslen, saved_egroups) < 0)
 		fatal("setgroups: %.100s", strerror(errno));
-#endif /* !HAVE_CYGWIN */
 	temporarily_use_uid_effective = 0;
 }