From e24ddb8946e73119c8dced2ea6580fa5c7b8438f Mon Sep 17 00:00:00 2001 From: Joey Hess Date: Wed, 10 Feb 2021 13:29:12 -0400 Subject: [PATCH] Bugfix: fsck --from a ssh remote did not actually check that the content on the remote is not corrupted Changing to the P2P protocol broke this, because preseedTmp copies the local copy of the object to the temp file, and then the P2P transfer sees the right length file and uses it as-is. When git-annex-shell is too old and rsync is used, it did verify the content, and when the local repo does not have the object it did verify the content. --- CHANGELOG | 2 ++ Remote/Git.hs | 11 +++-------- 2 files changed, 5 insertions(+), 8 deletions(-) diff --git a/CHANGELOG b/CHANGELOG index c7328abf21..580d5832ad 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -26,6 +26,8 @@ git-annex (8.20210128) UNRELEASED; urgency=medium verification itself. * Checksum as content is received from a remote git-annex repository over ssh/p2p protocols, rather than doing it in a second pass. + * Bugfix: fsck --from a ssh remote did not actually check that the + content on the remote is not corrupted. -- Joey Hess Thu, 28 Jan 2021 12:34:32 -0400 diff --git a/Remote/Git.hs b/Remote/Git.hs index 0964299fa0..43255ec32d 100644 --- a/Remote/Git.hs +++ b/Remote/Git.hs @@ -184,7 +184,7 @@ gen r u rc gc rs , name = Git.repoDescribe r , storeKey = copyToRemote new st , retrieveKeyFile = copyFromRemote new st - , retrieveKeyFileCheap = copyFromRemoteCheap new st r + , retrieveKeyFileCheap = copyFromRemoteCheap st r , retrievalSecurityPolicy = RetrievalAllKeysSecure , removeKey = dropKey new st , lockContent = Just (lockKey new st) @@ -635,9 +635,9 @@ copyFromRemote'' repo forcersync r st@(State connpool _ _ _ _) key file dest met bracketIO noop (const cleanup) (const $ a feeder) `onException` liftIO forcestop -copyFromRemoteCheap :: Remote -> State -> Git.Repo -> Maybe (Key -> AssociatedFile -> FilePath -> Annex ()) +copyFromRemoteCheap :: State -> Git.Repo -> Maybe (Key -> AssociatedFile -> FilePath -> Annex ()) #ifndef mingw32_HOST_OS -copyFromRemoteCheap r st repo +copyFromRemoteCheap st repo | not $ Git.repoIsUrl repo = Just $ \key _af file -> guardUsable repo (giveup "cannot access remote") $ do gc <- getGitConfigFromState st loc <- liftIO $ gitAnnexLocation key repo gc @@ -647,11 +647,6 @@ copyFromRemoteCheap r st repo R.createSymbolicLink absloc (toRawFilePath file) , giveup "remote does not contain key" ) - | Git.repoIsSsh repo = Just $ \key af file -> - ifM (Annex.Content.preseedTmp key file) - ( void $ copyFromRemote' True r st key af file nullMeterUpdate - , giveup "cannot preseed rsync with existing content" - ) | otherwise = Nothing #else copyFromRemoteCheap _ _ _ = Nothing