[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
05/07: services: openssh: Start as an inetd service.
From: |
guix-commits |
Subject: |
05/07: services: openssh: Start as an inetd service. |
Date: |
Wed, 30 Mar 2022 15:46:17 -0400 (EDT) |
civodul pushed a commit to branch wip-shepherd-upgrade
in repository guix.
commit 71b4fba64091fcb3cd674a81b58f4991f48febad
Author: Ludovic Courtès <ludo@gnu.org>
AuthorDate: Mon Mar 28 14:03:45 2022 +0200
services: openssh: Start as an inetd service.
* gnu/services/ssh.scm (openssh-shepherd-service): Use
'make-inetd-constructor' when it is defined.
* gnu/tests/ssh.scm (run-ssh-test)["sshd PID"]: Adjust to cope with
PID-FILE being #f.
* gnu/tests/ssh.scm (%test-openssh): Pass #f as the 'pid-file'
argument.
---
gnu/services/ssh.scm | 16 +++++++++++++---
gnu/tests/ssh.scm | 32 +++++++++++++++++---------------
2 files changed, 30 insertions(+), 18 deletions(-)
diff --git a/gnu/services/ssh.scm b/gnu/services/ssh.scm
index 5c8fe4eef4..6f5501ce73 100644
--- a/gnu/services/ssh.scm
+++ b/gnu/services/ssh.scm
@@ -515,6 +515,9 @@ of user-name/file-like tuples."
(define pid-file
(openssh-configuration-pid-file config))
+ (define port-number
+ (openssh-configuration-port-number config))
+
(define openssh-command
#~(list (string-append #$(openssh-configuration-openssh config)
"/sbin/sshd")
"-D" "-f" #$(openssh-config-file config)))
@@ -523,9 +526,16 @@ of user-name/file-like tuples."
(documentation "OpenSSH server.")
(requirement '(syslogd loopback))
(provision '(ssh-daemon ssh sshd))
- (start #~(make-forkexec-constructor #$openssh-command
- #:pid-file #$pid-file))
- (stop #~(make-kill-destructor))
+ (start #~(if (defined? 'make-inetd-constructor)
+ (make-inetd-constructor
+ (append #$openssh-command '("-i"))
+ (make-socket-address AF_INET INADDR_ANY
+ #$port-number))
+ (make-forkexec-constructor #$openssh-command
+ #:pid-file #$pid-file)))
+ (stop #~(if (defined? 'make-inetd-destructor)
+ (make-inetd-destructor)
+ (make-kill-destructor)))
(auto-start? (openssh-auto-start? config)))))
(define (openssh-pam-services config)
diff --git a/gnu/tests/ssh.scm b/gnu/tests/ssh.scm
index 791ff7b73f..e3dd601603 100644
--- a/gnu/tests/ssh.scm
+++ b/gnu/tests/ssh.scm
@@ -1,5 +1,5 @@
;;; GNU Guix --- Functional package management for GNU
-;;; Copyright © 2016, 2017, 2018, 2019, 2020, 2021 Ludovic Courtès
<ludo@gnu.org>
+;;; Copyright © 2016-2022 Ludovic Courtès <ludo@gnu.org>
;;; Copyright © 2017, 2018 Clément Lassieur <clement@lassieur.org>
;;; Copyright © 2017 Marius Bakke <mbakke@fastmail.com>
;;;
@@ -120,19 +120,21 @@ root with an empty password."
marionette))
;; Check sshd's PID file.
- (test-equal "sshd PID"
- (wait-for-file #$pid-file marionette)
- (marionette-eval
- '(begin
- (use-modules (gnu services herd)
- (srfi srfi-1))
-
- (live-service-running
- (find (lambda (live)
- (memq 'ssh-daemon
- (live-service-provision live)))
- (current-services))))
- marionette))
+ (test-assert "sshd PID"
+ (let ((pid (marionette-eval
+ '(begin
+ (use-modules (gnu services herd)
+ (srfi srfi-1))
+
+ (live-service-running
+ (find (lambda (live)
+ (memq 'ssh-daemon
+ (live-service-provision live)))
+ (current-services))))
+ marionette)))
+ (if #$pid-file
+ (= pid (wait-for-file #$pid-file marionette))
+ pid)))
(test-assert "wait for port 22"
(wait-for-tcp-port 22 marionette))
@@ -222,7 +224,7 @@ root with an empty password."
(openssh-configuration
(permit-root-login #t)
(allow-empty-passwords? #t)))
- "/var/run/sshd.pid"
+ #f ;inetd-style, no PID file
#:sftp? #t))))
(define %test-dropbear
- branch wip-shepherd-upgrade created (now b50cd62fe5), guix-commits, 2022/03/30
- 05/07: services: openssh: Start as an inetd service.,
guix-commits <=
- 02/07: shepherd: Adjust 'fork+exec-command/container' for the Shepherd 0.9., guix-commits, 2022/03/30
- 01/07: gnu: shepherd: Add 0.9.0rc1., guix-commits, 2022/03/30
- 06/07: secret-service: Abstract 'wait-for-readable-fd'., guix-commits, 2022/03/30
- 03/07: services: shepherd: Default to version 0.9., guix-commits, 2022/03/30
- 04/07: home: shepherd: Default to version 0.9., guix-commits, 2022/03/30
- 07/07: secret-service: Allow cooperative scheduling when Fibers is used., guix-commits, 2022/03/30