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

Former-commit-id: 57486bc120fc8734cbaf1694655ad9bc14c3276b [formerly 0b0c8a37d1]
Former-commit-id: 171de872a6f4c1f08f151d8b287d1584ac4f7061
This commit is contained in:
2022-11-06 00:43:25 -04:00
parent 86ad4e5cad
commit 2beeb1dc38
+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):
# 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 + '@'