From d9334fd12be8feb11106564d1a3b2e7526c89f43 Mon Sep 17 00:00:00 2001 From: Disassembler Date: Wed, 12 Jun 2019 16:23:07 +0200 Subject: [PATCH] Change LUKS password based on crypttab UUID --- usr/lib/python3.6/vmmgr/vmmgr.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/usr/lib/python3.6/vmmgr/vmmgr.py b/usr/lib/python3.6/vmmgr/vmmgr.py index 7176d02..c75a008 100644 --- a/usr/lib/python3.6/vmmgr/vmmgr.py +++ b/usr/lib/python3.6/vmmgr/vmmgr.py @@ -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