aboutsummaryrefslogtreecommitdiff
path: root/tests/accounts.scm
diff options
context:
space:
mode:
authorLudovic Courtès <ludo@gnu.org>2019-08-27 22:38:04 +0200
committerLudovic Courtès <ludo@gnu.org>2019-08-28 00:27:14 +0200
commitdd4e46edda6c255ca170a6650c6f92b16ff50a3f (patch)
tree545a8eaf37525b31fbdba3765a5f71c32334f0f9 /tests/accounts.scm
parent114f02bac47d86c04bf211e33864beffcde74aab (diff)
downloadpatches-dd4e46edda6c255ca170a6650c6f92b16ff50a3f.tar
patches-dd4e46edda6c255ca170a6650c6f92b16ff50a3f.tar.gz
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.
Diffstat (limited to 'tests/accounts.scm')
-rw-r--r--tests/accounts.scm19
1 files changed, 19 insertions, 0 deletions
diff --git a/tests/accounts.scm b/tests/accounts.scm
index 673dd42432..78136390bb 100644
--- a/tests/accounts.scm
+++ b/tests/accounts.scm
@@ -62,6 +62,25 @@ nobody:!:0::::::\n"))
(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