Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Updates to Allow/White List handling #359

Merged
merged 4 commits into from
Oct 20, 2023
Merged

Updates to Allow/White List handling #359

merged 4 commits into from
Oct 20, 2023

Conversation

drardin
Copy link
Contributor

@drardin drardin commented Oct 18, 2023

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.

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.
@itzg
Copy link
Owner

itzg commented Oct 18, 2023

Can you read through #336 and make sure your proposed change doesn't introduce a regression? I feel like your proposed change was already attempted and it helped half the people and hindered the other half. If you found the winning combo, then this will be awesome.

@itzg
Copy link
Owner

itzg commented Oct 18, 2023

...white-list probably needs to be removed from any existing server.properties file. Probably also good to remove it from property-definitions.json.

@drardin
Copy link
Contributor Author

drardin commented Oct 18, 2023

...white-list probably needs to be removed from any existing server.properties file.

I've manually removed the white-list=false line from server.properties but it gets reintroduced any time ALLOW_LIST_USERS or WHITE_LIST_USERS env variables are set. I'm reviewing #336 now as well.

@drardin
Copy link
Contributor Author

drardin commented Oct 18, 2023

I can't seem to reproduce the expected behavior of unsetting allow-list in server.properties or the removal of allowlist.json from /data with the omission of ALLOW_LIST_USERS || WHITE_LIST_USERS env variables and I suspect it's because the way rm -f allowlist.json and ALLOW_LIST=false are nested. Let me review my proposed changes and modify this as well.

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.
@drardin
Copy link
Contributor Author

drardin commented Oct 18, 2023

I've updated my original commit to include handling of the WHITE_LIST_USERS env variables, to not break existing installs where it's employed. One change I've made is that a boolean value is set only for ALLOW_USERS, which I feel is sufficient and shouldn't introduce any regression.

I've done testing in a local environment and this commit behaves as you'd expect. Additionally, it should address #336 which I believe was a result of the allowlist.json not being removed or regenerated with env variable changes.

@drardin
Copy link
Contributor Author

drardin commented Oct 18, 2023

Not sure how to rectify any existing server.properties files out there that have a white-list=false line at the end. I suppose we could reference a skeleton server.properties file and rebuild it on startup. This would require mapping every value to an environmental variable though. Thoughts?

@itzg
Copy link
Owner

itzg commented Oct 18, 2023

Not sure how to rectify any existing server.properties files out there that have a white-list=false line at the end. I suppose we could reference a skeleton server.properties file and rebuild it on startup. This would require mapping every value to an environmental variable though. Thoughts?

It's important to solve this. That's the gap I had left in my previous attempts. Maybe I could follow up to your PR with merging #351

Or just grep -v it out of the file.

@drardin
Copy link
Contributor Author

drardin commented Oct 18, 2023

I think we can use sed to remove any existing white-list value from server.properties. I can look at this more later.

Also, I've confirmed that my commit is working as expected with removing / generating the allowlist.json file and setting allow-list in server.properties but I am also using absolute paths to these files in my testing (/data/allowlist.json and /data/server.proeprties)

@itzg
Copy link
Owner

itzg commented Oct 18, 2023

sed is a good choice -- I used that a lot for the Java edition image before switching to the mc-image-helper tool.

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.
@drardin
Copy link
Contributor Author

drardin commented Oct 18, 2023

I've updated the code to include an implementation of sed that will remove any line that begins with "white-list" from server.properties, regardless of if the ALLOW_LIST_USERS or WHITE_LIST_USERS is set, as it's outside of the block that checks those variables.

Users will still be able to use both of these env variables which both ultimately export a Boolean value for ALLOW_LIST, which is confirmed to update server.properties file. With the removal of the white-list entry, conflicting values in server.properties should not be an issue.

Please review and let me know your thoughts.

@drardin drardin changed the title Update bedrock-entry.sh Updates to Allow/White List handling Oct 18, 2023
Copy link
Owner

@itzg itzg left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

One last little tweak and it's good to merge.

bedrock-entry.sh Outdated
ALLOW_LIST=false
rm allowlist.json
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just in case the file isn't present

Suggested change
rm allowlist.json
rm -f allowlist.json

bedrock-entry.sh Outdated
export WHITE_LIST ALLOW_LIST
else
ALLOW_LIST=false
rm allowlist.json
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

and here

@drardin
Copy link
Contributor Author

drardin commented Oct 20, 2023

Should be ready now. Thanks for pointing that out

@itzg itzg merged commit db8546e into itzg:master Oct 20, 2023
1 check passed
@drardin drardin deleted the patch-1 branch October 20, 2023 04:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants