From bec8f387252ac32e1fd7963cf871ceed8d313edd Mon Sep 17 00:00:00 2001 From: Gonéri Le Bouder Date: Thu, 2 Apr 2020 15:33:37 -0400 Subject: 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. --- cloudinit/distros/netbsd.py | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) (limited to 'cloudinit/distros/netbsd.py') 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.') -- cgit v1.2.3