summaryrefslogtreecommitdiff
path: root/gnu
diff options
context:
space:
mode:
authorLudovic Courtès <ludo@gnu.org>2017-05-18 10:08:55 +0200
committerLudovic Courtès <ludo@gnu.org>2017-05-20 10:17:10 +0200
commit51fe9cd38d4d64b5fade8a899d5323da0e217d5c (patch)
tree27dd58ab42b8517bb2a0805dff813bec40b9a060 /gnu
parentf3f8938fe0c07d221ebccdf5a9a0029fda01f036 (diff)
services: user-homes: Do not create home directories marked as no-create.
Fixes a bug whereby GuixSD would create the /nonexistent directory, from user 'nobody', even though it has 'create-home-directory?' set to #f. * gnu/build/activation.scm (activate-users+groups): Add comment for \#:create-home?. (activate-user-home)[ensure-user-home]: Skip when CREATE-HOME? is #f or SYSTEM? is #t. * gnu/tests/base.scm (run-basic-test)["no extra home directories"]: New tests.
Diffstat (limited to 'gnu')
-rw-r--r--gnu/build/activation.scm9
-rw-r--r--gnu/tests/base.scm22
2 files changed, 30 insertions, 1 deletions
diff --git a/gnu/build/activation.scm b/gnu/build/activation.scm
index beee56d4379..a1d2a9cc7d1 100644
--- a/gnu/build/activation.scm
+++ b/gnu/build/activation.scm
@@ -227,7 +227,11 @@ numeric gid or #f."
227 #:supplementary-groups supplementary-groups 227 #:supplementary-groups supplementary-groups
228 #:comment comment 228 #:comment comment
229 #:home home 229 #:home home
230
231 ;; Home directories of non-system accounts are created by
232 ;; 'activate-user-home'.
230 #:create-home? (and create-home? system?) 233 #:create-home? (and create-home? system?)
234
231 #:shell shell 235 #:shell shell
232 #:password password) 236 #:password password)
233 237
@@ -282,7 +286,10 @@ they already exist."
282 (match-lambda 286 (match-lambda
283 ((name uid group supplementary-groups comment home create-home? 287 ((name uid group supplementary-groups comment home create-home?
284 shell password system?) 288 shell password system?)
285 (unless (or (not home) (directory-exists? home)) 289 ;; The home directories of system accounts are created during
290 ;; activation, not here.
291 (unless (or (not home) (not create-home?) system?
292 (directory-exists? home))
286 (let* ((pw (getpwnam name)) 293 (let* ((pw (getpwnam name))
287 (uid (passwd:uid pw)) 294 (uid (passwd:uid pw))
288 (gid (passwd:gid pw))) 295 (gid (passwd:gid pw)))
diff --git a/gnu/tests/base.scm b/gnu/tests/base.scm
index 37aab8ef674..e5ac320b740 100644
--- a/gnu/tests/base.scm
+++ b/gnu/tests/base.scm
@@ -199,6 +199,28 @@ info --version")
199 ',users+homes)) 199 ',users+homes))
200 marionette))) 200 marionette)))
201 201
202 (test-equal "no extra home directories"
203 '()
204
205 ;; Make sure the home directories that are not supposed to be
206 ;; created are indeed not created.
207 (let ((nonexistent
208 '#$(filter-map (lambda (user)
209 (and (not
210 (user-account-create-home-directory?
211 user))
212 (user-account-home-directory user)))
213 (operating-system-user-accounts os))))
214 (marionette-eval
215 `(begin
216 (use-modules (srfi srfi-1))
217
218 ;; Note: Do not flag "/var/empty".
219 (filter file-exists?
220 ',(remove (cut string-prefix? "/var/" <>)
221 nonexistent)))
222 marionette)))
223
202 (test-equal "login on tty1" 224 (test-equal "login on tty1"
203 "root\n" 225 "root\n"
204 (begin 226 (begin