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

Docker: Only switch user if the current user is root #7654

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 7 additions & 2 deletions besu/src/main/scripts/besu-entry.sh
Original file line number Diff line number Diff line change
Expand Up @@ -45,5 +45,10 @@ done
# Construct the command as a single string
COMMAND="/opt/besu/bin/besu $@"

# Switch to the besu user and execute the command
exec su -s /bin/bash $BESU_USER_NAME -c "$COMMAND"
# Check if current user is root
Copy link
Contributor

Choose a reason for hiding this comment

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

Make sense, and probably if not root we can skip the all the part that fixes path permission, so I suggest to move this check at the very beginning of the script and if root just exec Besu, otherwise run the rest of the script, wdyt?

FYI @pullurib

Copy link
Contributor

Choose a reason for hiding this comment

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

Yes, I agree, a check at very beginning of the script and if not root, just exec'ing Besu should be good.

if [ "$(id -u)" -eq 0 ]; then
# Switch to the besu user and execute the command
exec su -s /bin/bash "$BESU_USER_NAME" -c "$COMMAND"
else
exec /bin/bash -c "$COMMAND"
fi
Loading