rsync shellescape disable option

Rsync special remotes can be configured with shellescape=no to avoid shell
quoting that is normally done when using rsync over ssh. This is known to
be needed for certian rsync hosting providers (specificially
hidrive.strato.com) that use rsync over ssh but do not pass it through the
shell.
This commit is contained in:
Joey Hess 2012-05-02 13:08:31 -04:00
parent 17fd57bd81
commit 6d61067599
3 changed files with 30 additions and 9 deletions

View file

@ -22,9 +22,10 @@ import Utility.RsyncFile
type RsyncUrl = String
data RsyncOpts = RsyncOpts {
rsyncUrl :: RsyncUrl,
rsyncOptions :: [CommandParam]
data RsyncOpts = RsyncOpts
{ rsyncUrl :: RsyncUrl
, rsyncOptions :: [CommandParam]
, rsyncShellEscape :: Bool
}
remote :: RemoteType
@ -37,7 +38,7 @@ remote = RemoteType {
gen :: Git.Repo -> UUID -> Maybe RemoteConfig -> Annex Remote
gen r u c = do
o <- genRsyncOpts r
o <- genRsyncOpts r c
cst <- remoteCost r expensiveRemoteCost
return $ encryptableRemote c
(storeEncrypted o)
@ -58,11 +59,13 @@ gen r u c = do
remotetype = remote
}
genRsyncOpts :: Git.Repo -> Annex RsyncOpts
genRsyncOpts r = do
genRsyncOpts :: Git.Repo -> Maybe RemoteConfig -> Annex RsyncOpts
genRsyncOpts r c = do
url <- getRemoteConfig r "rsyncurl" (error "missing rsyncurl")
opts <- getRemoteConfig r "rsync-options" ""
return $ RsyncOpts url $ map Param $ filter safe $ words opts
opts <- map Param . filter safe . words
<$> getRemoteConfig r "rsync-options" ""
let escape = maybe True (\m -> M.lookup "shellescape" m /= Just "no") c
return $ RsyncOpts url opts escape
where
safe o
-- Don't allow user to pass --delete to rsync;
@ -86,7 +89,7 @@ rsyncSetup u c = do
rsyncEscape :: RsyncOpts -> String -> String
rsyncEscape o s
| rsyncUrlIsShell (rsyncUrl o) = shellEscape s
| rsyncShellEscape o && rsyncUrlIsShell (rsyncUrl o) = shellEscape s
| otherwise = s
rsyncUrls :: RsyncOpts -> Key -> [String]