🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.bugs.4bsd
Article #354

Serious bug in 43bsd Reno make

#354
From: Mike McGann
Date: Fri, 12 Apr 1991 07:35
93 lines
3019 bytes
Subject: Make unlinks directories if run as su
Index: folder 4.3BSD-reno

Description:
	When make is interrupted it removes the current target. If you are running 
        as root and the target is a directory, it will unlink the directory.	
Repeat-By:
Create a make file with a directory as a target, as below. It runs a nmake in subdir
etc. Run as root. Then interrupt it. It will say ****** etc removed and mean it.
	
SUBDIR= etc src


all:	${SUBDIR}

${SUBDIR}: FRC
	cd $@; make all

	to occur.
Fix:
Make sure its a regular file before it's unlinked.	
*** job.c.dist	Fri Apr 12 09:13:44 1991
--- job.c	Fri Apr 12 09:23:06 1991
***************
*** 85,90 ****
--- 85,91 ----
  #include "make.h"
  #include <sys/signal.h>
  #include <sys/stat.h>
+ #include <sys/types.h>
  #include <sys/file.h>
  #include <sys/time.h>
  #include <sys/wait.h>
***************
*** 2441,2446 ****
--- 2442,2448 ----
      LstNode 	  ln;		/* element in job table */
      Job           *job;	    	/* job descriptor in that element */
      GNode         *interrupt;	/* the node describing the .INTERRUPT target */
+     struct stat   fileStatus;
      
      aborting = ABORT_INTERRUPT;
  
***************
*** 2452,2457 ****
--- 2454,2461 ----
  	    char  	*file = (job->node->path == (char *)NULL ?
  				 job->node->name :
  				 job->node->path);
+             stat(file,&fileStatus);
+             if((fileStatus.st_mode & S_IFMT) == S_IFREG)
  	    if (unlink (file) == 0) {
  		Error ("*** %s removed", file);
  	    }
*** compat.c.dist	Fri Apr 12 09:13:57 1991
--- compat.c	Fri Apr 12 09:23:45 1991
***************
*** 41,46 ****
--- 41,47 ----
  
  #include    <stdio.h>
  #include    <sys/types.h>
+ #include    <sys/stat.h>
  #include    <sys/signal.h>
  #include    <sys/wait.h>
  #include    <sys/errno.h>
***************
*** 81,90 ****
      int	    signo;
  {
      GNode   *gn;
      
      if ((curTarg != NILGNODE) && !Targ_Precious (curTarg)) {
  	char 	  *file = Var_Value (TARGET, curTarg);
! 
  	if (unlink (file) == SUCCESS) {
  	    printf ("*** %s removed\n", file);
  	}
--- 82,94 ----
      int	    signo;
  {
      GNode   *gn;
+     struct stat fileStatus;
      
      if ((curTarg != NILGNODE) && !Targ_Precious (curTarg)) {
  	char 	  *file = Var_Value (TARGET, curTarg);
!         
!         stat(file, &fileStatus);
!         if((fileStatus.st_mode & S_IFMT) == S_IFREG)
  	if (unlink (file) == SUCCESS) {
  	    printf ("*** %s removed\n", file);
  	}
Technical Details
Message-ID: <1930@hslrswi.hasler.ascom.ch>
Path: arc1-ca.pugleaf.net!utzoo!utgpu!news-server.csri.toronto.edu!rpi!usc!cs.utexas.edu!sun-barr!olivea!mintaka!bloom-beacon!eru!hagbard!sunic!mcsun!cernvax!chx400!chx400!hslrswi!mwm

Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!utzoo!utgpu!news-server.csri.toronto.edu!rpi!usc!cs.utexas.edu!sun-barr!olivea!mintaka!bloom-beacon!eru!hagbard!sunic!mcsun!cernvax!chx400!chx400!hslrswi!mwm
From: mwm@hslrswi.hasler.ascom.ch (Mike McGann)
Newsgroups: comp.bugs.4bsd
Subject: Serious bug in 43bsd Reno make
Keywords: bug,reno,make
Message-ID: <1930@hslrswi.hasler.ascom.ch>
Date: 12 Apr 91 07:35:44 GMT
Organization: Ascom Hasler AG, CH-3000 Berne 14, Switzerland
Lines: 93