diff options
author | Gonéri Le Bouder <goneri@lebouder.net> | 2020-04-02 15:33:37 -0400 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-04-02 14:33:37 -0500 |
commit | bec8f387252ac32e1fd7963cf871ceed8d313edd (patch) | |
tree | 1706d8300b61ab6acc8f4ff939ec53f519e4d53f /cloudinit/distros/netbsd.py | |
parent | 0dae0996a8005a1cf399bd6d370b538282ebdb20 (diff) | |
download | vyos-cloud-init-bec8f387252ac32e1fd7963cf871ceed8d313edd.tar.gz vyos-cloud-init-bec8f387252ac32e1fd7963cf871ceed8d313edd.zip |
openbsd: set_passwd should not unlock user (#289)
Decouple unlocking passwords when also setting passwords. On OpenBSD skip unlocking
password as `usermode -C no foo` does not work.
Diffstat (limited to 'cloudinit/distros/netbsd.py')
-rw-r--r-- | cloudinit/distros/netbsd.py | 10 |
1 files changed, 9 insertions, 1 deletions
diff --git a/cloudinit/distros/netbsd.py b/cloudinit/distros/netbsd.py index 69d07846..6ae60943 100644 --- a/cloudinit/distros/netbsd.py +++ b/cloudinit/distros/netbsd.py @@ -95,10 +95,11 @@ class NetBSD(cloudinit.distros.bsd.BSD): crypt.mksalt(method)) try: - util.subp(['usermod', '-C', 'no', '-p', hashed_pw, user]) + util.subp(['usermod', '-p', hashed_pw, user]) except Exception: util.logexc(LOG, "Failed to set password for %s", user) raise + self.unlock_passwd(user) def force_passwd_change(self, user): try: @@ -114,6 +115,13 @@ class NetBSD(cloudinit.distros.bsd.BSD): util.logexc(LOG, "Failed to lock user %s", name) raise + def unlock_passwd(self, name): + try: + util.subp(['usermod', '-C', 'no', name]) + except Exception: + util.logexc(LOG, "Failed to unlock user %s", name) + raise + def apply_locale(self, locale, out_fn=None): LOG.debug('Cannot set the locale.') |