[BACK]Return to wall.c CVS log [TXT][DIR] Up to [local] / src / usr.bin / wall

Diff for /src/usr.bin/wall/wall.c between version 1.28 and 1.29

version 1.28, 2015/09/29 03:19:24 version 1.29, 2015/11/05 22:20:11
Line 35 
Line 35 
  * is entitled "Mechanisms for Broadcast and Selective Broadcast".   * is entitled "Mechanisms for Broadcast and Selective Broadcast".
  */   */
   
   #include <sys/queue.h>
 #include <sys/stat.h>  #include <sys/stat.h>
 #include <sys/time.h>  #include <sys/time.h>
 #include <sys/uio.h>  #include <sys/uio.h>
Line 58 
Line 59 
         struct wallgroup *next;          struct wallgroup *next;
 } *grouplist;  } *grouplist;
   
   struct utmptty {
           char    *tty;
           SLIST_ENTRY(utmptty) next;
   };
   
 void    makemsg(char *);  void    makemsg(char *);
 void    addgroup(struct group *, char *);  void    addgroup(struct group *, char *);
 char   *ttymsg(struct iovec *, int, char *, int);  char   *ttymsg(struct iovec *, int, char *, int);
Line 81 
Line 87 
         struct passwd *pw;          struct passwd *pw;
         struct group *grp;          struct group *grp;
         struct wallgroup *g;          struct wallgroup *g;
           struct utmptty *un;
           SLIST_HEAD(,utmptty) utmphead;
           SLIST_INIT(&utmphead);
   
         while ((ch = getopt(argc, argv, "ng:")) != -1)          while ((ch = getopt(argc, argv, "ng:")) != -1)
                 switch (ch) {                  switch (ch) {
Line 105 
Line 114 
   
         makemsg(*argv);          makemsg(*argv);
   
           if (pledge("stdio rpath wpath getpw proc", NULL) == -1)
                   err(1, "pledge");
   
         if (!(fp = fopen(_PATH_UTMP, "r")))          if (!(fp = fopen(_PATH_UTMP, "r")))
                 err(1, "cannot read %s", _PATH_UTMP);                  err(1, "cannot read %s", _PATH_UTMP);
         iov.iov_base = mbuf;          iov.iov_base = mbuf;
         iov.iov_len = mbufsize;          iov.iov_len = mbufsize;
   
         while (fread(&utmp, sizeof(utmp), 1, fp) == 1) {          while (fread(&utmp, sizeof(utmp), 1, fp) == 1) {
                 if (!utmp.ut_name[0])                  if (!utmp.ut_name[0])
                         continue;                          continue;
Line 131 
Line 144 
                 }                  }
                 strncpy(line, utmp.ut_line, sizeof(utmp.ut_line));                  strncpy(line, utmp.ut_line, sizeof(utmp.ut_line));
                 line[sizeof(utmp.ut_line)] = '\0';                  line[sizeof(utmp.ut_line)] = '\0';
                 if ((p = ttymsg(&iov, 1, line, 60*5)) != NULL)                  un = malloc(sizeof(struct utmptty));
                   if (un == NULL)
                           err(1, "malloc");
                   un->tty = strndup(line, sizeof(utmp.ut_line));
                   if (un->tty == NULL)
                           err(1, "strndup");
                   SLIST_INSERT_HEAD(&utmphead, un, next);
           }
           fclose(fp);
   
           if (pledge("stdio rpath wpath proc", NULL) == -1)
                   err(1, "pledge");
   
           SLIST_FOREACH(un, &utmphead, next) {
                   if ((p = ttymsg(&iov, 1, un->tty, 60*5)) != NULL)
                         warnx("%s", p);                          warnx("%s", p);
         }          }
   
         exit(0);          exit(0);
 }  }
   

Legend:
Removed from v.1.28  
changed lines
  Added in v.1.29