[yocto] How Do I add users in /etc/passwd in Yocto

Davide Soldan davide.soldan at kynetics.it
Tue Oct 22 02:36:39 PDT 2013


In data martedì 22 ottobre 2013 14:35:52, Amit Tomer ha scritto:
> Fine Davide
> 
> So  my requiremnet is this .
> 
> From from original /etc/passwd file
> 
> root:x:0:0:root:/home/root:/bin/sh
> proxy:x:13:13:proxy:/bin:/bin/sh
> www-data:x:33:33:www-data:/var/www:/bin/sh
> 
> Have to do this
> 
> root:x:0:0:root:/home/root:/bin/false
> proxy:x:13:13:proxy:/bin:/bin/false
> www-data:x:33:33:www-data:/var/www:/bin/false
> 
> 
> 
> Now for this would below work??
> 
> SUMMARY = "Example recipe for using inherit useradd"
> DESCRIPTION = "This recipe serves as an example for using features
> from useradd.bbclass"
> SECTION = "examples"
> PR = "r1"
> LICENSE = "MIT"
> LIC_FILES_CHKSUM =
> "file://${COREBASE}/LICENSE;md5=3f40d7994397109285ec7b81fdeb3b58 \
> 
> file://${COREBASE}/meta/COPYING.MIT;md5=3da9cfbcb788c80a0384361b4de20420"
> 
> SRC_URI = "file://passwd"
> 
> USERADD_PARAM_${PN} = "-u 1200 -d /home/root -r -s /bin/false root"
> 
> And How do I force this recipe to be picked while bitbake my image??
> 
> Thanks
> Amit
> 
> On Tue, Oct 22, 2013 at 2:22 PM, Davide Soldan
> <davide.soldan at kynetics.it> wrote:
> > In data martedì 22 ottobre 2013 14:18:55, Amit Tomer ha scritto:
> >> Thanks Davide
> >> Can you please point to right link.
> >>
> > I found the example recipe there:
> > http://git.yoctoproject.org/cgit/cgit.cgi/poky/tree/meta-skeleton/recipes-skeleton/useradd/useradd-example.bb
> >
> >> On Tue, Oct 22, 2013 at 2:12 PM, Davide Soldan
> >> <davide.soldan at kynetics.it> wrote:
> >> > In data martedì 22 ottobre 2013 14:00:22, Amit Tomer ha scritto:
> >> >> For some requirement I wante to add some new users in /etc/passwd .
> >> >>
> >> >> I tried doing it in couple of way but none of it worked out well
> >> >>
> >> >> I tried to patcth the /etc/passwd file but getting few errors while
> >> >> bitbaking my image.
> >> >>
> >> >> Paul Eggleton suggests me that patching /etc/passwd  file won't work
> >> >>
> >> >> Then I tried doing it in below way
> >> >>
> >> >> SRC_URI += "file://passwd"
> >> >>
> >> >> do_install_append() {
> >> >> install -d ${D}${sysconfdir}/base-passwd ${D}${sysconfdir}
> >> >> passwd/passwd${STAGING_DIR_TARGET}${sysconfdir}/passwd
> >> >>
> >> >>                     install -m 0644 ${WORKDIR}/passwd ${D}${sysconfdir}/passwd
> >> >> }
> >> >>
> >> >>  With above method I am able to add new user to /etc/passwd file
> >> >>
> >> >> but testing this image gives me trouble and now when I login to board
> >> >> it is asking password.
> >> >>
> >> >> Now would like to know what are the ways to add new users in
> >> >> /etc/passwd file in yocto.
> >> >>
> >> >> Thanks
> >> >> Amit
> >> >> _______________________________________________
> >> >> yocto mailing list
> >> >> yocto at yoctoproject.org
> >> >> https://lists.yoctoproject.org/listinfo/yocto
> >> >
> >> > I've done it creating my useradd recipe following
> >> > poky/meta-skeleton/recipes-skeleton/useradd/useradd-example.bb
> >
For bitbaking your recipe within the image add the recipe in CORE_IMAGE_EXTRA_INSTALL of your local.conf
I don't know if the replacement of /etc/passwd would work...give it a try and if all works you're ok. 
I only add new users so I don't know how to replace existing ones...maybe recreate that users via USERADD_PARAM_${PN}/GROUPADD_PARAM_${PN} like in useradd-example.bb?
Hope this helps
Cheers



More information about the yocto mailing list