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:
@@ -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;
|
||||
|
||||
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user