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 <[email protected]>
---
 meta/classes/rootfs-postcommands.bbclass | 8 ++------
 1 file changed, 2 insertions(+), 6 deletions(-)

diff --git a/meta/classes/rootfs-postcommands.bbclass 
b/meta/classes/rootfs-postcommands.bbclass
index 87b5751e24..f3b8f13a55 100644
--- a/meta/classes/rootfs-postcommands.bbclass
+++ b/meta/classes/rootfs-postcommands.bbclass
@@ -76,12 +76,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
-- 
2.25.1

-=-=-=-=-=-=-=-=-=-=-=-
Links: You receive all messages sent to this group.
View/Reply Online (#162574): 
https://lists.openembedded.org/g/openembedded-core/message/162574
Mute This Topic: https://lists.openembedded.org/mt/89488152/21656
Group Owner: [email protected]
Unsubscribe: https://lists.openembedded.org/g/openembedded-core/unsub 
[[email protected]]
-=-=-=-=-=-=-=-=-=-=-=-

Reply via email to