mirror of
https://github.com/ccontavalli/ssh-ident.git
synced 2026-06-11 15:37:03 +02:00
Break some long lines into shorter ones.
This commit is contained in:
@@ -475,7 +475,8 @@ class AgentManager(object):
|
||||
keys = " ".join(keys)
|
||||
options = self.config.Get("SSH_ADD_OPTIONS").get(
|
||||
self.identity, self.config.Get("SSH_ADD_DEFAULT_OPTIONS"))
|
||||
self.RunShellCommandInAgent(self.agent_file, "ssh-add {} {}".format(options, keys))
|
||||
self.RunShellCommandInAgent(
|
||||
self.agent_file, "ssh-add {} {}".format(options, keys))
|
||||
|
||||
def GetLoadedKeys(self):
|
||||
"""Returns an iterable of strings, each the fingerprint of a loaded key."""
|
||||
@@ -495,7 +496,8 @@ class AgentManager(object):
|
||||
@staticmethod
|
||||
def GetPublicKeyFingerprint(key):
|
||||
"""Returns the fingerprint of a public key as a string."""
|
||||
retval, stdout = AgentManager.RunShellCommand("ssh-keygen -l -f {} |tr -s ' '".format(key))
|
||||
retval, stdout = AgentManager.RunShellCommand(
|
||||
"ssh-keygen -l -f {} |tr -s ' '".format(key))
|
||||
if retval:
|
||||
return None
|
||||
|
||||
@@ -522,11 +524,12 @@ class AgentManager(object):
|
||||
except OSError as e:
|
||||
if e.errno != errno.EEXIST:
|
||||
raise OSError(
|
||||
"Cannot create agents directory, try manually with 'mkdir -p {}'".format(
|
||||
path))
|
||||
"Cannot create agents directory, try manually with "
|
||||
"'mkdir -p {}'".format(path))
|
||||
|
||||
# Use the hostname as part of the path just in case this is on NFS.
|
||||
agentfile = os.path.join(path, "agent-{}-{}".format(identity, socket.gethostname()))
|
||||
agentfile = os.path.join(
|
||||
path, "agent-{}-{}".format(identity, socket.gethostname()))
|
||||
if os.access(agentfile, os.R_OK) and AgentManager.IsAgentFileValid(agentfile):
|
||||
print("Agent for identity {} ready".format(identity), file=sys.stderr)
|
||||
return agentfile
|
||||
@@ -539,7 +542,8 @@ class AgentManager(object):
|
||||
@staticmethod
|
||||
def IsAgentFileValid(agentfile):
|
||||
"""Returns true if the specified agentfile refers to a running agent."""
|
||||
retval, output = AgentManager.RunShellCommandInAgent(agentfile, "ssh-add -l >/dev/null 2>/dev/null")
|
||||
retval, output = AgentManager.RunShellCommandInAgent(
|
||||
agentfile, "ssh-add -l >/dev/null 2>/dev/null")
|
||||
if retval & 0xff not in [0, 1]:
|
||||
print("Agent in {} not running".format(agentfile), file=sys.stderr)
|
||||
return False
|
||||
@@ -572,9 +576,11 @@ class AgentManager(object):
|
||||
|
||||
def RunSSH(self, argv):
|
||||
"""Execs ssh with the specified arguments."""
|
||||
command = ["/bin/sh", "-c", ". {} >/dev/null 2>/dev/null; exec {} {}".format(
|
||||
self.agent_file, self.config.Get("BINARY_SSH"),
|
||||
self.EscapeShellArguments(argv))]
|
||||
command = [
|
||||
"/bin/sh", "-c",
|
||||
". {} >/dev/null 2>/dev/null; exec {} {}".format(
|
||||
self.agent_file, self.config.Get("BINARY_SSH"),
|
||||
self.EscapeShellArguments(argv))]
|
||||
os.execv("/bin/sh", command)
|
||||
|
||||
def main(argv):
|
||||
|
||||
Reference in New Issue
Block a user