cpb- / yocto-cooker

Meta buildtool for Yocto Project based Linux embedded systems
GNU General Public License v2.0
43 stars 22 forks source link

[FIX] usermod extrauser command #130

Closed Louson closed 1 year ago

Louson commented 2 years ago

Fix an error in the usermod command. For some reason it did not fail while the -P option did not exist. On recent shadow version, -P is for --prefix and the build fails.

cpb- commented 2 years ago

Good idea, but this will not work: with -p the passwords have to be hashed. One way to hash a password (for instance root) is:

$ openssl passwd -5 root
$5$1xX2pq0QkWc.hul1$fm3yN7Y.7BL26NoAoWPmz7cUHHPg658Ag.lHsCXc0TD

Then insert it with double-backslashes preceding the $ (three times):

"EXTRA_USERS_PARAMS_append  = 'usermod -p \\$5\\$1xX2pq0QkWc.hul1\\$fm3yN7Y.7BL26NoAoWPmz7cUHHPg658Ag.lHsCXc0TD root;'   ",

Not really intuitive...

Louson commented 2 years ago

This is true :/ Then it's maybe easier to remove those lines ?

Louson commented 2 years ago

For some reason, openssl does not give the right hash. The yocto page recommands mkpasswd:

$ mkpasswd -m sha256crypt root
$5$7H4iA1OMpawpxVRG$RoH57a3WzrrMU.enSqM5.SRPamRhT97swGurEZZunw6

https://docs.yoctoproject.org/singleindex.html#term-EXTRA_USERS_PARAMS

cpb- commented 2 years ago

It's strange, I use openssl very often (yesterday for example) during Yocto training courses. I've inserted the hashed passwords in the above patch.

Louson commented 2 years ago

Can you test on your side, I can't make it work on my qemu, I can't explain

cpb- commented 2 years ago

You're right, it doesn't work as is. To put a password in a menu, we have to use this:

"# `root` password: `linux` ",
"EXTRA_USERS_PARAMS:append  = \"usermod -p '\\$5\\$oWODdN2qVYVBB5Nl\\$NrH9rY/8gxTkbdEbNzBK9Iu5KLlSppkOhooF8sP2mo/'  root;\"     ",

Kind of weird, no ?

I propose to keep one such example of password configuration (usermod and useradd) in a single menu, and remove all the extra-user lines from the other menus.

Are you OK with that?

Louson commented 2 years ago

yes, it's fine for me

Louson commented 1 year ago

I have not made any test except the automatic tests