diff options
author | Lars Wirzenius <liw@liw.fi> | 2022-01-01 11:01:07 +0200 |
---|---|---|
committer | Lars Wirzenius <liw@liw.fi> | 2022-01-01 11:01:07 +0200 |
commit | 4bf7c361021a163203002196c36966d122575932 (patch) | |
tree | bcc4ee989838bd96d37c34a6b06df7fd34c33ec0 | |
parent | 2af1227d0c89b86618535183ae6246af1899a7ae (diff) | |
download | vmdb2-4bf7c361021a163203002196c36966d122575932.tar.gz |
cryptsetup: open device
Sponsored-by: author
-rw-r--r-- | vmdb/plugins/cryptsetup_plugin.py | 11 |
1 files changed, 10 insertions, 1 deletions
diff --git a/vmdb/plugins/cryptsetup_plugin.py b/vmdb/plugins/cryptsetup_plugin.py index e898bc6..496716d 100644 --- a/vmdb/plugins/cryptsetup_plugin.py +++ b/vmdb/plugins/cryptsetup_plugin.py @@ -42,6 +42,15 @@ class CryptsetupStepRunner(vmdb.StepRunnerInterface): key = os.path.join(tmp, "key") with open(key, "w") as f: f.write(password) - vmdb.runcmd(["cryptsetup", "--batch-mode", "luksFormat", device, key]) + vmdb.runcmd(["cryptsetup", "luksFormat", "--batch-mode", device, key]) + vmdb.runcmd( + ["cryptsetup", "open", "--type=luks", "--key-file", key, device, name] + ) + crypt_device = f"/dev/mapper/{name}" + assert os.path.exists(crypt_device) + state.tags.append(name) + vmdb.progress("remembering block device {} as {}".format(crypt_device, name)) + state.tags.set_dev(name, crypt_device) + shutil.rmtree(tmp) |