From 30feda7b5ce8803b10e4bca8e86e1caaadc71596 Mon Sep 17 00:00:00 2001
In-Reply-To: <Yr32oUimYFuhrFrB@andel>
References: <Yr32oUimYFuhrFrB@andel>
service accordingly.
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
To: 56327@debbugs.gnu.org
Reported by Andr� Batista <nandre@riseup.net>.
* gnu/services/ssh.scm (openssh-shepherd-service)[ipv6-support?]: New variable.
<start>: Use it. When using 'make-inetd-constructor', only pass a ipv6
endpoint if the system supports it.
---
gnu/services/ssh.scm | 38 ++++++++++++++++++++++++++------------
1 file changed, 26 insertions(+), 12 deletions(-)
Toggle diff (63 lines)
diff --git a/gnu/services/ssh.scm b/gnu/services/ssh.scm
index 57d3ad218c..050c3aa7c3 100644
--- a/gnu/services/ssh.scm
+++ b/gnu/services/ssh.scm
@@ -8,6 +8,7 @@
;;; Copyright � 2020 Oleg Pykhalov <go.wigust@gmail.com>
;;; Copyright � 2020 Brice Waegeneire <brice@waegenei.re>
;;; Copyright � 2021 Tobias Geerinckx-Rice <me@tobias.gr>
+;;; Copyright � 2022 Andr� Batista <nandre@riseup.net>
;;;
;;; This file is part of GNU Guix.
;;;
@@ -536,23 +537,36 @@ (define inetd-style?
#~(and (defined? 'make-inetd-constructor)
(not (string=? (@ (shepherd config) Version) "0.9.0"))))
+ (define ipv6-support?
+ ;; Helper function to start/stop ssh service on systems with no IPv6.
+ ;; See https://issues.guix.gnu.org/56327.
+ #~(false-if-exception (socket AF_INET6 SOCK_STREAM 0)))
+
(list (shepherd-service
(documentation "OpenSSH server.")
(requirement '(syslogd loopback))
(provision '(ssh-daemon ssh sshd))
- (start #~(if #$inetd-style?
- (make-inetd-constructor
- (append #$openssh-command '("-i"))
- (list (endpoint
- (make-socket-address AF_INET INADDR_ANY
- #$port-number))
- (endpoint
- (make-socket-address AF_INET6 IN6ADDR_ANY
- #$port-number)))
- #:max-connections #$max-connections)
- (make-forkexec-constructor #$openssh-command
- #:pid-file #$pid-file)))
+ (start #~(cond ((and #$inetd-style? #$ipv6-support?)
+ (make-inetd-constructor
+ (append #$openssh-command '("-i"))
+ (list (endpoint
+ (make-socket-address AF_INET INADDR_ANY
+ #$port-number))
+ (endpoint
+ (make-socket-address AF_INET6 IN6ADDR_ANY
+ #$port-number)))
+ #:max-connections #$max-connections))
+ ((and #$inetd-style? (not #$ipv6-support?))
+ (make-inetd-constructor
+ (append #$openssh-command '("-i"))
+ (list (endpoint
+ (make-socket-address AF_INET INADDR_ANY
+ #$port-number)))
+ #:max-connections #$max-connections))
+ (else
+ (make-forkexec-constructor #$openssh-command
+ #:pid-file #$pid-file))))
(stop #~(if #$inetd-style?
(make-inetd-destructor)
(make-kill-destructor)))
--
2.36.0