- (djm) Correctly handle SIA and AIX when no tty present. Spotted and
   suggested fix from Mike Battersby <mib@unimelb.edu.au>
diff --git a/ChangeLog b/ChangeLog
index 0dd9f7b..6e9ace6 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -6,6 +6,8 @@
  - (djm) Don't loop forever when changing password via PAM. Patch
    from Solar Designer <solar@openwall.com>
  - (djm) Generate config files before build
+ - (djm) Correctly handle SIA and AIX when no tty present. Spotted and
+   suggested fix from Mike Battersby <mib@unimelb.edu.au>
 
 20010320
  - (bal) glob.c update to added GLOB_LIMITS (OpenBSD CVS).
@@ -4654,4 +4656,4 @@
  - Wrote replacements for strlcpy and mkdtemp
  - Released 1.0pre1
 
-$Id: ChangeLog,v 1.997 2001/03/21 02:13:40 djm Exp $
+$Id: ChangeLog,v 1.998 2001/03/21 05:13:03 djm Exp $
diff --git a/session.c b/session.c
index 31a16dc..bed03c7 100644
--- a/session.c
+++ b/session.c
@@ -1053,7 +1053,7 @@
 	   switch, so we let login(1) to this for us. */
 	if (!options.use_login) {
 #ifdef HAVE_OSF_SIA
-		session_setup_sia(pw->pw_name, s->tty);
+		session_setup_sia(pw->pw_name, s->ttyfd == -1 ? NULL : s->tty);
 #else /* HAVE_OSF_SIA */
 #ifdef HAVE_CYGWIN
 		if (is_winnt) {
@@ -1137,7 +1137,8 @@
 			cp = xmalloc(22 + strlen(s->tty) + 
 			    2 * strlen(pw->pw_name));
 			i = sprintf(cp, "LOGNAME=%s%cNAME=%s%cTTY=%s%c%c",
-			    pw->pw_name, 0, pw->pw_name, 0, s->tty, 0,0);
+			    pw->pw_name, 0, pw->pw_name, 0, 
+			    s->ttyfd == -1 ? "" : s->tty, 0,0);
 			if (usrinfo(SETUINFO, cp, i) == -1)
 				fatal("Couldn't set usrinfo: %s", 
 				    strerror(errno));