diff --git a/doc/Changelog b/doc/Changelog index cfadaeb..2b4eac3 100644 --- a/doc/Changelog +++ b/doc/Changelog @@ -13,6 +13,10 @@ sysvinit (2.97) unreleased; urgency=low * Added patch from Didier Gaudin which allows init to load configuration data from files stored in /etc/inittab.d/ + * Added patch from William Shipley which allows shutdown time to be specified + in the format +hh:mm. This is in addition to the existing formats such as + hh:mm, +m, and "now". + sysvinit (2.96) released; urgency=low diff --git a/man/shutdown.8 b/man/shutdown.8 index 5d012ec..871808f 100644 --- a/man/shutdown.8 +++ b/man/shutdown.8 @@ -142,7 +142,9 @@ The \fItime\fP argument can have different formats. First, it can be an absolute time in the format \fIhh:mm\fP, in which \fIhh\fP is the hour (1 or 2 digits) and \fImm\fP is the minute of the hour (in two digits). Second, it can be in the format \fB+\fP\fIm\fP, in which \fIm\fP is the -number of minutes to wait. The word \fBnow\fP is an alias for \fB+0\fP. +number of minutes to wait. Third, it can be in the format \fB+\fP\fIhh:mm\fP, +in which \fIhh:mm\fP is the number of hours and minutes to wait. +The word \fBnow\fP is an alias for \fB+0\fP. .PP If shutdown is called with a delay, it will create the advisory file .I /etc/nologin diff --git a/src/dowall.c b/src/dowall.c index dbe4ed0..83b2828 100644 --- a/src/dowall.c +++ b/src/dowall.c @@ -163,7 +163,7 @@ void wall(const char *text, int remote) struct utmp *utmp; time_t t; char term[UT_LINESIZE+ strlen(_PATH_DEV) + 1]; - char line[81]; + char line[256]; char hostname[HOST_NAME_MAX+1]; char *date, *p; char *user, *tty; diff --git a/src/shutdown.c b/src/shutdown.c index b744a2c..c49795f 100644 --- a/src/shutdown.c +++ b/src/shutdown.c @@ -788,13 +788,21 @@ int main(int argc, char **argv) wt = atoi(when); if (wt == 0 && when[0] != '0') usage(); } else { - /* Time in hh:mm format. */ if (sscanf(when, "%d:%2d", &hours, &mins) != 2) usage(); - if (hours > 23 || mins > 59) usage(); - time(&t); - lt = localtime(&t); - wt = (60*hours + mins) - (60*lt->tm_hour + lt->tm_min); - if (wt < 0) wt += 1440; + /* Time in hh:mm format. */ + if (when[0] == '+') { + /* Hours and minutes from now */ + if (hours > 99999 || mins > 59) usage(); + wt = (60*hours + mins); + if (wt < 0) usage(); + } else { + /* Time of day */ + if (hours > 23 || mins > 59) usage(); + time(&t); + lt = localtime(&t); + wt = (60*hours + mins) - (60*lt->tm_hour + lt->tm_min); + if (wt < 0) wt += 1440; + } } /* Shutdown NOW if time == 0 */ if (wt == 0) issue_shutdown(halttype);