Author: markt Date: Sat Apr 5 11:04:27 2008 New Revision: 645152 URL: http://svn.apache.org/viewvc?rev=645152&view=rev Log: Fix shell env for vista and remove hack for pre 1.5 JVMs.
Modified: tomcat/tc6.0.x/trunk/java/org/apache/catalina/servlets/CGIServlet.java tomcat/tc6.0.x/trunk/webapps/docs/changelog.xml Modified: tomcat/tc6.0.x/trunk/java/org/apache/catalina/servlets/CGIServlet.java URL: http://svn.apache.org/viewvc/tomcat/tc6.0.x/trunk/java/org/apache/catalina/servlets/CGIServlet.java?rev=645152&r1=645151&r2=645152&view=diff ============================================================================== --- tomcat/tc6.0.x/trunk/java/org/apache/catalina/servlets/CGIServlet.java (original) +++ tomcat/tc6.0.x/trunk/java/org/apache/catalina/servlets/CGIServlet.java Sat Apr 5 11:04:27 2008 @@ -304,13 +304,7 @@ Boolean.valueOf(getServletConfig().getInitParameter("passShellEnvironment")).booleanValue(); if (passShellEnvironment) { - try { - shellEnv.putAll(getShellEnvironment()); - } catch (IOException ioe) { - ServletException e = new ServletException( - "Unable to read shell environment variables", ioe); - throw e; - } + shellEnv.putAll(System.getenv()); } if (getServletConfig().getInitParameter("executable") != null) { @@ -636,55 +630,6 @@ public static void main(String[] args) { System.out.println("$Header$"); } - - /** - * Get all shell environment variables. Have to do it this rather ugly way - * as the API to obtain is not available in 1.4 and earlier APIs. - * - * See <a href="http://www.rgagnon.com/javadetails/java-0150.html">Read environment - * variables from an application</a> for original source and article. - */ - private Hashtable<String,String> getShellEnvironment() throws IOException { - Hashtable<String,String> envVars = new Hashtable<String,String>(); - Process p = null; - Runtime r = Runtime.getRuntime(); - String OS = System.getProperty("os.name").toLowerCase(); - boolean ignoreCase; - - if (OS.indexOf("windows 9") > -1) { - p = r.exec( "command.com /c set" ); - ignoreCase = true; - } else if ( (OS.indexOf("nt") > -1) - || (OS.indexOf("windows 20") > -1) - || (OS.indexOf("windows xp") > -1) ) { - // thanks to JuanFran for the xp fix! - p = r.exec( "cmd.exe /c set" ); - ignoreCase = true; - } else { - // our last hope, we assume Unix (thanks to H. Ware for the fix) - p = r.exec( "env" ); - ignoreCase = false; - } - - BufferedReader br = new BufferedReader - ( new InputStreamReader( p.getInputStream() ) ); - String line; - while( (line = br.readLine()) != null ) { - int idx = line.indexOf( '=' ); - String key = line.substring( 0, idx ); - String value = line.substring( idx+1 ); - if (ignoreCase) { - key = key.toUpperCase(); - } - envVars.put(key, value); - } - return envVars; - } - - - - - /** Modified: tomcat/tc6.0.x/trunk/webapps/docs/changelog.xml URL: http://svn.apache.org/viewvc/tomcat/tc6.0.x/trunk/webapps/docs/changelog.xml?rev=645152&r1=645151&r2=645152&view=diff ============================================================================== --- tomcat/tc6.0.x/trunk/webapps/docs/changelog.xml (original) +++ tomcat/tc6.0.x/trunk/webapps/docs/changelog.xml Sat Apr 5 11:04:27 2008 @@ -60,6 +60,10 @@ <bug>44562</bug>: HEAD requests cannot use includes. Patch provided by David Jencks. (markt) </fix> + <fix> + Fix CGI Servlet so it correctly reads the environment variables on + Vista. (markt) + </fix> </changelog> </subsection> <subsection name="Coyote"> --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]