httpd-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Alexei Kosut <ako...@leland.Stanford.EDU>
Subject Re: [PATCH] NT CGI - Fetch interpreter from registry and oth
Date Mon, 15 Jun 1998 04:56:34 GMT
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

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 <> <>
   Stanford University, Class of 2001 * Apache <> *

View raw message