From 8c83d8cebc3b440a523e714e652b266f7c37b380 Mon Sep 17 00:00:00 2001 From: Vincent Legoll Date: Tue, 23 Aug 2016 12:37:57 +0200 Subject: [PATCH] Avoid creating system-user's home directories * gnu/build/activation.scm (modify-user): pass -d to usermod command (add-user): add system? condition to home dir creation. Signed-off-by: Vincent Legoll --- gnu/build/activation.scm | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/gnu/build/activation.scm b/gnu/build/activation.scm index 6666cb4..c0f54ae 100644 --- a/gnu/build/activation.scm +++ b/gnu/build/activation.scm @@ -140,9 +140,13 @@ properties. Return #t on success." '()) ,@(if comment `("-c" ,comment) '()) ,@(if home - (if (file-exists? home) - `("-d" ,home) ; avoid warning from 'useradd' - `("-d" ,home "--create-home")) + ;; system? accounts may have non existent home + ;; directories (for example, user nobody) + (if system? + `("-d" ,home) + (if (file-exists? home) + `("-d" ,home) ; avoid warning from 'useradd' + `("-d" ,home "--create-home"))) '()) ,@(if shell `("-s" ,shell) '()) ,@(if password `("-p" ,password) '()) @@ -169,7 +173,10 @@ properties. Return #t on success." `("-G" ,(string-join supplementary-groups ",")) '()) ,@(if comment `("-c" ,comment) '()) - ;; Don't use '--move-home', so ignore HOME. + ;; The home directory could have changed, but may be a + ;; nonexistent one, so don't use '--move-home'. Manually + ;; cleaning things up may be needed in such a case + ,@(if home `("-d" ,home) '()) ,@(if shell `("-s" ,shell) '()) ,name))) (zero? (apply system* "usermod" args)))) -- 1.9.1