all messages for Guix-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: "André Batista" <nandre@riseup.net>
To: 56327@debbugs.gnu.org
Subject: bug#56327: Regression: openssh service fails to start if system has no IPv6
Date: Thu, 30 Jun 2022 16:31:41 -0300	[thread overview]
Message-ID: <Yr36HQJ/ROA2Z7wh@andel> (raw)
In-Reply-To: <Yr32oUimYFuhrFrB@andel>

[-- Attachment #1: Type: text/plain, Size: 212 bytes --]

I've tested the following patch, which tests for IPv6 support, on
both a system without IPv6 and another with it, but I have not tested
on a system with shepherd < 0.9.1. Hopefuly it works as expected.

Cheers!


[-- Attachment #2: ssh-service.patch --]
[-- Type: text/plain, Size: 3916 bytes --]

From 30feda7b5ce8803b10e4bca8e86e1caaadc71596 Mon Sep 17 00:00:00 2001
In-Reply-To: <Yr32oUimYFuhrFrB@andel>
References: <Yr32oUimYFuhrFrB@andel>
From: =?UTF-8?q?Andr=C3=A9=20Batista?= <nandre@riseup.net>
Date: Thu, 30 Jun 2022 15:36:03 -0300
Subject: [PATCH] services: openssh: Check if IPv6 is supported and start
 service accordingly.
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
To: 56327@debbugs.gnu.org

Fixes <https://issues.guix.gnu.org/56327>.
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(-)

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


  reply	other threads:[~2022-06-30 19:32 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-06-30 19:20 bug#56327: Regression: openssh service fails to start if system has no IPv6 André Batista
2022-06-30 19:31 ` André Batista [this message]
2022-07-01 21:56   ` Ludovic Courtès
2022-07-02  0:27     ` André Batista

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=Yr36HQJ/ROA2Z7wh@andel \
    --to=nandre@riseup.net \
    --cc=56327@debbugs.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/guix.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.