[oe-commits] [openembedded-core] 14/17: useradd_base.bbclass: Do not mess with the gshadow file in the sysroot

git at git.openembedded.org git at git.openembedded.org
Fri Sep 16 14:24:49 UTC 2016


rpurdie pushed a commit to branch master
in repository openembedded-core.

commit 4fcaa484a2e8046cf3277b5d14933cdaa94a4c3f
Author: Peter Kjellerstedt <peter.kjellerstedt at axis.com>
AuthorDate: Thu Sep 15 17:44:47 2016 +0200

    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().
    
    Signed-off-by: Peter Kjellerstedt <peter.kjellerstedt at axis.com>
    Signed-off-by: Richard Purdie <richard.purdie at linuxfoundation.org>
---
 meta/classes/useradd_base.bbclass | 12 ------------
 1 file changed, 12 deletions(-)

diff --git a/meta/classes/useradd_base.bbclass b/meta/classes/useradd_base.bbclass
index f4dc713..ba87edc 100644
--- a/meta/classes/useradd_base.bbclass
+++ b/meta/classes/useradd_base.bbclass
@@ -51,14 +51,6 @@ perform_groupmems () {
 	local groupname=`echo "$opts" | awk '{ for (i = 1; i < NF; i++) if ($i == "-g" || $i == "--group") print $(i+1) }'`
 	local username=`echo "$opts" | awk '{ for (i = 1; i < NF; i++) if ($i == "-a" || $i == "--add") print $(i+1) }'`
 	bbnote "${PN}: Running groupmems command with group $groupname and user $username"
-	# groupmems fails if /etc/gshadow does not exist
-	local gshadow=""
-	if [ -f $rootdir${sysconfdir}/gshadow ]; then
-		gshadow="yes"
-	else
-		gshadow="no"
-		touch $rootdir${sysconfdir}/gshadow
-	fi
 	local mem_exists="`grep "^$groupname:[^:]*:[^:]*:\([^,]*,\)*$username\(,[^,]*\)*" $rootdir/etc/group || true`"
 	if test "x$mem_exists" = "x"; then
 		eval flock -x $rootdir${sysconfdir} -c \"$PSEUDO groupmems \$opts\" || true
@@ -69,10 +61,6 @@ perform_groupmems () {
 	else
 		bbnote "${PN}: group $groupname already contains $username, not re-adding it"
 	fi
-	if test "x$gshadow" = "xno"; then
-		rm -f $rootdir${sysconfdir}/gshadow
-		rm -f $rootdir${sysconfdir}/gshadow-
-	fi
 }
 
 perform_groupdel () {

-- 
To stop receiving notification emails like this one, please contact
the administrator of this repository.


More information about the Openembedded-commits mailing list