- (dtucker) [configure.ac openbsd-compat/bsd-cray.c openbsd-compat/bsd-cray.h]
   Bug #775: Cray fixes from wendy at cray.com
diff --git a/CREDITS b/CREDITS
index 86b20eb..fe6270c 100644
--- a/CREDITS
+++ b/CREDITS
@@ -88,11 +88,12 @@
 Tor-Ake Fransson <torake@hotmail.com> - AIX support
 Tudor Bosman <tudorb@jm.nu> - MD5 password support
 Udo Schweigert <ust@cert.siemens.de> - ReliantUNIX support
+Wendy Palm <wendyp at cray.com> - Cray fixes.
 Zack Weinberg <zack@wolery.cumb.org> - GNOME askpass enhancement
 
 Apologies to anyone I have missed.
 
 Damien Miller <djm@mindrot.org>
 
-$Id: CREDITS,v 1.75 2003/11/21 12:48:55 djm Exp $
+$Id: CREDITS,v 1.76 2004/01/30 03:34:21 dtucker Exp $
 
diff --git a/ChangeLog b/ChangeLog
index c540d75..dd50a9c 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -11,6 +11,8 @@
      [sftp-batch.sh]
  - (dtucker) [configure.ac] Add --without-zlib-version-check.  Feedback from
    tim@, ok several
+ - (dtucker) [configure.ac openbsd-compat/bsd-cray.c openbsd-compat/bsd-cray.h]
+   Bug #775: Cray fixes from wendy at cray.com
 
 20040128
  - (dtucker) [regress/README.regress] Add tcpwrappers issue, noted by tim@
@@ -1780,4 +1782,4 @@
  - Fix sshd BindAddress and -b options for systems using fake-getaddrinfo.
    Report from murple@murple.net, diagnosis from dtucker@zip.com.au
 
-$Id: ChangeLog,v 1.3203 2004/01/30 03:20:59 dtucker Exp $
+$Id: ChangeLog,v 1.3204 2004/01/30 03:34:21 dtucker Exp $
diff --git a/configure.ac b/configure.ac
index c037ee7..97ef89a 100644
--- a/configure.ac
+++ b/configure.ac
@@ -1,4 +1,4 @@
-# $Id: configure.ac,v 1.190 2004/01/30 03:20:59 dtucker Exp $
+# $Id: configure.ac,v 1.191 2004/01/30 03:34:22 dtucker Exp $
 
 AC_INIT
 AC_CONFIG_SRCDIR([ssh.c])
@@ -360,6 +360,10 @@
 	MANTYPE=man
 	;;
 *-*-unicosmk*)
+	AC_DEFINE(NO_SSH_LASTLOG)
+	AC_DEFINE(SETEUID_BREAKS_SETUID)
+	AC_DEFINE(BROKEN_SETREUID)
+	AC_DEFINE(BROKEN_SETREGID)
 	AC_DEFINE(USE_PIPES)
 	AC_DEFINE(DISABLE_FD_PASSING)
 	LDFLAGS="$LDFLAGS"
@@ -367,14 +371,20 @@
 	MANTYPE=cat
 	;;
 *-*-unicosmp*)
+	AC_DEFINE(SETEUID_BREAKS_SETUID)
+	AC_DEFINE(BROKEN_SETREUID)
+	AC_DEFINE(BROKEN_SETREGID)
 	AC_DEFINE(WITH_ABBREV_NO_TTY)
 	AC_DEFINE(USE_PIPES)
 	AC_DEFINE(DISABLE_FD_PASSING)
 	LDFLAGS="$LDFLAGS"
-	LIBS="$LIBS -lgen -lacid"
+	LIBS="$LIBS -lgen -lacid -ldb"
 	MANTYPE=cat
 	;;
 *-*-unicos*)
+	AC_DEFINE(SETEUID_BREAKS_SETUID)
+	AC_DEFINE(BROKEN_SETREUID)
+	AC_DEFINE(BROKEN_SETREGID)
 	AC_DEFINE(USE_PIPES)
 	AC_DEFINE(DISABLE_FD_PASSING)
 	AC_DEFINE(NO_SSH_LASTLOG)
diff --git a/openbsd-compat/bsd-cray.c b/openbsd-compat/bsd-cray.c
index f2ac428..f630366 100644
--- a/openbsd-compat/bsd-cray.c
+++ b/openbsd-compat/bsd-cray.c
@@ -1,5 +1,5 @@
 /* 
- * $Id: bsd-cray.c,v 1.12 2003/06/03 02:45:27 dtucker Exp $
+ * $Id: bsd-cray.c,v 1.13 2004/01/30 03:34:22 dtucker Exp $
  *
  * bsd-cray.c
  *
@@ -59,6 +59,28 @@
 #include <ia.h>
 #include <urm.h>
 #include "ssh.h"
+
+#include "includes.h"
+#include "sys/types.h"
+
+#ifndef HAVE_STRUCT_SOCKADDR_STORAGE
+# define      _SS_MAXSIZE     128     /* Implementation specific max size */
+# define       _SS_PADSIZE     (_SS_MAXSIZE - sizeof (struct sockaddr))
+
+# define ss_family ss_sa.sa_family
+#endif /* !HAVE_STRUCT_SOCKADDR_STORAGE */
+
+#ifndef IN6_IS_ADDR_LOOPBACK
+# define IN6_IS_ADDR_LOOPBACK(a) \
+	(((u_int32_t *) (a))[0] == 0 && ((u_int32_t *) (a))[1] == 0 && \
+	 ((u_int32_t *) (a))[2] == 0 && ((u_int32_t *) (a))[3] == htonl (1))
+#endif /* !IN6_IS_ADDR_LOOPBACK */
+
+#ifndef AF_INET6
+/* Define it to something that should never appear */
+#define AF_INET6 AF_MAX
+#endif
+
 #include "log.h"
 #include "servconf.h"
 #include "bsd-cray.h"
@@ -182,7 +204,7 @@
 	/* passwd stuff for ia_user */
 	passwd_t pwdacm, pwddialup, pwdudb, pwdwal, pwddce;
 	ia_user_ret_t uret;		/* stuff returned from ia_user */
-	ia_user_t usent			/* ia_user main structure */
+	ia_user_t usent;		/* ia_user main structure */
 	int ia_rcode;			/* ia_user return code */
 	ia_failure_t fsent;		/* ia_failure structure */
 	ia_failure_ret_t fret;		/* ia_failure return stuff */
@@ -501,54 +523,54 @@
 					break;
 				default:
 					valid_acct = nam2acid(acct_name);
-					if (valid_acct == -1) {
+					if (valid_acct == -1) 
 						printf(
 						    "Account id not found for"
 						    " account name \"%s\"\n\n",
 						    acct_name);
 					break;
+				}
+				/*
+				 * If an account was given, search the user's
+				 * acids array to verify they can use this account.
+				 */
+				if ((valid_acct != -1) &&
+				    !(ue.ue_permbits & PERMBITS_ACCTID)) {
+					for (i = 0; i < MAXVIDS; i++) {
+						if (ue.ue_acids[i] == -1)
+							break;
+						if (valid_acct == ue.ue_acids[i])
+							break;
 					}
-					/*
-					 * If an account was given, search the user's
-					 * acids array to verify they can use this account.
-					 */
-					if ((valid_acct != -1) &&
-					    !(ue.ue_permbits & PERMBITS_ACCTID)) {
-						for (i = 0; i < MAXVIDS; i++) {
-							if (ue.ue_acids[i] == -1)
-								break;
-							if (valid_acct == ue.ue_acids[i])
-								break;
-						}
-						if (i == MAXVIDS ||
-						    ue.ue_acids[i] == -1) {
-							fprintf(stderr, "Cannot set"
-							    " account name to "
-							    "\"%s\", permission "
-							    "denied\n\n", acct_name);
-							valid_acct = -1;
-						}
+					if (i == MAXVIDS ||
+					    ue.ue_acids[i] == -1) {
+						fprintf(stderr, "Cannot set"
+						    " account name to "
+						    "\"%s\", permission "
+						    "denied\n\n", acct_name);
+						valid_acct = -1;
 					}
 				}
-			} else {
-				/*
-				 * The client isn't connected to a terminal and can't
-				 * respond to an acid prompt.  Use default acid.
-				 */
-				debug("cray_setup: ttyname false case, %.100s",
-				    ttyname);
-				valid_acct = ue.ue_acids[0];
 			}
 		} else {
 			/*
-			 * The user doesn't have the askacid permbit set or
-			 * only has one valid account to use.
+			 * The client isn't connected to a terminal and can't
+			 * respond to an acid prompt.  Use default acid.
 			 */
+			debug("cray_setup: ttyname false case, %.100s",
+			    ttyname);
 			valid_acct = ue.ue_acids[0];
 		}
-		if (acctid(0, valid_acct) < 0) {
-			printf ("Bad account id: %d\n", valid_acct);
-			exit(1);
+	} else {
+		/*
+		 * The user doesn't have the askacid permbit set or
+		 * only has one valid account to use.
+		 */
+		valid_acct = ue.ue_acids[0];
+	}
+	if (acctid(0, valid_acct) < 0) {
+		printf ("Bad account id: %d\n", valid_acct);
+		exit(1);
 	}
 
 	/* 
@@ -778,4 +800,17 @@
 	ut->ut_jid = jid;
 	strncpy(ut->ut_tpath, cray_tmpdir, TPATHSIZ);
 }
-#endif
+#endif /* UNICOS */
+
+#ifdef _UNICOSMP
+#include <pwd.h>
+/*
+ * Set job id and create tmpdir directory.
+ */
+void
+cray_init_job(struct passwd *pw)
+{
+	initrm_silent(pw->pw_uid);
+	return;
+}
+#endif /* _UNICOSMP */
diff --git a/openbsd-compat/bsd-cray.h b/openbsd-compat/bsd-cray.h
index a121ea1..de6ba1a 100644
--- a/openbsd-compat/bsd-cray.h
+++ b/openbsd-compat/bsd-cray.h
@@ -1,4 +1,4 @@
-/* $Id: bsd-cray.h,v 1.10 2003/08/29 16:59:52 mouring Exp $ */
+/* $Id: bsd-cray.h,v 1.11 2004/01/30 03:34:22 dtucker Exp $ */
 
 /*
  * Copyright (c) 2002, Cray Inc.  (Wendy Palm <wendyp@cray.com>)
@@ -53,7 +53,6 @@
 # define MAXHOSTNAMELEN  64
 #endif
 #ifndef _CRAYT3E
-# include <sys/ttold.h>
 # define TIOCGPGRP (tIOC|20)
 #endif