From 0b0c8a37d11181ead3bd60c6e8806bc427a11b1a Mon Sep 17 00:00:00 2001 From: Randall Winkhart Date: Sun, 6 Nov 2022 00:43:25 -0400 Subject: [PATCH] Only check whitelist status if the gpg agent is locked (speeds up successive quick-unlock attempts) --- lib/sshyp.py | 21 +++++++++++---------- 1 file changed, 11 insertions(+), 10 deletions(-) diff --git a/lib/sshyp.py b/lib/sshyp.py index 6617ec7..7fb3f43 100755 --- a/lib/sshyp.py +++ b/lib/sshyp.py @@ -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): # checks the user's whitelist status and fetches the full gpg key password if possible - _i, _full_password = 0, '' - _server_whitelist = run('ssh -i ' + "'" + path.expanduser('~/.ssh/sshyp') + "' -p " + _port + " " + _username_ssh + - '@' + _ip + " 'ls ~/.config/sshyp/whitelist'", shell=True, stdout=PIPE, text=True) - for _device_id in _server_whitelist.stdout.rstrip().split('\n'): - if _device_id == _client_device_id: - try: - run(f"gpg --pinentry-mode cancel -qd --output /dev/null {path.expanduser('~/.config/sshyp/lock.gpg')}", - shell=True, stderr=PIPE, check=True, close_fds=True) - _full_password = False - except CalledProcessError: + try: + run(f"gpg --pinentry-mode cancel -qd --output /dev/null {path.expanduser('~/.config/sshyp/lock.gpg')}", + shell=True, stderr=PIPE, check=True, close_fds=True) + return False + except CalledProcessError: + _i, _full_password = 0, '' + _server_whitelist = run('ssh -i ' + "'" + path.expanduser('~/.ssh/sshyp') + "' -p " + _port + " " + + _username_ssh + '@' + _ip + " 'ls ~/.config/sshyp/whitelist'", + shell=True, stdout=PIPE, text=True) + 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_excluded = \ run('ssh -i ' + "'" + path.expanduser('~/.ssh/sshyp') + "' -p " + _port + " " + _username_ssh + '@'