diff mbox series

openssh: Don't hardcode the dir in sshd.service

Message ID 20231026070440.737673-1-mingli.yu@windriver.com
State Accepted, archived
Commit 977820725c39736061b649389864a53e112e213d
Headers show
Series openssh: Don't hardcode the dir in sshd.service | expand

Commit Message

Yu, Mingli Oct. 26, 2023, 7:04 a.m. UTC
From: Mingli Yu <mingli.yu@windriver.com>

Don't hardcode the directory of the binary in sshd.service.

Signed-off-by: Mingli Yu <mingli.yu@windriver.com>
---
 meta/recipes-connectivity/openssh/openssh/sshd.service | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

Jörg Sommer Oct. 26, 2023, 9:53 a.m. UTC | #1
On 26.10.23 09:04, Yu, Mingli via lists.openembedded.org wrote:
> From: Mingli Yu <mingli.yu@windriver.com>
> 
> Don't hardcode the directory of the binary in sshd.service.
> 
> Signed-off-by: Mingli Yu <mingli.yu@windriver.com>
> ---
>  meta/recipes-connectivity/openssh/openssh/sshd.service | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/meta/recipes-connectivity/openssh/openssh/sshd.service b/meta/recipes-connectivity/openssh/openssh/sshd.service
> index 6ace67d8ae..2a997b656a 100644
> --- a/meta/recipes-connectivity/openssh/openssh/sshd.service
> +++ b/meta/recipes-connectivity/openssh/openssh/sshd.service
> @@ -6,7 +6,7 @@ After=sshdgenkeys.service
>  [Service]
>  Environment="SSHD_OPTS="
>  EnvironmentFile=-/etc/default/ssh
> -ExecStartPre=/usr/bin/mkdir -p /var/run/sshd
> +ExecStartPre=@BASE_BINDIR@/mkdir -p /var/run/sshd

How about using `RuntimeDirectory=sshd` or don't hardcode any path and
call `ExecStartPre=mkdir -p …`

>  ExecStart=-@SBINDIR@/sshd -D $SSHD_OPTS
>  ExecReload=@BASE_BINDIR@/kill -HUP $MAINPID

Same here. This would match the example in the Manual page
systemd.service(5):

```
ExecReload=
    Commands to execute to trigger a configuration reload in the
service. This argument takes multiple command lines, following the same
scheme as described
    for ExecStart= above. Use of this setting is optional. Specifier and
environment variable substitution is supported here following the same
scheme as for
    ExecStart=.

    One additional, special environment variable is set: if known,
$MAINPID is set to the main process of the daemon, and may be used for
command lines like
    the following:

        ExecReload=kill -HUP $MAINPID
```

>  KillMode=process


Kind regards

Jörg Sommer
diff mbox series

Patch

diff --git a/meta/recipes-connectivity/openssh/openssh/sshd.service b/meta/recipes-connectivity/openssh/openssh/sshd.service
index 6ace67d8ae..2a997b656a 100644
--- a/meta/recipes-connectivity/openssh/openssh/sshd.service
+++ b/meta/recipes-connectivity/openssh/openssh/sshd.service
@@ -6,7 +6,7 @@  After=sshdgenkeys.service
 [Service]
 Environment="SSHD_OPTS="
 EnvironmentFile=-/etc/default/ssh
-ExecStartPre=/usr/bin/mkdir -p /var/run/sshd
+ExecStartPre=@BASE_BINDIR@/mkdir -p /var/run/sshd
 ExecStart=-@SBINDIR@/sshd -D $SSHD_OPTS
 ExecReload=@BASE_BINDIR@/kill -HUP $MAINPID
 KillMode=process