Verified Commit 181f2460 authored by Jakob Moser's avatar Jakob Moser
Browse files

Make cryptsetup more robust

parent fc192b08
Loading
Loading
Loading
Loading
+21 −15
Original line number Diff line number Diff line
@@ -71,6 +71,7 @@ class Vault(AbstractContextManager):

        :raise FileNotFoundError: if after opening attempt there is no mapper file, i.e. opening failed
        """
        try:
            run(
                [
                    "sudo",
@@ -86,6 +87,11 @@ class Vault(AbstractContextManager):
                input=password.encode("utf-8"),
                check=True,
            )
        except CalledProcessError as e:
            if e.returncode == 5:
                pass  # Device already exists, i.e., luks-volume was not properly closed previously. We ignore this.
            else:
                raise e

        if not self._mapper.exists():
            raise FileNotFoundError(