- Several patches from SAKAI Kiyotaka <ksakai@kso.netwk.ntt-at.co.jp>
  - INSTALL typo and URL fix
  - Makefile fix
  - Solaris fixes
 - Checking for ssize_t and memmove. Based on patch from SAKAI Kiyotaka
   <ksakai@kso.netwk.ntt-at.co.jp>
diff --git a/CREDITS b/CREDITS
index b8f231c..7ca3f78 100644
--- a/CREDITS
+++ b/CREDITS
@@ -34,6 +34,7 @@
 Juergen Keil <jk@tools.de> - scp bugfixing
 Kees Cook <cook@cpoint.net> - scp fixes
 Kiyokazu SUTO <suto@ks-and-ks.ne.jp> - Bugfixes
+Lutz Jaenicke <Lutz.Jaenicke@aet.TU-Cottbus.DE> - Bugfixes
 Marc G. Fournier <marc.fournier@acadiau.ca> - Solaris patches
 Matt Richards <v2matt@btv.ibm.com> - AIX patches
 Nalin Dahyabhai <nalin.dahyabhai@pobox.com> - PAM environment patch
@@ -41,7 +42,10 @@
 Peter Kocks <peter.kocks@baygate.com> - Makefile fixes
 Phil Hands <phil@hands.com> - Debian scripts, assorted patches
 Phil Karn <karn@ka9q.ampr.org> - Autoconf fix
+SAKAI Kiyotaka <ksakai@kso.netwk.ntt-at.co.jp> - Multiple bugfixes
+Simon Wilkinson <sxw@dcs.ed.ac.uk> - PAM fixes
 Thomas Neumann <tom@smart.ruhr.de> - Shadow passwords
+Tom Bertelson's <tbert@abac.com> - AIX auth fixes
 Tor-Ake Fransson <torake@hotmail.com> - AIX support
 Tudor Bosman <tudorb@jm.nu> - MD5 password support
 
diff --git a/ChangeLog b/ChangeLog
index e14392a..8cefa0f 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -25,6 +25,12 @@
     enable nonblocking IO for sshd w/ proto 1, too; split out common code
     [aux.c]
     missing include
+ - Several patches from SAKAI Kiyotaka <ksakai@kso.netwk.ntt-at.co.jp>
+  - INSTALL typo and URL fix
+  - Makefile fix
+  - Solaris fixes
+ - Checking for ssize_t and memmove. Based on patch from SAKAI Kiyotaka 
+   <ksakai@kso.netwk.ntt-at.co.jp>
 
 20000513
  - Fix for non-recognised DSA keys from Arkadiusz Miskiewicz 
diff --git a/INSTALL b/INSTALL
index bf7bc13..dc8cee0 100644
--- a/INSTALL
+++ b/INSTALL
@@ -4,7 +4,7 @@
 You will need working installations of Zlib and OpenSSL.
 
 Zlib:
-http://www.cdrom.com/pub/infozip/zlib/
+http://www.freesoftware.com/pub/infozip/zlib/
 
 OpenSSL 0.9.5a or greater:
 http://www.openssl.org/
@@ -90,7 +90,7 @@
 headers, for this to work.
 
 --with-random=/some/file allows you to specify an alternate source of
-random numbers (the default is /dev/urandom). Unless you are absolutly
+random numbers (the default is /dev/urandom). Unless you are absolutely
 sure of what you are doing, it is best to leave this alone.
 
 --with-egd-pool=/some/file allows you to enable Entropy Gathering
@@ -152,7 +152,7 @@
 real (AF_INET) IPv4 addresses. Works around some quirks on Linux.
 
 If you need to pass special options to the compiler or linker, you
-can specify these as enviornment variables before running ./configure.
+can specify these as environment variables before running ./configure.
 For example:
 
 CFLAGS="-O -m486" LFLAGS="-s" LIBS="-lrubbish" LD="/usr/foo/ld" ./configure
@@ -186,5 +186,5 @@
 
 If you experience problems compiling, installing or running OpenSSH. 
 Please refer to the "reporting bugs" section of the webpage at
-http://violet.ibs.com.au/openssh/
+http://www.openssh.com/
 
diff --git a/Makefile.in b/Makefile.in
index 3aeced9..0dc71c6 100644
--- a/Makefile.in
+++ b/Makefile.in
@@ -90,11 +90,11 @@
 	$(FIXPATHSCMD) $(srcdir)/$@
 
 clean:
-	rm -f *.o *.a $(TARGETS) config.status config.cache config.log 
-	rm -f *.out ssh_prng_cmds core
+	rm -f *.o *.a $(TARGETS) config.cache config.log 
+	rm -f *.out core
 
 distclean: clean
-	rm -f Makefile config.h core *~
+	rm -f Makefile config.h config.status ssh_prng_cmds *~
 
 mrproper: distclean
 
diff --git a/acconfig.h b/acconfig.h
index 4f5f48f..9a2c1af 100644
--- a/acconfig.h
+++ b/acconfig.h
@@ -117,6 +117,7 @@
 #undef HAVE_UINTXX_T
 #undef HAVE_SOCKLEN_T
 #undef HAVE_SIZE_T
+#undef HAVE_SSIZE_T
 #undef HAVE_STRUCT_SOCKADDR_STORAGE
 #undef HAVE_STRUCT_ADDRINFO
 #undef HAVE_STRUCT_IN6_ADDR
diff --git a/bsd-login.c b/bsd-login.c
index 910f9ff..6a80928 100644
--- a/bsd-login.c
+++ b/bsd-login.c
@@ -73,6 +73,7 @@
 	int t = 0;
 	struct utmp * u;
 
+#ifdef HAVE_TYPE_IN_UTMP
 	setutent();
 
 	while((u = getutent()) != NULL) {
@@ -91,6 +92,7 @@
 	}
 
 	endutent();
+#endif
 	return(-1);
 }
 
@@ -128,6 +130,7 @@
 		/* If no tty was found... */
 		if (tty == -1) {
 			/* ... append it to utmp on login */
+#ifdef HAVE_TYPE_IN_UTMP
 			if (utp->ut_type == USER_PROCESS) {
 				if ((fd = open(_PATH_UTMP, O_WRONLY|O_APPEND, 0)) >= 0) {
 					(void)write(fd, utp, sizeof(struct utmp));
@@ -138,6 +141,7 @@
 				/* Between login and logout */
 				log("No tty slot found at logout");
 			}
+#endif
 		} else {
 			/* Otherwise, tty was found - update at its location */
 #if defined(HAVE_HOST_IN_UTMP)
diff --git a/configure.in b/configure.in
index 62456ac..548d272 100644
--- a/configure.in
+++ b/configure.in
@@ -135,7 +135,7 @@
 AC_CHECK_HEADERS(bstring.h endian.h lastlog.h login.h maillock.h netdb.h netgroup.h netinet/in_systm.h paths.h poll.h pty.h shadow.h security/pam_appl.h sys/bitypes.h sys/bsdtty.h sys/cdefs.h sys/poll.h sys/select.h sys/stropts.h sys/sysmacros.h sys/time.h sys/ttcompat.h stddef.h util.h utmp.h utmpx.h)
 
 # Checks for library functions.
-AC_CHECK_FUNCS(arc4random b64_ntop bindresvport_af clock freeaddrinfo gai_strerror getaddrinfo getnameinfo getrusage innetgr md5_crypt mkdtemp openpty rresvport_af setenv seteuid setlogin setproctitle setreuid snprintf strlcat strlcpy updwtmpx vsnprintf vhangup _getpty __b64_ntop)
+AC_CHECK_FUNCS(arc4random b64_ntop bcopy bindresvport_af clock freeaddrinfo gai_strerror getaddrinfo getnameinfo getrusage innetgr md5_crypt memmove mkdtemp openpty rresvport_af setenv seteuid setlogin setproctitle setreuid snprintf strlcat strlcpy updwtmpx vsnprintf vhangup _getpty __b64_ntop)
 
 AC_CHECK_FUNC(login, 
 	[AC_DEFINE(HAVE_LOGIN)],
@@ -381,6 +381,20 @@
 	AC_DEFINE(HAVE_SIZE_T)
 fi
 
+AC_CACHE_CHECK([for ssize_t], ac_cv_have_ssize_t, [
+	AC_TRY_COMPILE(
+		[
+#include <sys/types.h>
+		],
+		[ ssize_t foo; foo = 1235; ],
+		[ ac_cv_have_ssize_t="yes" ],
+		[ ac_cv_have_ssize_t="no" ]
+	)
+])
+if test "x$ac_cv_have_ssize_t" = "xyes" ; then
+	AC_DEFINE(HAVE_SSIZE_T)
+fi
+
 
 AC_CACHE_CHECK([for struct sockaddr_storage], ac_cv_have_struct_sockaddr_storage, [
 	AC_TRY_COMPILE(
diff --git a/defines.h b/defines.h
index 9490e77..5eddf2e 100644
--- a/defines.h
+++ b/defines.h
@@ -150,6 +150,11 @@
 # define HAVE_SIZE_T
 #endif /* HAVE_SIZE_T */
 
+#ifndef HAVE_SSIZE_T
+typedef int ssize_t;
+# define HAVE_SSIZE_T
+#endif /* HAVE_SSIZE_T */
+
 #if !defined(HAVE_SS_FAMILY_IN_SS) && defined(HAVE___SS_FAMILY_IN_SS)
 # define ss_family __ss_family
 #endif /* !defined(HAVE_SS_FAMILY_IN_SS) && defined(HAVE_SA_FAMILY_IN_SS) */
@@ -216,6 +221,10 @@
 # define _PATH_DEVNULL "/dev/null"
 #endif
 
+#ifndef MAIL_DIRECTORY
+# define MAIL_DIRECTORY "/var/spool/mail"
+#endif
+
 #ifndef MAILDIR
 # define MAILDIR MAIL_DIRECTORY
 #endif
@@ -280,4 +289,8 @@
 # undef HAVE_GETADDRINFO
 #endif /* defined(BROKEN_GETADDRINFO) && defined(HAVE_GETADDRINFO) */
 
+#if !defined(HAVE_MEMMOVE) && defined(HAVE_BCOPY)
+# define memmove(s1, s2, n) bcopy((s2), (s1), (n))
+#endif /* !defined(HAVE_MEMMOVE) && defined(HAVE_BCOPY) */
+
 #endif /* _DEFINES_H */
diff --git a/packet.c b/packet.c
index dfe21fa..fd7a322 100644
--- a/packet.c
+++ b/packet.c
@@ -17,7 +17,7 @@
  */
 
 #include "includes.h"
-RCSID("$Id: packet.c,v 1.22 2000/05/07 02:03:17 damien Exp $");
+RCSID("$Id: packet.c,v 1.23 2000/05/17 12:53:35 damien Exp $");
 
 #include "xmalloc.h"
 #include "buffer.h"
@@ -1237,10 +1237,12 @@
 		 * Set IP options for an interactive connection.  Use
 		 * IPTOS_LOWDELAY and TCP_NODELAY.
 		 */
+#ifdef IP_TOS
 		int lowdelay = IPTOS_LOWDELAY;
 		if (setsockopt(connection_in, IPPROTO_IP, IP_TOS, (void *) &lowdelay,
 		    sizeof(lowdelay)) < 0)
 			error("setsockopt IPTOS_LOWDELAY: %.100s", strerror(errno));
+#endif
 		if (setsockopt(connection_in, IPPROTO_TCP, TCP_NODELAY, (void *) &on,
 		    sizeof(on)) < 0)
 			error("setsockopt TCP_NODELAY: %.100s", strerror(errno));
@@ -1249,10 +1251,12 @@
 		 * Set IP options for a non-interactive connection.  Use
 		 * IPTOS_THROUGHPUT.
 		 */
+#ifdef IP_TOS
 		int throughput = IPTOS_THROUGHPUT;
 		if (setsockopt(connection_in, IPPROTO_IP, IP_TOS, (void *) &throughput,
 		    sizeof(throughput)) < 0)
 			error("setsockopt IPTOS_THROUGHPUT: %.100s", strerror(errno));
+#endif
 	}
 }
 
diff --git a/scp.c b/scp.c
index 2831f9b..19f0fd9 100644
--- a/scp.c
+++ b/scp.c
@@ -45,7 +45,7 @@
  */
 
 #include "includes.h"
-RCSID("$Id: scp.c,v 1.22 2000/05/07 02:03:17 damien Exp $");
+RCSID("$Id: scp.c,v 1.23 2000/05/17 12:53:35 damien Exp $");
 
 #include "ssh.h"
 #include "xmalloc.h"
@@ -1008,7 +1008,7 @@
  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  * SUCH DAMAGE.
  *
- *	$Id: scp.c,v 1.22 2000/05/07 02:03:17 damien Exp $
+ *	$Id: scp.c,v 1.23 2000/05/17 12:53:35 damien Exp $
  */
 
 char *
@@ -1235,7 +1235,9 @@
 		struct sigaction sa;
 		sa.sa_handler = updateprogressmeter;
 		sigemptyset(&sa.sa_mask);
+#ifdef SA_RESTART
 		sa.sa_flags = SA_RESTART;
+#endif
 		sigaction(SIGALRM, &sa, NULL);
 		alarmtimer(1);
 	} else if (flag == 1) {
diff --git a/ssh-agent.c b/ssh-agent.c
index 30d99b9..7bfa290 100644
--- a/ssh-agent.c
+++ b/ssh-agent.c
@@ -507,6 +507,7 @@
 	struct sockaddr_un sunaddr;
 	pid_t pid;
 	char *shell, *format, *pidstr, pidstrbuf[1 + 3 * sizeof pid];
+	extern int optind;
 
 	/* check if RSA support exists */
 	if (rsa_alive() == 0) {