@ -29,7 +29,6 @@ except Exception:
pass
pass
import fcntl
import fcntl
import hashlib
import os
import os
import shlex
import shlex
import signal
import signal
@ -119,6 +118,8 @@ class Server():
self._start_time = datetime.datetime.now()
self._start_time = datetime.datetime.now()
self.log("setup connection %s" % self.play_context.connection)
self.conn = connection_loader.get(play_context.connection, play_context, sys.stdin)
self.conn = connection_loader.get(play_context.connection, play_context, sys.stdin)
self.conn._connect()
self.conn._connect()
if not self.conn.connected:
if not self.conn.connected:
@ -259,20 +260,15 @@ def main():
display.verbosity = pc.verbosity
display.verbosity = pc.verbosity
# here we create a hash to use later when creating the socket file,
ssh = connection_loader.get('ssh', class_only=True)
# so we can hide the info about the target host/user/etc.
m = ssh._create_control_path(pc.remote_addr, pc.port, pc.remote_user)
m = hashlib.sha256()
for attr in ('connection', 'remote_addr', 'port', 'remote_user'):
val = getattr(pc, attr, None)
if val:
m.update(to_bytes(val))
# create the persistent connection dir if need be and create the paths
# create the persistent connection dir if need be and create the paths
# which we will be using later
# which we will be using later
tmp_path = unfrackpath("$HOME/.ansible/pc")
tmp_path = unfrackpath("$HOME/.ansible/pc")
makedirs_safe(tmp_path)
makedirs_safe(tmp_path)
lk_path = unfrackpath("%s/.ansible_pc_lock" % tmp_path)
lk_path = unfrackpath("%s/.ansible_pc_lock" % tmp_path)
sf_path = unfrackpath("%s/conn-%s" % (tmp_path, m.hexdigest()[0:12] ))
sf_path = unfrackpath(m % dict(directory=tmp_path ))
# if the socket file doesn't exist, spin up the daemon process
# if the socket file doesn't exist, spin up the daemon process
lock_fd = os.open(lk_path, os.O_RDWR|os.O_CREAT, 0o600)
lock_fd = os.open(lk_path, os.O_RDWR|os.O_CREAT, 0o600)