From unknown Sat Sep 13 13:42:32 2025 X-Loop: help-debbugs@gnu.org Subject: bug#45570: operating-system definitions allow duplicate passwd and group entries Resent-From: Jason Conroy Original-Sender: "Debbugs-submit" Resent-CC: bug-guix@gnu.org Resent-Date: Thu, 31 Dec 2020 18:15:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: report 45570 X-GNU-PR-Package: guix X-GNU-PR-Keywords: To: 45570@debbugs.gnu.org X-Debbugs-Original-To: bug-guix@gnu.org Received: via spool by submit@debbugs.gnu.org id=B.160943850217048 (code B ref -1); Thu, 31 Dec 2020 18:15:02 +0000 Received: (at submit) by debbugs.gnu.org; 31 Dec 2020 18:15:02 +0000 Received: from localhost ([127.0.0.1]:41520 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1kv2TV-0004Qk-MZ for submit@debbugs.gnu.org; Thu, 31 Dec 2020 13:15:01 -0500 Received: from lists.gnu.org ([209.51.188.17]:60394) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1kv2TU-0004Qd-4T for submit@debbugs.gnu.org; Thu, 31 Dec 2020 13:15:00 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:58334) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kv2TT-0003DV-Vh for bug-guix@gnu.org; Thu, 31 Dec 2020 13:14:59 -0500 Received: from mail-ed1-x52c.google.com ([2a00:1450:4864:20::52c]:38586) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1kv2TS-0002vR-B4 for bug-guix@gnu.org; Thu, 31 Dec 2020 13:14:59 -0500 Received: by mail-ed1-x52c.google.com with SMTP id cw27so18825508edb.5 for ; Thu, 31 Dec 2020 10:14:57 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:from:date:message-id:subject:to; bh=9b93PNMLCrdXmEL0UW8hF06mJAtEV/FdpMrtbUXklt8=; b=Ywe4GZ/h6vtP0tOyEGb25VVjCrZIgOy4i1TcGGlXR5OqibT03e4wn+Ahs9qeZXoAg+ Ve9b+bcOfsM3b51qViNVGj4MToOnY2UCnVaxdzSDiz4uBKYGeH1I4NVqPCnLNwQLIq4c vMIIRIvhMRmkUUl+ReOTmqVaqBo95eM7/Wa38OWTiuorZ1IUDwxz2M6p9a/U4rIZb+Lb 7frcmemaLivs0xW0f0aLFK4RjI2hlTX/jRwERAMur2Bnh27ekKTcyIgo/hpYHz78h2cV koB5amrXjIhduvUSNvOzkEr5BXrv56hpmdavylUB4iI5flXmH6zlrclmvOAItG/oHH9u wzQw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:from:date:message-id:subject:to; bh=9b93PNMLCrdXmEL0UW8hF06mJAtEV/FdpMrtbUXklt8=; b=GQUKfzUI2MEyf6PQ85Lb4YCep1TRbnCRKh3YP5hpfsBNmiUVWafo1SqRGymirlCrfu 1d0T6l6FJBTlpVZ4N9i8td1dVM9pn/LF6ENDvBGO7XSg1aN6qnH7rcBKbpuCqnhHqeUu KecxGyD8Cwty4eez2gEfCiNNBhKpYRcBk3WCteHy8FP1DcVaXIIMWm/6VUpF8Ysefyvr VUm7B+9YGklWar/vdiqSdCKeWzI8Ke/hH/F0VJdIGERSzgVl0vWd3eMngpssF1HeYrhA Ss8Qb+gi39y7LEmg+D33o/IBV+zJVmThxKpvkYHnpHqXCxHbK5LxCwOsckl8u3gdgjeQ JyDA== X-Gm-Message-State: AOAM532h1cvIncE41fuF/e8czhFkcWA72oTPlXIzmdcn52sYrssKU4SN TukMtWl2AqI3z35Ytd789CZrPm84HQMBOhXNVPR+3mzr X-Google-Smtp-Source: ABdhPJzLyqmUJWkTucplTgLXV/PS3KSzIe+K+yFWkJg4zy5HnHdC5GxCILlQYR5OYhZskMeAQFNr2B5ukU5nuHk/1As= X-Received: by 2002:aa7:d916:: with SMTP id a22mr55862083edr.122.1609438495726; Thu, 31 Dec 2020 10:14:55 -0800 (PST) MIME-Version: 1.0 From: Jason Conroy Date: Thu, 31 Dec 2020 13:14:19 -0500 Message-ID: Content-Type: multipart/mixed; boundary="000000000000d37a7805b7c69949" Received-SPF: pass client-ip=2a00:1450:4864:20::52c; envelope-from=conjaroy@gmail.com; helo=mail-ed1-x52c.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_FROM=0.001, HTML_MESSAGE=0.001, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-Spam-Score: -1.3 (-) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -2.3 (--) --000000000000d37a7805b7c69949 Content-Type: multipart/alternative; boundary="000000000000d37a7605b7c69947" --000000000000d37a7605b7c69947 Content-Type: text/plain; charset="UTF-8" When an operating-system contains multiple users or groups with the same name, instantiating it with `guix system` does not cause a validation failure, nor are the duplicate entries filtered from the resulting /etc files. This duplication can happen in a few different ways: - both entries are manually included in the "users" or "groups" fields of the operating-system - a manually-specified entry collides with an entry defined by a service (via an account-service-type extension) - multiple services define entries that collide with each other Steps to reproduce: call "guix system container" with the attached operating-system definition. --000000000000d37a7605b7c69947 Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable
When an operating-system contains multiple users or g= roups with the same name, instantiating it with `guix system` does not caus= e a validation failure, nor are the duplicate entries filtered from the res= ulting /etc files.

This duplication can happen in = a few different ways:

- both entries are manually = included in the "users" or "groups" fields of the opera= ting-system
- a manually-specified entry collides with an entry d= efined by a service (via an account-service-type extension)
- mul= tiple services define entries that collide with each other

Steps to reproduce: call "guix system container" with th= e attached operating-system definition.
--000000000000d37a7605b7c69947-- --000000000000d37a7805b7c69949 Content-Type: application/octet-stream; name="duplicate-users-and-groups.scm" Content-Disposition: attachment; filename="duplicate-users-and-groups.scm" Content-Transfer-Encoding: base64 Content-ID: X-Attachment-Id: f_kjd4l5un0 KHVzZS1tb2R1bGVzIChnbnUpKQoodXNlLXNlcnZpY2UtbW9kdWxlcyBuZXR3b3JraW5nIHNzaCkK KHVzZS1wYWNrYWdlLW1vZHVsZXMgc2NyZWVuIHNzaCkKCihvcGVyYXRpbmctc3lzdGVtCiAgKGhv c3QtbmFtZSAia29tcHV0aWxvIikKICAodGltZXpvbmUgIkV1cm9wZS9CZXJsaW4iKQogIChsb2Nh bGUgImVuX1VTLnV0ZjgiKQogIChib290bG9hZGVyIChib290bG9hZGVyLWNvbmZpZ3VyYXRpb24K ICAgICAgICAgICAgICAgIChib290bG9hZGVyIGdydWItYm9vdGxvYWRlcikKICAgICAgICAgICAg ICAgICh0YXJnZXQgIi9kZXYvc2RYIikpKQogIChmaWxlLXN5c3RlbXMgKGNvbnMgKGZpbGUtc3lz dGVtCiAgICAgICAgICAgICAgICAgICAgICAgIChkZXZpY2UgKGZpbGUtc3lzdGVtLWxhYmVsICJt eS1yb290IikpCiAgICAgICAgICAgICAgICAgICAgICAgIChtb3VudC1wb2ludCAiLyIpCiAgICAg ICAgICAgICAgICAgICAgICAgICh0eXBlICJleHQ0IikpCiAgICAgICAgICAgICAgICAgICAgICAl YmFzZS1maWxlLXN5c3RlbXMpKQoKICAodXNlcnMgKGFwcGVuZCAobGlzdAoJCSAgOzsgVHdvIG1h bnVhbGx5LXNwZWNpZmllZCB1c2VycyB3aXRoIHRoZSBzYW1lIG5hbWUKCQkgICh1c2VyLWFjY291 bnQKICAgICAgICAgICAgICAgICAgIChuYW1lICJhbGljZSIpCiAgICAgICAgICAgICAgICAgICAo Y29tbWVudCAiQWxpY2UgMSIpCiAgICAgICAgICAgICAgICAgICAoZ3JvdXAgInVzZXJzIikpCgkJ ICAodXNlci1hY2NvdW50CiAgICAgICAgICAgICAgICAgICAobmFtZSAiYWxpY2UiKQogICAgICAg ICAgICAgICAgICAgKGNvbW1lbnQgIkFsaWNlIDIiKQogICAgICAgICAgICAgICAgICAgKGdyb3Vw ICJ1c2VycyIpKQoJCSAgOzsgQSBtYW51YWxseS1zcGVjaWZpZWQgdXNlciB3aXRoIHRoZSBzYW1l IG5hbWUgYXMgYQoJCSAgOzsgdXNlciBkZWZpbmVkIGJ5IHRoZSBvcGVuc3NoLXNlcnZpY2UuCgkJ ICAodXNlci1hY2NvdW50CiAgICAgICAgICAgICAgICAgICAobmFtZSAic3NoZCIpCiAgICAgICAg ICAgICAgICAgICAoY29tbWVudCAiU2VjdXJlIHNoZWxsIHVzZXIiKQogICAgICAgICAgICAgICAg ICAgKGdyb3VwICJzc2hkIikKCQkgICAoc3lzdGVtPyAjdCkpKQogICAgICAgICAgICAgICAlYmFz ZS11c2VyLWFjY291bnRzKSkKCiAgKGdyb3VwcyAoYXBwZW5kIChsaXN0CgkJICA7OyBUd28gbWFu dWFsbHktc3BlY2lmaWVkIGdyb3VwcyB3aXRoIHRoZSBzYW1lIG5hbWUKCQkgICAodXNlci1ncm91 cAoJCSAgICAobmFtZSAicG93ZXItdXNlcnMiKSkKCQkgICAodXNlci1ncm91cAoJCSAgICAobmFt ZSAicG93ZXItdXNlcnMiKSkKCQkgICA7OyBBIG1hbnVhbGx5LXNwZWNpZmllZCBncm91cCB3aXRo IHRoZSBzYW1lIG5hbWUgYXMKCQkgICA7OyBhIGdyb3VwIGRlZmluZWQgYnkgdGhlIG9wZW5zc2gt c2VydmljZS4KCQkgICAodXNlci1ncm91cAoJCSAgICAobmFtZSAic3NoZCIpKSkKCQkgICViYXNl LWdyb3VwcykpCiAgCiAgKHNlcnZpY2VzIChhcHBlbmQgKGxpc3QgKHNlcnZpY2UgZGhjcC1jbGll bnQtc2VydmljZS10eXBlKQogICAgICAgICAgICAgICAgICAgICAgICAgIChzZXJ2aWNlIG9wZW5z c2gtc2VydmljZS10eXBlCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgKG9wZW5z c2gtY29uZmlndXJhdGlvbgogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAob3Bl bnNzaCBvcGVuc3NoLXNhbnMteCkKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAg KHBvcnQtbnVtYmVyIDIyMjIpKSkpCiAgICAgICAgICAgICAgICAgICAgJWJhc2Utc2VydmljZXMp KSkK --000000000000d37a7805b7c69949-- From unknown Sat Sep 13 13:42:32 2025 X-Loop: help-debbugs@gnu.org Subject: bug#45570: [PATCH] system: Assert, that user and group names are unique. References: In-Reply-To: Resent-From: Leo Prikler Original-Sender: "Debbugs-submit" Resent-CC: bug-guix@gnu.org Resent-Date: Fri, 01 Jan 2021 11:15:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 45570 X-GNU-PR-Package: guix X-GNU-PR-Keywords: To: 45570@debbugs.gnu.org Cc: conjaroy@gmail.com Received: via spool by 45570-submit@debbugs.gnu.org id=B45570.160949968125708 (code B ref 45570); Fri, 01 Jan 2021 11:15:02 +0000 Received: (at 45570) by debbugs.gnu.org; 1 Jan 2021 11:14:41 +0000 Received: from localhost ([127.0.0.1]:55508 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1kvIOG-0006gZ-SB for submit@debbugs.gnu.org; Fri, 01 Jan 2021 06:14:41 -0500 Received: from mailrelay.tugraz.at ([129.27.2.202]:38618) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1kvIOE-0006gQ-HY for 45570@debbugs.gnu.org; Fri, 01 Jan 2021 06:14:39 -0500 Received: from localhost.localdomain (217-149-174-13.nat.highway.telekom.at [217.149.174.13]) by mailrelay.tugraz.at (Postfix) with ESMTPSA id 4D6j8r1frVz1LLyW; Fri, 1 Jan 2021 12:14:35 +0100 (CET) DKIM-Filter: OpenDKIM Filter v2.11.0 mailrelay.tugraz.at 4D6j8r1frVz1LLyW DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=tugraz.at; s=mailrelay; t=1609499676; bh=MlpwKQEw7KPCPFqcfOr3JEh9A6sNPniuqaxyX3NNX98=; h=From:To:Cc:Subject:Date:From; b=mur3SKGyD9b2w6/CcG3WO600u4XQ0MQejJMtLghKeaeRGZUg3HA+yklQdzjz1tptP x++gyoK6iRY+6wRPi0fjbBtSGuZVEblZ9137WVp5jAsWecfU3RANRVlQAmn9mNWjsh P5YlPEmk51Fknn65ZaDX2XfN5Jv9AakgT87trSHs= From: Leo Prikler Date: Fri, 1 Jan 2021 12:13:10 +0100 Message-Id: <20210101111309.7701-1-leo.prikler@student.tugraz.at> X-Mailer: git-send-email 2.29.2 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-TUG-Backscatter-control: bt4lQm5Tva3SBgCuw0EnZw X-Spam-Scanner: SpamAssassin 3.003001 X-Spam-Score-relay: -1.9 X-Scanned-By: MIMEDefang 2.74 on 129.27.10.116 X-Spam-Score: -2.3 (--) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -3.3 (---) *gnu/system/shadow.scm (assert-unique-account-names) (assert-unique-group-names): New variables. (account-activation): Use them here. --- gnu/system/shadow.scm | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/gnu/system/shadow.scm b/gnu/system/shadow.scm index a69339bc07..61562f225e 100644 --- a/gnu/system/shadow.scm +++ b/gnu/system/shadow.scm @@ -222,6 +222,32 @@ for a colorful Guile experience.\\n\\n\"))))\n")) (rename-file ".nanorc" ".config/nano/nanorc")) #t)))) +(define (assert-unique-account-names users) + (let loop ((names '()) + (users users)) + (unless (null? users) + (let ((name (user-account-name (car users)))) + (if (member name names) + (raise (condition + (&message + (message + (format #f (G_ "account with name '~a' found twice") + name))))) + (loop (cons name names) (cdr users))))))) + +(define (assert-unique-group-names groups) + (let loop ((names '()) + (groups groups)) + (unless (null? groups) + (let ((name (user-account-name (car groups)))) + (if (member name names) + (raise (condition + (&message + (message + (format #f (G_ "group with name '~a' found twice") + name))))) + (loop (cons name names) (cdr groups))))))) + (define (assert-valid-users/groups users groups) "Raise an error if USERS refer to groups not listed in GROUPS." (let ((groups (list->set (map user-group-name groups)))) @@ -292,6 +318,8 @@ group." (define group-specs (map user-group->gexp groups)) + (assert-unique-account-names accounts) + (assert-unique-group-names groups) (assert-valid-users/groups accounts groups) ;; Add users and user groups. -- 2.29.2 From unknown Sat Sep 13 13:42:32 2025 X-Loop: help-debbugs@gnu.org Subject: bug#45570: [PATCH] system: Assert, that user and group names are unique. Resent-From: Danny Milosavljevic Original-Sender: "Debbugs-submit" Resent-CC: bug-guix@gnu.org Resent-Date: Sat, 02 Jan 2021 01:17:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 45570 X-GNU-PR-Package: guix X-GNU-PR-Keywords: To: Leo Prikler Cc: 45570@debbugs.gnu.org, conjaroy@gmail.com Received: via spool by 45570-submit@debbugs.gnu.org id=B45570.160955017127658 (code B ref 45570); Sat, 02 Jan 2021 01:17:01 +0000 Received: (at 45570) by debbugs.gnu.org; 2 Jan 2021 01:16:11 +0000 Received: from localhost ([127.0.0.1]:35073 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1kvVWd-0007C2-9u for submit@debbugs.gnu.org; Fri, 01 Jan 2021 20:16:11 -0500 Received: from dd26836.kasserver.com ([85.13.145.193]:32802) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1kvVWZ-0007Bp-64 for 45570@debbugs.gnu.org; Fri, 01 Jan 2021 20:16:09 -0500 Received: from localhost (80-110-127-104.cgn.dynamic.surfer.at [80.110.127.104]) by dd26836.kasserver.com (Postfix) with ESMTPSA id 897A23361792; Sat, 2 Jan 2021 02:16:04 +0100 (CET) Date: Sat, 2 Jan 2021 02:16:01 +0100 From: Danny Milosavljevic Message-ID: <20210102021601.74c2205a@scratchpost.org> In-Reply-To: <20210101111309.7701-1-leo.prikler@student.tugraz.at> References: <20210101111309.7701-1-leo.prikler@student.tugraz.at> X-Mailer: Claws Mail 3.17.8 (GTK+ 2.24.32; x86_64-pc-linux-gnu) MIME-Version: 1.0 Content-Type: multipart/signed; boundary="Sig_/21LS2xbdBxkYFvtqhB//Y+J"; protocol="application/pgp-signature"; micalg=pgp-sha512 X-Spam-Score: -0.7 (/) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.7 (-) --Sig_/21LS2xbdBxkYFvtqhB//Y+J Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: quoted-printable Hi Leo, I agree that this is a good idea. Please use (ice-9 match) instead of car and cdr. Something among these lines would be more transparent: (define (find-duplicates list accessor) (match list (() '()) ((head . tail) (if (member head tail accessor) ; (srfi srfi-1) member (cons head (find-duplicates tail accessor)) (find-duplicates tail accessor))))) (find-duplicates users (lambda (a b) (string=3D? (user-account-name a) (user-account-name b))) (I think one could also use srfi-1 delete-duplicates and then compare the lengths. Then the entire thing is a one-liner--the only complication is to find the duplicates again after doing it (for the error message)) --Sig_/21LS2xbdBxkYFvtqhB//Y+J Content-Type: application/pgp-signature Content-Description: OpenPGP digital signature -----BEGIN PGP SIGNATURE----- iQEzBAEBCgAdFiEEds7GsXJ0tGXALbPZ5xo1VCwwuqUFAl/vyVEACgkQ5xo1VCww uqWekAgAp5r/QdsNKZ96v1UhGjbotHLNOS0BfMsvDZafTK/h8FToyel/E7wOrKca 0NjR+C01HkhhYYGl5/WoLLpR103fSo/NXtH0TykyBe7D4WwUn46gE2x7D59G2qmW f7ztIrkZke/JWEjQrSzsJwEY5uYT6D7b9dtYeUj7zBPU0Z+J+6+2nQYjZNLPrkDG 7GCZS8aJwmVBza6YKq/dmCM/nql8yV4kBpSXXEffhV4KEQAWdb51aS14wBIlEfj7 0y3Z64c0Xlgfd/6N5YSHlirn9gpNcRkO7jYiPwryweUK6LQRcWoeMXqM4oGJbTlU V0gqbnNxQqWwQIASBIUN/FXW7vpIoQ== =yiKX -----END PGP SIGNATURE----- --Sig_/21LS2xbdBxkYFvtqhB//Y+J-- From unknown Sat Sep 13 13:42:32 2025 X-Loop: help-debbugs@gnu.org Subject: bug#45570: [PATCH] system: Assert, that user and group names are unique. References: In-Reply-To: Resent-From: Leo Prikler Original-Sender: "Debbugs-submit" Resent-CC: bug-guix@gnu.org Resent-Date: Sat, 02 Jan 2021 05:59:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 45570 X-GNU-PR-Package: guix X-GNU-PR-Keywords: To: 45570@debbugs.gnu.org Cc: dannym@scratchpost.org, conjaroy@gmail.com Received: via spool by 45570-submit@debbugs.gnu.org id=B45570.16095670973772 (code B ref 45570); Sat, 02 Jan 2021 05:59:01 +0000 Received: (at 45570) by debbugs.gnu.org; 2 Jan 2021 05:58:17 +0000 Received: from localhost ([127.0.0.1]:38895 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1kvZvc-0000ym-Un for submit@debbugs.gnu.org; Sat, 02 Jan 2021 00:58:17 -0500 Received: from mailrelay.tugraz.at ([129.27.2.202]:55384) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1kvZvZ-0000yc-Vq for 45570@debbugs.gnu.org; Sat, 02 Jan 2021 00:58:15 -0500 Received: from localhost.localdomain (217-149-174-13.nat.highway.telekom.at [217.149.174.13]) by mailrelay.tugraz.at (Postfix) with ESMTPSA id 4D7B5G1wswz3wYT; Sat, 2 Jan 2021 06:58:09 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=tugraz.at; s=mailrelay; t=1609567090; bh=qHngEiAILzlDjqsIcVken0ZTK4ydmKtUyjebdQBf9fU=; h=From:To:Cc:Subject:Date; b=JWWyUUHv3d71mj47/ydYPD5S2oBwFcU3tSfjnh8kTdEckPkZTr+7R6nKvKObsRQ8f lXbhkhgmkTOVwXLKWcShBDZmpie/jjU08eUvmMAWUvVPSXoho7KopGKJLojJ9o3xhb UtjiToKd/lN6sjVgUUucl4ciT1RbiGfJKbzINC8o= From: Leo Prikler Date: Sat, 2 Jan 2021 06:57:29 +0100 Message-Id: <20210102055728.22594-1-leo.prikler@student.tugraz.at> X-Mailer: git-send-email 2.29.2 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-TUG-Backscatter-control: bt4lQm5Tva3SBgCuw0EnZw X-Spam-Scanner: SpamAssassin 3.003001 X-Spam-Score-relay: -1.9 X-Scanned-By: MIMEDefang 2.74 on 129.27.10.117 X-Spam-Score: -2.3 (--) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -3.3 (---) *gnu/system/shadow.scm (find-duplicates): New variable. (assert-unique-account-names, assert-unique-group-names): New variables. (account-activation): Use them here. --- gnu/system/shadow.scm | 35 +++++++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) diff --git a/gnu/system/shadow.scm b/gnu/system/shadow.scm index a69339bc07..3a5ea4dc70 100644 --- a/gnu/system/shadow.scm +++ b/gnu/system/shadow.scm @@ -34,6 +34,7 @@ #:use-module ((gnu packages admin) #:select (shadow)) #:use-module (gnu packages bash) + #:use-module (ice-9 match) #:use-module (srfi srfi-1) #:use-module (srfi srfi-26) #:use-module (srfi srfi-34) @@ -222,6 +223,38 @@ for a colorful Guile experience.\\n\\n\"))))\n")) (rename-file ".nanorc" ".config/nano/nanorc")) #t)))) +(define (find-duplicates list =) + (match list + ('() '()) + ((first . rest) + (if (member first rest =) ; (srfi srfi-1) member + (cons first (find-duplicates rest =)) + (find-duplicates rest =))))) + +(define (assert-unique-account-names users) + (for-each + (lambda (account) + (raise (condition + (&message + (message + (format #f (G_ "account with name '~a' found twice.") + (user-account-name account))))))) + (find-duplicates users (lambda (alice bob) + (string=? (user-account-name alice) + (user-account-name bob)))))) + +(define (assert-unique-group-names groups) + (for-each + (lambda (group) + (raise (condition + (&message + (message + (format #f (G_ "group with name '~a' found twice.") + (user-group-name group))))))) + (find-duplicates groups (lambda (red blue) + (string=? (user-group-name red) + (user-group-name blue)))))) + (define (assert-valid-users/groups users groups) "Raise an error if USERS refer to groups not listed in GROUPS." (let ((groups (list->set (map user-group-name groups)))) @@ -292,6 +325,8 @@ group." (define group-specs (map user-group->gexp groups)) + (assert-unique-account-names accounts) + (assert-unique-group-names groups) (assert-valid-users/groups accounts groups) ;; Add users and user groups. -- 2.29.2 From unknown Sat Sep 13 13:42:32 2025 X-Loop: help-debbugs@gnu.org Subject: bug#45570: [PATCH] system: Assert, that user and group names are unique. Resent-From: Ludovic =?UTF-8?Q?Court=C3=A8s?= Original-Sender: "Debbugs-submit" Resent-CC: bug-guix@gnu.org Resent-Date: Wed, 06 Jan 2021 09:57:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 45570 X-GNU-PR-Package: guix X-GNU-PR-Keywords: To: Leo Prikler Cc: 45570@debbugs.gnu.org, conjaroy@gmail.com Received: via spool by 45570-submit@debbugs.gnu.org id=B45570.16099269967831 (code B ref 45570); Wed, 06 Jan 2021 09:57:02 +0000 Received: (at 45570) by debbugs.gnu.org; 6 Jan 2021 09:56:36 +0000 Received: from localhost ([127.0.0.1]:43465 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1kx5YS-00022F-1D for submit@debbugs.gnu.org; Wed, 06 Jan 2021 04:56:36 -0500 Received: from eggs.gnu.org ([209.51.188.92]:56174) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1kx5YQ-00021z-0P for 45570@debbugs.gnu.org; Wed, 06 Jan 2021 04:56:34 -0500 Received: from fencepost.gnu.org ([2001:470:142:3::e]:57354) by eggs.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kx5YH-0008TB-PY; Wed, 06 Jan 2021 04:56:26 -0500 Received: from [2a01:e0a:1d:7270:af76:b9b:ca24:c465] (port=41410 helo=ribbon) by fencepost.gnu.org with esmtpsa (TLS1.2:RSA_AES_256_CBC_SHA1:256) (Exim 4.82) (envelope-from ) id 1kx5YH-0002rt-79; Wed, 06 Jan 2021 04:56:25 -0500 From: Ludovic =?UTF-8?Q?Court=C3=A8s?= References: <20210102055728.22594-1-leo.prikler@student.tugraz.at> X-URL: http://www.fdn.fr/~lcourtes/ X-Revolutionary-Date: 17 =?UTF-8?Q?Niv=C3=B4se?= an 229 de la =?UTF-8?Q?R=C3=A9volution?= X-PGP-Key-ID: 0x090B11993D9AEBB5 X-PGP-Key: http://www.fdn.fr/~lcourtes/ludovic.asc X-PGP-Fingerprint: 3CE4 6455 8A84 FDC6 9DB4 0CFB 090B 1199 3D9A EBB5 X-OS: x86_64-pc-linux-gnu Date: Wed, 06 Jan 2021 10:56:23 +0100 In-Reply-To: <20210102055728.22594-1-leo.prikler@student.tugraz.at> (Leo Prikler's message of "Sat, 2 Jan 2021 06:57:29 +0100") Message-ID: <87v9cao0c8.fsf@gnu.org> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/27.1 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable X-Spam-Score: -2.3 (--) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -3.3 (---) Hi, Leo Prikler skribis: > *gnu/system/shadow.scm (find-duplicates): New variable. > (assert-unique-account-names, assert-unique-group-names): New variables. > (account-activation): Use them here. [...] > +(define (find-duplicates list =3D) > + (match list > + ('() '()) This should be: (match list (() '()) =E2=80=A6) I=E2=80=99m surprised '() works as a pattern. > + ((first . rest) > + (if (member first rest =3D) ; (srfi srfi-1) member > + (cons first (find-duplicates rest =3D)) > + (find-duplicates rest =3D))))) Note that this is quadratic; it=E2=80=99s fine as long as we don=E2=80=99t = have =E2=80=9Ctoo many=E2=80=9D users, which may be the case in general. > +(define (assert-unique-account-names users) > + (for-each > + (lambda (account) > + (raise (condition > + (&message > + (message > + (format #f (G_ "account with name '~a' found twice.") > + (user-account-name account))))))) > + (find-duplicates users (lambda (alice bob) > + (string=3D? (user-account-name alice) > + (user-account-name bob)))))) =E2=80=98for-each=E2=80=99 looks awkward since we=E2=80=99ll stop on the fi= rst one. How about something like: (define (assert-unique-account-names users) (match (find-duplicates things =E2=80=A6) (() #t) (lst (raise (formatted-message (G_ "the following accounts appear more th= an once:~{ ~a~}~%" lst)))))) ? Thanks! Ludo=E2=80=99. From unknown Sat Sep 13 13:42:32 2025 X-Loop: help-debbugs@gnu.org Subject: bug#45570: [PATCH] system: Assert, that user and group names are unique. Resent-From: Leo Prikler Original-Sender: "Debbugs-submit" Resent-CC: bug-guix@gnu.org Resent-Date: Wed, 06 Jan 2021 12:35:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 45570 X-GNU-PR-Package: guix X-GNU-PR-Keywords: To: Ludovic =?UTF-8?Q?Court=C3=A8s?= Cc: 45570@debbugs.gnu.org, conjaroy@gmail.com Received: via spool by 45570-submit@debbugs.gnu.org id=B45570.160993647210284 (code B ref 45570); Wed, 06 Jan 2021 12:35:02 +0000 Received: (at 45570) by debbugs.gnu.org; 6 Jan 2021 12:34:32 +0000 Received: from localhost ([127.0.0.1]:43748 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1kx81H-0002fn-VJ for submit@debbugs.gnu.org; Wed, 06 Jan 2021 07:34:32 -0500 Received: from mailrelay.tugraz.at ([129.27.2.202]:24822) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1kx81F-0002fc-Tz for 45570@debbugs.gnu.org; Wed, 06 Jan 2021 07:34:31 -0500 Received: from nijino.local (217-149-174-13.nat.highway.telekom.at [217.149.174.13]) by mailrelay.tugraz.at (Postfix) with ESMTPSA id 4D9phg0rTTz1LWpD; Wed, 6 Jan 2021 13:34:26 +0100 (CET) DKIM-Filter: OpenDKIM Filter v2.11.0 mailrelay.tugraz.at 4D9phg0rTTz1LWpD DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=tugraz.at; s=mailrelay; t=1609936467; bh=fwZaYPT2fRErxwRO5PcrtDKtrJ0gGW/+OZFHQmGY6MU=; h=Subject:From:To:Cc:Date:In-Reply-To:References:From; b=PJ0N9hcao075RQsuw990cuMzgNX8EOM8x1D6Rg7jRzpp5I/N+KfPrfcNCHwJPKW+B c0d6O5e9uRdNOlptMJINz6+I8WrEs3jhCFxNwOr8b8XxC11wqNC+DbVH3yjPwJkPFQ arOOgMLiRrIxAC+Ha6KriMQVwluCUaHXQW+7h4XM= Message-ID: From: Leo Prikler Date: Wed, 06 Jan 2021 13:34:26 +0100 In-Reply-To: <87v9cao0c8.fsf@gnu.org> References: <20210102055728.22594-1-leo.prikler@student.tugraz.at> <87v9cao0c8.fsf@gnu.org> Content-Type: text/plain; charset="UTF-8" User-Agent: Evolution 3.34.2 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-TUG-Backscatter-control: bt4lQm5Tva3SBgCuw0EnZw X-Spam-Scanner: SpamAssassin 3.003001 X-Spam-Score-relay: -1.9 X-Scanned-By: MIMEDefang 2.74 on 129.27.10.116 X-Spam-Score: -2.3 (--) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -3.3 (---) Hi, Am Mittwoch, den 06.01.2021, 10:56 +0100 schrieb Ludovic Courtès: > Hi, > > Leo Prikler skribis: > > > *gnu/system/shadow.scm (find-duplicates): New variable. > > (assert-unique-account-names, assert-unique-group-names): New > > variables. > > (account-activation): Use them here. > > [...] > > > +(define (find-duplicates list =) > > + (match list > > + ('() '()) > > This should be: > > (match list > (() '()) > …) > > I’m surprised '() works as a pattern. I think it's because matching literals works, but you're right. > > + ((first . rest) > > + (if (member first rest =) ; (srfi srfi-1) member > > + (cons first (find-duplicates rest =)) > > + (find-duplicates rest =))))) > > Note that this is quadratic; it’s fine as long as we don’t have “too > many” users, which may be the case in general. It is indeed quadratic, but would there even be an n log n solution? I've once done an n log n sort+delete-duplicates!, perhaps that'd be a nicer solution here? > > +(define (assert-unique-account-names users) > > + (for-each > > + (lambda (account) > > + (raise (condition > > + (&message > > + (message > > + (format #f (G_ "account with name '~a' found > > twice.") > > + (user-account-name account))))))) > > + (find-duplicates users (lambda (alice bob) > > + (string=? (user-account-name alice) > > + (user-account-name bob)))))) > > ‘for-each’ looks awkward since we’ll stop on the first one. How > about > something like: > > (define (assert-unique-account-names users) > (match (find-duplicates things …) > (() #t) > (lst > (raise (formatted-message (G_ "the following accounts appear > more than once:~{ ~a~}~%" > lst)))))) > > ? That'd be weird for duplicate duplicates, hence just reporting the first. Of course we could always count occurrences by allocating a local hash table and then do some fancy hash-map->list conversion. If we do use hash-tables, perhaps this could even be a linear algorithm? Regards, Leo From unknown Sat Sep 13 13:42:32 2025 X-Loop: help-debbugs@gnu.org Subject: bug#45570: [PATCH] system: Assert, that user and group names are unique. Resent-From: Ludovic =?UTF-8?Q?Court=C3=A8s?= Original-Sender: "Debbugs-submit" Resent-CC: bug-guix@gnu.org Resent-Date: Wed, 06 Jan 2021 13:33:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 45570 X-GNU-PR-Package: guix X-GNU-PR-Keywords: To: Leo Prikler Cc: 45570@debbugs.gnu.org, conjaroy@gmail.com Received: via spool by 45570-submit@debbugs.gnu.org id=B45570.160993994616259 (code B ref 45570); Wed, 06 Jan 2021 13:33:02 +0000 Received: (at 45570) by debbugs.gnu.org; 6 Jan 2021 13:32:26 +0000 Received: from localhost ([127.0.0.1]:43807 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1kx8vK-0004EA-4O for submit@debbugs.gnu.org; Wed, 06 Jan 2021 08:32:26 -0500 Received: from eggs.gnu.org ([209.51.188.92]:45130) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1kx8vI-0004Dy-LP for 45570@debbugs.gnu.org; Wed, 06 Jan 2021 08:32:25 -0500 Received: from fencepost.gnu.org ([2001:470:142:3::e]:60367) by eggs.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kx8vA-00086d-37; Wed, 06 Jan 2021 08:32:17 -0500 Received: from [2a01:e0a:1d:7270:af76:b9b:ca24:c465] (port=41644 helo=ribbon) by fencepost.gnu.org with esmtpsa (TLS1.2:RSA_AES_256_CBC_SHA1:256) (Exim 4.82) (envelope-from ) id 1kx8v5-00035C-Nb; Wed, 06 Jan 2021 08:32:13 -0500 From: Ludovic =?UTF-8?Q?Court=C3=A8s?= References: <20210102055728.22594-1-leo.prikler@student.tugraz.at> <87v9cao0c8.fsf@gnu.org> X-URL: http://www.fdn.fr/~lcourtes/ X-Revolutionary-Date: 17 =?UTF-8?Q?Niv=C3=B4se?= an 229 de la =?UTF-8?Q?R=C3=A9volution?= X-PGP-Key-ID: 0x090B11993D9AEBB5 X-PGP-Key: http://www.fdn.fr/~lcourtes/ludovic.asc X-PGP-Fingerprint: 3CE4 6455 8A84 FDC6 9DB4 0CFB 090B 1199 3D9A EBB5 X-OS: x86_64-pc-linux-gnu Date: Wed, 06 Jan 2021 14:32:10 +0100 In-Reply-To: (Leo Prikler's message of "Wed, 06 Jan 2021 13:34:26 +0100") Message-ID: <87k0sqkx7p.fsf@gnu.org> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/27.1 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable X-Spam-Score: -2.3 (--) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -3.3 (---) Hi, Leo Prikler skribis: >> > + ((first . rest) >> > + (if (member first rest =3D) ; (srfi srfi-1) member >> > + (cons first (find-duplicates rest =3D)) >> > + (find-duplicates rest =3D))))) >>=20 >> Note that this is quadratic; it=E2=80=99s fine as long as we don=E2=80= =99t have =E2=80=9Ctoo >> many=E2=80=9D users, which may be the case in general. > It is indeed quadratic, but would there even be an n log n solution? > I've once done an n log n sort+delete-duplicates!, perhaps that'd be a > nicer solution here? You could first build a hash table or vhash or set with all the names, then traverse again the list of names and check whether they=E2=80=99re in = that table. That=E2=80=99d be linear (assuming the table is well balanced), but= the constant factor would be higher. >> (define (assert-unique-account-names users) >> (match (find-duplicates things =E2=80=A6) >> (() #t) >> (lst >> (raise (formatted-message (G_ "the following accounts appear >> more than once:~{ ~a~}~%" >> lst)))))) >>=20 >> ? > That'd be weird for duplicate duplicates, hence just reporting the > first. You could do (delete-duplicates lst) in the message above? Thanks, Ludo=E2=80=99. From unknown Sat Sep 13 13:42:32 2025 X-Loop: help-debbugs@gnu.org Subject: bug#45570: [PATCH] system: Assert, that user and group names are unique. Resent-From: Leo Prikler Original-Sender: "Debbugs-submit" Resent-CC: bug-guix@gnu.org Resent-Date: Wed, 06 Jan 2021 21:01:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 45570 X-GNU-PR-Package: guix X-GNU-PR-Keywords: To: Ludovic =?UTF-8?Q?Court=C3=A8s?= Cc: 45570@debbugs.gnu.org, conjaroy@gmail.com Received: via spool by 45570-submit@debbugs.gnu.org id=B45570.160996680912437 (code B ref 45570); Wed, 06 Jan 2021 21:01:01 +0000 Received: (at 45570) by debbugs.gnu.org; 6 Jan 2021 21:00:09 +0000 Received: from localhost ([127.0.0.1]:45728 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1kxFub-0003EX-6m for submit@debbugs.gnu.org; Wed, 06 Jan 2021 16:00:09 -0500 Received: from mailrelay.tugraz.at ([129.27.2.202]:38643) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1kxFuY-0003DN-Tt for 45570@debbugs.gnu.org; Wed, 06 Jan 2021 16:00:07 -0500 Received: from nijino.local (217-149-174-13.nat.highway.telekom.at [217.149.174.13]) by mailrelay.tugraz.at (Postfix) with ESMTPSA id 4DB1w41KLYz1LLyW; Wed, 6 Jan 2021 22:00:03 +0100 (CET) DKIM-Filter: OpenDKIM Filter v2.11.0 mailrelay.tugraz.at 4DB1w41KLYz1LLyW DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=tugraz.at; s=mailrelay; t=1609966804; bh=jd3gON0HPwX1p7XCwPPufT/Tgx4jwLi2L3nn+J2Y3mY=; h=Subject:From:To:Cc:Date:In-Reply-To:References:From; b=J6N+D9CoLPkG5fS4vh2LCMraDZOrmGPdkudzq6IFU24t2LLOWm6xuaLHM+gYvnkSX blTXYuyc48MW6QLz2fQbw87rfuut2CmXfPDUW5gBXe0SolzturwjfG3iYVg1vAkMD1 0N6V+xh2+41tYK76ou+sjLOSaxb9NleKGyCweHQo= Message-ID: From: Leo Prikler Date: Wed, 06 Jan 2021 22:00:03 +0100 In-Reply-To: <87k0sqkx7p.fsf@gnu.org> References: <20210102055728.22594-1-leo.prikler@student.tugraz.at> <87v9cao0c8.fsf@gnu.org> <87k0sqkx7p.fsf@gnu.org> Content-Type: text/plain; charset="UTF-8" User-Agent: Evolution 3.34.2 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-TUG-Backscatter-control: bt4lQm5Tva3SBgCuw0EnZw X-Spam-Scanner: SpamAssassin 3.003001 X-Spam-Score-relay: -1.9 X-Scanned-By: MIMEDefang 2.74 on 129.27.10.116 X-Spam-Score: -2.3 (--) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -3.3 (---) Hi, Am Mittwoch, den 06.01.2021, 14:32 +0100 schrieb Ludovic Courtès: > Hi, > > Leo Prikler skribis: > > > > > + ((first . rest) > > > > + (if (member first rest =) ; (srfi srfi-1) member > > > > + (cons first (find-duplicates rest =)) > > > > + (find-duplicates rest =))))) > > > > > > Note that this is quadratic; it’s fine as long as we don’t have > > > “too > > > many” users, which may be the case in general. > > It is indeed quadratic, but would there even be an n log n > > solution? > > I've once done an n log n sort+delete-duplicates!, perhaps that'd > > be a > > nicer solution here? > > You could first build a hash table or vhash or set with all the > names, > then traverse again the list of names and check whether they’re in > that > table. That’d be linear (assuming the table is well balanced), but > the > constant factor would be higher. Yeah, I think the hash table solution would make the most sense here. Since VHashes are based on VLists, they're not actually purely functional, are they? > > > (define (assert-unique-account-names users) > > > (match (find-duplicates things …) > > > (() #t) > > > (lst > > > (raise (formatted-message (G_ "the following accounts > > > appear > > > more than once:~{ ~a~}~%" > > > lst)))))) > > > > > > ? > > That'd be weird for duplicate duplicates, hence just reporting the > > first. > > You could do (delete-duplicates lst) in the message above? Sure, but that'd be O(n^2) on top of O(n^2), which is less than ideal. I think I'll try working on a hash-based implementation for now. Regards, Leo From unknown Sat Sep 13 13:42:32 2025 X-Loop: help-debbugs@gnu.org Subject: bug#45570: [PATCH v2] system: Assert, that user and group names are unique. References: In-Reply-To: Resent-From: Leo Prikler Original-Sender: "Debbugs-submit" Resent-CC: bug-guix@gnu.org Resent-Date: Wed, 06 Jan 2021 21:23:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 45570 X-GNU-PR-Package: guix X-GNU-PR-Keywords: To: 45570@debbugs.gnu.org Cc: ludo@gnu.org, conjaroy@gmail.com Received: via spool by 45570-submit@debbugs.gnu.org id=B45570.160996817914675 (code B ref 45570); Wed, 06 Jan 2021 21:23:01 +0000 Received: (at 45570) by debbugs.gnu.org; 6 Jan 2021 21:22:59 +0000 Received: from localhost ([127.0.0.1]:45754 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1kxGGh-0003od-1o for submit@debbugs.gnu.org; Wed, 06 Jan 2021 16:22:59 -0500 Received: from mailrelay.tugraz.at ([129.27.2.202]:11803) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1kxGGf-0003oS-AG for 45570@debbugs.gnu.org; Wed, 06 Jan 2021 16:22:58 -0500 Received: from localhost.localdomain (217-149-174-13.nat.highway.telekom.at [217.149.174.13]) by mailrelay.tugraz.at (Postfix) with ESMTPSA id 4DB2QQ1QFGz3wFK; Wed, 6 Jan 2021 22:22:54 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=tugraz.at; s=mailrelay; t=1609968174; bh=H/AW1y/aX8KMSGdzhYVMv9f4WP7gUpE7pZfG+aZBrC8=; h=From:To:Cc:Subject:Date; b=shbPZCUV4AxOnNXFu6aGcrx2F2rXrmOd2rvxJEzh4+ba7idQ5kA/bGft3T4FYl5Q+ WjNQGrqHJrioLUD8vt6ScIyKTGOqS67J1tzSPRaMEfkMU9TXU4uwS41V+ZIoSwA1JE RQuQaAkYsewMUwS1zzKWU9cIR7oTmQbPCKdaRaUQ= From: Leo Prikler Date: Wed, 6 Jan 2021 22:21:49 +0100 Message-Id: <20210106212148.28720-1-leo.prikler@student.tugraz.at> X-Mailer: git-send-email 2.30.0 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-TUG-Backscatter-control: bt4lQm5Tva3SBgCuw0EnZw X-Spam-Scanner: SpamAssassin 3.003001 X-Spam-Score-relay: -1.9 X-Scanned-By: MIMEDefang 2.74 on 129.27.10.116 X-Spam-Score: -2.3 (--) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -3.3 (---) *gnu/system/shadow.scm (find-duplicates): New variable. (assert-unique-account-names, assert-unique-group-names): New variables. (account-activation): Use them here. --- gnu/system/shadow.scm | 38 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 38 insertions(+) diff --git a/gnu/system/shadow.scm b/gnu/system/shadow.scm index a69339bc07..4dbd578e1e 100644 --- a/gnu/system/shadow.scm +++ b/gnu/system/shadow.scm @@ -20,6 +20,7 @@ ;;; along with GNU Guix. If not, see . (define-module (gnu system shadow) + #:use-module ((guix diagnostics) #:select (formatted-message)) #:use-module (guix records) #:use-module (guix gexp) #:use-module (guix store) @@ -34,6 +35,7 @@ #:use-module ((gnu packages admin) #:select (shadow)) #:use-module (gnu packages bash) + #:use-module (ice-9 match) #:use-module (srfi srfi-1) #:use-module (srfi srfi-26) #:use-module (srfi srfi-34) @@ -222,6 +224,40 @@ for a colorful Guile experience.\\n\\n\"))))\n")) (rename-file ".nanorc" ".config/nano/nanorc")) #t)))) +(define (find-duplicates list) + (let loop ((table (make-hash-table)) + (list list)) + (match list + (() + (hash-fold (lambda (key value seed) + (if (> value 1) + (cons key seed) + seed)) + '() + table)) + ((first . rest) + (hash-set! table first + (1+ (hash-ref table first 0))) + (loop table rest))))) + +(define (assert-unique-account-names users) + (match (find-duplicates (map user-account-name users)) + (() *unspecified*) + (duplicates + (raise + (formatted-message + (G_ "the following accounts appear more than once:~{ ~a~}~%") + duplicates))))) + +(define (assert-unique-group-names groups) + (match (find-duplicates (map user-group-name groups)) + (() *unspecified*) + (duplicates + (raise + (formatted-message + (G_ "the following groups appear more than once:~{ ~a~}~%") + duplicates))))) + (define (assert-valid-users/groups users groups) "Raise an error if USERS refer to groups not listed in GROUPS." (let ((groups (list->set (map user-group-name groups)))) @@ -292,6 +328,8 @@ group." (define group-specs (map user-group->gexp groups)) + (assert-unique-account-names accounts) + (assert-unique-group-names groups) (assert-valid-users/groups accounts groups) ;; Add users and user groups. -- 2.30.0 From unknown Sat Sep 13 13:42:32 2025 X-Loop: help-debbugs@gnu.org Subject: bug#45570: [PATCH] system: Assert, that user and group names are unique. Resent-From: Ludovic =?UTF-8?Q?Court=C3=A8s?= Original-Sender: "Debbugs-submit" Resent-CC: bug-guix@gnu.org Resent-Date: Thu, 07 Jan 2021 08:31:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 45570 X-GNU-PR-Package: guix X-GNU-PR-Keywords: To: Leo Prikler Cc: 45570@debbugs.gnu.org, conjaroy@gmail.com Received: via spool by 45570-submit@debbugs.gnu.org id=B45570.161000821011968 (code B ref 45570); Thu, 07 Jan 2021 08:31:01 +0000 Received: (at 45570) by debbugs.gnu.org; 7 Jan 2021 08:30:10 +0000 Received: from localhost ([127.0.0.1]:46249 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1kxQgM-00036x-6E for submit@debbugs.gnu.org; Thu, 07 Jan 2021 03:30:10 -0500 Received: from eggs.gnu.org ([209.51.188.92]:44188) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1kxQgK-00035l-0Y for 45570@debbugs.gnu.org; Thu, 07 Jan 2021 03:30:08 -0500 Received: from fencepost.gnu.org ([2001:470:142:3::e]:51775) by eggs.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kxQgD-0002WH-7C; Thu, 07 Jan 2021 03:30:01 -0500 Received: from [2a01:e0a:1d:7270:af76:b9b:ca24:c465] (port=43772 helo=ribbon) by fencepost.gnu.org with esmtpsa (TLS1.2:RSA_AES_256_CBC_SHA1:256) (Exim 4.82) (envelope-from ) id 1kxQgC-0007yR-7O; Thu, 07 Jan 2021 03:30:00 -0500 From: Ludovic =?UTF-8?Q?Court=C3=A8s?= References: <20210102055728.22594-1-leo.prikler@student.tugraz.at> <87v9cao0c8.fsf@gnu.org> <87k0sqkx7p.fsf@gnu.org> X-URL: http://www.fdn.fr/~lcourtes/ X-Revolutionary-Date: 18 =?UTF-8?Q?Niv=C3=B4se?= an 229 de la =?UTF-8?Q?R=C3=A9volution?= X-PGP-Key-ID: 0x090B11993D9AEBB5 X-PGP-Key: http://www.fdn.fr/~lcourtes/ludovic.asc X-PGP-Fingerprint: 3CE4 6455 8A84 FDC6 9DB4 0CFB 090B 1199 3D9A EBB5 X-OS: x86_64-pc-linux-gnu Date: Thu, 07 Jan 2021 09:29:59 +0100 In-Reply-To: (Leo Prikler's message of "Wed, 06 Jan 2021 22:00:03 +0100") Message-ID: <87im89jgjc.fsf@gnu.org> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/27.1 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable X-Spam-Score: -2.3 (--) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -3.3 (---) Hi, Leo Prikler skribis: > Am Mittwoch, den 06.01.2021, 14:32 +0100 schrieb Ludovic Court=C3=A8s: >> Hi, >>=20 >> Leo Prikler skribis: >>=20 >> > > > + ((first . rest) >> > > > + (if (member first rest =3D) ; (srfi srfi-1) member >> > > > + (cons first (find-duplicates rest =3D)) >> > > > + (find-duplicates rest =3D))))) >> > >=20 >> > > Note that this is quadratic; it=E2=80=99s fine as long as we don=E2= =80=99t have >> > > =E2=80=9Ctoo >> > > many=E2=80=9D users, which may be the case in general. >> > It is indeed quadratic, but would there even be an n log n >> > solution? >> > I've once done an n log n sort+delete-duplicates!, perhaps that'd >> > be a >> > nicer solution here? >>=20 >> You could first build a hash table or vhash or set with all the >> names, >> then traverse again the list of names and check whether they=E2=80=99re = in >> that >> table. That=E2=80=99d be linear (assuming the table is well balanced), = but >> the >> constant factor would be higher. > Yeah, I think the hash table solution would make the most sense here.=20 > Since VHashes are based on VLists, they're not actually purely > functional, are they? Their implementation is not =E2=80=9Cpurely functional=E2=80=9D but it=E2= =80=99s inconsequential; it=E2=80=99s a persistent data structure, and that=E2=80= =99s what matters (info "(guile) VLists"). >> > > (define (assert-unique-account-names users) >> > > (match (find-duplicates things =E2=80=A6) >> > > (() #t) >> > > (lst >> > > (raise (formatted-message (G_ "the following accounts >> > > appear >> > > more than once:~{ ~a~}~%" >> > > lst)))))) >> > >=20 >> > > ? >> > That'd be weird for duplicate duplicates, hence just reporting the >> > first. >>=20 >> You could do (delete-duplicates lst) in the message above? > Sure, but that'd be O(n^2) on top of O(n^2), which is less than ideal. Yes, but it=E2=80=99s a small =E2=80=98n=E2=80=99, typically one or two. Ludo=E2=80=99. From unknown Sat Sep 13 13:42:32 2025 X-Loop: help-debbugs@gnu.org Subject: bug#45570: [PATCH v2] system: Assert, that user and group names are unique. Resent-From: Ludovic =?UTF-8?Q?Court=C3=A8s?= Original-Sender: "Debbugs-submit" Resent-CC: bug-guix@gnu.org Resent-Date: Thu, 07 Jan 2021 08:36:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 45570 X-GNU-PR-Package: guix X-GNU-PR-Keywords: To: Leo Prikler Cc: 45570@debbugs.gnu.org, conjaroy@gmail.com Received: via spool by 45570-submit@debbugs.gnu.org id=B45570.161000855312439 (code B ref 45570); Thu, 07 Jan 2021 08:36:02 +0000 Received: (at 45570) by debbugs.gnu.org; 7 Jan 2021 08:35:53 +0000 Received: from localhost ([127.0.0.1]:46253 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1kxQls-0003EZ-TR for submit@debbugs.gnu.org; Thu, 07 Jan 2021 03:35:53 -0500 Received: from eggs.gnu.org ([209.51.188.92]:45148) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1kxQlq-0003EM-FT for 45570@debbugs.gnu.org; Thu, 07 Jan 2021 03:35:50 -0500 Received: from fencepost.gnu.org ([2001:470:142:3::e]:51828) by eggs.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kxQll-0005SN-7U; Thu, 07 Jan 2021 03:35:45 -0500 Received: from [2a01:e0a:1d:7270:af76:b9b:ca24:c465] (port=43786 helo=ribbon) by fencepost.gnu.org with esmtpsa (TLS1.2:RSA_AES_256_CBC_SHA1:256) (Exim 4.82) (envelope-from ) id 1kxQlk-0002Qc-Kj; Thu, 07 Jan 2021 03:35:44 -0500 From: Ludovic =?UTF-8?Q?Court=C3=A8s?= References: <20210106212148.28720-1-leo.prikler@student.tugraz.at> X-URL: http://www.fdn.fr/~lcourtes/ X-Revolutionary-Date: 18 =?UTF-8?Q?Niv=C3=B4se?= an 229 de la =?UTF-8?Q?R=C3=A9volution?= X-PGP-Key-ID: 0x090B11993D9AEBB5 X-PGP-Key: http://www.fdn.fr/~lcourtes/ludovic.asc X-PGP-Fingerprint: 3CE4 6455 8A84 FDC6 9DB4 0CFB 090B 1199 3D9A EBB5 X-OS: x86_64-pc-linux-gnu Date: Thu, 07 Jan 2021 09:35:43 +0100 In-Reply-To: <20210106212148.28720-1-leo.prikler@student.tugraz.at> (Leo Prikler's message of "Wed, 6 Jan 2021 22:21:49 +0100") Message-ID: <87czyhjg9s.fsf@gnu.org> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/27.1 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable X-Spam-Score: -2.3 (--) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -3.3 (---) Leo Prikler skribis: > *gnu/system/shadow.scm (find-duplicates): New variable. > (assert-unique-account-names, assert-unique-group-names): New variables. > (account-activation): Use them here. Final nitpicks! :-) > +(define (find-duplicates list) Please add a docstring. > + (let loop ((table (make-hash-table)) > + (list list)) You can move =E2=80=98table=E2=80=99 out of the =E2=80=98loop=E2=80=99 argu= ments since it=E2=80=99s mutated anyway. OK with these changes! Thanks, Ludo=E2=80=99. From unknown Sat Sep 13 13:42:32 2025 X-Loop: help-debbugs@gnu.org Subject: bug#45570: [PATCH v3] system: Assert, that user and group names are unique. References: In-Reply-To: Resent-From: Leo Prikler Original-Sender: "Debbugs-submit" Resent-CC: bug-guix@gnu.org Resent-Date: Thu, 07 Jan 2021 11:12:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 45570 X-GNU-PR-Package: guix X-GNU-PR-Keywords: To: 45570@debbugs.gnu.org Cc: ludo@gnu.org, conjaroy@gmail.com Received: via spool by 45570-submit@debbugs.gnu.org id=B45570.161001786227663 (code B ref 45570); Thu, 07 Jan 2021 11:12:01 +0000 Received: (at 45570) by debbugs.gnu.org; 7 Jan 2021 11:11:02 +0000 Received: from localhost ([127.0.0.1]:46652 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1kxTC1-0007Bx-Gn for submit@debbugs.gnu.org; Thu, 07 Jan 2021 06:11:01 -0500 Received: from mailrelay.tugraz.at ([129.27.2.202]:14567) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1kxTBz-0007Bj-SA for 45570@debbugs.gnu.org; Thu, 07 Jan 2021 06:11:00 -0500 Received: from localhost.localdomain (217-149-174-13.nat.highway.telekom.at [217.149.174.13]) by mailrelay.tugraz.at (Postfix) with ESMTPSA id 4DBNns12Rqz3x86; Thu, 7 Jan 2021 12:10:57 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=tugraz.at; s=mailrelay; t=1610017857; bh=tjv9docNCMZsPkru4y8d/dcwxZhXEcYtbXM57f5iSJg=; h=From:To:Cc:Subject:Date; b=mgEMKW+/xS8VBM+0TUEMDUmaG/4+5LFZEb/IDaBIC/o6qnSok0Z5RI7UO8tQkw91R p7Q00GkhILHDJLsWdq1S68wrvaC96QydgAOeWxZovmrXPF2GEsgqA89ZEZmAioxqSc W6YDvWa00CGH0TCuwlMd4mOE1EH1Ug+l8/bNQvoQ= From: Leo Prikler Date: Thu, 7 Jan 2021 12:10:20 +0100 Message-Id: <20210107111019.7277-1-leo.prikler@student.tugraz.at> X-Mailer: git-send-email 2.30.0 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-TUG-Backscatter-control: bt4lQm5Tva3SBgCuw0EnZw X-Spam-Scanner: SpamAssassin 3.003001 X-Spam-Score-relay: -1.9 X-Scanned-By: MIMEDefang 2.74 on 129.27.10.117 X-Spam-Score: -2.3 (--) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -3.3 (---) *gnu/system/shadow.scm (find-duplicates): New variable. (assert-unique-account-names, assert-unique-group-names): New variables. (account-activation): Use them here. --- gnu/system/shadow.scm | 44 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 44 insertions(+) diff --git a/gnu/system/shadow.scm b/gnu/system/shadow.scm index a69339bc07..183b2cd387 100644 --- a/gnu/system/shadow.scm +++ b/gnu/system/shadow.scm @@ -20,6 +20,7 @@ ;;; along with GNU Guix. If not, see . (define-module (gnu system shadow) + #:use-module ((guix diagnostics) #:select (formatted-message)) #:use-module (guix records) #:use-module (guix gexp) #:use-module (guix store) @@ -34,6 +35,7 @@ #:use-module ((gnu packages admin) #:select (shadow)) #:use-module (gnu packages bash) + #:use-module (ice-9 match) #:use-module (srfi srfi-1) #:use-module (srfi srfi-26) #:use-module (srfi srfi-34) @@ -222,6 +224,46 @@ for a colorful Guile experience.\\n\\n\"))))\n")) (rename-file ".nanorc" ".config/nano/nanorc")) #t)))) +(define (find-duplicates list) + "Find duplicate entries in @var{list}. +Two entries are considered duplicates, if they are @code{equal?} to each other. +This implementation is made asymptotically faster than @code{delete-duplicates} +through the internal use of hash tables." + (let loop ((list list) + ;; We actually modify table in-place, but still allocate it here + ;; so that we only need one level of indentation. + (table (make-hash-table))) + (match list + (() + (hash-fold (lambda (key value seed) + (if (> value 1) + (cons key seed) + seed)) + '() + table)) + ((first . rest) + (hash-set! table first + (1+ (hash-ref table first 0))) + (loop rest table))))) + +(define (assert-unique-account-names users) + (match (find-duplicates (map user-account-name users)) + (() *unspecified*) + (duplicates + (raise + (formatted-message + (G_ "the following accounts appear more than once:~{ ~a~}") + duplicates))))) + +(define (assert-unique-group-names groups) + (match (find-duplicates (map user-group-name groups)) + (() *unspecified*) + (duplicates + (raise + (formatted-message + (G_ "the following groups appear more than once:~{ ~a~}") + duplicates))))) + (define (assert-valid-users/groups users groups) "Raise an error if USERS refer to groups not listed in GROUPS." (let ((groups (list->set (map user-group-name groups)))) @@ -292,6 +334,8 @@ group." (define group-specs (map user-group->gexp groups)) + (assert-unique-account-names accounts) + (assert-unique-group-names groups) (assert-valid-users/groups accounts groups) ;; Add users and user groups. -- 2.30.0 From unknown Sat Sep 13 13:42:32 2025 X-Loop: help-debbugs@gnu.org Subject: bug#45570: [PATCH v2] system: Assert, that user and group names are unique. Resent-From: Leo Prikler Original-Sender: "Debbugs-submit" Resent-CC: bug-guix@gnu.org Resent-Date: Thu, 07 Jan 2021 11:14:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 45570 X-GNU-PR-Package: guix X-GNU-PR-Keywords: To: Ludovic =?UTF-8?Q?Court=C3=A8s?= Cc: 45570@debbugs.gnu.org, conjaroy@gmail.com Received: via spool by 45570-submit@debbugs.gnu.org id=B45570.161001801727881 (code B ref 45570); Thu, 07 Jan 2021 11:14:02 +0000 Received: (at 45570) by debbugs.gnu.org; 7 Jan 2021 11:13:37 +0000 Received: from localhost ([127.0.0.1]:46657 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1kxTEX-0007Fc-2v for submit@debbugs.gnu.org; Thu, 07 Jan 2021 06:13:37 -0500 Received: from mailrelay.tugraz.at ([129.27.2.202]:31087) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1kxTEU-0007FT-QG for 45570@debbugs.gnu.org; Thu, 07 Jan 2021 06:13:35 -0500 Received: from nijino.local (217-149-174-13.nat.highway.telekom.at [217.149.174.13]) by mailrelay.tugraz.at (Postfix) with ESMTPSA id 4DBNrr5HK4z3wCX; Thu, 7 Jan 2021 12:13:32 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=tugraz.at; s=mailrelay; t=1610018012; bh=oei+Q7Q1Gmr42ljEnyc9Ec/xeyzklkeYJz16fmOy8DU=; h=Subject:From:To:Cc:Date:In-Reply-To:References; b=epAywIQc7kKNaOo/pZ3+M1aUSvyRXs+sDmHd8XDEsOjjrSirvHEenJpST1K/q1qpD x1LMSo1azuoKO0MYazDD9xWu9xDsDHn7kHo3C2MeZtcRwdkm0Hp4A7zEIqc08rBkgt Xn07eAkLhimxeAQmc5xk6dAhYN0Gh3XvXtFE4Xeo= Message-ID: <08d83d415bc59d7b86dc7233f48ece7d909069f2.camel@student.tugraz.at> From: Leo Prikler Date: Thu, 07 Jan 2021 12:13:31 +0100 In-Reply-To: <87czyhjg9s.fsf@gnu.org> References: <20210106212148.28720-1-leo.prikler@student.tugraz.at> <87czyhjg9s.fsf@gnu.org> Content-Type: text/plain; charset="UTF-8" User-Agent: Evolution 3.34.2 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-TUG-Backscatter-control: bt4lQm5Tva3SBgCuw0EnZw X-Spam-Scanner: SpamAssassin 3.003001 X-Spam-Score-relay: -1.9 X-Scanned-By: MIMEDefang 2.74 on 129.27.10.117 X-Spam-Score: -2.3 (--) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -3.3 (---) Am Donnerstag, den 07.01.2021, 09:35 +0100 schrieb Ludovic Courtès: > Leo Prikler skribis: > > > *gnu/system/shadow.scm (find-duplicates): New variable. > > (assert-unique-account-names, assert-unique-group-names): New > > variables. > > (account-activation): Use them here. > > Final nitpicks! :-) > > > +(define (find-duplicates list) > > Please add a docstring. Done, see v3. > > + (let loop ((table (make-hash-table)) > > + (list list)) > > You can move ‘table’ out of the ‘loop’ arguments since it’s mutated > anyway. I don't see any benefit from doing so, however. It'd be an additional layer of mutation and if we ever wanted to change to vhashes or alists we'd have to refactor that. Regards, Leo From unknown Sat Sep 13 13:42:32 2025 X-Loop: help-debbugs@gnu.org Subject: bug#45570: [PATCH v3] system: Assert, that user and group names are unique. Resent-From: Ludovic =?UTF-8?Q?Court=C3=A8s?= Original-Sender: "Debbugs-submit" Resent-CC: bug-guix@gnu.org Resent-Date: Mon, 11 Jan 2021 13:10:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 45570 X-GNU-PR-Package: guix X-GNU-PR-Keywords: To: Leo Prikler Cc: 45570@debbugs.gnu.org, conjaroy@gmail.com Received: via spool by 45570-submit@debbugs.gnu.org id=B45570.161037060220341 (code B ref 45570); Mon, 11 Jan 2021 13:10:02 +0000 Received: (at 45570) by debbugs.gnu.org; 11 Jan 2021 13:10:02 +0000 Received: from localhost ([127.0.0.1]:56048 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1kywxN-0005Hs-HO for submit@debbugs.gnu.org; Mon, 11 Jan 2021 08:10:02 -0500 Received: from eggs.gnu.org ([209.51.188.92]:51464) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1kywxM-0005Hb-75 for 45570@debbugs.gnu.org; Mon, 11 Jan 2021 08:10:00 -0500 Received: from fencepost.gnu.org ([2001:470:142:3::e]:36352) by eggs.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kywxE-0003Xx-SO; Mon, 11 Jan 2021 08:09:53 -0500 Received: from [2a01:e0a:1d:7270:af76:b9b:ca24:c465] (port=57912 helo=ribbon) by fencepost.gnu.org with esmtpsa (TLS1.2:RSA_AES_256_CBC_SHA1:256) (Exim 4.82) (envelope-from ) id 1kywxE-0005Cw-8I; Mon, 11 Jan 2021 08:09:52 -0500 From: Ludovic =?UTF-8?Q?Court=C3=A8s?= References: <20210107111019.7277-1-leo.prikler@student.tugraz.at> X-URL: http://www.fdn.fr/~lcourtes/ X-Revolutionary-Date: 22 =?UTF-8?Q?Niv=C3=B4se?= an 229 de la =?UTF-8?Q?R=C3=A9volution?= X-PGP-Key-ID: 0x090B11993D9AEBB5 X-PGP-Key: http://www.fdn.fr/~lcourtes/ludovic.asc X-PGP-Fingerprint: 3CE4 6455 8A84 FDC6 9DB4 0CFB 090B 1199 3D9A EBB5 X-OS: x86_64-pc-linux-gnu Date: Mon, 11 Jan 2021 14:09:49 +0100 In-Reply-To: <20210107111019.7277-1-leo.prikler@student.tugraz.at> (Leo Prikler's message of "Thu, 7 Jan 2021 12:10:20 +0100") Message-ID: <87eeirfwma.fsf@gnu.org> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/27.1 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable X-Spam-Score: -2.3 (--) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -3.3 (---) Hi, Leo Prikler skribis: > *gnu/system/shadow.scm (find-duplicates): New variable. > (assert-unique-account-names, assert-unique-group-names): New variables. > (account-activation): Use them here. LGTM, thanks! :-) Ludo=E2=80=99. From unknown Sat Sep 13 13:42:32 2025 MIME-Version: 1.0 X-Mailer: MIME-tools 5.505 (Entity 5.505) X-Loop: help-debbugs@gnu.org From: help-debbugs@gnu.org (GNU bug Tracking System) To: Jason Conroy Subject: bug#45570: closed (Re: [PATCH v3] system: Assert, that user and group names are unique.) Message-ID: References: <1ef9ad81776e110cb538968f2a124df74bec06ac.camel@student.tugraz.at> X-Gnu-PR-Message: they-closed 45570 X-Gnu-PR-Package: guix Reply-To: 45570@debbugs.gnu.org Date: Mon, 11 Jan 2021 15:07:02 +0000 Content-Type: multipart/mixed; boundary="----------=_1610377622-26183-1" This is a multi-part message in MIME format... ------------=_1610377622-26183-1 Content-Disposition: inline Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Your bug report #45570: operating-system definitions allow duplicate passwd and group entri= es which was filed against the guix package, has been closed. The explanation is attached below, along with your original report. If you require more details, please reply to 45570@debbugs.gnu.org. --=20 45570: http://debbugs.gnu.org/cgi/bugreport.cgi?bug=3D45570 GNU Bug Tracking System Contact help-debbugs@gnu.org with problems ------------=_1610377622-26183-1 Content-Type: message/rfc822 Content-Disposition: inline Content-Transfer-Encoding: 7bit Received: (at 45570-done) by debbugs.gnu.org; 11 Jan 2021 15:06:52 +0000 Received: from localhost ([127.0.0.1]:57782 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1kyymS-0006np-3h for submit@debbugs.gnu.org; Mon, 11 Jan 2021 10:06:52 -0500 Received: from mailrelay.tugraz.at ([129.27.2.202]:45718) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1kyymP-0006nf-M3 for 45570-done@debbugs.gnu.org; Mon, 11 Jan 2021 10:06:50 -0500 Received: from nijino.local (217-149-169-137.nat.highway.telekom.at [217.149.169.137]) by mailrelay.tugraz.at (Postfix) with ESMTPSA id 4DDxr64QFvz1LZ3K; Mon, 11 Jan 2021 16:06:46 +0100 (CET) DKIM-Filter: OpenDKIM Filter v2.11.0 mailrelay.tugraz.at 4DDxr64QFvz1LZ3K DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=tugraz.at; s=mailrelay; t=1610377606; bh=+Z5NoIoOSUu9SY/hX5Ae4TZfwqS2Gxw49EqntTbmWUY=; h=Subject:From:To:Cc:Date:In-Reply-To:References:From; b=t6a/7/nBRipdM0x2HUx2HLeU2gqCW/TkxqlDxQM4bwhV9OdW5vY1NkYESlNcghHB2 BMLa08rKoUu2NBZ4GRSYJ5+jMp7pPFX2wfcwKIzDuad/193DNdsBGiMA1/TL+zj6rV y9HziE9AQYMYjQDW+lTB1EeX4LJel8nzNJjp2tyU= Message-ID: <1ef9ad81776e110cb538968f2a124df74bec06ac.camel@student.tugraz.at> Subject: Re: [PATCH v3] system: Assert, that user and group names are unique. From: Leo Prikler To: Ludovic =?ISO-8859-1?Q?Court=E8s?= Date: Mon, 11 Jan 2021 16:06:45 +0100 In-Reply-To: <87eeirfwma.fsf@gnu.org> References: <20210107111019.7277-1-leo.prikler@student.tugraz.at> <87eeirfwma.fsf@gnu.org> Content-Type: text/plain; charset="UTF-8" User-Agent: Evolution 3.34.2 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-TUG-Backscatter-control: bt4lQm5Tva3SBgCuw0EnZw X-Spam-Scanner: SpamAssassin 3.003001 X-Spam-Score-relay: -1.9 X-Scanned-By: MIMEDefang 2.74 on 129.27.10.116 X-Spam-Score: -2.3 (--) X-Debbugs-Envelope-To: 45570-done Cc: 45570-done@debbugs.gnu.org, conjaroy@gmail.com X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -3.3 (---) Am Montag, den 11.01.2021, 14:09 +0100 schrieb Ludovic Courtès: > Hi, > > Leo Prikler skribis: > > > *gnu/system/shadow.scm (find-duplicates): New variable. > > (assert-unique-account-names, assert-unique-group-names): New > > variables. > > (account-activation): Use them here. > > LGTM, thanks! :-) > > Ludo’. Aaaand it's pushed. ------------=_1610377622-26183-1 Content-Type: message/rfc822 Content-Disposition: inline Content-Transfer-Encoding: 7bit Received: (at submit) by debbugs.gnu.org; 31 Dec 2020 18:15:02 +0000 Received: from localhost ([127.0.0.1]:41520 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1kv2TV-0004Qk-MZ for submit@debbugs.gnu.org; Thu, 31 Dec 2020 13:15:01 -0500 Received: from lists.gnu.org ([209.51.188.17]:60394) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1kv2TU-0004Qd-4T for submit@debbugs.gnu.org; Thu, 31 Dec 2020 13:15:00 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:58334) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kv2TT-0003DV-Vh for bug-guix@gnu.org; Thu, 31 Dec 2020 13:14:59 -0500 Received: from mail-ed1-x52c.google.com ([2a00:1450:4864:20::52c]:38586) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1kv2TS-0002vR-B4 for bug-guix@gnu.org; Thu, 31 Dec 2020 13:14:59 -0500 Received: by mail-ed1-x52c.google.com with SMTP id cw27so18825508edb.5 for ; Thu, 31 Dec 2020 10:14:57 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:from:date:message-id:subject:to; bh=9b93PNMLCrdXmEL0UW8hF06mJAtEV/FdpMrtbUXklt8=; b=Ywe4GZ/h6vtP0tOyEGb25VVjCrZIgOy4i1TcGGlXR5OqibT03e4wn+Ahs9qeZXoAg+ Ve9b+bcOfsM3b51qViNVGj4MToOnY2UCnVaxdzSDiz4uBKYGeH1I4NVqPCnLNwQLIq4c vMIIRIvhMRmkUUl+ReOTmqVaqBo95eM7/Wa38OWTiuorZ1IUDwxz2M6p9a/U4rIZb+Lb 7frcmemaLivs0xW0f0aLFK4RjI2hlTX/jRwERAMur2Bnh27ekKTcyIgo/hpYHz78h2cV koB5amrXjIhduvUSNvOzkEr5BXrv56hpmdavylUB4iI5flXmH6zlrclmvOAItG/oHH9u wzQw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:from:date:message-id:subject:to; bh=9b93PNMLCrdXmEL0UW8hF06mJAtEV/FdpMrtbUXklt8=; b=GQUKfzUI2MEyf6PQ85Lb4YCep1TRbnCRKh3YP5hpfsBNmiUVWafo1SqRGymirlCrfu 1d0T6l6FJBTlpVZ4N9i8td1dVM9pn/LF6ENDvBGO7XSg1aN6qnH7rcBKbpuCqnhHqeUu KecxGyD8Cwty4eez2gEfCiNNBhKpYRcBk3WCteHy8FP1DcVaXIIMWm/6VUpF8Ysefyvr VUm7B+9YGklWar/vdiqSdCKeWzI8Ke/hH/F0VJdIGERSzgVl0vWd3eMngpssF1HeYrhA Ss8Qb+gi39y7LEmg+D33o/IBV+zJVmThxKpvkYHnpHqXCxHbK5LxCwOsckl8u3gdgjeQ JyDA== X-Gm-Message-State: AOAM532h1cvIncE41fuF/e8czhFkcWA72oTPlXIzmdcn52sYrssKU4SN TukMtWl2AqI3z35Ytd789CZrPm84HQMBOhXNVPR+3mzr X-Google-Smtp-Source: ABdhPJzLyqmUJWkTucplTgLXV/PS3KSzIe+K+yFWkJg4zy5HnHdC5GxCILlQYR5OYhZskMeAQFNr2B5ukU5nuHk/1As= X-Received: by 2002:aa7:d916:: with SMTP id a22mr55862083edr.122.1609438495726; Thu, 31 Dec 2020 10:14:55 -0800 (PST) MIME-Version: 1.0 From: Jason Conroy Date: Thu, 31 Dec 2020 13:14:19 -0500 Message-ID: Subject: operating-system definitions allow duplicate passwd and group entries To: bug-guix@gnu.org Content-Type: multipart/mixed; boundary="000000000000d37a7805b7c69949" Received-SPF: pass client-ip=2a00:1450:4864:20::52c; envelope-from=conjaroy@gmail.com; helo=mail-ed1-x52c.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_FROM=0.001, HTML_MESSAGE=0.001, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-Spam-Score: -1.3 (-) X-Debbugs-Envelope-To: submit X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -2.3 (--) --000000000000d37a7805b7c69949 Content-Type: multipart/alternative; boundary="000000000000d37a7605b7c69947" --000000000000d37a7605b7c69947 Content-Type: text/plain; charset="UTF-8" When an operating-system contains multiple users or groups with the same name, instantiating it with `guix system` does not cause a validation failure, nor are the duplicate entries filtered from the resulting /etc files. This duplication can happen in a few different ways: - both entries are manually included in the "users" or "groups" fields of the operating-system - a manually-specified entry collides with an entry defined by a service (via an account-service-type extension) - multiple services define entries that collide with each other Steps to reproduce: call "guix system container" with the attached operating-system definition. --000000000000d37a7605b7c69947 Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable
When an operating-system contains multiple users or g= roups with the same name, instantiating it with `guix system` does not caus= e a validation failure, nor are the duplicate entries filtered from the res= ulting /etc files.

This duplication can happen in = a few different ways:

- both entries are manually = included in the "users" or "groups" fields of the opera= ting-system
- a manually-specified entry collides with an entry d= efined by a service (via an account-service-type extension)
- mul= tiple services define entries that collide with each other

Steps to reproduce: call "guix system container" with th= e attached operating-system definition.
--000000000000d37a7605b7c69947-- --000000000000d37a7805b7c69949 Content-Type: application/octet-stream; name="duplicate-users-and-groups.scm" Content-Disposition: attachment; filename="duplicate-users-and-groups.scm" Content-Transfer-Encoding: base64 Content-ID: X-Attachment-Id: f_kjd4l5un0 KHVzZS1tb2R1bGVzIChnbnUpKQoodXNlLXNlcnZpY2UtbW9kdWxlcyBuZXR3b3JraW5nIHNzaCkK KHVzZS1wYWNrYWdlLW1vZHVsZXMgc2NyZWVuIHNzaCkKCihvcGVyYXRpbmctc3lzdGVtCiAgKGhv c3QtbmFtZSAia29tcHV0aWxvIikKICAodGltZXpvbmUgIkV1cm9wZS9CZXJsaW4iKQogIChsb2Nh bGUgImVuX1VTLnV0ZjgiKQogIChib290bG9hZGVyIChib290bG9hZGVyLWNvbmZpZ3VyYXRpb24K ICAgICAgICAgICAgICAgIChib290bG9hZGVyIGdydWItYm9vdGxvYWRlcikKICAgICAgICAgICAg ICAgICh0YXJnZXQgIi9kZXYvc2RYIikpKQogIChmaWxlLXN5c3RlbXMgKGNvbnMgKGZpbGUtc3lz dGVtCiAgICAgICAgICAgICAgICAgICAgICAgIChkZXZpY2UgKGZpbGUtc3lzdGVtLWxhYmVsICJt eS1yb290IikpCiAgICAgICAgICAgICAgICAgICAgICAgIChtb3VudC1wb2ludCAiLyIpCiAgICAg ICAgICAgICAgICAgICAgICAgICh0eXBlICJleHQ0IikpCiAgICAgICAgICAgICAgICAgICAgICAl YmFzZS1maWxlLXN5c3RlbXMpKQoKICAodXNlcnMgKGFwcGVuZCAobGlzdAoJCSAgOzsgVHdvIG1h bnVhbGx5LXNwZWNpZmllZCB1c2VycyB3aXRoIHRoZSBzYW1lIG5hbWUKCQkgICh1c2VyLWFjY291 bnQKICAgICAgICAgICAgICAgICAgIChuYW1lICJhbGljZSIpCiAgICAgICAgICAgICAgICAgICAo Y29tbWVudCAiQWxpY2UgMSIpCiAgICAgICAgICAgICAgICAgICAoZ3JvdXAgInVzZXJzIikpCgkJ ICAodXNlci1hY2NvdW50CiAgICAgICAgICAgICAgICAgICAobmFtZSAiYWxpY2UiKQogICAgICAg ICAgICAgICAgICAgKGNvbW1lbnQgIkFsaWNlIDIiKQogICAgICAgICAgICAgICAgICAgKGdyb3Vw ICJ1c2VycyIpKQoJCSAgOzsgQSBtYW51YWxseS1zcGVjaWZpZWQgdXNlciB3aXRoIHRoZSBzYW1l IG5hbWUgYXMgYQoJCSAgOzsgdXNlciBkZWZpbmVkIGJ5IHRoZSBvcGVuc3NoLXNlcnZpY2UuCgkJ ICAodXNlci1hY2NvdW50CiAgICAgICAgICAgICAgICAgICAobmFtZSAic3NoZCIpCiAgICAgICAg ICAgICAgICAgICAoY29tbWVudCAiU2VjdXJlIHNoZWxsIHVzZXIiKQogICAgICAgICAgICAgICAg ICAgKGdyb3VwICJzc2hkIikKCQkgICAoc3lzdGVtPyAjdCkpKQogICAgICAgICAgICAgICAlYmFz ZS11c2VyLWFjY291bnRzKSkKCiAgKGdyb3VwcyAoYXBwZW5kIChsaXN0CgkJICA7OyBUd28gbWFu dWFsbHktc3BlY2lmaWVkIGdyb3VwcyB3aXRoIHRoZSBzYW1lIG5hbWUKCQkgICAodXNlci1ncm91 cAoJCSAgICAobmFtZSAicG93ZXItdXNlcnMiKSkKCQkgICAodXNlci1ncm91cAoJCSAgICAobmFt ZSAicG93ZXItdXNlcnMiKSkKCQkgICA7OyBBIG1hbnVhbGx5LXNwZWNpZmllZCBncm91cCB3aXRo IHRoZSBzYW1lIG5hbWUgYXMKCQkgICA7OyBhIGdyb3VwIGRlZmluZWQgYnkgdGhlIG9wZW5zc2gt c2VydmljZS4KCQkgICAodXNlci1ncm91cAoJCSAgICAobmFtZSAic3NoZCIpKSkKCQkgICViYXNl LWdyb3VwcykpCiAgCiAgKHNlcnZpY2VzIChhcHBlbmQgKGxpc3QgKHNlcnZpY2UgZGhjcC1jbGll bnQtc2VydmljZS10eXBlKQogICAgICAgICAgICAgICAgICAgICAgICAgIChzZXJ2aWNlIG9wZW5z c2gtc2VydmljZS10eXBlCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgKG9wZW5z c2gtY29uZmlndXJhdGlvbgogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAob3Bl bnNzaCBvcGVuc3NoLXNhbnMteCkKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAg KHBvcnQtbnVtYmVyIDIyMjIpKSkpCiAgICAgICAgICAgICAgICAgICAgJWJhc2Utc2VydmljZXMp KSkK --000000000000d37a7805b7c69949-- ------------=_1610377622-26183-1--