VeraCrypt: Speichere Passwort abhängig von USB-Stick- und Containernamen
This commit is contained in:
parent
61fee22239
commit
abfcaa3aa1
|
@ -47,19 +47,16 @@ def __sync_io():
|
||||||
])
|
])
|
||||||
res.check_returncode()
|
res.check_returncode()
|
||||||
|
|
||||||
def __store_password(pw):
|
def __store_password(username, pw):
|
||||||
username = getpass.getuser()
|
|
||||||
keyring.set_password(KEYRING_SERVICE, username, pw)
|
keyring.set_password(KEYRING_SERVICE, username, pw)
|
||||||
|
|
||||||
def __delete_password():
|
def __delete_password(username):
|
||||||
username = getpass.getuser()
|
|
||||||
keyring.delete_password(KEYRING_SERVICE, username)
|
keyring.delete_password(KEYRING_SERVICE, username)
|
||||||
|
|
||||||
def __get_password(reset_pw = False):
|
def __get_password(username, reset_pw = False):
|
||||||
if reset_pw:
|
if reset_pw:
|
||||||
__delete_password()
|
__delete_password(username)
|
||||||
|
|
||||||
username = getpass.getuser()
|
|
||||||
pw = keyring.get_password(KEYRING_SERVICE, username)
|
pw = keyring.get_password(KEYRING_SERVICE, username)
|
||||||
if not pw:
|
if not pw:
|
||||||
pw = getpass.getpass()
|
pw = getpass.getpass()
|
||||||
|
@ -92,8 +89,8 @@ def unmount_usbdrive(usbdrive_mnt_path):
|
||||||
|
|
||||||
res.check_returncode()
|
res.check_returncode()
|
||||||
|
|
||||||
def vera_mount(volume_path, container):
|
def vera_mount(volume_path, container, identifier):
|
||||||
pw = __get_password()
|
pw = __get_password(identifier)
|
||||||
|
|
||||||
res = __vera_exec([
|
res = __vera_exec([
|
||||||
VERA_PARAM_NON_INTERACTIVE,
|
VERA_PARAM_NON_INTERACTIVE,
|
||||||
|
@ -102,7 +99,7 @@ def vera_mount(volume_path, container):
|
||||||
|
|
||||||
assert res == 0, \
|
assert res == 0, \
|
||||||
"Failed to mount VeraCrypt volume! VeraCrypt exited with status {}.".format(res)
|
"Failed to mount VeraCrypt volume! VeraCrypt exited with status {}.".format(res)
|
||||||
__store_password(pw)
|
__store_password(identifier, pw)
|
||||||
|
|
||||||
def __parse_cmdline():
|
def __parse_cmdline():
|
||||||
parser = argparse.ArgumentParser(description = DESCRIPTION)
|
parser = argparse.ArgumentParser(description = DESCRIPTION)
|
||||||
|
@ -128,9 +125,6 @@ def __parse_cmdline():
|
||||||
def __main():
|
def __main():
|
||||||
args = __parse_cmdline()
|
args = __parse_cmdline()
|
||||||
|
|
||||||
if args[ARG_RESET_PASSWORD]:
|
|
||||||
__delete_password()
|
|
||||||
|
|
||||||
volume_name = args[ARG_VERA_VOL_NAME]
|
volume_name = args[ARG_VERA_VOL_NAME]
|
||||||
mnt_path = args[ARG_MOUNT_PATH]
|
mnt_path = args[ARG_MOUNT_PATH]
|
||||||
volume = os.path.join(mnt_path, volume_name)
|
volume = os.path.join(mnt_path, volume_name)
|
||||||
|
@ -141,6 +135,15 @@ def __main():
|
||||||
container_name = args[ARG_CONTAINER_NAME]
|
container_name = args[ARG_CONTAINER_NAME]
|
||||||
container = os.path.join(usbdrive, container_name)
|
container = os.path.join(usbdrive, container_name)
|
||||||
|
|
||||||
|
identifier = ':'.join([
|
||||||
|
getpass.getuser(),
|
||||||
|
usbdrive_name,
|
||||||
|
container_name,
|
||||||
|
])
|
||||||
|
|
||||||
|
if args[ARG_RESET_PASSWORD]:
|
||||||
|
__delete_password(identifier)
|
||||||
|
|
||||||
if not os.path.exists(usbdrive):
|
if not os.path.exists(usbdrive):
|
||||||
print(":: USB partition mount point \"{}\" doesn't exist. Ignoring request.".format(usbdrive))
|
print(":: USB partition mount point \"{}\" doesn't exist. Ignoring request.".format(usbdrive))
|
||||||
return
|
return
|
||||||
|
@ -159,7 +162,7 @@ def __main():
|
||||||
print(":: VeraCrypt mount point \"{}\" already exists! Assuming container is already mounted.".format(volume))
|
print(":: VeraCrypt mount point \"{}\" already exists! Assuming container is already mounted.".format(volume))
|
||||||
return
|
return
|
||||||
|
|
||||||
vera_mount(volume, container)
|
vera_mount(volume, container, identifier)
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
__main()
|
__main()
|
||||||
|
|
Loading…
Reference in New Issue