--- telnet/config.guess.orig	2003-04-27 16:36:49.000000000 -0500
+++ telnet/config.guess	2005-06-06 09:32:56.000000000 -0500
@@ -130,7 +130,7 @@
 	PATH=$PATH:/.attbin ; export PATH
 fi
 
-UNAME_MACHINE=`(uname -m) 2>/dev/null` || UNAME_MACHINE=unknown
+UNAME_MACHINE=`(uname -p) 2>/dev/null` || UNAME_MACHINE=unknown
 UNAME_RELEASE=`(uname -r) 2>/dev/null` || UNAME_RELEASE=unknown
 UNAME_SYSTEM=`(uname -s) 2>/dev/null`  || UNAME_SYSTEM=unknown
 UNAME_VERSION=`(uname -v) 2>/dev/null` || UNAME_VERSION=unknown
@@ -1127,6 +1127,9 @@
     Power*:Rhapsody:*:*)
 	echo powerpc-apple-rhapsody${UNAME_RELEASE}
 	exit 0 ;;
+    *:Darwin:*:*)
+	echo ${UNAME_MACHINE}-apple-darwin${UNAME_RELEASE}
+	exit 0 ;;
     *:Rhapsody:*:*)
 	echo ${UNAME_MACHINE}-apple-rhapsody${UNAME_RELEASE}
 	exit 0 ;;
--- base/lib/shadow.c.orig      2005-06-05 21:02:46.000000000 -0500
+++ base/lib/shadow.c   2005-06-05 21:03:04.000000000 -0500
@@ -166,7 +166,7 @@
  * sgetspent - convert string in shadow file format to (struct spwd *)
  */
 
-static struct spwd *
+struct spwd *
 sgetspent (string)
        const char *string;
 {

--- base/libmisc/utmp.c.orig	2003-04-21 22:30:09.000000000 -0500
+++ base/libmisc/utmp.c	2006-04-07 12:53:49.000000000 -0500
@@ -31,10 +31,10 @@
 
 #include "defines.h"
 
-#include <utmp.h>
-
 #if HAVE_UTMPX_H
 #include <utmpx.h>
+#else
+#include <utmp.h>
 #endif
 
 #include <fcntl.h>
@@ -57,7 +57,7 @@
 #if HAVE_UTMPX_H
 extern	struct	utmpx	utxent;
 extern char *host;
-#endif
+#else
 extern	struct	utmp	utent;
 
 #ifndef HAVE_UTMP_H
@@ -66,6 +66,8 @@
 extern	void	setutent();
 extern	void	endutent();
 #endif
+#endif /* HAVE_UTMPX_H */
+
 extern	time_t	time();
 extern	char	*ttyname();
 extern	off_t	lseek();
@@ -98,13 +100,14 @@
 #if HAVE_UTMPX_H
 #include <utmpx.h>
 	struct	utmpx	*utx;
-#endif
+#else
 #ifdef HAVE_UTMP_H
 #include <utmp.h>
 #else
 	struct	utmp	*getutline();
 #endif
 	struct	utmp	*ut;
+#endif /* HAVE_UTMPX_H */
 #ifdef DEBUG
 	pid_t pid = getppid();
 #else
@@ -114,10 +117,11 @@
 
 #if HAVE_UTMPX_H
 	setutxent ();
-#endif
+#else
 #if HAVE_SETUTENT
 	setutent ();
 #endif	/* !SUN */
+#endif /* HAVE_UTMPX_H */
 
 #if defined(__linux__)
 	/* First, try to find a valid utmp entry for this process.  */
@@ -159,17 +163,18 @@
 
 		if (utx)
 			utxent = *utx;
-#endif
+#else
 		while ((ut = getutent()))
 			if (ut->ut_pid == pid)
 				break;
 
 		if (ut)
 			utent = *ut;
+#endif
 
 #if HAVE_UTMPX_H
 		endutxent();
-#endif
+#else
 		endutent();
 
 		if (!ut) {
@@ -187,6 +192,7 @@
 
 		if (utent.ut_line[0] == '\0')
 #endif	/* !UNIXPC */
+#endif /* HAVE_UTMPX_H */
 		{
 			if (!(line = ttyname(0))) {
 				puts(NO_TTY);
@@ -194,9 +200,10 @@
 			}
 			if (strncmp(line, "/dev/", 5) == 0)
 				line += 5;
-			strncpy(utent.ut_line, line, sizeof utent.ut_line);
 #if HAVE_UTMPX_H
 			strncpy(utxent.ut_line, line, sizeof utxent.ut_line);
+#else
+			strncpy(utent.ut_line, line, sizeof utent.ut_line);
 #endif
 		}
 	} else {
@@ -206,7 +213,15 @@
 		}
 		if (strncmp(line, "/dev/", 5) == 0)
 			line += 5;
+#if HAVE_UTMPX_H
+		if ((utx = getutxline(&utxent)))
+			strncpy(utxent.ut_id, getpid(), sizeof utxent.ut_id);
 
+		strncpy (utxent.ut_user, "LOGIN", sizeof utxent.ut_user);
+		utxent.ut_pid = getpid();
+		utxent.ut_type = LOGIN_PROCESS;
+		gettimeofday((struct timeval *) &utxent.ut_tv, NULL);
+#else
  		strncpy (utent.ut_line, line, sizeof utent.ut_line);
 		if ((ut = getutline(&utent)))
  			strncpy(utent.ut_id, ut->ut_id, sizeof ut->ut_id);
@@ -215,16 +230,7 @@
 		utent.ut_pid = getpid();
 		utent.ut_type = LOGIN_PROCESS;
 		time(&utent.ut_time);
-#if HAVE_UTMPX_H
-		if ((utx = getutxline(&utxent)))
-			strncpy(utxent.ut_id, utent.ut_id, sizeof utxent.ut_id);
-
-		strncpy (utxent.ut_user, utent.ut_user, sizeof utent.ut_user);
-		utxent.ut_pid = utent.ut_pid;
-		utxent.ut_type = utent.ut_type;
-		gettimeofday((struct timeval *) &utxent.ut_tv, NULL);
-		utent.ut_time = utxent.ut_tv.tv_sec;
-#endif
+#endif /* HAVE_UTMPX_H */
 	}
 #else	/* !USG */
 
@@ -269,7 +275,6 @@
 	time(&utent.ut_time);
 	/* other fields already filled in by checkutmp above */
 	setutent();
-	pututline(&utent);
 	endutent();
 	fd = open(_WTMP_FILE, O_APPEND | O_WRONLY, 0);
 	if (fd >= 0) {
@@ -277,11 +282,10 @@
 		close(fd);
 	}
 #elif HAVE_UTMPX_H
-	struct	utmp	*utmp, utline;
 	struct	utmpx	*utmpx, utxline;
 	pid_t	pid = getpid ();
 	FILE	*utmpx_fp;
-	int	found_utmpx = 0, found_utmp = 0;
+	int	found_utmpx = 0;
 	int	fd;
 
 	/*
@@ -298,7 +302,6 @@
 	 */
 
 	setutxent ();
-	setutent ();
 
 	while (utmpx = getutxent ()) {
 		if (utmpx->ut_pid == pid) {
@@ -306,12 +309,6 @@
 			break;
 		}
 	}
-	while (utmp = getutent ()) {
-		if (utmp->ut_pid == pid) {
-			found_utmp = 1;
-			break;
-		}
-	}
 
 	/*
 	 * If the entry matching `pid' cannot be found, create a new
@@ -330,19 +327,6 @@
 			utxline.ut_line[sizeof utxline.ut_line - 5] = '\0';
 		}
 	}
-	if (! found_utmp) {
-		memset ((void *) &utline, 0, sizeof utline);
-		strncpy (utline.ut_line, utxline.ut_line,
-			sizeof utline.ut_line);
-		utline.ut_pid = utxline.ut_pid;
-	} else {
-		utline = *utmp;
-		if (strncmp (utline.ut_line, "/dev/", 5) == 0) {
-			memmove (utline.ut_line, utline.ut_line + 5,
-				sizeof utline.ut_line - 5);
-			utline.ut_line[sizeof utline.ut_line - 5] = '\0';
-		}
-	}
 
 	/*
 	 * Fill in the fields in the utmpx entry and write it out.  Do
@@ -351,12 +335,10 @@
 	 */
 
 	strncpy (utxline.ut_user, name, sizeof utxline.ut_user);
-	strncpy (utline.ut_user, name, sizeof utline.ut_user);
 
-	utline.ut_type = utxline.ut_type = USER_PROCESS;
+	utxline.ut_type = USER_PROCESS;
 
 	gettimeofday(&utxline.ut_tv, NULL);
-	utline.ut_time = utxline.ut_tv.tv_sec;
 
 	strncpy (utxline.ut_host, host, sizeof utxline.ut_host);
 
@@ -366,7 +348,6 @@
 	  utxline.ut_syslen = sizeof (utxline.ut_host);
 #endif
 
-	pututline (&utline);
 	pututxline (&utxline);
 
 #ifdef _WTMP_FILE
@@ -374,10 +355,6 @@
 		write (fd, (void *) &utxline, sizeof utxline);
 		close (fd);
 	}
-	if ((fd = open (_WTMP_FILE, O_WRONLY|O_APPEND)) != -1) {
-		write (fd, (void *) &utline, sizeof utline);
-		close (fd);
-	}
 #elif defined(_WTMPX_FILE)
 	if ((fd = open (_WTMPX_FILE, O_WRONLY|O_APPEND)) != -1) {
 		write (fd, (void *) &utxline, sizeof utxline);
@@ -386,7 +363,6 @@
 #endif /* !_WTMP_FILE */
 
 	utxent = utxline;
-	utent = utline;
 	
 #else /* !SVR4 */
 	struct	utmp	utmp;
--- base/libmisc/limits.c.orig	2000-12-16 23:34:11.000000000 -0600
+++ base/libmisc/limits.c	2006-04-08 12:48:57.000000000 -0500
@@ -90,7 +90,13 @@
 	const char *name;
 	const char *maxlogins;
 {
+#if HAVE_UTMPX_H
+#include <utmpx.h>
+	struct utmpx *ut;
+#else
+#include <utmp.h>
 	struct utmp *ut;
+#endif
 	unsigned int limit, count;
 	char **endptr = (char **) &maxlogins;
 	const char *ml_orig = maxlogins;
@@ -103,10 +109,15 @@
 		SYSLOG((LOG_WARN, "No logins allowed for `%s'\n", name));
 		return LOGIN_ERROR_LOGIN;
 	}
-
+#if HAVE_UTMPX_H
+        setutxent();
+        count = 0;
+        while ((ut = getutxent())) {
+#else
 	setutent();
 	count = 0;
 	while ((ut = getutent())) {
+#endif
 #ifdef USER_PROCESS
 		if (ut->ut_type != USER_PROCESS)
 			continue;
@@ -118,7 +129,11 @@
 		if (++count >= limit)
 			break;
 	}
+#if HAVE_UTMPX_H
+	endutxent();
+#else
 	endutent();
+#endif
 	if (count >= limit) {
 		SYSLOG((LOG_WARN, "Too many logins (max %d) for %s\n",
 			limit, name));
--- telnet/telnetd/sys_term.c.orig	2006-04-07 00:57:17.000000000 -0500
+++ telnet/telnetd/sys_term.c	2006-04-07 00:58:24.000000000 -0500
@@ -2490,7 +2490,7 @@
 		f = open(wtmpf, O_WRONLY|O_APPEND);
 		if (f >= 0) {
 			SCPYN(wtmp.ut_line, line+5);
-			SCPYN(wtmp.UT_USER, "");
+			SCPYN(wtmp.ut_user, "");
 			SCPYN(wtmp.ut_host, "");
 #if (!defined(NO_WTMPX) && defined(HAVE_UTMPX_UT_TV)) || (defined(NO_WTMPX) && defined(HAVE_UTMP_UT_TV))
 			(void) time(&wtmp.ut_tv.tv_sec);
