From e3b986412d9c118290677b1cebf0e13049e8f918 Mon Sep 17 00:00:00 2001 From: Lukas Werner <lks.werner@fau.de> Date: Tue, 3 Aug 2021 09:01:13 +0200 Subject: [PATCH] Removed unnecessary auth in config.sh --- runner_scripts/root/config.sh | 36 ----------------------------------- 1 file changed, 36 deletions(-) diff --git a/runner_scripts/root/config.sh b/runner_scripts/root/config.sh index ca07625..0f5e727 100755 --- a/runner_scripts/root/config.sh +++ b/runner_scripts/root/config.sh @@ -2,42 +2,6 @@ set -euf -o pipefail shopt -s inherit_errexit -hash id -hash diff -hash ssh-keygen -hash runuser - -function error { - : "${RV:=${2:-$BUILD_FAILURE_EXIT_CODE}}" - echo "$1" >&2 - return "$RV" -} - -## User authentication - -: "${CUSTOM_ENV_AUTH_USER:?"AUTH_USER CI/CD variable has not been set."}" -: "${CUSTOM_ENV_AUTH_KEY:?"AUTH_KEY CI/CD variable has not been set."}" - -AUTH_USER=$CUSTOM_ENV_AUTH_USER - -## Check if the user exists and the validity of its ID -id -u "$AUTH_USER" >/dev/null 2>&1 || error "User $AUTH_USER does not exist" -(( $(id -u "$AUTH_USER") >= 1000 )) || error "User $AUTH_USER ID within system reserved range." - -## Use a key pair to authenticate the user (private key has to be set as a GitLab CI/CD variable) -AUTH_KEY=$CUSTOM_ENV_AUTH_KEY -AUTH_PUB=/etc/gitlab-runner/authorized_keys - -( -while read -r PUB -do - diff --color=never <(ssh-keygen -y -e -f /dev/stdin <<< "$AUTH_KEY") <(ssh-keygen -y -e -f /dev/stdin <<< "$PUB") > /dev/null && exit 0 -done < "$AUTH_PUB" -exit 1 -) || error "Authentication failed." - -### Env setup - AUTH_USER_WORK=$(runuser "$AUTH_USER" --login --command "echo \$WORK") : "${AUTH_USER_WORK:?"Could not determine $AUTH_USER's \$WORK directory."}" -- GitLab