diff mbox series

[v4] openssh: Add PACKAGECONFIG option to customize sshd mode

Message ID 20231206085604.3286804-1-mingli.yu@windriver.com
State New
Headers show
Series [v4] openssh: Add PACKAGECONFIG option to customize sshd mode | expand

Commit Message

Yu, Mingli Dec. 6, 2023, 8:56 a.m. UTC
From: Mingli Yu <mingli.yu@windriver.com>

Add systemd-sshd-socket-mode PACKAGECONFIG option to choose sshd.socket
and systemd-sshd-service-mode PACKAGECONFIG option to choose installing
sshd.service.

The systemd-sshd-socket-mode PACKAGECONFIG option is enabled by default
and user can customize the above two PACKAGECONFIG option to choose the
sshd mode.

Signed-off-by: Mingli Yu <mingli.yu@windriver.com>
---
Changed in v3:
rebase based on https://lore.kernel.org/all/20231201140947.792594-1-xiangyu.chen@eng.windriver.com/

Changed in v4:
make it possible to install both sshd.socket and sshd.service
.../openssh/openssh_9.5p1.bb                  | 25 ++++++++++++++-----
 1 file changed, 19 insertions(+), 6 deletions(-)

Comments

Alex Kiernan Dec. 6, 2023, 10:37 a.m. UTC | #1
On Wed, Dec 6, 2023 at 8:56 AM Yu, Mingli <mingli.yu@eng.windriver.com> wrote:
>
> From: Mingli Yu <mingli.yu@windriver.com>
>
> Add systemd-sshd-socket-mode PACKAGECONFIG option to choose sshd.socket
> and systemd-sshd-service-mode PACKAGECONFIG option to choose installing
> sshd.service.
>
> The systemd-sshd-socket-mode PACKAGECONFIG option is enabled by default
> and user can customize the above two PACKAGECONFIG option to choose the
> sshd mode.
>
> Signed-off-by: Mingli Yu <mingli.yu@windriver.com>
> ---
> Changed in v3:
> rebase based on https://lore.kernel.org/all/20231201140947.792594-1-xiangyu.chen@eng.windriver.com/
>
> Changed in v4:
> make it possible to install both sshd.socket and sshd.service

I'm wondering if we should make SYSTEMD_AUTO_ENABLE settable per
service, so you could then install both and manage which one is active
with a preset.

> .../openssh/openssh_9.5p1.bb                  | 25 ++++++++++++++-----
>  1 file changed, 19 insertions(+), 6 deletions(-)
>
> diff --git a/meta/recipes-connectivity/openssh/openssh_9.5p1.bb b/meta/recipes-connectivity/openssh/openssh_9.5p1.bb
> index 2c1c821ea9..58dd030c64 100644
> --- a/meta/recipes-connectivity/openssh/openssh_9.5p1.bb
> +++ b/meta/recipes-connectivity/openssh/openssh_9.5p1.bb
> @@ -50,16 +50,20 @@ INITSCRIPT_NAME:${PN}-sshd = "sshd"
>  INITSCRIPT_PARAMS:${PN}-sshd = "defaults 9"
>
>  SYSTEMD_PACKAGES = "${PN}-sshd"
> -SYSTEMD_SERVICE:${PN}-sshd = "sshd.socket sshd.service"
> +SYSTEMD_SERVICE:${PN}-sshd = "${@bb.utils.contains('PACKAGECONFIG','systemd-sshd-socket-mode','sshd.socket', '', d)} ${@bb.utils.contains('PACKAGECONFIG','systemd-sshd-service-mode','sshd.service', '', d)}"
>
>  inherit autotools-brokensep ptest pkgconfig
>
> -PACKAGECONFIG ??= "${@bb.utils.filter('DISTRO_FEATURES', 'systemd', d)}"
> +# systemd-sshd-socket-mode means sshd.socket and systemd-sshd-service-mode
> +# corresponding to sshd.service
> +PACKAGECONFIG ??= "${@bb.utils.filter('DISTRO_FEATURES', 'systemd', d)} systemd-sshd-socket-mode"
>  PACKAGECONFIG[kerberos] = "--with-kerberos5,--without-kerberos5,krb5"
>  PACKAGECONFIG[ldns] = "--with-ldns,--without-ldns,ldns"
>  PACKAGECONFIG[libedit] = "--with-libedit,--without-libedit,libedit"
>  PACKAGECONFIG[manpages] = "--with-mantype=man,--with-mantype=cat"
>  PACKAGECONFIG[systemd] = "--with-systemd,--without-systemd,systemd"
> +PACKAGECONFIG[systemd-sshd-socket-mode] = ""
> +PACKAGECONFIG[systemd-sshd-service-mode] = ""
>
>  EXTRA_AUTORECONF += "--exclude=aclocal"
>
> @@ -124,15 +128,24 @@ do_install:append () {
>         echo "HostKey /var/run/ssh/ssh_host_ed25519_key" >> ${D}${sysconfdir}/ssh/sshd_config_readonly
>
>         install -d ${D}${systemd_system_unitdir}
> -       install -c -m 0644 ${WORKDIR}/sshd.socket ${D}${systemd_system_unitdir}
> -       install -c -m 0644 ${WORKDIR}/sshd.service ${D}${systemd_system_unitdir}
> -       install -c -m 0644 ${WORKDIR}/sshd@.service ${D}${systemd_system_unitdir}
> +       if ${@bb.utils.contains('PACKAGECONFIG','systemd-sshd-socket-mode','true','false',d)}; then
> +           install -c -m 0644 ${WORKDIR}/sshd.socket ${D}${systemd_system_unitdir}
> +           install -c -m 0644 ${WORKDIR}/sshd@.service ${D}${systemd_system_unitdir}
> +           sed -i -e 's,@BASE_BINDIR@,${base_bindir},g' \
> +                   -e 's,@SBINDIR@,${sbindir},g' \
> +                   -e 's,@BINDIR@,${bindir},g' \
> +                   -e 's,@LIBEXECDIR@,${libexecdir}/${BPN},g' \
> +            ${D}${systemd_system_unitdir}/sshd.socket
> +       fi
> +       if ${@bb.utils.contains('PACKAGECONFIG','systemd-sshd-service-mode','true','false',d)}; then
> +           install -c -m 0644 ${WORKDIR}/sshd.service ${D}${systemd_system_unitdir}
> +       fi
>         install -c -m 0644 ${WORKDIR}/sshdgenkeys.service ${D}${systemd_system_unitdir}
>         sed -i -e 's,@BASE_BINDIR@,${base_bindir},g' \
>                 -e 's,@SBINDIR@,${sbindir},g' \
>                 -e 's,@BINDIR@,${bindir},g' \
>                 -e 's,@LIBEXECDIR@,${libexecdir}/${BPN},g' \
> -               ${D}${systemd_system_unitdir}/sshd.socket ${D}${systemd_system_unitdir}/*.service
> +               ${D}${systemd_system_unitdir}/*.service
>
>         sed -i -e 's,@LIBEXECDIR@,${libexecdir}/${BPN},g' \
>                 ${D}${sysconfdir}/init.d/sshd
> --
> 2.25.1
>
>
> -=-=-=-=-=-=-=-=-=-=-=-
> Links: You receive all messages sent to this group.
> View/Reply Online (#191874): https://lists.openembedded.org/g/openembedded-core/message/191874
> Mute This Topic: https://lists.openembedded.org/mt/103009646/3618097
> Group Owner: openembedded-core+owner@lists.openembedded.org
> Unsubscribe: https://lists.openembedded.org/g/openembedded-core/unsub [alex.kiernan@gmail.com]
> -=-=-=-=-=-=-=-=-=-=-=-
>
Yu, Mingli Dec. 7, 2023, 2:10 a.m. UTC | #2
Hi Alex,

Thanks for your suggestion!

Both sshd.socket and sshd.service belong to openssh-sshd package, so using SYSTEMD_AUTO_ENABLE can't enable one of them,  it just can enable both or disable both.

Thanks,
________________________________
From: Alex Kiernan <alex.kiernan@gmail.com>
Sent: Wednesday, December 6, 2023 18:37
To: Yu, Mingli <Mingli.Yu@windriver.com>
Cc: openembedded-core@lists.openembedded.org <openembedded-core@lists.openembedded.org>
Subject: Re: [OE-core] [PATCH v4] openssh: Add PACKAGECONFIG option to customize sshd mode

CAUTION: This email comes from a non Wind River email account!
Do not click links or open attachments unless you recognize the sender and know the content is safe.

On Wed, Dec 6, 2023 at 8:56 AM Yu, Mingli <mingli.yu@eng.windriver.com> wrote:
>
> From: Mingli Yu <mingli.yu@windriver.com>
>
> Add systemd-sshd-socket-mode PACKAGECONFIG option to choose sshd.socket
> and systemd-sshd-service-mode PACKAGECONFIG option to choose installing
> sshd.service.
>
> The systemd-sshd-socket-mode PACKAGECONFIG option is enabled by default
> and user can customize the above two PACKAGECONFIG option to choose the
> sshd mode.
>
> Signed-off-by: Mingli Yu <mingli.yu@windriver.com>
> ---
> Changed in v3:
> rebase based on https://lore.kernel.org/all/20231201140947.792594-1-xiangyu.chen@eng.windriver.com/
>
> Changed in v4:
> make it possible to install both sshd.socket and sshd.service

I'm wondering if we should make SYSTEMD_AUTO_ENABLE settable per
service, so you could then install both and manage which one is active
with a preset.

> .../openssh/openssh_9.5p1.bb                  | 25 ++++++++++++++-----
>  1 file changed, 19 insertions(+), 6 deletions(-)
>
> diff --git a/meta/recipes-connectivity/openssh/openssh_9.5p1.bb b/meta/recipes-connectivity/openssh/openssh_9.5p1.bb
> index 2c1c821ea9..58dd030c64 100644
> --- a/meta/recipes-connectivity/openssh/openssh_9.5p1.bb
> +++ b/meta/recipes-connectivity/openssh/openssh_9.5p1.bb
> @@ -50,16 +50,20 @@ INITSCRIPT_NAME:${PN}-sshd = "sshd"
>  INITSCRIPT_PARAMS:${PN}-sshd = "defaults 9"
>
>  SYSTEMD_PACKAGES = "${PN}-sshd"
> -SYSTEMD_SERVICE:${PN}-sshd = "sshd.socket sshd.service"
> +SYSTEMD_SERVICE:${PN}-sshd = "${@bb.utils.contains('PACKAGECONFIG','systemd-sshd-socket-mode','sshd.socket', '', d)} ${@bb.utils.contains('PACKAGECONFIG','systemd-sshd-service-mode','sshd.service', '', d)}"
>
>  inherit autotools-brokensep ptest pkgconfig
>
> -PACKAGECONFIG ??= "${@bb.utils.filter('DISTRO_FEATURES', 'systemd', d)}"
> +# systemd-sshd-socket-mode means sshd.socket and systemd-sshd-service-mode
> +# corresponding to sshd.service
> +PACKAGECONFIG ??= "${@bb.utils.filter('DISTRO_FEATURES', 'systemd', d)} systemd-sshd-socket-mode"
>  PACKAGECONFIG[kerberos] = "--with-kerberos5,--without-kerberos5,krb5"
>  PACKAGECONFIG[ldns] = "--with-ldns,--without-ldns,ldns"
>  PACKAGECONFIG[libedit] = "--with-libedit,--without-libedit,libedit"
>  PACKAGECONFIG[manpages] = "--with-mantype=man,--with-mantype=cat"
>  PACKAGECONFIG[systemd] = "--with-systemd,--without-systemd,systemd"
> +PACKAGECONFIG[systemd-sshd-socket-mode] = ""
> +PACKAGECONFIG[systemd-sshd-service-mode] = ""
>
>  EXTRA_AUTORECONF += "--exclude=aclocal"
>
> @@ -124,15 +128,24 @@ do_install:append () {
>         echo "HostKey /var/run/ssh/ssh_host_ed25519_key" >> ${D}${sysconfdir}/ssh/sshd_config_readonly
>
>         install -d ${D}${systemd_system_unitdir}
> -       install -c -m 0644 ${WORKDIR}/sshd.socket ${D}${systemd_system_unitdir}
> -       install -c -m 0644 ${WORKDIR}/sshd.service ${D}${systemd_system_unitdir}
> -       install -c -m 0644 ${WORKDIR}/sshd@.service ${D}${systemd_system_unitdir}
> +       if ${@bb.utils.contains('PACKAGECONFIG','systemd-sshd-socket-mode','true','false',d)}; then
> +           install -c -m 0644 ${WORKDIR}/sshd.socket ${D}${systemd_system_unitdir}
> +           install -c -m 0644 ${WORKDIR}/sshd@.service ${D}${systemd_system_unitdir}
> +           sed -i -e 's,@BASE_BINDIR@,${base_bindir},g' \
> +                   -e 's,@SBINDIR@,${sbindir},g' \
> +                   -e 's,@BINDIR@,${bindir},g' \
> +                   -e 's,@LIBEXECDIR@,${libexecdir}/${BPN},g' \
> +            ${D}${systemd_system_unitdir}/sshd.socket
> +       fi
> +       if ${@bb.utils.contains('PACKAGECONFIG','systemd-sshd-service-mode','true','false',d)}; then
> +           install -c -m 0644 ${WORKDIR}/sshd.service ${D}${systemd_system_unitdir}
> +       fi
>         install -c -m 0644 ${WORKDIR}/sshdgenkeys.service ${D}${systemd_system_unitdir}
>         sed -i -e 's,@BASE_BINDIR@,${base_bindir},g' \
>                 -e 's,@SBINDIR@,${sbindir},g' \
>                 -e 's,@BINDIR@,${bindir},g' \
>                 -e 's,@LIBEXECDIR@,${libexecdir}/${BPN},g' \
> -               ${D}${systemd_system_unitdir}/sshd.socket ${D}${systemd_system_unitdir}/*.service
> +               ${D}${systemd_system_unitdir}/*.service
>
>         sed -i -e 's,@LIBEXECDIR@,${libexecdir}/${BPN},g' \
>                 ${D}${sysconfdir}/init.d/sshd
> --
> 2.25.1
>
>
> -=-=-=-=-=-=-=-=-=-=-=-
> Links: You receive all messages sent to this group.
> View/Reply Online (#191874): https://lists.openembedded.org/g/openembedded-core/message/191874
> Mute This Topic: https://lists.openembedded.org/mt/103009646/3618097
> Group Owner: openembedded-core+owner@lists.openembedded.org
> Unsubscribe: https://lists.openembedded.org/g/openembedded-core/unsub [alex.kiernan@gmail.com]
> -=-=-=-=-=-=-=-=-=-=-=-
>


--
Alex Kiernan
Alex Kiernan Dec. 7, 2023, 12:11 p.m. UTC | #3
On Thu, Dec 7, 2023 at 2:10 AM Yu, Mingli <Mingli.Yu@windriver.com> wrote:
>
> Hi Alex,
>
> Thanks for your suggestion!
>
> Both sshd.socket and sshd.service belong to openssh-sshd package, so using SYSTEMD_AUTO_ENABLE can't enable one of them,  it just can enable both or disable both.
>

Yes, it would need changes to support per-service presets, which I
suspect would be generally useful.

> Thanks,
> ________________________________
> From: Alex Kiernan <alex.kiernan@gmail.com>
> Sent: Wednesday, December 6, 2023 18:37
> To: Yu, Mingli <Mingli.Yu@windriver.com>
> Cc: openembedded-core@lists.openembedded.org <openembedded-core@lists.openembedded.org>
> Subject: Re: [OE-core] [PATCH v4] openssh: Add PACKAGECONFIG option to customize sshd mode
>
> CAUTION: This email comes from a non Wind River email account!
> Do not click links or open attachments unless you recognize the sender and know the content is safe.
>
> On Wed, Dec 6, 2023 at 8:56 AM Yu, Mingli <mingli.yu@eng.windriver.com> wrote:
> >
> > From: Mingli Yu <mingli.yu@windriver.com>
> >
> > Add systemd-sshd-socket-mode PACKAGECONFIG option to choose sshd.socket
> > and systemd-sshd-service-mode PACKAGECONFIG option to choose installing
> > sshd.service.
> >
> > The systemd-sshd-socket-mode PACKAGECONFIG option is enabled by default
> > and user can customize the above two PACKAGECONFIG option to choose the
> > sshd mode.
> >
> > Signed-off-by: Mingli Yu <mingli.yu@windriver.com>
> > ---
> > Changed in v3:
> > rebase based on https://lore.kernel.org/all/20231201140947.792594-1-xiangyu.chen@eng.windriver.com/
> >
> > Changed in v4:
> > make it possible to install both sshd.socket and sshd.service
>
> I'm wondering if we should make SYSTEMD_AUTO_ENABLE settable per
> service, so you could then install both and manage which one is active
> with a preset.
>
> > .../openssh/openssh_9.5p1.bb                  | 25 ++++++++++++++-----
> >  1 file changed, 19 insertions(+), 6 deletions(-)
> >
> > diff --git a/meta/recipes-connectivity/openssh/openssh_9.5p1.bb b/meta/recipes-connectivity/openssh/openssh_9.5p1.bb
> > index 2c1c821ea9..58dd030c64 100644
> > --- a/meta/recipes-connectivity/openssh/openssh_9.5p1.bb
> > +++ b/meta/recipes-connectivity/openssh/openssh_9.5p1.bb
> > @@ -50,16 +50,20 @@ INITSCRIPT_NAME:${PN}-sshd = "sshd"
> >  INITSCRIPT_PARAMS:${PN}-sshd = "defaults 9"
> >
> >  SYSTEMD_PACKAGES = "${PN}-sshd"
> > -SYSTEMD_SERVICE:${PN}-sshd = "sshd.socket sshd.service"
> > +SYSTEMD_SERVICE:${PN}-sshd = "${@bb.utils.contains('PACKAGECONFIG','systemd-sshd-socket-mode','sshd.socket', '', d)} ${@bb.utils.contains('PACKAGECONFIG','systemd-sshd-service-mode','sshd.service', '', d)}"
> >
> >  inherit autotools-brokensep ptest pkgconfig
> >
> > -PACKAGECONFIG ??= "${@bb.utils.filter('DISTRO_FEATURES', 'systemd', d)}"
> > +# systemd-sshd-socket-mode means sshd.socket and systemd-sshd-service-mode
> > +# corresponding to sshd.service
> > +PACKAGECONFIG ??= "${@bb.utils.filter('DISTRO_FEATURES', 'systemd', d)} systemd-sshd-socket-mode"
> >  PACKAGECONFIG[kerberos] = "--with-kerberos5,--without-kerberos5,krb5"
> >  PACKAGECONFIG[ldns] = "--with-ldns,--without-ldns,ldns"
> >  PACKAGECONFIG[libedit] = "--with-libedit,--without-libedit,libedit"
> >  PACKAGECONFIG[manpages] = "--with-mantype=man,--with-mantype=cat"
> >  PACKAGECONFIG[systemd] = "--with-systemd,--without-systemd,systemd"
> > +PACKAGECONFIG[systemd-sshd-socket-mode] = ""
> > +PACKAGECONFIG[systemd-sshd-service-mode] = ""
> >
> >  EXTRA_AUTORECONF += "--exclude=aclocal"
> >
> > @@ -124,15 +128,24 @@ do_install:append () {
> >         echo "HostKey /var/run/ssh/ssh_host_ed25519_key" >> ${D}${sysconfdir}/ssh/sshd_config_readonly
> >
> >         install -d ${D}${systemd_system_unitdir}
> > -       install -c -m 0644 ${WORKDIR}/sshd.socket ${D}${systemd_system_unitdir}
> > -       install -c -m 0644 ${WORKDIR}/sshd.service ${D}${systemd_system_unitdir}
> > -       install -c -m 0644 ${WORKDIR}/sshd@.service ${D}${systemd_system_unitdir}
> > +       if ${@bb.utils.contains('PACKAGECONFIG','systemd-sshd-socket-mode','true','false',d)}; then
> > +           install -c -m 0644 ${WORKDIR}/sshd.socket ${D}${systemd_system_unitdir}
> > +           install -c -m 0644 ${WORKDIR}/sshd@.service ${D}${systemd_system_unitdir}
> > +           sed -i -e 's,@BASE_BINDIR@,${base_bindir},g' \
> > +                   -e 's,@SBINDIR@,${sbindir},g' \
> > +                   -e 's,@BINDIR@,${bindir},g' \
> > +                   -e 's,@LIBEXECDIR@,${libexecdir}/${BPN},g' \
> > +            ${D}${systemd_system_unitdir}/sshd.socket
> > +       fi
> > +       if ${@bb.utils.contains('PACKAGECONFIG','systemd-sshd-service-mode','true','false',d)}; then
> > +           install -c -m 0644 ${WORKDIR}/sshd.service ${D}${systemd_system_unitdir}
> > +       fi
> >         install -c -m 0644 ${WORKDIR}/sshdgenkeys.service ${D}${systemd_system_unitdir}
> >         sed -i -e 's,@BASE_BINDIR@,${base_bindir},g' \
> >                 -e 's,@SBINDIR@,${sbindir},g' \
> >                 -e 's,@BINDIR@,${bindir},g' \
> >                 -e 's,@LIBEXECDIR@,${libexecdir}/${BPN},g' \
> > -               ${D}${systemd_system_unitdir}/sshd.socket ${D}${systemd_system_unitdir}/*.service
> > +               ${D}${systemd_system_unitdir}/*.service
> >
> >         sed -i -e 's,@LIBEXECDIR@,${libexecdir}/${BPN},g' \
> >                 ${D}${sysconfdir}/init.d/sshd
> > --
> > 2.25.1
> >
> >
> > -=-=-=-=-=-=-=-=-=-=-=-
> > Links: You receive all messages sent to this group.
> > View/Reply Online (#191874): https://lists.openembedded.org/g/openembedded-core/message/191874
> > Mute This Topic: https://lists.openembedded.org/mt/103009646/3618097
> > Group Owner: openembedded-core+owner@lists.openembedded.org
> > Unsubscribe: https://lists.openembedded.org/g/openembedded-core/unsub [alex.kiernan@gmail.com]
> > -=-=-=-=-=-=-=-=-=-=-=-
> >
>
>
> --
> Alex Kiernan
Yu, Mingli Dec. 13, 2023, 3:37 a.m. UTC | #4
Hi Alex,

The SYSTEMD_SERVICE variable is used to control per-service preset now and we use PACKAGECONFIG to help define the variable for SYSTEMD_SERVICE as below.
SYSTEMD_PACKAGES = "${PN}-sshd"
SYSTEMD_SERVICE:${PN}-sshd = "${@bb.utils.contains('PACKAGECONFIG','systemd-sshd-socket-mode','sshd.socket', '', d)} ${@bb.utils.contains('PACKAGECONFIG','systemd-sshd-service-mode','sshd.service', '', d)}"

Thanks,
________________________________
From: Alex Kiernan <alex.kiernan@gmail.com>
Sent: Thursday, December 7, 2023 20:11
To: Yu, Mingli <Mingli.Yu@windriver.com>
Cc: openembedded-core@lists.openembedded.org <openembedded-core@lists.openembedded.org>
Subject: Re: [OE-core] [PATCH v4] openssh: Add PACKAGECONFIG option to customize sshd mode

CAUTION: This email comes from a non Wind River email account!
Do not click links or open attachments unless you recognize the sender and know the content is safe.

On Thu, Dec 7, 2023 at 2:10 AM Yu, Mingli <Mingli.Yu@windriver.com> wrote:
>
> Hi Alex,
>
> Thanks for your suggestion!
>
> Both sshd.socket and sshd.service belong to openssh-sshd package, so using SYSTEMD_AUTO_ENABLE can't enable one of them,  it just can enable both or disable both.
>

Yes, it would need changes to support per-service presets, which I
suspect would be generally useful.

> Thanks,
> ________________________________
> From: Alex Kiernan <alex.kiernan@gmail.com>
> Sent: Wednesday, December 6, 2023 18:37
> To: Yu, Mingli <Mingli.Yu@windriver.com>
> Cc: openembedded-core@lists.openembedded.org <openembedded-core@lists.openembedded.org>
> Subject: Re: [OE-core] [PATCH v4] openssh: Add PACKAGECONFIG option to customize sshd mode
>
> CAUTION: This email comes from a non Wind River email account!
> Do not click links or open attachments unless you recognize the sender and know the content is safe.
>
> On Wed, Dec 6, 2023 at 8:56 AM Yu, Mingli <mingli.yu@eng.windriver.com> wrote:
> >
> > From: Mingli Yu <mingli.yu@windriver.com>
> >
> > Add systemd-sshd-socket-mode PACKAGECONFIG option to choose sshd.socket
> > and systemd-sshd-service-mode PACKAGECONFIG option to choose installing
> > sshd.service.
> >
> > The systemd-sshd-socket-mode PACKAGECONFIG option is enabled by default
> > and user can customize the above two PACKAGECONFIG option to choose the
> > sshd mode.
> >
> > Signed-off-by: Mingli Yu <mingli.yu@windriver.com>
> > ---
> > Changed in v3:
> > rebase based on https://lore.kernel.org/all/20231201140947.792594-1-xiangyu.chen@eng.windriver.com/
> >
> > Changed in v4:
> > make it possible to install both sshd.socket and sshd.service
>
> I'm wondering if we should make SYSTEMD_AUTO_ENABLE settable per
> service, so you could then install both and manage which one is active
> with a preset.
>
> > .../openssh/openssh_9.5p1.bb                  | 25 ++++++++++++++-----
> >  1 file changed, 19 insertions(+), 6 deletions(-)
> >
> > diff --git a/meta/recipes-connectivity/openssh/openssh_9.5p1.bb b/meta/recipes-connectivity/openssh/openssh_9.5p1.bb
> > index 2c1c821ea9..58dd030c64 100644
> > --- a/meta/recipes-connectivity/openssh/openssh_9.5p1.bb
> > +++ b/meta/recipes-connectivity/openssh/openssh_9.5p1.bb
> > @@ -50,16 +50,20 @@ INITSCRIPT_NAME:${PN}-sshd = "sshd"
> >  INITSCRIPT_PARAMS:${PN}-sshd = "defaults 9"
> >
> >  SYSTEMD_PACKAGES = "${PN}-sshd"
> > -SYSTEMD_SERVICE:${PN}-sshd = "sshd.socket sshd.service"
> > +SYSTEMD_SERVICE:${PN}-sshd = "${@bb.utils.contains('PACKAGECONFIG','systemd-sshd-socket-mode','sshd.socket', '', d)} ${@bb.utils.contains('PACKAGECONFIG','systemd-sshd-service-mode','sshd.service', '', d)}"
> >
> >  inherit autotools-brokensep ptest pkgconfig
> >
> > -PACKAGECONFIG ??= "${@bb.utils.filter('DISTRO_FEATURES', 'systemd', d)}"
> > +# systemd-sshd-socket-mode means sshd.socket and systemd-sshd-service-mode
> > +# corresponding to sshd.service
> > +PACKAGECONFIG ??= "${@bb.utils.filter('DISTRO_FEATURES', 'systemd', d)} systemd-sshd-socket-mode"
> >  PACKAGECONFIG[kerberos] = "--with-kerberos5,--without-kerberos5,krb5"
> >  PACKAGECONFIG[ldns] = "--with-ldns,--without-ldns,ldns"
> >  PACKAGECONFIG[libedit] = "--with-libedit,--without-libedit,libedit"
> >  PACKAGECONFIG[manpages] = "--with-mantype=man,--with-mantype=cat"
> >  PACKAGECONFIG[systemd] = "--with-systemd,--without-systemd,systemd"
> > +PACKAGECONFIG[systemd-sshd-socket-mode] = ""
> > +PACKAGECONFIG[systemd-sshd-service-mode] = ""
> >
> >  EXTRA_AUTORECONF += "--exclude=aclocal"
> >
> > @@ -124,15 +128,24 @@ do_install:append () {
> >         echo "HostKey /var/run/ssh/ssh_host_ed25519_key" >> ${D}${sysconfdir}/ssh/sshd_config_readonly
> >
> >         install -d ${D}${systemd_system_unitdir}
> > -       install -c -m 0644 ${WORKDIR}/sshd.socket ${D}${systemd_system_unitdir}
> > -       install -c -m 0644 ${WORKDIR}/sshd.service ${D}${systemd_system_unitdir}
> > -       install -c -m 0644 ${WORKDIR}/sshd@.service ${D}${systemd_system_unitdir}
> > +       if ${@bb.utils.contains('PACKAGECONFIG','systemd-sshd-socket-mode','true','false',d)}; then
> > +           install -c -m 0644 ${WORKDIR}/sshd.socket ${D}${systemd_system_unitdir}
> > +           install -c -m 0644 ${WORKDIR}/sshd@.service ${D}${systemd_system_unitdir}
> > +           sed -i -e 's,@BASE_BINDIR@,${base_bindir},g' \
> > +                   -e 's,@SBINDIR@,${sbindir},g' \
> > +                   -e 's,@BINDIR@,${bindir},g' \
> > +                   -e 's,@LIBEXECDIR@,${libexecdir}/${BPN},g' \
> > +            ${D}${systemd_system_unitdir}/sshd.socket
> > +       fi
> > +       if ${@bb.utils.contains('PACKAGECONFIG','systemd-sshd-service-mode','true','false',d)}; then
> > +           install -c -m 0644 ${WORKDIR}/sshd.service ${D}${systemd_system_unitdir}
> > +       fi
> >         install -c -m 0644 ${WORKDIR}/sshdgenkeys.service ${D}${systemd_system_unitdir}
> >         sed -i -e 's,@BASE_BINDIR@,${base_bindir},g' \
> >                 -e 's,@SBINDIR@,${sbindir},g' \
> >                 -e 's,@BINDIR@,${bindir},g' \
> >                 -e 's,@LIBEXECDIR@,${libexecdir}/${BPN},g' \
> > -               ${D}${systemd_system_unitdir}/sshd.socket ${D}${systemd_system_unitdir}/*.service
> > +               ${D}${systemd_system_unitdir}/*.service
> >
> >         sed -i -e 's,@LIBEXECDIR@,${libexecdir}/${BPN},g' \
> >                 ${D}${sysconfdir}/init.d/sshd
> > --
> > 2.25.1
> >
> >
> > -=-=-=-=-=-=-=-=-=-=-=-
> > Links: You receive all messages sent to this group.
> > View/Reply Online (#191874): https://lists.openembedded.org/g/openembedded-core/message/191874
> > Mute This Topic: https://lists.openembedded.org/mt/103009646/3618097
> > Group Owner: openembedded-core+owner@lists.openembedded.org
> > Unsubscribe: https://lists.openembedded.org/g/openembedded-core/unsub [alex.kiernan@gmail.com]
> > -=-=-=-=-=-=-=-=-=-=-=-
> >
>
>
> --
> Alex Kiernan



--
Alex Kiernan
diff mbox series

Patch

diff --git a/meta/recipes-connectivity/openssh/openssh_9.5p1.bb b/meta/recipes-connectivity/openssh/openssh_9.5p1.bb
index 2c1c821ea9..58dd030c64 100644
--- a/meta/recipes-connectivity/openssh/openssh_9.5p1.bb
+++ b/meta/recipes-connectivity/openssh/openssh_9.5p1.bb
@@ -50,16 +50,20 @@  INITSCRIPT_NAME:${PN}-sshd = "sshd"
 INITSCRIPT_PARAMS:${PN}-sshd = "defaults 9"
 
 SYSTEMD_PACKAGES = "${PN}-sshd"
-SYSTEMD_SERVICE:${PN}-sshd = "sshd.socket sshd.service"
+SYSTEMD_SERVICE:${PN}-sshd = "${@bb.utils.contains('PACKAGECONFIG','systemd-sshd-socket-mode','sshd.socket', '', d)} ${@bb.utils.contains('PACKAGECONFIG','systemd-sshd-service-mode','sshd.service', '', d)}"
 
 inherit autotools-brokensep ptest pkgconfig
 
-PACKAGECONFIG ??= "${@bb.utils.filter('DISTRO_FEATURES', 'systemd', d)}"
+# systemd-sshd-socket-mode means sshd.socket and systemd-sshd-service-mode
+# corresponding to sshd.service
+PACKAGECONFIG ??= "${@bb.utils.filter('DISTRO_FEATURES', 'systemd', d)} systemd-sshd-socket-mode"
 PACKAGECONFIG[kerberos] = "--with-kerberos5,--without-kerberos5,krb5"
 PACKAGECONFIG[ldns] = "--with-ldns,--without-ldns,ldns"
 PACKAGECONFIG[libedit] = "--with-libedit,--without-libedit,libedit"
 PACKAGECONFIG[manpages] = "--with-mantype=man,--with-mantype=cat"
 PACKAGECONFIG[systemd] = "--with-systemd,--without-systemd,systemd"
+PACKAGECONFIG[systemd-sshd-socket-mode] = ""
+PACKAGECONFIG[systemd-sshd-service-mode] = ""
 
 EXTRA_AUTORECONF += "--exclude=aclocal"
 
@@ -124,15 +128,24 @@  do_install:append () {
 	echo "HostKey /var/run/ssh/ssh_host_ed25519_key" >> ${D}${sysconfdir}/ssh/sshd_config_readonly
 
 	install -d ${D}${systemd_system_unitdir}
-	install -c -m 0644 ${WORKDIR}/sshd.socket ${D}${systemd_system_unitdir}
-	install -c -m 0644 ${WORKDIR}/sshd.service ${D}${systemd_system_unitdir}
-	install -c -m 0644 ${WORKDIR}/sshd@.service ${D}${systemd_system_unitdir}
+	if ${@bb.utils.contains('PACKAGECONFIG','systemd-sshd-socket-mode','true','false',d)}; then
+	    install -c -m 0644 ${WORKDIR}/sshd.socket ${D}${systemd_system_unitdir}
+	    install -c -m 0644 ${WORKDIR}/sshd@.service ${D}${systemd_system_unitdir}
+	    sed -i -e 's,@BASE_BINDIR@,${base_bindir},g' \
+		    -e 's,@SBINDIR@,${sbindir},g' \
+		    -e 's,@BINDIR@,${bindir},g' \
+		    -e 's,@LIBEXECDIR@,${libexecdir}/${BPN},g' \
+            ${D}${systemd_system_unitdir}/sshd.socket
+	fi
+	if ${@bb.utils.contains('PACKAGECONFIG','systemd-sshd-service-mode','true','false',d)}; then
+	    install -c -m 0644 ${WORKDIR}/sshd.service ${D}${systemd_system_unitdir}
+	fi
 	install -c -m 0644 ${WORKDIR}/sshdgenkeys.service ${D}${systemd_system_unitdir}
 	sed -i -e 's,@BASE_BINDIR@,${base_bindir},g' \
 		-e 's,@SBINDIR@,${sbindir},g' \
 		-e 's,@BINDIR@,${bindir},g' \
 		-e 's,@LIBEXECDIR@,${libexecdir}/${BPN},g' \
-		${D}${systemd_system_unitdir}/sshd.socket ${D}${systemd_system_unitdir}/*.service
+		${D}${systemd_system_unitdir}/*.service
 
 	sed -i -e 's,@LIBEXECDIR@,${libexecdir}/${BPN},g' \
 		${D}${sysconfdir}/init.d/sshd