tomcat-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From lar...@locus.apache.org
Subject cvs commit: jakarta-tomcat/src/share/org/apache/tomcat/task ApacheConfig.java
Date Mon, 28 Aug 2000 03:08:44 GMT
larryi      00/08/27 20:08:43

  Modified:    src/share/org/apache/tomcat/task Tag: tomcat_32
                        ApacheConfig.java
  Log:
  Apply WEB-INF, META-INF, and ApJServDefaultPort improvements
  to tomcat_32 branch.
  
  Revision  Changes    Path
  No                   revision
  
  
  No                   revision
  
  
  1.12.2.1  +70 -5     jakarta-tomcat/src/share/org/apache/tomcat/task/ApacheConfig.java
  
  Index: ApacheConfig.java
  ===================================================================
  RCS file: /home/cvs/jakarta-tomcat/src/share/org/apache/tomcat/task/ApacheConfig.java,v
  retrieving revision 1.12
  retrieving revision 1.12.2.1
  diff -u -r1.12 -r1.12.2.1
  --- ApacheConfig.java	2000/06/23 02:16:26	1.12
  +++ ApacheConfig.java	2000/08/28 03:08:42	1.12.2.1
  @@ -64,6 +64,9 @@
   import java.net.*;
   import java.util.*;
   
  +// Used to find Ajp12 connector port
  +import org.apache.tomcat.service.PoolTcpConnector;
  +import org.apache.tomcat.service.connector.Ajp12ConnectionHandler;
   
   /**
    * Used by ContextManager to generate automatic apache configurations
  @@ -127,8 +130,20 @@
   	    pw.println("ApJServLogLevel notice");
   	    pw.println();
   
  -	    // XXX read it from ContextManager
  -	    pw.println("ApJServDefaultPort 8007");
  +		// Find Ajp12 connector
  +		int portInt=8007;
  +		Enumeration enum=cm.getConnectors();
  +		while( enum.hasMoreElements() ) {
  +			Object con=enum.nextElement();
  +			if( con instanceof  PoolTcpConnector ) {
  +				PoolTcpConnector tcpCon=(PoolTcpConnector) con;
  +				if( tcpCon.getTcpConnectionHandler()
  +						instanceof Ajp12ConnectionHandler ) {
  +					portInt=tcpCon.getPort();
  +				}
  +			}
  +		}
  +		pw.println("ApJServDefaultPort " + portInt);
   	    pw.println();
   
   	    pw.println("AddType text/jsp .jsp");
  @@ -182,7 +197,7 @@
   
   	    // Set up contexts
   	    // XXX deal with Virtual host configuration !!!!
  -	    Enumeration enum = cm.getContexts();
  +	    enum = cm.getContexts();
   	    while (enum.hasMoreElements()) {
   		Context context = (Context)enum.nextElement();
   		String path  = context.getPath();
  @@ -204,6 +219,8 @@
   		    if (!FileUtil.isAbsolute(docBase))
   			docBase = tomcatHome + "/" + docBase;
   		    docBase = FileUtil.patch(docBase);
  +			if (File.separatorChar == '\\')
  +				docBase = docBase.replace('\\','/');	// use separator preferred by Apache
   
   		    // Static files will be served by Apache
   		    pw.println("Alias " + path + " \"" + docBase + "\"");
  @@ -219,10 +236,30 @@
   		    pw.println("    AllowOverride None");
   		    pw.println("    deny from all");
   		    pw.println("</Location>");
  +			// For Windows, use Directory too. Location doesn't work unless case matches
  +			if (File.separatorChar == '\\') {
  +				pw.println("<Directory \"" + docBase + "/WEB-INF/\">");
  +				pw.println("    AllowOverride None");
  +				pw.println("    deny from all");
  +				pw.println("</Directory>");
  +			}
  +
  +		    // Deny serving any files from META-INF
  +			pw.println("<Location \"" + path + "/META-INF/\">");
  +			pw.println("    AllowOverride None");
  +			pw.println("    deny from all");
  +			pw.println("</Location>");
  +			// For Windows, use Directory too. Location doesn't work unless case matches
  +			if (File.separatorChar  == '\\') {
  +				pw.println("<Directory \"" + docBase + "/META-INF/\">");
  +				pw.println("    AllowOverride None");
  +				pw.println("    deny from all");
  +				pw.println("</Directory>");
  +			}
   		    pw.println();
   
   
  -		    // Static files will be served by Apache
  +			// Static files will be served by Apache
               mod_jk.println("#########################################################");
	    
               mod_jk.println("# Auto configuration for the " + path + " context starts.");
               mod_jk.println("#########################################################");
	    
  @@ -248,12 +285,40 @@
   		    // Deny serving any files from WEB-INF
               mod_jk.println();            
               mod_jk.println("#");		    
  -            mod_jk.println("# The following line prohibits users from directly access WEB-INF");
  +            mod_jk.println("# The following line prohibits users from directly accessing
WEB-INF");
               mod_jk.println("#");                        
   		    mod_jk.println("<Location \"" + path + "/WEB-INF/\">");
   		    mod_jk.println("    AllowOverride None");
   		    mod_jk.println("    deny from all");
   		    mod_jk.println("</Location>");
  +			if (File.separatorChar == '\\') {
  +				mod_jk.println("#");		    
  +				mod_jk.println("# Use Directory too. On Windows, Location doesn't work unless case
matches");
  +				mod_jk.println("#");                        
  +				mod_jk.println("<Directory \"" + docBase + "/WEB-INF/\">");
  +				mod_jk.println("    AllowOverride None");
  +				mod_jk.println("    deny from all");
  +				mod_jk.println("</Directory>");
  +			}
  +
  +			// Deny serving any files from META-INF
  +        	mod_jk.println();            
  +        	mod_jk.println("#");		    
  +        	mod_jk.println("# The following line prohibits users from directly accessing META-INF");
  +        	mod_jk.println("#");                        
  +			mod_jk.println("<Location \"" + path + "/META-INF/\">");
  +			mod_jk.println("    AllowOverride None");
  +			mod_jk.println("    deny from all");
  +			mod_jk.println("</Location>");
  +			if (File.separatorChar == '\\') {
  +				mod_jk.println("#");		    
  +				mod_jk.println("# Use Directory too. On Windows, Location doesn't work unless case
matches");
  +				mod_jk.println("#");                        
  +				mod_jk.println("<Directory \"" + docBase + "/META-INF/\">");
  +				mod_jk.println("    AllowOverride None");
  +				mod_jk.println("    deny from all");
  +				mod_jk.println("</Directory>");
  +			}
   		    mod_jk.println();
   
               mod_jk.println("#######################################################");
	    
  
  
  

Mime
View raw message