|
21 | 21 | import javafx.application.Platform;
|
22 | 22 | import javafx.stage.Stage;
|
23 | 23 | import org.jackhuang.hmcl.Launcher;
|
24 |
| -import org.jackhuang.hmcl.Metadata; |
25 | 24 | import org.jackhuang.hmcl.auth.*;
|
26 | 25 | import org.jackhuang.hmcl.auth.authlibinjector.AuthlibInjectorDownloadException;
|
27 | 26 | import org.jackhuang.hmcl.download.DefaultDependencyManager;
|
|
47 | 46 | import java.io.File;
|
48 | 47 | import java.io.FileNotFoundException;
|
49 | 48 | import java.io.IOException;
|
50 |
| -import java.io.InputStream; |
51 | 49 | import java.net.SocketTimeoutException;
|
52 | 50 | import java.net.URL;
|
53 | 51 | import java.nio.file.AccessDeniedException;
|
54 |
| -import java.nio.file.Files; |
55 |
| -import java.nio.file.Path; |
56 |
| -import java.nio.file.StandardCopyOption; |
57 | 52 | import java.util.*;
|
58 | 53 | import java.util.concurrent.CancellationException;
|
59 | 54 | import java.util.concurrent.CompletableFuture;
|
@@ -134,8 +129,6 @@ private void launch0() {
|
134 | 129 |
|
135 | 130 | AtomicReference<JavaVersion> javaVersionRef = new AtomicReference<>();
|
136 | 131 |
|
137 |
| - getLog4jPatch(version.get()).ifPresent(javaAgents::add); |
138 |
| - |
139 | 132 | TaskExecutor executor = checkGameState(profile, setting, version.get())
|
140 | 133 | .thenComposeAsync(javaVersion -> {
|
141 | 134 | javaVersionRef.set(Objects.requireNonNull(javaVersion));
|
@@ -663,47 +656,6 @@ private static Task<AuthInfo> logIn(Account account) {
|
663 | 656 | });
|
664 | 657 | }
|
665 | 658 |
|
666 |
| - private static Optional<String> getLog4jPatch(Version version) { |
667 |
| - Optional<String> log4jVersion = version.getLibraries().stream() |
668 |
| - .filter(it -> it.is("org.apache.logging.log4j", "log4j-core") |
669 |
| - && (VersionNumber.VERSION_COMPARATOR.compare(it.getVersion(), "2.17") < 0 || "2.0-beta9".equals(it.getVersion()))) |
670 |
| - .map(Library::getVersion) |
671 |
| - .findFirst(); |
672 |
| - |
673 |
| - if (log4jVersion.isPresent()) { |
674 |
| - final String agentFileName = "log4j-patch-agent-1.0.jar"; |
675 |
| - |
676 |
| - Path agentFile = Metadata.HMCL_DIRECTORY.resolve(agentFileName).toAbsolutePath(); |
677 |
| - String agentFilePath = agentFile.toString(); |
678 |
| - if (agentFilePath.indexOf('=') >= 0) { |
679 |
| - LOG.warning("Invalid character '=' in the HMCL directory path, unable to attach log4j-patch"); |
680 |
| - return Optional.empty(); |
681 |
| - } |
682 |
| - |
683 |
| - if (Files.notExists(agentFile)) { |
684 |
| - try (InputStream input = DefaultLauncher.class.getResourceAsStream("/assets/game/" + agentFileName)) { |
685 |
| - LOG.info("Extract log4j patch to " + agentFilePath); |
686 |
| - Files.createDirectories(agentFile.getParent()); |
687 |
| - Files.copy(input, agentFile, StandardCopyOption.REPLACE_EXISTING); |
688 |
| - } catch (IOException e) { |
689 |
| - LOG.log(Level.WARNING, "Failed to extract log4j patch"); |
690 |
| - try { |
691 |
| - Files.deleteIfExists(agentFile); |
692 |
| - } catch (IOException ex) { |
693 |
| - LOG.log(Level.WARNING, "Failed to delete incomplete log4j patch", ex); |
694 |
| - } |
695 |
| - return Optional.empty(); |
696 |
| - } |
697 |
| - } |
698 |
| - |
699 |
| - boolean isBeta = log4jVersion.get().startsWith("2.0-beta"); |
700 |
| - return Optional.of(agentFilePath + "=" + isBeta); |
701 |
| - } else { |
702 |
| - LOG.info("No log4j with security vulnerabilities found"); |
703 |
| - return Optional.empty(); |
704 |
| - } |
705 |
| - } |
706 |
| - |
707 | 659 | private void checkExit() {
|
708 | 660 | switch (launcherVisibility) {
|
709 | 661 | case HIDE_AND_REOPEN:
|
|
0 commit comments