Added a safety check to verify that the encrypted partition exists at least before trying to open it.
This commit is contained in:
parent
c5d099c3fa
commit
ae2da06075
|
|
@ -1,5 +1,7 @@
|
||||||
import os
|
import os
|
||||||
import shlex
|
import shlex
|
||||||
|
import time
|
||||||
|
import pathlib
|
||||||
from .exceptions import *
|
from .exceptions import *
|
||||||
from .general import *
|
from .general import *
|
||||||
from .disk import Partition
|
from .disk import Partition
|
||||||
|
|
@ -123,6 +125,11 @@ class luks2():
|
||||||
from .disk import get_filesystem_type
|
from .disk import get_filesystem_type
|
||||||
if '/' in mountpoint:
|
if '/' in mountpoint:
|
||||||
os.path.basename(mountpoint) # TODO: Raise exception instead?
|
os.path.basename(mountpoint) # TODO: Raise exception instead?
|
||||||
|
|
||||||
|
wait_timer = time.time()
|
||||||
|
while pathlib.Paht(partition.path).exists() is False and time.time() - wait_timer < 10:
|
||||||
|
time.sleep(0.025)
|
||||||
|
|
||||||
sys_command(f'/usr/bin/cryptsetup open {partition.path} {mountpoint} --key-file {os.path.abspath(key_file)} --type luks2')
|
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}'):
|
if os.path.islink(f'/dev/mapper/{mountpoint}'):
|
||||||
self.mapdev = f'/dev/mapper/{mountpoint}'
|
self.mapdev = f'/dev/mapper/{mountpoint}'
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue