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: Ludovic Courtès <ludo <at> gnu.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: Wed, 06 Jan 2021 14:32:10 +0100
Hi,

Leo Prikler <leo.prikler <at> student.tugraz.at> 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.

>>   (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?

Thanks,
Ludo’.




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.