GNU bug report logs - #45570
operating-system definitions allow duplicate passwd and group entries

Previous Next

Package: guix;

Reported by: Jason Conroy <conjaroy <at> gmail.com>

Date: Thu, 31 Dec 2020 18:15:02 UTC

Severity: normal

Done: Leo Prikler <leo.prikler <at> student.tugraz.at>

Bug is archived. No further changes may be made.

Full log


View this message in rfc822 format

From: Danny Milosavljevic <dannym <at> scratchpost.org>
To: Leo Prikler <leo.prikler <at> student.tugraz.at>
Cc: 45570 <at> debbugs.gnu.org, conjaroy <at> gmail.com
Subject: bug#45570: [PATCH] system: Assert, that user and group names are unique.
Date: Sat, 2 Jan 2021 02:16:01 +0100
[Message part 1 (text/plain, inline)]
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=? (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))
[Message part 2 (application/pgp-signature, inline)]

This bug report was last modified 4 years and 217 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.