- NetBSD patch from David Rankin <drankin@bohemians.lexington.ky.us> and
   Christos Zoulas <christos@netbsd.org>
diff --git a/CREDITS b/CREDITS
index f0be126..ac992e3 100644
--- a/CREDITS
+++ b/CREDITS
@@ -4,7 +4,7 @@
 Theo de Raadt, and Dug Song - Creators of OpenSSH
 
 Andrew Stribblehill <a.d.stribblehill@durham.ac.uk> - Bugfixes
-Andre Lucas <andre.lucas@dial.pipex.com> - Many portability fixes
+Andre Lucas <andre.lucas@dial.pipex.com> - build, login and many other fixes
 Ben Taylor <bent@clark.net> - Solaris debugging and fixes
 Chip Salzenberg <chip@valinux.com> - Assorted patches
 Chris Saia <csaia@wtower.com> - SuSE packaging
diff --git a/ChangeLog b/ChangeLog
index 259f7d8..14005e7 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -6,15 +6,19 @@
    - [sshconnect.c]
      - disable agent fwding for proto 1.3, remove abuse of auth-rsa flags.
      - destroy keys earlier
-     - split key exchange (kex) and user authentication (user-auth), ok: provos@
+     - split key exchange (kex) and user authentication (user-auth), 
+       ok: provos@
    - [sshd.c]
      - no need for poll.h; from bright@wintelcom.net
      - disable agent fwding for proto 1.3, remove abuse of auth-rsa flags.
-     - split key exchange (kex) and user authentication (user-auth), ok: provos@
+     - split key exchange (kex) and user authentication (user-auth), 
+       ok: provos@
  - Big manpage and config file cleanup from Andre Lucas
    <andre.lucas@dial.pipex.com>
    - Re-added latest (unmodified) OpenBSD manpages
  - Doc updates
+ - NetBSD patch from David Rankin <drankin@bohemians.lexington.ky.us> and
+   Christos Zoulas <christos@netbsd.org>
 
 20000119
  - SCO compile fixes from Gary E. Miller <gem@rellim.com>
diff --git a/configure.in b/configure.in
index 90ed2bb..4158b99 100644
--- a/configure.in
+++ b/configure.in
@@ -51,6 +51,31 @@
 
 AC_C_INLINE
 
+dnl Check for OpenSSL/SSLeay directories.
+AC_MSG_CHECKING([for OpenSSL/SSLeay directory])
+for ssldir in $prefix /usr /usr/local/openssl /usr/lib/openssl /usr/local/ssl /usr/lib/ssl /usr/local $prefix /usr/pkg ; do
+	if test -f "$ssldir/include/openssl/crypto.h"; then
+		AC_DEFINE(HAVE_OPENSSL)
+		GOT_SSL="yes"
+		break
+	fi
+	if test -f "$ssldir/include/ssl/crypto.h"; then
+		AC_DEFINE(HAVE_SSL)
+		GOT_SSL="yes"
+		break
+	fi
+done
+if test -z "$GOT_SSL" ; then
+	AC_MSG_ERROR([Could not find SSLeay / OpenSSL libraries, please install])	
+fi
+AC_SUBST(ssldir)
+AC_DEFINE_UNQUOTED(ssldir, "$ssldir")
+if test "$ssldir" != "/usr"; then
+	CFLAGS="$CFLAGS -I$ssldir/include"
+	LDFLAGS="$LDFLAGS -L$ssldir/lib"
+fi
+AC_MSG_RESULT($ssldir)
+
 dnl Check for some target-specific stuff
 case "$host" in
 *-*-aix*)
@@ -87,6 +112,11 @@
 *-*-linux*)
 	no_dev_ptmx=1
 	;;
+*-*-netbsd*)
+	if test "$GOT_SSL" = "yes"; then
+		LDFLAGS="$LDFLAGS -R$ssldir/lib"
+	fi
+	;;
 *-*-solaris*)
 	AC_DEFINE(USE_UTMPX)
 	;;
@@ -95,31 +125,6 @@
 	;;
 esac
 
-dnl Check for OpenSSL/SSLeay directories.
-AC_MSG_CHECKING([for OpenSSL/SSLeay directory])
-for ssldir in $prefix /usr /usr/local/openssl /usr/lib/openssl /usr/local/ssl /usr/lib/ssl /usr/local $prefix /usr/pkg ; do
-	if test -f "$ssldir/include/openssl/crypto.h"; then
-		AC_DEFINE(HAVE_OPENSSL)
-		GOT_SSL="yes"
-		break
-	fi
-	if test -f "$ssldir/include/ssl/crypto.h"; then
-		AC_DEFINE(HAVE_SSL)
-		GOT_SSL="yes"
-		break
-	fi
-done
-if test -z "$GOT_SSL" ; then
-	AC_MSG_ERROR([Could not find SSLeay / OpenSSL libraries, please install])	
-fi
-AC_SUBST(ssldir)
-AC_DEFINE_UNQUOTED(ssldir, "$ssldir")
-if test "$ssldir" != "/usr"; then
-	CFLAGS="$CFLAGS -I$ssldir/include"
-	LDFLAGS="$LDFLAGS -L$ssldir/lib"
-fi
-AC_MSG_RESULT($ssldir)
-
 dnl Check for RSAref library.
 AC_MSG_CHECKING([for RSAref library])
 saved_LIBS="$LIBS"
diff --git a/defines.h b/defines.h
index 3db1d0d..519ebba 100644
--- a/defines.h
+++ b/defines.h
@@ -34,6 +34,10 @@
 # include <sys/cdefs.h> /* For __P() */
 #endif 
 
+#ifdef HAVE_SYS_SYSMACROS_H
+# include <sys/sysmacros.h> /* For MIN, MAX, etc */
+#endif
+
 /* Constants */
 
 #ifndef SHUT_RDWR
diff --git a/log-client.c b/log-client.c
index 4d40cf2..668aaff 100644
--- a/log-client.c
+++ b/log-client.c
@@ -15,7 +15,7 @@
  */
 
 #include "includes.h"
-RCSID("$Id: log-client.c,v 1.3 1999/11/24 13:26:22 damien Exp $");
+RCSID("$Id: log-client.c,v 1.4 2000/01/20 13:18:16 damien Exp $");
 
 #include "xmalloc.h"
 #include "ssh.h"
@@ -45,12 +45,12 @@
 	}
 }
 
-#define MSGBUFSIZE 1024
+#define SSH_MSGBUFSIZE 1024
 
 void
 do_log(LogLevel level, const char *fmt, va_list args)
 {
-	char msgbuf[MSGBUFSIZE];
+	char msgbuf[SSH_MSGBUFSIZE];
 
 	if (level > log_level)
 		return;
diff --git a/log-server.c b/log-server.c
index 34f77b2..2642881 100644
--- a/log-server.c
+++ b/log-server.c
@@ -15,7 +15,7 @@
  */
 
 #include "includes.h"
-RCSID("$Id: log-server.c,v 1.5 1999/11/24 13:26:22 damien Exp $");
+RCSID("$Id: log-server.c,v 1.6 2000/01/20 13:18:16 damien Exp $");
 
 #include <syslog.h>
 #include "packet.h"
@@ -97,13 +97,13 @@
 	log_on_stderr = on_stderr;
 }
 
-#define MSGBUFSIZE 1024
+#define SSH_MSGBUFSIZE 1024
 
 void
 do_log(LogLevel level, const char *fmt, va_list args)
 {
-	char msgbuf[MSGBUFSIZE];
-	char fmtbuf[MSGBUFSIZE];
+	char msgbuf[SSH_MSGBUFSIZE];
+	char fmtbuf[SSH_MSGBUFSIZE];
 	char *txt = NULL;
 	int pri = LOG_INFO;
 
diff --git a/uidswap.c b/uidswap.c
index d81fde9..ca9e28e 100644
--- a/uidswap.c
+++ b/uidswap.c
@@ -7,7 +7,7 @@
  */
 
 #include "includes.h"
-RCSID("$Id: uidswap.c,v 1.3 1999/11/25 00:55:00 damien Exp $");
+RCSID("$Id: uidswap.c,v 1.4 2000/01/20 13:18:16 damien Exp $");
 
 #include "ssh.h"
 #include "uidswap.h"
@@ -25,11 +25,12 @@
 /* Lets assume that posix saved ids also work with seteuid, even though that
    is not part of the posix specification. */
 #define SAVED_IDS_WORK_WITH_SETEUID
-#endif /* _POSIX_SAVED_IDS */
 
 /* Saved effective uid. */
 static uid_t saved_euid = 0;
 
+#endif /* _POSIX_SAVED_IDS */
+
 /*
  * Temporarily changes to the given uid.  If the effective user
  * id is not root, this does nothing.  This call cannot be nested.