File tree 3 files changed +40
-10
lines changed
3 files changed +40
-10
lines changed Original file line number Diff line number Diff line change @@ -296,16 +296,20 @@ else
296
296
args=" $args --volume $objdir :/checkout/obj"
297
297
args=" $args --volume $HOME /.cargo:/cargo"
298
298
args=" $args --volume /tmp/toolstate:/tmp/toolstate"
299
+ fi
299
300
300
- id=$( id -u)
301
- if [[ " $id " != 0 && " $( docker version) " =~ Podman ]]; then
302
- # Rootless podman creates a separate user namespace, where an inner
303
- # LOCAL_USER_ID will map to a different subuid range on the host.
304
- # The "keep-id" mode maps the current UID directly into the container.
305
- args=" $args --env NO_CHANGE_USER=1 --userns=keep-id"
306
- else
307
- args=" $args --env LOCAL_USER_ID=$id "
308
- fi
301
+ id=$( id -u)
302
+ if [[ " $id " != 0 && " $( docker version) " =~ Podman ]]; then
303
+ # Rootless podman creates a separate user namespace, where an inner
304
+ # LOCAL_USER_ID will map to a different subuid range on the host.
305
+ # The "keep-id" mode maps the current UID directly into the container.
306
+ args=" $args --env NO_CHANGE_USER=1 --userns=keep-id"
307
+ elif [[ " $id " != 0 ]]; then
308
+ args=" $args --env LOCAL_USER_ID=$id "
309
+ else
310
+ # We're running as root.
311
+ # We set the user id to `1001` instead of `0` to avoid running the container as root.
312
+ args=" $args --env LOCAL_USER_ID=1001"
309
313
fi
310
314
311
315
if [ " $dev " = " 1" ]
Original file line number Diff line number Diff line change @@ -309,7 +309,7 @@ auto:
309
309
<< : *job-linux-4c
310
310
311
311
- name : x86_64-gnu-distcheck
312
- << : *job-linux-8c
312
+ << : *job-linux-36c-codebuild
313
313
314
314
# The x86_64-gnu-llvm-20 job is split into multiple jobs to run tests in parallel.
315
315
# x86_64-gnu-llvm-20-1 skips tests that run in x86_64-gnu-llvm-20-{2,3}.
Original file line number Diff line number Diff line change 2
2
3
3
set -e
4
4
5
+ # Change ownership of the given path to the user if the filesystem is writable
6
+ change_ownership_if_writable () {
7
+ local path=$1
8
+ local owner=" user:user"
9
+ local current_owner
10
+ current_owner=$( stat -f " %Su:%Sg" " $path " 2> /dev/null)
11
+
12
+ local test_file=" $path /.write_test"
13
+ # Test if filesystem is writable by attempting to touch a temporary file
14
+ if touch " $test_file " 2> /dev/null; then
15
+ # We wrote the file just for testing. We can remove it now.
16
+ rm " $test_file "
17
+ if [ " $current_owner " != " $owner " ]; then
18
+ chown -R $owner " $path "
19
+ fi
20
+ else
21
+ echo " $path is read-only, skipping ownership change"
22
+ fi
23
+ }
24
+
5
25
if [ -n " $CI_JOB_NAME " ]; then
6
26
echo " [CI_JOB_NAME=$CI_JOB_NAME ]"
7
27
fi
@@ -16,6 +36,12 @@ if [ "$NO_CHANGE_USER" = "" ]; then
16
36
export HOME=/home/user
17
37
unset LOCAL_USER_ID
18
38
39
+ # Give ownership of necessary directories to the user
40
+ change_ownership_if_writable .
41
+ mkdir -p /cargo
42
+ change_ownership_if_writable /cargo
43
+ change_ownership_if_writable /checkout
44
+
19
45
# Ensure that runners are able to execute git commands in the worktree,
20
46
# overriding the typical git protections. In our docker container we're running
21
47
# as root, while the user owning the checkout is not root.
You can’t perform that action at this time.
0 commit comments