[cookies] Let `_get_mac_keyring_password` fail gracefully

Closes #4915
This commit is contained in:
pukkandan 2022-09-26 02:53:08 +05:30
parent 914491b8e0
commit 46a5b335e7
No known key found for this signature in database
GPG Key ID: 7EEE9E1E817D0A39
1 changed files with 4 additions and 1 deletions

View File

@ -845,12 +845,15 @@ def _get_linux_keyring_password(browser_keyring_name, keyring, logger):
def _get_mac_keyring_password(browser_keyring_name, logger):
logger.debug('using find-generic-password to obtain password from OSX keychain')
try:
stdout, _, _ = Popen.run(
stdout, _, returncode = Popen.run(
['security', 'find-generic-password',
'-w', # write password to stdout
'-a', browser_keyring_name, # match 'account'
'-s', f'{browser_keyring_name} Safe Storage'], # match 'service'
stdout=subprocess.PIPE, stderr=subprocess.DEVNULL)
if returncode:
logger.warning('find-generic-password failed')
return None
return stdout.rstrip(b'\n')
except Exception as e:
logger.warning(f'exception running find-generic-password: {error_to_str(e)}')