Author: markt
Date: Fri Mar 27 13:47:02 2009
New Revision: 759136
URL: http://svn.apache.org/viewvc?rev=759136&view=rev
Log:
Improve handling of situation where web application tries to configure logging
at the context level but the security policy prevents this.
Modified:
tomcat/connectors/trunk/juli/src/java/org/apache/juli/ClassLoaderLogManager.java
tomcat/container/tc5.5.x/webapps/docs/changelog.xml
Modified:
tomcat/connectors/trunk/juli/src/java/org/apache/juli/ClassLoaderLogManager.java
URL:
http://svn.apache.org/viewvc/tomcat/connectors/trunk/juli/src/java/org/apache/juli/ClassLoaderLogManager.java?rev=759136&r1=759135&r2=759136&view=diff
==============================================================================
---
tomcat/connectors/trunk/juli/src/java/org/apache/juli/ClassLoaderLogManager.java
(original)
+++
tomcat/connectors/trunk/juli/src/java/org/apache/juli/ClassLoaderLogManager.java
Fri Mar 27 13:47:02 2009
@@ -19,10 +19,13 @@
import java.io.File;
import java.io.FileInputStream;
+import java.io.FilePermission;
import java.io.IOException;
import java.io.InputStream;
import java.net.URLClassLoader;
+import java.security.AccessControlException;
import java.security.AccessController;
+import java.security.Permission;
import java.security.PrivilegedAction;
import java.util.Collections;
import java.util.Enumeration;
@@ -295,9 +298,29 @@
InputStream is = null;
// Special case for URL classloaders which are used in containers:
// only look in the local repositories to avoid redefining loggers 20
times
- if ((classLoader instanceof URLClassLoader)
- && (((URLClassLoader)
classLoader).findResource("logging.properties") != null)) {
- is = classLoader.getResourceAsStream("logging.properties");
+ try {
+ if ((classLoader instanceof URLClassLoader)
+ && (((URLClassLoader)
classLoader).findResource("logging.properties") != null)) {
+ is = classLoader.getResourceAsStream("logging.properties");
+ }
+ } catch (AccessControlException ace) {
+ // No permission to configure logging in context
+ // Log and carry on
+ ClassLoaderLogInfo info =
+ (ClassLoaderLogInfo)
classLoaderLoggers.get(ClassLoader.getSystemClassLoader());
+ if (info != null) {
+ Logger log = (Logger) info.loggers.get("");
+ if (log != null) {
+ Permission perm = ace.getPermission();
+ if (perm instanceof FilePermission &&
perm.getActions().equals("read")) {
+ log.warning("Reading " + perm.getName() + " is not
permitted. See \"per context logging\" in the default catalina.policy file.");
+ }
+ else {
+ log.warning("Reading logging.properties is not
permitted in some context. See \"per context logging\" in the default
catalina.policy file.");
+ log.warning("Original error was: " + ace.getMessage());
+ }
+ }
+ }
}
if ((is == null) && (classLoader ==
ClassLoader.getSystemClassLoader())) {
String configFileStr =
System.getProperty("java.util.logging.config.file");
Modified: tomcat/container/tc5.5.x/webapps/docs/changelog.xml
URL:
http://svn.apache.org/viewvc/tomcat/container/tc5.5.x/webapps/docs/changelog.xml?rev=759136&r1=759135&r2=759136&view=diff
==============================================================================
--- tomcat/container/tc5.5.x/webapps/docs/changelog.xml (original)
+++ tomcat/container/tc5.5.x/webapps/docs/changelog.xml Fri Mar 27 13:47:02 2009
@@ -62,6 +62,11 @@
<bug>45628</bug>: JARs that do not declare any dependencies should
always be considered as fulfilled. (markt)
</fix>
+ <fix>
+ Improve handling of situation where web application tries to configure
+ logging at the context level but the security policy prevents this.
+ (markt/rjung)
+ </fix>
</changelog>
</subsection>
<subsection name="Jasper">
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]