From b97e03aa15de8897ebe5bef249f037457be19182 Mon Sep 17 00:00:00 2001
From: Sascha Wildner <saw@online.de>
Date: Thu, 1 Aug 2019 21:49:26 +0200
Subject: [PATCH] utmp/wtmp removal (for dports testing)

---
 Makefile_upgrade.inc                         |   4 +
 bin/csh/csh/config.h                         |   2 +-
 bin/date/Makefile                            |   2 +-
 bin/date/date.c                              |   6 -
 include/Makefile                             |   2 +-
 include/utmp.h                               |  72 -----
 lib/libc/gen/Makefile.inc                    |   3 +-
 lib/libc/gen/utmp.c                          | 102 -------
 lib/libc/gen/utmpx.c                         |  34 ---
 lib/libpam/modules/pam_lastlog/pam_lastlog.c |  77 +-----
 lib/libssh/config.h                          |  26 +-
 lib/libutil/Makefile                         |   4 +-
 lib/libutil/login.3                          |  65 -----
 lib/libutil/login.c                          |  57 ----
 lib/libutil/logout.3                         |  67 -----
 lib/libutil/logout.c                         |  67 -----
 lib/libutil/logwtmp.3                        |  71 -----
 lib/libutil/logwtmp.c                        |  98 -------
 libexec/Makefile                             |   8 +-
 libexec/comsat/comsat.c                      |   1 -
 libexec/ftpd/Makefile                        |   2 +-
 libexec/ftpd/logwtmp.c                       |  79 ------
 libexec/rpc.rusersd/rusers_proc.c            |   1 -
 libexec/talkd/Makefile                       |   2 +-
 libexec/telnetd/Makefile                     |   2 +-
 libexec/telnetd/sys_term.c                   |   4 -
 libexec/telnetd/telnetd.c                    |  24 --
 sbin/Makefile                                |   2 +-
 sbin/init/Makefile                           |   2 +-
 sbin/init/init.c                             |  10 -
 sbin/reboot/Makefile                         |   2 +-
 sbin/reboot/reboot.c                         |   3 -
 share/man/man5/Makefile                      |   3 -
 share/man/man5/utmp.5                        | 267 -------------------
 sys/sys/param.h                              |   3 +-
 usr.bin/Makefile                             |   4 +-
 usr.bin/finger/Makefile                      |   2 +-
 usr.bin/finger/lprint.c                      |   2 -
 usr.bin/finger/net.c                         |   1 -
 usr.bin/finger/sprint.c                      |   7 +-
 usr.bin/last/Makefile                        |   2 +-
 usr.bin/last/last.c                          |  48 +---
 usr.bin/systat/Makefile                      |   2 +-
 usr.bin/users/Makefile                       |   2 +-
 usr.bin/w/Makefile                           |   2 +-
 usr.bin/w/w.c                                |  66 +----
 usr.bin/wall/Makefile                        |   2 +-
 usr.bin/who/Makefile                         |   3 +-
 usr.bin/who/utmpentry.c                      | 112 +-------
 usr.bin/who/utmpentry.h                      |   7 -
 usr.bin/who/who.c                            |   3 -
 usr.bin/write/Makefile                       |   2 +-
 usr.sbin/Makefile                            |   8 +-
 usr.sbin/ac/ac.c                             |   1 -
 usr.sbin/adduser/adduser.8                   |   5 -
 usr.sbin/lastlogin/lastlogin.c               |  60 +----
 usr.sbin/ppp/id.c                            |   2 -
 usr.sbin/ppp/physical.c                      |   1 -
 usr.sbin/rwhod/rwhod.c                       |   1 -
 usr.sbin/sshd/Makefile                       |   2 -
 60 files changed, 68 insertions(+), 1453 deletions(-)
 delete mode 100644 include/utmp.h
 delete mode 100644 lib/libc/gen/utmp.c
 delete mode 100644 lib/libutil/login.3
 delete mode 100644 lib/libutil/login.c
 delete mode 100644 lib/libutil/logout.3
 delete mode 100644 lib/libutil/logout.c
 delete mode 100644 lib/libutil/logwtmp.3
 delete mode 100644 lib/libutil/logwtmp.c
 delete mode 100644 libexec/ftpd/logwtmp.c
 delete mode 100644 share/man/man5/utmp.5

diff --git a/Makefile_upgrade.inc b/Makefile_upgrade.inc
index 218ecc8510..1e17aee534 100644
--- a/Makefile_upgrade.inc
+++ b/Makefile_upgrade.inc
@@ -3756,6 +3756,10 @@ TO_REMOVE+=/usr/sbin/rdate
 TO_REMOVE+=/usr/share/man/man8/rdate.8.gz
 TO_REMOVE+=/entropy
 TO_REMOVE+=/usr/share/man/man9/kmalloc_cachealign.9.gz
+TO_REMOVE+=/usr/include/utmp.h
+TO_REMOVE+=/usr/share/man/man5/lastlog.5.gz
+TO_REMOVE+=/usr/share/man/man5/utmp.5.gz
+TO_REMOVE+=/usr/share/man/man5/wtmp.5.gz
 
 .if !defined(WANT_INSTALLER)
 TO_REMOVE+=/usr/sbin/dfuibe_installer
diff --git a/bin/csh/csh/config.h b/bin/csh/csh/config.h
index 150e32eb5d..2f8fbe7be4 100644
--- a/bin/csh/csh/config.h
+++ b/bin/csh/csh/config.h
@@ -185,7 +185,7 @@
 #define HAVE_UTMPX_H 1
 
 /* Define to 1 if you have the <utmp.h> header file. */
-#define HAVE_UTMP_H 1
+/* #undef HAVE_UTMP_H */
 
 /* Define to 1 if you have the <wchar.h> header file. */
 #define HAVE_WCHAR_H 1
diff --git a/bin/date/Makefile b/bin/date/Makefile
index 525eacbd6d..0278154b98 100644
--- a/bin/date/Makefile
+++ b/bin/date/Makefile
@@ -3,7 +3,7 @@
 
 PROG=	date
 SRCS=	date.c vary.c
-CFLAGS+=-DSUPPORT_UTMP -DSUPPORT_UTMPX
+CFLAGS+=-DSUPPORT_UTMPX
 
 DPADD=	${LIBUTIL}
 LDADD=	-lutil
diff --git a/bin/date/date.c b/bin/date/date.c
index 63384b43b0..fac762e6f4 100644
--- a/bin/date/date.c
+++ b/bin/date/date.c
@@ -255,9 +255,6 @@ setthetime(const char *fmt, const char *p, int jflag)
 		errx(1, "nonexistent time");
 
 	if (!jflag) {
-#ifdef SUPPORT_UTMP
-		logwtmp("|", "date", "");
-#endif
 #ifdef SUPPORT_UTMPX
 		logwtmpx("|", "date", "", 0, OLD_TIME);
 #endif
@@ -265,9 +262,6 @@ setthetime(const char *fmt, const char *p, int jflag)
 		tv.tv_usec = 0;
 		if (settimeofday(&tv, NULL))
 			err(1, "settimeofday (timeval)");
-#ifdef SUPPORT_UTMP
-		logwtmp("{", "date", "");
-#endif
 #ifdef SUPPORT_UTMPX
 		logwtmpx("{", "date", "", 0, NEW_TIME);
 #endif
diff --git a/include/Makefile b/include/Makefile
index 564cf02a73..0fbe3ca861 100644
--- a/include/Makefile
+++ b/include/Makefile
@@ -26,7 +26,7 @@ INCS=	a.out.h alloca.h ar.h assert.h bitstring.h cpio.h ctype.h db.h \
 	tar.h termios.h time.h \
 	timeconv.h \
 	timers.h ttyent.h \
-	uchar.h unistd.h ulimit.h utime.h utmp.h utmpx.h \
+	uchar.h unistd.h ulimit.h utime.h utmpx.h \
 	uuid.h vis.h \
 	wchar.h wctype.h wordexp.h xlocale.h
 
diff --git a/include/utmp.h b/include/utmp.h
deleted file mode 100644
index 3c62130501..0000000000
--- a/include/utmp.h
+++ /dev/null
@@ -1,72 +0,0 @@
-/*
- * Copyright (c) 1988, 1993
- *	The Regents of the University of California.  All rights reserved.
- * (c) UNIX System Laboratories, Inc.
- * All or some portions of this file are derived from material licensed
- * to the University of California by American Telephone and Telegraph
- * Co. or Unix System Laboratories, Inc. and are reproduced herein with
- * the permission of UNIX System Laboratories, Inc.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in the
- *    documentation and/or other materials provided with the distribution.
- * 3. Neither the name of the University nor the names of its contributors
- *    may be used to endorse or promote products derived from this software
- *    without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
- * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
- * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
- * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- *
- *	@(#)utmp.h	8.2 (Berkeley) 1/21/94
- * $FreeBSD: src/include/utmp.h,v 1.9 1999/08/27 23:44:53 peter Exp $
- * $DragonFly: src/include/utmp.h,v 1.2 2003/06/17 04:25:56 dillon Exp $
- */
-
-#ifndef	_UTMP_H_
-#define	_UTMP_H_
-
-#include <sys/cdefs.h>
-
-#define	_PATH_UTMP	"/var/run/utmp"
-#define	_PATH_WTMP	"/var/log/wtmp"
-#define	_PATH_LASTLOG	"/var/log/lastlog"
-
-#define	UT_NAMESIZE	16	/* see MAXLOGNAME in <sys/param.h> */
-#define	UT_LINESIZE	8
-#define	UT_HOSTSIZE	16
-
-struct lastlog {
-	time_t	ll_time;
-	char	ll_line[UT_LINESIZE];
-	char	ll_host[UT_HOSTSIZE];
-};
-
-struct utmp {
-	char	ut_line[UT_LINESIZE];
-	char	ut_name[UT_NAMESIZE];
-	char	ut_host[UT_HOSTSIZE];
-	time_t	ut_time;
-};
-
-__BEGIN_DECLS
-int utmpname(const char *);
-void setutent(void);
-struct utmp *getutent(void);
-void endutent(void);
-__END_DECLS
-
-#endif /* !_UTMP_H_ */
diff --git a/lib/libc/gen/Makefile.inc b/lib/libc/gen/Makefile.inc
index 08bdf7cf2a..71dcb40a68 100644
--- a/lib/libc/gen/Makefile.inc
+++ b/lib/libc/gen/Makefile.inc
@@ -39,8 +39,7 @@ SRCS+=  _once_stub.c _pthread_stubs.c _rand48.c _spinlock_stub.c \
 	stringlist.c strtofflags.c sysconf.c sysctl.c sysctlbyname.c \
 	sysctlnametomib.c syslog.c telldir.c termios.c time.c times.c \
 	ttyname.c ttyslot.c \
-	ualarm.c ucontext.c ulimit.c uname.c unvis.c usleep.c utime.c \
-	utmp.c utmpx.c \
+	ualarm.c ucontext.c ulimit.c uname.c unvis.c usleep.c utime.c utmpx.c \
 	valloc.c vis.c wait.c wait3.c waitpid.c waitid.c wordexp.c
 
 .if ${LIB} != {c_rtld}
diff --git a/lib/libc/gen/utmp.c b/lib/libc/gen/utmp.c
deleted file mode 100644
index 6b24a450eb..0000000000
--- a/lib/libc/gen/utmp.c
+++ /dev/null
@@ -1,102 +0,0 @@
-/*	$NetBSD: utmp.c,v 1.8 2009/01/11 02:46:27 christos Exp $	 */
-
-/*-
- * Copyright (c) 2002 The NetBSD Foundation, Inc.
- * All rights reserved.
- *
- * This code is derived from software contributed to The NetBSD Foundation
- * by Christos Zoulas.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in the
- *    documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
- * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
- * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
- * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
- * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
- * POSSIBILITY OF SUCH DAMAGE.
- */
-
-#include "namespace.h"
-#include <sys/types.h>
-#include <sys/param.h>
-#include <stdio.h>
-#include <string.h>
-#include <time.h>
-#include <utmp.h>
-#include <sys/stat.h>
-#include "un-namespace.h"
-
-static struct utmp utmp;
-static FILE *ut;
-static char utfile[MAXPATHLEN] = _PATH_UTMP;
-
-void
-setutent(void)
-{
-	if (ut == NULL)
-		return;
-	(void)fseeko(ut, (off_t)0, SEEK_SET);
-}
-
-struct utmp *
-getutent(void)
-{
-	if (ut == NULL) {
-		struct stat st;
-		off_t numentries;
-		if ((ut = fopen(utfile, "r")) == NULL)
-			return NULL;
-		if (_fstat(fileno(ut), &st) == -1)
-			goto out;
-		/*
-		 * If we have a an old version utmp file bail.
-		 */
-		numentries = st.st_size / sizeof(utmp);
-		if ((off_t)(numentries * sizeof(utmp)) != st.st_size)
-			goto out;
-	}
-	if (fread(&utmp, sizeof(utmp), 1, ut) == 1)
-		return &utmp;
-out:
-	(void)fclose(ut);
-	return NULL;
-}
-
-void
-endutent(void)
-{
-	if (ut != NULL) {
-		(void)fclose(ut);
-		ut = NULL;
-	}
-}
-
-int
-utmpname(const char *fname)
-{
-	size_t len = strlen(fname);
-
-	if (len >= sizeof(utfile))
-		return 0;
-
-	/* must not end in x! */
-	if (fname[len - 1] == 'x')
-		return 0;
-
-	(void)strlcpy(utfile, fname, sizeof(utfile));
-	endutent();
-	return 1;
-}
diff --git a/lib/libc/gen/utmpx.c b/lib/libc/gen/utmpx.c
index 79f5ee7c0b..b4df72db1c 100644
--- a/lib/libc/gen/utmpx.c
+++ b/lib/libc/gen/utmpx.c
@@ -44,7 +44,6 @@
 #include <string.h>
 #include <unistd.h>
 #include <pwd.h>
-#include <utmp.h>
 #include <utmpx.h>
 #include <vis.h>
 
@@ -404,39 +403,6 @@ utmpxname(const char *fname)
 	return 1;
 }
 
-void
-getutmp(const struct utmpx *ux, struct utmp *u)
-{
-
-	_DIAGASSERT(ux != NULL);
-	_DIAGASSERT(u != NULL);
-
-	(void)memcpy(u->ut_name, ux->ut_name, sizeof(u->ut_name));
-	(void)memcpy(u->ut_line, ux->ut_line, sizeof(u->ut_line));
-	(void)memcpy(u->ut_host, ux->ut_host, sizeof(u->ut_host));
-	u->ut_time = ux->ut_tv.tv_sec;
-}
-
-void
-getutmpx(const struct utmp *u, struct utmpx *ux)
-{
-
-	_DIAGASSERT(ux != NULL);
-	_DIAGASSERT(u != NULL);
-
-	(void)memcpy(ux->ut_name, u->ut_name, sizeof(u->ut_name));
-	(void)memcpy(ux->ut_line, u->ut_line, sizeof(u->ut_line));
-	(void)memcpy(ux->ut_host, u->ut_host, sizeof(u->ut_host));
-	ux->ut_tv.tv_sec = u->ut_time;
-	ux->ut_tv.tv_usec = 0;
-	(void)memset(&ux->ut_ss, 0, sizeof(ux->ut_ss));
-	ux->ut_pid = 0;
-	ux->ut_type = USER_PROCESS;
-	ux->ut_session = 0;
-	ux->ut_exit.e_termination = 0;
-	ux->ut_exit.e_exit = 0;
-}
-
 struct lastlogx *
 getlastlogx(const char *fname, uid_t uid, struct lastlogx *ll)
 {
diff --git a/lib/libpam/modules/pam_lastlog/pam_lastlog.c b/lib/libpam/modules/pam_lastlog/pam_lastlog.c
index 983807e1e1..617e45f98d 100644
--- a/lib/libpam/modules/pam_lastlog/pam_lastlog.c
+++ b/lib/libpam/modules/pam_lastlog/pam_lastlog.c
@@ -64,17 +64,8 @@
 #include <security/pam_modules.h>
 #include <security/pam_mod_misc.h>
 
-#define SUPPORT_UTMP 1
 #define SUPPORT_UTMPX 1
 
-#ifdef SUPPORT_UTMP
-#include <utmp.h>
-static void doutmp(const char *, const char *, const char *,
-    const struct timeval *);
-static void dolastlog(pam_handle_t *, int, const struct passwd *, const char *,
-    const char *, const struct timeval *);
-#endif
-
 #ifdef SUPPORT_UTMPX
 #include <utmpx.h>
 static void doutmpx(const char *, const char *, const char *,
@@ -83,7 +74,7 @@ static void dolastlogx(pam_handle_t *, int, const struct passwd *, const char *,
     const char *, const struct sockaddr_storage *ss, const struct timeval *);
 #endif
 
-#if defined(SUPPORT_UTMPX) || defined(SUPPORT_UTMP)
+#if defined(SUPPORT_UTMPX)
 static void domsg(pam_handle_t *, time_t, const char *, size_t, const char *,
     size_t);
 #endif
@@ -171,10 +162,6 @@ pam_sm_open_session(pam_handle_t *pamh, int flags,
 	doutmpx(user, rhost, tty, NULL, &now);
 	quiet = 1;
 #endif
-#ifdef SUPPORT_UTMP
-	doutmp(user, rhost, tty, &now);
-	dolastlog(pamh, quiet, pwd, rhost, tty, &now);
-#endif
 err:
 	if (openpam_get_option(pamh, "no_fail"))
 		return PAM_SUCCESS;
@@ -207,17 +194,10 @@ pam_sm_close_session(pam_handle_t *pamh __unused, int flags __unused,
 		    __func__, tty);
 #endif
 
-#ifdef SUPPORT_UTMP
-	if (logout(tty))
-		logwtmp(tty, "", "");
-	else
-		logit(LOG_NOTICE, "%s(): no utmp record for %s",
-		    __func__, tty);
-#endif
         return PAM_SUCCESS;
 }
 
-#if defined(SUPPORT_UTMPX) || defined(SUPPORT_UTMP)
+#if defined(SUPPORT_UTMPX)
 static void
 domsg(pam_handle_t *pamh, time_t t, const char *host, size_t hsize,
     const char *line, size_t lsize)
@@ -306,57 +286,4 @@ dolastlogx(pam_handle_t *pamh, int quiet, const struct passwd *pwd,
 }
 #endif
 
-#ifdef SUPPORT_UTMP
-static void
-doutmp(const char *username, const char *hostname, const char *tty,
-    const struct timeval *now)
-{
-	struct utmp utmp;
-
-	(void)memset((void *)&utmp, 0, sizeof(utmp));
-	utmp.ut_time = now->tv_sec;
-	(void)strncpy(utmp.ut_name, username, sizeof(utmp.ut_name));
-	if (hostname)
-		(void)strncpy(utmp.ut_host, hostname, sizeof(utmp.ut_host));
-	(void)strncpy(utmp.ut_line, tty, sizeof(utmp.ut_line));
-	login(&utmp);
-}
-
-static void
-dolastlog(pam_handle_t *pamh, int quiet, const struct passwd *pwd,
-    const char *hostname, const char *tty, const struct timeval *now)
-{
-	struct lastlog ll;
-	int fd;
-
-	if ((fd = open(_PATH_LASTLOG, O_RDWR, 0)) == -1) {
-		logit(LOG_NOTICE, "Cannot open `%s' %m", _PATH_LASTLOG);
-		return;
-	}
-	(void)lseek(fd, (off_t)(pwd->pw_uid * sizeof(ll)), SEEK_SET);
-
-	if (!quiet) {
-		if (read(fd, (char *)&ll, sizeof(ll)) == sizeof(ll) &&
-		    ll.ll_time != 0)
-			domsg(pamh, ll.ll_time, ll.ll_host,
-			    sizeof(ll.ll_host), ll.ll_line,
-			    sizeof(ll.ll_line));
-		(void)lseek(fd, (off_t)(pwd->pw_uid * sizeof(ll)), SEEK_SET);
-	}
-
-	ll.ll_time = now->tv_sec;
-	(void)strncpy(ll.ll_line, tty, sizeof(ll.ll_line));
-
-	if (hostname)
-		(void)strncpy(ll.ll_host, hostname, sizeof(ll.ll_host));
-	else
-		(void)memset(ll.ll_host, 0, sizeof(ll.ll_host));
-
-	(void)write(fd, &ll, sizeof(ll));
-	(void)close(fd);
-
-	PAM_LOG("Login recorded in %s", _PATH_LASTLOG);
-}
-#endif
-
 PAM_MODULE_ENTRY("pam_lastlog");
diff --git a/lib/libssh/config.h b/lib/libssh/config.h
index f5a154417c..34f766041f 100644
--- a/lib/libssh/config.h
+++ b/lib/libssh/config.h
@@ -95,13 +95,13 @@
 /* #undef CONF_LASTLOG_FILE */
 
 /* Define if you want to specify the path to your utmp file */
-#define CONF_UTMP_FILE "/var/run/utmp"
+/* #undef CONF_UTMP_FILE */
 
 /* Define if you want to specify the path to your wtmpx file */
-/* #undef CONF_WTMPX_FILE */
+#define CONF_WTMPX_FILE "/var/log/wtmpx"
 
 /* Define if you want to specify the path to your wtmp file */
-#define CONF_WTMP_FILE "/var/log/wtmp"
+/* #undef CONF_WTMP_FILE */
 
 /* Define if your platform needs to skip post auth file descriptor passing */
 /* #undef DISABLE_FD_PASSING */
@@ -110,7 +110,7 @@
 /* #undef DISABLE_LASTLOG */
 
 /* Define if you don't want to use your system's login() call */
-/* #undef DISABLE_LOGIN */
+#define DISABLE_LOGIN 1
 
 /* Define if you don't want to use pututline() etc. to write [uw]tmp */
 /* #undef DISABLE_PUTUTLINE */
@@ -122,16 +122,16 @@
 /* #undef DISABLE_SHADOW */
 
 /* Define if you don't want to use utmp */
-/* #undef DISABLE_UTMP */
+#define DISABLE_UTMP 1
 
 /* Define if you don't want to use utmpx */
 /* #undef DISABLE_UTMPX */
 
 /* Define if you don't want to use wtmp */
-/* #undef DISABLE_WTMP */
+#define DISABLE_WTMP 1
 
 /* Define if you don't want to use wtmpx */
-#define DISABLE_WTMPX 1
+/* #undef DISABLE_WTMPX */
 
 /* Enable for PKCS#11 support */
 /* #undef ENABLE_PKCS11 */
@@ -719,7 +719,7 @@
 #define HAVE_HMAC_CTX_INIT 1
 
 /* Define if you have ut_host in utmp.h */
-#define HAVE_HOST_IN_UTMP 1
+/* #undef HAVE_HOST_IN_UTMP */
 
 /* Define if you have ut_host in utmpx.h */
 #define HAVE_HOST_IN_UTMPX 1
@@ -848,7 +848,7 @@
 #define HAVE_LOCALE_H 1
 
 /* Define to 1 if you have the `login' function. */
-#define HAVE_LOGIN 1
+/* #undef HAVE_LOGIN */
 
 /* Define to 1 if you have the <login_cap.h> header file. */
 #define HAVE_LOGIN_CAP_H 1
@@ -863,7 +863,7 @@
 #define HAVE_LOGOUT 1
 
 /* Define to 1 if you have the `logwtmp' function. */
-#define HAVE_LOGWTMP 1
+/* #undef HAVE_LOGWTMP */
 
 /* Define to 1 if the system has the type `long double'. */
 #define HAVE_LONG_DOUBLE 1
@@ -1469,7 +1469,7 @@
 #define HAVE_TIME_H 1
 
 /* Define if you have ut_time in utmp.h */
-#define HAVE_TIME_IN_UTMP 1
+/* #undef HAVE_TIME_IN_UTMP */
 
 /* Define if you have ut_time in utmpx.h */
 /* #undef HAVE_TIME_IN_UTMPX */
@@ -1544,7 +1544,7 @@
 #define HAVE_UTIME_H 1
 
 /* Define to 1 if you have the `utmpname' function. */
-#define HAVE_UTMPNAME 1
+/* #undef HAVE_UTMPNAME */
 
 /* Define to 1 if you have the `utmpxname' function. */
 #define HAVE_UTMPXNAME 1
@@ -1553,7 +1553,7 @@
 #define HAVE_UTMPX_H 1
 
 /* Define to 1 if you have the <utmp.h> header file. */
-#define HAVE_UTMP_H 1
+/* #undef HAVE_UTMP_H */
 
 /* define if you have u_char data type */
 #define HAVE_U_CHAR 1
diff --git a/lib/libutil/Makefile b/lib/libutil/Makefile
index 6736f7fb8a..40c750adbb 100644
--- a/lib/libutil/Makefile
+++ b/lib/libutil/Makefile
@@ -6,7 +6,7 @@ SHLIB_MAJOR= 4
 SHLIBDIR?= /lib
 CFLAGS+=-DINET6
 CFLAGS+=-D_CTYPE_H_DISABLE_MACROS_ 
-SRCS=	flopen.c login.c login_tty.c logout.c logwtmp.c logwtmpx.c pty.c \
+SRCS=	flopen.c login_tty.c logwtmpx.c pty.c \
 	login_cap.c login_class.c login_auth.c login_times.c login_ok.c \
 	login_crypt.c loginx.c logoutx.c _secure_path.c uucplock.c \
 	property.c auth.c \
@@ -20,7 +20,7 @@ INCSLINKS=libutil.h ${INCLUDEDIR}/util.h
 
 CFLAGS+= -I${.CURDIR} -I${.CURDIR}/../libc/gen/
 
-MAN+=	flopen.3 login.3 loginx.3 login_auth.3 login_tty.3 logout.3 logwtmp.3 \
+MAN+=	flopen.3 loginx.3 login_auth.3 login_tty.3 \
 	pty.3 \
 	login_cap.3 login_class.3 login_times.3 login_ok.3 \
 	_secure_path.3 uucplock.3 property.3 auth.3 realhostname.3 \
diff --git a/lib/libutil/login.3 b/lib/libutil/login.3
deleted file mode 100644
index c4247bd3fd..0000000000
--- a/lib/libutil/login.3
+++ /dev/null
@@ -1,65 +0,0 @@
-.\"
-.\" Copyright (c) 1996 Joerg Wunsch
-.\"
-.\" All rights reserved.
-.\"
-.\" Redistribution and use in source and binary forms, with or without
-.\" modification, are permitted provided that the following conditions
-.\" are met:
-.\" 1. Redistributions of source code must retain the above copyright
-.\"    notice, this list of conditions and the following disclaimer.
-.\" 2. Redistributions in binary form must reproduce the above copyright
-.\"    notice, this list of conditions and the following disclaimer in the
-.\"    documentation and/or other materials provided with the distribution.
-.\"
-.\" THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY EXPRESS OR
-.\" IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
-.\" OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
-.\" IN NO EVENT SHALL THE DEVELOPERS BE LIABLE FOR ANY DIRECT, INDIRECT,
-.\" INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
-.\" NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-.\" DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-.\" THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-.\" (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
-.\" THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-.\"
-.\" $FreeBSD: src/lib/libutil/login.3,v 1.5.2.3 2001/12/17 10:08:32 ru Exp $
-.\"
-.Dd December 29, 1996
-.Dt LOGIN 3
-.Os
-.Sh NAME
-.Nm login
-.Nd "log a new login record to the utmp and wtmp files"
-.Sh LIBRARY
-.Lb libutil
-.Sh SYNOPSIS
-.In sys/types.h
-.In utmp.h
-.In libutil.h
-.Ft void
-.Fn login "struct utmp *ut"
-.Sh DESCRIPTION
-The function
-.Fn login
-records the
-.Ar ut
-entry being passed into the appropriate slot of the
-.Xr utmp 5
-file (according to the controlling terminal of the calling process),
-and appends it to the
-.Xr wtmp 5
-file.  The calling process must have permission to write to both files.
-.Sh RETURN VALUES
-None.
-.Sh SEE ALSO
-.Xr logout 3 ,
-.Xr ttyslot 3 ,
-.Xr utmp 5 ,
-.Xr wtmp 5
-.Sh BUGS
-The interface provided by
-.Fn login
-is rather crude.  The caller must know about the details of a
-.Va struct utmp .
-Some better abstraction needs to be worked out.
diff --git a/lib/libutil/login.c b/lib/libutil/login.c
deleted file mode 100644
index 3b65e637f8..0000000000
--- a/lib/libutil/login.c
+++ /dev/null
@@ -1,57 +0,0 @@
-/*-
- * Copyright (c) 1988, 1993
- *	The Regents of the University of California.  All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in the
- *    documentation and/or other materials provided with the distribution.
- * 3. Neither the name of the University nor the names of its contributors
- *    may be used to endorse or promote products derived from this software
- *    without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
- * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
- * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
- * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- *
- * @(#)login.c	8.1 (Berkeley) 6/4/93
- * $FreeBSD: src/lib/libutil/login.c,v 1.6 1999/08/28 00:05:45 peter Exp $
- */
-
-#include <sys/types.h>
-
-#include <fcntl.h>
-#include <stdlib.h>
-#include <unistd.h>
-#include <utmp.h>
-#include <libutil.h>
-
-void
-login(struct utmp *ut)
-{
-	int fd;
-	int tty;
-
-	tty = ttyslot();
-	if (tty > 0 && (fd = open(_PATH_UTMP, O_WRONLY|O_CREAT, 0644)) >= 0) {
-		(void)lseek(fd, (off_t)(tty * sizeof(struct utmp)), L_SET);
-		(void)write(fd, ut, sizeof(struct utmp));
-		(void)close(fd);
-	}
-	if ((fd = open(_PATH_WTMP, O_WRONLY|O_APPEND, 0)) >= 0) {
-		(void)write(fd, ut, sizeof(struct utmp));
-		(void)close(fd);
-	}
-}
diff --git a/lib/libutil/logout.3 b/lib/libutil/logout.3
deleted file mode 100644
index 6a5809004f..0000000000
--- a/lib/libutil/logout.3
+++ /dev/null
@@ -1,67 +0,0 @@
-.\"
-.\" Copyright (c) 1996 Joerg Wunsch
-.\"
-.\" All rights reserved.
-.\"
-.\" Redistribution and use in source and binary forms, with or without
-.\" modification, are permitted provided that the following conditions
-.\" are met:
-.\" 1. Redistributions of source code must retain the above copyright
-.\"    notice, this list of conditions and the following disclaimer.
-.\" 2. Redistributions in binary form must reproduce the above copyright
-.\"    notice, this list of conditions and the following disclaimer in the
-.\"    documentation and/or other materials provided with the distribution.
-.\"
-.\" THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY EXPRESS OR
-.\" IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
-.\" OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
-.\" IN NO EVENT SHALL THE DEVELOPERS BE LIABLE FOR ANY DIRECT, INDIRECT,
-.\" INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
-.\" NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-.\" DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-.\" THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-.\" (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
-.\" THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-.\"
-.\" $FreeBSD: src/lib/libutil/logout.3,v 1.6.2.4 2001/12/17 10:08:32 ru Exp $
-.\"
-.Dd December 29, 1996
-.Dt LOGOUT 3
-.Os
-.Sh NAME
-.Nm logout
-.Nd remove an entry from the utmp file
-.Sh LIBRARY
-.Lb libutil
-.Sh SYNOPSIS
-.In sys/types.h
-.In libutil.h
-.Ft int
-.Fn logout "const char *line"
-.Sh DESCRIPTION
-The function
-.Fn logout
-searches the
-.Xr utmp 5
-file for the slot described by
-.Ar line
-(usually a tty name).  If such a slot could be found, it will be updated
-with a record where the
-.Em name
-and
-.Em host
-fields are empty, and the time stamp field is updated to the current time.
-.Sh RETURN VALUES
-.Fn Logout
-returns 1 if the slot described by
-.Ar line
-has been found and updated, 0 otherwise.
-.Sh SEE ALSO
-.Xr login 3 ,
-.Xr utmp 5 ,
-.Xr wtmp 5
-.Sh BUGS
-The calling interface of
-.Fn logout
-is inconsistent with that of
-.Xr login 3 .
diff --git a/lib/libutil/logout.c b/lib/libutil/logout.c
deleted file mode 100644
index 9667cbc3a4..0000000000
--- a/lib/libutil/logout.c
+++ /dev/null
@@ -1,67 +0,0 @@
-/*-
- * Copyright (c) 1988, 1993
- *	The Regents of the University of California.  All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in the
- *    documentation and/or other materials provided with the distribution.
- * 3. Neither the name of the University nor the names of its contributors
- *    may be used to endorse or promote products derived from this software
- *    without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
- * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
- * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
- * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- *
- * @(#)logout.c	8.1 (Berkeley) 6/4/93
- * $FreeBSD: src/lib/libutil/logout.c,v 1.6.2.2 2000/09/20 09:54:16 jkh Exp $
- */
-
-#include <sys/types.h>
-#include <sys/time.h>
-
-#include <fcntl.h>
-#include <utmp.h>
-#include <unistd.h>
-#include <stdlib.h>
-#include <string.h>
-#include <libutil.h>
-
-typedef struct utmp UTMP;
-
-int
-logout(const char *line)
-{
-	int fd;
-	UTMP ut;
-	int rval;
-
-	if ((fd = open(_PATH_UTMP, O_RDWR, 0)) < 0)
-		return(0);
-	rval = 0;
-	while (read(fd, &ut, sizeof(UTMP)) == sizeof(UTMP)) {
-		if (!ut.ut_name[0] || strncmp(ut.ut_line, line, UT_LINESIZE))
-			continue;
-		bzero(ut.ut_name, UT_NAMESIZE);
-		bzero(ut.ut_host, UT_HOSTSIZE);
-		(void)time(&ut.ut_time);
-		(void)lseek(fd, -(off_t)sizeof(UTMP), L_INCR);
-		(void)write(fd, &ut, sizeof(UTMP));
-		rval = 1;
-	}
-	(void)close(fd);
-	return(rval);
-}
diff --git a/lib/libutil/logwtmp.3 b/lib/libutil/logwtmp.3
deleted file mode 100644
index 7ec7318402..0000000000
--- a/lib/libutil/logwtmp.3
+++ /dev/null
@@ -1,71 +0,0 @@
-.\"
-.\" Copyright (c) 1996 Joerg Wunsch
-.\"
-.\" All rights reserved.
-.\"
-.\" Redistribution and use in source and binary forms, with or without
-.\" modification, are permitted provided that the following conditions
-.\" are met:
-.\" 1. Redistributions of source code must retain the above copyright
-.\"    notice, this list of conditions and the following disclaimer.
-.\" 2. Redistributions in binary form must reproduce the above copyright
-.\"    notice, this list of conditions and the following disclaimer in the
-.\"    documentation and/or other materials provided with the distribution.
-.\"
-.\" THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY EXPRESS OR
-.\" IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
-.\" OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
-.\" IN NO EVENT SHALL THE DEVELOPERS BE LIABLE FOR ANY DIRECT, INDIRECT,
-.\" INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
-.\" NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-.\" DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-.\" THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-.\" (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
-.\" THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-.\"
-.\" $FreeBSD: src/lib/libutil/logwtmp.3,v 1.7.2.4 2001/12/17 10:08:32 ru Exp $
-.\"
-.Dd December 29, 1996
-.Dt LOGWTMP 3
-.Os
-.Sh NAME
-.Nm logwtmp
-.Nd append a new record to the wtmp file
-.Sh LIBRARY
-.Lb libutil
-.Sh SYNOPSIS
-.In sys/types.h
-.In libutil.h
-.Ft void
-.Fn logwtmp "const char *line" "const char *name" "const char *host"
-.Sh DESCRIPTION
-The function
-.Fn logwtmp
-tries to append a new record to the
-.Xr wtmp 5
-file, using the provided arguments
-.Ar line ,
-.Ar name ,
-and
-.Ar host ,
-and the current time.
-.Pp
-If the length of the hostname string
-.Ar host
-is longer than what would fit into the hostname field of the
-.Xr wtmp 5
-file, it will first be attempted to convert it into a numerical IP
-address using
-.Xr gethostbyname 3 .
-Failing this, the hostname will be recorded as
-.Qq invalid hostname .
-.Pp
-The calling process must have permission to write to the
-.Xr wtmp 5
-file.
-.Sh RETURN VALUES
-None.
-.Sh SEE ALSO
-.Xr gethostbyname 3 ,
-.Xr login 3 ,
-.Xr wtmp 5
diff --git a/lib/libutil/logwtmp.c b/lib/libutil/logwtmp.c
deleted file mode 100644
index a26237ffce..0000000000
--- a/lib/libutil/logwtmp.c
+++ /dev/null
@@ -1,98 +0,0 @@
-/*-
- * Copyright (c) 1988, 1993
- *	The Regents of the University of California.  All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in the
- *    documentation and/or other materials provided with the distribution.
- * 3. Neither the name of the University nor the names of its contributors
- *    may be used to endorse or promote products derived from this software
- *    without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
- * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
- * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
- * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- *
- * @(#)logwtmp.c	8.1 (Berkeley) 6/4/93
- * $FreeBSD: src/lib/libutil/logwtmp.c,v 1.14 2000/01/15 03:26:54 shin Exp $
- */
-
-#include <sys/param.h>
-#include <sys/file.h>
-#include <sys/socket.h>
-#include <sys/stat.h>
-
-#include <netdb.h>
-#include <stdio.h>
-#include <string.h>
-#include <time.h>
-#include <unistd.h>
-#include <utmp.h>
-#include <libutil.h>
-
-/* wrapper for KAME-special getnameinfo() */
-#ifndef NI_WITHSCOPEID
-#define	NI_WITHSCOPEID	0
-#endif
-
-
-void
-logwtmp(const char *line, const char *name, const char *host)
-{
-	struct utmp ut;
-	struct stat buf;
-	char   fullhost[MAXHOSTNAMELEN];
-	int fd;
-	
-	strncpy(fullhost, host, sizeof(fullhost) - 1);	
-	fullhost[sizeof(fullhost) - 1] = '\0';
-	trimdomain(fullhost, UT_HOSTSIZE);
-	host = fullhost;
-
-	if (strlen(host) > UT_HOSTSIZE) {
-		int error;
-		struct addrinfo hints, *res;
-
-		bzero(&hints, sizeof(struct addrinfo));
-		hints.ai_family = AF_UNSPEC;
-		hints.ai_flags = AI_CANONNAME;
-		error = getaddrinfo(host, NULL, &hints, &res);
-		if (error != 0 || res->ai_addr == NULL)
-			host = "invalid hostname";
-		else {
-			error = getnameinfo(res->ai_addr, res->ai_addrlen,
-					  fullhost, strlen(fullhost), NULL, 0,
-					  NI_NUMERICHOST|NI_WITHSCOPEID);
-			if (error != 0) {
-			  fprintf(stderr, "%d", error);
-				host = "invalid hostname";
-			}
-		}
-	}
-
-	if ((fd = open(_PATH_WTMP, O_WRONLY|O_APPEND, 0)) < 0)
-		return;
-	if (fstat(fd, &buf) == 0) {
-		(void) strncpy(ut.ut_line, line, sizeof(ut.ut_line));
-		(void) strncpy(ut.ut_name, name, sizeof(ut.ut_name));
-		(void) strncpy(ut.ut_host, host, sizeof(ut.ut_host));
-		(void) time(&ut.ut_time);
-		if (write(fd, (char *)&ut, sizeof(struct utmp)) !=
-		    sizeof(struct utmp))
-			(void) ftruncate(fd, buf.st_size);
-	}
-	(void) close(fd);
-}
diff --git a/libexec/Makefile b/libexec/Makefile
index 93603fe1ce..ac7b76ebfa 100644
--- a/libexec/Makefile
+++ b/libexec/Makefile
@@ -3,11 +3,9 @@
 
 SUBDIR=	atrun \
 	bootpd \
-	comsat \
 	customcc \
 	dma \
 	fingerd \
-	ftpd \
 	getty \
 	makekey \
 	makewhatis.local \
@@ -17,7 +15,6 @@ SUBDIR=	atrun \
 	revnetgroup \
 	rpc.rquotad \
 	rpc.rstatd \
-	rpc.rusersd \
 	rpc.rwalld \
 	rpc.sprayd \
 	rtld-elf \
@@ -31,6 +28,11 @@ SUBDIR=	atrun \
 	utmp_update \
 	ypxfr
 
+_XXX_PORT_TO_UTMPX = \
+	comsat\
+	ftpd \
+	rpc.rusersd
+
 # maximum parallelism
 #
 SUBDIR_ORDERED=
diff --git a/libexec/comsat/comsat.c b/libexec/comsat/comsat.c
index 07ecb9365a..376455899f 100644
--- a/libexec/comsat/comsat.c
+++ b/libexec/comsat/comsat.c
@@ -52,7 +52,6 @@
 #include <sysexits.h>
 #include <syslog.h>
 #include <unistd.h>
-#include <utmp.h>
 
 int	debug = 0;
 #define	dsyslog	if (debug) syslog
diff --git a/libexec/ftpd/Makefile b/libexec/ftpd/Makefile
index d7cdcfd938..335fb7e041 100644
--- a/libexec/ftpd/Makefile
+++ b/libexec/ftpd/Makefile
@@ -3,7 +3,7 @@
 
 PROG=	ftpd
 MAN=	ftpd.8 ftpchroot.5
-SRCS=	ftpd.c ftpcmd.y logwtmp.c popen.c
+SRCS=	ftpd.c ftpcmd.y popen.c
 
 CFLAGS+=-DSETPROCTITLE -DLOGIN_CAP -DVIRTUAL_HOSTING
 CFLAGS+=-I${.CURDIR}
diff --git a/libexec/ftpd/logwtmp.c b/libexec/ftpd/logwtmp.c
deleted file mode 100644
index dd306fbd13..0000000000
--- a/libexec/ftpd/logwtmp.c
+++ /dev/null
@@ -1,79 +0,0 @@
-/*
- * Copyright (c) 1988, 1993
- *	The Regents of the University of California.  All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in the
- *    documentation and/or other materials provided with the distribution.
- * 3. Neither the name of the University nor the names of its contributors
- *    may be used to endorse or promote products derived from this software
- *    without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
- * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
- * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
- * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- *
- * @(#)logwtmp.c	8.1 (Berkeley) 6/4/93
- * $FreeBSD: src/libexec/ftpd/logwtmp.c,v 1.9.2.2 2002/08/08 12:24:54 yar Exp $
- */
-
-#include <sys/types.h>
-#include <sys/stat.h>
-#include <netinet/in.h>
-#include <arpa/inet.h>
-#include <sys/socket.h>
-
-#include <fcntl.h>
-#include <time.h>
-#include <netdb.h>
-#include <utmp.h>
-#include <unistd.h>
-#include <stdio.h>
-#include <string.h>
-#include <libutil.h>
-#include "extern.h"
-
-static int fd = -1;
-
-/*
- * Modified version of logwtmp that holds wtmp file open
- * after first call, for use with ftp (which may chroot
- * after login, but before logout).
- */
-void
-ftpd_logwtmp(char *line, char *name, struct sockaddr *addr)
-{
-	struct utmp ut;
-	struct stat buf;
-	char host[UT_HOSTSIZE];
-
-	if (addr == NULL)
-		host[0] = '\0';
-	else
-		realhostname_sa(host, sizeof(host), addr, addr->sa_len);
-
-	if (fd < 0 && (fd = open(_PATH_WTMP, O_WRONLY|O_APPEND, 0)) < 0)
-		return;
-	if (fstat(fd, &buf) == 0) {
-		(void)strncpy(ut.ut_line, line, sizeof(ut.ut_line));
-		(void)strncpy(ut.ut_name, name, sizeof(ut.ut_name));
-		(void)strncpy(ut.ut_host, host, sizeof(ut.ut_host));
-		(void)time(&ut.ut_time);
-		if (write(fd, &ut, sizeof(struct utmp)) !=
-		    sizeof(struct utmp))
-			(void)ftruncate(fd, buf.st_size);
-	}
-}
diff --git a/libexec/rpc.rusersd/rusers_proc.c b/libexec/rpc.rusersd/rusers_proc.c
index bbce3785d6..40dae72cf8 100644
--- a/libexec/rpc.rusersd/rusers_proc.c
+++ b/libexec/rpc.rusersd/rusers_proc.c
@@ -38,7 +38,6 @@
 #include <sys/param.h>
 #include <sys/stat.h>
 #include <syslog.h>
-#include <utmp.h>
 #ifdef XIDLE
 #include <setjmp.h>
 #include <X11/Xlib.h>
diff --git a/libexec/talkd/Makefile b/libexec/talkd/Makefile
index 501d1d31f7..96f478eb96 100644
--- a/libexec/talkd/Makefile
+++ b/libexec/talkd/Makefile
@@ -11,6 +11,6 @@ DPADD=	${LIBUTIL}
 LDADD=	-lutil
 
 CFLAGS+=-I${.CURDIR}/../../usr.bin/wall
-CFLAGS+=-I${.CURDIR}/../../usr.bin/who -DSUPPORT_UTMP -DSUPPORT_UTMPX
+CFLAGS+=-I${.CURDIR}/../../usr.bin/who -DSUPPORT_UTMPX
 
 .include <bsd.prog.mk>
diff --git a/libexec/telnetd/Makefile b/libexec/telnetd/Makefile
index 6ed20a6259..0451b667f9 100644
--- a/libexec/telnetd/Makefile
+++ b/libexec/telnetd/Makefile
@@ -12,7 +12,7 @@ SRCS=		authenc.c global.c slc.c state.c sys_term.c telnetd.c \
 WARNS?=		2
 
 CFLAGS+=	-DLINEMODE -DUSE_TERMIO -DDIAGNOSTICS
-CFLAGS+=	-DOLD_ENVIRON -DENV_HACK -DSUPPORT_UTMP -DSUPPORT_UTMPX
+CFLAGS+=	-DOLD_ENVIRON -DENV_HACK -DSUPPORT_UTMPX
 CFLAGS+=	-I${.CURDIR}/../../lib
 
 .if !defined(NO_INET6)
diff --git a/libexec/telnetd/sys_term.c b/libexec/telnetd/sys_term.c
index 71dac32fec..a11b0def31 100644
--- a/libexec/telnetd/sys_term.c
+++ b/libexec/telnetd/sys_term.c
@@ -1323,10 +1323,6 @@ cleanup(int sig __unused)
 	 */
 	sigfillset(&mask);
 	sigprocmask(SIG_SETMASK, &mask, NULL);
-#ifdef SUPPORT_UTMP
-	if (logout(p))
-		logwtmp(p, "", "");
-#endif
 #ifdef SUPPORT_UTMPX
 	if (logoutx(p, 0, DEAD_PROCESS))
 		logwtmpx(p, "", "", 0, DEAD_PROCESS);
diff --git a/libexec/telnetd/telnetd.c b/libexec/telnetd/telnetd.c
index 44cf1a1385..5c2f1856bb 100644
--- a/libexec/telnetd/telnetd.c
+++ b/libexec/telnetd/telnetd.c
@@ -38,9 +38,6 @@
 #include <libutil.h>
 #include <paths.h>
 #include <termcap.h>
-#ifdef SUPPORT_UTMP
-#include <utmp.h>
-#endif
 
 #include <arpa/inet.h>
 
@@ -54,9 +51,6 @@ int	auth_level = 0;
 #include <libtelnet/misc.h>
 
 char	remote_hostname[MAXHOSTNAMELEN];
-#ifdef SUPPORT_UTMP
-size_t	utmp_len = sizeof(remote_hostname) - 1;
-#endif
 int	registerd_host_only = 0;
 
 
@@ -271,13 +265,7 @@ main(int argc, char *argv[])
 			break;
 
 		case 'u':
-#ifdef SUPPORT_UTMP
-			utmp_len = (size_t)atoi(optarg);
-			if (utmp_len >= sizeof(remote_hostname))
-				utmp_len = sizeof(remote_hostname) - 1;
-#else
 			fprintf(stderr, "telnetd: -u option unneeded\n");
-#endif
 			break;
 
 		case 'U':
@@ -641,9 +629,6 @@ terminaltypeok(char *s)
 void
 doit(struct sockaddr *who)
 {
-#ifdef SUPPORT_UTMP
-	int err_; /* XXX */
-#endif
 	int ptynum;
 
 	/*
@@ -675,15 +660,6 @@ doit(struct sockaddr *who)
 	Please contact your net administrator");
 	remote_hostname[sizeof(remote_hostname) - 1] = '\0';
 
-#ifdef SUPPORT_UTMP
-	trimdomain(remote_hostname, UT_HOSTSIZE);
-	if (!isdigit(remote_hostname[0]) && strlen(remote_hostname) > utmp_len)
-		err_ = getnameinfo(who, who->sa_len, remote_hostname,
-				  sizeof(remote_hostname), NULL, 0,
-				  NI_NUMERICHOST|NI_WITHSCOPEID);
-		/* XXX: do 'err_' check */
-#endif
-
 	(void) gethostname(host_name, sizeof(host_name) - 1);
 	host_name[sizeof(host_name) - 1] = '\0';
 	hostname = host_name;
diff --git a/sbin/Makefile b/sbin/Makefile
index 9ddea1ce39..54b0b4a9e6 100644
--- a/sbin/Makefile
+++ b/sbin/Makefile
@@ -79,9 +79,9 @@ SUBDIR=	adjkerntz \
 	ping \
 	ping6 \
 	quotacheck \
-	reboot \
 	rconfig \
 	rcorder \
+	reboot \
 	resolvconf \
 	restore \
 	route \
diff --git a/sbin/init/Makefile b/sbin/init/Makefile
index bfc244fa29..91c2d2f5ec 100644
--- a/sbin/init/Makefile
+++ b/sbin/init/Makefile
@@ -10,7 +10,7 @@ INSTALLFLAGS= -b -B.bak
 INSTALLFLAGS+= -fschg
 .endif
 CFLAGS+=-DDEBUGSHELL -DSECURE -DLOGIN_CAP -DCOMPAT_SYSV_INIT
-CFLAGS+=-DSUPPORT_UTMP -DSUPPORT_UTMPX
+CFLAGS+=-DSUPPORT_UTMPX
 DPADD=	${LIBUTIL} ${LIBCRYPT} ${LIBCRYPTO}
 LDADD=	-lutil -lcrypt -lprivate_crypto
 LDFLAGS+=	${PRIVATELIB_LDFLAGS}
diff --git a/sbin/init/init.c b/sbin/init/init.c
index 15dcd06187..3cfac9f984 100644
--- a/sbin/init/init.c
+++ b/sbin/init/init.c
@@ -616,10 +616,6 @@ clear_session_logs(session_t *sp)
 	if (logoutx(line, 0, DEAD_PROCESS))
 		 logwtmpx(line, "", "", 0, DEAD_PROCESS);
 #endif
-#ifdef SUPPORT_UTMP
-	if (logout(line))
-		logwtmp(line, "", "");
-#endif
 }
 
 /*
@@ -882,9 +878,6 @@ f_runcom(void)
 	runcom_mode = AUTOBOOT;		/* the default */
 #ifdef SUPPORT_UTMPX
 	logwtmpx("~", "reboot", "", 0, INIT_PROCESS);
-#endif
-#ifdef SUPPORT_UTMP
-	logwtmp("~", "reboot", "");
 #endif
 	return read_ttys;
 }
@@ -1550,9 +1543,6 @@ f_death(void)
 #ifdef SUPPORT_UTMPX
 	logwtmpx("~", "shutdown", "", 0, INIT_PROCESS);
 #endif
-#ifdef SUPPORT_UTMP
-	logwtmp("~", "shutdown", "");
-#endif
 
 	for (sp = sessions; sp; sp = sp->se_next) {
 		sp->se_flags |= SE_SHUTDOWN;
diff --git a/sbin/reboot/Makefile b/sbin/reboot/Makefile
index 30aa22917f..012f8660bd 100644
--- a/sbin/reboot/Makefile
+++ b/sbin/reboot/Makefile
@@ -4,7 +4,7 @@
 PROG=	reboot
 DPADD=	${LIBUTIL}
 LDADD=	-lutil
-CFLAGS+=-DSUPPORT_UTMP -DSUPPORT_UTMPX
+CFLAGS+=-DSUPPORT_UTMPX
 MAN=	reboot.8
 MLINKS=	reboot.8 halt.8 reboot.8 fastboot.8 reboot.8 fasthalt.8
 
diff --git a/sbin/reboot/reboot.c b/sbin/reboot/reboot.c
index 3adf86b882..f7da77695f 100644
--- a/sbin/reboot/reboot.c
+++ b/sbin/reboot/reboot.c
@@ -134,9 +134,6 @@ main(int argc, char *argv[])
 			syslog(LOG_CRIT, "rebooted by %s", user);
 		}
 	}
-#ifdef SUPPORT_UTMP
-	logwtmp("~", "shutdown", "");
-#endif
 #ifdef SUPPORT_UTMPX
 	logwtmpx("~", "shutdown", "", INIT_PROCESS, 0);
 #endif
diff --git a/share/man/man5/Makefile b/share/man/man5/Makefile
index 845396976d..9f3fa80215 100644
--- a/share/man/man5/Makefile
+++ b/share/man/man5/Makefile
@@ -54,7 +54,6 @@ MAN=	acct.5 \
 	sysctl.conf.5 \
 	tmpfs.5 \
 	autofs.5 \
-	utmp.5 \
 	utmpx.5 \
 	uuids.5 \
 	varsym.conf.5
@@ -72,8 +71,6 @@ MLINKS+=null.5 nullfs.5
 MLINKS+=hosts.equiv.5 rhosts.5
 MLINKS+=passwd.5 master.passwd.5
 MLINKS+=resolver.5 resolv.conf.5
-MLINKS+=utmp.5 lastlog.5 \
-	utmp.5 wtmp.5
 MLINKS+=utmpx.5 lastlogx.5 \
 	utmpx.5 wtmpx.5
 
diff --git a/share/man/man5/utmp.5 b/share/man/man5/utmp.5
deleted file mode 100644
index 4ce24614a1..0000000000
--- a/share/man/man5/utmp.5
+++ /dev/null
@@ -1,267 +0,0 @@
-.\" Copyright (c) 1980, 1991, 1993
-.\"	The Regents of the University of California.  All rights reserved.
-.\"
-.\" Redistribution and use in source and binary forms, with or without
-.\" modification, are permitted provided that the following conditions
-.\" are met:
-.\" 1. Redistributions of source code must retain the above copyright
-.\"    notice, this list of conditions and the following disclaimer.
-.\" 2. Redistributions in binary form must reproduce the above copyright
-.\"    notice, this list of conditions and the following disclaimer in the
-.\"    documentation and/or other materials provided with the distribution.
-.\" 3. Neither the name of the University nor the names of its contributors
-.\"    may be used to endorse or promote products derived from this software
-.\"    without specific prior written permission.
-.\"
-.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
-.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
-.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
-.\" ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
-.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
-.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
-.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
-.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
-.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
-.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
-.\" SUCH DAMAGE.
-.\"
-.\"     @(#)utmp.5	8.2 (Berkeley) 3/17/94
-.\" $FreeBSD: src/share/man/man5/utmp.5,v 1.9.2.8 2001/12/17 11:30:15 ru Exp $
-.\" $DragonFly: src/share/man/man5/utmp.5,v 1.3 2006/05/26 19:39:40 swildner Exp $
-.\"
-.Dd November 14, 2001
-.Dt UTMP 5
-.Os
-.Sh NAME
-.Nm utmp ,
-.Nm wtmp ,
-.Nm lastlog
-.Nd login records
-.Sh SYNOPSIS
-.In sys/types.h
-.In utmp.h
-.Sh DESCRIPTION
-The file
-.In utmp.h
-declares the structures used to record information about current
-users in the file
-.Nm ,
-logins and logouts in the file
-.Nm wtmp ,
-and last logins in the file
-.Nm lastlog .
-The time stamps of date changes, shutdowns and reboots are also logged in
-the
-.Nm wtmp
-file.
-.Bd -literal -offset indent
-#define _PATH_UTMP      "/var/run/utmp"
-#define _PATH_WTMP      "/var/log/wtmp"
-#define _PATH_LASTLOG   "/var/log/lastlog"
-
-#define UT_NAMESIZE     16
-#define UT_LINESIZE     8
-#define UT_HOSTSIZE     16
-
-struct lastlog {
-        time_t  ll_time;		/* When user logged in */
-        char    ll_line[UT_LINESIZE];	/* Terminal line name */
-        char    ll_host[UT_HOSTSIZE];	/* Host user came from */
-};
-
-struct utmp {
-        char    ut_line[UT_LINESIZE];	/* Terminal line name */
-        char    ut_name[UT_NAMESIZE];	/* User's login name */
-        char    ut_host[UT_HOSTSIZE];	/* Host user came from */
-        time_t  ut_time;		/* When user logged in */
-};
-.Ed
-.Pp
-The
-.Nm lastlog
-file is a linear array of
-.Vt lastlog
-structures indexed by a user's
-.Tn UID .
-The
-.Nm
-file is a linear array of
-.Vt utmp
-structures indexed by a terminal line number
-(see
-.Xr ttyslot 3 ) .
-The
-.Nm wtmp
-file consists of
-.Vt utmp
-structures and is a binary log file,
-that is, grows linearly at its end.
-.Pp
-Each time a user logs in, the
-.Xr login 1
-program looks up the user's
-.Tn UID
-in the file
-.Nm lastlog .
-If it is found, the timestamp of the last time the user logged
-in, the terminal line and the hostname
-are written to the standard output (unless the login is
-.Em quiet ,
-see
-.Xr login 1 ) .
-The
-.Xr login 1
-program then records the new login time in the file
-.Nm lastlog .
-.Pp
-After the new
-.Vt lastlog
-record is written,
-.\" the
-.\" .Xr libutil 3
-.\" routine
-the file
-.Nm
-is opened and the
-.Vt utmp
-record for the user is inserted.
-This record remains there until
-the user logs out at which time it is deleted.
-The
-.Nm
-file is used by the programs
-.Xr rwho 1 ,
-.Xr users 1 ,
-.Xr w 1 ,
-and
-.Xr who 1 .
-.Pp
-Next, the
-.Xr login 1
-program opens the file
-.Nm wtmp ,
-and appends the user's
-.Vt utmp
-record.
-The user's subsequent logout from the terminal
-line is marked by a special
-.Vt utmp
-record with
-.Va ut_line
-set accordingly,
-.Va ut_time
-updated, but
-.Va ut_name
-and
-.Va ut_host
-both empty
-(see
-.Xr init 8 ) .
-The
-.Nm wtmp
-file is used by the programs
-.Xr last 1
-and
-.Xr ac 8 .
-.Pp
-In the event of a date change, a shutdown or reboot, the
-following items are logged in the
-.Nm wtmp
-file.
-.Pp
-.Bl -tag -width ".Li shutdown" -compact
-.It Li reboot
-.It Li shutdown
-A system reboot or shutdown has been initiated.
-The character
-.Ql \&~
-is placed in the field
-.Va ut_line ,
-and
-.Li reboot
-or
-.Li shutdown
-in the field
-.Va ut_name
-(see
-.Xr shutdown 8
-and
-.Xr reboot 8 ) .
-.Pp
-.It Li date
-The system time has been manually or automatically updated
-(see
-.Xr date 1 ) .
-The command name
-.Li date
-is recorded in the field
-.Va ut_name .
-In the field
-.Va ut_line ,
-the character
-.Ql \&|
-indicates the time prior to the change, and the character
-.Ql \&{
-indicates the new time.
-.El
-.Sh NOTES
-The
-.Nm wtmp
-file can grow rapidly on busy systems, so daily or weekly rotation
-is recommended.
-It is maintained by
-.Xr newsyslog 8 .
-.Pp
-If any one of these files does not exist, it is not created by
-.Xr login 1 .
-They must be created manually.
-.Pp
-The supplied
-.Xr login 3 ,
-.Xr logout 3 ,
-and
-.Xr logwtmp 3
-utility functions should be used to perform
-the standard actions on the
-.Nm
-and
-.Nm wtmp
-files in order to maintain the portability across
-systems with different formats of those files.
-.Sh FILES
-.Bl -tag -width ".Pa /var/log/lastlog" -compact
-.It Pa /var/run/utmp
-The
-.Nm
-file.
-.It Pa /var/log/wtmp
-The
-.Nm wtmp
-file.
-.It Pa /var/log/lastlog
-The
-.Nm lastlog
-file.
-.El
-.Sh SEE ALSO
-.Xr last 1 ,
-.Xr login 1 ,
-.Xr w 1 ,
-.Xr who 1 ,
-.Xr login 3 ,
-.Xr logout 3 ,
-.Xr logwtmp 3 ,
-.Xr ttyslot 3 ,
-.Xr ac 8 ,
-.Xr init 8
-.Sh HISTORY
-A
-.Nm
-and
-.Nm wtmp
-file format appeared in
-.At v6 .
-The
-.Nm lastlog
-file format appeared in
-.Bx 3.0 .
diff --git a/sys/sys/param.h b/sys/sys/param.h
index 2c2ec5d971..a6e949cc16 100644
--- a/sys/sys/param.h
+++ b/sys/sys/param.h
@@ -220,13 +220,12 @@
  * Redefined constants are from POSIX 1003.1 limits file.
  *
  * MAXCOMLEN should be >= sizeof(ac_comm) (see <acct.h>)
- * MAXLOGNAME should be == UT_NAMESIZE+1 (see <utmp.h>)
  */
 #include <sys/syslimits.h>
 
 #define MAXCOMLEN	16		/* max command name remembered */
 #define MAXINTERP	32		/* max interpreter file name length */
-#define MAXLOGNAME	17		/* max login name length (incl. NUL) */
+#define MAXLOGNAME	33		/* max login name length (incl. NUL) */
 #define MAXUPRC		CHILD_MAX	/* max simultaneous processes */
 #define NCARGS		ARG_MAX		/* max bytes for an exec function */
 #define NGROUPS		NGROUPS_MAX	/* max number groups */
diff --git a/usr.bin/Makefile b/usr.bin/Makefile
index 85a3597050..f96dd407b3 100644
--- a/usr.bin/Makefile
+++ b/usr.bin/Makefile
@@ -59,7 +59,6 @@ SUBDIR=	alias \
 	file \
 	file2c \
 	find \
-	finger \
 	flex \
 	fmt \
 	fold \
@@ -249,6 +248,9 @@ SUBDIR=	alias \
 	ypmatch \
 	ypwhich
 
+_XXX_PORT_TO_UTMPX = \
+	finger
+
 .if defined(WANT_HESIOD)
 SUBDIR+=hesinfo
 .endif
diff --git a/usr.bin/finger/Makefile b/usr.bin/finger/Makefile
index 5ad7fed9e2..9652ac54a3 100644
--- a/usr.bin/finger/Makefile
+++ b/usr.bin/finger/Makefile
@@ -10,6 +10,6 @@ MAN=	finger.1 finger.conf.5
 DPADD+=	${LIBUTIL}
 LDADD+=	-lutil
 
-CFLAGS+= -I${.CURDIR}/../who -DSUPPORT_UTMP -DSUPPORT_UTMPX
+CFLAGS+= -I${.CURDIR}/../who -DSUPPORT_UTMPX
 
 .include <bsd.prog.mk>
diff --git a/usr.bin/finger/lprint.c b/usr.bin/finger/lprint.c
index 933f6ed4c1..abec08f9ff 100644
--- a/usr.bin/finger/lprint.c
+++ b/usr.bin/finger/lprint.c
@@ -31,7 +31,6 @@
  *
  * @(#)lprint.c	8.3 (Berkeley) 4/28/95
  * $FreeBSD: src/usr.bin/finger/lprint.c,v 1.10.2.4 2002/07/03 01:14:24 des Exp $
- * $DragonFly: src/usr.bin/finger/lprint.c,v 1.4 2004/09/03 19:13:23 dillon Exp $
  */
 
 #include <sys/types.h>
@@ -48,7 +47,6 @@
 #include <stdio.h>
 #include <string.h>
 #include <unistd.h>
-#include <utmp.h>
 #include "finger.h"
 #include "pathnames.h"
 #include "extern.h"
diff --git a/usr.bin/finger/net.c b/usr.bin/finger/net.c
index 514160300c..21ccb55c1a 100644
--- a/usr.bin/finger/net.c
+++ b/usr.bin/finger/net.c
@@ -45,7 +45,6 @@
 #include <stdlib.h>
 #include <string.h>
 #include <unistd.h>
-#include <utmp.h>
 #include "finger.h"
 
 static void cleanup(int sig);
diff --git a/usr.bin/finger/sprint.c b/usr.bin/finger/sprint.c
index e8620bc58c..7e1eaa9e31 100644
--- a/usr.bin/finger/sprint.c
+++ b/usr.bin/finger/sprint.c
@@ -31,9 +31,9 @@
  *
  * @(#)sprint.c	8.3 (Berkeley) 4/28/95
  * $FreeBSD: src/usr.bin/finger/sprint.c,v 1.11.2.5 2002/07/03 01:14:24 des Exp $
- * $DragonFly: src/usr.bin/finger/sprint.c,v 1.4 2008/02/09 17:12:05 matthias Exp $
  */
 
+#include <sys/param.h>
 #include <sys/socket.h>
 #include <db.h>
 #include <err.h>
@@ -42,7 +42,6 @@
 #include <stdio.h>
 #include <string.h>
 #include <time.h>
-#include <utmp.h>
 #include "finger.h"
 
 static void	  stimeprint(WHERE *);
@@ -78,7 +77,7 @@ sflag_print(void)
 	 */
 #define	MAXREALNAME	20
 #define MAXHOSTNAME     17      /* in reality, hosts are never longer than 16 */
-	(void)printf("%-*s %-*s%s  %s\n", UT_NAMESIZE, "Login", MAXREALNAME,
+	(void)printf("%-*s %-*s%s  %s\n", MAXLOGNAME, "Login", MAXREALNAME,
 	    "Name", " TTY  Idle  Login  Time ", (gflag) ? "" :
 	    oflag ? "Office  Phone" : "Where");
 
@@ -95,7 +94,7 @@ sflag_print(void)
 			namelen = MAXREALNAME;
 			if (w->info == LOGGEDIN && !w->writable)
 				--namelen;	/* leave space before `*' */
-			(void)printf("%-*.*s %-*.*s", UT_NAMESIZE, UT_NAMESIZE,
+			(void)printf("%-*.*s %-*.*s", MAXLOGNAME, MAXLOGNAME,
 				pn->name, MAXREALNAME, namelen,
 				pn->realname ? pn->realname : "");
 			if (!w->loginat) {
diff --git a/usr.bin/last/Makefile b/usr.bin/last/Makefile
index 4e251316e1..c1c86a6690 100644
--- a/usr.bin/last/Makefile
+++ b/usr.bin/last/Makefile
@@ -3,6 +3,6 @@
 
 PROG=	last
 
-CFLAGS+=-DSUPPORT_UTMP -DSUPPORT_UTMPX -I${.CURDIR}/../../lib/libc/stdtime
+CFLAGS+=-DSUPPORT_UTMPX -I${.CURDIR}/../../lib/libc/stdtime
 
 .include <bsd.prog.mk>
diff --git a/usr.bin/last/last.c b/usr.bin/last/last.c
index 4a171d6e84..ee73369566 100644
--- a/usr.bin/last/last.c
+++ b/usr.bin/last/last.c
@@ -46,9 +46,6 @@
 #ifdef SUPPORT_UTMPX
 #include <utmpx.h>
 #endif
-#ifdef SUPPORT_UTMP
-#include <utmp.h>
-#endif
 
 #ifndef UT_NAMESIZE
 #define UT_NAMESIZE 8
@@ -105,9 +102,6 @@ static char	*ttyconv(char *);
 #ifdef SUPPORT_UTMPX
 static void	 wtmpx(const char *, int, int, int);
 #endif
-#ifdef SUPPORT_UTMP
-static void	 wtmp(const char *, int, int, int);
-#endif
 static char	*fmttime(time_t, int);
 static void	 usage(void);
 
@@ -195,39 +189,17 @@ main(int argc, char *argv[])
 		}
 	}
 	if (file == NULL) {
-		/* default to wtmpx */
 #ifdef SUPPORT_UTMPX
 		if (access(_PATH_WTMPX, R_OK) == 0)
 			file = _PATH_WTMPX;
-		else
-#endif
-#ifdef SUPPORT_UTMP
-		if (access(_PATH_WTMP, R_OK) == 0)
-			file = _PATH_WTMP;
 #endif
 		if (file == NULL)
-#if defined(SUPPORT_UTMPX) && defined(SUPPORT_UTMP)
-			errx(1, "Cannot access `%s' or `%s'", _PATH_WTMPX,
-			    _PATH_WTMP);
-#elif defined(SUPPORT_UTMPX)
+#if defined(SUPPORT_UTMPX)
 			errx(1, "Cannot access `%s'", _PATH_WTMPX);
-#elif defined(SUPPORT_UTMP)
-			errx(1, "Cannot access `%s'", _PATH_WTMP);
-#else
-			errx(1, "No utmp or utmpx support compiled in.");
 #endif
 	}
-#if defined(SUPPORT_UTMPX) && defined(SUPPORT_UTMP)
-	if (file[strlen(file) - 1] == 'x')
-		wtmpx(file, namesize, linesize, hostsize);
-	else
-		wtmp(file, namesize, linesize, hostsize);
-#elif defined(SUPPORT_UTMPX)
+#if defined(SUPPORT_UTMPX)
 	wtmpx(file, namesize, linesize, hostsize);
-#elif defined(SUPPORT_UTMP)
-	wtmp(file, namesize, linesize, hostsize);
-#else
-	errx(1, "No utmp or utmpx support compiled in.");
 #endif
 	exit(0);
 }
@@ -342,22 +314,6 @@ fmttime(time_t t, int flags)
 	return (tbuf);
 }
 
-#ifdef SUPPORT_UTMP
-#define TYPE(a)	0
-#define NAMESIZE UT_NAMESIZE
-#define LINESIZE UT_LINESIZE
-#define HOSTSIZE UT_HOSTSIZE
-#define ut_timefld ut_time
-#define FIRSTVALID 0
-#include "want.c"
-#undef TYPE
-#undef NAMESIZE
-#undef LINESIZE
-#undef HOSTSIZE
-#undef ut_timefld
-#undef FIRSTVALID
-#endif
-
 #ifdef SUPPORT_UTMPX
 #define utmp utmpx
 #define want wantx
diff --git a/usr.bin/systat/Makefile b/usr.bin/systat/Makefile
index 22bb0cbaca..88632666dd 100644
--- a/usr.bin/systat/Makefile
+++ b/usr.bin/systat/Makefile
@@ -21,6 +21,6 @@ LDADD+=	-lutil
 CFLAGS+=	-I${_SHLIBDIRPREFIX}/usr/include/priv/ncurses
 LDFLAGS+=	${PRIVATELIB_LDFLAGS}
 
-CFLAGS+= -I${.CURDIR}/../who -DSUPPORT_UTMP -DSUPPORT_UTMPX
+CFLAGS+= -I${.CURDIR}/../who -DSUPPORT_UTMPX
 
 .include <bsd.prog.mk>
diff --git a/usr.bin/users/Makefile b/usr.bin/users/Makefile
index b6caa023d1..7c917d4fb4 100644
--- a/usr.bin/users/Makefile
+++ b/usr.bin/users/Makefile
@@ -7,6 +7,6 @@ SRCS=	users.c utmpentry.c
 DPADD=	${LIBUTIL}
 LDADD=	-lutil
 
-CFLAGS+= -I${.CURDIR}/../who -DSUPPORT_UTMP -DSUPPORT_UTMPX
+CFLAGS+= -I${.CURDIR}/../who -DSUPPORT_UTMPX
 
 .include <bsd.prog.mk>
diff --git a/usr.bin/w/Makefile b/usr.bin/w/Makefile
index cc05d02fd4..84112fa167 100644
--- a/usr.bin/w/Makefile
+++ b/usr.bin/w/Makefile
@@ -12,7 +12,7 @@ LINKS=	${BINDIR}/w ${BINDIR}/uptime
 WARNS?=	3
 NO_STRICT_ALIASING=
 
-CFLAGS+=	-DSUPPORT_UTMP -DSUPPORT_UTMPX
+CFLAGS+=-DSUPPORT_UTMPX
 .PATH: ${.CURDIR}/../../bin/ps
 
 .include <bsd.prog.mk>
diff --git a/usr.bin/w/w.c b/usr.bin/w/w.c
index 86c23fbc65..437089048b 100644
--- a/usr.bin/w/w.c
+++ b/usr.bin/w/w.c
@@ -65,9 +65,6 @@
 #include <stdlib.h>
 #include <string.h>
 #include <unistd.h>
-#ifdef SUPPORT_UTMP
-#include <utmp.h>
-#endif
 #ifdef SUPPORT_UTMPX
 #include <utmpx.h>
 #endif
@@ -79,9 +76,6 @@
 #include "extern.h"
 
 struct timeval	boottime;
-#ifdef SUPPORT_UTMP
-struct utmp	utmp;
-#endif
 struct winsize	ws;
 kvm_t	       *kd;
 time_t		now;		/* the current time of day */
@@ -120,7 +114,7 @@ struct	entry {
 #define debugproc(p) *((struct kinfo_proc **)&(p)->kp_spare[0])
 
 static void		 pr_header(time_t *, int);
-#if defined(SUPPORT_UTMP) || defined(SUPPORT_UTMPX)
+#if defined(SUPPORT_UTMPX)
 static struct stat	*ttystat(char *, int);
 static void	process(struct entry *);
 #endif
@@ -138,9 +132,6 @@ main(int argc, char **argv)
 	in_addr_t l;
 	int ch, i, nentries, nusers, wcmd, longidle, dropgid;
 	char *memf, *nlistf, *p, *x;
-#ifdef SUPPORT_UTMP
-	struct utmp *ut;
-#endif
 #ifdef SUPPORT_UTMPX
 	struct utmpx *utx;
 #endif
@@ -213,9 +204,6 @@ main(int argc, char **argv)
 #ifdef SUPPORT_UTMPX
 	setutxent();
 #endif
-#ifdef SUPPORT_UTMP
-	setutent();
-#endif
 
 	if (*argv)
 		sel_users = argv;
@@ -268,57 +256,9 @@ main(int argc, char **argv)
 	}
 #endif
 
-#ifdef SUPPORT_UTMP
-	while ((ut = getutent()) != NULL) {
-		if (ut->ut_name[0] == '\0')
-			continue;
-		++nusers;
-		if (sel_users) {
-			int usermatch;
-			char **user;
-
-			usermatch = 0;
-			for (user = sel_users; !usermatch && *user; user++)
-				if (!strncmp(ut->ut_name, *user, UT_NAMESIZE))
-					usermatch = 1;
-			if (!usermatch)
-				continue;
-		}
-
-		/* Don't process entries that we have utmpx for */
-		for (ep = ehead; ep != NULL; ep = ep->next) {
-			if (strncmp(ep->line, ut->ut_line,
-			    sizeof(ut->ut_line)) == 0)
-				break;
-		}
-		if (ep != NULL) {
-			--nusers; /* Duplicate entry */
-			continue;
-		}
-
-		if ((ep = calloc(1, sizeof(struct entry))) == NULL)
-			err(1, NULL);
-		(void)memcpy(ep->name, ut->ut_name, sizeof(ut->ut_name));
-		(void)memcpy(ep->line, ut->ut_line, sizeof(ut->ut_line));
-		(void)memcpy(ep->host, ut->ut_host, sizeof(ut->ut_host));
-		ep->name[sizeof(ut->ut_name)] = '\0';
-		ep->line[sizeof(ut->ut_line)] = '\0';
-		ep->host[sizeof(ut->ut_host)] = '\0';
-		ep->tv.tv_sec = ut->ut_time;
-
-		*nextp = ep;
-		nextp = &(ep->next);
-		if (wcmd != 0)
-			process(ep);
-	}
-#endif
-
 #ifdef SUPPORT_UTMPX
 	endutxent();
 #endif
-#ifdef SUPPORT_UTMP
-	endutent();
-#endif	
 	
 	if (header || wcmd == 0) {
 		pr_header(&now, nusers);
@@ -410,7 +350,7 @@ main(int argc, char **argv)
 			*nextp = save;
 		}
 	}
-#if defined(SUPPORT_UTMP) && defined(SUPPORT_UTMPX)
+#if defined(SUPPORT_UTMPX)
 	else if (ehead != NULL) {
 		struct entry *from = ehead, *save;
 
@@ -610,7 +550,7 @@ this_is_uptime(const char *s)
 	return (-1);
 }
 
-#if defined(SUPPORT_UTMP) || defined(SUPPORT_UTMPX)
+#if defined(SUPPORT_UTMPX)
 static void
 process(struct entry *ep)
 {
diff --git a/usr.bin/wall/Makefile b/usr.bin/wall/Makefile
index 81e3c9638e..5b2618e6c4 100644
--- a/usr.bin/wall/Makefile
+++ b/usr.bin/wall/Makefile
@@ -10,6 +10,6 @@ BINMODE=2555
 DPADD+=	${LIBUTIL}
 LDADD+=	-lutil
 
-CFLAGS+= -I${.CURDIR}/../who -DSUPPORT_UTMP -DSUPPORT_UTMPX
+CFLAGS+= -I${.CURDIR}/../who -DSUPPORT_UTMPX
 
 .include <bsd.prog.mk>
diff --git a/usr.bin/who/Makefile b/usr.bin/who/Makefile
index 68d3b1d324..80089e1131 100644
--- a/usr.bin/who/Makefile
+++ b/usr.bin/who/Makefile
@@ -1,10 +1,9 @@
 #	@(#)Makefile	8.1 (Berkeley) 6/6/93
-# $DragonFly: src/usr.bin/who/Makefile,v 1.3 2007/08/27 16:51:01 pavalos Exp $
 
 PROG=	who
 
 SRCS+=	who.c utmpentry.c
 
-CFLAGS+=	-DSUPPORT_UTMPX -DSUPPORT_UTMP
+CFLAGS+=-DSUPPORT_UTMPX
 
 .include <bsd.prog.mk>
diff --git a/usr.bin/who/utmpentry.c b/usr.bin/who/utmpentry.c
index 9c2a2a62d9..139bd7f3f9 100644
--- a/usr.bin/who/utmpentry.c
+++ b/usr.bin/who/utmpentry.c
@@ -38,9 +38,6 @@
 #include <string.h>
 #include <time.h>
 
-#ifdef SUPPORT_UTMP
-#include <utmp.h>
-#endif
 #ifdef SUPPORT_UTMPX
 #include <utmpx.h>
 #endif
@@ -80,15 +77,11 @@
 	((void)sizeof(struct { unsigned : ((x) ? 1 : -1); }))
 
 
-#ifdef SUPPORT_UTMP
-static void getentry(struct utmpentry *, struct utmp *);
-static struct timespec utmptime = {0, 0};
-#endif
 #ifdef SUPPORT_UTMPX
 static void getentryx(struct utmpentry *, struct utmpx *);
 static struct timespec utmpxtime = {0, 0};
 #endif
-#if defined(SUPPORT_UTMPX) || defined(SUPPORT_UTMP)
+#if defined(SUPPORT_UTMPX)
 static int setup(const char *);
 static void adjust_size(struct utmpentry *e);
 #endif
@@ -98,7 +91,7 @@ int etype = 1 << USER_PROCESS;
 static int numutmp = 0;
 static struct utmpentry *ehead;
 
-#if defined(SUPPORT_UTMPX) || defined(SUPPORT_UTMP)
+#if defined(SUPPORT_UTMPX)
 static void
 adjust_size(struct utmpentry *e)
 {
@@ -122,9 +115,6 @@ setup(const char *fname)
 	if (fname == NULL) {
 #ifdef SUPPORT_UTMPX
 		setutxent();
-#endif
-#ifdef SUPPORT_UTMP
-		setutent();
 #endif
 	} else {
 		size_t len = strlen(fname);
@@ -136,16 +126,6 @@ setup(const char *fname)
 			if (utmpxname(fname) == 0)
 				warnx("Cannot set utmpx file to `%s'",
 				    fname);
-#else
-			warnx("utmpx support not compiled in");
-#endif
-		} else {
-#ifdef SUPPORT_UTMP
-			if (utmpname(fname) == 0)
-				warnx("Cannot set utmp file to `%s'",
-				    fname);
-#else
-			warnx("utmp support not compiled in");
 #endif
 		}
 	}
@@ -162,20 +142,6 @@ setup(const char *fname)
 			    what &= ~1;
 		}
 	}
-#endif
-#ifdef SUPPORT_UTMP
-	if (what & 2) {
-		sfname = fname ? fname : _PATH_UTMP;
-		if (stat(sfname, &st) == -1) {
-			warn("Cannot stat `%s'", sfname);
-			what &= ~2;
-		} else {
-			if (timespeccmp(&st.st_mtimespec, &utmptime, >))
-				utmptime = st.st_mtimespec;
-			else
-				what &= ~2;
-		}
-	}
 #endif
 	return what;
 }
@@ -186,9 +152,6 @@ endutentries(void)
 {
 	struct utmpentry *ep;
 
-#ifdef SUPPORT_UTMP
-	timespecclear(&utmptime);
-#endif
 #ifdef SUPPORT_UTMPX
 	timespecclear(&utmpxtime);
 #endif
@@ -208,10 +171,7 @@ getutentries(const char *fname, struct utmpentry **epp)
 #ifdef SUPPORT_UTMPX
 	struct utmpx *utx;
 #endif
-#ifdef SUPPORT_UTMP
-	struct utmp *ut;
-#endif
-#if defined(SUPPORT_UTMP) || defined(SUPPORT_UTMPX)
+#if defined(SUPPORT_UTMPX)
 	struct utmpentry *ep;
 	int what = setup(fname);
 	struct utmpentry **nextp = &ehead;
@@ -242,32 +202,8 @@ getutentries(const char *fname, struct utmpentry **epp)
 	}
 #endif
 
-#ifdef SUPPORT_UTMP
-	if ((etype & (1 << USER_PROCESS)) != 0) {
-		while ((what & 2) && (ut = getutent()) != NULL) {
-			if (fname == NULL && (*ut->ut_name == '\0' ||
-			    *ut->ut_line == '\0'))
-				continue;
-			/* Don't process entries that we have utmpx for */
-			for (ep = ehead; ep != NULL; ep = ep->next) {
-				if (strncmp(ep->line, ut->ut_line,
-				    sizeof(ut->ut_line)) == 0)
-					break;
-			}
-			if (ep != NULL)
-				continue;
-			if ((ep = calloc(1, sizeof(*ep))) == NULL) {
-				warn(NULL);
-				return 0;
-			}
-			getentry(ep, ut);
-			*nextp = ep;
-			nextp = &(ep->next);
-		}
-	}
-#endif
 	numutmp = 0;
-#if defined(SUPPORT_UTMP) || defined(SUPPORT_UTMPX)
+#if defined(SUPPORT_UTMPX)
 	if (ehead != NULL) {
 		struct utmpentry *from = ehead, *save;
 		
@@ -286,48 +222,8 @@ getutentries(const char *fname, struct utmpentry **epp)
 	}
 	*epp = ehead;
 	return numutmp;
-#else
-	*epp = NULL;
-	return 0;
-#endif
-}
-
-#ifdef SUPPORT_UTMP
-static void
-getentry(struct utmpentry *e, struct utmp *up)
-{
-#if 1
-	COMPILE_ASSERT(sizeof(e->name) > sizeof(up->ut_name));
-	COMPILE_ASSERT(sizeof(e->line) > sizeof(up->ut_line));
-	COMPILE_ASSERT(sizeof(e->host) > sizeof(up->ut_host));
 #endif
-
-	/*
-	 * e has just been calloc'd. We don't need to clear it or
-	 * append null-terminators, because its length is strictly
-	 * greater than the source string. Use strncpy to _read_
-	 * up->ut_* because they may not be terminated. For this
-	 * reason we use the size of the _source_ as the length
-	 * argument.
-	 */
-
-	snprintf(e->name, sizeof(e->name), "%.*s",
-		 (int)sizeof(up->ut_name), up->ut_name);
-	snprintf(e->line, sizeof(e->line), "%.*s",
-		 (int)sizeof(up->ut_line), up->ut_line);
-	snprintf(e->host, sizeof(e->host), "%.*s",
-		 (int)sizeof(up->ut_host), up->ut_host);
-
-	e->tv.tv_sec = up->ut_time;
-	e->tv.tv_usec = 0;
-	e->pid = 0;
-	e->term = 0;
-	e->exit = 0;
-	e->sess = 0;
-	e->type = USER_PROCESS;
-	adjust_size(e);
 }
-#endif
 
 #ifdef SUPPORT_UTMPX
 static void
diff --git a/usr.bin/who/utmpentry.h b/usr.bin/who/utmpentry.h
index 6ebd8937e2..0a0f65f6d3 100644
--- a/usr.bin/who/utmpentry.h
+++ b/usr.bin/who/utmpentry.h
@@ -34,13 +34,6 @@
 # define WHO_NAME_LEN		_UTX_USERSIZE
 # define WHO_LINE_LEN		_UTX_LINESIZE
 # define WHO_HOST_LEN		_UTX_HOSTSIZE
-#elif defined(SUPPORT_UTMP)
-# include <utmp.h>
-# define WHO_NAME_LEN		UT_NAMESIZE
-# define WHO_LINE_LEN		UT_LINESIZE
-# define WHO_HOST_LEN		UT_HOSTSIZE
-#else
-# error Either SUPPORT_UTMPX or SUPPORT_UTMP must be defined!
 #endif
 
 
diff --git a/usr.bin/who/who.c b/usr.bin/who/who.c
index ab9aff8c2e..82cff77e15 100644
--- a/usr.bin/who/who.c
+++ b/usr.bin/who/who.c
@@ -45,9 +45,6 @@
 #include <string.h>
 #include <time.h>
 #include <unistd.h>
-#ifdef SUPPORT_UTMP
-#include <utmp.h>
-#endif
 #ifdef SUPPORT_UTMPX
 #include <utmpx.h>
 #endif
diff --git a/usr.bin/write/Makefile b/usr.bin/write/Makefile
index 7de9cc6208..e502f2655c 100644
--- a/usr.bin/write/Makefile
+++ b/usr.bin/write/Makefile
@@ -10,6 +10,6 @@ BINGRP=	tty
 DPADD+=	${LIBUTIL}
 LDADD+=	-lutil
 
-CFLAGS+= -I${.CURDIR}/../who -DSUPPORT_UTMP -DSUPPORT_UTMPX
+CFLAGS+= -I${.CURDIR}/../who -DSUPPORT_UTMPX
 
 .include <bsd.prog.mk>
diff --git a/usr.sbin/Makefile b/usr.sbin/Makefile
index 3e45df8357..8d79724933 100644
--- a/usr.sbin/Makefile
+++ b/usr.sbin/Makefile
@@ -4,7 +4,6 @@
 .include "../sys/platform/${MACHINE_PLATFORM}/Makefile.inc"
 
 SUBDIR= 802_11 \
-	ac \
 	accton \
 	acpi \
 	adduser \
@@ -79,7 +78,6 @@ SUBDIR= 802_11 \
 	pfctl \
 	pflogd \
 	powerd \
-	ppp \
 	pppctl \
 	prefix \
 	procctl \
@@ -106,7 +104,6 @@ SUBDIR= 802_11 \
 	rtadvctl \
 	rtprio \
 	rtsold \
-	rwhod \
 	sa \
 	sdpd \
 	sensorsd \
@@ -144,6 +141,11 @@ SUBDIR= 802_11 \
 	ypset \
 	zic
 
+_XXX_PORT_TO_UTMPX = \
+	ac \
+	ppp \
+	rwhod
+
 .if !defined(NO_LPR)
 SUBDIR+=lpr
 .endif
diff --git a/usr.sbin/ac/ac.c b/usr.sbin/ac/ac.c
index b61bff2cd1..ff1f836748 100644
--- a/usr.sbin/ac/ac.c
+++ b/usr.sbin/ac/ac.c
@@ -27,7 +27,6 @@
 #include <stdlib.h>
 #include <string.h>
 #include <unistd.h>
-#include <utmp.h>
 
 /*
  * this is for our list of currently logged in sessions
diff --git a/usr.sbin/adduser/adduser.8 b/usr.sbin/adduser/adduser.8
index 6ed42ecc13..652724715c 100644
--- a/usr.sbin/adduser/adduser.8
+++ b/usr.sbin/adduser/adduser.8
@@ -80,11 +80,6 @@ such a basic fundamental parameter in
 You can change
 .Dv UT_NAMESIZE
 in
-.In utmp.h
-and recompile the
-world; people have done this and it works, but you will have problems
-with any precompiled programs, or source that assumes the 8-character
-name limit, such as NIS.
 The NIS protocol mandates an 8-character username.
 If you need a longer login name for e-mail addresses,
 you can define an alias in
diff --git a/usr.sbin/lastlogin/lastlogin.c b/usr.sbin/lastlogin/lastlogin.c
index 729c59b314..c704acc6d1 100644
--- a/usr.sbin/lastlogin/lastlogin.c
+++ b/usr.sbin/lastlogin/lastlogin.c
@@ -40,11 +40,9 @@
 #include <stdio.h>
 #include <stdlib.h>
 #include <time.h>
-#include <utmp.h>
 #include <utmpx.h>
 #include <unistd.h>
 
-static	void	output(struct passwd *, struct lastlog *);
 static	void	outputx(struct passwd *, struct lastlogx *);
 static	void	usage(void);
 
@@ -52,19 +50,13 @@ int
 main(int argc, char **argv)
 {
 	int	ch, i;
-	long offset;
-	FILE	*fp;
 	struct passwd	*passwd;
-	struct lastlog	last;
 	struct lastlogx	lastx;
 
 	while ((ch = getopt(argc, argv, "")) != -1) {
 		usage();
 	}
 
-	if ((fp = fopen(_PATH_LASTLOG, "r")) == NULL)
-		err(1, "%s", _PATH_LASTLOG);
-
 	setpassent(1);	/* Keep passwd file pointers open */
 
 	/* Process usernames given on the command line. */
@@ -79,18 +71,6 @@ main(int argc, char **argv)
 				outputx(passwd, &lastx);
 				goto done;
 			}
-			/* Calculate the offset into the lastlog file. */
-			offset = (long)(passwd->pw_uid * sizeof(last));
-			if (fseek(fp, offset, SEEK_SET)) {
-				warn("fseek error");
-				continue;
-			}
-			if (fread(&last, sizeof(last), 1, fp) != 1) {
-				warnx("fread error on '%s'", passwd->pw_name);
-				clearerr(fp);
-				continue;
-			}
-			output(passwd, &last);
 		}
 	}
 	/* Read all lastlog entries, looking for active ones */
@@ -101,57 +81,23 @@ main(int argc, char **argv)
 				if (lastx.ll_tv.tv_sec == 0)
 					continue;
 				outputx(passwd, &lastx);
-			} else {
-				offset = (long)(passwd->pw_uid * sizeof(last));
-
-				if (fseek(fp, offset, SEEK_SET)) {
-					continue;
-				}
-				if (fread(&last, sizeof(last), 1, fp) != 1) {
-					continue;
-				}
-				if (last.ll_time == 0)
-					continue;
-				output(passwd, &last);
 			}
 		}
-#if 0
-		for (i = 0; fread(&last, sizeof(last), 1, fp) == 1; i++) {
-			if (last.ll_time == 0)
-				continue;
-			if ((passwd = getpwuid((uid_t)i)) != NULL)
-				output(passwd, &last);
-		}
-		if (ferror(fp))
-			warnx("fread error");
-#endif
 	}
 
 done:
 	setpassent(0);	/* Close passwd file pointers */
 
-	fclose(fp);
 	exit(0);
 }
 
-/* Duplicate the output of last(1) */
-static void
-output(struct passwd *p, struct lastlog *l)
-{
-	printf("%-*.*s  %-*.*s %-*.*s   %s",
-		UT_NAMESIZE, UT_NAMESIZE, p->pw_name,
-		UT_LINESIZE+4, UT_LINESIZE+4, l->ll_line,
-		UT_HOSTSIZE, UT_HOSTSIZE, l->ll_host,
-		(l->ll_time) ? ctime(&(l->ll_time)) : "Never logged in\n");
-}
-
 static void
 outputx(struct passwd *p, struct lastlogx *l)
 {
 	printf("%-*.*s  %-*.*s %-*.*s   %s",
-		UT_NAMESIZE, UT_NAMESIZE, p->pw_name,
-		UT_LINESIZE+4, UT_LINESIZE+4, l->ll_line,
-		UT_HOSTSIZE, UT_HOSTSIZE, l->ll_host,
+		UTX_USERSIZE, UTX_USERSIZE, p->pw_name,
+		UTX_LINESIZE+4, UTX_LINESIZE+4, l->ll_line,
+		UTX_HOSTSIZE, UTX_HOSTSIZE, l->ll_host,
 		(l->ll_tv.tv_sec) ? ctime((&l->ll_tv.tv_sec)) : "Never logged in\n");
 }
 
diff --git a/usr.sbin/ppp/id.c b/usr.sbin/ppp/id.c
index 154970657d..4d82831fda 100644
--- a/usr.sbin/ppp/id.c
+++ b/usr.sbin/ppp/id.c
@@ -24,7 +24,6 @@
  * SUCH DAMAGE.
  *
  * $FreeBSD: src/usr.sbin/ppp/id.c,v 1.18.2.3 2002/09/01 02:12:27 brian Exp $
- * $DragonFly: src/usr.sbin/ppp/id.c,v 1.4 2005/11/24 23:42:54 swildner Exp $
  */
 
 #include <sys/param.h>
@@ -50,7 +49,6 @@
 #else
 #include <libutil.h>
 #endif
-#include <utmp.h>
 
 #include "log.h"
 #include "main.h"
diff --git a/usr.sbin/ppp/physical.c b/usr.sbin/ppp/physical.c
index d760123cec..5028ecca69 100644
--- a/usr.sbin/ppp/physical.c
+++ b/usr.sbin/ppp/physical.c
@@ -40,7 +40,6 @@
 #include <termios.h>
 #include <time.h>
 #include <unistd.h>
-#include <utmp.h>
 #if defined(__OpenBSD__) || defined(__NetBSD__)
 #include <sys/ioctl.h>
 #include <util.h>
diff --git a/usr.sbin/rwhod/rwhod.c b/usr.sbin/rwhod/rwhod.c
index c503e9ebe4..8735ddd14f 100644
--- a/usr.sbin/rwhod/rwhod.c
+++ b/usr.sbin/rwhod/rwhod.c
@@ -58,7 +58,6 @@
 #include <string.h>
 #include <syslog.h>
 #include <unistd.h>
-#include <utmp.h>
 #include <pwd.h>
 #include <grp.h>
 
diff --git a/usr.sbin/sshd/Makefile b/usr.sbin/sshd/Makefile
index aab7177fdb..62dbf0f814 100644
--- a/usr.sbin/sshd/Makefile
+++ b/usr.sbin/sshd/Makefile
@@ -18,8 +18,6 @@ SRCS+=	auth.c auth-options.c auth-pam.c auth-passwd.c auth-rhosts.c \
 # Custom password routine
 SRCS+=	auth-passwd-custom.c
 CFLAGS+= -DCUSTOM_SYS_AUTH_PASSWD
-CFLAGS+= -DUSE_UTMPX -DUSE_WTMPX
-CFLAGS+= -DWTMPX_FILE=_PATH_WTMPX -DUTMPX_FILE=_PATH_UTMPX
 
 WARNS?=	3
 
-- 
2.22.0

