ywho, patch 1
Christos S. Zoulas
christos at theory.tn.cornell.edu
Sun Dec 16 13:11:25 AEST 1990
Hello again,
This is a patch to the ywho program I posted before, that takes care
of the non null terminated hostname printing bug.
Thanks to:
Mark Nagel <nagel at buckaroo.ics.uci.edu>
Jan van der Steen <jansteen at cwi.nl>
Tom Christiansen <tchrist at pixel.convex.com>
for their suggestions, bug report, and fixes.
christos
*** ywho.1v.orig Wed Jun 20 00:05:08 1990
--- ywho.1v Sat Dec 15 20:56:52 1990
***************
*** 1,8 ****
! .TH YWHO 1V "28 February 1988"
.SH NAME
! ywho/yusers/yuptime \- who, users, uptime on clients in a sun-RPC network.
.SH SYNOPSIS
! .B ywho/yusers/yuptime
[<host>]|[-g <netgroup>]
.SH DESCRIPTION
.I ywho
--- 1,8 ----
! .TH YWHO 1V "15 December 1990"
.SH NAME
! ywho, yusers, yuptime \- who, users, uptime on clients in a sun-RPC network.
.SH SYNOPSIS
! .B ywho, yusers, yuptime
[<host>]|[-g <netgroup>]
.SH DESCRIPTION
.I ywho
***************
*** 81,87 ****
.SH AUTHORS
James P. Lewis, York University, 1988
.br
! Christos S. Zoulas, Cornell University, 1989
.SH SEE ALSO
netgroup(5), yp(5)
.SH NOTE
--- 81,87 ----
.SH AUTHORS
James P. Lewis, York University, 1988
.br
! Christos S. Zoulas, Cornell University, 1990
.SH SEE ALSO
netgroup(5), yp(5)
.SH NOTE
*** ywho.c.orig Thu Oct 4 19:28:46 1990
--- ywho.c Sat Dec 15 20:56:40 1990
***************
*** 1,4 ****
! /* $Header: /usr/share/src/local/common/bin/ywho/RCS/ywho.c,v 1.10 90/10/04 19:28:14 christos Exp $ */
/*
* ywho.c: Use rpc to obtain information about remote users
* if it is invoked as yusers, present info in short format
--- 1,4 ----
! /* $Header: /tmp_mnt/usr/share/src/local/common/bin/ywho/RCS/ywho.c,v 1.11 90/12/15 20:59:44 christos Exp $ */
/*
* ywho.c: Use rpc to obtain information about remote users
* if it is invoked as yusers, present info in short format
***************
*** 19,24 ****
--- 19,28 ----
*
*
* $Log: ywho.c,v $
+ * Revision 1.11 90/12/15 20:59:44 christos
+ * Fixed remote host printing (again)
+ * and lint cosmetic fixes.
+ *
* Revision 1.10 90/10/04 19:28:14 christos
* Eliminated duplicate hosts from the list.
* Fixed printing for remote host.
***************
*** 60,66 ****
*
*/
#ifndef lint
! static char rcsid[] = "$Id: ywho.c,v 1.10 90/10/04 19:28:14 christos Exp $";
#endif /* lint */
#include <sys/types.h>
--- 64,70 ----
*
*/
#ifndef lint
! static char rcsid[] = "$Id: ywho.c,v 1.11 90/12/15 20:59:44 christos Exp $";
#endif /* lint */
#include <sys/types.h>
***************
*** 84,93 ****
# define HST_LEN 64
#endif
#define NIL(a) ((a *) 0)
! #define NEW(a) ((a *) Malloc(sizeof(a)))
! #define NEWN(a, n) ((a *) Malloc(sizeof(a) * (n)))
! #define strdup(a) ((char *) strcpy(Malloc(strlen(a) + 1), a))
#define SEP "\t \n,="
#ifndef FSCALE
#define FSCALE (1 << 8)
--- 88,109 ----
# define HST_LEN 64
#endif
+ #ifdef lint
+ /*
+ * Make lint think Malloc's value is well aligned.
+ */
+ typedef union {
+ double a; long b; int c; short d; char e;
+ } *align_t;
+ #else
+ typedef char *align_t;
+ #endif
+
#define NIL(a) ((a *) 0)
! #define NEW(a) ((a *) Malloc((unsigned) sizeof(a)))
! #define NEWN(a, n) ((a *) Malloc((unsigned) (sizeof(a) * (n))))
! #define strdup(a) ((char *) strcpy((char *) Malloc((unsigned) (strlen(a) + 1)),\
! a))
#define SEP "\t \n,="
#ifndef FSCALE
#define FSCALE (1 << 8)
***************
*** 113,119 ****
extern char *getenv();
extern char *sys_errlist[];
extern int errno;
! static char *Malloc();
static void do_host();
static void do_timeout();
static char *pname;
--- 129,135 ----
extern char *getenv();
extern char *sys_errlist[];
extern int errno;
! static align_t Malloc();
static void do_host();
static void do_timeout();
static char *pname;
***************
*** 193,199 ****
if ( argc == 1 ) {
home = getenv("HOME");
! sprintf(buffer, "%s%s.yhosts", home ? home : "", home ? "/" : "");
fp = fopen(buffer, "r");
if ( fp == NIL(FILE) ) {
--- 209,216 ----
if ( argc == 1 ) {
home = getenv("HOME");
! (void) sprintf(buffer, "%s%s.yhosts",
! home ? home : "", home ? "/" : "");
fp = fopen(buffer, "r");
if ( fp == NIL(FILE) ) {
***************
*** 301,307 ****
}
alarm(0);
}
! exit(0);
}
static struct utmpidlearr cutmpidlearr;
--- 318,324 ----
}
alarm(0);
}
! return(0);
}
static struct utmpidlearr cutmpidlearr;
***************
*** 319,325 ****
{
char nick_name[HST_LEN], tmp[BUFSIZ];
int ss, dd, hh, mm, printed;
! int addrlen, i, j, sock;
register CLIENT *client, *client_st;
struct hostent *hp;
struct timeval pertry_timeout, total_timeout;
--- 336,342 ----
{
char nick_name[HST_LEN], tmp[BUFSIZ];
int ss, dd, hh, mm, printed;
! int i, sock;
register CLIENT *client, *client_st;
struct hostent *hp;
struct timeval pertry_timeout, total_timeout;
***************
*** 326,331 ****
--- 343,349 ----
struct sockaddr_in server_addr;
enum clnt_stat clnt_stat, clnt_stat_st;
char *ptr, *host;
+ long j;
(void) strncpy(nick_name, hst->hp.h_name, HST_LEN);
***************
*** 347,353 ****
pertry_timeout.tv_usec = 0;
total_timeout.tv_sec = timeout;
total_timeout.tv_usec = 0;
- addrlen = sizeof(struct sockaddr_in);
bcopy(hp->h_addr, (caddr_t) &server_addr.sin_addr, hp->h_length);
server_addr.sin_family = AF_INET;
server_addr.sin_port = 0;
--- 365,370 ----
***************
*** 377,383 ****
pertry_timeout.tv_usec = 0;
total_timeout.tv_sec = timeout;
total_timeout.tv_usec = 0;
- addrlen = sizeof(struct sockaddr_in);
bcopy(hp->h_addr, (caddr_t) &server_addr.sin_addr, hp->h_length);
server_addr.sin_family = AF_INET;
server_addr.sin_port = 0;
--- 394,399 ----
***************
*** 446,465 ****
ctime(&j)+4, tmp);
#if !defined(hpux) || defined(__hpux)
if (*(host = cutmpidlearr.uia_arr[i]->ui_utmp.ut_host)) {
! char *ptr, flg;
! for (ptr = tmp, flg = isdigit(*host) ? '\0' : '.';
! *host != '\0' && ptr <
! &tmp[sizeof(cutmpidlearr.uia_arr[i]->ui_utmp.ut_host)] &&
! (*host != flg || ((host = strchr(host, ':')) != 0));
! host++) {
! if (*host == ':') flg = '\0';
! *ptr++ = isupper(*host) ? tolower(*host) : *host;
! *ptr = '\0';
}
(void) fprintf(stdout, " %-16.16s\n", tmp);
}
else
#endif
(void) fprintf(stdout, "\n");
if ( i < cutmpidlearr.uia_cnt - 1 )
--- 462,490 ----
ctime(&j)+4, tmp);
#if !defined(hpux) || defined(__hpux)
+
+ #define SIZ_UT_HOST sizeof(cutmpidlearr.uia_arr[i]->ui_utmp.ut_host)
+
if (*(host = cutmpidlearr.uia_arr[i]->ui_utmp.ut_host)) {
! char *dot, *col;
! (void) strncpy(tmp, host, SIZ_UT_HOST);
! tmp[SIZ_UT_HOST] = '\0';
! if (!isdigit(*tmp) && (dot = strchr(tmp, '.')) != NIL(char)) {
! if ((col = strchr(tmp, ':')) != NIL(char)) {
! if (col > dot)
! (void) strcpy(dot, col);
! }
! else
! *dot = '\0';
}
+ for (ptr = tmp; *ptr;)
+ *ptr++ = isupper(*ptr) ? tolower(*ptr) : *ptr;
(void) fprintf(stdout, " %-16.16s\n", tmp);
}
else
+
+ #undef SIZ_UT_HOST
+
#endif
(void) fprintf(stdout, "\n");
if ( i < cutmpidlearr.uia_cnt - 1 )
***************
*** 526,535 ****
/* Malloc():
* Memory checked malloc
*/
! static char *
Malloc(nth)
unsigned nth;
{
char *ptr;
extern char *malloc();
--- 551,561 ----
/* Malloc():
* Memory checked malloc
*/
! static align_t
Malloc(nth)
unsigned nth;
{
+ #ifndef lint
char *ptr;
extern char *malloc();
***************
*** 538,543 ****
--- 564,572 ----
exit(1);
}
return(ptr);
+ #else
+ return(nth ? (align_t) 0 : (align_t) 0);
+ #endif
} /* end Malloc */
/* do_timeout():
--
+------------------------------------------------------------------------+
| Christos Zoulas | 389 Theory Center, Electrical Engineering, |
| christos at ee.cornell.edu | Cornell University, Ithaca NY 14853. |
| christos at crnlee.bitnet | Phone: Disconnected | Fax: (607) 254 4565 |
More information about the Alt.sources
mailing list