From 37d0983d6c28e96ff60cbc7ef806edfb48d72845 Mon Sep 17 00:00:00 2001 From: drardin <81466808+drardin@users.noreply.github.com> Date: Tue, 17 Oct 2023 20:34:49 -0600 Subject: [PATCH 1/4] Update bedrock-entry.sh If the ALLOW_LIST_USERS or WHITE_LIST_USERS env variables were set, the existing code would append white-list=false to server.properties, which resulted in conflicting variables (allow-list=true , white-list=false). Because the variable is still currently supported, it would result in inconsistent behavior from the server. This commit removes all reference to the white-list variable, as support for it is being deprecated by Microsoft and also includes omission of the WHITE_LIST=false line. --- bedrock-entry.sh | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/bedrock-entry.sh b/bedrock-entry.sh index 274fb07..ae1527f 100755 --- a/bedrock-entry.sh +++ b/bedrock-entry.sh @@ -165,22 +165,20 @@ if [ -n "$OPS" ] || [ -n "$MEMBERS" ] || [ -n "$VISITORS" ]; then ]| flatten' > permissions.json fi +if [[ -v ALLOW_LIST_USERS ]]; then + allowListUsers=${ALLOW_LIST_USERS} -if [[ -v ALLOW_LIST_USERS || -v WHITE_LIST_USERS ]]; then - allowListUsers=${ALLOW_LIST_USERS:-${WHITE_LIST_USERS}} - - WHITE_LIST=false - rm -f whitelist.json - if [[ $allowListUsers ]]; then + if [[ "$allowListUsers" ]]; then echo "Setting allow list" jq -c -n --arg users "$allowListUsers" '$users | split(",") | map({"ignoresPlayerLimit":false,"name": .})' > "allowlist.json" # activate server property to enable list usage ALLOW_LIST=true else - rm -rf allowlist.json + rm -f allowlist.json + # deactivate server property if no allow list is specified ALLOW_LIST=false fi - export WHITE_LIST ALLOW_LIST + export ALLOW_LIST fi set-property --file server.properties --bulk /etc/bds-property-definitions.json From 8842fe2df736e0523758e5ccb5fb3a33e3ade2f3 Mon Sep 17 00:00:00 2001 From: drardin <81466808+drardin@users.noreply.github.com> Date: Tue, 17 Oct 2023 22:27:01 -0600 Subject: [PATCH 2/4] Update to allow | white List handling This proposal does the following: If neither ALLOW_LIST_USERS or WHITE_LIST_USERS env variables are set, the allowlist.json is removed and ALLOW_LIST is exported as a false value. If both of variables are set, ALLOW_LIST_USERS takes precedence and WHITE_LIST_USERS is ignored. If only one of these variables are set, it will function as expected. ALLOW_LIST is the only exported variable, which should be sufficient for server.properties. It's also exported outside of the if block. --- bedrock-entry.sh | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/bedrock-entry.sh b/bedrock-entry.sh index ae1527f..8dff601 100755 --- a/bedrock-entry.sh +++ b/bedrock-entry.sh @@ -165,8 +165,8 @@ if [ -n "$OPS" ] || [ -n "$MEMBERS" ] || [ -n "$VISITORS" ]; then ]| flatten' > permissions.json fi -if [[ -v ALLOW_LIST_USERS ]]; then - allowListUsers=${ALLOW_LIST_USERS} +if [[ -n "$ALLOW_LIST_USERS" || -n "$WHITE_LIST_USERS" ]]; then + allowListUsers=${ALLOW_LIST_USERS:-$WHITE_LIST_USERS} if [[ "$allowListUsers" ]]; then echo "Setting allow list" @@ -174,13 +174,16 @@ if [[ -v ALLOW_LIST_USERS ]]; then # activate server property to enable list usage ALLOW_LIST=true else - rm -f allowlist.json - # deactivate server property if no allow list is specified ALLOW_LIST=false + rm allowlist.json fi - export ALLOW_LIST +else + ALLOW_LIST=false + rm allowlist.json fi +export ALLOW_LIST + set-property --file server.properties --bulk /etc/bds-property-definitions.json export LD_LIBRARY_PATH=. From 0954b3a951d83167d39e8d61793319fa3eef89e8 Mon Sep 17 00:00:00 2001 From: drardin <81466808+drardin@users.noreply.github.com> Date: Wed, 18 Oct 2023 08:17:35 -0600 Subject: [PATCH 3/4] Removal of white-list line from server.properties This will remove any line beginning with "white-list=" in the server.properties file, regardless of if ALLOW_LIST_USERS or WHITE_LIST_USERS env variables are set or not. This should resolve any issues resulting from the addition of this line from previous versions of the docker image where env variables ALLOW_LIST_USERS or WHITE_LIST_USERS were set. --- bedrock-entry.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bedrock-entry.sh b/bedrock-entry.sh index 8dff601..6004692 100755 --- a/bedrock-entry.sh +++ b/bedrock-entry.sh @@ -181,7 +181,7 @@ else ALLOW_LIST=false rm allowlist.json fi - +sed -i '/^white-list=.*/d' server.properties #Removes white-list= line from server.properties export ALLOW_LIST set-property --file server.properties --bulk /etc/bds-property-definitions.json From cb0b70211746c99349b70a888b9520812ff2e03b Mon Sep 17 00:00:00 2001 From: drardin <81466808+drardin@users.noreply.github.com> Date: Thu, 19 Oct 2023 18:12:06 -0600 Subject: [PATCH 4/4] Added -f flag on rm command to ignore deletion errors --- bedrock-entry.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/bedrock-entry.sh b/bedrock-entry.sh index 6004692..861e188 100755 --- a/bedrock-entry.sh +++ b/bedrock-entry.sh @@ -175,11 +175,11 @@ if [[ -n "$ALLOW_LIST_USERS" || -n "$WHITE_LIST_USERS" ]]; then ALLOW_LIST=true else ALLOW_LIST=false - rm allowlist.json + rm -f allowlist.json fi else ALLOW_LIST=false - rm allowlist.json + rm -f allowlist.json fi sed -i '/^white-list=.*/d' server.properties #Removes white-list= line from server.properties export ALLOW_LIST