bugfixes to previous commits utmpx
authorAlex Hornung <ahornung@gmail.com>
Wed, 15 Dec 2010 22:10:47 +0000 (22:10 +0000)
committerAlex Hornung <ahornung@gmail.com>
Wed, 15 Dec 2010 22:10:47 +0000 (22:10 +0000)
games/dm/dm.c
usr.bin/finger/extern.h
usr.bin/finger/finger.c
usr.bin/finger/finger.h
usr.bin/finger/util.c
usr.bin/wall/wall.c
usr.sbin/syslogd/syslogd.c

index 298e77e..9be520a 100644 (file)
@@ -258,7 +258,7 @@ static int
 users(void)
 {
        struct utmpentry *ep;
-       int nusers;
+       int nusers = 0;
 
        getutentries(NULL, &ep);
        for (; ep; ep = ep->next)
index 726322c..26b456f 100644 (file)
@@ -50,10 +50,11 @@ extern int oflag;
 extern int lflag;
 extern int Tflag;
 extern sa_family_t family;
+struct utmpentry;
 
 void    enter_lastlog(PERSON *);
 PERSON *enter_person(struct passwd *);
-void    enter_where(struct utmp *, PERSON *);
+void    enter_where(struct utmpentry *, PERSON *);
 PERSON *find_person(char *);
 int            hide(struct passwd *);
 void    lflag_print(void);
index 388b592..16a14c7 100644 (file)
@@ -235,7 +235,7 @@ loginlist(void)
                                continue;
                        pn = enter_person(pw);
                }
-               enter_where(&user, pn);
+               enter_where(ep, pn);
        }
        if (db && lflag)
                for (sflag1 = R_FIRST;; sflag1 = R_NEXT) {
@@ -365,7 +365,7 @@ net:        for (p = nargv; *p;) {
        for (; ep; ep = ep->next) {
                if ((pn = find_person(ep->name)) == NULL)
                        continue;
-               enter_where(&user, pn);
+               enter_where(ep, pn);
        }
        if (db)
                for (sflag1 = R_FIRST;; sflag1 = R_NEXT) {
index 71edcd4..3913905 100644 (file)
@@ -60,8 +60,8 @@ typedef struct where {
        short writable;                 /* tty is writable */
        time_t loginat;                 /* time of (last) login */
        time_t idletime;                /* how long idle (if logged in) */
-       char tty[UT_LINESIZE+1];        /* null terminated tty line */
-       char host[UT_HOSTSIZE+1];       /* null terminated remote host name */
+       char *tty;      /* null terminated tty line */
+       char *host;     /* null terminated remote host name */
 } WHERE;
 
 #define UNPRIV_NAME    "nobody"        /* Preferred privilege level */
index 5279ec1..7128808 100644 (file)
@@ -52,6 +52,7 @@
 #include <stdlib.h>
 #include <string.h>
 #include <unistd.h>
+#include "utmpentry.h"
 #include <utmp.h>
 #include "finger.h"
 #include "pathnames.h"
@@ -150,17 +151,15 @@ enter_lastlog(PERSON *pn)
 }
 
 void
-enter_where(struct utmp *ut, PERSON *pn)
+enter_where(struct utmpentry *ep, PERSON *pn)
 {
        WHERE *w;
 
        w = walloc(pn);
        w->info = LOGGEDIN;
-       bcopy(ut->ut_line, w->tty, UT_LINESIZE);
-       w->tty[UT_LINESIZE] = 0;
-       bcopy(ut->ut_host, w->host, UT_HOSTSIZE);
-       w->host[UT_HOSTSIZE] = 0;
-       w->loginat = (time_t)ut->ut_time;
+       w->tty = ep->line;
+       w->host = ep->host;
+       w->loginat = (time_t)ep->tv.tv_sec;
        find_idle_and_ttywrite(w);
 }
 
index 72dfae8..ab3f335 100644 (file)
@@ -79,7 +79,6 @@ main(int argc, char *argv[])
        struct utmpentry *ep;
        int ch;
        int ingroup;
-       FILE *fp;
        struct wallgroup *g;
        struct group *grp;
        char **np;
@@ -139,7 +138,7 @@ main(int argc, char *argv[])
                                        ingroup = 1;
                                else if ((grp = getgrgid(g->gid)) != NULL) {
                                        for (np = grp->gr_mem; *np; np++) {
-                                               if (strcmp(*np, username) == 0) {
+                                               if (strcmp(*np, ep->name) == 0) {
                                                        ingroup = 1;
                                                        break;
                                                }
index d76415a..4f72452 100644 (file)
@@ -164,7 +164,7 @@ struct filed {
 #define PRI_GT 0x4
        char    *f_program;             /* program this applies to */
        union {
-               char    f_uname[MAXUNAMES][UT_NAMESIZE+1];
+               char    f_uname[MAXUNAMES][32+1];
                struct {
                        char    f_hname[MAXHOSTNAMELEN];
                        struct addrinfo *f_addr;
@@ -1365,7 +1365,7 @@ wallmsg(struct filed *f, struct iovec *iov, const int iovlen)
 
        getutentries(NULL, &ep);
        if (ep == NULL) {
-               logerror(_PATH_UTMP);
+               logerror("getutentries");
                reenter = 0;
                return;
        }
@@ -2056,9 +2056,9 @@ cfline(const char *line, struct filed *f, const char *prog, const char *host)
                for (i = 0; i < MAXUNAMES && *p; i++) {
                        for (q = p; *q && *q != ','; )
                                q++;
-                       strncpy(f->f_un.f_uname[i], p, UT_NAMESIZE);
-                       if ((q - p) > UT_NAMESIZE)
-                               f->f_un.f_uname[i][UT_NAMESIZE] = '\0';
+                       strncpy(f->f_un.f_uname[i], p, 32);
+                       if ((q - p) > 32)
+                               f->f_un.f_uname[i][32] = '\0';
                        else
                                f->f_un.f_uname[i][q - p] = '\0';
                        while (*q == ',' || *q == ' ')