Date: Wed, 6 Jan 2010 12:42:16 +0000 (UTC) From: Ed Schouten <ed@FreeBSD.org> To: src-committers@freebsd.org, svn-src-user@freebsd.org Subject: svn commit: r201640 - in user/ed/utmpx: usr.bin/finger usr.bin/who usr.sbin/ac usr.sbin/lastlogin Message-ID: <201001061242.o06CgGPZ026230@svn.freebsd.org>
next in thread | raw e-mail | index | archive | help
Author: ed Date: Wed Jan 6 12:42:16 2010 New Revision: 201640 URL: http://svn.freebsd.org/changeset/base/201640 Log: Make more tools use the utmpx interface. Modified: user/ed/utmpx/usr.bin/finger/Makefile user/ed/utmpx/usr.bin/finger/finger.c user/ed/utmpx/usr.bin/finger/lprint.c user/ed/utmpx/usr.bin/finger/net.c user/ed/utmpx/usr.bin/finger/sprint.c user/ed/utmpx/usr.bin/finger/util.c user/ed/utmpx/usr.bin/who/who.c user/ed/utmpx/usr.sbin/ac/Makefile user/ed/utmpx/usr.sbin/ac/ac.c user/ed/utmpx/usr.sbin/lastlogin/Makefile user/ed/utmpx/usr.sbin/lastlogin/lastlogin.c Modified: user/ed/utmpx/usr.bin/finger/Makefile ============================================================================== --- user/ed/utmpx/usr.bin/finger/Makefile Wed Jan 6 12:15:10 2010 (r201639) +++ user/ed/utmpx/usr.bin/finger/Makefile Wed Jan 6 12:42:16 2010 (r201640) @@ -7,7 +7,4 @@ MAN= finger.1 finger.conf.5 WARNS?= 2 -DPADD= ${LIBULOG} -LDADD= -lulog - .include <bsd.prog.mk> Modified: user/ed/utmpx/usr.bin/finger/finger.c ============================================================================== --- user/ed/utmpx/usr.bin/finger/finger.c Wed Jan 6 12:15:10 2010 (r201639) +++ user/ed/utmpx/usr.bin/finger/finger.c Wed Jan 6 12:42:16 2010 (r201640) @@ -82,9 +82,8 @@ __FBSDID("$FreeBSD$"); #include <stdlib.h> #include <string.h> #include <time.h> -#define _ULOG_POSIX_NAMES -#include <ulog.h> #include <unistd.h> +#include <utmpx.h> #include <locale.h> #include "finger.h" Modified: user/ed/utmpx/usr.bin/finger/lprint.c ============================================================================== --- user/ed/utmpx/usr.bin/finger/lprint.c Wed Jan 6 12:15:10 2010 (r201639) +++ user/ed/utmpx/usr.bin/finger/lprint.c Wed Jan 6 12:42:16 2010 (r201640) @@ -56,9 +56,8 @@ __FBSDID("$FreeBSD$"); #include <pwd.h> #include <stdio.h> #include <string.h> -#define _ULOG_POSIX_NAMES -#include <ulog.h> #include <unistd.h> +#include <utmpx.h> #include "finger.h" #include "pathnames.h" Modified: user/ed/utmpx/usr.bin/finger/net.c ============================================================================== --- user/ed/utmpx/usr.bin/finger/net.c Wed Jan 6 12:15:10 2010 (r201639) +++ user/ed/utmpx/usr.bin/finger/net.c Wed Jan 6 12:42:16 2010 (r201640) @@ -54,9 +54,8 @@ __FBSDID("$FreeBSD$"); #include <stdio.h> #include <stdlib.h> #include <string.h> -#define _ULOG_POSIX_NAMES -#include <ulog.h> #include <unistd.h> +#include <utmpx.h> #include "finger.h" static void cleanup(int sig); Modified: user/ed/utmpx/usr.bin/finger/sprint.c ============================================================================== --- user/ed/utmpx/usr.bin/finger/sprint.c Wed Jan 6 12:15:10 2010 (r201639) +++ user/ed/utmpx/usr.bin/finger/sprint.c Wed Jan 6 12:42:16 2010 (r201640) @@ -53,8 +53,7 @@ __FBSDID("$FreeBSD$"); #include <stdio.h> #include <string.h> #include <time.h> -#define _ULOG_POSIX_NAMES -#include <ulog.h> +#include <utmpx.h> #include "finger.h" static void stimeprint(WHERE *); Modified: user/ed/utmpx/usr.bin/finger/util.c ============================================================================== --- user/ed/utmpx/usr.bin/finger/util.c Wed Jan 6 12:15:10 2010 (r201639) +++ user/ed/utmpx/usr.bin/finger/util.c Wed Jan 6 12:42:16 2010 (r201640) @@ -56,9 +56,8 @@ __FBSDID("$FreeBSD$"); #include <stdio.h> #include <stdlib.h> #include <string.h> -#define _ULOG_POSIX_NAMES -#include <ulog.h> #include <unistd.h> +#include <utmpx.h> #include "finger.h" #include "pathnames.h" @@ -110,11 +109,11 @@ void enter_lastlog(PERSON *pn) { WHERE *w; - struct ulog_utmpx *ut; + struct utmpx *ut = NULL; char doit = 0; - ulog_setutxfile(UTXI_USER, NULL); - ut = ulog_getutxuser(pn->name); + if (setutxdb(UTXDB_LASTLOGIN, NULL) == 0) + ut = getutxuser(pn->name); if ((w = pn->whead) == NULL) doit = 1; else if (ut != NULL && ut->ut_type == USER_PROCESS) { @@ -140,7 +139,7 @@ enter_lastlog(PERSON *pn) strcpy(w->host, ut->ut_host); w->loginat = ut->ut_tv.tv_sec; } - ulog_endutxent(); + endutxent(); } void Modified: user/ed/utmpx/usr.bin/who/who.c ============================================================================== --- user/ed/utmpx/usr.bin/who/who.c Wed Jan 6 12:15:10 2010 (r201639) +++ user/ed/utmpx/usr.bin/who/who.c Wed Jan 6 12:42:16 2010 (r201640) @@ -107,12 +107,10 @@ main(int argc, char *argv[]) if (argc > 1) usage(); -#if 0 if (*argv != NULL) { - if (ulog_setutxfile(UTXI_TTY, *argv) != 0) + if (setutxdb(UTXDB_ACTIVE, *argv) != 0) err(1, "%s", *argv); } -#endif if (qflag) quick(); Modified: user/ed/utmpx/usr.sbin/ac/Makefile ============================================================================== --- user/ed/utmpx/usr.sbin/ac/Makefile Wed Jan 6 12:15:10 2010 (r201639) +++ user/ed/utmpx/usr.sbin/ac/Makefile Wed Jan 6 12:42:16 2010 (r201640) @@ -5,9 +5,6 @@ MAN= ac.8 WARNS?= 6 -DPADD= ${LIBULOG} -LDADD= -lulog - # Temporary, while tracking down problem wrt 64-bit time_t's on sparc64 .if ${MACHINE_ARCH} == "sparc64" CFLAGS+=-DDEBUG Modified: user/ed/utmpx/usr.sbin/ac/ac.c ============================================================================== --- user/ed/utmpx/usr.sbin/ac/ac.c Wed Jan 6 12:15:10 2010 (r201639) +++ user/ed/utmpx/usr.sbin/ac/ac.c Wed Jan 6 12:42:16 2010 (r201640) @@ -26,9 +26,8 @@ __FBSDID("$FreeBSD$"); #include <stdlib.h> #include <string.h> #include <timeconv.h> -#define _ULOG_POSIX_NAMES -#include <ulog.h> #include <unistd.h> +#include <utmpx.h> /* * this is for our list of currently logged in sessions @@ -486,7 +485,7 @@ ac(const char *file) prev_secs = 1; /* Minimum acceptable date == 1970 */ rfound = tchanged = tskipped = 0; secs = 0; - if (ulog_setutxfile(UTXI_TIME, file) != 0) + if (setutxdb(UTXDB_LOG, file) != 0) err(1, "%s", file); while ((usr = getutxent()) != NULL) { rfound++; Modified: user/ed/utmpx/usr.sbin/lastlogin/Makefile ============================================================================== --- user/ed/utmpx/usr.sbin/lastlogin/Makefile Wed Jan 6 12:15:10 2010 (r201639) +++ user/ed/utmpx/usr.sbin/lastlogin/Makefile Wed Jan 6 12:42:16 2010 (r201640) @@ -3,7 +3,4 @@ PROG= lastlogin MAN= lastlogin.8 -DPADD= ${LIBULOG} -LDADD= -lulog - .include <bsd.prog.mk> Modified: user/ed/utmpx/usr.sbin/lastlogin/lastlogin.c ============================================================================== --- user/ed/utmpx/usr.sbin/lastlogin/lastlogin.c Wed Jan 6 12:15:10 2010 (r201639) +++ user/ed/utmpx/usr.sbin/lastlogin/lastlogin.c Wed Jan 6 12:42:16 2010 (r201640) @@ -41,62 +41,62 @@ __RCSID("$NetBSD: lastlogin.c,v 1.4 1998 #include <stdio.h> #include <stdlib.h> #include <time.h> -#include <ulog.h> #include <unistd.h> +#include <utmpx.h> int main(int, char **); -static void output(struct ulog_utmpx *); +static void output(struct utmpx *); static void usage(void); int main(int argc, char *argv[]) { int ch, i; - struct ulog_utmpx *u; + struct utmpx *u; while ((ch = getopt(argc, argv, "")) != -1) { usage(); } - if (ulog_setutxfile(UTXI_USER, NULL) != 0) - errx(1, "failed to open lastlog database"); - setpassent(1); /* Keep passwd file pointers open */ /* Process usernames given on the command line. */ if (argc > 1) { for (i = 1; i < argc; ++i) { - if ((u = ulog_getutxuser(argv[i])) == NULL) { + if (setutxdb(UTXDB_LASTLOGIN, NULL) != 0) + errx(1, "failed to open lastlog database"); + if ((u = getutxuser(argv[i])) == NULL) { warnx("user '%s' not found", argv[i]); continue; } output(u); + endutxent(); } } /* Read all lastlog entries, looking for active ones */ else { - while ((u = ulog_getutxent()) != NULL) { + if (setutxdb(UTXDB_LASTLOGIN, NULL) != 0) + errx(1, "failed to open lastlog database"); + while ((u = getutxent()) != NULL) { if (u->ut_type != USER_PROCESS) continue; output(u); } + endutxent(); } setpassent(0); /* Close passwd file pointers */ - - ulog_endutxent(); exit(0); } /* Duplicate the output of last(1) */ static void -output(struct ulog_utmpx *u) +output(struct utmpx *u) { time_t t = u->ut_tv.tv_sec; printf("%-16s %-8s %-16s %s", - u->ut_user, u->ut_line, u->ut_host, - (u->ut_type == USER_PROCESS) ? ctime(&t) : "Never logged in\n"); + u->ut_user, u->ut_line, u->ut_host, ctime(&t)); } static void
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201001061242.o06CgGPZ026230>