Change LUKS password based on crypttab UUID
This commit is contained in:
parent
54d3c1d23b
commit
d9334fd12b
@ -86,7 +86,9 @@ class VMMgr:
|
||||
def update_password(self, oldpassword, newpassword):
|
||||
# Update LUKS password and adminpwd for WSGI application
|
||||
pwinput = '{}\n{}'.format(oldpassword, newpassword).encode()
|
||||
subprocess.run(['cryptsetup', 'luksChangeKey', '/dev/sda2'], input=pwinput, check=True)
|
||||
partition_uuid = open('/etc/crypttab').read().split()[1][5:]
|
||||
partition_name = subprocess.run(['/sbin/blkid', '-U', partition_uuid], check=True, stdout=subprocess.PIPE).stdout.decode().strip()
|
||||
subprocess.run(['cryptsetup', 'luksChangeKey', partition_name], input=pwinput, check=True)
|
||||
# Update bcrypt-hashed password in config
|
||||
self.conf['host']['adminpwd'] = crypto.adminpwd_hash(newpassword)
|
||||
# Save config to file
|
||||
|
Loading…
Reference in New Issue
Block a user