- markus@cvs.openbsd.org 2001/10/09 10:12:08
     [session.c]
     chdir $HOME after krb_afslog(); from bbense@networking.stanford.edu
diff --git a/ChangeLog b/ChangeLog
index e208f88..c0e076e 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -31,6 +31,12 @@
    - markus@cvs.openbsd.org 2001/10/08 16:15:47
      [sshconnect.c]
      use correct family for -b option
+   - markus@cvs.openbsd.org 2001/10/08 19:05:05
+     [ssh.c sshconnect.c sshconnect.h ssh-keyscan.c]
+     some more IPv4or6 cleanup
+   - markus@cvs.openbsd.org 2001/10/09 10:12:08
+     [session.c]
+     chdir $HOME after krb_afslog(); from bbense@networking.stanford.edu
 
 20011007
  - (bal) ssh-copy-id corrected permissions for .ssh/ and authorized_keys.
@@ -6676,4 +6682,4 @@
  - Wrote replacements for strlcpy and mkdtemp
  - Released 1.0pre1
 
-$Id: ChangeLog,v 1.1594 2001/10/10 05:04:41 djm Exp $
+$Id: ChangeLog,v 1.1595 2001/10/10 05:07:44 djm Exp $
diff --git a/session.c b/session.c
index b891431..0e3e933 100644
--- a/session.c
+++ b/session.c
@@ -33,7 +33,7 @@
  */
 
 #include "includes.h"
-RCSID("$OpenBSD: session.c,v 1.103 2001/10/06 00:36:42 markus Exp $");
+RCSID("$OpenBSD: session.c,v 1.104 2001/10/09 10:12:08 markus Exp $");
 
 #include "ssh.h"
 #include "ssh1.h"
@@ -1342,16 +1342,6 @@
 	for (i = 3; i < 64; i++)
 		close(i);
 
-	/* Change current directory to the user\'s home directory. */
-	if (chdir(pw->pw_dir) < 0) {
-		fprintf(stderr, "Could not chdir to home directory %s: %s\n",
-			pw->pw_dir, strerror(errno));
-#ifdef HAVE_LOGIN_CAP
-		if (login_getcapbool(lc, "requirehome", 0))
-			exit(1);
-#endif
-	}
-
 	/*
 	 * Must take new environment into use so that .ssh/rc, /etc/sshrc and
 	 * xauth are run in the proper environment.
@@ -1370,6 +1360,16 @@
 	}
 #endif /* AFS */
 
+	/* Change current directory to the user\'s home directory. */
+	if (chdir(pw->pw_dir) < 0) {
+		fprintf(stderr, "Could not chdir to home directory %s: %s\n",
+		    pw->pw_dir, strerror(errno));
+#ifdef HAVE_LOGIN_CAP
+		if (login_getcapbool(lc, "requirehome", 0))
+			exit(1);
+#endif
+	}
+
 	/*
 	 * Run $HOME/.ssh/rc, /etc/sshrc, or xauth (whichever is found first
 	 * in this order).
diff --git a/ssh-keyscan.c b/ssh-keyscan.c
index 1849c33..c46ce63 100644
--- a/ssh-keyscan.c
+++ b/ssh-keyscan.c
@@ -7,7 +7,7 @@
  */
 
 #include "includes.h"
-RCSID("$OpenBSD: ssh-keyscan.c,v 1.29 2001/08/30 22:22:32 markus Exp $");
+RCSID("$OpenBSD: ssh-keyscan.c,v 1.30 2001/10/08 19:05:05 markus Exp $");
 
 #if defined(HAVE_SYS_QUEUE_H) && !defined(HAVE_BOGUS_SYS_QUEUE_H)
 #include <sys/queue.h>
@@ -36,11 +36,7 @@
 
 /* Flag indicating whether IPv4 or IPv6.  This can be set on the command line.
    Default value is AF_UNSPEC means both IPv4 and IPv6. */
-#ifdef IPV4_DEFAULT
-int IPv4or6 = AF_INET;
-#else
 int IPv4or6 = AF_UNSPEC;
-#endif
 
 int ssh_port = SSH_DEFAULT_PORT;
 
diff --git a/ssh.c b/ssh.c
index f0903c5..a19b06b 100644
--- a/ssh.c
+++ b/ssh.c
@@ -39,7 +39,7 @@
  */
 
 #include "includes.h"
-RCSID("$OpenBSD: ssh.c,v 1.146 2001/10/01 21:38:53 markus Exp $");
+RCSID("$OpenBSD: ssh.c,v 1.147 2001/10/08 19:05:05 markus Exp $");
 
 #include <openssl/evp.h>
 #include <openssl/err.h>
@@ -681,7 +681,7 @@
 
 	/* Open a connection to the remote host. */
 
-	cerr = ssh_connect(host, &hostaddr, options.port,
+	cerr = ssh_connect(host, &hostaddr, options.port, IPv4or6,
 	    options.connection_attempts,
 	    original_effective_uid != 0 || !options.use_privileged_port,
 	    pw, options.proxy_command);
diff --git a/sshconnect.c b/sshconnect.c
index 7c92853..de6cc22 100644
--- a/sshconnect.c
+++ b/sshconnect.c
@@ -13,7 +13,7 @@
  */
 
 #include "includes.h"
-RCSID("$OpenBSD: sshconnect.c,v 1.114 2001/10/08 16:15:47 markus Exp $");
+RCSID("$OpenBSD: sshconnect.c,v 1.115 2001/10/08 19:05:05 markus Exp $");
 
 #include <openssl/bn.h>
 
@@ -38,9 +38,6 @@
 extern Options options;
 extern char *__progname;
 
-/* AF_UNSPEC or AF_INET or AF_INET6 */
-extern int IPv4or6;
-
 #ifndef INET6_ADDRSTRLEN		/* for non IPv6 machines */
 #define INET6_ADDRSTRLEN 46
 #endif
@@ -243,9 +240,8 @@
  */
 int
 ssh_connect(const char *host, struct sockaddr_storage * hostaddr,
-	    u_short port, int connection_attempts,
-	    int anonymous, struct passwd *pw,
-	    const char *proxy_command)
+    u_short port, int family, int connection_attempts,
+    int anonymous, struct passwd *pw, const char *proxy_command)
 {
 	int gaierr;
 	int on = 1;
@@ -279,7 +275,7 @@
 	/* No proxy command. */
 
 	memset(&hints, 0, sizeof(hints));
-	hints.ai_family = IPv4or6;
+	hints.ai_family = family;
 	hints.ai_socktype = SOCK_STREAM;
 	snprintf(strport, sizeof strport, "%d", port);
 	if ((gaierr = getaddrinfo(host, strport, &hints, &aitop)) != 0)
diff --git a/sshconnect.h b/sshconnect.h
index 27ed2b7..b475add 100644
--- a/sshconnect.h
+++ b/sshconnect.h
@@ -1,4 +1,4 @@
-/*	$OpenBSD: sshconnect.h,v 1.12 2001/06/26 17:27:25 markus Exp $	*/
+/*	$OpenBSD: sshconnect.h,v 1.13 2001/10/08 19:05:05 markus Exp $	*/
 
 /*
  * Copyright (c) 2000 Markus Friedl.  All rights reserved.
@@ -27,7 +27,7 @@
 #define SSHCONNECT_H
 
 int
-ssh_connect(const char *, struct sockaddr_storage *, u_short, int,
+ssh_connect(const char *, struct sockaddr_storage *, u_short, int, int,
     int, struct passwd *, const char *);
 
 void