From nobody@FreeBSD.org  Mon Nov 19 07:49:11 2001
Return-Path: <nobody@FreeBSD.org>
Received: from freefall.freebsd.org (freefall.FreeBSD.org [216.136.204.21])
	by hub.freebsd.org (Postfix) with ESMTP id E437037B416
	for <freebsd-gnats-submit@FreeBSD.org>; Mon, 19 Nov 2001 07:49:10 -0800 (PST)
Received: (from nobody@localhost)
	by freefall.freebsd.org (8.11.4/8.11.4) id fAJFnAl10476;
	Mon, 19 Nov 2001 07:49:10 -0800 (PST)
	(envelope-from nobody)
Message-Id: <200111191549.fAJFnAl10476@freefall.freebsd.org>
Date: Mon, 19 Nov 2001 07:49:10 -0800 (PST)
From: Magnus Backstrom <b@etek.chalmers.se>
To: freebsd-gnats-submit@FreeBSD.org
Subject: Scripts with #!/interpreter paths longer than 64 bytes don't work.
X-Send-Pr-Version: www-1.0

>Number:         32106
>Category:       kern
>Synopsis:       Scripts with #!/interpreter paths longer than 64 bytes don't work.
>Confidential:   no
>Severity:       non-critical
>Priority:       medium
>Responsible:    jwd
>State:          closed
>Quarter:        
>Keywords:       
>Date-Required:  
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Mon Nov 19 07:50:01 PST 2001
>Closed-Date:    Wed Nov 28 18:31:16 PST 2001
>Last-Modified:  Wed Nov 28 18:33:38 PST 2001
>Originator:     Magnus Backstrom
>Release:        4.4-STABLE and 5.0-CURRENT
>Organization:
Chalmers UofT
>Environment:
FreeBSD j0.etek.chalmers.se 4.4-STABLE FreeBSD 4.4-STABLE #0: Thu Nov  1 09:35:50 CET 2001     b@j0.etek.chalmers.se:/usr/src/sys/compile/J0  i386
>Description:
If an interpreter pathname is longer than about 64 characters, i.e.
#!/you/have/a/slightly/longer/than/usual/path/to/your/interpreter,
/bin/sh gets used instead and your script may break.

>How-To-Repeat:
x> mkdir -p /tmp/this/is/a/slightly/too/long/path/to/the/interpreter
x> ln -s /usr/bin/awk \
    /tmp/this/is/a/slightly/too/long/path/to/the/interpreter
x> cat > /tmp/test.awk
#!/tmp/this/is/a/slightly/too/long/path/to/the/interpreter/awk -f
{ 1 }
x> chmod +x /tmp/test.awk 
x> /tmp/test.awk 
{: Command not found.
x> 

>Fix:
Change line 39 of /usr/src/sys/sys/imgact.h from
#define MAXSHELLCMDLEN  64
to something more sensible, e g
#define MAXSHELLCMDLEN  512
This doesn't seem to break anything.

>Release-Note:
>Audit-Trail:
Responsible-Changed-From-To: freebsd-bugs->jwd 
Responsible-Changed-By: jwd 
Responsible-Changed-When: Sun Nov 25 18:42:09 PST 2001 
Responsible-Changed-Why:  
I've looked into the problem and will followup. 

http://www.FreeBSD.org/cgi/query-pr.cgi?pr=32106 
State-Changed-From-To: open->feedback 
State-Changed-By: jwd 
State-Changed-When: Tue Nov 27 19:27:13 PST 2001 
State-Changed-Why:  
Fix committed for secondary /bin/sh execution.  
Increased MAXSHELLCMDLEN to 128. Waiting on feedback 
from submitter. 

http://www.FreeBSD.org/cgi/query-pr.cgi?pr=32106 
State-Changed-From-To: feedback->closed 
State-Changed-By: jwd 
State-Changed-When: Wed Nov 28 18:31:16 PST 2001 
State-Changed-Why:  
Received positive feedback from Magnus. 

http://www.FreeBSD.org/cgi/query-pr.cgi?pr=32106 
>Unformatted:
