summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPeter Kjellerstedt <peter.kjellerstedt@axis.com>2016-09-15 17:44:47 +0200
committerRichard Purdie <richard.purdie@linuxfoundation.org>2016-09-16 15:24:03 +0100
commitde154f0289b5e3498cb3a1102d144ee42bfac90c (patch)
tree9904c8af736f17df54cf4195ba6771d09dd670f7
parenta4f10da74ae3b91af403f9ee1a2d94e0a1795224 (diff)
downloadpoky-de154f0289b5e3498cb3a1102d144ee42bfac90c.tar.gz
useradd_base.bbclass: Do not mess with the gshadow file in the sysroot
Previously, if the gshadow file did not exist in the sysroot when perform_groupmems() was run, it would be temporarily created and removed again afterwards. This was supposedly due to groupmems failing if it does not exist. However, based on empirical testing and examination of the source code for groupmems, it should not fail if the gshadow file does not exist when groupmems is started. But it WILL fail if the file is removed sometime after its existence has been check at the beginning of the execution, but before it needs to be modified. And this is exactly what the previous code in perform_groupmems() could cause if multiple tasks simultaneously modified users or groups. It could cause any of the useradd, groupadd and groupmems commands to fail as long as at least one other recipe invoked perform_groupmems(). (From OE-Core rev: 4fcaa484a2e8046cf3277b5d14933cdaa94a4c3f) Signed-off-by: Peter Kjellerstedt <peter.kjellerstedt@axis.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
-rw-r--r--meta/classes/useradd_base.bbclass12
1 files changed, 0 insertions, 12 deletions
diff --git a/meta/classes/useradd_base.bbclass b/meta/classes/useradd_base.bbclass
index f4dc7134cb..ba87edc57a 100644
--- a/meta/classes/useradd_base.bbclass
+++ b/meta/classes/useradd_base.bbclass
@@ -51,14 +51,6 @@ perform_groupmems () {
51 local groupname=`echo "$opts" | awk '{ for (i = 1; i < NF; i++) if ($i == "-g" || $i == "--group") print $(i+1) }'` 51 local groupname=`echo "$opts" | awk '{ for (i = 1; i < NF; i++) if ($i == "-g" || $i == "--group") print $(i+1) }'`
52 local username=`echo "$opts" | awk '{ for (i = 1; i < NF; i++) if ($i == "-a" || $i == "--add") print $(i+1) }'` 52 local username=`echo "$opts" | awk '{ for (i = 1; i < NF; i++) if ($i == "-a" || $i == "--add") print $(i+1) }'`
53 bbnote "${PN}: Running groupmems command with group $groupname and user $username" 53 bbnote "${PN}: Running groupmems command with group $groupname and user $username"
54 # groupmems fails if /etc/gshadow does not exist
55 local gshadow=""
56 if [ -f $rootdir${sysconfdir}/gshadow ]; then
57 gshadow="yes"
58 else
59 gshadow="no"
60 touch $rootdir${sysconfdir}/gshadow
61 fi
62 local mem_exists="`grep "^$groupname:[^:]*:[^:]*:\([^,]*,\)*$username\(,[^,]*\)*" $rootdir/etc/group || true`" 54 local mem_exists="`grep "^$groupname:[^:]*:[^:]*:\([^,]*,\)*$username\(,[^,]*\)*" $rootdir/etc/group || true`"
63 if test "x$mem_exists" = "x"; then 55 if test "x$mem_exists" = "x"; then
64 eval flock -x $rootdir${sysconfdir} -c \"$PSEUDO groupmems \$opts\" || true 56 eval flock -x $rootdir${sysconfdir} -c \"$PSEUDO groupmems \$opts\" || true
@@ -69,10 +61,6 @@ perform_groupmems () {
69 else 61 else
70 bbnote "${PN}: group $groupname already contains $username, not re-adding it" 62 bbnote "${PN}: group $groupname already contains $username, not re-adding it"
71 fi 63 fi
72 if test "x$gshadow" = "xno"; then
73 rm -f $rootdir${sysconfdir}/gshadow
74 rm -f $rootdir${sysconfdir}/gshadow-
75 fi
76} 64}
77 65
78perform_groupdel () { 66perform_groupdel () {