diff options
author | Joey Hess <joeyh@joeyh.name> | 2017-02-15 15:08:46 -0400 |
---|---|---|
committer | Joey Hess <joeyh@joeyh.name> | 2017-02-15 15:08:46 -0400 |
commit | 6892102ea2ef394de2a9802aa36dfe19761f37dd (patch) | |
tree | 3e90dcf2faf1db369ffa601bb858cf334364fc28 /Remote/Git.hs | |
parent | ebd15a59b4453e4e99a3a7225f50b897dd83653a (diff) |
Run ssh with -n whenever input is not being piped into it
... to avoid it consuming stdin that it shouldn't.
This fixes git-annex-checkpresentkey --batch remote, which didn't output
results for all keys passed into it.
Other git-annex commands that communicate with a remote over ssh may also
have been consuming stdin that they shouldn't have, which could have
impacted using them in eg, shell scripts. For example, a shell script
reading files from stdin and passing them to git annex drop would be
impacted by this bug, whenever git annex drop ran git-annex-shell
checkpresent, it would consume part/all of the stdin that the shell script
was supposed to consume.
Fixed by adding a ConsumeStdin parameter to Annex.Ssh.sshOptions, which
is used throughout git-annex to run ssh (in order for ssh connection
caching to work). Every call site was checked to see if it used
CreatePipe for stdin, and if not was marked NoConsumeStdin.
Diffstat (limited to 'Remote/Git.hs')
-rw-r--r-- | Remote/Git.hs | 15 |
1 files changed, 10 insertions, 5 deletions
diff --git a/Remote/Git.hs b/Remote/Git.hs index a0b590654..604056fc2 100644 --- a/Remote/Git.hs +++ b/Remote/Git.hs @@ -210,7 +210,9 @@ tryGitConfigRead :: Bool -> Git.Repo -> Annex Git.Repo tryGitConfigRead autoinit r | haveconfig r = return r -- already read | Git.repoIsSsh r = store $ do - v <- Ssh.onRemote r (pipedconfig, return (Left $ giveup "configlist failed")) "configlist" [] configlistfields + v <- Ssh.onRemote NoConsumeStdin r + (pipedconfig, return (Left $ giveup "configlist failed")) + "configlist" [] configlistfields case v of Right r' | haveconfig r' -> return r' @@ -384,7 +386,8 @@ lockKey r key callback ) | Git.repoIsSsh (repo r) = do showLocking r - Just (cmd, params) <- Ssh.git_annex_shell (repo r) "lockcontent" + Just (cmd, params) <- Ssh.git_annex_shell ConsumeStdin + (repo r) "lockcontent" [Param $ key2file key] [] (Just hin, Just hout, Nothing, p) <- liftIO $ withFile devNull WriteMode $ \nullh -> @@ -477,7 +480,8 @@ copyFromRemote' r key file dest meterupdate u <- getUUID let fields = (Fields.remoteUUID, fromUUID u) : maybe [] (\f -> [(Fields.associatedFile, f)]) file - Just (cmd, params) <- Ssh.git_annex_shell (repo r) "transferinfo" + Just (cmd, params) <- Ssh.git_annex_shell ConsumeStdin + (repo r) "transferinfo" [Param $ key2file key] fields v <- liftIO (newEmptySV :: IO (MSampleVar Integer)) pidv <- liftIO $ newEmptyMVar @@ -583,7 +587,7 @@ copyToRemote' r key file meterupdate fsckOnRemote :: Git.Repo -> [CommandParam] -> Annex (IO Bool) fsckOnRemote r params | Git.repoIsUrl r = do - s <- Ssh.git_annex_shell r "fsck" params [] + s <- Ssh.git_annex_shell NoConsumeStdin r "fsck" params [] return $ case s of Nothing -> return False Just (c, ps) -> batchCommand c ps @@ -665,7 +669,8 @@ commitOnCleanup r a = go `after` a Annex.Branch.commit "update" | otherwise = void $ do Just (shellcmd, shellparams) <- - Ssh.git_annex_shell (repo r) "commit" [] [] + Ssh.git_annex_shell NoConsumeStdin + (repo r) "commit" [] [] -- Throw away stderr, since the remote may not -- have a new enough git-annex shell to |