Openembedded Core Discussions
 help / color / mirror / Atom feed
* Setting root password
@ 2013-10-11 14:35 Jack Mitchell
  2013-10-11 15:08 ` Koen Kooi
  2013-10-12  2:04 ` ChenQi
  0 siblings, 2 replies; 3+ messages in thread
From: Jack Mitchell @ 2013-10-11 14:35 UTC (permalink / raw)
  To: openembedded-core

What is the best way to set the root password for an image during build
time?

I have come across this snippet:

ROOTFS_POSTPROCESS_COMMAND += " \
        sed 's%^root:[^:]*:%root:${PASSWD}:%' \
        < ${IMAGE_ROOTFS}/etc/shadow \
        > ${IMAGE_ROOTFS}/etc/shadow.new;\
        mv ${IMAGE_ROOTFS}/etc/shadow.new ${IMAGE_ROOTFS}/etc/shadow ;"

but it feels a bit hacky... is there no defined way to do this cleanly?

Cheers,
Jack.


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: Setting root password
  2013-10-11 14:35 Setting root password Jack Mitchell
@ 2013-10-11 15:08 ` Koen Kooi
  2013-10-12  2:04 ` ChenQi
  1 sibling, 0 replies; 3+ messages in thread
From: Koen Kooi @ 2013-10-11 15:08 UTC (permalink / raw)
  To: ml; +Cc: openembedded-core


Op 11 okt. 2013, om 16:35 heeft Jack Mitchell <ml@communistcode.co.uk> het volgende geschreven:

> What is the best way to set the root password for an image during build
> time?
> 
> I have come across this snippet:
> 
> ROOTFS_POSTPROCESS_COMMAND += " \
>        sed 's%^root:[^:]*:%root:${PASSWD}:%' \
>        < ${IMAGE_ROOTFS}/etc/shadow \
>> ${IMAGE_ROOTFS}/etc/shadow.new;\
>        mv ${IMAGE_ROOTFS}/etc/shadow.new ${IMAGE_ROOTFS}/etc/shadow ;"
> 
> but it feels a bit hacky...

indeed, gnu sed has had a -i option for some years now, no needs to that intermediate file.

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: Setting root password
  2013-10-11 14:35 Setting root password Jack Mitchell
  2013-10-11 15:08 ` Koen Kooi
@ 2013-10-12  2:04 ` ChenQi
  1 sibling, 0 replies; 3+ messages in thread
From: ChenQi @ 2013-10-12  2:04 UTC (permalink / raw)
  To: openembedded-core

On 10/11/2013 10:35 PM, Jack Mitchell wrote:
> What is the best way to set the root password for an image during build
> time?
>
> I have come across this snippet:
>
> ROOTFS_POSTPROCESS_COMMAND += " \
>          sed 's%^root:[^:]*:%root:${PASSWD}:%' \
>          < ${IMAGE_ROOTFS}/etc/shadow \
>          > ${IMAGE_ROOTFS}/etc/shadow.new;\
>          mv ${IMAGE_ROOTFS}/etc/shadow.new ${IMAGE_ROOTFS}/etc/shadow ;"
>
> but it feels a bit hacky... is there no defined way to do this cleanly?
>
> Cheers,
> Jack.
> _______________________________________________
> Openembedded-core mailing list
> Openembedded-core@lists.openembedded.org
> http://lists.openembedded.org/mailman/listinfo/openembedded-core
>
>
What about using EXTRA_USERS_PARAMS?

E.g.
1. Get the encrypted password.
(One way to get the encrypted password is using openssl, of course you 
can use other methods.)
openssl passwd -1 root
$1$QauDU/Ig$KEeg.OaCLFkNwSXW4xYRu1


2. Add to local.conf the following lines. Note the '$' sign should be 
escaped.

INHERIT += "extrausers"
EXTRA_USERS_PARAMS = "usermod -p '\$1\$QauDU/Ig\$KEeg.OaCLFkNwSXW4xYRu1' root;"


Best Regards,
Chen Qi


^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2013-10-12  2:03 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-10-11 14:35 Setting root password Jack Mitchell
2013-10-11 15:08 ` Koen Kooi
2013-10-12  2:04 ` ChenQi

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox