You are viewing a plain text version of this content. The canonical link for it is here.
Posted to bugs@httpd.apache.org by bu...@apache.org on 2009/02/21 22:01:22 UTC

DO NOT REPLY [Bug 46751] New: Can passenv variables who's name contain '(' or ')'

https://issues.apache.org/bugzilla/show_bug.cgi?id=46751

           Summary: Can passenv variables who's name contain '(' or ')'
           Product: Apache httpd-2
           Version: 2.3-HEAD
          Platform: PC
        OS/Version: Windows Server 2008 (Longhorn)
            Status: NEW
          Severity: normal
          Priority: P2
         Component: mod_env
        AssignedTo: bugs@httpd.apache.org
        ReportedBy: bsobel@symantec.com


In Windows Vista and Windows 2008, many registry entries are now
reg_expand_sz's which use environment variables substitution to resolve their
actual path.  And example of this is the ADODB componets.  This means that cgi
applications need to have the 'CommonProgramFiles' environment variable passed
if they attempt to instantiate these components via COM.  This is common with
PHP.

However,on 64bit platforms one must also pass the 'CommonProgramFiles(x86)'
environment variable if launching 32bit cgi programs. Apache's only allows
alphanumerics in the name of environment variables passed and converts
CommonProgramFiles(x86) to CommonProgramFiles_x86_  This means that the 32bit
client does not have the correct environment setup and com can not expand the
registry paths when attempting to instantiate components.

( and ) should be allowed in environment variable names.

-- 
Configure bugmail: https://issues.apache.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug.

---------------------------------------------------------------------
To unsubscribe, e-mail: bugs-unsubscribe@httpd.apache.org
For additional commands, e-mail: bugs-help@httpd.apache.org


[Bug 46751] Can passenv variables who's name contain '(' or ')'

Posted by bu...@apache.org.
https://issues.apache.org/bugzilla/show_bug.cgi?id=46751

John <jo...@leineweb.de> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEEDINFO                    |NEW

--- Comment #4 from John <jo...@leineweb.de> ---
If you have a combination of windows x64, apache and a win32 cgi (exe) using
ADODB you have the problem that the enviroment variable
CommonProgramFiles(x86)is translated into CommonProgramFiles_x86_

Adodb needs that env-variable to find the software, so it ends there.


The problem lies in util_script.c (2.4.9)

AP_DECLARE(char **) ap_create_environment(apr_pool_t *p, apr_table_t *t)
{
...
        while (*whack != '=') {
            if (!apr_isalnum(*whack)) {
                *whack = '_';
            }
            ++whack;
        }
...
}


I propose a Change into : 

        while (*whack != '=') {
            if (!apr_isalnum(*whack) && *whack != '(' && *whack != ')') {
                *whack = '_';
            }
            ++whack;
        }


You also need the following in Httpd.conf:  

SetEnv ProgramFiles "C:\Program Files"
SetEnv "ProgramFiles(x86)" "C:\Program Files (x86)"
SetEnv ProgramFilesW6432 "C:\Program Files"
SetEnv CommonProgramFiles "C:\Program Files\Common Files"
SetEnv "CommonProgramFiles(x86)" "C:\Program Files (x86)\Common Files"
SetEnv CommonProgramFilesW6432 "C:\Program Files\Common Files"

I tested the proposal with httpd 2.2 and httpd 2.4.9. Works fine.

Send me a message if you need the mod_cgi.so file

cheers

John

-- 
You are receiving this mail because:
You are the assignee for the bug.

---------------------------------------------------------------------
To unsubscribe, e-mail: bugs-unsubscribe@httpd.apache.org
For additional commands, e-mail: bugs-help@httpd.apache.org


[Bug 46751] Can passenv variables who's name contain '(' or ')'

Posted by bu...@apache.org.
https://issues.apache.org/bugzilla/show_bug.cgi?id=46751

Polecat <sj...@yahoo.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |sjp4@yahoo.com
            Version|2.5-HEAD                    |2.2.24
                 OS|All                         |Windows 7

--- Comment #3 from Polecat <sj...@yahoo.com> ---
Title:  Can't Set or Pass Environment Variables who's names contain special
characters '(' or ')'. 

When I set the parameters in httpd.conf to pass Windows 7 x64 bit environment
variables to CGI based applications, then as stated before, if they contain any
special characters, then these characters are replaced with underscores "_". 
This can cause CGI applications which are x32 based running on an x64 based OS
to fail, as the underlying components cannot discern the correct x32 path to
the necessary libraries. 

---------------------------------------------------------
Example:  httpd.conf file with a virtual host settings to pass env. variables.

<VirtualHost myserver.homesite.com:80>

PassEnv ProgramFiles
PassEnv ProgramFiles(x86)
PassEnv CommonProgramFiles(x86)
PassEnv CommonProgramFiles
PassEnv CommonProgramFilesW6432

</VirtualHost>


Debug Output of passed Environment variables to the CGI app: 
Note the replacement of (x86) with _86_  in the Variable Names.
----------------------
ProgramFiles=C:\Program Files (x86)
ProgramFiles_x86_=C:\Program Files (x86)
CommonProgramFiles_x86_=C:\Program Files (x86)\Common Files
CommonProgramFiles=C:\Program Files (x86)\Common Files


---------------------------------------------------------
After having our CGI apps. work flawlessly for years with Windows XP on Apache,
the following errors were seen immediately after upgrade to Win 7 x64. 

The following error was encountered at the point the CGI app. initiated a call
for ADO to action (which then called the underlying OS component), which was
not found at the location indicated by the incorrect env. variable.  

Error in the following Subroutine:  LogonToDatabase
Error Number = -2147024770  Automation error
The specified module could not be found. 

After much research, and code testing, I have confirmed and verified the cause
of the problem is Apache's substitution in the Environment Variable names for
the (x86) with _x86_ .

---------------------------------------------------------
Additional info:  
For those affected, there is a work around to this problem to apply Env.
Variables in the CGI app. when it launches, but it's a kludge.  

There is a large potential for affected users in the Windows environment, as
this affects any legacy VB app that uses ADO (Database) components and possible
other COM based features.   

https://forums.embarcadero.com/thread.jspa?threadID=57551

I hope it's a rather simple fix, as it would be a great benefit to address.
Thanks. 


---------------------------------------------------------------------------
NOTE:  SetEnv is also impacted by this bug on Windows x64. 
Httpd.conf:  

SetEnv ProgramFiles "C:\Program Files"
SetEnv "ProgramFiles(x86)" "C:\Program Files (x86)"
SetEnv ProgramFilesW6432 "C:\Program Files"
SetEnv CommonProgramFiles "C:\Program Files\Common Files"
SetEnv "CommonProgramFiles(x86)" "C:\Program Files (x86)\Common Files"
SetEnv CommonProgramFilesW6432 "C:\Program Files\Common Files"


Results in CGI Debug app:

ProgramFiles=C:\Program Files
ProgramFiles_x86_=C:\Program Files (x86)
ProgramFilesW6432=C:\Program Files
CommonProgramFiles=C:\Program Files\Common Files
CommonProgramFiles_x86_=C:\Program Files (x86)\Common Files
CommonProgramFilesW6432=C:\Program Files\Common Files


Keywords:  PassEnv, SetEnv, Environment Variable, Windows 7 x64, CGI
application, VB6, ADODB

-- 
You are receiving this mail because:
You are the assignee for the bug.

---------------------------------------------------------------------
To unsubscribe, e-mail: bugs-unsubscribe@httpd.apache.org
For additional commands, e-mail: bugs-help@httpd.apache.org


DO NOT REPLY [Bug 46751] Can passenv variables who's name contain '(' or ')'

Posted by bu...@apache.org.
https://issues.apache.org/bugzilla/show_bug.cgi?id=46751

Nick Kew <ni...@webthing.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |NEEDINFO

--- Comment #1 from Nick Kew <ni...@webthing.com> 2010-07-05 16:19:57 EDT ---
AFAICT there's nothing in mod_env to preclude your choice of name if the
platform is happy with it.  But I don't have a windows box to test on.

Are you sure it isn't just a matter of needing to escape your brackets?

-- 
Configure bugmail: https://issues.apache.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug.

---------------------------------------------------------------------
To unsubscribe, e-mail: bugs-unsubscribe@httpd.apache.org
For additional commands, e-mail: bugs-help@httpd.apache.org


DO NOT REPLY [Bug 46751] Can passenv variables who's name contain '(' or ')'

Posted by bu...@apache.org.
https://issues.apache.org/bugzilla/show_bug.cgi?id=46751

Chris Stevens <ch...@cisco.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |chsteven@cisco.com

-- 
Configure bugmail: https://issues.apache.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug.

---------------------------------------------------------------------
To unsubscribe, e-mail: bugs-unsubscribe@httpd.apache.org
For additional commands, e-mail: bugs-help@httpd.apache.org


DO NOT REPLY [Bug 46751] Can passenv variables who's name contain '(' or ')'

Posted by bu...@apache.org.
https://issues.apache.org/bugzilla/show_bug.cgi?id=46751

--- Comment #2 from Bill Sobel <bs...@symantec.com> 2012-02-03 16:49:03 UTC ---
When I had traced the code, there was a loop that only allowed alphanumerics
and changed anything else into the _ character causing the issue.  There did
not appear to be any way to escaper the characters to prevent this code from
modifying the string.

-- 
Configure bugmail: https://issues.apache.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug.

---------------------------------------------------------------------
To unsubscribe, e-mail: bugs-unsubscribe@httpd.apache.org
For additional commands, e-mail: bugs-help@httpd.apache.org