View | Details | Raw Unified | Return to bug 32411
Collapse All | Expand All

(-)shutdown.8 (+7 lines)
Lines 118-123 Link Here
118
to the current system values.  The first form brings the system down in
118
to the current system values.  The first form brings the system down in
119
.Ar number
119
.Ar number
120
minutes and the second at the absolute time specified.
120
minutes and the second at the absolute time specified.
121
If an absolute time is specified, but not a date,
122
and that time today has already passed,
123
.Nm
124
will assume that the same time tomorrow was meant.
125
(If a complete date is specified which has already passed,
126
.Nm
127
will print an error and exit without shutting the system down.)
121
.It Ar warning-message
128
.It Ar warning-message
122
Any other arguments comprise the warning message that is broadcast
129
Any other arguments comprise the warning message that is broadcast
123
to users currently logged into the system.
130
to users currently logged into the system.
(-)shutdown.c (-3 / +21 lines)
Lines 400-407 Link Here
400
	struct tm *lt;
400
	struct tm *lt;
401
	char *p;
401
	char *p;
402
	time_t now;
402
	time_t now;
403
	int this_year;
403
	int this_year, maybe_today;
404
404
405
	maybe_today = 1;
405
	(void)time(&now);
406
	(void)time(&now);
406
407
407
	if (!strcasecmp(timearg, "now")) {		/* now */
408
	if (!strcasecmp(timearg, "now")) {		/* now */
Lines 454-459 Link Here
454
			badtime();
455
			badtime();
455
		/* FALLTHROUGH */
456
		/* FALLTHROUGH */
456
	case 6:
457
	case 6:
458
		maybe_today = 0;
457
		lt->tm_mday = ATOI2(timearg);
459
		lt->tm_mday = ATOI2(timearg);
458
		if (lt->tm_mday < 1 || lt->tm_mday > 31)
460
		if (lt->tm_mday < 1 || lt->tm_mday > 31)
459
			badtime();
461
			badtime();
Lines 468-475 Link Here
468
		lt->tm_sec = 0;
470
		lt->tm_sec = 0;
469
		if ((shuttime = mktime(lt)) == -1)
471
		if ((shuttime = mktime(lt)) == -1)
470
			badtime();
472
			badtime();
471
		if ((offset = shuttime - now) < 0)
473
472
			errx(1, "that time is already past.");
474
		if ((offset = shuttime - now) < 0) {
475
			if (!maybe_today)
476
				errx(1, "that time is already past.");
477
478
			/*
479
			 * If the user only gave a time, assume that
480
			 * any time earlier than the current time
481
			 * was intended to be that time tomorrow.
482
			 */
483
			lt->tm_mday++;
484
			if ((shuttime = mktime(lt)) == -1)
485
				badtime();
486
			if ((offset = shuttime - now) < 0) {
487
				warnx("tomorrow is before today?");
488
				abort();
489
			}
490
		}
473
		break;
491
		break;
474
	default:
492
	default:
475
		badtime();
493
		badtime();

Return to bug 32411