summaryrefslogtreecommitdiff
path: root/bin
diff options
context:
space:
mode:
authorNathaniel Case <this.is@nathanielca.se>2018-12-17 12:53:32 -0500
committerGitHub <noreply@github.com>2018-12-17 12:53:32 -0500
commit61a649ce0f5c2f37d399805cd6d91ee7a87e9e76 (patch)
tree7cd1d1f97ac90208cea00c3d65c850c6ec5b00f7 /bin
parentbf4ad56479a652521056c8f6fbff24f31927dee8 (diff)
downloadansible-61a649ce0f5c2f37d399805cd6d91ee7a87e9e76.tar.gz
Don't fail if a remote_addr with a '/' hits ansible_connection (#49781)
* Fail if a remote_addr with a '/' hist ansible_connection This is _probably_ a CIDR block, but anything with a slash will fail, so no need to try to parse to make sure * Locks are now per-socket_path. Locks use the same value as socket_path. Locks are also cleaned up in shutdown like sockets.
Diffstat (limited to 'bin')
-rwxr-xr-xbin/ansible-connection7
1 files changed, 6 insertions, 1 deletions
diff --git a/bin/ansible-connection b/bin/ansible-connection
index ce03429703..a7a1b23716 100755
--- a/bin/ansible-connection
+++ b/bin/ansible-connection
@@ -179,6 +179,7 @@ class ConnectionProcess(object):
def shutdown(self):
""" Shuts down the local domain socket
"""
+ lock_path = unfrackpath("%s/.ansible_pc_lock_%s" % os.path.split(self.socket_path))
if os.path.exists(self.socket_path):
try:
if self.sock:
@@ -192,6 +193,10 @@ class ConnectionProcess(object):
os.remove(self.socket_path)
setattr(self.connection, '_socket_path', None)
setattr(self.connection, '_connected', False)
+
+ if os.path.exists(lock_path):
+ os.remove(lock_path)
+
display.display('shutdown complete', log_only=True)
@@ -246,8 +251,8 @@ def main():
tmp_path = unfrackpath(C.PERSISTENT_CONTROL_PATH_DIR)
makedirs_safe(tmp_path)
- lock_path = unfrackpath("%s/.ansible_pc_lock_%s" % (tmp_path, play_context.remote_addr))
socket_path = unfrackpath(cp % dict(directory=tmp_path))
+ lock_path = unfrackpath("%s/.ansible_pc_lock_%s" % os.path.split(socket_path))
with file_lock(lock_path):
if not os.path.exists(socket_path):