61 lines
2.5 KiB
Diff
61 lines
2.5 KiB
Diff
|
From bcbd6be99d8317793aff905c4222c351a1bf5c46 Mon Sep 17 00:00:00 2001
|
||
|
From: Eduardo Otubo <otubo@redhat.com>
|
||
|
Date: Thu, 21 Jan 2021 10:08:49 +0100
|
||
|
Subject: [PATCH 1/2] DataSourceAzure: update password for defuser if exists
|
||
|
(#671)
|
||
|
|
||
|
RH-Author: Eduardo Terrell Ferrari Otubo (eterrell)
|
||
|
RH-MergeRequest: 37: DataSourceAzure: update password for defuser if exists (#671)
|
||
|
RH-Commit: [1/1] 264092a68a3771cc4ed99dad5b93f7a1433e143a (eterrell/cloud-init)
|
||
|
RH-Bugzilla: 1900892
|
||
|
|
||
|
commit eea754492f074e00b601cf77aa278e3623857c5a
|
||
|
Author: Anh Vo <anhvo@microsoft.com>
|
||
|
Date: Thu Nov 19 00:35:46 2020 -0500
|
||
|
|
||
|
DataSourceAzure: update password for defuser if exists (#671)
|
||
|
|
||
|
cc_set_password will only update the password for the default user if
|
||
|
cfg['password'] is set. The existing code of datasource Azure will fail
|
||
|
to update the default user's password because it does not set that
|
||
|
metadata. If the default user doesn't exist in the image, the current
|
||
|
code works fine because the password is set during user create and
|
||
|
not in cc_set_password
|
||
|
|
||
|
Signed-off-by: Eduardo Otubo <otubo@redhat.com>
|
||
|
---
|
||
|
cloudinit/sources/DataSourceAzure.py | 2 +-
|
||
|
tests/unittests/test_datasource/test_azure.py | 3 +++
|
||
|
2 files changed, 4 insertions(+), 1 deletion(-)
|
||
|
|
||
|
diff --git a/cloudinit/sources/DataSourceAzure.py b/cloudinit/sources/DataSourceAzure.py
|
||
|
index 1c214db9..d4a2d60f 100755
|
||
|
--- a/cloudinit/sources/DataSourceAzure.py
|
||
|
+++ b/cloudinit/sources/DataSourceAzure.py
|
||
|
@@ -1231,7 +1231,7 @@ def read_azure_ovf(contents):
|
||
|
if password:
|
||
|
defuser['lock_passwd'] = False
|
||
|
if DEF_PASSWD_REDACTION != password:
|
||
|
- defuser['passwd'] = encrypt_pass(password)
|
||
|
+ defuser['passwd'] = cfg['password'] = encrypt_pass(password)
|
||
|
|
||
|
if defuser:
|
||
|
cfg['system_info'] = {'default_user': defuser}
|
||
|
diff --git a/tests/unittests/test_datasource/test_azure.py b/tests/unittests/test_datasource/test_azure.py
|
||
|
index 47e03bd1..2059990a 100644
|
||
|
--- a/tests/unittests/test_datasource/test_azure.py
|
||
|
+++ b/tests/unittests/test_datasource/test_azure.py
|
||
|
@@ -919,6 +919,9 @@ scbus-1 on xpt0 bus 0
|
||
|
crypt.crypt(odata['UserPassword'],
|
||
|
defuser['passwd'][0:pos]))
|
||
|
|
||
|
+ # the same hashed value should also be present in cfg['password']
|
||
|
+ self.assertEqual(defuser['passwd'], dsrc.cfg['password'])
|
||
|
+
|
||
|
def test_user_not_locked_if_password_redacted(self):
|
||
|
odata = {'HostName': "myhost", 'UserName': "myuser",
|
||
|
'UserPassword': dsaz.DEF_PASSWD_REDACTION}
|
||
|
--
|
||
|
2.18.4
|
||
|
|