From f16c15c9baf757cc481e3733874d554d6b901e5c Mon Sep 17 00:00:00 2001 From: Nick Liu Date: Wed, 12 Jun 2024 20:02:49 -0500 Subject: [PATCH] fix(syncoid): Regression: Fallback recursion `$rhost` mutated already MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit An oversight during the merging of subroutine `getsnapsfallback` into `getsnaps` (https://github.com/jimsalterjrs/sanoid/pull/818/commits/e301b5b1) caused the recursive call to prepend `$sshcmd` to `$rhost` again, leading to this error: ```shell # syncoid --debug root@192.168.122.26:rpool/before syncoid-test-11/after … [TRUNCATED] … WARNING: snapshot listing failed, trying fallback command DEBUG: getting list of snapshots on rpool/before using ssh ssh -S /tmp/syncoid-root19216812226-1718239169-761069-2198 root@192.168.122.26 zfs get -Hpd 1 all ''"'"'rpool/before'"'"'' |... root@192.168.122.26: Command not found. CRITICAL ERROR: snapshots couldn't be listed for rpool/before (exit code 256) at /usr/sbin/syncoid line 1900. ``` Fixes: https://github.com/jimsalterjrs/sanoid/pull/818#issuecomment-2164155867 --- syncoid | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/syncoid b/syncoid index 79ad45f..bb773b6 100755 --- a/syncoid +++ b/syncoid @@ -1874,6 +1874,8 @@ sub getsnaps { my $fsescaped = escapeshellparam($fs); if ($isroot) { $mysudocmd = ''; } else { $mysudocmd = $sudocmd; } + my $rhostOriginal = $rhost; + if ($rhost ne '') { $rhost = "$sshcmd $rhost"; # double escaping needed @@ -1895,7 +1897,7 @@ sub getsnaps { close FH or do { if (!$use_fallback) { writelog('WARN', "snapshot listing failed, trying fallback command"); - return getsnaps($type, $rhost, $fs, $isroot, 1, %snaps); + return getsnaps($type, $rhostOriginal, $fs, $isroot, 1, %snaps); } die "CRITICAL ERROR: snapshots couldn't be listed for $fs (exit code $?)"; };