Annotation of src/usr.bin/last/last.c, Revision 1.40
1.40 ! guenther 1: /* $OpenBSD: last.c,v 1.39 2013/08/22 04:43:40 guenther Exp $ */
1.1 deraadt 2: /* $NetBSD: last.c,v 1.6 1994/12/24 16:49:02 cgd Exp $ */
3:
4: /*
5: * Copyright (c) 1987, 1993, 1994
6: * The Regents of the University of California. All rights reserved.
7: *
8: * Redistribution and use in source and binary forms, with or without
9: * modification, are permitted provided that the following conditions
10: * are met:
11: * 1. Redistributions of source code must retain the above copyright
12: * notice, this list of conditions and the following disclaimer.
13: * 2. Redistributions in binary form must reproduce the above copyright
14: * notice, this list of conditions and the following disclaimer in the
15: * documentation and/or other materials provided with the distribution.
1.26 millert 16: * 3. Neither the name of the University nor the names of its contributors
1.1 deraadt 17: * may be used to endorse or promote products derived from this software
18: * without specific prior written permission.
19: *
20: * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
21: * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
22: * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
23: * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
24: * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
25: * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
26: * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
27: * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
28: * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
29: * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
30: * SUCH DAMAGE.
31: */
32:
33: #include <sys/param.h>
34: #include <sys/stat.h>
35:
1.35 chl 36: #include <ctype.h>
1.1 deraadt 37: #include <err.h>
38: #include <fcntl.h>
1.38 fgsch 39: #include <libgen.h>
1.1 deraadt 40: #include <paths.h>
41: #include <signal.h>
42: #include <stdio.h>
43: #include <stdlib.h>
44: #include <string.h>
45: #include <time.h>
46: #include <tzfile.h>
47: #include <unistd.h>
48: #include <utmp.h>
49:
50: #define NO 0 /* false/no */
51: #define YES 1 /* true/yes */
1.18 mickey 52: #define ATOI2(ar) ((ar)[0] - '0') * 10 + ((ar)[1] - '0'); (ar) += 2;
1.1 deraadt 53:
54: static struct utmp buf[1024]; /* utmp read buffer */
55:
1.33 deraadt 56: struct arg {
1.1 deraadt 57: char *name; /* argument */
58: #define HOST_TYPE -2
59: #define TTY_TYPE -3
60: #define USER_TYPE -4
61: int type; /* type of arg */
1.33 deraadt 62: struct arg *next; /* linked list pointer */
63: } *arglist;
1.1 deraadt 64:
1.33 deraadt 65: struct ttytab {
1.1 deraadt 66: time_t logout; /* log out time */
67: char tty[UT_LINESIZE + 1]; /* terminal name */
1.33 deraadt 68: struct ttytab*next; /* linked list pointer */
69: } *ttylist;
1.1 deraadt 70:
71: static time_t currentout; /* current logout value */
1.33 deraadt 72: static long maxrec = -1; /* records to display */
1.1 deraadt 73: static char *file = _PATH_WTMP; /* wtmp file */
1.6 mickey 74: static int fulltime = 0; /* Display seconds? */
1.33 deraadt 75: static time_t snaptime = 0; /* report only at this time */
76: static int calculate = 0;
77: static int seconds = 0;
1.1 deraadt 78:
1.19 millert 79: void addarg(int, char *);
1.33 deraadt 80: struct ttytab *addtty(char *);
1.19 millert 81: void hostconv(char *);
82: void onintr(int);
83: char *ttyconv(char *);
84: time_t dateconv(char *);
85: int want(struct utmp *, int);
86: void wtmp(void);
87: void checkargs(void);
1.40 ! guenther 88: void print_entry(const struct utmp *);
1.22 deraadt 89: void usage(void);
1.1 deraadt 90:
1.28 deraadt 91: #define NAME_WIDTH 9
1.14 fgsch 92: #define HOST_WIDTH 24
1.13 deraadt 93:
1.1 deraadt 94: int
1.27 deraadt 95: main(int argc, char *argv[])
1.1 deraadt 96: {
1.31 millert 97: const char *errstr;
1.33 deraadt 98: int ch, lastch = '\0', newarg = 1, prevoptind = 1;
1.1 deraadt 99:
1.32 millert 100: while ((ch = getopt(argc, argv, "0123456789cf:h:n:st:d:T")) != -1) {
1.1 deraadt 101: switch (ch) {
102: case '0': case '1': case '2': case '3': case '4':
103: case '5': case '6': case '7': case '8': case '9':
104: /*
105: * kludge: last was originally designed to take
106: * a number after a dash.
107: */
1.32 millert 108: if (newarg || !isdigit(lastch))
109: maxrec = 0;
110: else if (maxrec > INT_MAX / 10)
111: usage();
112: maxrec = (maxrec * 10) + (ch - '0');
1.1 deraadt 113: break;
1.9 downsj 114: case 'c':
115: calculate++;
116: break;
1.1 deraadt 117: case 'f':
118: file = optarg;
119: break;
120: case 'h':
121: hostconv(optarg);
122: addarg(HOST_TYPE, optarg);
123: break;
1.31 millert 124: case 'n':
125: maxrec = strtonum(optarg, 0, LONG_MAX, &errstr);
126: if (errstr != NULL)
127: errx(1, "number of lines is %s: %s", errstr,
128: optarg);
129: if (maxrec == 0)
130: exit(0);
131: break;
1.9 downsj 132: case 's':
133: seconds++;
134: break;
1.1 deraadt 135: case 't':
136: addarg(TTY_TYPE, ttyconv(optarg));
137: break;
1.4 jdm 138: case 'd':
139: snaptime = dateconv(optarg);
140: break;
1.6 mickey 141: case 'T':
1.9 downsj 142: fulltime = 1;
1.6 mickey 143: break;
1.1 deraadt 144: default:
1.22 deraadt 145: usage();
1.1 deraadt 146: }
1.32 millert 147: lastch = ch;
148: newarg = optind != prevoptind;
149: prevoptind = optind;
150: }
151: if (maxrec == 0)
152: exit(0);
1.1 deraadt 153:
154: if (argc) {
155: setlinebuf(stdout);
156: for (argv += optind; *argv; ++argv) {
157: #define COMPATIBILITY
158: #ifdef COMPATIBILITY
159: /* code to allow "last p5" to work */
160: addarg(TTY_TYPE, ttyconv(*argv));
161: #endif
162: addarg(USER_TYPE, *argv);
163: }
164: }
1.18 mickey 165:
1.5 jdm 166: checkargs();
1.1 deraadt 167: wtmp();
168: exit(0);
169: }
170:
171: /*
1.33 deraadt 172: * if snaptime is set, print warning if usernames, or -t or -h
173: * flags are also provided
1.5 jdm 174: */
175: void
1.27 deraadt 176: checkargs(void)
1.5 jdm 177: {
1.18 mickey 178: int ttyflag = 0;
1.33 deraadt 179: struct arg *step;
1.5 jdm 180:
1.33 deraadt 181: if (!snaptime || !arglist)
1.5 jdm 182: return;
183:
184: for (step = arglist; step; step = step->next)
185: switch (step->type) {
186: case HOST_TYPE:
1.7 deraadt 187: (void)fprintf(stderr,
188: "Warning: Ignoring hostname flag\n");
1.5 jdm 189: break;
190: case TTY_TYPE:
1.18 mickey 191: if (!ttyflag) { /* don't print this twice */
1.7 deraadt 192: (void)fprintf(stderr,
193: "Warning: Ignoring tty flag\n");
1.5 jdm 194: ttyflag = 1;
195: }
196: break;
197: case USER_TYPE:
1.7 deraadt 198: (void)fprintf(stderr,
199: "Warning: Ignoring username[s]\n");
1.5 jdm 200: break;
201: default:
1.20 millert 202: break;
1.5 jdm 203: /* PRINT NOTHING */
204: }
1.18 mickey 205: }
1.5 jdm 206:
1.40 ! guenther 207: void
! 208: print_entry(const struct utmp *bp)
! 209: {
! 210: printf("%-*.*s %-*.*s %-*.*s ",
! 211: NAME_WIDTH, UT_NAMESIZE, bp->ut_name,
! 212: UT_LINESIZE, UT_LINESIZE, bp->ut_line,
! 213: HOST_WIDTH, UT_HOSTSIZE, bp->ut_host);
! 214:
! 215: if (seconds)
! 216: printf("%lld", (long long)bp->ut_time);
! 217: else {
! 218: struct tm *tm;
! 219:
! 220: tm = localtime(&bp->ut_time);
! 221: if (tm == NULL) {
! 222: /* bogus entry? format as epoch time... */
! 223: printf("%lld", (long long)bp->ut_time);
! 224: } else {
! 225: char tim[40];
! 226:
! 227: strftime(tim, sizeof tim,
! 228: fulltime ? "%a %b %d %H:%M:%S" : "%a %b %d %H:%M",
! 229: tm);
! 230: printf("%s", tim);
! 231: }
! 232: }
! 233: }
! 234:
1.5 jdm 235:
236: /*
1.33 deraadt 237: * read through the wtmp file
1.1 deraadt 238: */
239: void
1.27 deraadt 240: wtmp(void)
1.1 deraadt 241: {
1.33 deraadt 242: time_t delta, total = 0;
243: int timesize, wfd, snapfound = 0;
1.40 ! guenther 244: char *ct, *crmsg;
1.33 deraadt 245: struct utmp *bp;
246: struct stat stb;
247: ssize_t bytes;
1.8 deraadt 248: off_t bl;
1.33 deraadt 249: struct ttytab *T;
250:
1.1 deraadt 251: if ((wfd = open(file, O_RDONLY, 0)) < 0 || fstat(wfd, &stb) == -1)
252: err(1, "%s", file);
253: bl = (stb.st_size + sizeof(buf) - 1) / sizeof(buf);
254:
1.6 mickey 255: if (fulltime)
256: timesize = 8; /* HH:MM:SS */
257: else
258: timesize = 5; /* HH:MM */
259:
1.1 deraadt 260: (void)time(&buf[0].ut_time);
261: (void)signal(SIGINT, onintr);
262: (void)signal(SIGQUIT, onintr);
263:
264: while (--bl >= 0) {
1.11 millert 265: if (lseek(wfd, bl * sizeof(buf), SEEK_SET) == -1 ||
1.1 deraadt 266: (bytes = read(wfd, buf, sizeof(buf))) == -1)
267: err(1, "%s", file);
268: for (bp = &buf[bytes / sizeof(buf[0]) - 1]; bp >= buf; --bp) {
269: /*
270: * if the terminal line is '~', the machine stopped.
271: * see utmp(5) for more info.
272: */
273: if (bp->ut_line[0] == '~' && !bp->ut_line[1]) {
274: /* everybody just logged out */
275: for (T = ttylist; T; T = T->next)
276: T->logout = -bp->ut_time;
277: currentout = -bp->ut_time;
278: crmsg = strncmp(bp->ut_name, "shutdown",
279: UT_NAMESIZE) ? "crash" : "shutdown";
1.33 deraadt 280:
1.18 mickey 281: /*
282: * if we're in snapshot mode, we want to
1.4 jdm 283: * exit if this shutdown/reboot appears
284: * while we we are tracking the active
285: * range
286: */
1.33 deraadt 287: if (snaptime && snapfound) {
288: close(wfd);
1.4 jdm 289: return;
1.33 deraadt 290: }
291:
1.18 mickey 292: /*
1.4 jdm 293: * don't print shutdown/reboot entries
1.18 mickey 294: * unless flagged for
295: */
1.5 jdm 296: if (want(bp, NO)) {
1.40 ! guenther 297: print_entry(bp);
! 298: printf("\n");
1.33 deraadt 299: if (maxrec != -1 && !--maxrec) {
300: close(wfd);
1.1 deraadt 301: return;
1.33 deraadt 302: }
1.1 deraadt 303: }
304: continue;
305: }
1.33 deraadt 306:
1.1 deraadt 307: /*
308: * if the line is '{' or '|', date got set; see
309: * utmp(5) for more info.
310: */
1.33 deraadt 311: if ((bp->ut_line[0] == '{' || bp->ut_line[0] == '|') &&
312: !bp->ut_line[1]) {
1.5 jdm 313: if (want(bp, NO)) {
1.40 ! guenther 314: print_entry(bp);
! 315: printf("\n");
1.33 deraadt 316: if (maxrec && !--maxrec) {
317: close(wfd);
1.1 deraadt 318: return;
1.33 deraadt 319: }
1.1 deraadt 320: }
321: continue;
322: }
1.33 deraadt 323:
1.1 deraadt 324: /* find associated tty */
325: for (T = ttylist;; T = T->next) {
326: if (!T) {
327: /* add new one */
328: T = addtty(bp->ut_line);
329: break;
330: }
331: if (!strncmp(T->tty, bp->ut_line, UT_LINESIZE))
332: break;
333: }
1.33 deraadt 334:
1.18 mickey 335: /*
1.4 jdm 336: * print record if not in snapshot mode and wanted
337: * or in snapshot mode and in snapshot range
338: */
339: if (bp->ut_name[0] &&
1.28 deraadt 340: ((want(bp, YES)) || (bp->ut_time < snaptime &&
341: (T->logout > snaptime || !T->logout ||
342: T->logout < 0)))) {
1.4 jdm 343: snapfound = 1;
1.40 ! guenther 344: print_entry(bp);
! 345: printf(" ");
1.33 deraadt 346:
1.1 deraadt 347: if (!T->logout)
348: puts(" still logged in");
349: else {
350: if (T->logout < 0) {
351: T->logout = -T->logout;
352: printf("- %s", crmsg);
1.9 downsj 353: } else {
1.18 mickey 354: if (seconds)
1.40 ! guenther 355: printf("- %lld",
! 356: (long long)T->logout);
1.9 downsj 357: else
358: printf("- %*.*s",
359: timesize, timesize,
360: ctime(&T->logout)+11);
1.1 deraadt 361: }
362: delta = T->logout - bp->ut_time;
1.9 downsj 363: if (seconds)
1.40 ! guenther 364: printf(" (%lld)\n",
! 365: (long long)delta);
1.9 downsj 366: else {
367: if (delta < SECSPERDAY)
368: printf(" (%*.*s)\n",
369: timesize, timesize,
370: asctime(gmtime(&delta))+11);
371: else
1.39 guenther 372: printf(" (%lld+%*.*s)\n",
373: (long long)delta / SECSPERDAY,
1.9 downsj 374: timesize, timesize,
375: asctime(gmtime(&delta))+11);
376: }
377: if (calculate)
378: total += delta;
1.1 deraadt 379: }
1.33 deraadt 380: if (maxrec != -1 && !--maxrec) {
381: close(wfd);
1.1 deraadt 382: return;
1.33 deraadt 383: }
1.1 deraadt 384: }
385: T->logout = bp->ut_time;
386: }
1.9 downsj 387: }
1.33 deraadt 388: close(wfd);
1.9 downsj 389: if (calculate) {
390: if ((total / SECSPERDAY) > 0) {
391: int days = (total / SECSPERDAY);
392: total -= (days * SECSPERDAY);
393:
394: printf("\nTotal time: %d days, %*.*s\n",
1.28 deraadt 395: days, timesize, timesize,
396: asctime(gmtime(&total))+11);
1.9 downsj 397: } else
398: printf("\nTotal time: %*.*s\n",
1.28 deraadt 399: timesize, timesize,
400: asctime(gmtime(&total))+11);
1.1 deraadt 401: }
402: ct = ctime(&buf[0].ut_time);
1.37 lum 403: printf("\n%s begins %10.10s %*.*s %4.4s\n", basename(file), ct,
404: timesize, timesize, ct + 11, ct + 20);
1.1 deraadt 405: }
406:
407: /*
1.33 deraadt 408: * see if want this entry
1.1 deraadt 409: */
410: int
1.27 deraadt 411: want(struct utmp *bp, int check)
1.1 deraadt 412: {
1.33 deraadt 413: struct arg *step;
1.1 deraadt 414:
1.15 deraadt 415: if (check) {
1.1 deraadt 416: /*
417: * when uucp and ftp log in over a network, the entry in
418: * the utmp file is the name plus their process id. See
419: * etc/ftpd.c and usr.bin/uucp/uucpd.c for more information.
420: */
421: if (!strncmp(bp->ut_line, "ftp", sizeof("ftp") - 1))
422: bp->ut_line[3] = '\0';
423: else if (!strncmp(bp->ut_line, "uucp", sizeof("uucp") - 1))
424: bp->ut_line[4] = '\0';
1.15 deraadt 425: }
1.5 jdm 426:
1.18 mickey 427: if (snaptime) /* if snaptime is set, return NO */
1.5 jdm 428: return (NO);
429:
1.1 deraadt 430: if (!arglist)
431: return (YES);
432:
433: for (step = arglist; step; step = step->next)
1.33 deraadt 434: switch (step->type) {
1.1 deraadt 435: case HOST_TYPE:
436: if (!strncasecmp(step->name, bp->ut_host, UT_HOSTSIZE))
437: return (YES);
438: break;
439: case TTY_TYPE:
440: if (!strncmp(step->name, bp->ut_line, UT_LINESIZE))
441: return (YES);
442: break;
443: case USER_TYPE:
444: if (!strncmp(step->name, bp->ut_name, UT_NAMESIZE))
445: return (YES);
446: break;
1.5 jdm 447: }
448:
1.1 deraadt 449: return (NO);
450: }
451:
452: /*
1.33 deraadt 453: * add an entry to a linked list of arguments
1.1 deraadt 454: */
455: void
1.27 deraadt 456: addarg(int type, char *arg)
1.1 deraadt 457: {
1.33 deraadt 458: struct arg *cur;
1.1 deraadt 459:
1.33 deraadt 460: if (!(cur = (struct arg *)malloc((u_int)sizeof(struct arg))))
1.1 deraadt 461: err(1, "malloc failure");
462: cur->next = arglist;
463: cur->type = type;
464: cur->name = arg;
465: arglist = cur;
466: }
467:
468: /*
1.33 deraadt 469: * add an entry to a linked list of ttys
1.1 deraadt 470: */
1.33 deraadt 471: struct ttytab *
1.27 deraadt 472: addtty(char *ttyname)
1.1 deraadt 473: {
1.33 deraadt 474: struct ttytab *cur;
1.1 deraadt 475:
1.33 deraadt 476: if (!(cur = (struct ttytab *)malloc((u_int)sizeof(struct ttytab))))
1.1 deraadt 477: err(1, "malloc failure");
478: cur->next = ttylist;
479: cur->logout = currentout;
480: memmove(cur->tty, ttyname, UT_LINESIZE);
481: return (ttylist = cur);
482: }
483:
484: /*
1.33 deraadt 485: * convert the hostname to search pattern; if the supplied host name
486: * has a domain attached that is the same as the current domain, rip
487: * off the domain suffix since that's what login(1) does.
1.1 deraadt 488: */
489: void
1.27 deraadt 490: hostconv(char *arg)
1.1 deraadt 491: {
1.33 deraadt 492: static char *hostdot, name[MAXHOSTNAMELEN];
1.1 deraadt 493: static int first = 1;
494: char *argdot;
495:
496: if (!(argdot = strchr(arg, '.')))
497: return;
498: if (first) {
499: first = 0;
500: if (gethostname(name, sizeof(name)))
501: err(1, "gethostname");
502: hostdot = strchr(name, '.');
503: }
504: if (hostdot && !strcasecmp(hostdot, argdot))
505: *argdot = '\0';
506: }
507:
508: /*
1.33 deraadt 509: * convert tty to correct name.
1.1 deraadt 510: */
511: char *
1.27 deraadt 512: ttyconv(char *arg)
1.1 deraadt 513: {
1.33 deraadt 514: size_t len = 8;
1.1 deraadt 515: char *mval;
516:
517: /*
518: * kludge -- we assume that all tty's end with
519: * a two character suffix.
520: */
521: if (strlen(arg) == 2) {
522: /* either 6 for "ttyxx" or 8 for "console" */
1.21 deraadt 523: if (!(mval = malloc(len)))
1.1 deraadt 524: err(1, "malloc failure");
525: if (!strcmp(arg, "co"))
1.21 deraadt 526: (void)strlcpy(mval, "console", len);
527: else
528: snprintf(mval, len, "tty%s", arg);
1.1 deraadt 529: return (mval);
530: }
531: if (!strncmp(arg, _PATH_DEV, sizeof(_PATH_DEV) - 1))
532: return (arg + 5);
533: return (arg);
534: }
1.4 jdm 535:
1.18 mickey 536: /*
537: * Convert the snapshot time in command line given in the format
1.23 deraadt 538: * [[[CC]YY]MMDD]hhmm[.SS]] to a time_t.
1.18 mickey 539: * Derived from atime_arg1() in usr.bin/touch/touch.c
1.4 jdm 540: */
541: time_t
1.27 deraadt 542: dateconv(char *arg)
1.4 jdm 543: {
1.7 deraadt 544: time_t timet;
545: struct tm *t;
546: int yearset;
547: char *p;
548:
549: /* Start with the current time. */
550: if (time(&timet) < 0)
551: err(1, "time");
552: if ((t = localtime(&timet)) == NULL)
553: err(1, "localtime");
554:
1.23 deraadt 555: /* [[[CC]YY]MMDD]hhmm[.SS] */
1.7 deraadt 556: if ((p = strchr(arg, '.')) == NULL)
1.18 mickey 557: t->tm_sec = 0; /* Seconds defaults to 0. */
1.7 deraadt 558: else {
559: if (strlen(p + 1) != 2)
560: goto terr;
561: *p++ = '\0';
562: t->tm_sec = ATOI2(p);
563: }
564:
565: yearset = 0;
566: switch (strlen(arg)) {
1.22 deraadt 567: case 12: /* CCYYMMDDhhmm */
1.7 deraadt 568: t->tm_year = ATOI2(arg);
569: t->tm_year *= 100;
570: yearset = 1;
1.29 otto 571: /* FALLTHROUGH */
1.22 deraadt 572: case 10: /* YYMMDDhhmm */
1.7 deraadt 573: if (yearset) {
574: yearset = ATOI2(arg);
575: t->tm_year += yearset;
576: } else {
577: yearset = ATOI2(arg);
578: if (yearset < 69)
579: t->tm_year = yearset + 2000;
580: else
581: t->tm_year = yearset + 1900;
582: }
1.28 deraadt 583: t->tm_year -= 1900; /* Convert to UNIX time. */
1.7 deraadt 584: /* FALLTHROUGH */
585: case 8: /* MMDDhhmm */
586: t->tm_mon = ATOI2(arg);
1.18 mickey 587: --t->tm_mon; /* Convert from 01-12 to 00-11 */
1.7 deraadt 588: t->tm_mday = ATOI2(arg);
589: t->tm_hour = ATOI2(arg);
590: t->tm_min = ATOI2(arg);
591: break;
592: case 4: /* hhmm */
593: t->tm_hour = ATOI2(arg);
594: t->tm_min = ATOI2(arg);
595: break;
596: default:
597: goto terr;
598: }
1.18 mickey 599: t->tm_isdst = -1; /* Figure out DST. */
1.7 deraadt 600: timet = mktime(t);
601: if (timet == -1)
1.28 deraadt 602: terr: errx(1, "out of range or illegal time specification: "
603: "[[[CC]YY]MMDD]hhmm[.SS]");
1.22 deraadt 604: return (timet);
1.4 jdm 605: }
606:
1.1 deraadt 607:
608: /*
1.33 deraadt 609: * on interrupt, we inform the user how far we've gotten
1.1 deraadt 610: */
611: void
1.27 deraadt 612: onintr(int signo)
1.1 deraadt 613: {
1.25 deraadt 614: char str[1024], *ct;
1.1 deraadt 615:
1.25 deraadt 616: ct = ctime(&buf[0].ut_time); /* XXX signal race */
617: snprintf(str, sizeof str, "\ninterrupted %10.10s %8.8s \n",
618: ct, ct + 11);
619: write(STDOUT_FILENO, str, strlen(str));
1.1 deraadt 620: if (signo == SIGINT)
1.25 deraadt 621: _exit(1);
1.22 deraadt 622: }
623:
624: void
625: usage(void)
626: {
627: extern char *__progname;
628:
629: fprintf(stderr,
1.34 jmc 630: "usage: %s [-csT] [-d date] [-f file] [-h host]"
631: " [-n number] [-t tty] [user ...]\n", __progname);
1.22 deraadt 632: exit(1);
1.1 deraadt 633: }