[OE-core] [PATCH 2/7] shadow: add a -native recipe with customized utilities

Richard Purdie richard.purdie at linuxfoundation.org
Fri Sep 2 14:03:31 UTC 2011


On Fri, 2011-09-02 at 10:50 +0100, Phil Blundell wrote:
> On Thu, 2011-09-01 at 22:59 +0100, Richard Purdie wrote:
> > The latter sounds like what we'll need to do. I haven't looked at shadow
> > to see what kind of finessing is required though...
> 
> Fixing the immediate problem with shadow turned out to be rather
> straightforward, see attached.  However, with this done, I now encounter
> two new issues.
> 
> 1. the logic around $D in useradd.bbclass seems to be backwards to me
> (and, empirically, isn't working because the supposedly-created users
> are not showing up in my rootfs).  Specifically, it does:
> 
>         useradd_preinst () {
>         OPT=""
>         SYSROOT=""
>         
>         if test "x$D" != "x"; then
>         	# Installing into a sysroot
>         	SYSROOT="${STAGING_DIR_TARGET}"
>         	OPT="--root ${STAGING_DIR_TARGET}"
>         
>         [...]
>         
>         useradd_sysroot () {
>         	export PSEUDO="${STAGING_DIR_NATIVE}/usr/bin/pseudo"
>         	export PSEUDO_LOCALSTATEDIR="${STAGING_DIR_TARGET}/var/pseudo"
>         
>         	# Explicitly set $D since it isn't set to anything
>         	# before do_install
>         	D=${D}
>         	useradd_preinst
>         }
> 
> It looks to me as though the code in useradd_preinst() should be using
> SYSROOT="$D" (and likewise for OPT), and useradd_sysroot() should be
> setting D=${STAGING_DIR_TARGET}.  But maybe there is some clever thing
> going on here that I'm not properly understanding.

It looks like the useradd_sysroot code will work since D is set to
'something' and then is set correctly in the preinst. What won't work
correctly is the rootfs user creation as you point out.

So I'd agree with your change.

> 2. during rootfs construction, the script ordering is wrong.  All the
> preinsts run before all the postinsts, which has always been a bit wrong
> but hasn't caused too much of a problem in the past.  However,
> crucially, this means that the useradd_preinst() runs before
> base-passwd's postinst and hence /etc/passwd doesn't exist at the point
> where useradd tries to modify it.
> 
> I can't think of any reasonable fix for (2) other than to teach
> rootfs_ipk how to track package dependencies and run the scripts in the
> right order.  I guess that wouldn't be impossible by any means but
> trying to do it in a shell script is not a prospect that fills me with a
> lot of enthusiasm.  Any better suggestions?

Write it in python? ;-)

Seriously, does opkg have the logic in it to run this stuff? If so
perhaps we need to teach opkg about offline postinstalls since it should
already know about dependencies?

Cheers,

Richard






More information about the Openembedded-core mailing list