summaryrefslogtreecommitdiff
path: root/cloudinit/config
diff options
context:
space:
mode:
authorGonéri Le Bouder <goneri@lebouder.net>2020-03-25 13:44:10 -0400
committerGitHub <noreply@github.com>2020-03-25 13:44:10 -0400
commit993f3e3e76e56266a83776a8f54dbb3ba59cfce7 (patch)
treea7226ed8f85b6a8b09c14d923bc08aadf5a1c11b /cloudinit/config
parent42f69f410ab8850c02b1f53dd67c132aa8ef64f5 (diff)
downloadvyos-cloud-init-993f3e3e76e56266a83776a8f54dbb3ba59cfce7.tar.gz
vyos-cloud-init-993f3e3e76e56266a83776a8f54dbb3ba59cfce7.zip
set_passwords: avoid chpasswd on BSD (#268)
Avoid chpasswd on all the BSD variants.
Diffstat (limited to 'cloudinit/config')
-rwxr-xr-xcloudinit/config/cc_set_passwords.py2
-rw-r--r--cloudinit/config/tests/test_set_passwords.py16
2 files changed, 9 insertions, 9 deletions
diff --git a/cloudinit/config/cc_set_passwords.py b/cloudinit/config/cc_set_passwords.py
index 4943d545..7b7aa885 100755
--- a/cloudinit/config/cc_set_passwords.py
+++ b/cloudinit/config/cc_set_passwords.py
@@ -241,7 +241,7 @@ def rand_user_password(pwlen=20):
def chpasswd(distro, plist_in, hashed=False):
- if util.is_FreeBSD():
+ if util.is_BSD():
for pentry in plist_in.splitlines():
u, p = pentry.split(":")
distro.set_passwd(u, p, hashed=hashed)
diff --git a/cloudinit/config/tests/test_set_passwords.py b/cloudinit/config/tests/test_set_passwords.py
index 8247c388..2732bd60 100644
--- a/cloudinit/config/tests/test_set_passwords.py
+++ b/cloudinit/config/tests/test_set_passwords.py
@@ -112,12 +112,12 @@ class TestSetPasswordsHandle(CiTestCase):
'\n'.join(valid_hashed_pwds) + '\n')],
m_subp.call_args_list)
- @mock.patch(MODPATH + "util.is_FreeBSD")
+ @mock.patch(MODPATH + "util.is_BSD")
@mock.patch(MODPATH + "util.subp")
- def test_freebsd_calls_custom_pw_cmds_to_set_and_expire_passwords(
- self, m_subp, m_is_freebsd):
- """FreeBSD calls custom pw commands instead of chpasswd and passwd"""
- m_is_freebsd.return_value = True
+ def test_bsd_calls_custom_pw_cmds_to_set_and_expire_passwords(
+ self, m_subp, m_is_bsd):
+ """BSD don't use chpasswd"""
+ m_is_bsd.return_value = True
cloud = self.tmp_cloud(distro='freebsd')
valid_pwds = ['ubuntu:passw0rd']
cfg = {'chpasswd': {'list': valid_pwds}}
@@ -129,12 +129,12 @@ class TestSetPasswordsHandle(CiTestCase):
mock.call(['pw', 'usermod', 'ubuntu', '-p', '01-Jan-1970'])],
m_subp.call_args_list)
- @mock.patch(MODPATH + "util.is_FreeBSD")
+ @mock.patch(MODPATH + "util.is_BSD")
@mock.patch(MODPATH + "util.subp")
def test_handle_on_chpasswd_list_creates_random_passwords(self, m_subp,
- m_is_freebsd):
+ m_is_bsd):
"""handle parses command set random passwords."""
- m_is_freebsd.return_value = False
+ m_is_bsd.return_value = False
cloud = self.tmp_cloud(distro='ubuntu')
valid_random_pwds = [
'root:R',