summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChen Qi <Qi.Chen@windriver.com>2014-10-21 14:30:36 +0800
committerRichard Purdie <richard.purdie@linuxfoundation.org>2014-12-24 17:48:58 +0000
commit2501c2f03f24fbbefd9999dd444318704d8aa8c2 (patch)
tree29ed69930b1a8fd899fc75ee978dc259f9cc9abf
parentebc185186c36fe839008d94dbfb779383df960c7 (diff)
downloadopenembedded-core-contrib-2501c2f03f24fbbefd9999dd444318704d8aa8c2.tar.gz
openembedded-core-contrib-2501c2f03f24fbbefd9999dd444318704d8aa8c2.tar.bz2
openembedded-core-contrib-2501c2f03f24fbbefd9999dd444318704d8aa8c2.zip
image.bbclass: avoid boot error on read-only systemd image
New version of systemd implements a new feature of updating /etc or /var when needed at boot. For details, please see link below. Opointer.de/blog/projects/stateless.html For now, at boot time, the systemd-sysusers.service would update user database files (/etc/passwd, /etc/group, etc.) according to the configuration files under /usr/lib/sysusers.d. This step is necessary for other systemd services to work correctly. Examples of such services are systemd-resolved and systemd-tmpfiles-setup. The problem is that on a read-only file system, that is, if /etc is read-only, the user database files could not be updated, causing failures of services. This patch fixes this problem by adding users/groups at rootfs time. Signed-off-by: Chen Qi <Qi.Chen@windriver.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
-rw-r--r--meta/classes/image.bbclass21
1 files changed, 21 insertions, 0 deletions
diff --git a/meta/classes/image.bbclass b/meta/classes/image.bbclass
index 832c7384c6..34e9f4cba5 100644
--- a/meta/classes/image.bbclass
+++ b/meta/classes/image.bbclass
@@ -215,6 +215,27 @@ read_only_rootfs_hook () {
fi
fi
fi
+
+ if ${@bb.utils.contains("DISTRO_FEATURES", "systemd", "true", "false", d)}; then
+ # Update user database files so that services don't fail for a read-only systemd system
+ for conffile in ${IMAGE_ROOTFS}/usr/lib/sysusers.d/systemd.conf ${IMAGE_ROOTFS}/usr/lib/sysusers.d/systemd-remote.conf; do
+ [ -e $conffile ] || continue
+ grep -v "^#" $conffile | sed -e '/^$/d' | while read type name id comment; do
+ if [ "$type" = "u" ]; then
+ useradd_params=""
+ [ "$id" != "-" ] && useradd_params="$useradd_params --uid $id"
+ [ "$comment" != "-" ] && useradd_params="$useradd_params --comment $comment"
+ useradd_params="$useradd_params --system $name"
+ eval useradd --root ${IMAGE_ROOTFS} $useradd_params || true
+ elif [ "$type" = "g" ]; then
+ groupadd_params=""
+ [ "$id" != "-" ] && groupadd_params="$groupadd_params --gid $id"
+ groupadd_params="$groupadd_params --system $name"
+ eval groupadd --root ${IMAGE_ROOTFS} $groupadd_params || true
+ fi
+ done
+ done
+ fi
}
PACKAGE_EXCLUDE ??= ""