glenn       2003/03/08 09:01:20

  Modified:    catalina/src/share/org/apache/catalina/loader
                        WebappClassLoader.java WebappLoader.java
  Log:
  Port bug #17775 patch from Tomcat 4
  
  Revision  Changes    Path
  1.15      +19 -4     
jakarta-tomcat-catalina/catalina/src/share/org/apache/catalina/loader/WebappClassLoader.java
  
  Index: WebappClassLoader.java
  ===================================================================
  RCS file: 
/home/cvs/jakarta-tomcat-catalina/catalina/src/share/org/apache/catalina/loader/WebappClassLoader.java,v
  retrieving revision 1.14
  retrieving revision 1.15
  diff -u -r1.14 -r1.15
  --- WebappClassLoader.java    4 Feb 2003 07:24:22 -0000       1.14
  +++ WebappClassLoader.java    8 Mar 2003 17:01:20 -0000       1.15
  @@ -464,14 +464,27 @@
        * @param path file directory path
        */
       public void addPermission(String path) {
  +        if (path == null) {
  +            return;
  +        }
  +
           if (securityManager != null) {
               Permission permission = null;
               if( path.startsWith("jndi:") || path.startsWith("jar:jndi:") ) {
  +                if (!path.endsWith("/")) {
  +                    path = path + "/";
  +                }
                   permission = new JndiPermission(path + "*");
  +                addPermission(permission);
               } else {
  -                permission = new FilePermission(path + "-","read");
  +                if (!path.endsWith(File.separator)) {
  +                    permission = new FilePermission(path, "read");
  +                    addPermission(permission);
  +                    path = path + File.separator;
  +                }
  +                permission = new FilePermission(path + "-", "read");
  +                addPermission(permission);
               }
  -            addPermission(permission);
           }
       }
   
  @@ -483,7 +496,9 @@
        * @param url URL for a file or directory on local system
        */
       public void addPermission(URL url) {
  -        addPermission(url.toString());
  +        if (url != null) {
  +            addPermission(url.toString());
  +        }
       }
   
   
  
  
  
  1.8       +15 -28    
jakarta-tomcat-catalina/catalina/src/share/org/apache/catalina/loader/WebappLoader.java
  
  Index: WebappLoader.java
  ===================================================================
  RCS file: 
/home/cvs/jakarta-tomcat-catalina/catalina/src/share/org/apache/catalina/loader/WebappLoader.java,v
  retrieving revision 1.7
  retrieving revision 1.8
  diff -u -r1.7 -r1.8
  --- WebappLoader.java 26 Feb 2003 20:20:39 -0000      1.7
  +++ WebappLoader.java 8 Mar 2003 17:01:20 -0000       1.8
  @@ -898,37 +898,28 @@
               String contextRoot = servletContext.getRealPath("/");
               if (contextRoot != null) {
                   try {
  -                    contextRoot = 
  -                        (new File(contextRoot)).getCanonicalPath() 
  -                        + File.separator;
  +                    contextRoot = (new File(contextRoot)).getCanonicalPath();
                       classLoader.addPermission(contextRoot);
                   } catch (IOException e) {
                       // Ignore
                   }
               }
   
  -            URL classesURL =
  -                servletContext.getResource("/WEB-INF/classes/");
  -            if (classesURL != null)
  -                classLoader.addPermission(classesURL);
  -
  +            URL classesURL = servletContext.getResource("/WEB-INF/classes/");
  +            classLoader.addPermission(classesURL);
               URL libURL = servletContext.getResource("/WEB-INF/lib/");
  -            if (libURL != null) {
  -                classLoader.addPermission(libURL);
  -            }
  +            classLoader.addPermission(libURL);
   
               if (contextRoot != null) {
   
                   if (libURL != null) {
                       File rootDir = new File(contextRoot);
                       File libDir = new File(rootDir, "WEB-INF/lib/");
  -                    String path = null;
                       try {
  -                        path = libDir.getCanonicalPath() + File.separator;
  +                        String path = libDir.getCanonicalPath();
  +                        classLoader.addPermission(path);
                       } catch (IOException e) {
                       }
  -                    if (path != null)
  -                        classLoader.addPermission(path);
                   }
   
               } else {
  @@ -936,23 +927,19 @@
                   if (workDir != null) {
                       if (libURL != null) {
                           File libDir = new File(workDir, "WEB-INF/lib/");
  -                        String path = null;
                           try {
  -                            path = libDir.getCanonicalPath() + File.separator;
  +                            String path = libDir.getCanonicalPath();
  +                            classLoader.addPermission(path);
                           } catch (IOException e) {
                           }
  -                        classLoader.addPermission(path);
                       }
                       if (classesURL != null) {
  -                        File classesDir =
  -                            new File(workDir, "WEB-INF/classes/");
  -                        String path = null;
  +                        File classesDir = new File(workDir, "WEB-INF/classes/");
                           try {
  -                            path = classesDir.getCanonicalPath()
  -                                + File.separator;
  +                            String path = classesDir.getCanonicalPath();
  +                            classLoader.addPermission(path);
                           } catch (IOException e) {
                           }
  -                        classLoader.addPermission(path);
                       }
                   }
   
  
  
  

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to