]> mj.ucw.cz Git - nwho.git/commitdiff
See changelogs...
authorMartin Mares <mj@ucw.cz>
Tue, 6 Feb 2001 20:34:51 +0000 (20:34 +0000)
committerMartin Mares <mj@ucw.cz>
Tue, 6 Feb 2001 20:34:51 +0000 (20:34 +0000)
ChangeLog
Makefile
debian/changelog
net.h
nwho.c
nwhod.c

index 779e9935616ee048325f48ad0a0cb67030236ac2..50351b524c3f93c8cee9051cb1b69e6138675dfc 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,14 @@
+2001-02-06  Martin Mares  <mj@atrey.karlin.mff.cuni.cz>
+
+       * Released as version 1.9.
+
+       * ywho.c: Killed a Y2K bug. Lots of cosmetic changes.
+       (readutmp): Better formatting of tty names.
+
+       * nwho.c, nwhod.c, net.h: Pass longer tty names. Unfortunately
+       this required a change of packet format, hence addition of magic
+       numbers at the start of the packet.
+
 Sun Mar 28 22:39:37 1999  Martin Mares  <mj@albireo.ucw.cz>
 
        * ywho.c: Miscellaneous fixes based on bug reports and patch
index efd919627684cc8129c7d4f04892a180c63f658d..4b3255e0dc1d31ced12ae8f0cc829900257d319e 100644 (file)
--- a/Makefile
+++ b/Makefile
@@ -1,6 +1,6 @@
 # Makefile for the ywho toolkit
 
-CFLAGS=-O2 -m486 -fomit-frame-pointer -Wall -Wno-parentheses -malign-loops=0 -malign-jumps=0 -malign-functions=2
+CFLAGS=-O2 -Wall -Wno-parentheses
 LDFLAGS=-s
 ROOT=/
 REL=ywho-1.9
index c7395d71bebc2f84c219601dae1393d43c54f778..428380b6775d80f9d8a3f8270c268d74a14ee590 100644 (file)
@@ -1,3 +1,15 @@
+ywho (1.9-2) unstable; urgency=low
+
+  * Synced with master CVS.
+
+ -- Martin Mares <mj@atrey.karlin.mff.cuni.cz>  Tue,  6 Feb 2001 21:33:21 +0100
+
+ywho (1.9-1) unstable; urgency=low
+
+  * New upstream release
+
+ -- Martin Mares <mj@atrey.karlin.mff.cuni.cz>  Tue,  6 Feb 2001 21:21:35 +0100
+
 ywho (1.0) unstable; urgency=low
 
   * First released version.
diff --git a/net.h b/net.h
index ad733a54e92bdfa2e9bea7635feeacdb4f955927..de3a11f67055d4535ff644c5286c1bee357f5c4a 100644 (file)
--- a/net.h
+++ b/net.h
@@ -1,7 +1,7 @@
 /*
  *     The Remote User Info Distribution Protocol
  *
- *     (c) 1997 Martin Mares <mj@atrey.karlin.mff.cuni.cz>
+ *     (c) 1997--2001 Martin Mares <mj@atrey.karlin.mff.cuni.cz>
  *
  *     This software may be freely distributed and used according to the terms
  *     of the GNU General Public License. See file COPYING in any of the GNU packages.
@@ -11,7 +11,7 @@
 
 struct userinfo {
   char name[10];
-  char con[4];
+  char con[8];
   char mesg_y;
   char pad;
   __u32 login_time;
@@ -19,6 +19,7 @@ struct userinfo {
 };
 
 struct rywho_pkt {
+  __u32 magic;                         /* Guard against ancient nwho versions */
   __u32 local_time;
   __u32 server_time;                   /* Reserved for use by the server */
   __u32 num_users;
@@ -27,7 +28,8 @@ struct rywho_pkt {
   struct userinfo users[MAX_USERS];
 };
 
-#define YWHO_SPOOL_DIR "/var/spool/nwho"
+#define NWHO_SPOOL_DIR "/var/spool/nwho"
+#define NWHO_MAGIC 0x21913332
 
 #define DEFAULT_SEND_TIME 30
 #define DEFAULT_PRUNE_TIME 30
diff --git a/nwho.c b/nwho.c
index dedaecadb6cb9d71ee5c44a00933d19c6ea48ec6..505309c35ebc0b010353233af1b677a2277bdc8f 100644 (file)
--- a/nwho.c
+++ b/nwho.c
@@ -1,7 +1,7 @@
 /*
- *     The Remote User Information Lister 1.8
+ *     The Remote User Information Lister 1.9
  *
- *     (c) 1997 Martin Mares <mj@atrey.karlin.mff.cuni.cz>
+ *     (c) 1997--2001 Martin Mares <mj@atrey.karlin.mff.cuni.cz>
  *
  *     This software may be freely distributed and used according to the terms
  *     of the GNU General Public License. See file COPYING in any of the GNU packages.
@@ -72,7 +72,7 @@ show_users(char *name, struct rywho_pkt *p)
   for(u=0; u<m; u++)
     {
       i = &p->users[u];
-      printf("%-8.8s %-3s %c %-16s ", i->name, i->con, (i->mesg_y ? ' ' : '-'), name);
+      printf("%-8.8s %-7s %c %-16s ", i->name, i->con, (i->mesg_y ? ' ' : '-'), name);
       puttime(ntohl(i->login_time));
       putchar(' ');
       puttime(ntohl(i->idle_time));
@@ -91,9 +91,9 @@ scan(void)
   int fd, r;
   int is = 0;
 
-  if (chdir(YWHO_SPOOL_DIR) < 0)
+  if (chdir(NWHO_SPOOL_DIR) < 0)
     {
-      fprintf(stderr, "chdir(" YWHO_SPOOL_DIR "): %m\n");
+      fprintf(stderr, "chdir(" NWHO_SPOOL_DIR "): %m\n");
       exit(1);
     }
   d = opendir(".");
@@ -114,6 +114,7 @@ scan(void)
        r = read(fd, &pkt, sizeof(pkt));
        close(fd);
        if (r < sizeof(struct rywho_pkt) - MAX_USERS*sizeof(struct userinfo)
+           || pkt.magic != htonl(NWHO_MAGIC)
            || r != sizeof(struct rywho_pkt) - (MAX_USERS - ntohl(pkt.num_users))*sizeof(struct userinfo))
          {
            fprintf(stderr, "%s: Malformed record\n", e->d_name);
@@ -138,7 +139,7 @@ main(int argc, char **argv)
       return 1;
     }
   if (!is_uptime)
-    puts("Name     Li  M Where            LogT  IdleT");
+    puts("Name     Li      M Where            LogT  IdleT");
   scan();
   return 0;
 }
diff --git a/nwhod.c b/nwhod.c
index 9b3cb7b4ff8082be3945fbd7591eb3bf5cc786f0..812759f6b25e150de74f5e767c8ba4830c6a346a 100644 (file)
--- a/nwhod.c
+++ b/nwhod.c
@@ -1,7 +1,7 @@
 /*
- *     The Remote User Information Daemon 1.8
+ *     The Remote User Information Daemon 1.9
  *
- *     (c) 1997 Martin Mares <mj@atrey.karlin.mff.cuni.cz>
+ *     (c) 1997--2001 Martin Mares <mj@atrey.karlin.mff.cuni.cz>
  *
  *     This software may be freely distributed and used according to the terms
  *     of the GNU General Public License. See file COPYING in any of the GNU packages.
@@ -112,19 +112,7 @@ scan_utmp(struct rywho_pkt *p, time_t now)
        name[9] = 0;
        strcpy(h->name, name);
        h->login_time = htonl(now - u->ut_time);
-       if (u->ut_id[0])
-         {
-           h->con[0] = u->ut_id[0];
-           h->con[1] = u->ut_id[1];
-           h->con[2] = 0;
-         }
-       else
-         {
-           char *z = u->ut_line;
-           if (!strncmp(z, "tty", 3))
-             z += 3;
-           sprintf(h->con, "%.3s", z);
-         }
+       sprintf(h->con, "%.7s", u->ut_line);
        sprintf(device, "/dev/%s", u->ut_line);
        if (stat(device, &st) < 0)
          {
@@ -178,6 +166,7 @@ static void
 make_pkt(struct rywho_pkt *pkt)
 {
   bzero(pkt, sizeof(pkt));
+  pkt->magic = htonl(NWHO_MAGIC);
   pkt->local_time = htonl(now);
   scan_utmp(pkt, now);
   scan_load(pkt);
@@ -257,6 +246,12 @@ receive(void)
       return;
     }
 
+  if (pkt.magic != htonl(NWHO_MAGIC))
+    {
+      syslog(LOG_WARNING, "Received ancient nwho packet from %s", inet_ntoa(sa.sin_addr));
+      return;
+    }
+
   for(e=first_host; e; e=e->next)
     if (e->addr == sa.sin_addr.s_addr)
       break;
@@ -337,8 +332,8 @@ server(void)
   static struct sigaction sigact;
 
   net_init(NULL);
-  if (chdir(YWHO_SPOOL_DIR) < 0)
-    die("chdir(" YWHO_SPOOL_DIR "): %m");
+  if (chdir(NWHO_SPOOL_DIR) < 0)
+    die("chdir(" NWHO_SPOOL_DIR "): %m");
   cleanup();
   bzero(&sigact, sizeof(sigact));
   sigact.sa_handler = tick;