--- xterm/Imakefile.orig	Mon Mar  2 11:56:39 1998
+++ xterm/Imakefile	Sun May 24 15:01:18 1998
@@ -49,6 +49,10 @@
          PTYLIB = -lpucc
 #endif
 
+PTMXDEF = -DPTMXFAKE
+PTYLIB = -L/usr/local/lib -lptmxfake -lutmphelper
+#undef InstallXtermSetUID
+
 #if XtermWithI18N
         I18NDEF = -DI18N
 #endif
@@ -69,6 +73,7 @@
         EXTRAOBJ = ttysvr.o
 #endif
    MAIN_DEFINES = $(UTMPDEF) $(TTYGROUPDEF) $(PUCCPTYDDEF) $(NOPOSIXTERMIOS) \
+		  $(PTMXDEF) \
 		  -DOSMAJORVERSION=$(OSMAJORVERSION) \
 		  -DOSMINORVERSION=$(OSMINORVERSION)
    MISC_DEFINES = /* -DALLOWLOGFILEEXEC */ 
--- xterm/main.c.orig	Wed May 20 17:56:54 1998
+++ xterm/main.c	Sat May 23 22:40:48 1998
@@ -69,6 +69,10 @@
 
 /* main.c */
 
+#include <ptmx_fake.h>
+#include <pututmp.h>
+#include <netinet/in.h>
+
 #ifdef HAVE_CONFIG_H
 #include <xtermcfg.h>
 #endif
@@ -1765,6 +1769,16 @@
  * has problems, we can re-enter this function and get another one.
  */
 
+#if 1
+static int get_pty(pty)
+    int *pty;
+{
+	if ((*pty=open(PTMX, O_RDWR))<0) return 1;
+	if (grantpt(*pty) || unlockpt(*pty)) return 1;
+	strcpy(ttydev, ptsname(*pty));
+	return 0;
+}
+#else
 static int
 get_pty (pty)
     int *pty;
@@ -1873,7 +1887,7 @@
 #endif /* USE_GET_PSEUDOTTY else */
 #endif /* ATT else */
 }
-
+#endif
 /*
  * Called from get_pty to iterate over likely pseudo terminals
  * we might allocate.  Used on those systems that do not have
@@ -2154,6 +2168,11 @@
 	struct lastlog lastlog;
 #endif	/* LASTLOG */
 #endif	/* UTMP */
+#ifdef linux
+	struct sockaddr addr;
+	int addrlen=sizeof(addr);
+	int gotpeer=0;
+#endif
 
 	screen->uid = getuid();
 	screen->gid = getgid();
@@ -2503,6 +2522,11 @@
 		}
 
 		/* we don't need the socket, or the pty master anymore */
+#ifdef linux
+		if (!getpeername(ConnectionNumber(screen->display),
+			&addr, &addrlen))
+			gotpeer=1;
+#endif
 		close (ConnectionNumber(screen->display));
 		close (screen->respond);
 
@@ -3036,6 +3060,11 @@
 		    if (disfin)
 			*disfin = '\0';
 		}
+#else
+		/* Which endianness is utmp addr? */
+		if (gotpeer && addr.sa_family==AF_INET)
+			memcpy(&utmp.ut_addr, 
+				&((struct sockaddr_in *)&addr)->sin_addr, 4);
 #endif
 		(void) strncpy(utmp.ut_host, buf, sizeof(utmp.ut_host));
 #endif
@@ -3919,13 +3948,13 @@
 		/* restore ownership of tty and pty */
 		chown (ttydev, 0, 0);
 #if (!defined(__sgi) && !defined(__osf__))
-		chown (ptydev, 0, 0);
+/* 		chown (ptydev, 0, 0); */
 #endif
 
 		/* restore modes of tty and pty */
 		chmod (ttydev, 0666);
 #if (!defined(__sgi) && !defined(__osf__))
-		chmod (ptydev, 0666);
+/* 		chmod (ptydev, 0666); */
 #endif
 	}
 #endif /* AMOEBA */

