Subject: [PATCH] openssh-service: export AcceptEnv option

From: Martin Castillo <[email-masked]>
Date: Wed, 14 Mar 2018 15:55:14 +0100

(Resent, because I forgot '[PATCH]' in the subject.)

This patch makes AcceptEnv configurable from config.scm.

Questions:
Is the dash in environment-variables correct?
Why are there always two spaces after a period?
Is @option the correct annotation for AcceptEnv?

Martin

From e64e4a908936c5aec0c026324cc08be12edb8ec1 Mon Sep 17 00:00:00 2001
From: Martin Castillo <[email-masked]>
Date: Tue, 13 Mar 2018 16:40:55 +0100
Subject: [PATCH] services: openssh: Add 'AcceptEnv' field.

* gnu/services/ssh.scm (<openssh-configuration>)[AcceptEnv]: New field.
(openssh-config-file): Honor 'AcceptEnv'.
* doc/guix.texi (Networking Services): Document it.
---
 doc/guix.texi        | 11 +++++++++++
 gnu/services/ssh.scm |  7 +++++++
 2 files changed, 18 insertions(+)

diff --git a/doc/guix.texi b/doc/guix.texi
index d3a7908f9..bed0d3359 100644
--- a/doc/guix.texi
+++ b/doc/guix.texi
@@ -11158,6 +11158,17 @@ server.  Alternately, one can specify the @command{sftp-server} command:
            `(("sftp" ,(file-append openssh "/libexec/sftp-server"))))))
 @end example
 
+@item @code{accept-env} (default: @code{'()})
+List of strings describing which environment-variables may be exported.
+
+Each string gets on its own line.  See the @option{AcceptEnv} option in
+@code{sshd_config(5)}.
+@example
+(service openssh-service-type
+         (openssh-configuration
+		  (accept-env '("COLORTERM"))))
+@end example
+
 @item @code{authorized-keys} (default: @code{'()})
 @cindex authorized keys, SSH
 @cindex SSH authorized keys
diff --git a/gnu/services/ssh.scm b/gnu/services/ssh.scm
index 301ba7404..ad778f394 100644
--- a/gnu/services/ssh.scm
+++ b/gnu/services/ssh.scm
@@ -302,6 +302,10 @@ The other options should be self-descriptive."
   (subsystems            openssh-configuration-subsystems
                          (default '(("sftp" "internal-sftp"))))
 
+  ;; list of strings
+  (accept-env            openssh-configuration-accept-env
+                         (default '()))
+
   ;; list of user-name/file-like tuples
   (authorized-keys       openssh-authorized-keys
                          (default '()))
@@ -430,6 +434,9 @@ of user-name/file-like tuples."
            (format port "AuthorizedKeysFile \
  .ssh/authorized_keys .ssh/authorized_keys2 /etc/ssh/authorized_keys.d/%u\n")
 
+           (for-each (lambda (s) (format port "AcceptEnv ~a\n" s))
+                     '#$(openssh-configuration-accept-env config))
+
            (for-each
             (match-lambda
               ((name command) (format port "Subsystem\t~a\t~a\n" name command)))
-- 
2.16.2