mirror of
https://git.in.rschanz.org/ryan77627/guix.git
synced 2024-11-07 07:26:13 -05:00
accounts: Delete duplicate entries.
When adding multiple instances of a service requiring some user account/group, we could end up with multiple entries for that account or group in /etc/passwd or /etc/group. * gnu/build/accounts.scm (database-writer)[write-entries]: Add call to 'delete-duplicates'. * tests/accounts.scm ("write-passwd with duplicate entry"): New test.
This commit is contained in:
parent
114f02bac4
commit
dd4e46edda
2 changed files with 20 additions and 1 deletions
|
@ -238,7 +238,7 @@ (define (write-entries port)
|
|||
(for-each (lambda (entry)
|
||||
(display (entry->string entry) port)
|
||||
(newline port))
|
||||
entries))
|
||||
(delete-duplicates entries)))
|
||||
|
||||
(if (port? file-or-port)
|
||||
(write-entries file-or-port)
|
||||
|
|
|
@ -62,6 +62,25 @@ (define %shadow-sample
|
|||
(shell "/bin/sh")))
|
||||
port))))
|
||||
|
||||
(test-equal "write-passwd with duplicate entry"
|
||||
%passwd-sample
|
||||
(call-with-output-string
|
||||
(lambda (port)
|
||||
(let ((charlie (password-entry
|
||||
(name "charlie")
|
||||
(uid 1000) (gid 998)
|
||||
(real-name "Charlie")
|
||||
(directory "/home/charlie")
|
||||
(shell "/bin/sh"))))
|
||||
(write-passwd (list (password-entry
|
||||
(name "root")
|
||||
(uid 0) (gid 0)
|
||||
(real-name "Admin")
|
||||
(directory "/root")
|
||||
(shell "/bin/sh"))
|
||||
charlie charlie)
|
||||
port)))))
|
||||
|
||||
(test-equal "read-passwd + write-passwd"
|
||||
%passwd-sample
|
||||
(call-with-output-string
|
||||
|
|
Loading…
Reference in a new issue