summaryrefslogtreecommitdiff
path: root/gnu/system
diff options
context:
space:
mode:
authorLudovic Courtès <ludo@gnu.org>2016-02-06 11:46:09 +0100
committerLudovic Courtès <ludo@gnu.org>2016-02-06 12:01:42 +0100
commit12c00bca92e3eef2b86565924bbefc39397b5497 (patch)
tree2b29083741c8a9181ee307d333547d804d1da4e6 /gnu/system
parentd7bce31c36469167226df9bed95be39db595c2c8 (diff)
system: pam: 'pam-root-service-type' can be extended with transformations.
* gnu/system/pam.scm (<pam-configuration>): New record type. (/etc-entry): Change 'services' parameter' to 'config'. Honor the 'transform' field of CONFIG. (extend-configuration): New procedure. (pam-root-service-type): Use EXTEND-CONFIGURATION as the 'extend' field. (pam-root-service): Add #:transform parameter. Service value is a <pam-configuration>.
Diffstat (limited to 'gnu/system')
-rw-r--r--gnu/system/pam.scm44
1 files changed, 38 insertions, 6 deletions
diff --git a/gnu/system/pam.scm b/gnu/system/pam.scm
index b526c952397..743039daf6c 100644
--- a/gnu/system/pam.scm
+++ b/gnu/system/pam.scm
@@ -23,6 +23,7 @@
23 #:use-module (gnu services) 23 #:use-module (gnu services)
24 #:use-module (ice-9 match) 24 #:use-module (ice-9 match)
25 #:use-module (srfi srfi-1) 25 #:use-module (srfi srfi-1)
26 #:use-module (srfi srfi-11)
26 #:use-module (srfi srfi-26) 27 #:use-module (srfi srfi-26)
27 #:use-module ((guix utils) #:select (%current-system)) 28 #:use-module ((guix utils) #:select (%current-system))
28 #:export (pam-service 29 #:export (pam-service
@@ -208,19 +209,50 @@ authenticate to run COMMAND."
208;;; PAM root service. 209;;; PAM root service.
209;;; 210;;;
210 211
211(define (/etc-entry services) 212;; Overall PAM configuration: a list of services, plus a procedure that takes
212 `(("pam.d" ,(pam-services->directory services)))) 213;; one <pam-service> and returns a <pam-service>. The procedure is used to
214;; implement cross-cutting concerns such as the use of the 'elogind.so'
215;; session module that keeps track of logged-in users.
216(define-record-type* <pam-configuration>
217 pam-configuration make-pam-configuration? pam-configuration?
218 (services pam-configuration-services) ;list of <pam-service>
219 (transform pam-configuration-transform)) ;procedure
220
221(define (/etc-entry config)
222 "Return the /etc/pam.d entry corresponding to CONFIG."
223 (match config
224 (($ <pam-configuration> services transform)
225 (let ((services (map transform services)))
226 `(("pam.d" ,(pam-services->directory services)))))))
227
228(define (extend-configuration initial extensions)
229 "Extend INITIAL with NEW."
230 (let-values (((services procs)
231 (partition pam-service? extensions)))
232 (pam-configuration
233 (services (append (pam-configuration-services initial)
234 services))
235 (transform (apply compose
236 (pam-configuration-transform initial)
237 procs)))))
213 238
214(define pam-root-service-type 239(define pam-root-service-type
215 (service-type (name 'pam) 240 (service-type (name 'pam)
216 (extensions (list (service-extension etc-service-type 241 (extensions (list (service-extension etc-service-type
217 /etc-entry))) 242 /etc-entry)))
243
244 ;; Arguments include <pam-service> as well as procedures.
218 (compose concatenate) 245 (compose concatenate)
219 (extend append))) 246 (extend extend-configuration)))
220 247
221(define (pam-root-service base) 248(define* (pam-root-service base #:key (transform identity))
222 "The \"root\" PAM service, which collects <pam-service> instance and turns 249 "The \"root\" PAM service, which collects <pam-service> instance and turns
223them into a /etc/pam.d directory, including the <pam-service> listed in BASE." 250them into a /etc/pam.d directory, including the <pam-service> listed in BASE.
224 (service pam-root-service-type base)) 251TRANSFORM is a procedure that takes a <pam-service> and returns a
252<pam-service>. It can be used to implement cross-cutting concerns that affect
253all the PAM services."
254 (service pam-root-service-type
255 (pam-configuration (services base)
256 (transform transform))))
225 257
226;;; linux.scm ends here 258;;; linux.scm ends here