*BSD News Article 18575


Return to BSD News archive

Path: sserve!newshost.anu.edu.au!munnari.oz.au!news.Hawaii.Edu!ames!agate!spool.mu.edu!darwin.sura.net!news.dfn.de!urmel.informatik.rwth-aachen.de!acds.physik.rwth-aachen.de!kuku
From: kuku@acds.physik.rwth-aachen.de (Christoph Kukulies)
Newsgroups: comp.os.386bsd.development
Subject: kern_execve.c patch (repost)
Date: 18 Jul 1993 12:00:39 GMT
Organization: I.Physikalisches Institut RWTH-Aachen
Lines: 123
Distribution: world
Message-ID: <22be17$m5c@urmel.informatik.rwth-aachen.de>
Reply-To: kuku@acds.physik.rwth-aachen.de
NNTP-Posting-Host: acds.physik.rwth-aachen.de
Mime-Version: 1.0
Content-Type: text/plain; charset=US-ASCII
Content-Transfer-Encoding: 7bit


Someone pointed me to an error I made in a previously posted patch to kern_execve.c. Sorry for the inconvenience I may have caused. Here goes again.

The patch fixes a problem with things like #!/usr/local/wish -f where the  -f
has to be passed to the argv[]. Note that the rest of the line is not being
split up into more args. It's taken in toto and put into one argv[].

The patch is supposed to be applied to a 386bsd-0.1-0.2.3-0.2.4 patched system.

--

--Chris
Christoph P. U. Kukulies
kuku@acds.physik.rwth-aachen.de
*** Error code 1
 
Stop.
----------------------------------- cut here ----------------------------------
*** kern_execve.c.pl7	Mon Jun 28 12:00:04 1993
--- kern_execve.c	Sun Jul 18 12:04:33 1993
***************
*** 64,69 ****
--- 64,75 ----
   * 20 Apr 93	markie			Stop execution of a file open for write
   *		Rodney W. Grimes	Fix date on Yoval Yarom's patch
   * 01 Jun 93	Chris Demetriou		Completed markie's patch for VTEXT busy
+  * 21 May 93	Christoph P. Kukulies	made things like
+  *                                      #!/usr/local/bin/wish -f work
+  *                                      one may additionally increase
+  *					MAXINTERP to 80 in
+  *					/usr/include/sys/syslimits.
+  *
   */
  
  #include "param.h"
***************
*** 115,120 ****
--- 121,127 ----
  	struct vmspace *vs;
  	caddr_t newframe;
  	char shellname[MAXINTERP];			/* 05 Aug 92*/
+ 	char rest_of_line[MAXINTERP];
  	union {
  		char	ex_shell[MAXINTERP];	/* #! and interpreter name */
  		struct	exec ex_hdr;
***************
*** 215,222 ****
  		while (*cp && *cp != ' ')
  			*sp++ = *cp++;
  		*sp = '\0';
  
- 		indir = 1;              /* indicate this is a script file */
  		vput(ndp->ni_vp);
  		FREE(ndp->ni_pnbuf, M_NAMEI);
  
--- 222,239 ----
  		while (*cp && *cp != ' ')
  			*sp++ = *cp++;
  		*sp = '\0';
+ 		if(*cp) { /* if there is something following the #!/shell */
+                         while ( *cp == ' ' )
+                                 cp++;
+                         sp = rest_of_line;
+                         while ( *cp)
+                                 *sp++ = *cp++;
+                         *sp = '\0';
+                         indir = 2; /* indicate this is a script file with args*/
+                 }
+                 else
+                         indir = 1; /* indicate this is a script file */
  
  		vput(ndp->ni_vp);
  		FREE(ndp->ni_pnbuf, M_NAMEI);
  
***************
*** 289,295 ****
  	/* first, do (shell name if any then) args */
  	if (indir)  {
  		ep = shellname;
! twice:
  		if (ep) {
  			/* did we outgrow initial argbuf, if so, die */
  			if (argbufp >= (char **)stringbuf) {
--- 306,312 ----
  	/* first, do (shell name if any then) args */
  	if (indir)  {
  		ep = shellname;
! threetimes:
  		if (ep) {
  			/* did we outgrow initial argbuf, if so, die */
  			if (argbufp >= (char **)stringbuf) {
***************
*** 309,320 ****
  			limitonargs -= stringlen;
  		}
  
! 		if (indir) {
! 			indir = 0;
! 			/* orginal executable is 1st argument with scripts */
! 			ep = uap->fname;
! 			goto twice;
! 		}
  		/* terminate in case no more args to script */
  		suword(argbufp, 0);
  		if (vectp = uap->argp) vectp++; /* manually doing the first
--- 326,342 ----
  			limitonargs -= stringlen;
  		}
  
!                 if (indir == 2 ) {
!                         indir = 1;
!                         ep = rest_of_line;
!                         goto threetimes;
!                 }
!                 if (indir == 1) {
!                         indir = 0;
!                         /* orginal executable is 1st argument with scripts */
!                         ep = uap->fname;
!                         goto threetimes;
!                 }
  		/* terminate in case no more args to script */
  		suword(argbufp, 0);
  		if (vectp = uap->argp) vectp++; /* manually doing the first