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".

Cleared up compiler warning in dowall which can happen if the
output message is longer than the size limit on the snprintf()
buffer. This is not a bug, a the trucation works, but using a larger
buffer avoids the warning on systems with long user/host names.
This commit is contained in:
Jesse Smith 2020-06-20 13:41:18 -03:00
parent d4cc79bcb9
commit 584df5efaf
4 changed files with 22 additions and 8 deletions

View File

@ -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

View File

@ -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

View File

@ -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;

View File

@ -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);