cups-service-type duplicates lp group

  • Done
  • quality assurance status badge
Details
2 participants
  • Leo Prikler
  • Ludovic Courtès
Owner
unassigned
Submitted by
Leo Prikler
Severity
normal
L
L
Leo Prikler wrote on 13 Jan 2021 02:09
(address . bug-guix@gnu.org)
a8a72caf989dc39752a4025c6035d82f346fe116.camel@student.tugraz.at
Hello Guix,

it has come to my attention due to the recent reporting of #45830 and
some conversation in IRC, that cups-service-type adds an lp group,
which is already defined in %base-groups. Since both share the same
definition, this is not too big an issue, but it prohibits us from
using a hard error for #45770.

I can currently think of two solutions: Either remove the lp group from
cups-service-type or remove it from base-groups. Neither sounds
particularly awesome. Perhaps we could also delete identical
duplicates before asserting that there are none for #45770, but that
sounds like a little much effort. Any ideas how else to solve this?

Regards,
Leo
L
L
Ludovic Courtès wrote on 13 Jan 2021 12:28
(name . Leo Prikler)(address . leo.prikler@student.tugraz.at)(address . 45836@debbugs.gnu.org)
874kjlcbz1.fsf@gnu.org
Hi Leo,

Leo Prikler <leo.prikler@student.tugraz.at> skribis:

Toggle quote (12 lines)
> it has come to my attention due to the recent reporting of #45830 and
> some conversation in IRC, that cups-service-type adds an lp group,
> which is already defined in %base-groups. Since both share the same
> definition, this is not too big an issue, but it prohibits us from
> using a hard error for #45770.
>
> I can currently think of two solutions: Either remove the lp group from
> cups-service-type or remove it from base-groups. Neither sounds
> particularly awesome. Perhaps we could also delete identical
> duplicates before asserting that there are none for #45770, but that
> sounds like a little much effort. Any ideas how else to solve this?

I’d be pragmatic here:

1. Ignore duplicates that are identical (don’t report them).

2. Remove “lp” from %base-groups since it has no use without CUPS
(right?).

Thanks,
Ludo’.
L
L
Leo Prikler wrote on 13 Jan 2021 13:06
(name . Ludovic Courtès)(address . ludo@gnu.org)(address . 45836@debbugs.gnu.org)
cfbfaf9013c68f0cee70a476f9272d4048837a11.camel@student.tugraz.at
Hi Ludo,

Am Mittwoch, den 13.01.2021, 12:28 +0100 schrieb Ludovic Courtès:
Toggle quote (24 lines)
> Hi Leo,
>
> Leo Prikler <leo.prikler@student.tugraz.at> skribis:
>
> > it has come to my attention due to the recent reporting of #45830
> > and
> > some conversation in IRC, that cups-service-type adds an lp group,
> > which is already defined in %base-groups. Since both share the
> > same
> > definition, this is not too big an issue, but it prohibits us from
> > using a hard error for #45770.
> >
> > I can currently think of two solutions: Either remove the lp group
> > from
> > cups-service-type or remove it from base-groups. Neither sounds
> > particularly awesome. Perhaps we could also delete identical
> > duplicates before asserting that there are none for #45770, but
> > that
> > sounds like a little much effort. Any ideas how else to solve
> > this?
>
> I’d be pragmatic here:
>
> 1. Ignore duplicates that are identical (don’t report them).
Is that still not a problem, because either definition could change?

Toggle quote (2 lines)
> 2. Remove “lp” from %base-groups since it has no use without CUPS
> (right?).
That's probably true, but I fear, that some have already added "lp" to
their config.scm. Would that cause issues? We could also add CUPS to
%base-services or %desktop-services in some way, but that would
probably cause issues with configurations, that already have it.

Regards,
Leo
L
L
Ludovic Courtès wrote on 14 Jan 2021 12:38
(name . Leo Prikler)(address . leo.prikler@student.tugraz.at)(address . 45836@debbugs.gnu.org)
87turj695g.fsf@gnu.org
Hi Leo,

Leo Prikler <leo.prikler@student.tugraz.at> skribis:

Toggle quote (5 lines)
>> I’d be pragmatic here:
>>
>> 1. Ignore duplicates that are identical (don’t report them).
> Is that still not a problem, because either definition could change?

Sure, but that’s a separate issue, which is what #2 addresses.

Toggle quote (5 lines)
>> 2. Remove “lp” from %base-groups since it has no use without CUPS
>> (right?).
> That's probably true, but I fear, that some have already added "lp" to
> their config.scm. Would that cause issues?

Presumably everyone uses ‘%base-groups’ and thus everyone already has a
definition of “lp”, coming from Guix itself.

On second thought, my proposal was not so good because as the comment in
(gnu system shadow) suggests, there are default udev rules that refer to
the “lp” group. So it has to exist (to be on the safe side at least).

So perhaps we can leave things unchanged and simply add a comment in
(gnu services cups) that the “lp” group definition is redundant but kept
here for clarity.

WDYT?

If the two “lp” eventually come to differ, we’ll notice via system
tests… and bug reports.

Toggle quote (4 lines)
> We could also add CUPS to
> %base-services or %desktop-services in some way, but that would
> probably cause issues with configurations, that already have it.

Adding CUPS by default is not a reasonable option, no. :-)

Thanks,
Ludo’.
L
L
Leo Prikler wrote on 14 Jan 2021 14:06
[PATCH] services: Let cups-service-type reuse base lp group.
(address . 45836@debbugs.gnu.org)(address . ludo@gnu.org)
20210114130610.31936-1-leo.prikler@student.tugraz.at
* gnu/services/cups.scm (%cups-accounts): Try to use the lp group defined in
%base-groups.
* gnu/system/shadow.scm (account-activation): Delete duplicate (eq?) users
and groups before transforming them to specs and asserting, that names are
unique.
---
gnu/services/cups.scm | 10 ++++++++--
gnu/system/shadow.scm | 4 ++--
2 files changed, 10 insertions(+), 4 deletions(-)

Toggle diff (50 lines)
diff --git a/gnu/services/cups.scm b/gnu/services/cups.scm
index f10615e59e..17ed04e58b 100644
--- a/gnu/services/cups.scm
+++ b/gnu/services/cups.scm
@@ -32,7 +32,7 @@
#:use-module (guix records)
#:use-module (guix gexp)
#:use-module (ice-9 match)
- #:use-module ((srfi srfi-1) #:select (append-map))
+ #:use-module ((srfi srfi-1) #:select (append-map find))
#:export (cups-service-type
cups-configuration
opaque-cups-configuration
@@ -50,7 +50,13 @@
;;; Code:
(define %cups-accounts
- (list (user-group (name "lp") (system? #t))
+ (list (or
+ ;; The "lp" group should already exist; try to reuse it.
+ (find (lambda (group)
+ (and (user-group? group)
+ (string=? (user-group-name group) "lp")))
+ %base-groups)
+ (user-group (name "lp") (system? #t)))
(user-group (name "lpadmin") (system? #t))
(user-account
(name "lp")
diff --git a/gnu/system/shadow.scm b/gnu/system/shadow.scm
index 0538fb1a24..7c57222716 100644
--- a/gnu/system/shadow.scm
+++ b/gnu/system/shadow.scm
@@ -321,13 +321,13 @@ of user '~a' is undeclared")
<user-group> objects. Raise an error if a user account refers to a undefined
group."
(define accounts
- (filter user-account? accounts+groups))
+ (delete-duplicates (filter user-account? accounts+groups) eq?))
(define user-specs
(map user-account->gexp accounts))
(define groups
- (filter user-group? accounts+groups))
+ (delete-duplicates (filter user-group? accounts+groups) eq?))
(define group-specs
(map user-group->gexp groups))
--
2.30.0
L
L
Ludovic Courtès wrote on 16 Jan 2021 19:37
(name . Leo Prikler)(address . leo.prikler@student.tugraz.at)(address . 45836@debbugs.gnu.org)
875z3wzq1k.fsf@gnu.org
Hi,

Leo Prikler <leo.prikler@student.tugraz.at> skribis:

Toggle quote (6 lines)
> * gnu/services/cups.scm (%cups-accounts): Try to use the lp group defined in
> %base-groups.
> * gnu/system/shadow.scm (account-activation): Delete duplicate (eq?) users
> and groups before transforming them to specs and asserting, that names are
> unique.

[...]

Toggle quote (13 lines)
> (define %cups-accounts
> - (list (user-group (name "lp") (system? #t))
> + (list (or
> + ;; The "lp" group should already exist; try to reuse it.
> + (find (lambda (group)
> + (and (user-group? group)
> + (string=? (user-group-name group) "lp")))
> + %base-groups)
> + (user-group (name "lp") (system? #t)))
> (user-group (name "lpadmin") (system? #t))
> (user-account
> (name "lp")

This bit LGTM, and I think it can be committed in a commit of its own.

Toggle quote (18 lines)
> diff --git a/gnu/system/shadow.scm b/gnu/system/shadow.scm
> index 0538fb1a24..7c57222716 100644
> --- a/gnu/system/shadow.scm
> +++ b/gnu/system/shadow.scm
> @@ -321,13 +321,13 @@ of user '~a' is undeclared")
> <user-group> objects. Raise an error if a user account refers to a undefined
> group."
> (define accounts
> - (filter user-account? accounts+groups))
> + (delete-duplicates (filter user-account? accounts+groups) eq?))
>
> (define user-specs
> (map user-account->gexp accounts))
>
> (define groups
> - (filter user-group? accounts+groups))
> + (delete-duplicates (filter user-group? accounts+groups) eq?))

Why use ‘eq?’? I’d use ‘equal?’, but note that <user-account> records
cannot necessarily be compared with ‘equal?’ because of the thunked
‘home-directory’ field (‘equal?’ is meaningless for procedures).

Thanks,
Ludo’.
L
L
Leo Prikler wrote on 16 Jan 2021 20:49
(name . Ludovic Courtès)(address . ludo@gnu.org)(address . 45836@debbugs.gnu.org)
5c790abbd52abae17c6b449b4982380f9ae26806.camel@student.tugraz.at
Hi,
Am Samstag, den 16.01.2021, 19:37 +0100 schrieb Ludovic Courtès:
Toggle quote (30 lines)
> Hi,
>
> Leo Prikler <leo.prikler@student.tugraz.at> skribis:
>
> > * gnu/services/cups.scm (%cups-accounts): Try to use the lp group
> > defined in
> > %base-groups.
> > * gnu/system/shadow.scm (account-activation): Delete duplicate
> > (eq?) users
> > and groups before transforming them to specs and asserting, that
> > names are
> > unique.
>
> [...]
>
> > (define %cups-accounts
> > - (list (user-group (name "lp") (system? #t))
> > + (list (or
> > + ;; The "lp" group should already exist; try to reuse it.
> > + (find (lambda (group)
> > + (and (user-group? group)
> > + (string=? (user-group-name group) "lp")))
> > + %base-groups)
> > + (user-group (name "lp") (system? #t)))
> > (user-group (name "lpadmin") (system? #t))
> > (user-account
> > (name "lp")
>
> This bit LGTM, and I think it can be committed in a commit of its
> own.
Will do so once I get my working tree is less dirty.

Toggle quote (24 lines)
> > diff --git a/gnu/system/shadow.scm b/gnu/system/shadow.scm
> > index 0538fb1a24..7c57222716 100644
> > --- a/gnu/system/shadow.scm
> > +++ b/gnu/system/shadow.scm
> > @@ -321,13 +321,13 @@ of user '~a' is undeclared")
> > <user-group> objects. Raise an error if a user account refers to
> > a undefined
> > group."
> > (define accounts
> > - (filter user-account? accounts+groups))
> > + (delete-duplicates (filter user-account? accounts+groups)
> > eq?))
> >
> > (define user-specs
> > (map user-account->gexp accounts))
> >
> > (define groups
> > - (filter user-group? accounts+groups))
> > + (delete-duplicates (filter user-group? accounts+groups) eq?))
>
> Why use ‘eq?’? I’d use ‘equal?’, but note that <user-account>
> records
> cannot necessarily be compared with ‘equal?’ because of the thunked
> ‘home-directory’ field (‘equal?’ is meaningless for procedures).
My personal reasoning (and perhaps a rather strong opinion) is, that it
is an error to add duplicate users even if they happen to be equal?.
eq? is only provided as a way out for the specific case of services,
that need to do so for safety reasons – e.g. cups to not allow
overriding of the lp group if it has been removed from the OS groups
for whichever reason.

Regards,
Leo
L
L
Ludovic Courtès wrote on 18 Jan 2021 15:47
(name . Leo Prikler)(address . leo.prikler@student.tugraz.at)(address . 45836@debbugs.gnu.org)
875z3ul2tj.fsf@gnu.org
Hi,

Leo Prikler <leo.prikler@student.tugraz.at> skribis:

Toggle quote (31 lines)
>> > diff --git a/gnu/system/shadow.scm b/gnu/system/shadow.scm
>> > index 0538fb1a24..7c57222716 100644
>> > --- a/gnu/system/shadow.scm
>> > +++ b/gnu/system/shadow.scm
>> > @@ -321,13 +321,13 @@ of user '~a' is undeclared")
>> > <user-group> objects. Raise an error if a user account refers to
>> > a undefined
>> > group."
>> > (define accounts
>> > - (filter user-account? accounts+groups))
>> > + (delete-duplicates (filter user-account? accounts+groups)
>> > eq?))
>> >
>> > (define user-specs
>> > (map user-account->gexp accounts))
>> >
>> > (define groups
>> > - (filter user-group? accounts+groups))
>> > + (delete-duplicates (filter user-group? accounts+groups) eq?))
>>
>> Why use ‘eq?’? I’d use ‘equal?’, but note that <user-account>
>> records
>> cannot necessarily be compared with ‘equal?’ because of the thunked
>> ‘home-directory’ field (‘equal?’ is meaningless for procedures).
> My personal reasoning (and perhaps a rather strong opinion) is, that it
> is an error to add duplicate users even if they happen to be equal?.
> eq? is only provided as a way out for the specific case of services,
> that need to do so for safety reasons – e.g. cups to not allow
> overriding of the lp group if it has been removed from the OS groups
> for whichever reason.

Ah I see, makes sense to me!

Thanks,
Ludo’.
L
L
Leo Prikler wrote on 20 Jan 2021 09:16
(name . Ludovic Courtès)(address . ludo@gnu.org)(address . 45836-done@debbugs.gnu.org)
b8af3871582e4c1f19ffa595774423c81ab4af90.camel@student.tugraz.at
Am Montag, den 18.01.2021, 15:47 +0100 schrieb Ludovic Courtès:
Toggle quote (43 lines)
> Hi,
>
> Leo Prikler <leo.prikler@student.tugraz.at> skribis:
>
> > > > diff --git a/gnu/system/shadow.scm b/gnu/system/shadow.scm
> > > > index 0538fb1a24..7c57222716 100644
> > > > --- a/gnu/system/shadow.scm
> > > > +++ b/gnu/system/shadow.scm
> > > > @@ -321,13 +321,13 @@ of user '~a' is undeclared")
> > > > <user-group> objects. Raise an error if a user account refers
> > > > to
> > > > a undefined
> > > > group."
> > > > (define accounts
> > > > - (filter user-account? accounts+groups))
> > > > + (delete-duplicates (filter user-account? accounts+groups)
> > > > eq?))
> > > >
> > > > (define user-specs
> > > > (map user-account->gexp accounts))
> > > >
> > > > (define groups
> > > > - (filter user-group? accounts+groups))
> > > > + (delete-duplicates (filter user-group? accounts+groups)
> > > > eq?))
> > >
> > > Why use ‘eq?’? I’d use ‘equal?’, but note that <user-account>
> > > records
> > > cannot necessarily be compared with ‘equal?’ because of the
> > > thunked
> > > ‘home-directory’ field (‘equal?’ is meaningless for procedures).
> > My personal reasoning (and perhaps a rather strong opinion) is,
> > that it
> > is an error to add duplicate users even if they happen to be
> > equal?.
> > eq? is only provided as a way out for the specific case of
> > services,
> > that need to do so for safety reasons – e.g. cups to not allow
> > overriding of the lp group if it has been removed from the OS
> > groups
> > for whichever reason.
>
> Ah I see, makes sense to me!
I've now pushed it with eq?, if there's a (good!) reason to change that
to equal?, it can still be done later.

Regards,
Leo
Closed
?