Skip to content

Commit

Permalink
make root user check at the beginning
Browse files Browse the repository at this point in the history
Signed-off-by: Rafael Matias <rafael@skyle.net>
  • Loading branch information
skylenet committed Sep 23, 2024
1 parent 57ca378 commit 96dcb6e
Showing 1 changed file with 10 additions and 11 deletions.
21 changes: 10 additions & 11 deletions besu/src/main/scripts/besu-entry.sh
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,14 @@
## SPDX-License-Identifier: Apache-2.0
##

# Construct the command as a single string
COMMAND="/opt/besu/bin/besu $@"

# Check if current user is not root. If not, run the command as is.
if [ "$(id -u)" -ne 0 ]; then
exec /bin/bash -c "$COMMAND"
fi

# Run Besu first to get paths needing permission adjustment
output=$(/opt/besu/bin/besu --print-paths-and-exit $BESU_USER_NAME "$@")

Expand Down Expand Up @@ -41,14 +49,5 @@ echo "$output" | while IFS=: read -r prefix path accessType; do
fi
done

# Finally, run Besu with the actual arguments passed to the container
# Construct the command as a single string
COMMAND="/opt/besu/bin/besu $@"

# Check if current user is root
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
# Switch to the besu user and execute the command
exec su -s /bin/bash "$BESU_USER_NAME" -c "$COMMAND"

0 comments on commit 96dcb6e

Please sign in to comment.