[11659] in Athena Bugs

home help back first fref pref prev next nref lref last post

zhm start-up can bring down machine if /etc/zhm.pid is empty

daemon@ATHENA.MIT.EDU (Jonathan I. Kamens)
Tue Jan 25 11:06:37 1994

Date: Tue, 25 Jan 1994 11:07:45 -0500
From: "Jonathan I. Kamens" <jik@security.ov.com>
To: bugs@MIT.EDU

	zhm.c, around line 327 in the zhm sources, reads:

     /* kill old hm if it exists */
     fp = fopen(PidFile, "r");
     if (fp != NULL) {
	  (void)fscanf(fp, "%d\n", &oldpid);
	  while (!kill(oldpid, SIGTERM))
	       sleep(1);
	  syslog(LOG_INFO, "Killed old image.");
	  (void) fclose(fp);
     }

The problem with this is that /etc/zhm.pid is empty, oldpid will be 0,
which means that the signal will be sent to all of the processes in
the process group.  During a reboot, this means that the machine will
be brought into single-user mode instead of finishing its reboot.

Here's a patch:

*** zhm.c	1992/12/17 15:32:49
--- zhm.c	1994/01/18 00:40:31
***************
*** 323,332 ****
       /* kill old hm if it exists */
       fp = fopen(PidFile, "r");
       if (fp != NULL) {
! 	  (void)fscanf(fp, "%d\n", &oldpid);
! 	  while (!kill(oldpid, SIGTERM))
! 	       sleep(1);
! 	  syslog(LOG_INFO, "Killed old image.");
  	  (void) fclose(fp);
       }
  
--- 323,333 ----
       /* kill old hm if it exists */
       fp = fopen(PidFile, "r");
       if (fp != NULL) {
! 	  if (fscanf(fp, "%d\n", &oldpid) > 0) {
! 	       while (!kill(oldpid, SIGTERM))
! 		    sleep(1);
! 	       syslog(LOG_INFO, "Killed old image.");
! 	  }
  	  (void) fclose(fp);
       }
  
Jonathan Kamens | OpenVision Technologies, Inc. | jik@security.ov.com

home help back first fref pref prev next nref lref last post