guix-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[PATCH 4/4] services: openssh: Add 'subsystems' option.


From: Clément Lassieur
Subject: [PATCH 4/4] services: openssh: Add 'subsystems' option.
Date: Tue, 21 Feb 2017 00:53:55 +0100

* gnu/services/ssh.scm (openssh-config-file): Add it.
  (<openssh-configuration>)[subsystems]: Add it.
* doc/guix.texi (Networking Services): Document it.
---
 doc/guix.texi        | 19 +++++++++++++
 gnu/services/ssh.scm | 80 +++++++++++++++++++++++++++++-----------------------
 2 files changed, 64 insertions(+), 35 deletions(-)

diff --git a/doc/guix.texi b/doc/guix.texi
index db0bf0f9b..69ff33149 100644
--- a/doc/guix.texi
+++ b/doc/guix.texi
@@ -9175,6 +9175,25 @@ equivalent role to password authentication, you should 
disable either
 @item @code{print-last-log?} (default: @code{#t})
 Specifies whether @command{sshd} should print the date and time of the
 last user login when a user logs in interactively.
+
address@hidden @code{subsystems} (default: @code{'()})
+Configures external subsystems (e.g. file transfer daemon).
+
+This is a list of two-element tuples, where each tuple contains the
+subsystem name and a command (with optional arguments) to execute upon
+subsystem request.
+
+The command @command{sftp-server} implements the SFTP file transfer
+subsystem.
address@hidden
+'(("sftp" "/usr/libexec/sftp-server"))
address@hidden example
+
+Alternately the name @command{internal-sftp} implements an in-process
+SFTP server.
address@hidden
+'(("sftp" "internal-sftp"))
address@hidden example
 @end table
 @end deftp
 
diff --git a/gnu/services/ssh.scm b/gnu/services/ssh.scm
index 9e1449743..054743d11 100644
--- a/gnu/services/ssh.scm
+++ b/gnu/services/ssh.scm
@@ -280,7 +280,9 @@ The other options should be self-descriptive."
   (use-pam?              openssh-configuration-use-pam?
                          (default #t)) ;Boolean
   (print-last-log?       openssh-configuration-print-last-log?
-                         (default #t))) ;Boolean
+                         (default #t)) ;Boolean
+  (subsystems            openssh-configuration-subsystems
+                         (default '()))) ;List of two-element tuples
 
 (define %openssh-accounts
   (list (user-group (name "sshd") (system? #t))
@@ -314,40 +316,48 @@ The other options should be self-descriptive."
   "Return the sshd configuration file corresponding to CONFIG."
   (computed-file
    "sshd_config"
-   #~(call-with-output-file #$output
-       (lambda (port)
-         (display "# Generated by 'openssh-service'.\n" port)
-         (format port "Port ~a\n"
-                 #$(number->string (openssh-configuration-port-number config)))
-         (format port "PermitRootLogin ~a\n"
-                 #$(match (openssh-configuration-permit-root-login config)
-                     (#t "yes")
-                     (#f "no")
-                     ('without-password "without-password")))
-         (format port "PermitEmptyPasswords ~a\n"
-                 #$(if (openssh-configuration-allow-empty-passwords? config)
-                       "yes" "no"))
-         (format port "PasswordAuthentication ~a\n"
-                 #$(if (openssh-configuration-password-authentication? config)
-                       "yes" "no"))
-         (format port "PubkeyAuthentication ~a\n"
-                 #$(if (openssh-configuration-public-key-authentication? 
config)
-                       "yes" "no"))
-         (format port "X11Forwarding ~a\n"
-                 #$(if (openssh-configuration-x11-forwarding? config)
-                       "yes" "no"))
-         (format port "PidFile ~a\n"
-                 #$(openssh-configuration-pid-file config))
-         (format port "ChallengeResponseAuthentication ~a\n"
-                 #$(if (openssh-challenge-response-authentication? config)
-                       "yes" "no"))
-         (format port "UsePAM ~a\n"
-                 #$(if (openssh-configuration-use-pam? config)
-                       "yes" "no"))
-         (format port "PrintLastLog ~a\n"
-                 #$(if (openssh-configuration-print-last-log? config)
-                       "yes" "no"))
-         #t))))
+   #~(begin
+       (use-modules (ice-9 match))
+       (call-with-output-file #$output
+         (lambda (port)
+           (display "# Generated by 'openssh-service'.\n" port)
+           (format port "Port ~a\n"
+                   #$(number->string
+                      (openssh-configuration-port-number config)))
+           (format port "PermitRootLogin ~a\n"
+                   #$(match (openssh-configuration-permit-root-login config)
+                       (#t "yes")
+                       (#f "no")
+                       ('without-password "without-password")))
+           (format port "PermitEmptyPasswords ~a\n"
+                   #$(if (openssh-configuration-allow-empty-passwords? config)
+                         "yes" "no"))
+           (format port "PasswordAuthentication ~a\n"
+                   #$(if (openssh-configuration-password-authentication? 
config)
+                         "yes" "no"))
+           (format port "PubkeyAuthentication ~a\n"
+                   #$(if (openssh-configuration-public-key-authentication?
+                          config)
+                         "yes" "no"))
+           (format port "X11Forwarding ~a\n"
+                   #$(if (openssh-configuration-x11-forwarding? config)
+                         "yes" "no"))
+           (format port "PidFile ~a\n"
+                   #$(openssh-configuration-pid-file config))
+           (format port "ChallengeResponseAuthentication ~a\n"
+                   #$(if (openssh-challenge-response-authentication? config)
+                         "yes" "no"))
+           (format port "UsePAM ~a\n"
+                   #$(if (openssh-configuration-use-pam? config)
+                         "yes" "no"))
+           (format port "PrintLastLog ~a\n"
+                   #$(if (openssh-configuration-print-last-log? config)
+                         "yes" "no"))
+           (for-each
+            (match-lambda
+              ((name command) (format port "Subsystem\t~a\t~a\n" name 
command)))
+            '#$(openssh-configuration-subsystems config))
+           #t)))))
 
 (define (openssh-shepherd-service config)
   "Return a <shepherd-service> for openssh with CONFIG."
-- 
2.11.1




reply via email to

[Prev in Thread] Current Thread [Next in Thread]