From 60a4c6ad5c7bec35ba23e2bf616c3a643ce1cffd Mon Sep 17 00:00:00 2001 From: Martin Mares Date: Tue, 6 Feb 2001 20:34:51 +0000 Subject: [PATCH] See changelogs... --- ChangeLog | 11 +++++++++++ Makefile | 2 +- debian/changelog | 12 ++++++++++++ net.h | 8 +++++--- nwho.c | 13 +++++++------ nwhod.c | 29 ++++++++++++----------------- 6 files changed, 48 insertions(+), 27 deletions(-) diff --git a/ChangeLog b/ChangeLog index 779e993..50351b5 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,14 @@ +2001-02-06 Martin Mares + + * 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 * ywho.c: Miscellaneous fixes based on bug reports and patch diff --git a/Makefile b/Makefile index efd9196..4b3255e 100644 --- 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 diff --git a/debian/changelog b/debian/changelog index c7395d7..428380b 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,3 +1,15 @@ +ywho (1.9-2) unstable; urgency=low + + * Synced with master CVS. + + -- Martin Mares Tue, 6 Feb 2001 21:33:21 +0100 + +ywho (1.9-1) unstable; urgency=low + + * New upstream release + + -- Martin Mares 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 ad733a5..de3a11f 100644 --- a/net.h +++ b/net.h @@ -1,7 +1,7 @@ /* * The Remote User Info Distribution Protocol * - * (c) 1997 Martin Mares + * (c) 1997--2001 Martin Mares * * 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 dedaeca..505309c 100644 --- 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 + * (c) 1997--2001 Martin Mares * * 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; uusers[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 9b3cb7b..812759f 100644 --- 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 + * (c) 1997--2001 Martin Mares * * 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; -- 2.39.2