From 4452bdb483efbf9bc623d27a1954ddaa67463680 Mon Sep 17 00:00:00 2001 From: Fiona Klute Date: Mon, 4 May 2026 01:25:04 +0200 Subject: [PATCH] package/openssh: explicitly configure PID file directory OpenSSH checks during ./configure if the default location /var/run exists on the build host, and defaults to ${sysconfdir} (/etc/ssh in Buildroot) if not. This can break e.g. in a sandbox with its own mount namespace where there is no reason to create a /var. On the target this leads to errors when starting/stopping the service from the init script, which expects the PID file at /var/run/sshd.pid if sshd is running. A "stop" (including as part of "restart") or "reload" will always fail with no /usr/sbin/sshd found; none killed from start-stop-daemon, even though sshd is running (because the PID file doesn't exist where start-stop-daemon tries to read it). On the other hand, a "start" command will try to start sshd even if it is already running, because it cannot detect the running instance. Unfortunately sshd does not fail directly in that situation (so the init script completes), but something like the following appears in the log: [May 04 14:48:05] auth sshd[4592]: error: Bind to port 22 on 0.0.0.0 failed: Address in use. [May 04 14:48:05] auth sshd[4592]: error: Bind to port 22 on :: failed: Address in use. [May 04 14:48:05] auth sshd[4592]: fatal: Cannot bind any address. Explicitly setting --with-pid-dir=/var/run overrides either default, and only logs a warning if /var/run does not exist. [1] https://github.com/openssh/openssh-portable/blob/5fa60ae0d2ed3fc441f54c9349afbd63b6301929/configure.ac#L5568-L5576 Signed-off-by: Fiona Klute [Marcus: expand commit message after discussion on ML] Signed-off-by: Marcus Hoffmann (cherry picked from commit c09bec68f14f39e99b40eda89e538a6f4075fe98) Signed-off-by: Thomas Perale --- package/openssh/openssh.mk | 1 + 1 file changed, 1 insertion(+) diff --git a/package/openssh/openssh.mk b/package/openssh/openssh.mk index b5e4645b50..f0c542df23 100644 --- a/package/openssh/openssh.mk +++ b/package/openssh/openssh.mk @@ -23,6 +23,7 @@ OPENSSH_CONF_ENV = \ OPENSSH_CPE_ID_VENDOR = openbsd OPENSSH_CONF_OPTS = \ --sysconfdir=/etc/ssh \ + --with-pid-dir=/var/run \ --with-default-path=$(BR2_SYSTEM_DEFAULT_PATH) \ $(if $(BR2_PACKAGE_OPENSSH_SANDBOX),--with-sandbox,--without-sandbox) \ --disable-lastlog \