summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTean Cunningham <tean.cunningham@digi.com>2022-03-01 14:25:39 -0700
committerAnuj Mittal <anuj.mittal@intel.com>2022-03-07 11:05:16 +0800
commit5f53e232f92011e131abff6128fa25812c3744ac (patch)
tree5f54623286c85ab552e86a0d74aa848857ec6b73
parenta5adc91b6cebf7a006805e01fcf20ca4cb9a9a6a (diff)
downloadopenembedded-core-contrib-5f53e232f92011e131abff6128fa25812c3744ac.tar.gz
rootfs-postcommands: amend systemd_create_users add user to group check
Currently when adding a user to a group ('m' type), the conditional check to only create a user/group if it does not exist always resolves to true. This causes a build exit failure if the user and/or group defined in the sysusers configuration file were already created prior to the execution of systemd_create_users(). This logic has been updated to instead fail silently (consistent with 'u' and 'g' type). Additionally, if a user doesn't exist it will be created without the default group. Signed-off-by: Tean Cunningham <tean.cunningham@digi.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org> (cherry picked from commit 65649be6b2196ab964c69605d0306bfc2481da33) Signed-off-by: Anuj Mittal <anuj.mittal@intel.com>
-rw-r--r--meta/classes/rootfs-postcommands.bbclass8
1 files changed, 2 insertions, 6 deletions
diff --git a/meta/classes/rootfs-postcommands.bbclass b/meta/classes/rootfs-postcommands.bbclass
index 74035c30b7..0452fe4b27 100644
--- a/meta/classes/rootfs-postcommands.bbclass
+++ b/meta/classes/rootfs-postcommands.bbclass
@@ -78,12 +78,8 @@ systemd_create_users () {
eval groupadd --root ${IMAGE_ROOTFS} $groupadd_params || true
elif [ "$type" = "m" ]; then
group=$id
- if [ ! `grep -q "^${group}:" ${IMAGE_ROOTFS}${sysconfdir}/group` ]; then
- eval groupadd --root ${IMAGE_ROOTFS} --system $group
- fi
- if [ ! `grep -q "^${name}:" ${IMAGE_ROOTFS}${sysconfdir}/passwd` ]; then
- eval useradd --root ${IMAGE_ROOTFS} --shell /sbin/nologin --system $name
- fi
+ eval groupadd --root ${IMAGE_ROOTFS} --system $group || true
+ eval useradd --root ${IMAGE_ROOTFS} --shell /sbin/nologin --system $name --no-user-group || true
eval usermod --root ${IMAGE_ROOTFS} -a -G $group $name
fi
done