systemd-conf: make KillUserProcesses configurable via PACKAGECONFIG
PATCH 1/1 systemd-conf: make KillUserProcesses configurable via PACKAGECONFIG
The logind.conf config snippet installed by this recipe unconditionally sets KillUserProcesses=yes, so logind terminates the whole session scope when a login session ends. Among other things this kills detached screen or tmux sessions on logout, which is surprising on interactive development images, and there is currently no recipe-level way to turn the policy off.
Add a 'kill-user-processes' PACKAGECONFIG option, enabled by default, so behaviour is unchanged unless a distro or image opts out with:
PACKAGECONFIG:remove:pn-systemd-conf = "kill-user-processes"
--- meta/recipes-core/systemd/systemd-conf/logind.conf | 2 +- meta/recipes-core/systemd/systemd-conf_1.0.bb | 6 +++++- 2 files changed, 6 insertions(+), 2 deletions(-)
meta/recipes-core/systemd/systemd-conf/logind.conf +1 -1
@@ -1,2 +1,2 @@ [Login] -KillUserProcesses=yes +KillUserProcesses=@KILL_USER_PROCESSES@
meta/recipes-core/systemd/systemd-conf_1.0.bb +5 -1
@@ -10,8 +10,9 @@ REQUIRED_DISTRO_FEATURES += "usrmerge" PE = "1" -PACKAGECONFIG ??= "dhcp-ethernet" +PACKAGECONFIG ??= "dhcp-ethernet kill-user-processes" PACKAGECONFIG[dhcp-ethernet] = "" +PACKAGECONFIG[kill-user-processes] = "" SRC_URI = "\ file://journald.conf \
@@ -28,6 +29,9 @@ do_install() { install -D -m0644 ${S}/logind.conf ${D}${systemd_unitdir}/logind.conf.d/00-${PN}.conf install -D -m0644 ${S}/system.conf ${D}${systemd_unitdir}/system.conf.d/00-${PN}.conf + KILL_USER_PROCESSES="${@bb.utils.contains('PACKAGECONFIG', 'kill-user-processes', 'yes', 'no', d)}" + sed -i "s/@KILL_USER_PROCESSES@/${KILL_USER_PROCESSES}/" ${D}${systemd_unitdir}/logind.conf.d/00-${PN}.conf + if ${@bb.utils.contains('PACKAGECONFIG', 'dhcp-ethernet', 'true', 'false', d)}; then install -D -m0644 ${S}/wired.network ${D}${systemd_unitdir}/network/80-wired.network fi
Signature · 1 line
2.47.3
Quoted 10 lines · Carlos Alberto Lopez Perez via lists.openembedded.org
The logind.conf config snippet installed by this recipe unconditionally sets KillUserProcesses=yes, so logind terminates the whole session scope when a login session ends. Among other things this kills detached screen or tmux sessions on logout, which is surprising on interactive development images, and there is currently no recipe-level way to turn the policy off.
Add a 'kill-user-processes' PACKAGECONFIG option, enabled by default, so behaviour is unchanged unless a distro or image opts out with:
PACKAGECONFIG:remove:pn-systemd-conf = "kill-user-processes"
Using :remove should be reserved for exceptional cases, not recommended as the normal way to configure things. So perhaps we need to invert this and have a "no-kill-user-processes" PACKAGECONFIG.
Quoted 31 lines
Signed-off-by Carlos Alberto Lopez Perez <[email protected]>--- meta/recipes-core/systemd/systemd-conf/logind.conf | 2 +- meta/recipes-core/systemd/systemd-conf_1.0.bb | 6 +++++- 2 files changed, 6 insertions(+), 2 deletions(-)meta/recipes-core/systemd/systemd-conf/logind.conf +1
-1@@ -1,2 +1,2 @@ [Login] -KillUserProcesses=yes +KillUserProcesses=@KILL_USER_PROCESSES@meta/recipes-core/systemd/systemd-conf_1.0.bb +2
-1@@ -10,8 +10,9 @@ REQUIRED_DISTRO_FEATURES += "usrmerge" PE = "1" -PACKAGECONFIG ??= "dhcp-ethernet" +PACKAGECONFIG ??= "dhcp-ethernet kill-user-processes" PACKAGECONFIG[dhcp-ethernet] = "" +PACKAGECONFIG[kill-user-processes] = "" SRC_URI = "\ file://journald.conf \
meta/recipes-core/systemd/systemd-conf_1.0.bb do_install() { · line 34
Quoted 6 lines
meta/recipes-core/systemd/systemd-conf_1.0.bb +3
-0@@ -28,6 +29,9 @@ do_install() { install -D -m0644 ${S}/logind.conf ${D}${systemd_unitdir}/logind.conf.d/00-${PN}.conf install -D -m0644 ${S}/system.conf ${D}${systemd_unitdir}/system.conf.d/00-${PN}.conf + KILL_USER_PROCESSES="${@bb.utils.contains('PACKAGECONFIG', 'kill-user-processes', 'yes', 'no', d)}" + sed -i "s/@KILL_USER_PROCESSES@/${KILL_USER_PROCESSES}/" ${D}${systemd_unitdir}/logind.conf.d/00-${PN}.conf +
Note that KillUserProcesses=yes is the built-in default so we don't need to set that in a logind.conf.d file. To disable this at systemd build time we can add -Ddefault-kill-user-processes=false to EXTRA_OEMESON. So, I think we should handle this in systemd instead of systemd-conf and drop the logind.conf file from systemd-conf completely.
systemd-conf should remain fairly lightweight, we don't want to turn all systemd runtime options into PACKAGECONFIGs for systemd-conf or things will get out of hand.
Best regards,
Signature · 1 line
Paul Barker