mirror of https://github.com/jimsalterjrs/sanoid
Merge pull request #909 from phreaker0/socket-rename
rename ssh control socket to avoid problem with length limits and con…
This commit is contained in:
commit
fdbbe28ac7
9
syncoid
9
syncoid
|
|
@ -1786,8 +1786,15 @@ sub getssh {
|
||||||
|
|
||||||
if ($rhost ne "") {
|
if ($rhost ne "") {
|
||||||
if ($remoteuser eq 'root' || $args{'no-privilege-elevation'}) { $isroot = 1; } else { $isroot = 0; }
|
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
|
# 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 |";
|
open FH, "$sshcmd -M -S $socket -o ControlPersist=1m $args{'sshport'} $rhost exit |";
|
||||||
close FH;
|
close FH;
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue