diff options
author | Ludovic Courtès <ludo@gnu.org> | 2022-05-22 20:12:27 +0200 |
---|---|---|
committer | Ludovic Courtès <ludo@gnu.org> | 2022-05-22 21:56:40 +0200 |
commit | d2b3400f79ffaed3357650307376ab69a7ec3b1b (patch) | |
tree | 1b531c135fea77d60de3df5408be1500d6a720c9 | |
parent | marionette: Add #:address parameter to 'wait-for-tcp-port'. (diff) | |
download | guix-d2b3400f79ffaed3357650307376ab69a7ec3b1b.tar.gz guix-d2b3400f79ffaed3357650307376ab69a7ec3b1b.tar.bz2 guix-d2b3400f79ffaed3357650307376ab69a7ec3b1b.tar.xz |
services: openssh: Listen on both IPv4 and IPv6.
Fixes <https://issues.guix.gnu.org/55335>.
Reported by Christopher Baines <mail@cbaines.net>.
* gnu/services/ssh.scm (openssh-shepherd-service)[inetd-style?]: New variable.
<start>: Use it. When using 'make-inetd-constructor', pass a list of
endpoints as is possible with the Shepherd 0.9.1.
<stop>: Adjust accordingly.
* gnu/tests/ssh.scm (run-ssh-test)["wait for port 22"]: Rename to...
["wait for port 22, IPv4"]: ... this.
["wait for port 22, IPv6"]: New test.
-rw-r--r-- | gnu/services/ssh.scm | 21 | ||||
-rw-r--r-- | gnu/tests/ssh.scm | 12 |
2 files changed, 28 insertions, 5 deletions
diff --git a/gnu/services/ssh.scm b/gnu/services/ssh.scm index 7fbbe383e5..be5d029374 100644 --- a/gnu/services/ssh.scm +++ b/gnu/services/ssh.scm | |||
@@ -528,19 +528,32 @@ of user-name/file-like tuples." | |||
528 | #~(list (string-append #$(openssh-configuration-openssh config) "/sbin/sshd") | 528 | #~(list (string-append #$(openssh-configuration-openssh config) "/sbin/sshd") |
529 | "-D" "-f" #$(openssh-config-file config))) | 529 | "-D" "-f" #$(openssh-config-file config))) |
530 | 530 | ||
531 | (define inetd-style? | ||
532 | ;; Whether to use 'make-inetd-constructor'. That procedure appeared in | ||
533 | ;; Shepherd 0.9.0, but in 0.9.0, 'make-inetd-constructor' wouldn't let us | ||
534 | ;; pass a list of endpoints, and it wouldn't let us define a service | ||
535 | ;; listening on both IPv4 and IPv6, hence the conditional below. | ||
536 | #~(and (defined? 'make-inetd-constructor) | ||
537 | (not (string=? (@ (shepherd config) Version) "0.9.0")))) | ||
538 | |||
531 | (list (shepherd-service | 539 | (list (shepherd-service |
532 | (documentation "OpenSSH server.") | 540 | (documentation "OpenSSH server.") |
533 | (requirement '(syslogd loopback)) | 541 | (requirement '(syslogd loopback)) |
534 | (provision '(ssh-daemon ssh sshd)) | 542 | (provision '(ssh-daemon ssh sshd)) |
535 | (start #~(if (defined? 'make-inetd-constructor) | 543 | |
544 | (start #~(if #$inetd-style? | ||
536 | (make-inetd-constructor | 545 | (make-inetd-constructor |
537 | (append #$openssh-command '("-i")) | 546 | (append #$openssh-command '("-i")) |
538 | (make-socket-address AF_INET INADDR_ANY | 547 | (list (endpoint |
539 | #$port-number) | 548 | (make-socket-address AF_INET INADDR_ANY |
549 | #$port-number)) | ||
550 | (endpoint | ||
551 | (make-socket-address AF_INET6 IN6ADDR_ANY | ||
552 | #$port-number))) | ||
540 | #:max-connections #$max-connections) | 553 | #:max-connections #$max-connections) |
541 | (make-forkexec-constructor #$openssh-command | 554 | (make-forkexec-constructor #$openssh-command |
542 | #:pid-file #$pid-file))) | 555 | #:pid-file #$pid-file))) |
543 | (stop #~(if (defined? 'make-inetd-destructor) | 556 | (stop #~(if #$inetd-style? |
544 | (make-inetd-destructor) | 557 | (make-inetd-destructor) |
545 | (make-kill-destructor))) | 558 | (make-kill-destructor))) |
546 | (auto-start? (openssh-auto-start? config))))) | 559 | (auto-start? (openssh-auto-start? config))))) |
diff --git a/gnu/tests/ssh.scm b/gnu/tests/ssh.scm index e3dd601603..3f550db5ea 100644 --- a/gnu/tests/ssh.scm +++ b/gnu/tests/ssh.scm | |||
@@ -136,9 +136,19 @@ root with an empty password." | |||
136 | (= pid (wait-for-file #$pid-file marionette)) | 136 | (= pid (wait-for-file #$pid-file marionette)) |
137 | pid))) | 137 | pid))) |
138 | 138 | ||
139 | (test-assert "wait for port 22" | 139 | (test-assert "wait for port 22, IPv4" |
140 | (wait-for-tcp-port 22 marionette)) | 140 | (wait-for-tcp-port 22 marionette)) |
141 | 141 | ||
142 | (test-assert "wait for port 22, IPv6" | ||
143 | ;; Make sure it's also available as IPv6. | ||
144 | ;; See <https://issues.guix.gnu.org/55335>. | ||
145 | (wait-for-tcp-port 22 marionette | ||
146 | #:address | ||
147 | `(make-socket-address | ||
148 | AF_INET6 | ||
149 | (inet-pton AF_INET6 "::1") | ||
150 | 22))) | ||
151 | |||
142 | ;; Connect to the guest over SSH. Make sure we can run a shell | 152 | ;; Connect to the guest over SSH. Make sure we can run a shell |
143 | ;; command there. | 153 | ;; command there. |
144 | (test-equal "shell command" | 154 | (test-equal "shell command" |