bug-guix
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

bug#24275: Misnamed directory in GuixSD


From: Ludovic Courtès
Subject: bug#24275: Misnamed directory in GuixSD
Date: Sun, 28 Aug 2016 01:32:01 +0200
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/24.5 (gnu/linux)

Hello!

What an embarrassing bug.  :-)

Vincent Legoll <address@hidden> skribis:

> I came with the attached patch, totally untested, probably wrong for some
> cases...
>
> The following is what I think I have implemented:
>
> At account creation time, do not create directories for system? accounts.
>
> At account modification, do not create directories, nor move existing ones,
> but change them in /etc/passwd
>
> WDYT ?

We currently lack a way to specify whether the home directory should be
created, which would be useful for ‘nobody’.

So what about a patch along these lines instead?  It adds a
‘create-home-directory?’ field to <user-account> and sets it to #f for
‘nobody’.

Thanks,
Ludo’.

diff --git a/gnu/build/activation.scm b/gnu/build/activation.scm
index 6666cb4..10aa58d 100644
--- a/gnu/build/activation.scm
+++ b/gnu/build/activation.scm
@@ -110,7 +110,8 @@ owner-writable in HOME."
               files)))
 
 (define* (add-user name group
-                   #:key uid comment home shell password system?
+                   #:key uid comment home create-home?
+                   shell password system?
                    (supplementary-groups '())
                    (log-port (current-error-port)))
   "Create an account for user NAME part of GROUP, with the specified
@@ -139,7 +140,7 @@ properties.  Return #t on success."
                           `("-G" ,(string-join supplementary-groups ","))
                           '())
                     ,@(if comment `("-c" ,comment) '())
-                    ,@(if home
+                    ,@(if (and home create-home?)
                           (if (file-exists? home)
                               `("-d" ,home)     ; avoid warning from 'useradd'
                               `("-d" ,home "--create-home"))
@@ -158,7 +159,8 @@ properties.  Return #t on success."
                #t)))))
 
 (define* (modify-user name group
-                      #:key uid comment home shell password system?
+                      #:key uid comment home create-home?
+                      shell password system?
                       (supplementary-groups '())
                       (log-port (current-error-port)))
   "Modify user account NAME to have all the given settings."
@@ -186,7 +188,8 @@ logged in."
   (zero? (system* "groupdel" name)))
 
 (define* (ensure-user name group
-                      #:key uid comment home shell password system?
+                      #:key uid comment home create-home?
+                      shell password system?
                       (supplementary-groups '())
                       (log-port (current-error-port))
                       #:rest rest)
@@ -207,7 +210,8 @@ numeric gid or #f."
 
   (define activate-user
     (match-lambda
-     ((name uid group supplementary-groups comment home shell password system?)
+     ((name uid group supplementary-groups comment home create-home?
+       shell password system?)
       (let ((profile-dir (string-append "/var/guix/profiles/per-user/"
                                         name)))
         (ensure-user name group
@@ -216,6 +220,7 @@ numeric gid or #f."
                      #:supplementary-groups supplementary-groups
                      #:comment comment
                      #:home home
+                     #:create-home? create-home?
                      #:shell shell
                      #:password password)
 
diff --git a/gnu/system/shadow.scm b/gnu/system/shadow.scm
index c394890..be08646 100644
--- a/gnu/system/shadow.scm
+++ b/gnu/system/shadow.scm
@@ -78,6 +78,8 @@
                         (default '()))            ; list of strings
   (comment        user-account-comment (default ""))
   (home-directory user-account-home-directory)
+  (create-home-directory? user-account-create-home-directory? ;Boolean
+                          (default #f))
   (shell          user-account-shell              ; gexp
                   (default #~(string-append #$bash "/bin/bash")))
   (system?        user-account-system?            ; Boolean
@@ -128,6 +130,7 @@
          (group "nogroup")
          (shell #~(string-append #$shadow "/sbin/nologin"))
          (home-directory "/nonexistent")
+         (create-home-directory? #f)
          (system? #t))))
 
 (define (default-skeletons)
@@ -255,6 +258,7 @@ of user '~a' is undeclared")
       #$(user-account-supplementary-groups account)
       #$(user-account-comment account)
       #$(user-account-home-directory account)
+      #$(user-account-create-home-directory? account)
       ,#$(user-account-shell account)             ; this one is a gexp
       #$(user-account-password account)
       #$(user-account-system? account)))

reply via email to

[Prev in Thread] Current Thread [Next in Thread]