From 6892102ea2ef394de2a9802aa36dfe19761f37dd Mon Sep 17 00:00:00 2001 From: Joey Hess Date: Wed, 15 Feb 2017 15:08:46 -0400 Subject: 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. --- RemoteDaemon/Transport/GCrypt.hs | 3 ++- RemoteDaemon/Transport/Ssh.hs | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) (limited to 'RemoteDaemon') diff --git a/RemoteDaemon/Transport/GCrypt.hs b/RemoteDaemon/Transport/GCrypt.hs index ec71b1842..2ebd16189 100644 --- a/RemoteDaemon/Transport/GCrypt.hs +++ b/RemoteDaemon/Transport/GCrypt.hs @@ -14,12 +14,13 @@ import RemoteDaemon.Transport.Ssh (transportUsingCmd) import Git.GCrypt import Remote.Helper.Ssh import Remote.GCrypt (accessShellConfig) +import Annex.Ssh transport :: Transport transport rr@(RemoteRepo r gc) url h@(TransportHandle (LocalRepo g) _) ichan ochan | accessShellConfig gc = do r' <- encryptedRemote g r - v <- liftAnnex h $ git_annex_shell r' "notifychanges" [] [] + v <- liftAnnex h $ git_annex_shell ConsumeStdin r' "notifychanges" [] [] case v of Nothing -> noop Just (cmd, params) -> diff --git a/RemoteDaemon/Transport/Ssh.hs b/RemoteDaemon/Transport/Ssh.hs index 6f8e8323e..fdb75e871 100644 --- a/RemoteDaemon/Transport/Ssh.hs +++ b/RemoteDaemon/Transport/Ssh.hs @@ -23,7 +23,7 @@ import Control.Concurrent.Async transport :: Transport transport rr@(RemoteRepo r _) url h ichan ochan = do - v <- liftAnnex h $ git_annex_shell r "notifychanges" [] [] + v <- liftAnnex h $ git_annex_shell ConsumeStdin r "notifychanges" [] [] case v of Nothing -> noop Just (cmd, params) -> transportUsingCmd cmd params rr url h ichan ochan -- cgit v1.2.3