summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--gnu/build/accounts.scm2
-rw-r--r--tests/accounts.scm19
2 files changed, 20 insertions, 1 deletions
diff --git a/gnu/build/accounts.scm b/gnu/build/accounts.scm
index 5094456ab1..f60d68d9b3 100644
--- a/gnu/build/accounts.scm
+++ b/gnu/build/accounts.scm
@@ -238,7 +238,7 @@ to it atomically and set the appropriate permissions."
(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)
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