All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] openssh: Add SSHD_SERVICE_TYPE variable
@ 2023-12-04  8:54 mingli.yu
  2023-12-04 11:07 ` [OE-core] " Richard Purdie
  0 siblings, 1 reply; 14+ messages in thread
From: mingli.yu @ 2023-12-04  8:54 UTC (permalink / raw)
  To: openembedded-core

From: Mingli Yu <mingli.yu@windriver.com>

There are two types of sshd server now, one is based on socket
activation(sshd.socket) and another is service activation(sshd.service).
And the default sshd service type is based on socket by default as below.
============================================
 # systemctl status sshd.socket
* sshd.socket
     Loaded: loaded (/lib/systemd/system/sshd.socket; enabled; preset: enabled)
     Active: active (listening) since Mon 2023-12-04 08:34:33 UTC; 22s ago
     Listen: [::]:22 (Stream)
   Accepted: 0; Connected: 0;
    Process: 228 ExecStartPre=/bin/mkdir -p /var/run/sshd (code=exited, status=0/SUCCESS)
      Tasks: 0 (limit: 263)
     Memory: 84.0K
     CGroup: /system.slice/sshd.socket

Dec 04 08:34:33 qemux86-64 systemd[1]: Starting sshd.socket...
Dec 04 08:34:33 qemux86-64 systemd[1]: Listening on sshd.socket.
============================================

And use can switch to service activation if they want as below after
the device boot up.
============================================
 # systemctl disable sshd.socket
Removed "/etc/systemd/system/sockets.target.wants/sshd.socket".
 # systemctl stop sshd.socket
 # systemctl start sshd.service
 # systemctl status sshd.service
* sshd.service - OpenSSH server daemon
     Loaded: loaded (/lib/systemd/system/sshd.service; enabled; preset: enabled)
     Active: active (running) since Mon 2023-12-04 08:48:14 UTC; 53s ago
    Process: 390 ExecStartPre=/bin/mkdir -p /var/run/sshd (code=exited, status=0/SUCCESS)
   Main PID: 391 (sshd)
      Tasks: 1 (limit: 263)
     Memory: 2.1M
     CGroup: /system.slice/sshd.service
             `-391 "sshd: /usr/sbin/sshd -D [listener] 0 of 10-100 startups"

Dec 04 08:48:14 qemux86-64 systemd[1]: Starting OpenSSH server daemon...
Dec 04 08:48:14 qemux86-64 systemd[1]: Started OpenSSH server daemon.
Dec 04 08:48:14 qemux86-64 sshd[391]: Server listening on 0.0.0.0 port 22.
Dec 04 08:48:14 qemux86-64 sshd[391]: Server listening on :: port 22.
============================================

But it's more convenient to determine the service type at build time
if there are so many devices.

So add SSHD_SERVICE_TYPE variable to enable sshd.socket or sshd.service
at build time and we still enable sshd.socket by default now.

Signed-off-by: Mingli Yu <mingli.yu@windriver.com>
---
 .../openssh/openssh_9.5p1.bb                   | 18 +++++++++++++-----
 1 file changed, 13 insertions(+), 5 deletions(-)

diff --git a/meta/recipes-connectivity/openssh/openssh_9.5p1.bb b/meta/recipes-connectivity/openssh/openssh_9.5p1.bb
index bbb8fb091a..6a603cd12d 100644
--- a/meta/recipes-connectivity/openssh/openssh_9.5p1.bb
+++ b/meta/recipes-connectivity/openssh/openssh_9.5p1.bb
@@ -50,7 +50,7 @@ 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('SSHD_SERVICE_TYPE', '1', 'sshd.service', 'sshd.socket', d)}"
 
 inherit autotools-brokensep ptest pkgconfig
 DEPENDS += "${@bb.utils.contains('DISTRO_FEATURES', 'systemd', 'systemd', '', d)}"
@@ -125,15 +125,23 @@ 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('SSHD_SERVICE_TYPE','1','true','false',d)}; then
+	    install -c -m 0644 ${WORKDIR}/sshd.service ${D}${systemd_system_unitdir}
+	else
+	    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
 	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



^ permalink raw reply related	[flat|nested] 14+ messages in thread

* Re: [OE-core] [PATCH] openssh: Add SSHD_SERVICE_TYPE variable
  2023-12-04  8:54 [PATCH] openssh: Add SSHD_SERVICE_TYPE variable mingli.yu
@ 2023-12-04 11:07 ` Richard Purdie
  2023-12-05  2:51   ` Yu, Mingli
  0 siblings, 1 reply; 14+ messages in thread
From: Richard Purdie @ 2023-12-04 11:07 UTC (permalink / raw)
  To: Yu, Mingli, openembedded-core

On Mon, 2023-12-04 at 16:54 +0800, Yu, Mingli wrote:
> From: Mingli Yu <mingli.yu@windriver.com>
> 
> There are two types of sshd server now, one is based on socket
> activation(sshd.socket) and another is service activation(sshd.service).
> And the default sshd service type is based on socket by default as below.

Firstly, I'm a little frustrated about how these changes are being
proposed in pieces. The original patches made no mention that this was
eventually going to be controlled by a new variable. I did wonder if
something like this was going to happen but the didn't push back. Now
we're "pinned" into a corner with the direction this code takes now
we've already merged the on target configuration change.

> But it's more convenient to determine the service type at build time
> if there are so many devices.

Why did we merge a patch which made this an on target decision then?

> So add SSHD_SERVICE_TYPE variable to enable sshd.socket or sshd.service
> at build time and we still enable sshd.socket by default now.

No, we're not adding randomly named variables which take magic options.

I cannot look at SSHD_SERVICE_TYPE and know that "1" means socket
activation and not setting it means service activation (or whatever,
the fact I can't check what I've written easily proves my point). What
happens if I set it to "true", or "socket", or "apples"?

I'd suggest thinking about a PACKAGECONFIG option such as systemd-sshd-
socket-mode and systemd-sshd-service-mode which at least uses naming
users are mode used to and says what it does.

Cheers,

Richard


^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: [OE-core] [PATCH] openssh: Add SSHD_SERVICE_TYPE variable
  2023-12-04 11:07 ` [OE-core] " Richard Purdie
@ 2023-12-05  2:51   ` Yu, Mingli
  2023-12-05  5:52     ` [PATCH v2] openssh: Add PACKAGECONFIG option to customize sshd mode mingli.yu
  0 siblings, 1 reply; 14+ messages in thread
From: Yu, Mingli @ 2023-12-05  2:51 UTC (permalink / raw)
  To: Richard Purdie, Yu, Mingli, openembedded-core

Hi Richard,

On 12/4/23 19:07, Richard Purdie wrote:
> 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 Mon, 2023-12-04 at 16:54 +0800, Yu, Mingli wrote:
>> From: Mingli Yu <mingli.yu@windriver.com>
>>
>> There are two types of sshd server now, one is based on socket
>> activation(sshd.socket) and another is service activation(sshd.service).
>> And the default sshd service type is based on socket by default as below.
> 
> Firstly, I'm a little frustrated about how these changes are being
> proposed in pieces. The original patches made no mention that this was
> eventually going to be controlled by a new variable. I did wonder if
> something like this was going to happen but the didn't push back. Now
> we're "pinned" into a corner with the direction this code takes now
> we've already merged the on target configuration change.
> 
>> But it's more convenient to determine the service type at build time
>> if there are so many devices.
> 
> Why did we merge a patch which made this an on target decision then?

Maybe usage requirement change? sorry for noise!

> 
>> So add SSHD_SERVICE_TYPE variable to enable sshd.socket or sshd.service
>> at build time and we still enable sshd.socket by default now.
> 
> No, we're not adding randomly named variables which take magic options.
> 
> I cannot look at SSHD_SERVICE_TYPE and know that "1" means socket
> activation and not setting it means service activation (or whatever,
> the fact I can't check what I've written easily proves my point). What
> happens if I set it to "true", or "socket", or "apples"?
> 
> I'd suggest thinking about a PACKAGECONFIG option such as systemd-sshd-
> socket-mode and systemd-sshd-service-mode which at least uses naming
> users are mode used to and says what it does.

Will sent v2 to use the common PACKAGECONFIG option to control the sshd 
type.

Thanks,

> 
> Cheers,
> 
> Richard


^ permalink raw reply	[flat|nested] 14+ messages in thread

* [PATCH v2] openssh: Add PACKAGECONFIG option to customize sshd mode
  2023-12-05  2:51   ` Yu, Mingli
@ 2023-12-05  5:52     ` mingli.yu
  2023-12-05  7:43       ` [OE-core] " Alexandre Belloni
  2023-12-06 22:34       ` [OE-core] [PATCH v2] " Peter Kjellerstedt
  0 siblings, 2 replies; 14+ messages in thread
From: mingli.yu @ 2023-12-05  5:52 UTC (permalink / raw)
  To: openembedded-core

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>
---
 .../openssh/openssh_9.5p1.bb                  | 24 ++++++++++++++-----
 1 file changed, 18 insertions(+), 6 deletions(-)

diff --git a/meta/recipes-connectivity/openssh/openssh_9.5p1.bb b/meta/recipes-connectivity/openssh/openssh_9.5p1.bb
index bbb8fb091a..a10f5c5a61 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
 DEPENDS += "${@bb.utils.contains('DISTRO_FEATURES', 'systemd', 'systemd', '', d)}"
 
-PACKAGECONFIG ??= ""
+# systemd-sshd-socket-mode means sshd.socket and systemd-sshd-service-mode
+# corresponding to sshd.service
+PACKAGECONFIG ??= " 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-sshd-socket-mode] = ""
+PACKAGECONFIG[systemd-sshd-service-mode] = ""
 
 EXTRA_AUTORECONF += "--exclude=aclocal"
 
@@ -125,15 +129,23 @@ 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
+	elif ${@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



^ permalink raw reply related	[flat|nested] 14+ messages in thread

* Re: [OE-core] [PATCH v2] openssh: Add PACKAGECONFIG option to customize sshd mode
  2023-12-05  5:52     ` [PATCH v2] openssh: Add PACKAGECONFIG option to customize sshd mode mingli.yu
@ 2023-12-05  7:43       ` Alexandre Belloni
  2023-12-06  5:44         ` [PATCH v3] " mingli.yu
                           ` (2 more replies)
  2023-12-06 22:34       ` [OE-core] [PATCH v2] " Peter Kjellerstedt
  1 sibling, 3 replies; 14+ messages in thread
From: Alexandre Belloni @ 2023-12-05  7:43 UTC (permalink / raw)
  To: Yu, Mingli; +Cc: openembedded-core

Hello,

On 05/12/2023 13:52:01+0800, Yu, Mingli 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.
> 

This doesn't apply after https://lore.kernel.org/all/20231201140947.792594-1-xiangyu.chen@eng.windriver.com/

Can you synchronize and provide a working series?

> Signed-off-by: Mingli Yu <mingli.yu@windriver.com>
> ---
>  .../openssh/openssh_9.5p1.bb                  | 24 ++++++++++++++-----
>  1 file changed, 18 insertions(+), 6 deletions(-)
> 
> diff --git a/meta/recipes-connectivity/openssh/openssh_9.5p1.bb b/meta/recipes-connectivity/openssh/openssh_9.5p1.bb
> index bbb8fb091a..a10f5c5a61 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
>  DEPENDS += "${@bb.utils.contains('DISTRO_FEATURES', 'systemd', 'systemd', '', d)}"
>  
> -PACKAGECONFIG ??= ""
> +# systemd-sshd-socket-mode means sshd.socket and systemd-sshd-service-mode
> +# corresponding to sshd.service
> +PACKAGECONFIG ??= " 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-sshd-socket-mode] = ""
> +PACKAGECONFIG[systemd-sshd-service-mode] = ""
>  
>  EXTRA_AUTORECONF += "--exclude=aclocal"
>  
> @@ -125,15 +129,23 @@ 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
> +	elif ${@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 (#191794): https://lists.openembedded.org/g/openembedded-core/message/191794
> Mute This Topic: https://lists.openembedded.org/mt/102987153/3617179
> Group Owner: openembedded-core+owner@lists.openembedded.org
> Unsubscribe: https://lists.openembedded.org/g/openembedded-core/unsub [alexandre.belloni@bootlin.com]
> -=-=-=-=-=-=-=-=-=-=-=-
> 


-- 
Alexandre Belloni, co-owner and COO, Bootlin
Embedded Linux and Kernel engineering
https://bootlin.com


^ permalink raw reply	[flat|nested] 14+ messages in thread

* [PATCH v3] openssh: Add PACKAGECONFIG option to customize sshd mode
  2023-12-05  7:43       ` [OE-core] " Alexandre Belloni
@ 2023-12-06  5:44         ` mingli.yu
  2023-12-06  8:56         ` [PATCH v4] " mingli.yu
       [not found]         ` <179E3241B25BBB7C.1352@lists.openembedded.org>
  2 siblings, 0 replies; 14+ messages in thread
From: mingli.yu @ 2023-12-06  5:44 UTC (permalink / raw)
  To: openembedded-core

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>
---
 .../openssh/openssh_9.5p1.bb                  | 24 ++++++++++++++-----
 1 file changed, 18 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..8273cc0f64 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,23 @@ 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
+	elif ${@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



^ permalink raw reply related	[flat|nested] 14+ messages in thread

* [PATCH v4] openssh: Add PACKAGECONFIG option to customize sshd mode
  2023-12-05  7:43       ` [OE-core] " Alexandre Belloni
  2023-12-06  5:44         ` [PATCH v3] " mingli.yu
@ 2023-12-06  8:56         ` mingli.yu
  2023-12-06 10:37           ` [OE-core] " Alex Kiernan
       [not found]         ` <179E3241B25BBB7C.1352@lists.openembedded.org>
  2 siblings, 1 reply; 14+ messages in thread
From: mingli.yu @ 2023-12-06  8:56 UTC (permalink / raw)
  To: openembedded-core

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(-)

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



^ permalink raw reply related	[flat|nested] 14+ messages in thread

* Re: [OE-core] [PATCH v4] openssh: Add PACKAGECONFIG option to customize sshd mode
  2023-12-06  8:56         ` [PATCH v4] " mingli.yu
@ 2023-12-06 10:37           ` Alex Kiernan
  2023-12-07  2:10             ` Yu, Mingli
  0 siblings, 1 reply; 14+ messages in thread
From: Alex Kiernan @ 2023-12-06 10:37 UTC (permalink / raw)
  To: Yu, Mingli; +Cc: openembedded-core

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


^ permalink raw reply	[flat|nested] 14+ messages in thread

* RE: [OE-core] [PATCH v2] openssh: Add PACKAGECONFIG option to customize sshd mode
  2023-12-05  5:52     ` [PATCH v2] openssh: Add PACKAGECONFIG option to customize sshd mode mingli.yu
  2023-12-05  7:43       ` [OE-core] " Alexandre Belloni
@ 2023-12-06 22:34       ` Peter Kjellerstedt
  2023-12-07  1:53         ` Yu, Mingli
  1 sibling, 1 reply; 14+ messages in thread
From: Peter Kjellerstedt @ 2023-12-06 22:34 UTC (permalink / raw)
  To: Yu, Mingli, openembedded-core@lists.openembedded.org

> -----Original Message-----
> From: openembedded-core@lists.openembedded.org <openembedded-core@lists.openembedded.org> On Behalf Of Yu, Mingli
> Sent: den 5 december 2023 06:52
> To: openembedded-core@lists.openembedded.org
> Subject: [OE-core] [PATCH v2] openssh: Add PACKAGECONFIG option to customize sshd mode
> 
> 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>
> ---
>  .../openssh/openssh_9.5p1.bb                  | 24 ++++++++++++++-----
>  1 file changed, 18 insertions(+), 6 deletions(-)
> 
> diff --git a/meta/recipes-connectivity/openssh/openssh_9.5p1.bb b/meta/recipes-connectivity/openssh/openssh_9.5p1.bb
> index bbb8fb091a..a10f5c5a61 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
>  DEPENDS += "${@bb.utils.contains('DISTRO_FEATURES', 'systemd', 'systemd', '', d)}"
> 
> -PACKAGECONFIG ??= ""
> +# systemd-sshd-socket-mode means sshd.socket and systemd-sshd-service-mode
> +# corresponding to sshd.service
> +PACKAGECONFIG ??= " systemd-sshd-socket-mode"

Unnecessary leading space after the first quote.

>  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-sshd-socket-mode] = ""
> +PACKAGECONFIG[systemd-sshd-service-mode] = ""
> 
>  EXTRA_AUTORECONF += "--exclude=aclocal"
> 
> @@ -125,15 +129,23 @@ 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

There is no need to duplicate the sed command here. The original 
command below would take care of all the files that are actually 
installed.

> +	elif ${@bb.utils.contains('PACKAGECONFIG','systemd-sshd-service-mode','true','false',d)}; then

Are the PACKAGECONFIGs mutually exclusive? The `elif` indicates 
that this is the case. If so, they should be marked as mutually 
exclusive by changing them to:

PACKAGECONFIG[systemd-sshd-socket-mode] = ",,,,, systemd-sshd-service-mode"
PACKAGECONFIG[systemd-sshd-service-mode] = ",,,,, systemd-sshd-socket-mode"

Alternatively, if it is useful to be able to install both the 
sshd.socket file and the sshd.service file at the same time, then
the `elif` should be changed to a `fi` and an `if`.

> +	    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

Keep it as it was.

> 
>  	sed -i -e 's,@LIBEXECDIR@,${libexecdir}/${BPN},g' \
>  		${D}${sysconfdir}/init.d/sshd
> --
> 2.25.1

//Peter



^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: [OE-core] [PATCH v2] openssh: Add PACKAGECONFIG option to customize sshd mode
  2023-12-06 22:34       ` [OE-core] [PATCH v2] " Peter Kjellerstedt
@ 2023-12-07  1:53         ` Yu, Mingli
  0 siblings, 0 replies; 14+ messages in thread
From: Yu, Mingli @ 2023-12-07  1:53 UTC (permalink / raw)
  To: Peter Kjellerstedt, openembedded-core@lists.openembedded.org

[-- Attachment #1: Type: text/plain, Size: 5595 bytes --]

Hi Peter,

Thanks very much for your comments!

Please use v4([OE-core] [PATCH v4] openssh: Add PACKAGECONFIG option to customize sshd mode) to track the series.

Thanks,
________________________________
From: Peter Kjellerstedt <peter.kjellerstedt@axis.com>
Sent: Thursday, December 7, 2023 06:34
To: Yu, Mingli <Mingli.Yu@windriver.com>; openembedded-core@lists.openembedded.org <openembedded-core@lists.openembedded.org>
Subject: RE: [OE-core] [PATCH v2] 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.

> -----Original Message-----
> From: openembedded-core@lists.openembedded.org <openembedded-core@lists.openembedded.org> On Behalf Of Yu, Mingli
> Sent: den 5 december 2023 06:52
> To: openembedded-core@lists.openembedded.org
> Subject: [OE-core] [PATCH v2] openssh: Add PACKAGECONFIG option to customize sshd mode
>
> 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>
> ---
>  .../openssh/openssh_9.5p1.bb                  | 24 ++++++++++++++-----
>  1 file changed, 18 insertions(+), 6 deletions(-)
>
> diff --git a/meta/recipes-connectivity/openssh/openssh_9.5p1.bb b/meta/recipes-connectivity/openssh/openssh_9.5p1.bb
> index bbb8fb091a..a10f5c5a61 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
>  DEPENDS += "${@bb.utils.contains('DISTRO_FEATURES', 'systemd', 'systemd', '', d)}"
>
> -PACKAGECONFIG ??= ""
> +# systemd-sshd-socket-mode means sshd.socket and systemd-sshd-service-mode
> +# corresponding to sshd.service
> +PACKAGECONFIG ??= " systemd-sshd-socket-mode"

Unnecessary leading space after the first quote.

>  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-sshd-socket-mode] = ""
> +PACKAGECONFIG[systemd-sshd-service-mode] = ""
>
>  EXTRA_AUTORECONF += "--exclude=aclocal"
>
> @@ -125,15 +129,23 @@ 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

There is no need to duplicate the sed command here. The original
command below would take care of all the files that are actually
installed.

> +     elif ${@bb.utils.contains('PACKAGECONFIG','systemd-sshd-service-mode','true','false',d)}; then

Are the PACKAGECONFIGs mutually exclusive? The `elif` indicates
that this is the case. If so, they should be marked as mutually
exclusive by changing them to:

PACKAGECONFIG[systemd-sshd-socket-mode] = ",,,,, systemd-sshd-service-mode"
PACKAGECONFIG[systemd-sshd-service-mode] = ",,,,, systemd-sshd-socket-mode"

Alternatively, if it is useful to be able to install both the
sshd.socket file and the sshd.service file at the same time, then
the `elif` should be changed to a `fi` and an `if`.

> +         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

Keep it as it was.

>
>       sed -i -e 's,@LIBEXECDIR@,${libexecdir}/${BPN},g' \
>               ${D}${sysconfdir}/init.d/sshd
> --
> 2.25.1

//Peter


[-- Attachment #2: Type: text/html, Size: 9917 bytes --]

^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: [OE-core] [PATCH v4] openssh: Add PACKAGECONFIG option to customize sshd mode
  2023-12-06 10:37           ` [OE-core] " Alex Kiernan
@ 2023-12-07  2:10             ` Yu, Mingli
  2023-12-07 12:11               ` Alex Kiernan
  0 siblings, 1 reply; 14+ messages in thread
From: Yu, Mingli @ 2023-12-07  2:10 UTC (permalink / raw)
  To: Alex Kiernan; +Cc: openembedded-core@lists.openembedded.org

[-- Attachment #1: Type: text/plain, Size: 5629 bytes --]

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

[-- Attachment #2: Type: text/html, Size: 10487 bytes --]

^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: [OE-core] [PATCH v4] openssh: Add PACKAGECONFIG option to customize sshd mode
  2023-12-07  2:10             ` Yu, Mingli
@ 2023-12-07 12:11               ` Alex Kiernan
  2023-12-13  3:37                 ` Yu, Mingli
  0 siblings, 1 reply; 14+ messages in thread
From: Alex Kiernan @ 2023-12-07 12:11 UTC (permalink / raw)
  To: Yu, Mingli; +Cc: openembedded-core@lists.openembedded.org

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


^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: [OE-core] [PATCH v4] openssh: Add PACKAGECONFIG option to customize sshd mode
  2023-12-07 12:11               ` Alex Kiernan
@ 2023-12-13  3:37                 ` Yu, Mingli
  0 siblings, 0 replies; 14+ messages in thread
From: Yu, Mingli @ 2023-12-13  3:37 UTC (permalink / raw)
  To: Alex Kiernan; +Cc: openembedded-core@lists.openembedded.org

[-- Attachment #1: Type: text/plain, Size: 6996 bytes --]

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

[-- Attachment #2: Type: text/html, Size: 12621 bytes --]

^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: [OE-core] [PATCH v4] openssh: Add PACKAGECONFIG option to customize sshd mode
       [not found]         ` <179E3241B25BBB7C.1352@lists.openembedded.org>
@ 2023-12-18  6:16           ` Yu, Mingli
  0 siblings, 0 replies; 14+ messages in thread
From: Yu, Mingli @ 2023-12-18  6:16 UTC (permalink / raw)
  To: Yu, Mingli, openembedded-core

Ping.

Thanks,

On 12/6/23 16:56, Yu, Mingli 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
> .../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
> 
> 
> 
> -=-=-=-=-=-=-=-=-=-=-=-
> 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/3618448
> Group Owner: openembedded-core+owner@lists.openembedded.org
> Unsubscribe: https://lists.openembedded.org/g/openembedded-core/unsub [mingli.yu@eng.windriver.com]
> -=-=-=-=-=-=-=-=-=-=-=-
> 


^ permalink raw reply	[flat|nested] 14+ messages in thread

end of thread, other threads:[~2023-12-18  6:17 UTC | newest]

Thread overview: 14+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-12-04  8:54 [PATCH] openssh: Add SSHD_SERVICE_TYPE variable mingli.yu
2023-12-04 11:07 ` [OE-core] " Richard Purdie
2023-12-05  2:51   ` Yu, Mingli
2023-12-05  5:52     ` [PATCH v2] openssh: Add PACKAGECONFIG option to customize sshd mode mingli.yu
2023-12-05  7:43       ` [OE-core] " Alexandre Belloni
2023-12-06  5:44         ` [PATCH v3] " mingli.yu
2023-12-06  8:56         ` [PATCH v4] " mingli.yu
2023-12-06 10:37           ` [OE-core] " Alex Kiernan
2023-12-07  2:10             ` Yu, Mingli
2023-12-07 12:11               ` Alex Kiernan
2023-12-13  3:37                 ` Yu, Mingli
     [not found]         ` <179E3241B25BBB7C.1352@lists.openembedded.org>
2023-12-18  6:16           ` Yu, Mingli
2023-12-06 22:34       ` [OE-core] [PATCH v2] " Peter Kjellerstedt
2023-12-07  1:53         ` Yu, Mingli

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.