mirror of
https://github.com/GravitLauncher/Launcher
synced 2024-12-23 09:01:08 +03:00
CodeStyle для EnvHelper
This commit is contained in:
parent
91f9e11b36
commit
23f67c2160
4 changed files with 17 additions and 13 deletions
|
@ -19,7 +19,7 @@ public static void main(String[] arguments) throws IOException, InterruptedExcep
|
||||||
LogHelper.printVersion("Launcher");
|
LogHelper.printVersion("Launcher");
|
||||||
JVMHelper.checkStackTrace(ClientLauncherWrapper.class);
|
JVMHelper.checkStackTrace(ClientLauncherWrapper.class);
|
||||||
JVMHelper.verifySystemProperties(Launcher.class, true);
|
JVMHelper.verifySystemProperties(Launcher.class, true);
|
||||||
EnvHelper.checkDangerousParametrs();
|
EnvHelper.checkDangerousParams();
|
||||||
LogHelper.debug("Restart Launcher");
|
LogHelper.debug("Restart Launcher");
|
||||||
ProcessBuilder processBuilder = new ProcessBuilder();
|
ProcessBuilder processBuilder = new ProcessBuilder();
|
||||||
processBuilder.inheritIO();
|
processBuilder.inheritIO();
|
||||||
|
|
|
@ -42,7 +42,6 @@
|
||||||
import ru.gravit.launcher.request.auth.AuthRequest;
|
import ru.gravit.launcher.request.auth.AuthRequest;
|
||||||
import ru.gravit.launcher.request.auth.CheckServerRequest;
|
import ru.gravit.launcher.request.auth.CheckServerRequest;
|
||||||
import ru.gravit.launcher.request.auth.JoinServerRequest;
|
import ru.gravit.launcher.request.auth.JoinServerRequest;
|
||||||
import ru.gravit.launcher.request.update.LegacyLauncherRequest;
|
|
||||||
import ru.gravit.launcher.request.update.UpdateRequest;
|
import ru.gravit.launcher.request.update.UpdateRequest;
|
||||||
import ru.gravit.launcher.request.uuid.BatchProfileByUsernameRequest;
|
import ru.gravit.launcher.request.uuid.BatchProfileByUsernameRequest;
|
||||||
import ru.gravit.launcher.request.uuid.ProfileByUUIDRequest;
|
import ru.gravit.launcher.request.uuid.ProfileByUUIDRequest;
|
||||||
|
@ -151,7 +150,7 @@ public static void addLauncherClassBindings(Map<String, Object> bindings) {
|
||||||
public static void main(String... args) throws Throwable {
|
public static void main(String... args) throws Throwable {
|
||||||
JVMHelper.checkStackTrace(LauncherEngine.class);
|
JVMHelper.checkStackTrace(LauncherEngine.class);
|
||||||
JVMHelper.verifySystemProperties(Launcher.class, true);
|
JVMHelper.verifySystemProperties(Launcher.class, true);
|
||||||
EnvHelper.checkDangerousParametrs();
|
EnvHelper.checkDangerousParams();
|
||||||
if(!LauncherAgent.isStarted()) throw new SecurityException("JavaAgent not set");
|
if(!LauncherAgent.isStarted()) throw new SecurityException("JavaAgent not set");
|
||||||
LogHelper.printVersion("Launcher");
|
LogHelper.printVersion("Launcher");
|
||||||
// Start Launcher
|
// Start Launcher
|
||||||
|
|
|
@ -407,7 +407,7 @@ public static void main(String... args) throws Throwable {
|
||||||
}
|
}
|
||||||
checkJVMBitsAndVersion();
|
checkJVMBitsAndVersion();
|
||||||
JVMHelper.verifySystemProperties(ClientLauncher.class, true);
|
JVMHelper.verifySystemProperties(ClientLauncher.class, true);
|
||||||
EnvHelper.checkDangerousParametrs();
|
EnvHelper.checkDangerousParams();
|
||||||
JVMHelper.checkStackTrace(ClientLauncher.class);
|
JVMHelper.checkStackTrace(ClientLauncher.class);
|
||||||
LogHelper.printVersion("Client Launcher");
|
LogHelper.printVersion("Client Launcher");
|
||||||
// Read and delete params file
|
// Read and delete params file
|
||||||
|
|
|
@ -14,20 +14,25 @@ public class EnvHelper {
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void addEnv(ProcessBuilder builder) {
|
public static void addEnv(ProcessBuilder builder) {
|
||||||
Map<String, String> repl = builder.environment();
|
Map<String, String> map = builder.environment();
|
||||||
for (String str : toTest) {
|
for (String env : toTest) {
|
||||||
repl.put(str, "");
|
if(map.containsKey(env))
|
||||||
repl.put(str.toLowerCase(Locale.US), "");
|
map.put(env, "");
|
||||||
|
String lower_env = env.toLowerCase(Locale.US);
|
||||||
|
if(map.containsKey(lower_env))
|
||||||
|
map.put(lower_env, "");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void checkDangerousParametrs() {
|
public static void checkDangerousParams() {
|
||||||
for (String t : toTest)
|
for (String t : toTest) {
|
||||||
if (System.getenv(t) != null) {
|
String env = System.getenv(t);
|
||||||
String env = System.getenv(t).toLowerCase(Locale.US);
|
if (env != null) {
|
||||||
|
env = env.toLowerCase(Locale.US);
|
||||||
if (env.contains("-cp") || env.contains("-classpath") || env.contains("-javaagent")
|
if (env.contains("-cp") || env.contains("-classpath") || env.contains("-javaagent")
|
||||||
|| env.contains("-agentpath") || env.contains("-agentlib"))
|
|| env.contains("-agentpath") || env.contains("-agentlib"))
|
||||||
throw new SecurityException("JavaAgent in global optings not allow");
|
throw new SecurityException("JavaAgent in global options not allow");
|
||||||
}
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue