[Pkg-sysvinit-commits] r1445 - in sysvinit-upstream/trunk: doc src

Petter Reinholdtsen pere at alioth.debian.org
Sun Jul 12 13:30:32 UTC 2009


Author: pere
Date: 2009-07-12 13:30:31 +0000 (Sun, 12 Jul 2009)
New Revision: 1445

Modified:
   sysvinit-upstream/trunk/doc/Changelog
   sysvinit-upstream/trunk/src/dowall.c
Log:
Change wall to make halt include hostname in output.

Modified: sysvinit-upstream/trunk/doc/Changelog
===================================================================
--- sysvinit-upstream/trunk/doc/Changelog	2009-07-12 13:28:37 UTC (rev 1444)
+++ sysvinit-upstream/trunk/doc/Changelog	2009-07-12 13:30:31 UTC (rev 1445)
@@ -63,6 +63,7 @@
     from Sebastian Reichelt, Werner Fink and SuSe.
   * Modify wall to use UT_LINESIZE from <utmp.h> instead of hardcoded
     string lengths.  Patch from SuSe.
+  * Change wall to make halt include hostname in output.
 
  -- Petter Reinholdtsen <pere at debian.org>  Fri, 30 Jul 2004 14:14:58 +0200
 

Modified: sysvinit-upstream/trunk/src/dowall.c
===================================================================
--- sysvinit-upstream/trunk/src/dowall.c	2009-07-12 13:28:37 UTC (rev 1444)
+++ sysvinit-upstream/trunk/src/dowall.c	2009-07-12 13:30:31 UTC (rev 1445)
@@ -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 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-commits mailing list