Skip to contentSkip to conversation

gitlab-ci: Run ninja test as non-root

PATCH In review Arkadiusz Hiler via igt-dev 1 participant 2 messages Feb 12, 2019

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 gitlab-ci: Run ninja test as non-root

igt_command_line.sh now fails if it is run as root, which breaks 'ninja test' in GitLab's CI with our current setup.

There's no convenient means of switching users yet:
- USER in Dockerfile file won't do it, we would lack permissions for the src
- each line of script is execute separately, so no setuid()
- no facilities for juggling users in the gitlab-runner itself

So will just useradd && chmod && su -c "ninja test" in the testing steps. At least for now.

Cc Daniel Vetter <[email protected]>
Cc Petri Latvala <[email protected]>
---
 .gitlab-ci.yml | 9 +++++++--
 1 file changed, 7 insertions(+), 2 deletions(-)
.gitlab-ci.yml +7 -2
index 4bd4130f..08e8e6cc 100644
@@ -86,7 +86,10 @@ test:ninja-test:
   dependencies:
     - build:tests-fedora
   stage: test
-  script: ninja -C build test
+  script:
+    - useradd igt
+    - chown -R igt:igt build
+    - su igt -c "ninja -C build test"
 
 test:ninja-test-arm64:
   image: $CI_REGISTRY/$CI_PROJECT_PATH/igt-debian-arm64:latest
@@ -96,7 +99,9 @@ test:ninja-test-arm64:
   script:
     - export PKG_CONFIG_PATH=/usr/lib/aarch64-linux-gnu/pkgconfig/
     - env > build/envdump.txt
-    - ninja -C build test
+    - useradd igt
+    - chown -R igt:igt build
+    - su igt -c "ninja -C build test"
   artifacts:
     paths:
       - build
Signature · 6 lines
2.20.1

_______________________________________________
igt-dev mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/igt-dev
#1 lore raw
Quoted 8 lines · Arkadiusz Hiler via igt-dev

igt_command_line.sh now fails if it is run as root, which breaks 'ninja test' in GitLab's CI with our current setup.

There's no convenient means of switching users yet:
- USER in Dockerfile file won't do it, we would lack permissions for the src
- each line of script is execute separately, so no setuid()
- no facilities for juggling users in the gitlab-runner itself

Quoted 6 lines

So will just useradd && chmod && su -c "ninja test" in the testing steps. At least for now.

Cc Daniel Vetter <[email protected]>
Cc Petri Latvala <[email protected]>

Tested in my fork:
https://gitlab.freedesktop.org/ivyl/igt/pipelines/18748

I'll cancel i915 CI's run over this, no need to waste machine time.

Signature · 7 lines
Cheers,
Arek

_______________________________________________
igt-dev mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/igt-dev