summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJoshua Harlow <harlowja@gmail.com>2013-01-05 10:18:01 -0800
committerJoshua Harlow <harlowja@gmail.com>2013-01-05 10:18:01 -0800
commit6cfd12c96608eb5fd086da49c4c685635e40e6e0 (patch)
treed595e38aee2f777839369231cc31a0c03421decb
parent3569e71a1579b97f4e33fb46ab3fcef08a4ddad4 (diff)
downloadvyos-cloud-init-6cfd12c96608eb5fd086da49c4c685635e40e6e0.tar.gz
vyos-cloud-init-6cfd12c96608eb5fd086da49c4c685635e40e6e0.zip
Fix the password locking logic.
Instead of only not locking when system is present the logic should handle the correct case when lock password is set and system is not present. LP: #1096423
-rw-r--r--cloudinit/distros/__init__.py7
1 files changed, 4 insertions, 3 deletions
diff --git a/cloudinit/distros/__init__.py b/cloudinit/distros/__init__.py
index 6a684b89..be32757d 100644
--- a/cloudinit/distros/__init__.py
+++ b/cloudinit/distros/__init__.py
@@ -335,9 +335,10 @@ class Distro(object):
self.set_passwd(name, kwargs['plain_text_passwd'])
# Default locking down the account.
- if ('lock_passwd' not in kwargs and
- ('lock_passwd' in kwargs and kwargs['lock_passwd']) or
- 'system' not in kwargs):
+ #
+ # Which means if lock_passwd is False (on non-existent its true)
+ # then lock or if system is True (on non-existent its false) then lock.
+ if (kwargs.get('lock_passwd', True) or kwargs.get('system', False)):
try:
util.subp(['passwd', '--lock', name])
except Exception as e: