From 113b9d10b523af3faadc4a1e07ebd4f95f5995ac Mon Sep 17 00:00:00 2001 From: Guilherme Espada Date: Tue, 2 Sep 2014 21:15:18 +0100 Subject: [PATCH] Delegate checks to the existing SecurityManager. In case one already exists. --- .../cpw/mods/fml/common/launcher/FMLTweaker.java | 2 +- .../cpw/mods/fml/relauncher/FMLSecurityManager.java | 12 ++++++++++++ 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/src/main/java/cpw/mods/fml/common/launcher/FMLTweaker.java b/src/main/java/cpw/mods/fml/common/launcher/FMLTweaker.java index bd1e2e2f3..96f98474f 100644 --- a/src/main/java/cpw/mods/fml/common/launcher/FMLTweaker.java +++ b/src/main/java/cpw/mods/fml/common/launcher/FMLTweaker.java @@ -32,7 +32,7 @@ public FMLTweaker() System.setProperty("java.net.preferIPv4Stack", "true"); //Lets do this as early as possible. Vanilla does it in Main.main try { - System.setSecurityManager(new FMLSecurityManager()); + System.setSecurityManager(new FMLSecurityManager(System.getSecurityManager())); } catch (SecurityException se) { diff --git a/src/main/java/cpw/mods/fml/relauncher/FMLSecurityManager.java b/src/main/java/cpw/mods/fml/relauncher/FMLSecurityManager.java index 71a092544..1944a3114 100644 --- a/src/main/java/cpw/mods/fml/relauncher/FMLSecurityManager.java +++ b/src/main/java/cpw/mods/fml/relauncher/FMLSecurityManager.java @@ -10,6 +10,14 @@ * */ public class FMLSecurityManager extends SecurityManager { + + private SecurityManager delegate; + + public FMLSecurityManager(SecurityManager delegate) + { + this.delegate=delegate; + } + @Override public void checkPermission(Permission perm) { @@ -29,6 +37,10 @@ else if ("setSecurityManager".equals(permName)) { throw new SecurityException("Cannot replace the FML security manager"); } + else if (delegate != null) + { + delegate.checkPermission(perm); + } return; }