costin      01/08/21 21:43:24

  Modified:    src/share/org/apache/tomcat/startup EmbededTomcat.java
                        Main.java
  Log:
  Enable Main to set the right policy, in case we don't use scripts or the
  scripts are broken ( bad path, etc - it happens to me, it may happen to someone else 
).
   Java -jar is now closer to the sh/bat scripts.
  
  Also clean up more messages.
  
  Revision  Changes    Path
  1.48      +19 -5     
jakarta-tomcat/src/share/org/apache/tomcat/startup/EmbededTomcat.java
  
  Index: EmbededTomcat.java
  ===================================================================
  RCS file: 
/home/cvs/jakarta-tomcat/src/share/org/apache/tomcat/startup/EmbededTomcat.java,v
  retrieving revision 1.47
  retrieving revision 1.48
  diff -u -r1.47 -r1.48
  --- EmbededTomcat.java        2001/08/21 05:29:27     1.47
  +++ EmbededTomcat.java        2001/08/22 04:43:23     1.48
  @@ -143,7 +143,6 @@
       /** Tomcat will run in a sandboxed environment, under SecurityManager
        */
       public void setSandbox(boolean b) {
  -     debug("Sandbox enabled");
        attributes.put("sandbox", "true");
       }
   
  @@ -254,13 +253,15 @@
       /** Init tomcat using server.xml-style configuration
        */
       public void addServerXmlModules() throws TomcatException {
  -     debug( "Using server.xml " + attributes.get( "config" ));
  +     String conf=(String)attributes.get( "config" );
  +
        addModule( "org.apache.tomcat.modules.config.PathSetter");
        int mid=addModule( "org.apache.tomcat.modules.config.ServerXmlReader");
   
  -     if( null!=attributes.get( "config" ) )
  -         setModuleProperty( mid, "config",
  -                            (String)attributes.get("config") );
  +     if( null!=conf ) {
  +         if( dL>0) debug( "Using config file " + conf);
  +         setModuleProperty( mid, "config",conf );
  +     }
       }
   
       public void addDefaultModules()
  @@ -408,6 +409,9 @@
                                         modules.elementAt( i ) );
            }
            contextM.init();
  +     } catch( InvocationTargetException rex ) {
  +         debug("exception initializing ContextManager", rex.getTargetException());
  +         throw new TomcatException( "EmbededTomcat.initContextManager", 
ex.getTargetExeption() );
        } catch( Exception ex ) {
            debug("exception initializing ContextManager", ex);
            throw new TomcatException( "EmbededTomcat.initContextManager", ex );
  @@ -501,6 +505,16 @@
        directly the methods you need.
        */
       public void execute() throws Exception {
  +     final EmbededTomcat et=this;
  +     jdk11Compat.doPrivileged( new Action() {
  +             public Object run() throws Exception {
  +                 et.execute1();
  +                 return null;
  +             }
  +         }, jdk11Compat.getAccessControlContext());
  +    }
  +    
  +    public void execute1() throws Exception {
        if( args!=null )
            processArgs( args );
        // Init 
  
  
  
  1.38      +17 -14    jakarta-tomcat/src/share/org/apache/tomcat/startup/Main.java
  
  Index: Main.java
  ===================================================================
  RCS file: /home/cvs/jakarta-tomcat/src/share/org/apache/tomcat/startup/Main.java,v
  retrieving revision 1.37
  retrieving revision 1.38
  diff -u -r1.37 -r1.38
  --- Main.java 2001/08/21 05:35:05     1.37
  +++ Main.java 2001/08/22 04:43:23     1.38
  @@ -1,4 +1,4 @@
  -/* $Id: Main.java,v 1.37 2001/08/21 05:35:05 costin Exp $
  +/* $Id: Main.java,v 1.38 2001/08/22 04:43:23 costin Exp $
    * ====================================================================
    *
    * The Apache Software License, Version 1.1
  @@ -178,6 +178,10 @@
            IntrospectionUtils.displayClassPath("Main classpath: ", commonCP );
       }
   
  +    // initSecurityFile is intended to simplify sandbox config, the shell
  +    // script can't normalize the path. We also want java -jar to behave the same,
  +    // without requiring anything difficult.
  +    
       /** If "-sandbox" parameter is found ( the first after the action ), we'll
        *  load a sandbox with the policy in install/conf/tomcat.policy. This
        *  has to happen before loading any class or constructing the loader, or
  @@ -190,20 +194,19 @@
        *  so that all "system" classes have permissions.
        */
       public void initSecurityFile() {
  -//   if( args.length > 1 &&
  -//       "-sandbox".equals( args[1] ) ) {
  -//       if( null == System.getProperty("java.security.policy")) {
  -//           File f=null;
  -//           String policyFile=installDir + File.separator + "conf" +
  -//               File.separator + "tomcat.policy";
  +     if( args.length > 1 &&
  +         "-sandbox".equals( args[1] ) ) {
  +         if( null == System.getProperty("java.security.policy")) {
  +             File f=null;
  +             String policyFile=installDir + File.separator + "conf" +
  +                 File.separator + "tomcat.policy";
                
  -//           debug("Setting policy file to " + policyFile + " tomcat.home= " +
  -//               System.getProperty( "tomcat.home") );
  -//           System.setProperty( "tomcat.home", installDir );
  -//           System.setProperty("java.security.policy",  policyFile);
  -//           java.security.Policy.getPolicy().refresh();
  -//       }
  -//   }
  +             debug("Setting policy " + policyFile );
  +             System.setProperty( "tomcat.home", installDir );
  +             System.setProperty("java.security.policy",  policyFile);
  +             jdk11Compat.refreshPolicy();
  +         }
  +     }
       }
       
       // -------------------- Tasks --------------------
  
  
  

Reply via email to