Bug 11460

Summary: useradd postinst refers to recipe sysroot
Product: [Build System, Metadata & Runtime] OE-Core Reporter: Ross Burton <ross.burton>
Component: coreAssignee: Maxin B. John <maxin.john>
Status: RESOLVED FIXED QA Contact:
Severity: normal    
Priority: High CC: brian.avery, jose.perez.carranza, meta.mr.watcher, meta.watcher
Version: 2.3   
Target Milestone: 2.4 M1   
Hardware: x86   
OS: Multiple   
Whiteboard:
OS type for building Yocto: --- Type of Regression: ---
Verified: Documentation change: No (bug/feature does not impact docs)

Description Ross Burton 2017-05-04 14:38:42 UTC
useradd.bbclass has this in useradd_preinst:

	export PSEUDO_PASSWD="$SYSROOT:${STAGING_DIR_NATIVE}"

But with recipe-specific-sysroots the STAGING_DIR_NATIVE is in the *recipe* work directory, and may well not exist if the packages were taken from sstate or rm_work is enabled.
Comment 1 Ross Burton 2017-05-04 14:40:06 UTC
Concrete example: dbus pkg_preinst has this line:

export PSEUDO_PASSWD="$SYSROOT:/data/poky-master/tmp/work/corei7-64-poky-linux/dbus/1.10.14-r0/recipe-sysroot-native"
Comment 2 brian avery 2017-05-10 16:01:28 UTC
which is used/called as part of -c populate_sdk_ext :(
Comment 3 brian avery 2017-05-10 20:12:05 UTC
Moving my comments from the duplicate bug I filed before finding this one and closing mine:.
My comments, moved:

The path to pseudo-native/usr/bin/pseudo used by useradd is populated from sstate. This means if the build dir is different from the build dir that was used to generate the sstate, the useradd command will fail. One place this happens is "$bitbake <image> -c populate_sdk_ext" . This tries to do a groupadd for dbus and fails. 

This bug is being opened by me for tracking/discussion, there is a patch already available that seems to fix it in my testing, from Peter Kjellerstedt .  His patch is https://patchwork.openembedded.org/series/6598/ .

His comments on the patch cover letter:
Similar to the problem with the hosttools directory and the state
cache that was recently fixed, there is another problem with the
sysroots-components directory. This only affects postinst-useradd
scripts, so in this case the fix can be activated from useradd.bbclass
rather than sstate.bbclass and thus affects a lot less recipes.

Also, from Jose: 
Bug 11497 created to add a test case for this scenario
Comment 4 brian avery 2017-05-10 20:13:28 UTC
*** Bug 11489 has been marked as a duplicate of this bug. ***