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.