Bug 260452 - [PATCH] games/minecraft-server: Update to latest version and patch log4shell
Summary: [PATCH] games/minecraft-server: Update to latest version and patch log4shell
Status: Closed FIXED
Alias: None
Product: Ports & Packages
Classification: Unclassified
Component: Individual Port(s) (show other bugs)
Version: Latest
Hardware: Any Any
: --- Affects Many People
Assignee: Juraj Lutter
URL:
Keywords:
: 260346 (view as bug list)
Depends on:
Blocks: 260421
  Show dependency treegraph
 
Reported: 2021-12-15 21:43 UTC by Jonathan Price
Modified: 2021-12-26 13:57 UTC (History)
6 users (show)

See Also:


Attachments
git diff patch (1.34 KB, patch)
2021-12-15 21:43 UTC, Jonathan Price
freebsd: maintainer-approval+
Details | Diff
git diff patch v2 (2.10 KB, patch)
2021-12-15 22:05 UTC, Jonathan Price
freebsd: maintainer-approval+
Details | Diff
git diff patch v3 (2.67 KB, patch)
2021-12-15 22:17 UTC, Jonathan Price
freebsd: maintainer-approval+
Details | Diff
git diff patch v4 (2.33 KB, patch)
2021-12-16 21:15 UTC, Jonathan Price
freebsd: maintainer-approval+
Details | Diff
git diff patch v5 (5.08 KB, patch)
2021-12-16 21:46 UTC, Jonathan Price
freebsd: maintainer-approval+
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Jonathan Price 2021-12-15 21:43:22 UTC
Created attachment 230155 [details]
git diff patch

Port has been updated to the latest version (1.18.1). Credit to Martin Kuss for supplying the original diff.

This update also patches the log4shell vulnerability.

A diff file has been attached.
Comment 1 Jonathan Price 2021-12-15 22:05:57 UTC
Created attachment 230157 [details]
git diff patch v2

I discovered an issue when running the new version on a system that already has an existing Java 8 install. the path "%%LOCALBASE%%/bin/java" continues to point to Java 8 after Java 17 has been installed. With the existing RC script, this was causing the Minecraft server to try to launch with Java 8 and subsequently failing.

I have updated the patch to instead point to %%LOCALBASE%%/openjdk17/bin/java, which I have confirmed resolves the issue.

If somebody happens to read this and knows of a more "correct" way to resolve this issue, feel free to let me know.
Comment 2 Jonathan Price 2021-12-15 22:17:59 UTC
Created attachment 230159 [details]
git diff patch v3

A similar issue existed with the standalone configuration and not explicitly calling Java 17. This has now also been resolved.
Comment 3 Eric Rucker 2021-12-16 02:21:27 UTC
I believe the correct way to force a specific Java version is to pass it in the JAVA_VERSION environment variable (as JAVA_VERSION=17 or JAVA_VERSION=17+) at runtime, FWIW.
Comment 4 Corey Hinshaw 2021-12-16 14:07:19 UTC
As of version 1.18.1, server.jar now extracts several libraries and other jar files into /usr/local/minecraft-server/libraries and /usr/local/minecraft-server/versions when it is run for the first time. These files will remain after a deinstall with the current patch.

One approach might be to add these files to pkg-plist with a @rmtry keyword. They would then be removed on deinstall. This will leave the empty directory hierarchies behind, but those could be cleaned up with something like the following in pkg-deinstall.in:

find "%%PREFIX%%/minecraft-server/libraries" -type d -empty -delete
find "%%PREFIX%%/minecraft-server/versions" -type d -empty -delete

For reference, the files extracted after first run for 1.18.1 are:

minecraft-server/libraries/it/unimi/dsi/fastutil/8.5.6/fastutil-8.5.6.jar
minecraft-server/libraries/commons-io/commons-io/2.11.0/commons-io-2.11.0.jar
minecraft-server/libraries/com/mojang/authlib/3.2.38/authlib-3.2.38.jar
minecraft-server/libraries/com/mojang/brigadier/1.0.18/brigadier-1.0.18.jar
minecraft-server/libraries/com/mojang/javabridge/1.2.24/javabridge-1.2.24.jar
minecraft-server/libraries/com/mojang/datafixerupper/4.0.26/datafixerupper-4.0.26.jar
minecraft-server/libraries/com/github/oshi/oshi-core/5.8.2/oshi-core-5.8.2.jar
minecraft-server/libraries/com/google/code/gson/gson/2.8.8/gson-2.8.8.jar
minecraft-server/libraries/com/google/guava/guava/31.0.1-jre/guava-31.0.1-jre.jar
minecraft-server/libraries/com/google/guava/failureaccess/1.0.1/failureaccess-1.0.1.jar
minecraft-server/libraries/org/slf4j/slf4j-api/1.8.0-beta4/slf4j-api-1.8.0-beta4.jar
minecraft-server/libraries/org/apache/commons/commons-lang3/3.12.0/commons-lang3-3.12.0.jar
minecraft-server/libraries/org/apache/logging/log4j/log4j-slf4j18-impl/2.14.1/log4j-slf4j18-impl-2.14.1.jar
minecraft-server/libraries/org/apache/logging/log4j/log4j-api/2.14.1/log4j-api-2.14.1.jar
minecraft-server/libraries/org/apache/logging/log4j/log4j-core/2.14.1/log4j-core-2.14.1.jar
minecraft-server/libraries/net/sf/jopt-simple/jopt-simple/5.0.4/jopt-simple-5.0.4.jar
minecraft-server/libraries/net/java/dev/jna/jna-platform/5.9.0/jna-platform-5.9.0.jar
minecraft-server/libraries/net/java/dev/jna/jna/5.9.0/jna-5.9.0.jar
minecraft-server/libraries/io/netty/netty-all/4.1.68.Final/netty-all-4.1.68.Final.jar
minecraft-server/versions/1.18.1/server-1.18.1.jar
Comment 5 Jonathan Price 2021-12-16 21:15:59 UTC
Created attachment 230186 [details]
git diff patch v4

I've modified the port to use JAVA_VERSION=17 instead of hardcoding the path to Java 17. Thanks for the suggestion Eric.

Strangely, 16+ works, 17 works, but 17+ doesn't seem to exist. The manpage doesn't even reckon 17 exists so I guess it just hasn't kept up with updates. However, given the port specifies Java 17, this shouldn't pose a problem.
Comment 6 Jonathan Price 2021-12-16 21:46:24 UTC
Created attachment 230187 [details]
git diff patch v5

I have updated the port to track the contents of the libraries and versions folder that are downloaded on first launch so that they are cleared during a deinstall. 

I have then added find statements to pkg-deinstall.in to delete the folders if there are no further contents.

Thanks to Corey for both of these suggestions.
Comment 7 Joel Bodenmann freebsd_committer freebsd_triage 2021-12-20 11:30:41 UTC
Thanks a lot for updating this port!

I think a lot of people would appreciate if this patch lands before the holidays start so we can enjoy some Minecraft 1.18 action :p
Comment 8 Xin LI freebsd_committer freebsd_triage 2021-12-26 01:59:14 UTC
*** Bug 260346 has been marked as a duplicate of this bug. ***
Comment 9 commit-hook freebsd_committer freebsd_triage 2021-12-26 13:51:30 UTC
A commit in branch main references this bug:

URL: https://cgit.FreeBSD.org/ports/commit/?id=9b7bf0835c59594c983a54034f3fa04d95d5fc3e

commit 9b7bf0835c59594c983a54034f3fa04d95d5fc3e
Author:     Jonathan Price <freebsd@jonathanprice.org>
AuthorDate: 2021-12-26 13:40:41 +0000
Commit:     Juraj Lutter <otis@FreeBSD.org>
CommitDate: 2021-12-26 13:49:48 +0000

    games/minecraft-server: Update to 1.18.1

    PR:             260452

 games/minecraft-server/Makefile                  |  5 +++--
 games/minecraft-server/distinfo                  |  6 +++---
 games/minecraft-server/files/minecraft-server.in |  3 ++-
 games/minecraft-server/files/minecraft.in        |  2 ++
 games/minecraft-server/files/pkg-deinstall.in    |  3 +++
 games/minecraft-server/pkg-plist                 | 21 +++++++++++++++++++++
 6 files changed, 34 insertions(+), 6 deletions(-)
Comment 10 commit-hook freebsd_committer freebsd_triage 2021-12-26 13:55:33 UTC
A commit in branch 2021Q4 references this bug:

URL: https://cgit.FreeBSD.org/ports/commit/?id=190d1538adeb123e49ee12569960158f3b75d228

commit 190d1538adeb123e49ee12569960158f3b75d228
Author:     Jonathan Price <freebsd@jonathanprice.org>
AuthorDate: 2021-12-26 13:40:41 +0000
Commit:     Juraj Lutter <otis@FreeBSD.org>
CommitDate: 2021-12-26 13:53:47 +0000

    games/minecraft-server: Update to 1.18.1

    PR:             260452
    (cherry picked from commit 9b7bf0835c59594c983a54034f3fa04d95d5fc3e)

 games/minecraft-server/Makefile                  |  5 +++--
 games/minecraft-server/distinfo                  |  6 +++---
 games/minecraft-server/files/minecraft-server.in |  3 ++-
 games/minecraft-server/files/minecraft.in        |  2 ++
 games/minecraft-server/files/pkg-deinstall.in    |  3 +++
 games/minecraft-server/pkg-plist                 | 21 +++++++++++++++++++++
 6 files changed, 34 insertions(+), 6 deletions(-)
Comment 11 Juraj Lutter freebsd_committer freebsd_triage 2021-12-26 13:57:02 UTC
Committed, thanks.