122549Sdist /* 235392Sbostic * Copyright (c) 1983 The Regents of the University of California. 335392Sbostic * All rights reserved. 435392Sbostic * 542819Sbostic * %sccs.include.redist.c% 622549Sdist */ 722549Sdist 86460Swnj #ifndef lint 922549Sdist char copyright[] = 1035392Sbostic "@(#) Copyright (c) 1983 The Regents of the University of California.\n\ 1122549Sdist All rights reserved.\n"; 1235392Sbostic #endif /* not lint */ 136460Swnj 1422549Sdist #ifndef lint 15*44328Ssklower static char sccsid[] = "@(#)rwhod.c 5.18 (Berkeley) 06/27/90"; 1635392Sbostic #endif /* not lint */ 1722549Sdist 1842265Skarels #include <sys/param.h> 199215Ssam #include <sys/socket.h> 209215Ssam #include <sys/stat.h> 2137295Sbostic #include <sys/signal.h> 229215Ssam #include <sys/ioctl.h> 2313187Ssam #include <sys/file.h> 249215Ssam 2512236Ssam #include <net/if.h> 269215Ssam #include <netinet/in.h> 279215Ssam 289215Ssam #include <nlist.h> 296460Swnj #include <errno.h> 306460Swnj #include <utmp.h> 318486Ssam #include <ctype.h> 328486Ssam #include <netdb.h> 3316673Sralph #include <syslog.h> 3423535Smckusick #include <protocols/rwhod.h> 3537295Sbostic #include <stdio.h> 3637971Sbostic #include <paths.h> 376460Swnj 3815541Sralph /* 3915541Sralph * Alarm interval. Don't forget to change the down time check in ruptime 4015541Sralph * if this is changed. 4115541Sralph */ 4216673Sralph #define AL_INTERVAL (3 * 60) 4315541Sralph 4442265Skarels struct sockaddr_in sin; 456460Swnj 4642265Skarels char myname[MAXHOSTNAMELEN]; 476460Swnj 486460Swnj struct nlist nl[] = { 4938182Smckusick #define NL_BOOTTIME 0 509215Ssam { "_boottime" }, 516460Swnj 0 526460Swnj }; 536460Swnj 5412236Ssam /* 5512236Ssam * We communicate with each neighbor in 5612236Ssam * a list constructed at the time we're 5712236Ssam * started up. Neighbors are currently 5812236Ssam * directly connected via a hardware interface. 5912236Ssam */ 6012236Ssam struct neighbor { 6112236Ssam struct neighbor *n_next; 6212236Ssam char *n_name; /* interface name */ 6312236Ssam char *n_addr; /* who to send to */ 6412236Ssam int n_addrlen; /* size of address */ 6512236Ssam int n_flags; /* should forward?, interface flags */ 6612236Ssam }; 6712236Ssam 6812236Ssam struct neighbor *neighbors; 696460Swnj struct whod mywd; 7012236Ssam struct servent *sp; 716460Swnj int s, utmpf, kmemf = -1; 726460Swnj 7312236Ssam #define WHDRSIZE (sizeof (mywd) - sizeof (mywd.wd_we)) 7411834Ssam 7537295Sbostic extern int errno; 766460Swnj int onalrm(); 7732449Sbostic char *strcpy(), *malloc(); 786460Swnj long lseek(); 796460Swnj int getkmem(); 8012236Ssam struct in_addr inet_makeaddr(); 816460Swnj 826460Swnj main() 836460Swnj { 846460Swnj struct sockaddr_in from; 8526016Skarels struct stat st; 866460Swnj char path[64]; 8726484Smckusick int on = 1; 8837295Sbostic char *cp, *index(), *strerror(); 896460Swnj 9016673Sralph if (getuid()) { 9116673Sralph fprintf(stderr, "rwhod: not super user\n"); 9216673Sralph exit(1); 9316673Sralph } 948486Ssam sp = getservbyname("who", "udp"); 958486Ssam if (sp == 0) { 968486Ssam fprintf(stderr, "rwhod: udp/who: unknown service\n"); 978486Ssam exit(1); 988486Ssam } 996460Swnj #ifndef DEBUG 1006460Swnj if (fork()) 1016460Swnj exit(0); 1026460Swnj { int s; 1036460Swnj for (s = 0; s < 10; s++) 1046460Swnj (void) close(s); 1056460Swnj (void) open("/", 0); 1066460Swnj (void) dup2(0, 1); 1076460Swnj (void) dup2(0, 2); 10837971Sbostic s = open(_PATH_TTY, 2); 1096460Swnj if (s >= 0) { 1106460Swnj ioctl(s, TIOCNOTTY, 0); 1116460Swnj (void) close(s); 1126460Swnj } 1136460Swnj } 1146460Swnj #endif 11537295Sbostic if (chdir(_PATH_RWHODIR) < 0) { 11637295Sbostic (void)fprintf(stderr, "rwhod: %s: %s\n", 11737295Sbostic _PATH_RWHODIR, strerror(errno)); 11826011Smckusick exit(1); 11926011Smckusick } 1206460Swnj (void) signal(SIGHUP, getkmem); 12124853Seric openlog("rwhod", LOG_PID, LOG_DAEMON); 12212236Ssam /* 12312236Ssam * Establish host name as returned by system. 12412236Ssam */ 12512236Ssam if (gethostname(myname, sizeof (myname) - 1) < 0) { 12616673Sralph syslog(LOG_ERR, "gethostname: %m"); 1276460Swnj exit(1); 1286460Swnj } 12924745Sbloom if ((cp = index(myname, '.')) != NULL) 13024745Sbloom *cp = '\0'; 13112236Ssam strncpy(mywd.wd_hostname, myname, sizeof (myname) - 1); 13237295Sbostic utmpf = open(_PATH_UTMP, O_RDONLY|O_CREAT, 0644); 1336460Swnj if (utmpf < 0) { 13437295Sbostic syslog(LOG_ERR, "%s: %m", _PATH_UTMP); 1356460Swnj exit(1); 1366460Swnj } 1376460Swnj getkmem(); 13813187Ssam if ((s = socket(AF_INET, SOCK_DGRAM, 0)) < 0) { 13916673Sralph syslog(LOG_ERR, "socket: %m"); 1409215Ssam exit(1); 1416460Swnj } 14217155Ssam if (setsockopt(s, SOL_SOCKET, SO_BROADCAST, &on, sizeof (on)) < 0) { 14317055Skarels syslog(LOG_ERR, "setsockopt SO_BROADCAST: %m"); 14417055Skarels exit(1); 14517055Skarels } 14642265Skarels sin.sin_family = AF_INET; 14712236Ssam sin.sin_port = sp->s_port; 14813187Ssam if (bind(s, &sin, sizeof (sin)) < 0) { 14916673Sralph syslog(LOG_ERR, "bind: %m"); 1509215Ssam exit(1); 1519215Ssam } 15212236Ssam if (!configure(s)) 15312236Ssam exit(1); 15413027Ssam signal(SIGALRM, onalrm); 1556460Swnj onalrm(); 1566460Swnj for (;;) { 1576460Swnj struct whod wd; 15812236Ssam int cc, whod, len = sizeof (from); 1596460Swnj 16012236Ssam cc = recvfrom(s, (char *)&wd, sizeof (struct whod), 0, 16112236Ssam &from, &len); 1626460Swnj if (cc <= 0) { 1636460Swnj if (cc < 0 && errno != EINTR) 16416673Sralph syslog(LOG_WARNING, "recv: %m"); 1656460Swnj continue; 1666460Swnj } 1678486Ssam if (from.sin_port != sp->s_port) { 16816673Sralph syslog(LOG_WARNING, "%d: bad from port", 1698486Ssam ntohs(from.sin_port)); 1706460Swnj continue; 1716460Swnj } 17212347Ssam if (wd.wd_vers != WHODVERSION) 17312347Ssam continue; 17412236Ssam if (wd.wd_type != WHODTYPE_STATUS) 17512236Ssam continue; 1768486Ssam if (!verify(wd.wd_hostname)) { 17716673Sralph syslog(LOG_WARNING, "malformed host name from %x", 1788486Ssam from.sin_addr); 1798486Ssam continue; 1808486Ssam } 18126011Smckusick (void) sprintf(path, "whod.%s", wd.wd_hostname); 18226016Skarels /* 18326016Skarels * Rather than truncating and growing the file each time, 18426016Skarels * use ftruncate if size is less than previous size. 18526016Skarels */ 18626016Skarels whod = open(path, O_WRONLY | O_CREAT, 0644); 1876460Swnj if (whod < 0) { 18816673Sralph syslog(LOG_WARNING, "%s: %m", path); 1896460Swnj continue; 1906460Swnj } 19142265Skarels #if ENDIAN != BIG_ENDIAN 19211834Ssam { 19313187Ssam int i, n = (cc - WHDRSIZE)/sizeof(struct whoent); 19411834Ssam struct whoent *we; 19511834Ssam 19611834Ssam /* undo header byte swapping before writing to file */ 19711834Ssam wd.wd_sendtime = ntohl(wd.wd_sendtime); 19811834Ssam for (i = 0; i < 3; i++) 19911834Ssam wd.wd_loadav[i] = ntohl(wd.wd_loadav[i]); 20011834Ssam wd.wd_boottime = ntohl(wd.wd_boottime); 20111834Ssam we = wd.wd_we; 20211834Ssam for (i = 0; i < n; i++) { 20311834Ssam we->we_idle = ntohl(we->we_idle); 20412872Ssam we->we_utmp.out_time = 20512872Ssam ntohl(we->we_utmp.out_time); 20611834Ssam we++; 20711834Ssam } 20811834Ssam } 20911834Ssam #endif 2106460Swnj (void) time(&wd.wd_recvtime); 2116460Swnj (void) write(whod, (char *)&wd, cc); 21226016Skarels if (fstat(whod, &st) < 0 || st.st_size > cc) 21326016Skarels ftruncate(whod, cc); 2146460Swnj (void) close(whod); 2156460Swnj } 2166460Swnj } 2176460Swnj 2188486Ssam /* 2198486Ssam * Check out host name for unprintables 2208486Ssam * and other funnies before allowing a file 2218486Ssam * to be created. Sorry, but blanks aren't allowed. 2228486Ssam */ 2238486Ssam verify(name) 2248486Ssam register char *name; 2258486Ssam { 2268486Ssam register int size = 0; 2278486Ssam 2288486Ssam while (*name) { 22915214Sleres if (!isascii(*name) || !(isalnum(*name) || ispunct(*name))) 2308486Ssam return (0); 2318486Ssam name++, size++; 2328486Ssam } 2338486Ssam return (size > 0); 2348486Ssam } 2358486Ssam 2366460Swnj int utmptime; 2376460Swnj int utmpent; 23822546Sbloom int utmpsize = 0; 23922546Sbloom struct utmp *utmp; 2406460Swnj int alarmcount; 2416460Swnj 2426460Swnj onalrm() 2436460Swnj { 24437295Sbostic register struct neighbor *np; 24537295Sbostic register struct whoent *we = mywd.wd_we, *wlast; 2466460Swnj register int i; 2476460Swnj struct stat stb; 2486460Swnj int cc; 2496460Swnj double avenrun[3]; 25037295Sbostic time_t now = time((time_t *)NULL); 25137295Sbostic char *strerror(); 2526460Swnj 2536460Swnj if (alarmcount % 10 == 0) 2546460Swnj getkmem(); 2556460Swnj alarmcount++; 2566460Swnj (void) fstat(utmpf, &stb); 25722546Sbloom if ((stb.st_mtime != utmptime) || (stb.st_size > utmpsize)) { 25817303Stef utmptime = stb.st_mtime; 25922546Sbloom if (stb.st_size > utmpsize) { 26022546Sbloom utmpsize = stb.st_size + 10 * sizeof(struct utmp); 26122546Sbloom if (utmp) 26222546Sbloom utmp = (struct utmp *)realloc(utmp, utmpsize); 26322546Sbloom else 26422546Sbloom utmp = (struct utmp *)malloc(utmpsize); 26522546Sbloom if (! utmp) { 26622546Sbloom fprintf(stderr, "rwhod: malloc failed\n"); 26722546Sbloom utmpsize = 0; 26822546Sbloom goto done; 26922546Sbloom } 27022546Sbloom } 27113187Ssam (void) lseek(utmpf, (long)0, L_SET); 27222546Sbloom cc = read(utmpf, (char *)utmp, stb.st_size); 2736460Swnj if (cc < 0) { 27437295Sbostic fprintf(stderr, "rwhod: %s: %s\n", 27537295Sbostic _PATH_UTMP, strerror(errno)); 27613469Ssam goto done; 2776460Swnj } 27812236Ssam wlast = &mywd.wd_we[1024 / sizeof (struct whoent) - 1]; 2796460Swnj utmpent = cc / sizeof (struct utmp); 2806460Swnj for (i = 0; i < utmpent; i++) 2816460Swnj if (utmp[i].ut_name[0]) { 28212807Ssam bcopy(utmp[i].ut_line, we->we_utmp.out_line, 28312807Ssam sizeof (utmp[i].ut_line)); 28412807Ssam bcopy(utmp[i].ut_name, we->we_utmp.out_name, 28512807Ssam sizeof (utmp[i].ut_name)); 28612807Ssam we->we_utmp.out_time = htonl(utmp[i].ut_time); 2876577Ssam if (we >= wlast) 2886577Ssam break; 2896460Swnj we++; 2906460Swnj } 2916460Swnj utmpent = we - mywd.wd_we; 2926460Swnj } 29326484Smckusick 29426484Smckusick /* 29526484Smckusick * The test on utmpent looks silly---after all, if no one is 29626484Smckusick * logged on, why worry about efficiency?---but is useful on 29726484Smckusick * (e.g.) compute servers. 29826484Smckusick */ 29937971Sbostic if (utmpent && chdir(_PATH_DEV)) { 30037971Sbostic syslog(LOG_ERR, "chdir(%s): %m", _PATH_DEV); 30126484Smckusick exit(1); 30226484Smckusick } 3036460Swnj we = mywd.wd_we; 3046460Swnj for (i = 0; i < utmpent; i++) { 30526484Smckusick if (stat(we->we_utmp.out_line, &stb) >= 0) 30612807Ssam we->we_idle = htonl(now - stb.st_atime); 3076460Swnj we++; 3086460Swnj } 30938182Smckusick (void) getloadavg(avenrun, sizeof(avenrun)/sizeof(avenrun[0])); 3106460Swnj for (i = 0; i < 3; i++) 31112873Ssam mywd.wd_loadav[i] = htonl((u_long)(avenrun[i] * 100)); 3126460Swnj cc = (char *)we - (char *)&mywd; 31312807Ssam mywd.wd_sendtime = htonl(time(0)); 31412236Ssam mywd.wd_vers = WHODVERSION; 31512236Ssam mywd.wd_type = WHODTYPE_STATUS; 31612236Ssam for (np = neighbors; np != NULL; np = np->n_next) 31712236Ssam (void) sendto(s, (char *)&mywd, cc, 0, 31812236Ssam np->n_addr, np->n_addrlen); 31937295Sbostic if (utmpent && chdir(_PATH_RWHODIR)) { 32037295Sbostic syslog(LOG_ERR, "chdir(%s): %m", _PATH_RWHODIR); 32126484Smckusick exit(1); 32226484Smckusick } 32313469Ssam done: 32415541Sralph (void) alarm(AL_INTERVAL); 3256460Swnj } 3266460Swnj 3276460Swnj getkmem() 3286460Swnj { 32916663Ssam static ino_t vmunixino; 33016663Ssam static time_t vmunixctime; 33116663Ssam struct stat sb; 3326460Swnj 33337295Sbostic if (stat(_PATH_UNIX, &sb) < 0) { 33416663Ssam if (vmunixctime) 33516663Ssam return; 33616663Ssam } else { 33716663Ssam if (sb.st_ctime == vmunixctime && sb.st_ino == vmunixino) 33816663Ssam return; 33916663Ssam vmunixctime = sb.st_ctime; 34016663Ssam vmunixino= sb.st_ino; 34116663Ssam } 3426460Swnj if (kmemf >= 0) 3436460Swnj (void) close(kmemf); 3446460Swnj loop: 34537295Sbostic if (nlist(_PATH_UNIX, nl)) { 34637295Sbostic syslog(LOG_WARNING, "%s: namelist botch", _PATH_UNIX); 3476460Swnj sleep(300); 3486460Swnj goto loop; 3496460Swnj } 35037295Sbostic kmemf = open(_PATH_KMEM, O_RDONLY, 0); 3516460Swnj if (kmemf < 0) { 35237295Sbostic syslog(LOG_ERR, "%s: %m", _PATH_KMEM); 35316673Sralph exit(1); 3546460Swnj } 35513187Ssam (void) lseek(kmemf, (long)nl[NL_BOOTTIME].n_value, L_SET); 35613187Ssam (void) read(kmemf, (char *)&mywd.wd_boottime, 35713187Ssam sizeof (mywd.wd_boottime)); 35812807Ssam mywd.wd_boottime = htonl(mywd.wd_boottime); 3596460Swnj } 36012236Ssam 36112236Ssam /* 36212236Ssam * Figure out device configuration and select 36312236Ssam * networks which deserve status information. 36412236Ssam */ 36512236Ssam configure(s) 36612236Ssam int s; 36712236Ssam { 36844308Ssklower char buf[BUFSIZ], *cp, *cplim; 36912236Ssam struct ifconf ifc; 37012236Ssam struct ifreq ifreq, *ifr; 37112236Ssam struct sockaddr_in *sin; 37212236Ssam register struct neighbor *np; 37312236Ssam 37412236Ssam ifc.ifc_len = sizeof (buf); 37512236Ssam ifc.ifc_buf = buf; 37612236Ssam if (ioctl(s, SIOCGIFCONF, (char *)&ifc) < 0) { 37716673Sralph syslog(LOG_ERR, "ioctl (get interface configuration)"); 37812236Ssam return (0); 37912236Ssam } 38012236Ssam ifr = ifc.ifc_req; 381*44328Ssklower #ifdef AF_LINK 38244308Ssklower #define max(a, b) (a > b ? a : b) 38344308Ssklower #define size(p) max((p).sa_len, sizeof(p)) 38444308Ssklower #else 38544308Ssklower #define size(p) (sizeof (p)) 38644308Ssklower #endif 38744308Ssklower cplim = buf + ifc.ifc_len; /*skip over if's with big ifr_addr's */ 38844308Ssklower for (cp = buf; cp < cplim; 38944308Ssklower cp += sizeof (ifr->ifr_name) + size(ifr->ifr_addr)) { 39044308Ssklower ifr = (struct ifreq *)cp; 39112236Ssam for (np = neighbors; np != NULL; np = np->n_next) 39212236Ssam if (np->n_name && 39312236Ssam strcmp(ifr->ifr_name, np->n_name) == 0) 39412236Ssam break; 39512236Ssam if (np != NULL) 39612236Ssam continue; 39712236Ssam ifreq = *ifr; 39812236Ssam np = (struct neighbor *)malloc(sizeof (*np)); 39912236Ssam if (np == NULL) 40012236Ssam continue; 40112236Ssam np->n_name = malloc(strlen(ifr->ifr_name) + 1); 40212236Ssam if (np->n_name == NULL) { 40312236Ssam free((char *)np); 40412236Ssam continue; 40512236Ssam } 40612236Ssam strcpy(np->n_name, ifr->ifr_name); 40712236Ssam np->n_addrlen = sizeof (ifr->ifr_addr); 40812236Ssam np->n_addr = malloc(np->n_addrlen); 40912236Ssam if (np->n_addr == NULL) { 41012236Ssam free(np->n_name); 41112236Ssam free((char *)np); 41212236Ssam continue; 41312236Ssam } 41412236Ssam bcopy((char *)&ifr->ifr_addr, np->n_addr, np->n_addrlen); 41512236Ssam if (ioctl(s, SIOCGIFFLAGS, (char *)&ifreq) < 0) { 41616673Sralph syslog(LOG_ERR, "ioctl (get interface flags)"); 41712236Ssam free((char *)np); 41812236Ssam continue; 41912236Ssam } 42021852Skarels if ((ifreq.ifr_flags & IFF_UP) == 0 || 42121852Skarels (ifreq.ifr_flags & (IFF_BROADCAST|IFF_POINTOPOINT)) == 0) { 42212236Ssam free((char *)np); 42312236Ssam continue; 42412236Ssam } 42512236Ssam np->n_flags = ifreq.ifr_flags; 42612236Ssam if (np->n_flags & IFF_POINTOPOINT) { 42712236Ssam if (ioctl(s, SIOCGIFDSTADDR, (char *)&ifreq) < 0) { 42816673Sralph syslog(LOG_ERR, "ioctl (get dstaddr)"); 42912236Ssam free((char *)np); 43012236Ssam continue; 43112236Ssam } 43212236Ssam /* we assume addresses are all the same size */ 43312236Ssam bcopy((char *)&ifreq.ifr_dstaddr, 43412236Ssam np->n_addr, np->n_addrlen); 43512236Ssam } 43612236Ssam if (np->n_flags & IFF_BROADCAST) { 43721852Skarels if (ioctl(s, SIOCGIFBRDADDR, (char *)&ifreq) < 0) { 43821852Skarels syslog(LOG_ERR, "ioctl (get broadaddr)"); 43921852Skarels free((char *)np); 44021852Skarels continue; 44121852Skarels } 44212236Ssam /* we assume addresses are all the same size */ 44321852Skarels bcopy((char *)&ifreq.ifr_broadaddr, 44421852Skarels np->n_addr, np->n_addrlen); 44512236Ssam } 44612236Ssam /* gag, wish we could get rid of Internet dependencies */ 44712236Ssam sin = (struct sockaddr_in *)np->n_addr; 44812236Ssam sin->sin_port = sp->s_port; 44912236Ssam np->n_next = neighbors; 45012236Ssam neighbors = np; 45112236Ssam } 45212236Ssam return (1); 45312236Ssam } 45412807Ssam 45512807Ssam #ifdef DEBUG 45612807Ssam sendto(s, buf, cc, flags, to, tolen) 45712807Ssam int s; 45812807Ssam char *buf; 45912807Ssam int cc, flags; 46012807Ssam char *to; 46112807Ssam int tolen; 46212807Ssam { 46312807Ssam register struct whod *w = (struct whod *)buf; 46412807Ssam register struct whoent *we; 46512807Ssam struct sockaddr_in *sin = (struct sockaddr_in *)to; 46612807Ssam char *interval(); 46712807Ssam 46812807Ssam printf("sendto %x.%d\n", ntohl(sin->sin_addr), ntohs(sin->sin_port)); 46912807Ssam printf("hostname %s %s\n", w->wd_hostname, 47013187Ssam interval(ntohl(w->wd_sendtime) - ntohl(w->wd_boottime), " up")); 47112807Ssam printf("load %4.2f, %4.2f, %4.2f\n", 47213187Ssam ntohl(w->wd_loadav[0]) / 100.0, ntohl(w->wd_loadav[1]) / 100.0, 47313187Ssam ntohl(w->wd_loadav[2]) / 100.0); 47412807Ssam cc -= WHDRSIZE; 47512807Ssam for (we = w->wd_we, cc /= sizeof (struct whoent); cc > 0; cc--, we++) { 47613187Ssam time_t t = ntohl(we->we_utmp.out_time); 47712807Ssam printf("%-8.8s %s:%s %.12s", 47813187Ssam we->we_utmp.out_name, 47913187Ssam w->wd_hostname, we->we_utmp.out_line, 48013187Ssam ctime(&t)+4); 48113187Ssam we->we_idle = ntohl(we->we_idle) / 60; 48212807Ssam if (we->we_idle) { 48312807Ssam if (we->we_idle >= 100*60) 48412807Ssam we->we_idle = 100*60 - 1; 48512807Ssam if (we->we_idle >= 60) 48612807Ssam printf(" %2d", we->we_idle / 60); 48712807Ssam else 48812807Ssam printf(" "); 48912807Ssam printf(":%02d", we->we_idle % 60); 49012807Ssam } 49112807Ssam printf("\n"); 49212807Ssam } 49312807Ssam } 49412807Ssam 49512807Ssam char * 49612807Ssam interval(time, updown) 49712807Ssam int time; 49812807Ssam char *updown; 49912807Ssam { 50012807Ssam static char resbuf[32]; 50112807Ssam int days, hours, minutes; 50212807Ssam 50312807Ssam if (time < 0 || time > 3*30*24*60*60) { 50412807Ssam (void) sprintf(resbuf, " %s ??:??", updown); 50512807Ssam return (resbuf); 50612807Ssam } 50712807Ssam minutes = (time + 59) / 60; /* round to minutes */ 50812807Ssam hours = minutes / 60; minutes %= 60; 50912807Ssam days = hours / 24; hours %= 24; 51012807Ssam if (days) 51112807Ssam (void) sprintf(resbuf, "%s %2d+%02d:%02d", 51212807Ssam updown, days, hours, minutes); 51312807Ssam else 51412807Ssam (void) sprintf(resbuf, "%s %2d:%02d", 51512807Ssam updown, hours, minutes); 51612807Ssam return (resbuf); 51712807Ssam } 51812807Ssam #endif 519