[Pkg-sysvinit-devel] Bug#325772: /sbin/halt: mention which machine
is going down
Petter Reinholdtsen
pere at hungry.com
Sat Nov 5 10:07:37 UTC 2005
tags 325772 + patch
thanks
I believe this patch should solve the issue. Any objections before I
include it in a new version of sysvinit?
Index: src/dowall.c
===================================================================
--- src/dowall.c (revisjon 100)
+++ src/dowall.c (arbeidskopi)
@@ -131,6 +131,7 @@
time_t t;
char term[UT_LINESIZE+6];
char line[81];
+ char hostname[256]; /* HOST_NAME_MAX+1 */
char *date, *p;
char *user, *tty;
int fd, flags;
@@ -144,6 +145,16 @@
getuidtty(&user, &tty);
+ /* Get and report current hostname, to make it easier to find
+ out which machine that is being shut down. */
+ if (0 != gethostname(hostname, sizeof(hostname))) {
+ strncpy(hostname, "[unknown]", sizeof(hostname)-1);
+ }
+ /* If hostname is truncated, it is unspecified if the string
+ is null terminated or not. Make sure we know it is null
+ terminated. */
+ hostname[sizeof(hostname)-1] = 0;
+
/* Get the time */
time(&t);
date = ctime(&t);
@@ -157,8 +168,8 @@
date);
} else {
snprintf(line, sizeof(line),
- "\007\r\nBroadcast message from %s %s(%s):\r\n\r\n",
- user, tty, date);
+ "\007\r\nBroadcast message from %s@%s %s(%s):\r\n\r\n",
+ user, hostname, tty, date);
}
/*
More information about the Pkg-sysvinit-devel
mailing list