diff mbox series

[bug#63314,v2,1/2] system: pam: Let PAM extensions add shepherd requirements.

Message ID 8735435db5.fsf@gnu.org
State New
Headers show
Series [bug#63314,v2,1/2] system: pam: Let PAM extensions add shepherd requirements. | expand

Commit Message

Ludovic Courtès May 11, 2023, 11:15 a.m. UTC
Hi,

Josselin Poiret <dev@jpoiret.xyz> skribis:

> From: Josselin Poiret <dev@jpoiret.xyz>
>
> * gnu/system/pam.scm (<pam-extension>): New record type.
> (pam-shepherd-service): Add Shepherd synchronization point.
>
> * gnu/services/mail.scm (dovecot-shepherd-service)
> * gnu/services/lightdm.scm (lightdm-shepherd-service)
> * gnu/services/mail.scm (opensmtpd-shepherd-service)
> * gnu/services/sddm.scm (sddm-shepherd-service)
> * gnu/services/ssh.scm (lsh-shepherd-service, openssh-shepherd-service)
> * gnu/services/xorg.scm (slim-shepherd-service, gdm-shepherd-service)
> * gnu/services/base.scm (greetd-shepherd-services): Add PAM requirement.
>
> * gnu/system/pam.scm (/etc-entry, extend-configuration,
> pam-root-service-type, pam-root-service)
> * gnu/services/authentication.scm (pam-ldap-pam-service)
> * gnu/services/base.scm (pam-limits-service-type)
> (greetd-pam-service)
> * gnu/services/desktop.scm (pam-gnome-keyring)
> * gnu/services/kerberos.scm (pam-krb5-pam-service)
> * gnu/services/pam-mount.scm (pam-mount-pam-service): Adapt to use
> pam-extension.

Excellent!  I committed with the cosmetic changes below:
Ludo’.
diff mbox series

Patch

diff --git a/gnu/system/pam.scm b/gnu/system/pam.scm
index f624064999..adc40c975f 100644
--- a/gnu/system/pam.scm
+++ b/gnu/system/pam.scm
@@ -1,5 +1,6 @@ 
 ;;; GNU Guix --- Functional package management for GNU
 ;;; Copyright © 2013-2017, 2019-2021 Ludovic Courtès <ludo@gnu.org>
+;;; Copyright © 2023 Josselin Poiret <dev@jpoiret.xyz>
 ;;;
 ;;; This file is part of GNU Guix.
 ;;;
@@ -354,9 +355,9 @@  (define (session-environment-service vars)
 ;;; PAM root service.
 ;;;
 
-;; A PAM transformer consists of a procedure acting on each PAM entry, with an
-;; additional list of shepherd-requirements that the meta PAM shepherd service
-;; will depend on.
+;; Extension of the PAM configuration.  A PAM transformer consists of a
+;; procedure acting on each PAM entry; 'shepherd-requirements' lists services
+;; that the meta 'pam' Shepherd service will depend on.
 (define-record-type* <pam-extension>
   pam-extension make-pam-extension pam-extension?
   (transformer pam-extension-transformer)
@@ -380,12 +381,8 @@  (define (/etc-entry config)
   "Return the /etc/pam.d entry corresponding to CONFIG."
   (match config
     (($ <pam-configuration> services transformers shepherd-requirements)
-     (let ((services
-            (map
-             ;; XXX We need to add identity because compose expects at least
-             ;; one argument for some reason.
-             (apply compose (cons identity transformers))
-             services)))
+     (let ((services (map (apply compose identity transformers)
+                          services)))
        `(("pam.d" ,(pam-services->directory services)))))))
 
 (define (pam-shepherd-service config)
@@ -404,16 +401,15 @@  (define (extend-configuration initial extensions)
   "Extend INITIAL with NEW."
   ;; TODO: Remove deprecation shim.
   (define cleaned-extensions
-    (map
-     (lambda (ext)
-       (cond
-        ((procedure? ext)
-         (begin
-           (warning (G_ "pam-root-service-type transformer extensions should\
-now use the <pam-extension> record."))
-           (pam-extension (transformer ext))))
-        (#t ext)))
-     extensions))
+    (map (lambda (ext)
+           (if (procedure? ext)
+               (begin
+                 (warning (G_ "'pam-root-service-type' extensions should \
+now use the <pam-extension> record~%"))
+                 (pam-extension (transformer ext)))
+               ext))
+         extensions))
+
   (let-values (((services pam-extensions)
                 (partition pam-service? cleaned-extensions)))
     (pam-configuration