Skip to content

Commit 6b0a55e

Browse files
gentoo-rootaanm
authored andcommitted
contrib: Temporary workaround to run as root
Renovate bot attempts to run make and builder.sh as root and fails [1]. Since commit 2b8a914 ("contrib: Fix UID != 1000 in builder.sh"), running builder.sh as root is not supported, and it attempts to match the UID in the container with the host UID. Commit 74b5841 ("contrib: Remove RUN_AS_ROOT from builder.sh") removed the RUN_AS_ROOT option and fixed the workflows that used it, but Renovate still tries to run commands as root. This is insecure and should be fixed on Renovate side, but in the meanwhile allow running builder.sh as root with a prominent warning. Note that the host cache directories are mounted under /home/ubuntu, and the root user in the container will not use them in this mode. This mode should be prohibited, once Renovate workflows are fixed. [1]: cilium#45389 (comment) Signed-off-by: Alice Mikityanska <alice@isovalent.com>
1 parent 61cee0a commit 6b0a55e

1 file changed

Lines changed: 7 additions & 0 deletions

File tree

contrib/scripts/builder.sh

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,13 @@ set -u # End workaround for macOS and BASH 3.2.
6262
trap 'docker rm -f "$CONTAINER"' EXIT
6363
docker start "$CONTAINER"
6464

65+
if [ "$USERID" -eq 0 ] || [ "$GROUPID" -eq 0 ]; then
66+
echo "WARNING: Running with root permissions is discouraged, not supported and insecure!" 1>&2
67+
echo "Go cache dirs and ccache dir will be mounted at wrong locations. Don't run as root." 1>&2
68+
docker exec ${DOCKER_ARGS:+$DOCKER_ARGS} "$CONTAINER" "$@"
69+
exit "$?"
70+
fi
71+
6572
EXISTING_GROUP=$(docker exec "$CONTAINER" getent group "$GROUPID" || :)
6673
if [ -n "$EXISTING_GROUP" ] && [ "${EXISTING_GROUP%%:*}" != "ubuntu" ]; then
6774
echo "Group exists in the container, trying to reassign ID: $EXISTING_GROUP"

0 commit comments

Comments
 (0)