diff options
| author | Ludovic Courtès <ludo@gnu.org> | 2025-03-25 17:41:57 +0100 |
|---|---|---|
| committer | Ludovic Courtès <ludo@gnu.org> | 2025-04-20 18:52:59 +0200 |
| commit | e2583b5a17bfdedc1d24b3bab2d752fbf8fa6db6 (patch) | |
| tree | 58437a302bea35fc2d8e2267e9b1ca0397eb2f0b /gnu/tests | |
| parent | 2c7c059e0b8f086979af070fe9c61fa793bb0e3f (diff) | |
services: guix: Allow ‘guix-daemon’ to run without root privileges.
* gnu/services/base.scm (run-with-writable-store)
(guix-ownership-change-program): New procedures.
(<guix-configuration>)[privileged?]: New field.
(guix-shepherd-service): Rename to…
(guix-shepherd-services): … this. Add the ‘guix-ownership’ service.
Change ‘guix-daemon’ service to depend on it; when unprivileged,
prefix ‘daemon-command’ by ‘run-with-writable-store’ and
omit ‘--build-users-group’; adjust socket activation endpoints.
(guix-accounts): When unprivileged, create the “guix-daemon” user and
group in addition to the others.
(guix-service-type)[extensions]: Adjust to name change.
* gnu/tests/base.scm (run-guix-daemon-test): Add ‘name’ parameter.
(%test-guix-daemon): Adjust accordingly.
(%test-guix-daemon-unprivileged): New test.
* doc/guix.texi (Base Services): Document ‘privileged?’.
(Migrating to the Unprivileged Daemon): Explain that this is automatic
on Guix System.
Reviewed-by: Maxim Cournoyer <maxim.cournoyer@gmail.com>
Change-Id: I28a9a22e617416c551dccb24e43a253b544ba163
Diffstat (limited to 'gnu/tests')
| -rw-r--r-- | gnu/tests/base.scm | 41 |
1 files changed, 36 insertions, 5 deletions
diff --git a/gnu/tests/base.scm b/gnu/tests/base.scm index 83e047f7e64..ef05e56e5f7 100644 --- a/gnu/tests/base.scm +++ b/gnu/tests/base.scm | |||
| @@ -1,5 +1,5 @@ | |||
| 1 | ;;; GNU Guix --- Functional package management for GNU | 1 | ;;; GNU Guix --- Functional package management for GNU |
| 2 | ;;; Copyright © 2016-2020, 2022, 2024 Ludovic Courtès <ludo@gnu.org> | 2 | ;;; Copyright © 2016-2020, 2022, 2024-2025 Ludovic Courtès <ludo@gnu.org> |
| 3 | ;;; Copyright © 2018 Clément Lassieur <clement@lassieur.org> | 3 | ;;; Copyright © 2018 Clément Lassieur <clement@lassieur.org> |
| 4 | ;;; Copyright © 2022 Maxim Cournoyer <maxim.cournoyer@gmail.com> | 4 | ;;; Copyright © 2022 Maxim Cournoyer <maxim.cournoyer@gmail.com> |
| 5 | ;;; Copyright © 2022 Marius Bakke <marius@gnu.org> | 5 | ;;; Copyright © 2022 Marius Bakke <marius@gnu.org> |
| @@ -63,7 +63,8 @@ | |||
| 63 | 63 | ||
| 64 | %hello-dependencies-manifest | 64 | %hello-dependencies-manifest |
| 65 | guix-daemon-test-cases | 65 | guix-daemon-test-cases |
| 66 | %test-guix-daemon)) | 66 | %test-guix-daemon |
| 67 | %test-guix-daemon-unprivileged)) | ||
| 67 | 68 | ||
| 68 | (define %simple-os | 69 | (define %simple-os |
| 69 | (simple-operating-system)) | 70 | (simple-operating-system)) |
| @@ -1121,7 +1122,7 @@ test." | |||
| 1121 | (system-error-errno args))) | 1122 | (system-error-errno args))) |
| 1122 | #$marionette)))) | 1123 | #$marionette)))) |
| 1123 | 1124 | ||
| 1124 | (define (run-guix-daemon-test os) | 1125 | (define (run-guix-daemon-test os name) |
| 1125 | (define test-image | 1126 | (define test-image |
| 1126 | (image (operating-system os) | 1127 | (image (operating-system os) |
| 1127 | (format 'compressed-qcow2) | 1128 | (format 'compressed-qcow2) |
| @@ -1168,7 +1169,7 @@ test." | |||
| 1168 | 1169 | ||
| 1169 | (test-end)))) | 1170 | (test-end)))) |
| 1170 | 1171 | ||
| 1171 | (gexp->derivation "guix-daemon-test" test)) | 1172 | (gexp->derivation name test)) |
| 1172 | 1173 | ||
| 1173 | (define %test-guix-daemon | 1174 | (define %test-guix-daemon |
| 1174 | (system-test | 1175 | (system-test |
| @@ -1190,4 +1191,34 @@ test." | |||
| 1190 | %base-user-accounts))) | 1191 | %base-user-accounts))) |
| 1191 | #:imported-modules '((gnu services herd) | 1192 | #:imported-modules '((gnu services herd) |
| 1192 | (guix combinators))))) | 1193 | (guix combinators))))) |
| 1193 | (run-guix-daemon-test os))))) | 1194 | (run-guix-daemon-test os "guix-daemon-test"))))) |
| 1195 | |||
| 1196 | (define %test-guix-daemon-unprivileged | ||
| 1197 | (system-test | ||
| 1198 | (name "guix-daemon-unprivileged") | ||
| 1199 | (description | ||
| 1200 | "Test 'guix-daemon' behavior on a multi-user system, where 'guix-daemon' | ||
| 1201 | runs unprivileged.") | ||
| 1202 | (value | ||
| 1203 | (let ((os (marionette-operating-system | ||
| 1204 | (let ((base (operating-system-with-gc-roots | ||
| 1205 | %daemon-os | ||
| 1206 | (list (profile | ||
| 1207 | (name "hello-build-dependencies") | ||
| 1208 | (content %hello-dependencies-manifest)))))) | ||
| 1209 | (operating-system | ||
| 1210 | (inherit base) | ||
| 1211 | (kernel-arguments '("console=ttyS0")) | ||
| 1212 | (users (cons (user-account | ||
| 1213 | (name "user") | ||
| 1214 | (group "users")) | ||
| 1215 | %base-user-accounts)) | ||
| 1216 | (services | ||
| 1217 | (modify-services (operating-system-user-services base) | ||
| 1218 | (guix-service-type | ||
| 1219 | config => (guix-configuration | ||
| 1220 | (inherit config) | ||
| 1221 | (privileged? #f))))))) | ||
| 1222 | #:imported-modules '((gnu services herd) | ||
| 1223 | (guix combinators))))) | ||
| 1224 | (run-guix-daemon-test os "guix-daemon-unprivileged-test"))))) | ||
