Skip to content

Commit

Permalink
Merge bitcoin#27376: ci: Remove second user account
Browse files Browse the repository at this point in the history
fafe3a8 ci: Remove second user account (MarcoFalke)

Pull request description:

  The rationale for the second (nonroot) account no longer applies. See also bitcoin#27333 (comment)

ACKs for top commit:
  josibake:
    utACK bitcoin@fafe3a8

Tree-SHA512: 4464e50bc6499e012ff33c591f20c5989b99e223c476cefea669aedb79a0e731734db9469d4c7d800642191b43b57ea32cda187093395f100dec719fea17724d
  • Loading branch information
fanquake committed Mar 31, 2023
2 parents 47184cf + fafe3a8 commit 5c2bb2b
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 22 deletions.
24 changes: 3 additions & 21 deletions ci/test/04_install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -28,11 +28,6 @@ export BINS_SCRATCH_DIR="${BASE_SCRATCH_DIR}/bins/"

if [ -z "$DANGER_RUN_CI_ON_HOST" ]; then
echo "Creating $CI_IMAGE_NAME_TAG container to run in"
LOCAL_UID=$(id -u)
LOCAL_GID=$(id -g)

# the name isn't important, so long as we use the same UID
LOCAL_USER=nonroot
DOCKER_BUILDKIT=1 ${CI_RETRY_EXE} docker build \
--file "${BASE_ROOT_DIR}/ci/test_imagefile" \
--build-arg "CI_IMAGE_NAME_TAG=${CI_IMAGE_NAME_TAG}" \
Expand All @@ -59,18 +54,9 @@ if [ -z "$DANGER_RUN_CI_ON_HOST" ]; then
--name $CONTAINER_NAME \
$CONTAINER_NAME)
export CI_CONTAINER_ID
export CI_EXEC_CMD_PREFIX_ROOT="docker exec -u 0 $CI_CONTAINER_ID"
export CI_EXEC_CMD_PREFIX="docker exec -u $LOCAL_UID $CI_CONTAINER_ID"
$CI_EXEC_CMD_PREFIX_ROOT rsync --archive --stats --human-readable /ci_base_install/ "${BASE_ROOT_DIR}"
$CI_EXEC_CMD_PREFIX_ROOT rsync --archive --stats --human-readable /ro_base/ "$BASE_ROOT_DIR"

# Create a non-root user inside the container which matches the local user.
#
# This prevents the root user in the container modifying the local file system permissions
# on the mounted directories
docker exec "$CI_CONTAINER_ID" useradd -u "$LOCAL_UID" -o -m "$LOCAL_USER"
docker exec "$CI_CONTAINER_ID" groupmod -o -g "$LOCAL_GID" "$LOCAL_USER"
docker exec "$CI_CONTAINER_ID" chown -R "$LOCAL_USER":"$LOCAL_USER" "${BASE_ROOT_DIR}"
export CI_EXEC_CMD_PREFIX="docker exec ${CI_CONTAINER_ID}"
$CI_EXEC_CMD_PREFIX rsync --archive --stats --human-readable /ci_base_install/ "${BASE_ROOT_DIR}"
$CI_EXEC_CMD_PREFIX rsync --archive --stats --human-readable /ro_base/ "$BASE_ROOT_DIR"
else
echo "Running on host system without docker wrapper"
"${BASE_ROOT_DIR}/ci/test/01_base_install.sh"
Expand All @@ -79,11 +65,7 @@ fi
CI_EXEC () {
$CI_EXEC_CMD_PREFIX bash -c "export PATH=${BINS_SCRATCH_DIR}:\$PATH && cd \"$P_CI_DIR\" && $*"
}
CI_EXEC_ROOT () {
$CI_EXEC_CMD_PREFIX_ROOT bash -c "export PATH=${BINS_SCRATCH_DIR}:\$PATH && cd \"$P_CI_DIR\" && $*"
}
export -f CI_EXEC
export -f CI_EXEC_ROOT

CI_EXEC mkdir -p "${BINS_SCRATCH_DIR}"

Expand Down
1 change: 0 additions & 1 deletion ci/test/05_before_script.sh
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ if [ "$CI_OS_NAME" == "macos" ]; then
echo > "${HOME}/Library/Application Support/Bitcoin"
else
CI_EXEC echo \> \$HOME/.bitcoin
CI_EXEC_ROOT echo \> \$HOME/.bitcoin
fi

if [ -z "$NO_DEPENDS" ]; then
Expand Down

0 comments on commit 5c2bb2b

Please sign in to comment.