Create persistent socket path using port and connection type (#28492)

* Create persistent socket path using port and connection type

*  Use remote address, port, connection type and remote user
   to create a socket path.

* Fix review comment
This commit is contained in:
Ganesh Nalawade 2017-08-23 18:28:44 -04:00 committed by Brian Coca
parent 9407a17c40
commit cd8c1c1108
2 changed files with 4 additions and 2 deletions

View file

@ -295,7 +295,7 @@ def main():
sys.exit("FAIL: %s" % e)
ssh = connection_loader.get('ssh', class_only=True)
cp = ssh._create_control_path(pc.remote_addr, pc.port, pc.remote_user)
cp = ssh._create_control_path(pc.remote_addr, pc.port, pc.remote_user, pc.connection)
# create the persistent connection dir if need be and create the paths
# which we will be using later

View file

@ -268,9 +268,11 @@ class Connection(ConnectionBase):
sock.close()
@staticmethod
def _create_control_path(host, port, user):
def _create_control_path(host, port, user, connection=None):
'''Make a hash for the controlpath based on con attributes'''
pstring = '%s-%s-%s' % (host, port, user)
if connection:
pstring += '-%s' % connection
m = hashlib.sha1()
m.update(to_bytes(pstring))
digest = m.hexdigest()