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