I am attempting to upgrade an application that uses an embedded cassandra 2.1.1 (about time!), but the application in question sets it's own security manager. Cassandra 3.11 seems to not consider this possibility and just attempts to set the security manager on it's own without any consideration that there might already be one (which fails).
2017-06-26T12:05:22,736 ERROR Thread-0 org.apache.cassandra.service.CassandraDaemon Exception encountered during startup
java.security.AccessControlException: access denied ("java.lang.RuntimePermission" "createSecurityManager")
at java.security.AccessControlContext.checkPermission(AccessControlContext.java:472) ~[?:1.8.0_101]
at java.security.AccessController.checkPermission(AccessController.java:884) ~[?:1.8.0_101]
at java.lang.SecurityManager.checkPermission(SecurityManager.java:549) ~[?:1.8.0_101]
at java.lang.SecurityManager.<init>(SecurityManager.java:299) ~[?:1.8.0_101]
at org.apache.cassandra.cql3.functions.ThreadAwareSecurityManager.<init>(ThreadAwareSecurityManager.java:199) ~[?:3.11.0]
at org.apache.cassandra.cql3.functions.ThreadAwareSecurityManager.install(ThreadAwareSecurityManager.java:80) ~[?:3.11.0]
at org.apache.cassandra.service.CassandraDaemon.setup(CassandraDaemon.java:192) ~[?:3.11.0]
at org.apache.cassandra.service.CassandraDaemon.activate(CassandraDaemon.java:600) ~[?:3.11.0]
at org.jesterj.ingest.persistence.Cassandra.start(Cassandra.java:94) ~[?:?]
at org.jesterj.ingest.Main.startCassandra(Main.java:190) ~[?:?]
at org.jesterj.ingest.Main.lambda$main$0(Main.java:125) ~[?:?]
at java.lang.Thread.run(Thread.java:745) [?:1.8.0_101]
There doesn't seem to be any check for configuration to avoid this when I browse the Cassandra code:
public static void install()
{
if (installed)
return;
System.setSecurityManager(new ThreadAwareSecurityManager());
Comments in ThreadAwareSecurityManager seem to indicate that this is meant to make user defined functions safe, but I have no plans to use user defined functions, so I'd be perfectly happy to turn that off, but I don't see such an option in the code.
static
{
//
// Use own security policy to be easier (and faster) since the C* has no fine grained permissions.
// Either code has access to everything or code has access to nothing (UDFs).
// This also removes the burden to maintain and configure policy files for production, unit tests etc.
This looks suspiciously like it requires a code change to Cassandra before it will ever work. Does anyone have a better idea?
For reference, this comes about as an attempt to escape issues that old cqlsh has with current versions of python:
https://github.com/nsoft/jesterj/issues/89
EDIT: Figured out why the exception occurs despite my previous installation of security manager. It turns out that they install a policy that fails anything not coming from a codesource with a url starting with 'file'. My app loads via one-jar so all my code sources have a url like: onejar:lib/docopt-0.6.1.jar. Thus when they try to install their own security manager, they run afoul of their own policy and die.