Only check whitelist status if the gpg agent is locked (speeds up successive quick-unlock attempts)

This commit is contained in:
2022-11-06 00:43:25 -04:00
parent 5fa30fa770
commit 0b0c8a37d1
+11 -10
View File
@@ -571,16 +571,17 @@ def whitelist_setup(): # takes input from the user to set up quick-unlock passw
def whitelist_verify(_port, _username_ssh, _ip, _client_device_id): def whitelist_verify(_port, _username_ssh, _ip, _client_device_id):
# checks the user's whitelist status and fetches the full gpg key password if possible # checks the user's whitelist status and fetches the full gpg key password if possible
_i, _full_password = 0, '' try:
_server_whitelist = run('ssh -i ' + "'" + path.expanduser('~/.ssh/sshyp') + "' -p " + _port + " " + _username_ssh + run(f"gpg --pinentry-mode cancel -qd --output /dev/null {path.expanduser('~/.config/sshyp/lock.gpg')}",
'@' + _ip + " 'ls ~/.config/sshyp/whitelist'", shell=True, stdout=PIPE, text=True) shell=True, stderr=PIPE, check=True, close_fds=True)
for _device_id in _server_whitelist.stdout.rstrip().split('\n'): return False
if _device_id == _client_device_id: except CalledProcessError:
try: _i, _full_password = 0, ''
run(f"gpg --pinentry-mode cancel -qd --output /dev/null {path.expanduser('~/.config/sshyp/lock.gpg')}", _server_whitelist = run('ssh -i ' + "'" + path.expanduser('~/.ssh/sshyp') + "' -p " + _port + " " +
shell=True, stderr=PIPE, check=True, close_fds=True) _username_ssh + '@' + _ip + " 'ls ~/.config/sshyp/whitelist'",
_full_password = False shell=True, stdout=PIPE, text=True)
except CalledProcessError: for _device_id in _server_whitelist.stdout.rstrip().split('\n'):
if _device_id == _client_device_id:
_quick_unlock_password = input('\nquick-unlock passphrase: ') _quick_unlock_password = input('\nquick-unlock passphrase: ')
_quick_unlock_password_excluded = \ _quick_unlock_password_excluded = \
run('ssh -i ' + "'" + path.expanduser('~/.ssh/sshyp') + "' -p " + _port + " " + _username_ssh + '@' run('ssh -i ' + "'" + path.expanduser('~/.ssh/sshyp') + "' -p " + _port + " " + _username_ssh + '@'