2def1d0a23
In c6632ee5c8
, it actually only handled
uploading objects to a shared repository. To avoid verification when
downloading objects from a shared repository, was a lot harder.
On the plus side, if the process of downloading a file from a remote
is able to verify its content on the side, the remote can indicate this
now, and avoid the extra post-download verification.
As of yet, I don't have any remotes (except Git) using this ability.
Some more work would be needed to support it in special remotes.
It would make sense for tahoe to implicitly verify things downloaded from it;
as long as you trust your tahoe server (which typically runs locally),
there's cryptographic integrity. OTOH, despite bup being based on shas,
a bup repo under an attacker's control could have the git ref used for an
object changed, and so a bup repo shouldn't implicitly verify. Indeed,
tahoe seems unique in being trustworthy enough to implicitly verify.
46 lines
1.2 KiB
Haskell
46 lines
1.2 KiB
Haskell
{- git-annex command
|
|
-
|
|
- Copyright 2010 Joey Hess <id@joeyh.name>
|
|
-
|
|
- Licensed under the GNU GPL version 3 or higher.
|
|
-}
|
|
|
|
module Command.RecvKey where
|
|
|
|
import Common.Annex
|
|
import Command
|
|
import Annex.Content
|
|
import Annex.Action
|
|
import Annex
|
|
import Utility.Rsync
|
|
import Logs.Transfer
|
|
import Command.SendKey (fieldTransfer)
|
|
import qualified CmdLine.GitAnnexShell.Fields as Fields
|
|
|
|
cmd :: Command
|
|
cmd = noCommit $ command "recvkey" SectionPlumbing
|
|
"runs rsync in server mode to receive content"
|
|
paramKey (withParams seek)
|
|
|
|
seek :: CmdParams -> CommandSeek
|
|
seek = withKeys start
|
|
|
|
start :: Key -> CommandStart
|
|
start key = fieldTransfer Download key $ \_p -> do
|
|
-- Always verify content when a direct mode repo is sending a file,
|
|
-- as the file could change while being transferred.
|
|
fromdirect <- isJust <$> Fields.getField Fields.direct
|
|
let verify = if fromdirect then AlwaysVerify else DefaultVerify
|
|
ifM (getViaTmp verify key go)
|
|
( do
|
|
-- forcibly quit after receiving one key,
|
|
-- and shutdown cleanly
|
|
_ <- shutdown True
|
|
return True
|
|
, return False
|
|
)
|
|
where
|
|
go tmp = unVerified $ do
|
|
opts <- filterRsyncSafeOptions . maybe [] words
|
|
<$> getField "RsyncOptions"
|
|
liftIO $ rsyncServerReceive (map Param opts) tmp
|