On Sun, Mar 16, 2014 at 04:01:04PM +0000, Florian Obser wrote:
> On Fri, Mar 07, 2014 at 10:35:37PM -0500, James Turner wrote:
> > On Fri, Mar 07, 2014 at 11:20:53PM +0000, Stuart Henderson wrote:
> > > I've been umming and ahhing about this diff, the thing I don't like is
> > > that SCRIPT_FILENAME is an Apache extension rather than part of the
> > > standard CGI variables, which explains why it's not included by
> > > default in nginx (or other servers that people might conceivably
> > > want to use with slowcgi, such as lighttpd).
> > > 
> > > Still, I don't see a better way to handle this, and replacing Apache
> > > is going to need to support cgis outside of /cgi-bin one way or another.
> > > But I do think it should fallback to using SCRIPT_NAME if the
> > > SCRIPT_FILENAME variable isn't present, so that standard fastcgi
> > > servers can use it to some extent too.
> > > 
> > 
> > Maybe something like this? Using SCRIPT_FILENAME if present but falling
> > back on SCRIPT_NAME.
> > 
> > -- 
> > James Turner
> 
> How about this? I don't see a reason to track SCRIPT_NAME vs.
> SCRIPT_FILENAME through the whole daemon. c->script_name is just the
> thing that get's execve'ed, it doesn't care where it's comming from.
> 
> diff --git slowcgi.c slowcgi.c
> index af07bd8..1b467f5 100644
> --- slowcgi.c
> +++ slowcgi.c
> @@ -741,7 +741,11 @@ parse_params(uint8_t *buf, uint16_t n, struct request 
> *c, uint16_t id)
>  
>               env_entry->val[name_len] = '\0';
>               if (val_len < MAXPATHLEN && strcmp(env_entry->val,
> -                 "SCRIPT_NAME") == 0) {
> +                 "SCRIPT_NAME") == 0 && c->script_name[0] == '\0') {
> +                     bcopy(buf, c->script_name, val_len);
> +                     c->script_name[val_len] = '\0';
> +             } else if (val_len < MAXPATHLEN && strcmp(env_entry->val,
> +                 "SCRIPT_FILENAME") == 0) {
>                       bcopy(buf, c->script_name, val_len);
>                       c->script_name[val_len] = '\0';
>               }
> 
> -- 
> I'm not entirely sure you are real.
> 

I like it. SCRIPT_FILENAME is used when set otherwise it falls back on
SCRIPT_NAME. Works with my test case were I have a cgi script in htdocs
and need to set SCRIPT_FILENAME with something like:

fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;

and when I use /cgi-bin/ and don't set SCRIPT_FILENAME (current nginx
cgi-bin example).

ok jturner@

-- 
James Turner

Reply via email to