From a059054ffb78ece128f79de8c9fc65342e3006d5 Mon Sep 17 00:00:00 2001 From: Christoph Klaffl Date: Wed, 17 Apr 2024 08:14:04 +0200 Subject: [PATCH] rename ssh control socket to avoid problem with length limits and conflicts --- syncoid | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/syncoid b/syncoid index 61814d2..a1cf416 100755 --- a/syncoid +++ b/syncoid @@ -1786,8 +1786,15 @@ sub getssh { if ($rhost ne "") { if ($remoteuser eq 'root' || $args{'no-privilege-elevation'}) { $isroot = 1; } else { $isroot = 0; } + + my $sanitizedrhost = $rhost; + $sanitizedrhost =~ s/[^a-zA-Z0-9-]//g; + # unix socket path have a length limit of about 104 characters so make sure it's not exceeded + $sanitizedrhost = substr($sanitizedrhost, 0, 50); + # now we need to establish a persistent master SSH connection - $socket = "/tmp/syncoid-$rhost-" . time() . "-" . int(rand(10000)); + $socket = "/tmp/syncoid-$sanitizedrhost-" . time() . "-" . $$ . "-" . int(rand(10000)); + open FH, "$sshcmd -M -S $socket -o ControlPersist=1m $args{'sshport'} $rhost exit |"; close FH;