diff options
author | Daniil Baturin <daniil@vyos.io> | 2024-03-07 16:36:44 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-03-07 16:36:44 +0100 |
commit | 6e7e7842bc1ba55bd4c91c3af35faf8961793318 (patch) | |
tree | 14e32e239451b380e8b2d7bd80b38beeb5b057cf /src/op_mode/image_manager.py | |
parent | 38fdc27ee2b3253053b2794e3e7ec5d8e0d5aa02 (diff) | |
parent | 4a882d3f8dfcf1900da9f98f5993c9d63e70d3a8 (diff) | |
download | vyos-1x-6e7e7842bc1ba55bd4c91c3af35faf8961793318.tar.gz vyos-1x-6e7e7842bc1ba55bd4c91c3af35faf8961793318.zip |
Merge pull request #1740 from sarthurdev/tpm_luks
config: T4919: Add support for encrypted config with TPM
Diffstat (limited to 'src/op_mode/image_manager.py')
-rwxr-xr-x | src/op_mode/image_manager.py | 21 |
1 files changed, 20 insertions, 1 deletions
diff --git a/src/op_mode/image_manager.py b/src/op_mode/image_manager.py index e64a85b95..1510a667c 100755 --- a/src/op_mode/image_manager.py +++ b/src/op_mode/image_manager.py @@ -1,6 +1,6 @@ #!/usr/bin/env python3 # -# Copyright 2023 VyOS maintainers and contributors <maintainers@vyos.io> +# Copyright 2023-2024 VyOS maintainers and contributors <maintainers@vyos.io> # # This file is part of VyOS. # @@ -95,6 +95,15 @@ def delete_image(image_name: Optional[str] = None, except Exception as err: exit(f'Unable to remove the image "{image_name}": {err}') + # remove LUKS volume if it exists + luks_path: Path = Path(f'{persistence_storage}/luks/{image_name}') + if luks_path.is_file(): + try: + luks_path.unlink() + print(f'The encrypted config for "{image_name}" was successfully deleted') + except Exception as err: + exit(f'Unable to remove the encrypted config for "{image_name}": {err}') + @compat.grub_cfg_update def set_image(image_name: Optional[str] = None, @@ -174,6 +183,16 @@ def rename_image(name_old: str, name_new: str) -> None: except Exception as err: exit(f'Unable to rename image "{name_old}" to "{name_new}": {err}') + # rename LUKS volume if it exists + old_luks_path: Path = Path(f'{persistence_storage}/luks/{name_old}') + if old_luks_path.is_file(): + try: + new_luks_path: Path = Path(f'{persistence_storage}/luks/{name_new}') + old_luks_path.rename(new_luks_path) + print(f'The encrypted config for "{name_old}" was successfully renamed to "{name_new}"') + except Exception as err: + exit(f'Unable to rename the encrypted config for "{name_old}" to "{name_new}": {err}') + def list_images() -> None: """Print list of available images for CLI hints""" |