Source-Changes-HG archive

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

[src/trunk]: src/usr.sbin/syslogd add utmpx support;



details:   https://anonhg.NetBSD.org/src/rev/34380b4c0047
branches:  trunk
changeset: 534713:34380b4c0047
user:      christos <christos%NetBSD.org@localhost>
date:      Fri Aug 02 02:23:49 2002 +0000

description:
add utmpx support;

diffstat:

 usr.sbin/syslogd/Makefile  |   5 ++++-
 usr.sbin/syslogd/syslogd.c |  37 ++++++++++++++++---------------------
 2 files changed, 20 insertions(+), 22 deletions(-)

diffs (109 lines):

diff -r 20e03f6b38d1 -r 34380b4c0047 usr.sbin/syslogd/Makefile
--- a/usr.sbin/syslogd/Makefile Fri Aug 02 02:13:46 2002 +0000
+++ b/usr.sbin/syslogd/Makefile Fri Aug 02 02:23:49 2002 +0000
@@ -1,13 +1,16 @@
-#      $NetBSD: Makefile,v 1.16 2002/06/09 19:59:55 itojun Exp $
+#      $NetBSD: Makefile,v 1.17 2002/08/02 02:23:49 christos Exp $
 #      from: @(#)Makefile      8.1 (Berkeley) 6/6/93
 
 PROG=  syslogd
+SRCS=  syslogd.c utmpentry.c
 MAN=   syslogd.8 syslog.conf.5
 DPADD+=${LIBUTIL}
 LDADD+=-lutil
 #make symlink to old socket location for transitional period
 SYMLINKS=      /var/run/log /dev/log
 CPPFLAGS+=-DINET6
+.PATH.c: ${.CURDIR}/../../usr.bin/who
+CPPFLAGS+=-I${.CURDIR}/../../usr.bin/who -DSUPPORT_UTMPX -DSUPPORT_UTMP
 
 CPPFLAGS+=-DLIBWRAP
 LDADD+=        -lwrap
diff -r 20e03f6b38d1 -r 34380b4c0047 usr.sbin/syslogd/syslogd.c
--- a/usr.sbin/syslogd/syslogd.c        Fri Aug 02 02:13:46 2002 +0000
+++ b/usr.sbin/syslogd/syslogd.c        Fri Aug 02 02:23:49 2002 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: syslogd.c,v 1.54 2002/06/09 19:59:55 itojun Exp $      */
+/*     $NetBSD: syslogd.c,v 1.55 2002/08/02 02:23:49 christos Exp $    */
 
 /*
  * Copyright (c) 1983, 1988, 1993, 1994
@@ -43,7 +43,7 @@
 #if 0
 static char sccsid[] = "@(#)syslogd.c  8.3 (Berkeley) 4/4/94";
 #else
-__RCSID("$NetBSD: syslogd.c,v 1.54 2002/06/09 19:59:55 itojun Exp $");
+__RCSID("$NetBSD: syslogd.c,v 1.55 2002/08/02 02:23:49 christos Exp $");
 #endif
 #endif /* not lint */
 
@@ -98,8 +98,8 @@
 #include <string.h>
 #include <unistd.h>
 #include <util.h>
-#include <utmp.h>
 
+#include "utmpentry.h"
 #include "pathnames.h"
 
 #define SYSLOG_NAMES
@@ -951,27 +951,24 @@
 wallmsg(struct filed *f, struct iovec *iov)
 {
        static int reenter;                     /* avoid calling ourselves */
-       FILE *uf;
-       struct utmp ut;
        int i;
        char *p;
-       char line[sizeof(ut.ut_line) + 1];
+       static struct utmpentry *ohead = NULL;
+       struct utmpentry *ep;
 
        if (reenter++)
                return;
-       if ((uf = fopen(_PATH_UTMP, "r")) == NULL) {
-               logerror(_PATH_UTMP);
-               reenter = 0;
-               return;
+
+       (void)getutentries(NULL, &ep);
+       if (ep != ohead) {
+               freeutentries(ohead);
+               ohead = ep;
        }
        /* NOSTRICT */
-       while (fread((char *)&ut, sizeof(ut), 1, uf) == 1) {
-               if (ut.ut_name[0] == '\0')
-                       continue;
-               strncpy(line, ut.ut_line, sizeof(ut.ut_line));
-               line[sizeof(ut.ut_line)] = '\0';
+       for (; ep; ep = ep->next) {
                if (f->f_type == F_WALL) {
-                       if ((p = ttymsg(iov, 6, line, TTYMSGTIME)) != NULL) {
+                       if ((p = ttymsg(iov, 6, ep->line, TTYMSGTIME))
+                           != NULL) {
                                errno = 0;      /* already in msg */
                                logerror(p);
                        }
@@ -981,10 +978,9 @@
                for (i = 0; i < MAXUNAMES; i++) {
                        if (!f->f_un.f_uname[i][0])
                                break;
-                       if (!strncmp(f->f_un.f_uname[i], ut.ut_name,
-                           UT_NAMESIZE)) {
-                               if ((p = ttymsg(iov, 6, line, TTYMSGTIME))
-                                                               != NULL) {
+                       if (strcmp(f->f_un.f_uname[i], ep->name) == 0) {
+                               if ((p = ttymsg(iov, 6, ep->line, TTYMSGTIME))
+                                   != NULL) {
                                        errno = 0;      /* already in msg */
                                        logerror(p);
                                }
@@ -992,7 +988,6 @@
                        }
                }
        }
-       (void)fclose(uf);
        reenter = 0;
 }
 



Home | Main Index | Thread Index | Old Index