Send patches - preferably formatted by git format-patch - to patches at archlinux32 dot org.
summaryrefslogtreecommitdiff
path: root/archinstall/lib/luks.py
diff options
context:
space:
mode:
Diffstat (limited to 'archinstall/lib/luks.py')
-rw-r--r--archinstall/lib/luks.py9
1 files changed, 7 insertions, 2 deletions
diff --git a/archinstall/lib/luks.py b/archinstall/lib/luks.py
index c9946239..fa040788 100644
--- a/archinstall/lib/luks.py
+++ b/archinstall/lib/luks.py
@@ -6,13 +6,14 @@ from .output import log, LOG_LEVELS
from .storage import storage
class luks2():
- def __init__(self, partition, mountpoint, password, key_file=None, *args, **kwargs):
+ def __init__(self, partition, mountpoint, password, key_file=None, auto_unmount=False, *args, **kwargs):
self.password = password
self.partition = partition
self.mountpoint = mountpoint
self.args = args
self.kwargs = kwargs
self.key_file = key_file
+ self.auto_unmount = auto_unmount
self.filesystem = 'crypto_LUKS'
def __enter__(self):
@@ -32,6 +33,9 @@ class luks2():
def __exit__(self, *args, **kwargs):
# TODO: https://stackoverflow.com/questions/28157929/how-to-safely-handle-an-exception-inside-a-context-manager
+ if self.auto_unmount:
+ self.close()
+
if len(args) >= 2 and args[1]:
raise args[1]
return True
@@ -73,11 +77,12 @@ class luks2():
:param mountpoint: The name without absolute path, for instance "luksdev" will point to /dev/mapper/luksdev
:type mountpoint: str
"""
+ from .disk import get_filesystem_type
if '/' in mountpoint:
os.path.basename(mountpoint) # TODO: Raise exception instead?
sys_command(f'/usr/bin/cryptsetup open {partition.path} {mountpoint} --key-file {os.path.abspath(key_file)} --type luks2')
if os.path.islink(f'/dev/mapper/{mountpoint}'):
- return Partition(f'/dev/mapper/{mountpoint}', encrypted=True)
+ return Partition(f'/dev/mapper/{mountpoint}', encrypted=True, filesystem=get_filesystem_type(f'/dev/mapper/{mountpoint}'))
def close(self, mountpoint):
sys_command(f'cryptsetup close /dev/mapper/{mountpoint}')