Skip to content

Commit 0e667fe

Browse files
authored
Merge pull request #283 from HackAttack/disable-userns-remap-for-chown
Disable namespace remapping for chown cleanup
2 parents 0aaea30 + 1918632 commit 0e667fe

File tree

3 files changed

+7
-5
lines changed

3 files changed

+7
-5
lines changed

README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -355,6 +355,8 @@ Whether to `chown` the directory mounted with `mount-checkout` to the Buildkite
355355

356356
Prefer using `propagate-uid-gid` over this option, as the `chown`–which can take some time if your checkout is of considerable size—is likely not needed at all in that case.
357357

358+
**Security**: This option runs a container with [user namespace remapping disabled](https://docs.docker.com/reference/cli/docker/container/run/#userns).
359+
358360
Default: `false`
359361

360362
### `chown-image` (optional, string)

hooks/pre-exit

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,6 @@ if [[ "${BUILDKITE_PLUGIN_DOCKER_CLEANUP:-true}" =~ ^(true|on|1)$ ]] ; then
1414
fi
1515

1616
if ! is_windows && [[ "${BUILDKITE_PLUGIN_DOCKER_MOUNT_CHECKOUT:-true}" =~ ^(true|on|1)$ ]] && [[ "${BUILDKITE_PLUGIN_DOCKER_CHOWN:-false}" =~ ^(true|on|1)$ ]] ; then
17-
docker run --rm -v "$PWD":"$PWD" "${BUILDKITE_PLUGIN_DOCKER_CHOWN_IMAGE:-busybox}" chown -Rh "$(id -u):$(id -g)" "$PWD"
17+
docker run --rm -v "$PWD":"$PWD" --userns host "${BUILDKITE_PLUGIN_DOCKER_CHOWN_IMAGE:-busybox}" chown -Rh "$(id -u):$(id -g)" "$PWD"
1818
fi
1919

tests/pre-exit.bats

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ load "${BATS_PLUGIN_PATH}/load.bash"
66
export BUILDKITE_PLUGIN_DOCKER_CHOWN=true
77

88
stub docker \
9-
"run --rm -v $PWD:$PWD busybox chown -Rh $(id -u):$(id -g) $PWD : echo cleaned"
9+
"run --rm -v $PWD:$PWD --userns host busybox chown -Rh $(id -u):$(id -g) $PWD : echo cleaned"
1010

1111
run "$PWD"/hooks/pre-exit
1212

@@ -20,7 +20,7 @@ load "${BATS_PLUGIN_PATH}/load.bash"
2020
unset BUILDKITE_PLUGIN_DOCKER_CHOWN
2121

2222
stub docker \
23-
"run --rm -v $PWD:$PWD busybox chown -Rh $(id -u):$(id -g) $PWD : echo cleaned"
23+
"run --rm -v $PWD:$PWD --userns host busybox chown -Rh $(id -u):$(id -g) $PWD : echo cleaned"
2424

2525
run "$PWD"/hooks/pre-exit
2626

@@ -35,7 +35,7 @@ load "${BATS_PLUGIN_PATH}/load.bash"
3535
export BUILDKITE_PLUGIN_DOCKER_MOUNT_CHECKOUT=false
3636

3737
stub docker \
38-
"run --rm -v $PWD:$PWD busybox chown -Rh $(id -u):$(id -g) $PWD : echo cleaned"
38+
"run --rm -v $PWD:$PWD --userns host busybox chown -Rh $(id -u):$(id -g) $PWD : echo cleaned"
3939

4040
run "$PWD"/hooks/pre-exit
4141

@@ -50,7 +50,7 @@ load "${BATS_PLUGIN_PATH}/load.bash"
5050
export BUILDKITE_PLUGIN_DOCKER_CHOWN_IMAGE=some-image
5151

5252
stub docker \
53-
"run --rm -v $PWD:$PWD some-image chown -Rh $(id -u):$(id -g) $PWD : echo cleaned"
53+
"run --rm -v $PWD:$PWD --userns host some-image chown -Rh $(id -u):$(id -g) $PWD : echo cleaned"
5454

5555
run "$PWD"/hooks/pre-exit
5656

0 commit comments

Comments
 (0)