httpd-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Pierre Barbier <Pierre.Barb...@digitalinsight.com>
Subject RE: [users@httpd] Unexpected argv[0] passed to CGI programs
Date Fri, 06 Sep 2002 00:51:43 GMT
Ryan,
I found out that the code change that triggered this occurred between 2.0.39
and 2.0.40 and is probably the one that you are referring to (I saw the
entry in the CHANGES log).
The change (in the default_build_command function in mod_cgi.c) sets *cmd to
the full path, but this also affects (*argv)[0] at line 543 ((*argv)[0] =
*cmd), maybe unintentionally.
My patch resets (*argv)[0] to what it used to be.
--
Pierre

> -----Original Message-----
> From: Pierre Barbier 
> Sent: Thursday, September 05, 2002 4:11 PM
> To: 'users@httpd.apache.org'
> Subject: RE: [users@httpd] Unexpected argv[0] passed to CGI programs
> 
> 
> Ryan, thanks for your reply.
> To avoid any confusion: I'm not talking about the path used 
> to invoke the
> CGI program (first argument to exec) but the first item in 
> the argument
> list.
> I verified with 1.3.26 that argv[0] is indeed the filename, 
> not the full
> path (the code doing this is lines 390-393 of
> 'src/modules/standard/mod_cgi.c' in the 1.3.26 source tree -- 
> I didn't find
> any equivalent in the 2.0.40 code).
> I wanted to get some feedback as to whether this would be a 
> desirable change
> before submitting the patch formally.
> --
> Pierre
> 
> > -----Original Message-----
> > From: rbb@apache.org [mailto:rbb@apache.org]
> > Sent: Thursday, September 05, 2002 3:52 PM
> > To: 'users@httpd.apache.org'
> > Subject: Re: [users@httpd] Unexpected argv[0] passed to CGI programs
> > 
> > 
> > 
> > I seem to think that I fixed this a long time ago.  Okay, I 
> > found it in
> > CVS.  Apache 1.3 used absolute paths for everything except for
> > SuExec.  Until 2.0.40, Apache 2.0 used relative paths for
> > everything.  Are you sure that 1.3 used to use relative paths?  I
> > double-checked the code, and I had a user telling me that 2.0 wasn't
> > working like 1.3 (which I verified).  Which version of 1.3?
> > 
> > Also, patches that are sent to this list will generally not 
> > be applied,
> > because most developers aren't watching this list closely.  
> > Patches should
> > be sent to dev@httpd.apache.org.
> > 
> > Ryan
> > 
> > On Thu, 5 Sep 2002, Pierre Barbier wrote:
> > 
> > > Testing our CGI programs under Apache 2.0.40, we noticed 
> > that the value
> > > received by a CGI program as argv[0] is the full path to 
> > the executable, not
> > > just the file name as it used to be in 1.3.
> > > Is this a bug (at least an omission, since the CGI spec 
> > doens't seem to
> > > cover this), or a feature?
> > > Is there a configuration option to modify that behavior 
> > (after looking at
> > > the source code, I don't think so)?
> > > 
> > > If it's a bug, here is a patch that seems to fix it:
> > > 
> > > diff -ruN httpd-2.0.40/modules/generators/mod_cgi.c
> > > httpd-2.0.40p/modules/generators/mod_cgi.c
> > > --- httpd-2.0.40/modules/generators/mod_cgi.c   Tue Jul 30 
> > 11:18:03 2002
> > > +++ httpd-2.0.40p/modules/generators/mod_cgi.c  Thu Sep  5 
> > 10:01:19 2002
> > > @@ -540,7 +540,7 @@
> > >          numwords = APACHE_ARG_MAX - 1;    /* Truncate args 
> > to prevent
> > > overrun */
> > >      }
> > >      *argv = apr_palloc(p, (numwords + 2) * sizeof(char *));
> > > -    (*argv)[0] = *cmd;
> > > +    (*argv)[0] = apr_filename_of_pathname(*cmd);
> > >      for (x = 1, idx = 1; x < numwords; x++) {
> > >          w = ap_getword_nulls(p, &args, '+');
> > >          ap_unescape_url(w);
> > > 
> > > Any feedback would be welcome!
> > > 
> > > 
> > 
> ---------------------------------------------------------------------
> > > The official User-To-User support forum of the Apache HTTP 
> > Server Project.
> > > See <URL:http://httpd.apache.org/userslist.html> for more info.
> > > To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
> > >    "   from the digest: users-digest-unsubscribe@httpd.apache.org
> > > For additional commands, e-mail: users-help@httpd.apache.org
> > > 
> > 
> > -- 
> > 
> > ______________________________________________________________
> > _________________
> > Ryan Bloom                        	rbb@apache.org
> > 550 Jean St
> > Oakland CA 94610
> > --------------------------------------------------------------
> > -----------------
> > 
> > 
> > 
> ---------------------------------------------------------------------
> > The official User-To-User support forum of the Apache HTTP 
> > Server Project.
> > See <URL:http://httpd.apache.org/userslist.html> for more info.
> > To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
> >    "   from the digest: users-digest-unsubscribe@httpd.apache.org
> > For additional commands, e-mail: users-help@httpd.apache.org
> > 
> 
> ---------------------------------------------------------------------
> The official User-To-User support forum of the Apache HTTP 
> Server Project.
> See <URL:http://httpd.apache.org/userslist.html> for more info.
> To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
>    "   from the digest: users-digest-unsubscribe@httpd.apache.org
> For additional commands, e-mail: users-help@httpd.apache.org
> 

---------------------------------------------------------------------
The official User-To-User support forum of the Apache HTTP Server Project.
See <URL:http://httpd.apache.org/userslist.html> for more info.
To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
   "   from the digest: users-digest-unsubscribe@httpd.apache.org
For additional commands, e-mail: users-help@httpd.apache.org


Mime
View raw message