Commit 0adf7154 authored by Matthias Klumpp's avatar Matthias Klumpp

Fix some mistakes and rebuild initramfs in cryptestup helper

parent c88b6ae7
......@@ -78,7 +78,8 @@ def run(new_password):
for partition in partitions:
if not partition.strip():
partition = partition.strip()
if not partition:
continue
out, err, ret = run_command(['cryptsetup',
......@@ -92,16 +93,16 @@ def run(new_password):
out, err, ret = run_command(['cryptsetup',
'luksRemoveKey',
partition,
KEYFILE_OLD,
'--key-file', KEYFILE])
KEYFILE_OLD])
if ret != 0:
raise Exception("Unable to remove old key file: {} - {}".format(out, err))
out, err, ret = run_command(['cryptsetup',
'luksAddKey',
partition,
new_password,
'--key-file', KEYFILE])
'--key-file', KEYFILE,
'-q'],
input=new_password)
if ret != 0:
raise Exception("Unable to add key: {} - {}".format(out, err))
......@@ -113,22 +114,22 @@ def run(new_password):
raise Exception("Unable to set permissions on key file: {} - {}".format(out, err))
os.remove(KEYFILE_OLD)
os.remove(ENCRYPT_BYPASS_INITRAMFS_HOOK)
os.remove(CALAMARES_LUKS_PARTITION_FILE)
os.system('update-initramfs -u')
def main():
parser = argparse.ArgumentParser(description="Set a new disk password, replacing existing ones")
parser.add_argument('-p', '--password', type=str, required=True)
parser.add_argument('-d', '--partition', type=str, required=True)
args = parser.parse_args()
if not os.path.isfile(ENCRYPT_BYPASS_INITRAMFS_HOOK) or not os.path.isfile(CALAMARES_LUKS_PARTITION_FILE):
print('Encrypt bypass initramfs hook does not exist, script will not do anything')
return
run(args.password, args.partition)
run(args.password)
if __name__ == '__main__':
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment