You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@httpd.apache.org by W G Stoddard <wg...@us.ibm.com> on 1998/06/14 00:20:51 UTC

Re: [PATCH] NT CGI - Fetch interpreter from registry and oth

I did take some liberties in getting rid of tabs. Other than that, most
everything else (or the gratuitous ilk :-) was directed at making the code more
readable!

If the registery query fails to find the interpreter, the code still does the
shebang peek as a last resort. I was really tempted to eliminate the peek code
altogether (thinking like a windows weenie) then (thinking like a unix hack)
decided not.  Not too crazy about that 2048 buffer on the stack...

Regards,
Bill Stoddard
wgstodda@us.ibm.com


new-httpd-owner@apache.org on 06/13/98 01:56:55 PM
Please respond to new-httpd@apache.org
To: new-httpd@apache.org
cc:
Subject: Re: [PATCH] NT CGI - Fetch interpreter from registry and oth


W G Stoddard wrote:
>
> This patch uses a CGI script's file extension to search the registry for the
> interpreter, rather than shebang peeking the file. This should allow unix
> scripts to be run on NT without modifing the #! line in the script. Cleaned up
> the Win32 section of ap_call_exec a bit as well. Included this patch both
> inline and as a mime attachment.  Let me know if you experience problems with
> the inline patch. My mail program has been know to mangle text on occasion.
> Probably a config thing I've not quite mastered yet....

90% of the patch seems to be gratuitous reformatting, which makes it
rather hard to see what it really does.

Also, I think that #! should be optionally obeyed. I don't know if you
cater for that already, though.

Cheers,

Ben.

--
Ben Laurie            |Phone: +44 (181) 735 0686| Apache Group member
Freelance Consultant  |Fax:   +44 (181) 735 0689|http://www.apache.org/
and Technical Director|Email: ben@algroup.co.uk |
A.L. Digital Ltd,     |Apache-SSL author     http://www.apache-ssl.org/
London, England.      |"Apache: TDG" http://www.ora.com/catalog/apache/

WE'RE RECRUITING! http://www.aldigital.co.uk/recruit/




Re: [PATCH] NT CGI - Fetch interpreter from registry and oth

Posted by Marc Slemko <ma...@worldgate.com>.
On Sun, 14 Jun 1998, Alexei Kosut wrote:

> On Sun, 14 Jun 1998, Ben Laurie wrote:
> 
> > I think we should be able to configure the order. The example of
> > multiple Perl versions is a good one. Also, people may not want to have
> > to mess with the registry to get appropriate interpreters to run.
> 
> Personally, I can't think of a reason you would ever want the registry to
> override a shebang line. I mean, most Windows users used to other web
> servers won't use them. And files don't just have "#!" prepended to them
> accidentally (well, maybe if you were downloading Perl files designed for 
> Unix off the Net. hmm). And if you *do* have a registry setting for some
> given extension, #! provides the only way to override that, without
> changing the filename (which might be undesirable if you have a URL you
> need to maintain) or the program for all files of that extension.
> 
> The only downside to looking at the registry last is the extra time it
> takes. But is Apache - and Windows' program spawning code - really so fast
> that opening the file and reading two bytes takes all that much extra
> time?

It _should_ be (what it is now is irrelevant) and I do not want to have to
be stuck with a legacy behaviour that sucks. 


Re: [PATCH] NT CGI - Fetch interpreter from registry and oth

Posted by Dean Gaudet <dg...@arctic.org>.
Or consider someone trying to do a demo off a CDROM on a windows box.
This is not uncommon -- marketing folks, and design folks at wired asked
for this a bunch.  Wired uses unix servers, so the CGIs have shebangs.
But with registry overriding shebang it would be trivial to copy a tree to
a CDROM and have it work on a windows laptop for a demo.

Dean

On Mon, 15 Jun 1998, Dean Gaudet wrote:

> 
> 
> On Sun, 14 Jun 1998, Alexei Kosut wrote:
> 
> > Personally, I can't think of a reason you would ever want the registry to
> > override a shebang line. 
> 
> Consider a network filesystem, and a script shared between unix and NT.
> With shebang for the unix side and registry settings for the NT side it
> could work.
> 
> Dean
> 
> 


Re: [PATCH] NT CGI - Fetch interpreter from registry and oth

Posted by Dean Gaudet <dg...@arctic.org>.

On Sun, 14 Jun 1998, Alexei Kosut wrote:

> Personally, I can't think of a reason you would ever want the registry to
> override a shebang line. 

Consider a network filesystem, and a script shared between unix and NT.
With shebang for the unix side and registry settings for the NT side it
could work.

Dean


Re: [PATCH] NT CGI - Fetch interpreter from registry and oth

Posted by Alexei Kosut <ak...@leland.Stanford.EDU>.
On Sun, 14 Jun 1998, Ben Laurie wrote:

> I think we should be able to configure the order. The example of
> multiple Perl versions is a good one. Also, people may not want to have
> to mess with the registry to get appropriate interpreters to run.

Personally, I can't think of a reason you would ever want the registry to
override a shebang line. I mean, most Windows users used to other web
servers won't use them. And files don't just have "#!" prepended to them
accidentally (well, maybe if you were downloading Perl files designed for 
Unix off the Net. hmm). And if you *do* have a registry setting for some
given extension, #! provides the only way to override that, without
changing the filename (which might be undesirable if you have a URL you
need to maintain) or the program for all files of that extension.

The only downside to looking at the registry last is the extra time it
takes. But is Apache - and Windows' program spawning code - really so fast
that opening the file and reading two bytes takes all that much extra
time?

My vote would go to checking for #! first, then the registry, with an
option to turn off the magic number checking code only (IMHO, changing the
precedence isn't necessary, and can just confuse things).

> > I was really tempted to eliminate the peek code
> > altogether (thinking like a windows weenie) then (thinking like a unix hack)
> > decided not.  Not too crazy about that 2048 buffer on the stack...

Well... you could make it a 2 byte buffer (a bunch of code has been left
out here):

int is_script;
char shebang[2];

...

fgets(shebang, sizeof(shebang, program));
if (!strncmp(shebang, "#!", 2)) {
    char interpreter[2048];

    fgets(interpreter, sizeof(interpreter), program);
    execl(interpreter, interpreter, r->filename, NULL);
} else {
    /* do other stuff */
}

But that just seems silly...

-- Alexei Kosut <ak...@stanford.edu> <http://www.stanford.edu/~akosut/>
   Stanford University, Class of 2001 * Apache <http://www.apache.org> *





Re: [PATCH] NT CGI - Fetch interpreter from registry and oth

Posted by Ben Laurie <be...@algroup.co.uk>.
W G Stoddard wrote:
> 
> I did take some liberties in getting rid of tabs. Other than that, most
> everything else (or the gratuitous ilk :-) was directed at making the code more
> readable!

Readability patches should not be combined with functionality patches,
because they hamper code review. By all means submit separate
readability patches, but do remember that they should conmform to the
style guide.

> If the registery query fails to find the interpreter, the code still does the
> shebang peek as a last resort.

I think we should be able to configure the order. The example of
multiple Perl versions is a good one. Also, people may not want to have
to mess with the registry to get appropriate interpreters to run.

> I was really tempted to eliminate the peek code
> altogether (thinking like a windows weenie) then (thinking like a unix hack)
> decided not.  Not too crazy about that 2048 buffer on the stack...

Any particular reason?

Cheers,

Ben.

-- 
Ben Laurie            |Phone: +44 (181) 735 0686| Apache Group member
Freelance Consultant  |Fax:   +44 (181) 735 0689|http://www.apache.org/
and Technical Director|Email: ben@algroup.co.uk |
A.L. Digital Ltd,     |Apache-SSL author     http://www.apache-ssl.org/
London, England.      |"Apache: TDG" http://www.ora.com/catalog/apache/

WE'RE RECRUITING! http://www.aldigital.co.uk/recruit/

Re: [PATCH] NT CGI - Fetch interpreter from registry and oth

Posted by Sameer Parekh <sa...@c2.net>.
	Code-style/readability patches should be seperated from functionality
patches. Then its easier to know what you're doing on a per-commit basis.

At 03:20 PM 6/13/98 , W G Stoddard wrote:
>I did take some liberties in getting rid of tabs. Other than that, most
>everything else (or the gratuitous ilk :-) was directed at making the code
more
>readable!
>
>If the registery query fails to find the interpreter, the code still does the
>shebang peek as a last resort. I was really tempted to eliminate the peek
code
>altogether (thinking like a windows weenie) then (thinking like a unix hack)
>decided not.  Not too crazy about that 2048 buffer on the stack...
>
>Regards,
>Bill Stoddard
>wgstodda@us.ibm.com
>
>
>new-httpd-owner@apache.org on 06/13/98 01:56:55 PM
>Please respond to new-httpd@apache.org
>To: new-httpd@apache.org
>cc:
>Subject: Re: [PATCH] NT CGI - Fetch interpreter from registry and oth
>
>
>W G Stoddard wrote:
>>
>> This patch uses a CGI script's file extension to search the registry for
the
>> interpreter, rather than shebang peeking the file. This should allow unix
>> scripts to be run on NT without modifing the #! line in the script.
Cleaned up
>> the Win32 section of ap_call_exec a bit as well. Included this patch both
>> inline and as a mime attachment.  Let me know if you experience problems
with
>> the inline patch. My mail program has been know to mangle text on occasion.
>> Probably a config thing I've not quite mastered yet....
>
>90% of the patch seems to be gratuitous reformatting, which makes it
>rather hard to see what it really does.
>
>Also, I think that #! should be optionally obeyed. I don't know if you
>cater for that already, though.
>
>Cheers,
>
>Ben.
>
>--
>Ben Laurie            |Phone: +44 (181) 735 0686| Apache Group member
>Freelance Consultant  |Fax:   +44 (181) 735 0689|http://www.apache.org/
>and Technical Director|Email: ben@algroup.co.uk |
>A.L. Digital Ltd,     |Apache-SSL author     http://www.apache-ssl.org/
>London, England.      |"Apache: TDG" http://www.ora.com/catalog/apache/
>
>WE'RE RECRUITING! http://www.aldigital.co.uk/recruit/
> 
--
Sameer Parekh                                   Voice:   510-986-8770
CEO                                             FAX:     510-986-8777
C2Net                                           http://www.c2.net/