How to sanely configure security policy in Tomcat 6

前端 未结 4 623
走了就别回头了
走了就别回头了 2021-02-05 10:06

I\'m using Tomcat 6.0.24, as packaged for Ubuntu Karmic. The default security policy of Ubuntu\'s Tomcat package is pretty stringent, but appears straightforward. In /va

4条回答
  •  没有蜡笔的小新
    2021-02-05 10:45

    It's possible that you have to grant file access permissions separately. Try changing the grant for your app to:

    grant codeBase "file:${catalina.base}/webapps/ROOT.war" {
      permission java.security.AllPermission;
      permission java.io.FilePermission "file:${catalina.base}/webapps/ROOT/-", "read, write";
    }
    

    If that doesn't work, then it could be that some code outside of what your existing grants cover is accessing those property files (e.g. servlet or other library code).

    As a workaround, and to confirm if this is the case, you could do a straight grant on the .properties that are causing you the problem:

    grant {
      permission java.io.FilePermission "file:${catalina.base}/webapps/ROOT/WEB-INF/classes/com/foo/some-file-here.txt", "read, write";
    }
    

    It seems in fact that the latter could be the case since the stack trace shows code in Tomcat's context loader. If the straight grant on the .properties works, you might want to lock the grant down to org.apache.naming.resources.FileDirContext.

    Do you get any stack traces specific to your own code?

提交回复
热议问题