mirror of
https://git.in.rschanz.org/ryan77627/guix.git
synced 2024-12-25 05:48:07 -05:00
gnu: vm: Create shadow files with the right format.
* gnu/system/vm.scm (passwd-file): When SHADOW? is true, use the right shadow(5) format. Always add a trailing newline.
This commit is contained in:
parent
37c825eb79
commit
3b07625ad6
1 changed files with 11 additions and 7 deletions
|
@ -367,21 +367,25 @@ (define* (passwd-file store accounts #:key shadow?)
|
||||||
"Return a password file for ACCOUNTS, a list of vectors as returned by
|
"Return a password file for ACCOUNTS, a list of vectors as returned by
|
||||||
'getpwnam'. If SHADOW? is true, then it is a /etc/shadow file, otherwise it
|
'getpwnam'. If SHADOW? is true, then it is a /etc/shadow file, otherwise it
|
||||||
is a /etc/passwd file."
|
is a /etc/passwd file."
|
||||||
;; XXX: The resulting file is world-readable, so don't rely on it!
|
;; XXX: The resulting file is world-readable, so beware when SHADOW? is #t!
|
||||||
(define contents
|
(define contents
|
||||||
(let loop ((accounts accounts)
|
(let loop ((accounts accounts)
|
||||||
(result '()))
|
(result '()))
|
||||||
(match accounts
|
(match accounts
|
||||||
((#(name pass uid gid comment home-dir shell) rest ...)
|
((#(name pass uid gid comment home-dir shell) rest ...)
|
||||||
(loop rest
|
(loop rest
|
||||||
(cons (string-append name
|
(cons (if shadow?
|
||||||
":" (if shadow? pass "x")
|
(string-append name
|
||||||
|
":" ; XXX: use (crypt PASS …)?
|
||||||
|
":::::::")
|
||||||
|
(string-append name
|
||||||
|
":" "x"
|
||||||
":" (number->string uid)
|
":" (number->string uid)
|
||||||
":" (number->string gid)
|
":" (number->string gid)
|
||||||
":" comment ":" home-dir ":" shell)
|
":" comment ":" home-dir ":" shell))
|
||||||
result)))
|
result)))
|
||||||
(()
|
(()
|
||||||
(string-concatenate-reverse result)))))
|
(string-join (reverse result) "\n" 'suffix)))))
|
||||||
|
|
||||||
(add-text-to-store store (if shadow? "shadow" "passwd")
|
(add-text-to-store store (if shadow? "shadow" "passwd")
|
||||||
contents '()))
|
contents '()))
|
||||||
|
|
Loading…
Reference in a new issue