summaryrefslogtreecommitdiff
path: root/gnu/tests
diff options
context:
space:
mode:
authorLudovic Courtès <ludo@gnu.org>2025-06-06 16:00:15 +0200
committerLudovic Courtès <ludo@gnu.org>2025-10-21 16:52:30 +0200
commit633ed510fa733861cd4b717c5a4e34bf5be7ef8e (patch)
tree5392702ff88214099139c6052317f02edb7f1eff /gnu/tests
parentab01e5adb21810f865c6e13e91a6d1ffc349d943 (diff)
tests: guix-daemon: Check that build processes can chown to “kvm”.
* gnu/tests/base.scm (guix-daemon-test-cases)[chown-snippet]: New variable. ["kvm GID mapped"]: New test. Change-Id: I0ce7a9250539766628eb2459d60abce7c05a36ee
Diffstat (limited to 'gnu/tests')
-rw-r--r--gnu/tests/base.scm37
1 files changed, 37 insertions, 0 deletions
diff --git a/gnu/tests/base.scm b/gnu/tests/base.scm
index f96d781b523..659b754802f 100644
--- a/gnu/tests/base.scm
+++ b/gnu/tests/base.scm
@@ -1116,6 +1116,32 @@ non-ASCII names from /tmp.")
1116evaluated in MARIONETTE, a gexp denoting a marionette (system under test). 1116evaluated in MARIONETTE, a gexp denoting a marionette (system under test).
1117Assume that an unprivileged account for 'user' exists on the system under 1117Assume that an unprivileged account for 'user' exists on the system under
1118test." 1118test."
1119 (define chown-snippet
1120 ;; XXX: This snippet exists primarily so that #$output is understood in
1121 ;; the right context.
1122 '(object->string
1123 `(begin
1124 (use-modules (guix)
1125 (gnu packages bootstrap))
1126 (computed-file "chown-to-supplementary-group"
1127 #~(begin
1128 (use-modules (srfi srfi-1))
1129
1130 ',(gettimeofday) ;nonce
1131 (let* ((groups (getgroups))
1132 (other (find (lambda (gid)
1133 (not (= gid (getgid))))
1134 (vector->list groups))))
1135 (format #t "attempting to chown \
1136to supplementary group ~a...~%" other)
1137 (pk 'supplementary-groups (getgroups)
1138 'gid (getgid) 'other other)
1139 (force-output)
1140 (mkdir "test")
1141 (chown "test" (getuid) other)
1142 (mkdir #$output)))
1143 #:guile %bootstrap-guile))))
1144
1119 #~(begin 1145 #~(begin
1120 (test-equal "guix describe" 1146 (test-equal "guix describe"
1121 0 1147 0
@@ -1143,6 +1169,17 @@ test."
1143 hello)) 1169 hello))
1144 #$marionette)) 1170 #$marionette))
1145 1171
1172 (test-equal "kvm GID mapped"
1173 0
1174 ;; The "kvm" group should be among the supplementary groups of the
1175 ;; build user. Try to chown a file to that group; this fails with
1176 ;; EINVAL when running the unprivileged guix-daemon and the "kvm" GID
1177 ;; is not mapped in its user namespace. See
1178 ;; <https://bugs.gnu.org/77862>.
1179 (marionette-eval
1180 '(system* "guix" "build" "--no-grafts" "-e" #$chown-snippet)
1181 #$marionette))
1182
1146 (test-equal "guix install hello" 1183 (test-equal "guix install hello"
1147 0 1184 0
1148 ;; Check that ~/.guix-profile & co. are properly created. 1185 ;; Check that ~/.guix-profile & co. are properly created.