Skip to content

Commit ed4283f

Browse files
author
Sean Carpenter
committed
Updated ssh-agent handling since ssh-agent -l no longer includes filenames.
This is taken from lyft#52.
1 parent 437ae7c commit ed4283f

File tree

1 file changed

+5
-8
lines changed

1 file changed

+5
-8
lines changed

blessclient/client.py

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -352,21 +352,18 @@ def save_cached_creds(token_data, bless_config):
352352
def ssh_agent_remove_bless(identity_file):
353353
DEVNULL = open(os.devnull, 'w')
354354
try:
355-
current = subprocess.check_output(['ssh-add', '-l']).decode('UTF-8')
356-
match = re.search(re.escape(identity_file), current)
357-
if match:
358-
subprocess.check_call(
359-
['ssh-add', '-d', identity_file], stderr=DEVNULL)
355+
subprocess.check_call(
356+
['ssh-add', '-d', identity_file], stderr=DEVNULL)
360357
except subprocess.CalledProcessError:
361358
logging.debug(
362359
"Non-zero exit from ssh-add, are there no identities in the current agent?")
363360

364361

365362
def ssh_agent_add_bless(identity_file):
366363
DEVNULL = open(os.devnull, 'w')
367-
subprocess.check_call(['ssh-add', identity_file], stderr=DEVNULL)
368-
current = subprocess.check_output(['ssh-add', '-l']).decode('UTF-8')
369-
if not re.search(re.escape(identity_file), current):
364+
try:
365+
subprocess.check_call(['ssh-add', identity_file], stderr=DEVNULL)
366+
except:
370367
logging.debug("Could not add '{}' to ssh-agent".format(identity_file))
371368
sys.stderr.write(
372369
"Couldn't add identity to ssh-agent")

0 commit comments

Comments
 (0)