diff options
author | Pau Espin Pedrol <pespin@sysmocom.de> | 2024-05-15 20:10:01 +0200 |
---|---|---|
committer | Pau Espin Pedrol <pespin@sysmocom.de> | 2024-05-15 20:25:01 +0200 |
commit | 2b9c8e3db8cf77c5ce5c3f888365f983f3ee8d76 (patch) | |
tree | 1a4e5c502501171f1c22fd9e3a9158439b523f65 | |
parent | f9c8ed8de78b7f6641c9802be2d0cdd2488295fb (diff) |
ttcn3-docker-run.sh: Fix dumpcap failing to access /data inside docker
In docker, the /data dir is mapped to $VOL_BASE_DIR, which is created by
docker-playground.git jenkins-common.sh, hence as the user running
jenkins.sh in the host system.
As a result, when the dir is mapped to /data, inside the container it
will have the UID:GID of the outter user, not the one inside docker.
Before this patch, if a ttcn3 container was started in jenkins.sh with
--cap-add=NET_ADMIN, then osmo-ttcn3-hacks.git/ttcn3-tcpdump-start.sh
would select dumpcap instead of tcpdump, to attempt to record a pcap
file to /data/$testcase.pcap.
Due to some unknown way of dropping privileges done by dumpcap though,
it was unable to open the /data/$testcase.pcap due to /data being owned
to another user (tcpdump doesn't have this problem).
This patch fixes the above scenario by making sure /data is chowned to
the user running stuff inside docker. This is already kinda expected
since there's a fix_perms() script in jenkins-common.sh reverting files
created during the test so that they can be accessible by outter user
once everything is finished.
Change-Id: I1229a91cdbb1aa73fd94f1bf7e26f34086f06b25
-rwxr-xr-x | common/ttcn3-docker-run.sh | 3 |
1 files changed, 3 insertions, 0 deletions
diff --git a/common/ttcn3-docker-run.sh b/common/ttcn3-docker-run.sh index c8c871e..60339c4 100755 --- a/common/ttcn3-docker-run.sh +++ b/common/ttcn3-docker-run.sh @@ -31,6 +31,9 @@ if [ -n "$WAIT_FOR_NETDEV" ]; then done fi +# Make sure /data is owned to the user running inside docker. +# jenkins-commons.sh fix_perms() will fix back the permissions once done. +chown -R "$(id -u):$(id -g)" /data cd /data # Use TEST_NAME to only run one test instead of all. Set it like this: |