new file mode 100644
@@ -0,0 +1,31 @@
+From bf97001978cdefad644f7b4b909f281368e5a4dd Mon Sep 17 00:00:00 2001
+From: Louis Rannou <lrannou@baylibre.com>
+Date: Thu, 27 Jul 2023 08:23:06 +0000
+Subject: [PATCH] sysusers.d: Change the user root's home directory
+
+The default sysusers basic.conf.in file sets the root home directory to `/root`
+and does not permit its configuration. Change this to `:ROOT_HOME:` which must
+be set before the installation.
+
+The upstream considers the root home directory should not be changed
+<https://github.com/systemd/systemd/issues/27959>
+
+Upstream-Status: Denied
+Signed-off-by: Louis Rannou <lrannou@baylibre.com>
+---
+ sysusers.d/basic.conf.in | 2 +-
+ 1 file changed, 1 insertion(+), 1 deletion(-)
+
+diff --git a/sysusers.d/basic.conf.in b/sysusers.d/basic.conf.in
+index 0aec080a4c..f26c224341 100644
+--- a/sysusers.d/basic.conf.in
++++ b/sysusers.d/basic.conf.in
+@@ -7,7 +7,7 @@
+
+ # The superuser
+ g root 0 - -
+-u root 0:0 "Super User" /root
++u root 0:0 "Super User" :ROOT_HOME:
+
+ # The nobody user/group for NFS file systems
+ g {{NOBODY_GROUP_NAME}} 65534 - -
deleted file mode 100644
@@ -1,40 +0,0 @@
-# This file is part of systemd.
-#
-# systemd is free software; you can redistribute it and/or modify it
-# under the terms of the GNU Lesser General Public License as published by
-# the Free Software Foundation; either version 2.1 of the License, or
-# (at your option) any later version.
-
-# The superuser
-u root 0 "root" :ROOT_HOME:
-
-# The nobody user/group for NFS file systems
-g {{NOBODY_GROUP_NAME}} 65534 - -
-u {{NOBODY_USER_NAME }} 65534:65534 "Nobody" -
-
-# Administrator group: can *see* more than normal users
-g adm {{ADM_GID }} - -
-
-# Administrator group: can *do* more than normal users
-g wheel {{WHEEL_GID }} - -
-
-# Access to shared database of users on the system
-g utmp {{UTMP_GID }} - -
-
-# Physical and virtual hardware access groups
-g audio {{AUDIO_GID }} - -
-g cdrom {{CDROM_GID }} - -
-g dialout {{DIALOUT_GID}} - -
-g disk {{DISK_GID }} - -
-g input {{INPUT_GID }} - -
-g kmem {{KMEM_GID }} - -
-g kvm {{KVM_GID }} - -
-g lp {{LP_GID }} - -
-g render {{RENDER_GID }} - -
-g sgx {{SGX_GID }} - -
-g tape {{TAPE_GID }} - -
-g tty {{TTY_GID }} - -
-g video {{VIDEO_GID }} - -
-
-# Default group for normal users
-g users {{USERS_GID }} - -
@@ -21,7 +21,6 @@ REQUIRED_DISTRO_FEATURES += "systemd"
SRC_URI += " \
file://touchscreen.rules \
file://00-create-volatile.conf \
- file://basic.conf.in \
${@bb.utils.contains('PACKAGECONFIG', 'polkit_hostnamed_fallback', 'file://org.freedesktop.hostname1_no_polkit.conf', '', d)} \
${@bb.utils.contains('PACKAGECONFIG', 'polkit_hostnamed_fallback', 'file://00-hostnamed-network-user.conf', '', d)} \
file://init \
@@ -30,6 +29,7 @@ SRC_URI += " \
file://0002-binfmt-Don-t-install-dependency-links-at-install-tim.patch \
file://0008-implment-systemd-sysv-install-for-OE.patch \
file://0004-Move-sysusers.d-sysctl.d-binfmt.d-modules-load.d-to-.patch \
+ file://0030-sysusersd-Change-the-user-root-s-home-direct.patch \
"
# patches needed by musl
@@ -260,10 +260,6 @@ EXTRA_OEMESON += "-Dkexec-path=${sbindir}/kexec \
# The 60 seconds is watchdog's default vaule.
WATCHDOG_TIMEOUT ??= "60"
-do_configure:prepend() {
- sed s@:ROOT_HOME:@${ROOT_HOME}@g ${WORKDIR}/basic.conf.in > ${S}/sysusers.d/basic.conf.in
-}
-
do_install() {
meson_do_install
install -d ${D}/${base_sbindir}
@@ -375,6 +371,11 @@ do_install() {
sed -i -e 's/#RebootWatchdogSec=10min/RebootWatchdogSec=${WATCHDOG_TIMEOUT}/' \
${D}/${sysconfdir}/systemd/system.conf
fi
+
+ # The root home directory specified in sysusers.d/ was patched to
+ # `:ROOT_HOME:`. Change now to the correct path given by ${ROOT_HOME}.
+ [ ! -f ${D}${libdir}/sysusers.d/basic.conf ] ||
+ sed -i s@:ROOT_HOME:@${ROOT_HOME}@g ${D}${libdir}/sysusers.d/basic.conf
}
python populate_packages:prepend (){