Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/sbin/dump support utmpx



details:   https://anonhg.NetBSD.org/src/rev/d44d71278658
branches:  trunk
changeset: 534710:d44d71278658
user:      christos <christos%NetBSD.org@localhost>
date:      Fri Aug 02 02:07:09 2002 +0000

description:
support utmpx

diffstat:

 sbin/dump/Makefile |   7 ++++---
 sbin/dump/optr.c   |  30 +++++++++++-------------------
 2 files changed, 15 insertions(+), 22 deletions(-)

diffs (110 lines):

diff -r 3fc8c89446c8 -r d44d71278658 sbin/dump/Makefile
--- a/sbin/dump/Makefile        Fri Aug 02 01:52:13 2002 +0000
+++ b/sbin/dump/Makefile        Fri Aug 02 02:07:09 2002 +0000
@@ -1,4 +1,4 @@
-#      $NetBSD: Makefile,v 1.27 2001/12/25 11:56:14 lukem Exp $
+#      $NetBSD: Makefile,v 1.28 2002/08/02 02:07:09 christos Exp $
 #      @(#)Makefile    8.1 (Berkeley) 6/5/93
 
 #      dump.h                  header file
@@ -23,14 +23,15 @@
 PROG=  dump
 LINKS= ${BINDIR}/dump ${BINDIR}/rdump
 CPPFLAGS+=-DRDUMP -I${.CURDIR}
+CPPFLAGS+=-I${.CURDIR}/../../usr.bin/who -DSUPPORT_UTMPX -DSUPPORT_UTMP
 # CPPFLAGS+= -DDEBUG -DTDEBUG -DFDEBUG -DWRITEDEBUG -DSTATS -DDIAGNOSTICS
 SRCS=  itime.c main.c optr.c dumprmt.c rcache.c tape.c traverse.c unctime.c \
-       ffs_inode.c ffs_bswap.c
+       ffs_inode.c ffs_bswap.c utmpentry.c
 BINGRP=        tty
 BINMODE=2555
 MAN=   dump.8
 MLINKS+=dump.8 rdump.8
 
-.PATH:  ${.CURDIR}/../../sys/ufs/ffs
+.PATH:  ${.CURDIR}/../../sys/ufs/ffs ${.CURDIR}/../../usr.bin/who
 
 .include <bsd.prog.mk>
diff -r 3fc8c89446c8 -r d44d71278658 sbin/dump/optr.c
--- a/sbin/dump/optr.c  Fri Aug 02 01:52:13 2002 +0000
+++ b/sbin/dump/optr.c  Fri Aug 02 02:07:09 2002 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: optr.c,v 1.25 2001/12/25 12:06:26 lukem Exp $  */
+/*     $NetBSD: optr.c,v 1.26 2002/08/02 02:07:09 christos Exp $       */
 
 /*-
  * Copyright (c) 1980, 1988, 1993
@@ -38,7 +38,7 @@
 #if 0
 static char sccsid[] = "@(#)optr.c     8.2 (Berkeley) 1/6/94";
 #else
-__RCSID("$NetBSD: optr.c,v 1.25 2001/12/25 12:06:26 lukem Exp $");
+__RCSID("$NetBSD: optr.c,v 1.26 2002/08/02 02:07:09 christos Exp $");
 #endif
 #endif /* not lint */
 
@@ -60,11 +60,12 @@
 #include <time.h>
 #include <tzfile.h>
 #include <unistd.h>
-#include <utmp.h>
 
 #include "dump.h"
 #include "pathnames.h"
 
+#include "utmpentry.h"
+
 void   alarmcatch(int);
 struct fstab *allocfsent(struct fstab *);
 int    datesort(const void *, const void *);
@@ -216,11 +217,10 @@
 void
 broadcast(char *message)
 {
-       struct utmp utmp;
        time_t  now;
-       FILE   *f_utmp;
        char  **np;
        int     pid, s;
+       struct utmpentry *ep;
 
        if (!notify || gp == NULL)
                return;
@@ -243,31 +243,23 @@
        now = time((time_t *)0);
        localclock = localtime(&now);
 
-       if ((f_utmp = fopen(_PATH_UTMP, "r")) == NULL) {
-               msg("Cannot open %s: %s\n", _PATH_UTMP, strerror(errno));
-               return;
-       }
+       (void)getutentries(NULL, &ep);
 
-       while (!feof(f_utmp)) {
-               if (fread((char *) &utmp, sizeof (struct utmp), 1, f_utmp) != 1)
-                       break;
-               if (utmp.ut_name[0] == 0)
-                       continue;
+       for (; ep; ep = ep->next) {
                for (np = gp->gr_mem; *np; np++) {
-                       if (strncmp(*np, utmp.ut_name, sizeof(utmp.ut_name)) != 0)
+                       if (strcmp(*np, ep->name) != 0)
                                continue;
                        /*
                         *      Do not send messages to operators on dialups
                         */
-                       if (strncmp(utmp.ut_line, DIALUP, strlen(DIALUP)) == 0)
+                       if (strcmp(ep->line, DIALUP) == 0)
                                continue;
 #ifdef DEBUG
-                       msg("Message to %s at %s\n", *np, utmp.ut_line);
+                       msg("Message to %s at %s\n", *np, ep->line);
 #endif
-                       sendmes(utmp.ut_line, message);
+                       sendmes(ep->line, message);
                }
        }
-       (void) fclose(f_utmp);
        Exit(0);        /* the wait in this same routine will catch this */
        /* NOTREACHED */
 }



Home | Main Index | Thread Index | Old Index