diff options
Diffstat (limited to 'gnu/system/shadow.scm')
| -rw-r--r-- | gnu/system/shadow.scm | 49 | 
1 files changed, 28 insertions, 21 deletions
| diff --git a/gnu/system/shadow.scm b/gnu/system/shadow.scm index 2cc0b89162..ca24c3df2b 100644 --- a/gnu/system/shadow.scm +++ b/gnu/system/shadow.scm @@ -23,6 +23,7 @@    #:use-module (guix monads)    #:use-module ((gnu packages system)                  #:select (shadow)) +  #:use-module (gnu packages bash)    #:use-module (srfi srfi-1)    #:use-module (ice-9 match)    #:export (user-account @@ -34,6 +35,7 @@              user-account-comment              user-account-home-directory              user-account-shell +            user-account-inputs              user-group              user-group? @@ -61,7 +63,9 @@    (gid            user-account-gid)    (comment        user-account-comment (default ""))    (home-directory user-account-home-directory) -  (shell          user-account-shell (default "/bin/sh"))) +  (shell          user-account-shell              ; monadic value +                  (default (package-file bash "bin/bash"))) +  (inputs         user-account-inputs (default `(("bash" ,bash)))))  (define-record-type* <user-group>    user-group make-user-group @@ -93,26 +97,29 @@  SHADOW? is true, then it is a /etc/shadow file, otherwise it is a /etc/passwd  file."    ;; XXX: The resulting file is world-readable, so beware when SHADOW? is #t! -  (define contents -    (let loop ((accounts accounts) -               (result   '())) -      (match accounts -        ((($ <user-account> name pass uid gid comment home-dir shell) -          rest ...) -         (loop rest -               (cons (if shadow? -                         (string-append name -                                        ":"       ; XXX: use (crypt PASS …)? -                                        ":::::::") -                         (string-append name -                                        ":" "x" -                                        ":" (number->string uid) -                                        ":" (number->string gid) -                                        ":" comment ":" home-dir ":" shell)) -                     result))) -        (() -         (string-join (reverse result) "\n" 'suffix))))) +  (define (contents) +    (with-monad %store-monad +      (let loop ((accounts accounts) +                 (result   '())) +        (match accounts +          ((($ <user-account> name pass uid gid comment home-dir mshell) +            rest ...) +           (mlet %store-monad ((shell mshell)) +             (loop rest +                   (cons (if shadow? +                             (string-append name +                                            ":"    ; XXX: use (crypt PASS …)? +                                            ":::::::") +                             (string-append name +                                            ":" "x" +                                            ":" (number->string uid) +                                            ":" (number->string gid) +                                            ":" comment ":" home-dir ":" shell)) +                         result)))) +          (() +           (return (string-join (reverse result) "\n" 'suffix))))))) -  (text-file (if shadow? "shadow" "passwd") contents)) +  (mlet %store-monad ((contents (contents))) +    (text-file (if shadow? "shadow" "passwd") contents)))  ;;; shadow.scm ends here | 
