Fix for already set SSH_ASKPASS env var

This commit is contained in:
Ymage 2022-08-21 13:11:20 +02:00
parent 4908899986
commit e186367d5d

View file

@ -226,7 +226,7 @@ def ssh_add(session: str, item_id: str, key_id: str, key_pw: Optional[str]) -> N
) )
else: else:
envdict = dict(os.environ, SSH_ASKPASS_REQUIRE="never") envdict = dict(os.environ, SSH_ASKPASS_REQUIRE="never")
logging.debug("Running ssh-add") logging.debug("Running ssh-add")
# CAVEAT: `ssh-add` provides no useful output, even with maximum verbosity # CAVEAT: `ssh-add` provides no useful output, even with maximum verbosity
subprocess.run( subprocess.run(
@ -236,7 +236,7 @@ def ssh_add(session: str, item_id: str, key_id: str, key_pw: Optional[str]) -> N
env=envdict, env=envdict,
universal_newlines=True, universal_newlines=True,
check=True, check=True,
) )
if __name__ == '__main__': if __name__ == '__main__':
@ -305,7 +305,7 @@ if __name__ == '__main__':
logging.error('"%s" error: %s', error.cmd[0], error.stderr) logging.error('"%s" error: %s', error.cmd[0], error.stderr)
logging.debug('Error running %s', error.cmd) logging.debug('Error running %s', error.cmd)
if os.environ.get('SSH_ASKPASS'): if os.environ.get('SSH_ASKPASS') and os.environ.get('SSH_ASKPASS') == os.path.realpath(__file__):
print(os.environ.get('SSH_KEY_PASSPHRASE')) print(os.environ.get('SSH_KEY_PASSPHRASE'))
else: else:
main() main()