Skip to contentSkip to conversation

ref-manual: Update how to set a useradd password

PATCH Superseded Daiane Angolini 2 participants 3 messages Oct 20, 2021 – Oct 21, 2021 1 message not in the archive

v1 of 3 Superseded Latest is v3 →

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 ref-manual: Update how to set a useradd password

Partial fix for [YOCTO 14605]

---
 documentation/ref-manual/classes.rst | 16 +++++++++++-----
 1 file changed, 11 insertions(+), 5 deletions(-)
documentation/ref-manual/classes.rst +11 -5
index ffaad9bfc..b09f83b28 100644
@@ -590,19 +590,25 @@ Here is an example that uses this class in an image recipe::
        "
 
 Here is an example that adds two users named "tester-jim" and "tester-sue" and assigns
-passwords::
+passwords. First on host, create the password hash::
+
+   mkpasswd -m sha512crypt tester01
+
+The resultant hash is set to a variable and used in ``useradd`` command parameters.
+Remember to escape the character ``$``::
 
    inherit extrausers
+   PASSWD = "\$6\$kt.uxYMp9O9.Yxqd\$SBaJTucixmPm7/WjFL2CjUGMHTqtw8KPK0yxpYw.tGWWHlnOwkUwZ0Pa6vR724Te/E5./V.wua4HT/h0li8Lw/"
    EXTRA_USERS_PARAMS = "\
-       useradd -P tester01 tester-jim; \
-       useradd -P tester01 tester-sue; \
+       useradd -p '${PASSWD} tester-jim; \
+       useradd -p '${PASSWD} tester-sue; \
        "
 
-Finally, here is an example that sets the root password to "1876*18"::
+Finally, here is an example that sets the root password::
 
    inherit extrausers
    EXTRA_USERS_PARAMS = "\
-       usermod -P 1876*18 root; \
+       usermod -p '${PASSWD} root; \
        "
 
 .. _ref-classes-features_check:
Signature · 1 line
2.30.2

A message that is not in the archive (sent off-list or not yet received): [email protected]

#2 lore raw
Quoted 5 lines · Michael Opdenacker

And when I tried to log in with user "alice" and the password, I got:
"crypt method not supported by libcrypt? (SHA512)"

Not sure our instructions are enough here...

Actually, if I generate the password with "mkpasswd -m sha256crypt bob", everything works fine. Not sure libcrypt in Poky's "core-image-minimal" is sufficient.

What about using sha256crypt instead?

If you don't have time right now, I'll be happy to propose a V2 of your patch if you are interested.
Cheers,

Michael.

Signature · 3 lines
Michael Opdenacker, Bootlin
Embedded Linux and Kernel engineering
https://bootlin.com
#3 lore raw
Quoted 7 lines · Michael Opdenacker
Quoted 4 lines · Michael Opdenacker

And when I tried to log in with user "alice" and the password, I got:
"crypt method not supported by libcrypt? (SHA512)"

Quoted 8 lines
Quoted 1 line

Not sure our instructions are enough here...

Actually, if I generate the password with "mkpasswd -m sha256crypt bob", everything works fine. Not sure libcrypt in Poky's "core-image-minimal" is sufficient.

What about using sha256crypt instead?

One of my sources of doubt on the initial patch is exactly that there is a whole world around how to create a password.

And the main purpose of the patch is to inform one that a clear text password is not supported any longer.

So, from my perspective, it's ok to use your command instead.

Quoted 3 lines

If you don't have time right now, I'll be happy to propose a V2 of your patch if you are interested.

Let me work on this today! I think I can handle this. Thanks for the offer =D

Daiane

Quoted 9 lines

Cheers,

Michael.

--
Michael Opdenacker, Bootlin
Embedded Linux and Kernel engineering
https://bootlin.com