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.
This commit is contained in:
Joey Hess 2017-02-15 15:08:46 -04:00
parent a0222ea7eb
commit f07af03018
No known key found for this signature in database
GPG key ID: C910D9222512E3C7
14 changed files with 99 additions and 40 deletions

View file

@ -746,7 +746,9 @@ testGitLabUrl glu = case parseGitLabUrl glu of
probeuuid sshdata = do
r <- inRepo $ Git.Construct.fromRemoteLocation (fromJust $ sshRepoUrl sshdata)
getUncachedUUID . either (const r) fst <$>
Remote.Helper.Ssh.onRemote r (Git.Config.fromPipe r, return (Left $ error "configlist failed")) "configlist" [] []
Remote.Helper.Ssh.onRemote NoConsumeStdin r
(Git.Config.fromPipe r, return (Left $ error "configlist failed"))
"configlist" [] []
verifysshworks sshdata = inRepo $ Git.Command.runBool
[ Param "send-pack"
, Param (fromJust $ sshRepoUrl sshdata)