git-annex-shell uuid verification
* git-annex now asks git-annex-shell to verify that it's operating in the expected repository. * Note that this git-annex will not interoperate with remotes using older versions of git-annex-shell. The reason for this check is to avoid git-annex getting confused about what remote repository actually contains a value. It's a prerequisite for supporting git insteadOf aliases.
This commit is contained in:
parent
f011033869
commit
5414bbce58
4 changed files with 30 additions and 5 deletions
|
@ -189,6 +189,8 @@ paramGlob :: String
|
||||||
paramGlob = "GLOB"
|
paramGlob = "GLOB"
|
||||||
paramName :: String
|
paramName :: String
|
||||||
paramName = "NAME"
|
paramName = "NAME"
|
||||||
|
paramUUID :: String
|
||||||
|
paramUUID = "UUID"
|
||||||
paramType :: String
|
paramType :: String
|
||||||
paramType = "TYPE"
|
paramType = "TYPE"
|
||||||
paramKeyValue :: String
|
paramKeyValue :: String
|
||||||
|
|
|
@ -13,6 +13,7 @@ import qualified Git
|
||||||
import Utility.SafeCommand
|
import Utility.SafeCommand
|
||||||
import Types
|
import Types
|
||||||
import Config
|
import Config
|
||||||
|
import UUID
|
||||||
|
|
||||||
{- Generates parameters to ssh to a repository's host and run a command.
|
{- Generates parameters to ssh to a repository's host and run a command.
|
||||||
- Caller is responsible for doing any neccessary shellEscaping of the
|
- Caller is responsible for doing any neccessary shellEscaping of the
|
||||||
|
@ -33,15 +34,20 @@ git_annex_shell :: Git.Repo -> String -> [CommandParam] -> Annex (Maybe (FilePat
|
||||||
git_annex_shell r command params
|
git_annex_shell r command params
|
||||||
| not $ Git.repoIsUrl r = return $ Just (shellcmd, shellopts)
|
| not $ Git.repoIsUrl r = return $ Just (shellcmd, shellopts)
|
||||||
| Git.repoIsSsh r = do
|
| Git.repoIsSsh r = do
|
||||||
sshparams <- sshToRepo r [Param sshcmd]
|
uuid <- getUUID r
|
||||||
|
sshparams <- sshToRepo r [Param $ sshcmd uuid ]
|
||||||
return $ Just ("ssh", sshparams)
|
return $ Just ("ssh", sshparams)
|
||||||
| otherwise = return Nothing
|
| otherwise = return Nothing
|
||||||
where
|
where
|
||||||
dir = Git.workTree r
|
dir = Git.workTree r
|
||||||
shellcmd = "git-annex-shell"
|
shellcmd = "git-annex-shell"
|
||||||
shellopts = Param command : File dir : params
|
shellopts = Param command : File dir : params
|
||||||
sshcmd = shellcmd ++ " " ++
|
sshcmd uuid = unwords $
|
||||||
unwords (map shellEscape $ toCommand shellopts)
|
shellcmd : (map shellEscape $ toCommand shellopts) ++
|
||||||
|
uuidcheck uuid
|
||||||
|
uuidcheck uuid
|
||||||
|
| null uuid = []
|
||||||
|
| otherwise = ["--uuid", uuid]
|
||||||
|
|
||||||
{- Uses a supplied function (such as boolSystem) to run a git-annex-shell
|
{- Uses a supplied function (such as boolSystem) to run a git-annex-shell
|
||||||
- command on a remote.
|
- command on a remote.
|
||||||
|
|
5
debian/changelog
vendored
5
debian/changelog
vendored
|
@ -13,6 +13,11 @@ git-annex (3.20110929) UNRELEASED; urgency=low
|
||||||
* Note that older versions of git-annex will display the timestamp as part
|
* Note that older versions of git-annex will display the timestamp as part
|
||||||
of the repository description, which is ugly but otherwise harmless.
|
of the repository description, which is ugly but otherwise harmless.
|
||||||
* Add timestamps to trust.log and remote.log too.
|
* Add timestamps to trust.log and remote.log too.
|
||||||
|
* git-annex-shell: Added the --uuid option.
|
||||||
|
* git-annex now asks git-annex-shell to verify that it's operating in
|
||||||
|
the expected repository.
|
||||||
|
* Note that this git-annex will not interoperate with remotes using
|
||||||
|
older versions of git-annex-shell.
|
||||||
|
|
||||||
-- Joey Hess <joeyh@debian.org> Thu, 29 Sep 2011 18:58:53 -0400
|
-- Joey Hess <joeyh@debian.org> Thu, 29 Sep 2011 18:58:53 -0400
|
||||||
|
|
||||||
|
|
|
@ -6,12 +6,14 @@
|
||||||
-}
|
-}
|
||||||
|
|
||||||
import System.Environment
|
import System.Environment
|
||||||
|
import System.Console.GetOpt
|
||||||
|
|
||||||
import Common.Annex
|
import Common.Annex
|
||||||
import qualified Git
|
import qualified Git
|
||||||
import CmdLine
|
import CmdLine
|
||||||
import Command
|
import Command
|
||||||
import Options
|
import Options
|
||||||
|
import UUID
|
||||||
|
|
||||||
import qualified Command.ConfigList
|
import qualified Command.ConfigList
|
||||||
import qualified Command.InAnnex
|
import qualified Command.InAnnex
|
||||||
|
@ -30,6 +32,16 @@ cmds = map adddirparam $ concat
|
||||||
where
|
where
|
||||||
adddirparam c = c { cmdparams = "DIRECTORY " ++ cmdparams c }
|
adddirparam c = c { cmdparams = "DIRECTORY " ++ cmdparams c }
|
||||||
|
|
||||||
|
options :: [OptDescr (Annex ())]
|
||||||
|
options = uuid : commonOptions
|
||||||
|
where
|
||||||
|
uuid = Option [] ["uuid"] (ReqArg check paramUUID) "repository uuid"
|
||||||
|
check expected = do
|
||||||
|
u <- getUUID =<< gitRepo
|
||||||
|
when (u /= expected) $ error $
|
||||||
|
"expected repository UUID " ++ expected
|
||||||
|
++ " but found UUID " ++ u
|
||||||
|
|
||||||
header :: String
|
header :: String
|
||||||
header = "Usage: git-annex-shell [-c] command [parameters ...] [option ..]"
|
header = "Usage: git-annex-shell [-c] command [parameters ...] [option ..]"
|
||||||
|
|
||||||
|
@ -57,7 +69,7 @@ builtins = map cmdname cmds
|
||||||
builtin :: String -> String -> [String] -> IO ()
|
builtin :: String -> String -> [String] -> IO ()
|
||||||
builtin cmd dir params =
|
builtin cmd dir params =
|
||||||
Git.repoAbsPath dir >>= Git.repoFromAbsPath >>=
|
Git.repoAbsPath dir >>= Git.repoFromAbsPath >>=
|
||||||
dispatch (cmd : filterparams params) cmds commonOptions header
|
dispatch (cmd : filterparams params) cmds options header
|
||||||
|
|
||||||
external :: [String] -> IO ()
|
external :: [String] -> IO ()
|
||||||
external params =
|
external params =
|
||||||
|
@ -72,4 +84,4 @@ filterparams ("--":_) = []
|
||||||
filterparams (a:as) = a:filterparams as
|
filterparams (a:as) = a:filterparams as
|
||||||
|
|
||||||
failure :: IO ()
|
failure :: IO ()
|
||||||
failure = error $ "bad parameters\n\n" ++ usage header cmds commonOptions
|
failure = error $ "bad parameters\n\n" ++ usage header cmds options
|
||||||
|
|
Loading…
Reference in a new issue