all messages for Guix-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* bug#45836: cups-service-type duplicates lp group
@ 2021-01-13  1:09 Leo Prikler
  2021-01-13 11:28 ` Ludovic Courtès
  2021-01-14 13:06 ` bug#45836: [PATCH] services: Let cups-service-type reuse base " Leo Prikler
  0 siblings, 2 replies; 9+ messages in thread
From: Leo Prikler @ 2021-01-13  1:09 UTC (permalink / raw)
  To: 45836

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





^ permalink raw reply	[flat|nested] 9+ messages in thread

* bug#45836: cups-service-type duplicates lp group
  2021-01-13  1:09 bug#45836: cups-service-type duplicates lp group Leo Prikler
@ 2021-01-13 11:28 ` Ludovic Courtès
  2021-01-13 12:06   ` Leo Prikler
  2021-01-14 13:06 ` bug#45836: [PATCH] services: Let cups-service-type reuse base " Leo Prikler
  1 sibling, 1 reply; 9+ messages in thread
From: Ludovic Courtès @ 2021-01-13 11:28 UTC (permalink / raw)
  To: Leo Prikler; +Cc: 45836

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).

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

Thanks,
Ludo’.




^ permalink raw reply	[flat|nested] 9+ messages in thread

* bug#45836: cups-service-type duplicates lp group
  2021-01-13 11:28 ` Ludovic Courtès
@ 2021-01-13 12:06   ` Leo Prikler
  2021-01-14 11:38     ` Ludovic Courtès
  0 siblings, 1 reply; 9+ messages in thread
From: Leo Prikler @ 2021-01-13 12:06 UTC (permalink / raw)
  To: Ludovic Courtès; +Cc: 45836

Hi Ludo,

Am Mittwoch, den 13.01.2021, 12:28 +0100 schrieb Ludovic Courtès:
> 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?

>   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





^ permalink raw reply	[flat|nested] 9+ messages in thread

* bug#45836: cups-service-type duplicates lp group
  2021-01-13 12:06   ` Leo Prikler
@ 2021-01-14 11:38     ` Ludovic Courtès
  0 siblings, 0 replies; 9+ messages in thread
From: Ludovic Courtès @ 2021-01-14 11:38 UTC (permalink / raw)
  To: Leo Prikler; +Cc: 45836

Hi Leo,

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

>> 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.

>>   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.

> 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’.




^ permalink raw reply	[flat|nested] 9+ messages in thread

* bug#45836: [PATCH] services: Let cups-service-type reuse base lp group.
  2021-01-13  1:09 bug#45836: cups-service-type duplicates lp group Leo Prikler
  2021-01-13 11:28 ` Ludovic Courtès
@ 2021-01-14 13:06 ` Leo Prikler
  2021-01-16 18:37   ` Ludovic Courtès
  1 sibling, 1 reply; 9+ messages in thread
From: Leo Prikler @ 2021-01-14 13:06 UTC (permalink / raw)
  To: 45836

* 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(-)

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





^ permalink raw reply related	[flat|nested] 9+ messages in thread

* bug#45836: [PATCH] services: Let cups-service-type reuse base lp group.
  2021-01-14 13:06 ` bug#45836: [PATCH] services: Let cups-service-type reuse base " Leo Prikler
@ 2021-01-16 18:37   ` Ludovic Courtès
  2021-01-16 19:49     ` Leo Prikler
  0 siblings, 1 reply; 9+ messages in thread
From: Ludovic Courtès @ 2021-01-16 18:37 UTC (permalink / raw)
  To: Leo Prikler; +Cc: 45836

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.

> 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’.




^ permalink raw reply	[flat|nested] 9+ messages in thread

* bug#45836: [PATCH] services: Let cups-service-type reuse base lp group.
  2021-01-16 18:37   ` Ludovic Courtès
@ 2021-01-16 19:49     ` Leo Prikler
  2021-01-18 14:47       ` Ludovic Courtès
  0 siblings, 1 reply; 9+ messages in thread
From: Leo Prikler @ 2021-01-16 19:49 UTC (permalink / raw)
  To: Ludovic Courtès; +Cc: 45836

Hi,
Am Samstag, den 16.01.2021, 19:37 +0100 schrieb Ludovic Courtès:
> 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.

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





^ permalink raw reply	[flat|nested] 9+ messages in thread

* bug#45836: [PATCH] services: Let cups-service-type reuse base lp group.
  2021-01-16 19:49     ` Leo Prikler
@ 2021-01-18 14:47       ` Ludovic Courtès
  2021-01-20  8:16         ` Leo Prikler
  0 siblings, 1 reply; 9+ messages in thread
From: Ludovic Courtès @ 2021-01-18 14:47 UTC (permalink / raw)
  To: Leo Prikler; +Cc: 45836

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!

Thanks,
Ludo’.




^ permalink raw reply	[flat|nested] 9+ messages in thread

* bug#45836: [PATCH] services: Let cups-service-type reuse base lp group.
  2021-01-18 14:47       ` Ludovic Courtès
@ 2021-01-20  8:16         ` Leo Prikler
  0 siblings, 0 replies; 9+ messages in thread
From: Leo Prikler @ 2021-01-20  8:16 UTC (permalink / raw)
  To: Ludovic Courtès; +Cc: 45836-done

Am Montag, den 18.01.2021, 15:47 +0100 schrieb Ludovic Courtès:
> 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





^ permalink raw reply	[flat|nested] 9+ messages in thread

end of thread, other threads:[~2021-01-20  8:17 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-01-13  1:09 bug#45836: cups-service-type duplicates lp group Leo Prikler
2021-01-13 11:28 ` Ludovic Courtès
2021-01-13 12:06   ` Leo Prikler
2021-01-14 11:38     ` Ludovic Courtès
2021-01-14 13:06 ` bug#45836: [PATCH] services: Let cups-service-type reuse base " Leo Prikler
2021-01-16 18:37   ` Ludovic Courtès
2021-01-16 19:49     ` Leo Prikler
2021-01-18 14:47       ` Ludovic Courtès
2021-01-20  8:16         ` Leo Prikler

Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/guix.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.