Red Hat axp-list: Linux on Alpha (1995-2022)
 help / color / mirror / Atom feed
From: Ferdy Hanssen <hanssen@Cam031205.student.utwente.nl>
Subject: rwho/rwhod from NetKit-B-0.09 bug + fix
Date: Sat, 12 Apr 1997 10:21:58 +0200 (MEST)	[thread overview]
Message-ID: <1f66b95ec5b1f427e614e2f06ed691bf.axp-list@archive.invalid> (raw)

Hello,

  The rwho and rwhod commands from the NetKit-B-0.09 for Red Hat Linux 4.1
don't work properly.

  I fixed it, and include the patch below.  It has to be applied only for
Alpha (it's untested on any other architecture), and it has to be applied
after all other patches in the current src rpm.

Ferdy T.Y. Hanssen, Student at Dept. of Computer Science, University of Twente
E-mail: hanssen@cs.utwente.nl or hanssen@Cam031205.student.utwente.nl

------ Included file: NetKit-B-0.09-rwhod.patch ------
diff -ur NetKit-0.09.old/MCONFIG NetKit-0.09/MCONFIG
--- NetKit-0.09.old/MCONFIG	Fri Apr 11 14:48:07 1997
+++ NetKit-0.09/MCONFIG	Fri Apr 11 13:12:35 1997
@@ -69,7 +69,7 @@
 # On alphas you may want to take out -Wcast-align for now.
 WARNINGS=-Wall -W -Wpointer-arith -Wbad-function-cast -Wcast-qual \
 	 -Wstrict-prototypes -Wmissing-prototypes \
-	 -Wmissing-declarations -Wnested-externs -Winline -Wcast-align
+	 -Wmissing-declarations -Wnested-externs -Winline # -Wcast-align
 
 # Linux libc's /usr/include isn't clean with these.
 # -Wredundant-decls      (there are a number of such in /usr/include)
diff -ur NetKit-0.09.old/include/protocols/rwhod.h NetKit-0.09/include/protocols/rwhod.h
--- NetKit-0.09.old/include/protocols/rwhod.h	Mon Jul 15 23:41:40 1996
+++ NetKit-0.09/include/protocols/rwhod.h	Thu Apr 10 12:05:01 1997
@@ -43,7 +43,7 @@
 struct	outmp {
 	char	out_line[8];		/* tty name */
 	char	out_name[8];		/* user id */
-	long	out_time;		/* time on */
+	int	out_time;		/* time on */
 };
 
 struct	whod {
diff -ur NetKit-0.09.old/rwho/rwho.c NetKit-0.09/rwho/rwho.c
--- NetKit-0.09.old/rwho/rwho.c	Thu Aug 15 05:25:20 1996
+++ NetKit-0.09/rwho/rwho.c	Fri Apr 11 13:45:42 1997
@@ -39,6 +39,10 @@
  * From: @(#)rwho.c	5.5 (Berkeley) 6/1/90
  */
 char rcsid[] = "$Id: rwho.c,v 1.4 1996/08/15 03:25:17 dholland Exp $";
+/*
+ * Fixed 11 Apr 1997 by Ferdy Hanssen <hanssen@esrac.ele.tue.nl>,
+ * to make it work in Linux/Alpha
+ */
 
 #include <sys/param.h>
 #include <sys/dir.h>
@@ -144,12 +148,14 @@
 	mp = myutmp;
 	for (i = 0; i < nusers; i++) {
 		char buf[BUFSIZ];
+		time_t timetmp;
 		(void)sprintf(buf, "%s:%s", mp->myhost, mp->myutmp.out_line);
+		timetmp = mp->myutmp.out_time;
 		printf("%-8.8s %-*s %.12s",
 		   mp->myutmp.out_name,
 		   width,
 		   buf,
-		   ctime((time_t *)&mp->myutmp.out_time)+4);
+		   ctime(&timetmp)+4);
 		mp->myidle /= 60;
 		if (mp->myidle) {
 			if (aflg) {
diff -ur NetKit-0.09.old/rwhod/Makefile NetKit-0.09/rwhod/Makefile
--- NetKit-0.09.old/rwhod/Makefile	Sat Nov 23 19:52:33 1996
+++ NetKit-0.09/rwhod/Makefile	Fri Apr 11 13:10:59 1997
@@ -3,7 +3,8 @@
 include ../MCONFIG
 include ../MRULES
 
-CFLAGS += -I ../include
+#CFLAGS += -I ../include -DDEBUG -D_GNU_SOURCE
+CFLAGS += -I ../include -D_GNU_SOURCE
 OBJS = rwhod.o daemon.o
 
 rwhod: $(OBJS)
diff -ur NetKit-0.09.old/rwhod/rwhod.c NetKit-0.09/rwhod/rwhod.c
--- NetKit-0.09.old/rwhod/rwhod.c	Fri Apr 11 14:48:07 1997
+++ NetKit-0.09/rwhod/rwhod.c	Fri Apr 11 14:50:28 1997
@@ -40,7 +40,12 @@
  */
 char rcsid[] = 
   "$Id: rwhod.c,v 1.8 1996/08/29 22:45:22 dholland Exp $";
+/*
+ * Fixed 11 Apr 1997 by Ferdy Hanssen <hanssen@esrac.ele.tue.nl>,
+ * to make it work in Linux/Alpha
+ */
 
+#include <sys/types.h>
 #include <sys/param.h>
 #include <sys/socket.h>
 #include <sys/stat.h>
@@ -115,8 +120,71 @@
 static void getkmem(int);
 static void onalrm(int);
 
-int
-main(void)
+#ifdef DEBUG
+char *interval(int time, char *updown);
+
+#define sendto my_sendto
+
+int sendto(int s, __const void *buf, size_t cc, int flags, __const struct sockaddr *to, size_t tolen)
+{
+	register struct whod *w;
+	register struct whoent *we;
+	struct sockaddr_in *sn;
+
+	w = buf;
+	sn = (struct sockaddr_in *)to;
+
+	printf("sendto %lx.%d\n", ntohl(sn->sin_addr.s_addr), ntohs(sn->sin_port));
+	printf("hostname %s %s\n", w->wd_hostname,
+	   interval(ntohl(w->wd_sendtime) - ntohl(w->wd_boottime), "  up"));
+	printf("load %4.2f, %4.2f, %4.2f\n",
+	    ntohl(w->wd_loadav[0]) / 100.0, ntohl(w->wd_loadav[1]) / 100.0,
+	    ntohl(w->wd_loadav[2]) / 100.0);
+	cc -= WHDRSIZE;
+	for (we = w->wd_we, cc /= sizeof (struct whoent); cc > 0; cc--, we++) {
+		time_t t = ntohl(we->we_utmp.out_time);
+		printf("%-8.8s %s:%s %.12s",
+			we->we_utmp.out_name,
+			w->wd_hostname, we->we_utmp.out_line,
+			ctime(&t)+4);
+		we->we_idle = ntohl(we->we_idle) / 60;
+		if (we->we_idle) {
+			if (we->we_idle >= 100*60)
+				we->we_idle = 100*60 - 1;
+			if (we->we_idle >= 60)
+				printf(" %2d", we->we_idle / 60);
+			else
+				printf("   ");
+			printf(":%02d", we->we_idle % 60);
+		}
+		printf("\n");
+	}
+	return 0;
+}
+
+char *interval(int time, char *updown)
+{
+	static char resbuf[32];
+	int days, hours, minutes;
+
+	if (time < 0 || time > 3*30*24*60*60) {
+		(void) sprintf(resbuf, "   %s ??:??", updown);
+		return (resbuf);
+	}
+	minutes = (time + 59) / 60;		/* round to minutes */
+	hours = minutes / 60; minutes %= 60;
+	days = hours / 24; hours %= 24;
+	if (days)
+		(void) sprintf(resbuf, "%s %2d+%02d:%02d",
+		    updown, days, hours, minutes);
+	else
+		(void) sprintf(resbuf, "%s    %2d:%02d",
+		    updown, hours, minutes);
+	return (resbuf);
+}
+#endif
+
+int main(void)
 {
 	struct sockaddr_in from;
 	struct stat st;
@@ -251,8 +319,7 @@
  * and other funnies before allowing a file
  * to be created.  Sorry, but blanks aren't allowed.
  */
-static int
-verify(const char *name)
+static int verify(const char *name)
 {
 	register int size = 0;
 
@@ -264,9 +331,9 @@
 	return size > 0;
 }
 
-int	utmptime;
+unsigned long int	utmptime;
 int	utmpent;
-int	utmpsize = 0;
+long int	utmpsize = 0;
 struct	utmp *utmp;
 int	alarmcount;
 
@@ -342,7 +409,7 @@
 	}
 	getloadavg(avenrun, sizeof(avenrun)/sizeof(avenrun[0]));
 	for (i = 0; i < 3; i++)
-		mywd.wd_loadav[i] = htonl((u_long)(avenrun[i] * 100));
+		mywd.wd_loadav[i] = (int)htonl((u_long)(avenrun[i] * 100));
 	cc = (char *)we - (char *)&mywd;
 	mywd.wd_sendtime = htonl(time(0));
 	mywd.wd_vers = WHODVERSION;
@@ -467,8 +534,7 @@
  * Figure out device configuration and select
  * networks which deserve status information.
  */
-static int
-configure(int s)
+static int configure(int s)
 {
 	char buf[BUFSIZ], *cp, *cplim;
 	struct ifconf ifc;
@@ -479,7 +545,7 @@
 	ifc.ifc_len = sizeof (buf);
 	ifc.ifc_buf = buf;
 	if (ioctl(s, SIOCGIFCONF, (char *)&ifc) < 0) {
-		syslog(LOG_ERR, "ioctl (get interface configuration)");
+		syslog(LOG_ERR, "ioctl (get interface configuration): %m");
 		return (0);
 	}
 	ifr = ifc.ifc_req;
@@ -490,8 +556,7 @@
 #define size(p) (sizeof (p))
 #endif
 	cplim = buf + ifc.ifc_len; /*skip over if's with big ifr_addr's */
-	for (cp = buf; cp < cplim;
-			cp += sizeof (ifr->ifr_name) + size(ifr->ifr_addr)) {
+	for (cp = buf; cp < cplim; cp += sizeof(*ifr)) {
 		ifr = (struct ifreq *)cp;
 		for (np = neighbors; np != NULL; np = np->n_next)
 			if (np->n_name &&
@@ -518,7 +583,7 @@
 		}
 		bcopy((char *)&ifr->ifr_addr, np->n_addr, np->n_addrlen);
 		if (ioctl(s, SIOCGIFFLAGS, (char *)&ifreq) < 0) {
-			syslog(LOG_ERR, "ioctl (get interface flags)");
+			syslog(LOG_ERR, "ioctl (get interface flags): %m");
 			free((char *)np);
 			continue;
 		}
@@ -530,7 +595,7 @@
 		np->n_flags = ifreq.ifr_flags;
 		if (np->n_flags & IFF_POINTOPOINT) {
 			if (ioctl(s, SIOCGIFDSTADDR, (char *)&ifreq) < 0) {
-				syslog(LOG_ERR, "ioctl (get dstaddr)");
+				syslog(LOG_ERR, "ioctl (get dstaddr): %m");
 				free((char *)np);
 				continue;
 			}
@@ -540,7 +605,7 @@
 		}
 		if (np->n_flags & IFF_BROADCAST) {
 			if (ioctl(s, SIOCGIFBRDADDR, (char *)&ifreq) < 0) {
-				syslog(LOG_ERR, "ioctl (get broadaddr)");
+				syslog(LOG_ERR, "ioctl (get broadaddr): %m");
 				free((char *)np);
 				continue;
 			}
@@ -556,76 +621,3 @@
 	}
 	return (1);
 }
-
-#ifdef DEBUG
-sendto(s, buf, cc, flags, to, tolen)
-	int s;
-#ifdef	__linux__
-	__const void *buf;
-	int cc;
-	unsigned int flags;
-	__const struct sockaddr *to;
-	int tolen;
-#else
-	char *buf;
-	int cc, flags;
-	char *to;
-	int tolen;
-#endif
-{
-	register struct whod *w = (struct whod *)buf;
-	register struct whoent *we;
-	struct sockaddr_in *sn = (struct sockaddr_in *)to;
-	char *interval();
-
-	printf("sendto %x.%d\n", ntohl(sn->sin_addr.s_addr), ntohs(sn->sin_port));
-	printf("hostname %s %s\n", w->wd_hostname,
-	   interval(ntohl(w->wd_sendtime) - ntohl(w->wd_boottime), "  up"));
-	printf("load %4.2f, %4.2f, %4.2f\n",
-	    ntohl(w->wd_loadav[0]) / 100.0, ntohl(w->wd_loadav[1]) / 100.0,
-	    ntohl(w->wd_loadav[2]) / 100.0);
-	cc -= WHDRSIZE;
-	for (we = w->wd_we, cc /= sizeof (struct whoent); cc > 0; cc--, we++) {
-		time_t t = ntohl(we->we_utmp.out_time);
-		printf("%-8.8s %s:%s %.12s",
-			we->we_utmp.out_name,
-			w->wd_hostname, we->we_utmp.out_line,
-			ctime(&t)+4);
-		we->we_idle = ntohl(we->we_idle) / 60;
-		if (we->we_idle) {
-			if (we->we_idle >= 100*60)
-				we->we_idle = 100*60 - 1;
-			if (we->we_idle >= 60)
-				printf(" %2d", we->we_idle / 60);
-			else
-				printf("   ");
-			printf(":%02d", we->we_idle % 60);
-		}
-		printf("\n");
-	}
-}
-
-char *
-interval(time, updown)
-	int time;
-	char *updown;
-{
-	static char resbuf[32];
-	int days, hours, minutes;
-
-	if (time < 0 || time > 3*30*24*60*60) {
-		(void) sprintf(resbuf, "   %s ??:??", updown);
-		return (resbuf);
-	}
-	minutes = (time + 59) / 60;		/* round to minutes */
-	hours = minutes / 60; minutes %= 60;
-	days = hours / 24; hours %= 24;
-	if (days)
-		(void) sprintf(resbuf, "%s %2d+%02d:%02d",
-		    updown, days, hours, minutes);
-	else
-		(void) sprintf(resbuf, "%s    %2d:%02d",
-		    updown, hours, minutes);
-	return (resbuf);
-}
-#endif

--
To unsubscribe: send e-mail to axp-list-request@redhat.com with
'unsubscribe' as the subject.  Do not send it to axp-list@redhat.com

                 reply	other threads:[~1997-04-12  8:21 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed
read-only archive

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox