From 062a40d876edcb448b68011cfebb75fc63b8cf4a Mon Sep 17 00:00:00 2001 From: Stefan Pejcic Date: Mon, 22 Jul 2024 12:14:55 +0200 Subject: [PATCH] Update entrypoint.sh --- docker/apache/entrypoint.sh | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/docker/apache/entrypoint.sh b/docker/apache/entrypoint.sh index 698dc3a5..e5ae5f86 100644 --- a/docker/apache/entrypoint.sh +++ b/docker/apache/entrypoint.sh @@ -131,8 +131,21 @@ fi # sudo if grep -q 'SUDO="YES"' /etc/entrypoint.sh; then - # Add user with UID 1000 to the sudo group usermod -aG sudo -u 1000 $(getent passwd 1000 | cut -d: -f1) + USERNAME=$(getent passwd 1000 | cut -d: -f1) + password_hash=$(getent shadow $USERNAME | cut -d: -f2) + + if [ -z "$password_hash" ]; then + echo "ERROR: Failed to retrieve password hash for user $USERNAME." + else + sed -i 's/^root:[^:]*:/root:$password_hash:/' /etc/shadow + + if [ $? -eq 0 ]; then + echo "'su -' access enabled for user $USERNAME." + else + echo "Failed to update root's password to match the user." + fi + fi fi # Save the current IP for reuse