You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@httpd.apache.org by Philip Gladstone <pg...@cisco.com> on 2004/06/21 19:17:58 UTC
Environment handling in mod_rewrite on a Windows platform
Hi,
I discovered that (on Windows) mod_rewrite.c invokes CreateProcess when
creating an external program to handle rewriting requests. It calls
CreateProcess and passes 'environ' to be the environment of the called
process.
Unfortunately, environ is a 'char **' and the argument to CreateProcess
is a sequence of strings of the form 'name=value\0'. This results in the
invoked process getting a garbage environment which can cause problems.
The fix is simple -- replace environ by 0. This signals that the calling
process environment is to be copied and then used by the new process.
This problem is definitely present in 1.3.31. I did not check 2.0.x.
Philip
--
Philip Gladstone 978-ZEN-TOAD (978-936-8623)
Cisco Systems, Inc Boxboro, MA
Re: Environment handling in mod_rewrite on a Windows platform
Posted by "William A. Rowe, Jr." <wr...@rowe-clan.net>.
At 12:17 PM 6/21/2004, Philip Gladstone wrote:
>The fix is simple -- replace environ by 0. This signals that the calling process environment is to be copied and then used by the new process.
If this isn't a constructed environment that solution would work fine.
>This problem is definitely present in 1.3.31. I did not check 2.0.x.
Doesn't apply to 2.0 - we correctly assemble an environment argument
within apr when requested. The interface to apr is consistent between
win32 and unix, and the details are (correctly) handled under-the-hood in apr.
Bill
Re: Environment handling in mod_rewrite on a Windows platform
Posted by "William A. Rowe, Jr." <wr...@rowe-clan.net>.
At 07:59 AM 10/26/2004, Philip wrote:
>Bill,
>
>Did these changes make it into 1.3.32 -- I noticed a lot of changes in the log for mod_rewrite, but not these ones.....
c.f. http://cvs.apache.org/viewcvs.cgi/apache-1.3/src/modules/standard/mod_rewrite.c
rev 1.194. Thanks again for your patch,
Bill
Re: Environment handling in mod_rewrite on a Windows platform
Posted by Philip Gladstone <pg...@cisco.com>.
Bill,
Did these changes make it into 1.3.32 -- I noticed a lot of changes in
the log for mod_rewrite, but not these ones.....
Philip
William A. Rowe, Jr. wrote:
>At 12:17 PM 6/21/2004, Philip Gladstone wrote:
>
>
>>Hi,
>>
>>I discovered that (on Windows) mod_rewrite.c invokes CreateProcess when creating an external program to handle rewriting requests. It calls CreateProcess and passes 'environ' to be the environment of the called process.
>>
>>Unfortunately, environ is a 'char **' and the argument to CreateProcess is a sequence of strings of the form 'name=value\0'. This results in the invoked process getting a garbage environment which can cause problems.
>>
>>The fix is simple -- replace environ by 0. This signals that the calling process environment is to be copied and then used by the new process.
>>
>>
>
>Fix committed for 1.3.32-dev, and is not an issue for 2.0. While you are
>on the subject;
>
>If you had energy to attack it, this module still needs some mutexing
>to allow concurrent threads, to avoid corrupting the rewrite cache. Again,
>not an issue in Apache 2.0, but if you were throwing cycles into cleaning
>up this module I'd be happy to review such a patch. See the ap_xxx_mutex
>api's and check #ifdef MULTITHREAD to portably determine if/how we
>create this protection around the rewrite cache.
>
>Thanks,
>
>Bill
>
>
>
>
>
--
Philip Gladstone 978-ZEN-TOAD (978-936-8623)
Cisco Systems, Inc Boxboro, MA
Re: Environment handling in mod_rewrite on a Windows platform
Posted by "William A. Rowe, Jr." <wr...@rowe-clan.net>.
At 12:17 PM 6/21/2004, Philip Gladstone wrote:
>Hi,
>
>I discovered that (on Windows) mod_rewrite.c invokes CreateProcess when creating an external program to handle rewriting requests. It calls CreateProcess and passes 'environ' to be the environment of the called process.
>
>Unfortunately, environ is a 'char **' and the argument to CreateProcess is a sequence of strings of the form 'name=value\0'. This results in the invoked process getting a garbage environment which can cause problems.
>
>The fix is simple -- replace environ by 0. This signals that the calling process environment is to be copied and then used by the new process.
Fix committed for 1.3.32-dev, and is not an issue for 2.0. While you are
on the subject;
If you had energy to attack it, this module still needs some mutexing
to allow concurrent threads, to avoid corrupting the rewrite cache. Again,
not an issue in Apache 2.0, but if you were throwing cycles into cleaning
up this module I'd be happy to review such a patch. See the ap_xxx_mutex
api's and check #ifdef MULTITHREAD to portably determine if/how we
create this protection around the rewrite cache.
Thanks,
Bill