diff options
| author | Ludovic Courtès <ludo@gnu.org> | 2017-09-21 23:52:45 +0200 |
|---|---|---|
| committer | Ludovic Courtès <ludo@gnu.org> | 2017-09-22 00:05:08 +0200 |
| commit | fbc31dc1247d3a494246e69f3cf28476af9eb9d6 (patch) | |
| tree | 6d84652594ea43264c798e35dd6045894f7417f9 /gnu/system/pam.scm | |
| parent | db4e8fd5d4a07d3be8ce68fb96722ef7077c0eee (diff) | |
services: Move 'session-environment-service-type' to pam.scm.
* gnu/services/base.scm (environment-variables->environment-file)
(session-environment-service-type)
(session-environment-service): Move to...
* gnu/system/pam.scm: ... here.
Diffstat (limited to 'gnu/system/pam.scm')
| -rw-r--r-- | gnu/system/pam.scm | 47 |
1 files changed, 46 insertions, 1 deletions
diff --git a/gnu/system/pam.scm b/gnu/system/pam.scm index eedf9339465..13f76a50ed7 100644 --- a/gnu/system/pam.scm +++ b/gnu/system/pam.scm | |||
| @@ -1,5 +1,5 @@ | |||
| 1 | ;;; GNU Guix --- Functional package management for GNU | 1 | ;;; GNU Guix --- Functional package management for GNU |
| 2 | ;;; Copyright © 2013, 2014, 2015, 2016 Ludovic Courtès <ludo@gnu.org> | 2 | ;;; Copyright © 2013, 2014, 2015, 2016, 2017 Ludovic Courtès <ludo@gnu.org> |
| 3 | ;;; | 3 | ;;; |
| 4 | ;;; This file is part of GNU Guix. | 4 | ;;; This file is part of GNU Guix. |
| 5 | ;;; | 5 | ;;; |
| @@ -50,6 +50,9 @@ | |||
| 50 | unix-pam-service | 50 | unix-pam-service |
| 51 | base-pam-services | 51 | base-pam-services |
| 52 | 52 | ||
| 53 | session-environment-service | ||
| 54 | session-environment-service-type | ||
| 55 | |||
| 53 | pam-root-service-type | 56 | pam-root-service-type |
| 54 | pam-root-service)) | 57 | pam-root-service)) |
| 55 | 58 | ||
| @@ -278,6 +281,48 @@ authenticate to run COMMAND." | |||
| 278 | 281 | ||
| 279 | 282 | ||
| 280 | ;;; | 283 | ;;; |
| 284 | ;;; System-wide environment variables. | ||
| 285 | ;;; | ||
| 286 | |||
| 287 | (define (environment-variables->environment-file vars) | ||
| 288 | "Return a file for pam_env(8) that contains environment variables VARS." | ||
| 289 | (apply mixed-text-file "environment" | ||
| 290 | (append-map (match-lambda | ||
| 291 | ((key . value) | ||
| 292 | (list key "=" value "\n"))) | ||
| 293 | vars))) | ||
| 294 | |||
| 295 | (define session-environment-service-type | ||
| 296 | (service-type | ||
| 297 | (name 'session-environment) | ||
| 298 | (extensions | ||
| 299 | (list (service-extension | ||
| 300 | etc-service-type | ||
| 301 | (lambda (vars) | ||
| 302 | (list `("environment" | ||
| 303 | ,(environment-variables->environment-file vars))))))) | ||
| 304 | (compose concatenate) | ||
| 305 | (extend append) | ||
| 306 | (description | ||
| 307 | "Populate @file{/etc/environment}, which is honored by @code{pam_env}, | ||
| 308 | with the specified environment variables. The value of this service is a list | ||
| 309 | of name/value pairs for environments variables, such as: | ||
| 310 | |||
| 311 | @example | ||
| 312 | '((\"TZ\" . \"Canada/Pacific\")) | ||
| 313 | @end example\n"))) | ||
| 314 | |||
| 315 | (define (session-environment-service vars) | ||
| 316 | "Return a service that builds the @file{/etc/environment}, which can be read | ||
| 317 | by PAM-aware applications to set environment variables for sessions. | ||
| 318 | |||
| 319 | VARS should be an association list in which both the keys and the values are | ||
| 320 | strings or string-valued gexps." | ||
| 321 | (service session-environment-service-type vars)) | ||
| 322 | |||
| 323 | |||
| 324 | |||
| 325 | ;;; | ||
| 281 | ;;; PAM root service. | 326 | ;;; PAM root service. |
| 282 | ;;; | 327 | ;;; |
| 283 | 328 | ||
