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 /Command | |
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 'Command')
-rw-r--r-- | Command/Map.hs | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/Command/Map.hs b/Command/Map.hs index b04beb477..eb08037c6 100644 --- a/Command/Map.hs +++ b/Command/Map.hs @@ -16,6 +16,7 @@ import qualified Git.Config import qualified Git.Construct import qualified Remote import qualified Annex +import Annex.Ssh import Annex.UUID import Logs.UUID import Logs.Trust @@ -219,10 +220,11 @@ tryScan r where p = proc pcmd $ toCommand params - configlist = Ssh.onRemote r (pipedconfig, return Nothing) "configlist" [] [] + configlist = Ssh.onRemote NoConsumeStdin r + (pipedconfig, return Nothing) "configlist" [] [] manualconfiglist = do gc <- Annex.getRemoteGitConfig r - sshparams <- Ssh.toRepo r gc [Param sshcmd] + sshparams <- Ssh.toRepo NoConsumeStdin r gc [Param sshcmd] liftIO $ pipedconfig "ssh" sshparams where sshcmd = "sh -c " ++ shellEscape |