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 | |
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')
-rw-r--r-- | cloudinit/distros/netbsd.py | 10 | ||||
-rw-r--r-- | cloudinit/distros/openbsd.py | 3 |
2 files changed, 12 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.') diff --git a/cloudinit/distros/openbsd.py b/cloudinit/distros/openbsd.py index dbe1f069..ca094156 100644 --- a/cloudinit/distros/openbsd.py +++ b/cloudinit/distros/openbsd.py @@ -32,6 +32,9 @@ class Distro(cloudinit.distros.netbsd.NetBSD): util.logexc(LOG, "Failed to lock user %s", name) raise + def unlock_passwd(self, name): + pass + def _get_pkg_cmd_environ(self): """Return env vars used in OpenBSD package_command operations""" os_release = platform.release() |