diff options
| author | Ludovic Courtès <ludo@gnu.org> | 2022-07-01 16:29:53 +0200 |
|---|---|---|
| committer | Ludovic Courtès <ludo@gnu.org> | 2022-07-01 23:29:16 +0200 |
| commit | bf7e07d299b197891110fbd8c717badbab06a472 (patch) | |
| tree | 7bbf249ee7a7dcdda5deff42ee70fb503f09671e /gnu/services | |
| parent | b512dadfd603869ac009a432b56f55945841cce0 (diff) | |
services: openssh: Listen on IPv6 only when IPv6 is supported.
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.
Use it in 'start' method.
Diffstat (limited to 'gnu/services')
| -rw-r--r-- | gnu/services/ssh.scm | 20 |
1 files changed, 16 insertions, 4 deletions
diff --git a/gnu/services/ssh.scm b/gnu/services/ssh.scm index 57d3ad218c9..72e71835908 100644 --- a/gnu/services/ssh.scm +++ b/gnu/services/ssh.scm | |||
| @@ -536,6 +536,15 @@ of user-name/file-like tuples." | |||
| 536 | #~(and (defined? 'make-inetd-constructor) | 536 | #~(and (defined? 'make-inetd-constructor) |
| 537 | (not (string=? (@ (shepherd config) Version) "0.9.0")))) | 537 | (not (string=? (@ (shepherd config) Version) "0.9.0")))) |
| 538 | 538 | ||
| 539 | (define ipv6-support? | ||
| 540 | ;; Expression that returns true if IPv6 support is available. | ||
| 541 | #~(catch 'system-error | ||
| 542 | (lambda () | ||
| 543 | (let ((sock (socket AF_INET6 SOCK_STREAM 0))) | ||
| 544 | (close-port sock) | ||
| 545 | #t)) | ||
| 546 | (const #f))) | ||
| 547 | |||
| 539 | (list (shepherd-service | 548 | (list (shepherd-service |
| 540 | (documentation "OpenSSH server.") | 549 | (documentation "OpenSSH server.") |
| 541 | (requirement '(syslogd loopback)) | 550 | (requirement '(syslogd loopback)) |
| @@ -544,12 +553,15 @@ of user-name/file-like tuples." | |||
| 544 | (start #~(if #$inetd-style? | 553 | (start #~(if #$inetd-style? |
| 545 | (make-inetd-constructor | 554 | (make-inetd-constructor |
| 546 | (append #$openssh-command '("-i")) | 555 | (append #$openssh-command '("-i")) |
| 547 | (list (endpoint | 556 | (cons (endpoint |
| 548 | (make-socket-address AF_INET INADDR_ANY | 557 | (make-socket-address AF_INET INADDR_ANY |
| 549 | #$port-number)) | 558 | #$port-number)) |
| 550 | (endpoint | 559 | (if #$ipv6-support? |
| 551 | (make-socket-address AF_INET6 IN6ADDR_ANY | 560 | (list |
| 552 | #$port-number))) | 561 | (endpoint |
| 562 | (make-socket-address AF_INET6 IN6ADDR_ANY | ||
| 563 | #$port-number))) | ||
| 564 | '())) | ||
| 553 | #:max-connections #$max-connections) | 565 | #:max-connections #$max-connections) |
| 554 | (make-forkexec-constructor #$openssh-command | 566 | (make-forkexec-constructor #$openssh-command |
| 555 | #:pid-file #$pid-file))) | 567 | #:pid-file #$pid-file))) |
