import qualified Types.Backend
import qualified Backend
-import System.Console.GetOpt
-
def :: [Command]
def = [noCommit $ command "recvkey" paramKey seek
SectionPlumbing "runs rsync in server mode to receive content"]
)
where
go tmp = do
- (opts,_,_) <- getOpt Permute rsyncSafeOptions <$>
- maybe [] words <$> getField "RsyncOptions"
+ opts <- filterRsyncSafeOptions . maybe [] words
+ <$> getField "RsyncOptions"
ifM (liftIO $ rsyncServerReceive (map Param opts) tmp)
( ifM (isJust <$> Fields.getField Fields.direct)
( directcheck tmp
import qualified Fields
import Utility.Metered
-import System.Console.GetOpt
-
def :: [Command]
def = [noCommit $ command "sendkey" paramKey seek
SectionPlumbing "runs rsync in server mode to send content"]
start :: Key -> CommandStart
start key = do
- (opts,_,_) <- getOpt Permute rsyncSafeOptions <$>
- maybe [] words <$> getField "RsyncOptions"
+ opts <- filterRsyncSafeOptions . maybe [] words
+ <$> getField "RsyncOptions"
ifM (inAnnex key)
( fieldTransfer Upload key $ \_p ->
sendAnnex key rollback $ liftIO . rsyncServerSend (map Param opts)
import Data.Char
import System.Console.GetOpt
+import Data.Tuple.Utils
{- Generates parameters to make rsync use a specified command as its remote
- shell. -}
(_, []) -> Nothing
(b, _) -> readish b
-{- Rsync options that are safe to pass to rsync in server mode, without
- - causing it to eg, expose files.
- -
- - Note: Ensure that when calling getopt, the first component of the
- - output is a subset of the input.
- -}
-rsyncSafeOptions :: [OptDescr String]
-rsyncSafeOptions = [ Option [] ["bwlimit"] (reqArgLong "bwlimit") "" ]
+{- Filters options to those that are safe to pass to rsync in server mode,
+ - without causing it to eg, expose files. -}
+filterRsyncSafeOptions :: [String] -> [String]
+filterRsyncSafeOptions = fst3 . getOpt Permute
+ [ Option [] ["bwlimit"] (reqArgLong "bwlimit") "" ]
where
reqArgLong x = ReqArg (\v -> "--" ++ x ++ "=" ++ v) ""