do not re-set installer user password if it can be found in cloud-init.log
To avoid re-setting the password when refreshing from a subiquity that does not have this change
This commit is contained in:
parent
87c2e7539e
commit
47eefa42fe
|
@ -116,6 +116,20 @@ class MetaController:
|
||||||
ips=ips)
|
ips=ips)
|
||||||
|
|
||||||
|
|
||||||
|
def get_installer_password_from_cloudinit_log():
|
||||||
|
try:
|
||||||
|
fp = open("/var/log/cloud-init-output.log")
|
||||||
|
except FileNotFoundError:
|
||||||
|
return None
|
||||||
|
|
||||||
|
with fp:
|
||||||
|
for line in fp:
|
||||||
|
if line.startswith("installer:"):
|
||||||
|
return line[len("installer:"):].strip()
|
||||||
|
|
||||||
|
return None
|
||||||
|
|
||||||
|
|
||||||
class SubiquityServer(Application):
|
class SubiquityServer(Application):
|
||||||
|
|
||||||
snapd_socket_path = '/run/snapd.socket'
|
snapd_socket_path = '/run/snapd.socket'
|
||||||
|
@ -409,6 +423,13 @@ class SubiquityServer(Application):
|
||||||
if self.opts.dry_run:
|
if self.opts.dry_run:
|
||||||
self.installer_user_passwd = rand_user_password()
|
self.installer_user_passwd = rand_user_password()
|
||||||
return
|
return
|
||||||
|
# refreshing from a version of subiquity that relied on
|
||||||
|
# cloud-init to set the password to one that does not should
|
||||||
|
# not reset the password.
|
||||||
|
passwd = get_installer_password_from_cloudinit_log()
|
||||||
|
if passwd:
|
||||||
|
self.installer_user_passwd = passwd
|
||||||
|
return
|
||||||
try:
|
try:
|
||||||
pwd.getpwnam('installer')
|
pwd.getpwnam('installer')
|
||||||
except KeyError:
|
except KeyError:
|
||||||
|
|
Loading…
Reference in New Issue