- (djm) [acss.c auth-krb5.c auth-options.c auth-pam.c auth-shadow.c]
   [canohost.c channels.c cipher-acss.c defines.h dns.c gss-genr.c]
   [gss-serv-krb5.c gss-serv.c log.h loginrec.c logintest.c readconf.c]
   [servconf.c ssh-keygen.c ssh-keyscan.c ssh-keysign.c ssh-rand-helper.c]
   [ssh.c sshconnect.c sshd.c openbsd-compat/bindresvport.c]
   [openbsd-compat/bsd-arc4random.c openbsd-compat/bsd-misc.c]
   [openbsd-compat/getrrsetbyname.c openbsd-compat/glob.c]
   [openbsd-compat/mktemp.c openbsd-compat/port-linux.c]
   [openbsd-compat/port-tun.c openbsd-compat/readpassphrase.c]
   [openbsd-compat/setproctitle.c openbsd-compat/xmmap.c]
   make the portable tree compile again - sprinkle unistd.h and string.h
   back in. Don't redefine __unused, as it turned out to be used in
   headers on Linux, and replace its use in auth-pam.c with ARGSUSED
diff --git a/ChangeLog b/ChangeLog
index 7f76794..d2cd9b5 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -99,6 +99,19 @@
      [auth.h dispatch.c kex.h sftp-client.c]
      #include <signal.h> for sig_atomic_t; need this prior to <sys/param.h>
      move
+ - (djm) [acss.c auth-krb5.c auth-options.c auth-pam.c auth-shadow.c]
+   [canohost.c channels.c cipher-acss.c defines.h dns.c gss-genr.c]
+   [gss-serv-krb5.c gss-serv.c log.h loginrec.c logintest.c readconf.c]
+   [servconf.c ssh-keygen.c ssh-keyscan.c ssh-keysign.c ssh-rand-helper.c]
+   [ssh.c sshconnect.c sshd.c openbsd-compat/bindresvport.c]
+   [openbsd-compat/bsd-arc4random.c openbsd-compat/bsd-misc.c]
+   [openbsd-compat/getrrsetbyname.c openbsd-compat/glob.c]
+   [openbsd-compat/mktemp.c openbsd-compat/port-linux.c]
+   [openbsd-compat/port-tun.c openbsd-compat/readpassphrase.c]
+   [openbsd-compat/setproctitle.c openbsd-compat/xmmap.c]
+   make the portable tree compile again - sprinkle unistd.h and string.h 
+   back in. Don't redefine __unused, as it turned out to be used in
+   headers on Linux, and replace its use in auth-pam.c with ARGSUSED
 
 20060713
  - (dtucker) [auth-krb5.c auth-pam.c] Still more errno.h
@@ -5017,4 +5030,4 @@
    - (djm) Trim deprecated options from INSTALL. Mention UsePAM
    - (djm) Fix quote handling in sftp; Patch from admorten AT umich.edu
 
-$Id: ChangeLog,v 1.4429 2006/07/24 04:14:19 djm Exp $
+$Id: ChangeLog,v 1.4430 2006/07/24 04:51:00 djm Exp $
diff --git a/acss.c b/acss.c
index 99efde0..86e2c01 100644
--- a/acss.c
+++ b/acss.c
@@ -1,4 +1,4 @@
-/*	$Id: acss.c,v 1.3 2005/07/17 07:04:47 djm Exp $ */
+/*	$Id: acss.c,v 1.4 2006/07/24 04:51:01 djm Exp $ */
 /*
  * Copyright (c) 2004 The OpenBSD project
  *
@@ -16,6 +16,9 @@
  */
 
 #include "includes.h"
+
+#include <string.h>
+
 #include <openssl/evp.h>
 
 #if !defined(EVP_CTRL_SET_ACSS_MODE) && (OPENSSL_VERSION_NUMBER >= 0x00906000L)
diff --git a/auth-krb5.c b/auth-krb5.c
index 8beacc0..676b8ab 100644
--- a/auth-krb5.c
+++ b/auth-krb5.c
@@ -41,6 +41,8 @@
 
 #ifdef KRB5
 #include <errno.h>
+#include <unistd.h>
+#include <string.h>
 #include <krb5.h>
 
 extern ServerOptions	 options;
diff --git a/auth-options.c b/auth-options.c
index 33c6264..cd90496 100644
--- a/auth-options.c
+++ b/auth-options.c
@@ -14,9 +14,7 @@
 
 #include <sys/types.h>
 
-#if defined(HAVE_NETDB_H)
-# include <netdb.h>
-#endif
+#include <netdb.h>
 #include <pwd.h>
 #include <string.h>
 
diff --git a/auth-pam.c b/auth-pam.c
index cb8754e..6ce9db1 100644
--- a/auth-pam.c
+++ b/auth-pam.c
@@ -54,6 +54,8 @@
 
 #include <errno.h>
 #include <signal.h>
+#include <string.h>
+#include <unistd.h>
 
 #ifdef USE_PAM
 #if defined(HAVE_SECURITY_PAM_APPL_H)
@@ -152,14 +154,16 @@
 		fatal("PAM: authentication thread exited uncleanly");
 }
 
+/* ARGSUSED */
 static void
-pthread_exit(void *value __unused)
+pthread_exit(void *value)
 {
 	_exit(0);
 }
 
+/* ARGSUSED */
 static int
-pthread_create(sp_pthread_t *thread, const void *attr __unused,
+pthread_create(sp_pthread_t *thread, const void *attr,
     void *(*thread_start)(void *), void *arg)
 {
 	pid_t pid;
@@ -191,8 +195,9 @@
 	return (kill(thread, SIGTERM));
 }
 
+/* ARGSUSED */
 static int
-pthread_join(sp_pthread_t thread, void **value __unused)
+pthread_join(sp_pthread_t thread, void **value)
 {
 	int status;
 
diff --git a/auth-shadow.c b/auth-shadow.c
index c8d5dd3..7cd69c2 100644
--- a/auth-shadow.c
+++ b/auth-shadow.c
@@ -26,6 +26,7 @@
 
 #if defined(USE_SHADOW) && defined(HAS_SHADOW_EXPIRE)
 #include <shadow.h>
+#include <string.h>
 
 #include "auth.h"
 #include "buffer.h"
diff --git a/canohost.c b/canohost.c
index 97b5a78..b40cbf6 100644
--- a/canohost.c
+++ b/canohost.c
@@ -21,9 +21,7 @@
 
 #include <ctype.h>
 #include <errno.h>
-#if defined(HAVE_NETDB_H)
-# include <netdb.h>
-#endif
+#include <netdb.h>
 #include <string.h>
 
 #include "packet.h"
diff --git a/channels.c b/channels.c
index 8cf4242..895c43f 100644
--- a/channels.c
+++ b/channels.c
@@ -50,9 +50,7 @@
 #include <arpa/inet.h>
 
 #include <errno.h>
-#if defined(HAVE_NETDB_H)
-# include <netdb.h>
-#endif
+#include <netdb.h>
 #include <string.h>
 #include <termios.h>
 #include <unistd.h>
diff --git a/cipher-acss.c b/cipher-acss.c
index 90b51a4..cb0bf73 100644
--- a/cipher-acss.c
+++ b/cipher-acss.c
@@ -15,8 +15,11 @@
  */
 
 #include "includes.h"
+
 #include <openssl/evp.h>
 
+#include <string.h>
+
 #if !defined(EVP_CTRL_SET_ACSS_MODE) && (OPENSSL_VERSION_NUMBER >= 0x00907000L)
 
 #include "acss.h"
diff --git a/defines.h b/defines.h
index 4dccc91..7b0a302 100644
--- a/defines.h
+++ b/defines.h
@@ -25,7 +25,7 @@
 #ifndef _DEFINES_H
 #define _DEFINES_H
 
-/* $Id: defines.h,v 1.133 2006/07/12 04:14:31 dtucker Exp $ */
+/* $Id: defines.h,v 1.134 2006/07/24 04:51:01 djm Exp $ */
 
 
 /* Constants */
@@ -143,16 +143,11 @@
 #define INADDR_LOOPBACK ((u_long)0x7f000001)
 #endif
 
-#ifndef __unused
-#define __unused
-#endif
-
 /* Types */
 
 /* If sys/types.h does not supply intXX_t, supply them ourselves */
 /* (or die trying) */
 
-
 #ifndef HAVE_U_INT
 typedef unsigned int u_int;
 #endif
diff --git a/dns.c b/dns.c
index 5f123a2..c9368b9 100644
--- a/dns.c
+++ b/dns.c
@@ -30,9 +30,7 @@
 #include <sys/types.h>
 #include <sys/socket.h>
 
-#if defined(HAVE_NETDB_H)
-# include <netdb.h>
-#endif
+#include <netdb.h>
 #include <string.h>
 
 #include "xmalloc.h"
diff --git a/gss-genr.c b/gss-genr.c
index 0497657..522feda 100644
--- a/gss-genr.c
+++ b/gss-genr.c
@@ -29,6 +29,7 @@
 #ifdef GSSAPI
 
 #include <string.h>
+#include <unistd.h>
 
 #include "xmalloc.h"
 #include "bufaux.h"
diff --git a/gss-serv-krb5.c b/gss-serv-krb5.c
index eae29b2..7b78cfe 100644
--- a/gss-serv-krb5.c
+++ b/gss-serv-krb5.c
@@ -29,6 +29,8 @@
 #ifdef GSSAPI
 #ifdef KRB5
 
+#include <string.h>
+
 #include "auth.h"
 #include "xmalloc.h"
 #include "log.h"
diff --git a/gss-serv.c b/gss-serv.c
index c033aad..b5c5538 100644
--- a/gss-serv.c
+++ b/gss-serv.c
@@ -29,6 +29,7 @@
 #ifdef GSSAPI
 
 #include <string.h>
+#include <unistd.h>
 
 #include "bufaux.h"
 #include "auth.h"
diff --git a/log.h b/log.h
index 9e1a2fc..15ebc93 100644
--- a/log.h
+++ b/log.h
@@ -15,6 +15,8 @@
 #ifndef SSH_LOG_H
 #define SSH_LOG_H
 
+#include "includes.h"
+
 #include <stdarg.h>
 
 #include <syslog.h> /* Needed for LOG_AUTHPRIV (if present) */
diff --git a/loginrec.c b/loginrec.c
index 8299b79..955d42e 100644
--- a/loginrec.c
+++ b/loginrec.c
@@ -156,6 +156,8 @@
 #include <errno.h>
 #include <fcntl.h>
 #include <pwd.h>
+#include <string.h>
+#include <unistd.h>
 
 #include "ssh.h"
 #include "xmalloc.h"
diff --git a/logintest.c b/logintest.c
index 0de928b..7e9fbbf 100644
--- a/logintest.c
+++ b/logintest.c
@@ -40,9 +40,7 @@
 #include <stdio.h>
 #include <string.h>
 #include <pwd.h>
-#if defined(HAVE_NETDB_H)
-# include <netdb.h>
-#endif
+#include <netdb.h>
 #ifdef HAVE_TIME_H
 #include <time.h>
 #endif
diff --git a/openbsd-compat/bindresvport.c b/openbsd-compat/bindresvport.c
index 2c16233..ef0eff3 100644
--- a/openbsd-compat/bindresvport.c
+++ b/openbsd-compat/bindresvport.c
@@ -37,6 +37,7 @@
 #include "includes.h"
 
 #include <errno.h>
+#include <string.h>
 
 #define STARTPORT 600
 #define ENDPORT (IPPORT_RESERVED - 1)
diff --git a/openbsd-compat/bsd-arc4random.c b/openbsd-compat/bsd-arc4random.c
index 46e0a02..c1aecfe 100644
--- a/openbsd-compat/bsd-arc4random.c
+++ b/openbsd-compat/bsd-arc4random.c
@@ -15,6 +15,10 @@
  */
 
 #include "includes.h"
+
+#include <sys/types.h>
+#include <string.h>
+
 #include "log.h"
 
 #ifndef HAVE_ARC4RANDOM
diff --git a/openbsd-compat/bsd-misc.c b/openbsd-compat/bsd-misc.c
index d2d9ad7..e6128f9 100644
--- a/openbsd-compat/bsd-misc.c
+++ b/openbsd-compat/bsd-misc.c
@@ -17,6 +17,7 @@
 
 #include "includes.h"
 
+#include <string.h>
 #include <signal.h>
 
 #include "xmalloc.h"
diff --git a/openbsd-compat/getrrsetbyname.c b/openbsd-compat/getrrsetbyname.c
index a855ad6..70ef185 100644
--- a/openbsd-compat/getrrsetbyname.c
+++ b/openbsd-compat/getrrsetbyname.c
@@ -49,6 +49,8 @@
 
 #ifndef HAVE_GETRRSETBYNAME
 
+#include <string.h>
+
 #include "getrrsetbyname.h"
 
 #if defined(HAVE_DECL_H_ERRNO) && !HAVE_DECL_H_ERRNO
diff --git a/openbsd-compat/glob.c b/openbsd-compat/glob.c
index bba4c09..b487393 100644
--- a/openbsd-compat/glob.c
+++ b/openbsd-compat/glob.c
@@ -41,6 +41,8 @@
 #include <ctype.h>
 #include <errno.h>
 #include <pwd.h>
+#include <string.h>
+#include <unistd.h>
 
 static long
 get_arg_max(void)
diff --git a/openbsd-compat/mktemp.c b/openbsd-compat/mktemp.c
index b8b0793..2285c84 100644
--- a/openbsd-compat/mktemp.c
+++ b/openbsd-compat/mktemp.c
@@ -41,6 +41,7 @@
 #include <fcntl.h>
 #include <ctype.h>
 #include <errno.h>
+#include <unistd.h>
 
 #if !defined(HAVE_MKDTEMP) || defined(HAVE_STRICT_MKSTEMP)
 
diff --git a/openbsd-compat/port-linux.c b/openbsd-compat/port-linux.c
index 54ec291..5e2e878 100644
--- a/openbsd-compat/port-linux.c
+++ b/openbsd-compat/port-linux.c
@@ -1,4 +1,4 @@
-/* $Id: port-linux.c,v 1.1 2006/04/22 11:26:08 djm Exp $ */
+/* $Id: port-linux.c,v 1.2 2006/07/24 04:51:01 djm Exp $ */
 
 /*
  * Copyright (c) 2005 Daniel Walsh <dwalsh@redhat.com>
@@ -23,6 +23,9 @@
 
 #include "includes.h"
 
+#include <errno.h>
+#include <string.h>
+
 #ifdef WITH_SELINUX
 #include "log.h"
 #include "port-linux.h"
diff --git a/openbsd-compat/port-tun.c b/openbsd-compat/port-tun.c
index 9806eec..f6a6aa9 100644
--- a/openbsd-compat/port-tun.c
+++ b/openbsd-compat/port-tun.c
@@ -23,6 +23,8 @@
 
 #include <errno.h>
 #include <fcntl.h>
+#include <string.h>
+#include <unistd.h>
 
 #include "log.h"
 #include "misc.h"
diff --git a/openbsd-compat/readpassphrase.c b/openbsd-compat/readpassphrase.c
index fd9731a..11bd8f6 100644
--- a/openbsd-compat/readpassphrase.c
+++ b/openbsd-compat/readpassphrase.c
@@ -32,6 +32,8 @@
 #include <fcntl.h>
 #include <readpassphrase.h>
 #include <errno.h>
+#include <string.h>
+#include <unistd.h>
 
 #ifdef TCSASOFT
 # define _T_FLUSH	(TCSAFLUSH|TCSASOFT)
diff --git a/openbsd-compat/setproctitle.c b/openbsd-compat/setproctitle.c
index 32e987d..7fec73f 100644
--- a/openbsd-compat/setproctitle.c
+++ b/openbsd-compat/setproctitle.c
@@ -40,6 +40,7 @@
 #ifdef HAVE_SYS_PSTAT_H
 #include <sys/pstat.h>
 #endif
+#include <string.h>
 
 #define SPT_NONE	0	/* don't use it at all */
 #define SPT_PSTAT	1	/* use pstat(PSTAT_SETCMD, ...) */
diff --git a/openbsd-compat/xmmap.c b/openbsd-compat/xmmap.c
index 7d5cc81..1293dca 100644
--- a/openbsd-compat/xmmap.c
+++ b/openbsd-compat/xmmap.c
@@ -23,7 +23,7 @@
  * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  */
 
-/* $Id: xmmap.c,v 1.8 2006/07/12 12:35:52 dtucker Exp $ */
+/* $Id: xmmap.c,v 1.9 2006/07/24 04:51:01 djm Exp $ */
 
 #include "includes.h"
 
@@ -34,6 +34,8 @@
 #include <sys/stat.h>
 
 #include <errno.h>
+#include <string.h>
+#include <unistd.h>
 
 #include "log.h"
 
diff --git a/readconf.c b/readconf.c
index 432b80e..6fe3727 100644
--- a/readconf.c
+++ b/readconf.c
@@ -22,9 +22,7 @@
 
 #include <ctype.h>
 #include <errno.h>
-#if defined(HAVE_NETDB_H)
-# include <netdb.h>
-#endif
+#include <netdb.h>
 #include <string.h>
 #include <unistd.h>
 
diff --git a/servconf.c b/servconf.c
index ce44b5f..dca9508 100644
--- a/servconf.c
+++ b/servconf.c
@@ -15,9 +15,7 @@
 #include <sys/types.h>
 #include <sys/socket.h>
 
-#if defined(HAVE_NETDB_H)
-# include <netdb.h>
-#endif
+#include <netdb.h>
 #include <string.h>
 #include <unistd.h>
 
diff --git a/ssh-keygen.c b/ssh-keygen.c
index f2d3712..17236a5 100644
--- a/ssh-keygen.c
+++ b/ssh-keygen.c
@@ -23,9 +23,7 @@
 
 #include <errno.h>
 #include <fcntl.h>
-#if defined(HAVE_NETDB_H)
-# include <netdb.h>
-#endif
+#include <netdb.h>
 #ifdef HAVE_PATHS_H
 # include <paths.h>
 #endif
diff --git a/ssh-keyscan.c b/ssh-keyscan.c
index 30df751..6b706f0 100644
--- a/ssh-keyscan.c
+++ b/ssh-keyscan.c
@@ -14,9 +14,7 @@
 
 #include <openssl/bn.h>
 
-#if defined(HAVE_NETDB_H)
-# include <netdb.h>
-#endif
+#include <netdb.h>
 #include <errno.h>
 #include <stdarg.h>
 #include <setjmp.h>
diff --git a/ssh-keysign.c b/ssh-keysign.c
index 435b839..89b8e43 100644
--- a/ssh-keysign.c
+++ b/ssh-keysign.c
@@ -148,7 +148,7 @@
 {
 	Buffer b;
 	Options options;
-	Key *keys[2], *key;
+	Key *keys[2], *key = NULL;
 	struct passwd *pw;
 	int key_fd[2], i, found, version = 2, fd;
 	u_char *signature, *data;
diff --git a/ssh-rand-helper.c b/ssh-rand-helper.c
index fb6fc28..121fa52 100644
--- a/ssh-rand-helper.c
+++ b/ssh-rand-helper.c
@@ -41,6 +41,8 @@
 #include <fcntl.h>
 #include <pwd.h>
 #include <signal.h>
+#include <time.h>
+#include <unistd.h>
 
 #include <openssl/rand.h>
 #include <openssl/sha.h>
diff --git a/ssh.c b/ssh.c
index d0d9457..df787e4 100644
--- a/ssh.c
+++ b/ssh.c
@@ -54,9 +54,7 @@
 #include <ctype.h>
 #include <errno.h>
 #include <fcntl.h>
-#if defined(HAVE_NETDB_H)
-# include <netdb.h>
-#endif
+#include <netdb.h>
 #ifdef HAVE_PATHS_H
 #include <paths.h>
 #endif
diff --git a/sshconnect.c b/sshconnect.c
index f33cf52..21c5203 100644
--- a/sshconnect.c
+++ b/sshconnect.c
@@ -24,9 +24,7 @@
 
 #include <ctype.h>
 #include <errno.h>
-#if defined(HAVE_NETDB_H)
-# include <netdb.h>
-#endif
+#include <netdb.h>
 #ifdef HAVE_PATHS_H
 #include <paths.h>
 #endif
diff --git a/sshd.c b/sshd.c
index 6428f42..cc1ebd8 100644
--- a/sshd.c
+++ b/sshd.c
@@ -54,9 +54,7 @@
 
 #include <errno.h>
 #include <fcntl.h>
-#if defined(HAVE_NETDB_H)
-# include <netdb.h>
-#endif
+#include <netdb.h>
 #ifdef HAVE_PATHS_H
 #include <paths.h>
 #endif