Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 30 Dec 1999 07:32:47 -0800 (PST)
From:      arjan@inventionz.org
To:        freebsd-gnats-submit@freebsd.org
Subject:   misc/15782: kernel script handling breaks with perl
Message-ID:  <19991230153247.6E45414F40@hub.freebsd.org>

next in thread | raw e-mail | index | archive | help

>Number:         15782
>Category:       misc
>Synopsis:       kernel script handling breaks with perl
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    freebsd-bugs
>State:          open
>Quarter:        
>Keywords:       
>Date-Required:
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Thu Dec 30 07:40:01 PST 1999
>Closed-Date:
>Last-Modified:
>Originator:     Arjan van der Oest
>Release:        3.3s
>Organization:
>Environment:
none
>Description:
While moving our webserver from OpenBSD to FreeBSD (hurray !), we've
seen a lot of perl scripts break on the first line 
"#!/usr/bin/perl -*-perl-*-". Apperantly, the FreeBSD kernel does not 
ignore the extra text and tries to invoke this as a script, breaking the
original script. In the OpenBSD kernel is lists this comment in the 
kernel script handling module :
                /*
                 * collect the shell argument.  everything after the 
                 * shell name is passed as ONE argument; that's the 
                 * correct (historical) behaviour.
                 */

Now I don't know that this is a good idea, but Laary Wall decided Perl
would expect one argument, including whitespace for #!perl
scripts. FreeBSD decided to parse the initial line of script files
into arguments. The two are incompatible.






>How-To-Repeat:

>Fix:
I do think if FreeBSD is going to parse the line into separate
arguments, it would be a good idea to actually do the parsing
properly, not simply break strings on whitespace. That's harder to do
and may well not be worth the effort. On the other hand, the following
patch in imgact_shell.c make Perl happy:

--- imgact_shell.c  Wed Dec 29 13:12:47 1999
+++ /sys/kern/imgact_shell.c    Fri Oct 16 05:55:00 1998
@@ -116,30 +107,12 @@
        while ((*ihp == ' ') || (*ihp == '\t')) ihp++;
 
        if (ihp < line_endp) {
-
-/**********************
- jes - web patches
- **********************/
            /*
             * Copy to end of token. No need to watch stringspace
             *  because this is at the front of the string buffer
             *  and the maximum shell command length is tiny.
             */
-/**********************************
- above comment is no longer true
- **********************************/
-
-               /*
-                * collect the shell argument.  everything after the 
-                * shell name is passed as ONE argument; that's the 
-                * correct (historical) behaviour.
-                */
-
-#if 0
            while ((ihp < line_endp) && (*ihp != ' ') && (*ihp != '\t')) {
-#else
-           while (ihp < line_endp) {
-#endif

(the comment is frm OpenBSD)

Patch & original comment by Jim E. Segrave (jes@nl.demon.net)




>Release-Note:
>Audit-Trail:
>Unformatted:


To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe freebsd-bugs" in the body of the message




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?19991230153247.6E45414F40>