openbsd: set_passwd should not unlock user#289
Conversation
igalic
left a comment
There was a problem hiding this comment.
an account on OpenBSD is locked with usermod -Z and unlocked with usermod -U
or is this, again, specifically about password based logins over the network?
When you set a new password to a OpenBSD account, you unlock it at the same time because the |
|
Looking at the manpage on NetBSD/OpenBSD it seems to me there is no direct command for locking the password itself and keeping the account active, which is what is needed. It sounds like a common BSD lock_password() could be: usermod -p * However, that would drop the existing password; Other than manually inserting the '*' in to the |
|
When I build the NetBSD image, I do a This patch does not address the ability to lock an account on OpenBSD. It ensures we can set the password of an user. |
My reading of the manpage suggest that the '-C yes' locks the account ; OpenBSD seems the same. Can you confirm that "lock account" disables password entry but allows ssh The comments on this PR aren't clear about what locking passwd vs locking |
NetBSD
OpenBSD
Why this patchCurrently, NetBSD we silently re-enable the account if we set a password, this just in case the password auth was disabled. This to reproduce the behaviour of the other systems (including OpenBSD). This patch ensures we don't do that on OpenBSD. |
|
OK. I'm sorry this has been difficult for me to grasp. Let me try again. In NetBSD, the unlock happens when set_passwd() is called OpenBSD distro class reuses this method, however, the '-C no' is So, drop the '-C no', create a new method for unlocking the password One follow up, the OpenBSD lock_passwd method uses: usermod -p '*' name; If this is run, how can one unlock the passwd? |
It's not a reversible operation, because we replace its hashed content with '*'. So to unlock the account, we need to set a new password. |
Is this known to OpenBSD users? Should lock_passwd() be used on OpenBSD by default? Cloud-init defaults to locking passwords by default to encourage use of ssh. I wonder if we can just make a doc note that on OpenBSD, one cannot undo the locked password, rather one must set a new password instead? We can do that in a separate PR. |
raharper
left a comment
There was a problem hiding this comment.
Thanks for helping me understand the changes in this PR.
Is this specific to OpenBSD, I believe Linux has the same behaviour. |
It looks like Linux usermod(8) supports lock and unlock. |
`usermode -C no foo` does not work on OpenBSD. Unlike NetBSD, we don't actually need to unlock the user.
2bb0f01 to
be8aa20
Compare
Ok TIL. Thanks. |
usermode -C no foodoes not work on OpenBSD. Unlike NetBSD, we don'tactually need to unlock the user.