diff mbox series

[bug#56699,v2] gnu: greetd-service-type: Add greeter-extra-groups config field.

Message ID 87edxqzg95.fsf@muradm.net
State Accepted
Headers show
Series [bug#56699,v2] gnu: greetd-service-type: Add greeter-extra-groups config field. | expand

Checks

Context Check Description
cbaines/comparison success View comparision
cbaines/git-branch success View Git branch
cbaines/applying patch success View Laminar job
cbaines/issue success View issue

Commit Message

muradm Aug. 8, 2022, 7:27 p.m. UTC
Liliana Marie Prikler <liliana.prikler@ist.tugraz.at> writes:

> Am Montag, dem 08.08.2022 um 00:48 +0300 schrieb muradm:
>> ---
>>  doc/guix.texi         |  8 ++++++++
>>  gnu/services/base.scm | 24 +++++++++++-------------
>>  gnu/tests/desktop.scm |  7 +++++++
>>  3 files changed, 26 insertions(+), 13 deletions(-)
>>
>> diff --git a/doc/guix.texi b/doc/guix.texi
>> index 21cee4e369..2b09bea3b0 100644
>> --- a/doc/guix.texi
>> +++ b/doc/guix.texi
>> @@ -18509,6 +18509,14 @@ the 'root' account has just been 
>> created.
>>  @item @code{terminals} (default: @code{'()})
>>  List of @code{greetd-terminal-configuration} per terminal for 
>> which
>>  @code{greetd} should be started.
>> +
>> +@item @code{greeter-groups} (default: @code{'()})
>> +List of groups which should be added to @code{greeter} user. 
>> For
>> instance:
>> +@lisp
>> +(greeter-groups '("seat" "video"))
>> +@end lisp
>> +Note that, however it will fail if @code{seatd-service-type} 
>> is not
>> present,
>> +or to be more specific, @code{seat} group is not present.
> Note that this example will fail if the @code{seat} group does 
> not
> exist.
Which is stated right on the next line.

>> +  (greeter-groups greetd-greeter-groups (default '())))
> I think, we can err a little on the side of verbosity here and 
> make
> clear that it's greeter-supplementary-groups.
done

> Other than that LGTM

Comments

Liliana Marie Prikler Aug. 9, 2022, 6:25 a.m. UTC | #1
Am Montag, dem 08.08.2022 um 22:27 +0300 schrieb muradm:
> 
> Liliana Marie Prikler <liliana.prikler@ist.tugraz.at> writes:
> 
> > Am Montag, dem 08.08.2022 um 00:48 +0300 schrieb muradm:
> > > ---
> > >  doc/guix.texi         |  8 ++++++++
> > >  gnu/services/base.scm | 24 +++++++++++-------------
> > >  gnu/tests/desktop.scm |  7 +++++++
> > >  3 files changed, 26 insertions(+), 13 deletions(-)
> > > 
> > > diff --git a/doc/guix.texi b/doc/guix.texi
> > > index 21cee4e369..2b09bea3b0 100644
> > > --- a/doc/guix.texi
> > > +++ b/doc/guix.texi
> > > @@ -18509,6 +18509,14 @@ the 'root' account has just been 
> > > created.
> > >  @item @code{terminals} (default: @code{'()})
> > >  List of @code{greetd-terminal-configuration} per terminal for 
> > > which
> > >  @code{greetd} should be started.
> > > +
> > > +@item @code{greeter-groups} (default: @code{'()})
> > > +List of groups which should be added to @code{greeter} user. 
> > > For
> > > instance:
> > > +@lisp
> > > +(greeter-groups '("seat" "video"))
> > > +@end lisp
> > > +Note that, however it will fail if @code{seatd-service-type} 
> > > is not
> > > present,
> > > +or to be more specific, @code{seat} group is not present.
> > Note that this example will fail if the @code{seat} group does 
> > not exist.
> Which is stated right on the next line.
In a convoluted way.  "Note that this example will fail if the
@code{seat} group does not exist." is imho easier on the reader.

Cheers
diff mbox series

Patch

From c8ba263cd3323c06cd3044243347e76a85cb9628 Mon Sep 17 00:00:00 2001
From: muradm <mail@muradm.net>
Date: Fri, 22 Jul 2022 14:28:57 +0300
Subject: [PATCH v3] gnu: greetd-service-type: Add greeter-extra-groups config
 field.
To: 56699@debbugs.gnu.org

* gnu/services/base.scm (greetd-service-type): Added configurable
supplementary groups.
[extensions]: Switching accounts-service-type from const to function.
(<greetd-configuration>): Added greeter-supplementary-groups field.
(greetd-accounts-service): New variable, function returning list
necessary accounts for accounts-service-type, including the
greeter-supplementary-groups.
(%greetd-accounts): Removed.
* gnu/tests/desktop.scm (%minimal-services): Add test for
greeter-supplementary-groups.
* doc/guix.texi: Mention greeter-supplementary-groups field with example.
---
 doc/guix.texi         |  8 ++++++++
 gnu/services/base.scm | 24 +++++++++++-------------
 gnu/tests/desktop.scm |  7 +++++++
 3 files changed, 26 insertions(+), 13 deletions(-)

diff --git a/doc/guix.texi b/doc/guix.texi
index 9a6a5c307d..8eda5bb2c0 100644
--- a/doc/guix.texi
+++ b/doc/guix.texi
@@ -18541,6 +18541,14 @@  the 'root' account has just been created.
 @item @code{terminals} (default: @code{'()})
 List of @code{greetd-terminal-configuration} per terminal for which
 @code{greetd} should be started.
+
+@item @code{greeter-supplementary-groups} (default: @code{'()})
+List of groups which should be added to @code{greeter} user. For instance:
+@lisp
+(greeter-supplementary-groups '("seat" "video"))
+@end lisp
+Note that, however it will fail if @code{seatd-service-type} is not present,
+or to be more specific, @code{seat} group is not present.
 @end table
 @end deftp
 
diff --git a/gnu/services/base.scm b/gnu/services/base.scm
index 27eae75c46..251196b108 100644
--- a/gnu/services/base.scm
+++ b/gnu/services/base.scm
@@ -2918,17 +2918,6 @@  (define (make-greetd-terminal-configuration-file config)
      "user = " default-session-user "\n"
      "command = " default-session-command "\n")))
 
-(define %greetd-accounts
-  (list (user-account
-         (name "greeter")
-         (group "greeter")
-         ;; video group is required for graphical greeters.
-         (supplementary-groups '("video"))
-         (system? #t))
-        (user-group
-         (name "greeter")
-         (system? #t))))
-
 (define %greetd-file-systems
   (list (file-system
           (device "none")
@@ -2956,7 +2945,16 @@  (define-record-type* <greetd-configuration>
   greetd-configuration?
   (motd greetd-motd (default %default-motd))
   (allow-empty-passwords? greetd-allow-empty-passwords? (default #t))
-  (terminals greetd-terminals (default '())))
+  (terminals greetd-terminals (default '()))
+  (greeter-supplementary-groups greetd-greeter-supplementary-groups (default '())))
+
+(define (greetd-accounts-service config)
+  (list (user-group (name "greeter") (system? #t))
+        (user-account
+         (name "greeter")
+         (group "greeter")
+         (supplementary-groups (greetd-greeter-supplementary-groups config))
+         (system? #t))))
 
 (define (make-greetd-pam-mount-conf-file config)
   (computed-file
@@ -3033,7 +3031,7 @@  (define greetd-service-type
 login manager daemon.")
    (extensions
     (list
-     (service-extension account-service-type (const %greetd-accounts))
+     (service-extension account-service-type greetd-accounts-service)
      (service-extension file-system-service-type (const %greetd-file-systems))
      (service-extension etc-service-type greetd-etc-service)
      (service-extension pam-root-service-type greetd-pam-service)
diff --git a/gnu/tests/desktop.scm b/gnu/tests/desktop.scm
index 25971f9225..f20423f0aa 100644
--- a/gnu/tests/desktop.scm
+++ b/gnu/tests/desktop.scm
@@ -122,6 +122,7 @@  (define %minimal-services
     (service seatd-service-type)
     (service greetd-service-type
              (greetd-configuration
+              (greeter-supplementary-groups '("input" "video"))
               (terminals
                (list
                 ;; we can make any terminal active by default
@@ -286,6 +287,12 @@  (define (greetd-pid-to-sock pid)
               (marionette-type "echo alice > /run/user/1000/test\n" marionette)
               (file-get-all-strings "/run/user/1000/test")))
 
+          (test-equal "check greeter user has correct groups"
+            "greeter input video\n"
+            (begin
+              (marionette-type "id -Gn greeter > /run/user/1000/greeter-groups\n" marionette)
+              (file-get-all-strings "/run/user/1000/greeter-groups")))
+
           (test-assert "screendump"
             (begin
               (marionette-control (string-append "screendump " #$output
-- 
2.37.1