darcs

Issue 845 pass through stderr from ssh (because ssh prompts can block)

Title pass through stderr from ssh (because ssh prompts can block)
Priority feature Status resolved
Milestone 2.8.0 Resolved in 2.8.0
Superseder Nosy List dmitry.kurochkin, eivuokko, jaredj, kirby, kowey, thorkilnaur, tommy, uzytkownik, wglozer, zooko
Assigned To
Topics SSH, Windows

Created on 2008-05-14.13:38:11 by zooko, last changed 2012-01-05.23:28:41 by noreply.

Messages
msg4680 (view) Author: zooko Date: 2008-05-14.13:38:09
Folks:

I just ran into a problem where I did a "darcs push user@host" and it  
"hung".  After a few minutes (instead of waiting I went to do other  
stuff), I realized that the underlying ssh connection must be blocked.

I tried it -- "ssh user@host" -- and sure enough the Windows putty  
ssh posted a warning message to stderr and blocked after asking  
"Store key in cache? (y/n)".

I've noticed that this is a frequent problem for new users of  
darcs.  If anyone is having trouble using darcs over ssh, the first  
step is always to tell them to invoke the equivalent ssh command on  
the command-line so that they can see the stderr.

Brian Warner pointed out to me that if darcs simply passed any stderr  
from the call to ssh back to darcs's stderr, then this would happen  
automatically and new users (as well as experienced users like me)  
would be able to diagnose their problems more quickly.

Regards,

Zooko
msg4684 (view) Author: kowey Date: 2008-05-14.13:50:30
I'll submit a patch for this (as I have seen the problem myself)... but I have
the feeling it's a bit more subtle than that, or that my patch will break
something else...
msg4685 (view) Author: kowey Date: 2008-05-14.13:55:31
So, as I mention in my patch, the potential cost of doing this is that we're
going to be dumping a lot of ssh output (scp) to the user's screen.  One thought
is that it doesn't matter as much now with darcs transfer-mode.  Another is that
we could make this something parameterisable (--no-ssh-stderr)
msg4686 (view) Author: zooko Date: 2008-05-14.13:56:35
Yes, that's a good point.  Another thought is that we can ask ssh to be as quiet
as possible by passing "-q" or equivalent flags.
msg4689 (view) Author: kowey Date: 2008-05-14.14:02:06
Heh... I had a feeling we've discussed this before...

Fri Jul  7 03:52:45 BST 2006  Eric Kow <eric.kow@gmail.com>
  * Run ssh/scp/sftp quietly.
  
  This is useful for silencing Putty, and could also be for OpenSSH should
  we decide to stop redirecting to /dev/null.
msg4711 (view) Author: kowey Date: 2008-05-15.12:13:01
Resolved in unstable by my patch... (seems our auto-resolver is broken)

Wed May 14 14:55:04 BST 2008  Eric Kow <E.Y.Kow@brighton.ac.uk>
  * Resolve issue845: Pass ssh's stderr to our stderr.
  
  This may have the side effect that users get *a lot* of scp output dumped
  on their screen, but false 'hanging' that Zooko reported seems like the
  greater evil.  Note that darcs transfer-mode is not affected by this, so
  the only users that would see the extra output are those who are interacting
  with servers that don't have darcs 2 installed.
msg5853 (view) Author: zooko Date: 2008-08-31.21:16:34
This change seems have been reverted by

http://allmydata.org/trac/darcs-2/changeset/6017

Maybe a good compromise would be to filter out certain normal ssh stderr
messages that we don't want to see, but pass through all unrecognized ones?
msg5856 (view) Author: kowey Date: 2008-09-01.09:22:45
So, now if users experience weird hanging over ssh (because putty is asking the
user something) we can at least tell them to try darcs --debug

But I guess Zooko's solution would be ideal (sigh).  

Or we pass along PuTTY's stderr, but not that of any other ssh.

Or PuTTY stops putting its prompts on stderr

Or we stop using PuTTY
msg5870 (view) Author: zooko Date: 2008-09-01.11:47:29
What are the messages that ssh puts on stderr that we don't want to show to the
user?

I just experimented with ssh a bit, both with and without a "known_hosts" entry
for the host, and I didn't get any messages on stderr.
msg5871 (view) Author: kowey Date: 2008-09-01.11:54:42
On Mon, Sep 01, 2008 at 11:47:36 -0000, Zooko wrote:
> What are the messages that ssh puts on stderr that we don't want to show to the
> user?

scp errors fetching a non-existent _darcs/prefs/format (non-essential
file)
msg5872 (view) Author: zooko Date: 2008-09-01.11:56:23
I don't think it is a good strategy to let users experience weird hangs (because
the ssh client is blocked asking the user something), and then hope that the
user will come find the darcs developers and ask them for advice, or will try to
use the darcs "--debug" flag.

I'm hoping that droundy made this change because he wasn't aware that it causes
darcs to mysteriously hang in some situations -- making darcs mysteriously hang
doesn't seem like the kind of thing that he likes to do, even in order to make
the stderr friendlier.

By the way, I don't think that this is limited to putty.  Although there are no
notes on this ticket showing that it has happened with openssh, I seem to
remember that new users frequently have the problem of darcs hanging because
their underlying ssh isn't configured properly.

See related tickets:, issue334, issue219, issue218, issue325, issue1028,
issue29, issue28

See also: http://wiki.darcs.net/DarcsWiki/SSHNotes
msg5880 (view) Author: kowey Date: 2008-09-02.07:35:10
On Mon, Sep 01, 2008 at 11:56:30 -0000, Zooko wrote:
> I don't think it is a good strategy to let users experience weird hangs (because
> the ssh client is blocked asking the user something), and then hope that the
> user will come find the darcs developers and ask them for advice, or will try to
> use the darcs "--debug" flag.

Fair enough.  I think we need to either go back to passing stderr
through or trying to capture the err output and filtering out what we
are familiar with.

> By the way, I don't think that this is limited to putty.  Although
> there are no notes on this ticket showing that it has happened with
> openssh, I seem to remember that new users frequently have the problem
> of darcs hanging because their underlying ssh isn't configured
> properly.

So far I have only seen this particular behaviour with PutTTY.

The OpenSSH hanging was genuine, and was due to a bug in their control
master feature.

Otherwise, OpenSSH has the virtue of writing directly to terminal (I
only say this because I tried ssh example.com 2> foo and still got
output)

> See related tickets:, issue334, issue219, issue218, issue325, issue1028,
> issue29, issue28
> 
> See also: http://wiki.darcs.net/DarcsWiki/SSHNotes

Those notes were for diagnosing the ControlMaster problem.
msg5901 (view) Author: kowey Date: 2008-09-04.11:42:54
On Mon, Sep 01, 2008 at 11:56:30 -0000, Zooko wrote:
> I don't think it is a good strategy to let users experience weird hangs (because
> the ssh client is blocked asking the user something), and then hope that the
> user will come find the darcs developers and ask them for advice, or will try to
> use the darcs "--debug" flag.

Ok, Zooko, I think I know what may be the right way to fix this, and I
think I want you to do it (*)!

In src/Exec.lhs, there is type called Redirect

  data Redirect = AsIs | Null | File FilePath | Stdout
                  deriving Show

I think we could extend it to

  data Redirect = AsIs | Null | File FilePath | Stdout
                | Filter (String -> String) Redirect
                  deriving Show

If you don't know what I'm getting at, ask #darcs for help.

(*) You've been one of our most productive issue submitters so far,
for which thanks.  But I think what would make you even more useful
is to upgrade you into the kind of issue submitter that sends patches
for some N% of his issues! I realise you may not be a Haskeller, but
I think this falls into ProbablyEasy territory.
msg6367 (view) Author: zooko Date: 2008-10-21.13:02:49
(Adding Nosy: droundy)

Folks, I just hit this issue again -- upgraded to darcs-2.1.0 on a Windows
computer, tried to "darcs get" from another computer, and it silently hung. 
Eventually I realized that it was waiting for something, killed it, constructed
an equivalent ssh commandline (which, note, is normally never done from this
windows computer to that server -- it has to be done only in order to debug
darcs and it has to be done using the ssh executable that darcs invokes, which
is not necessarily the one that "ssh" invokes), learned that the host key or IP
address has changed so I have to approve yes/no to continue, and then I could go
back to using darcs.

Until I implement the nice filtering described in this ticket, which will
exclude the specific noisy lines that we don't want but lets through prompts and
unexpected error messages and so forth, could we err on the side of noisiness
instead of on the side of silently hanging?
msg6368 (view) Author: kowey Date: 2008-10-21.13:06:03
As a compromise with Zooko's interim measure, we could usually output ssh
warnings, and suppress them when people do darcs --quiet
msg6369 (view) Author: zooko Date: 2008-10-21.13:38:00
> > What are the messages that ssh puts on stderr that we don't want to show to the
> > user?

> scp errors fetching a non-existent _darcs/prefs/format (non-essential

Does this happen only if the server is running darcs earlier than 2.0?  (I
thought if both server and client were darcs-2, then it would use the
darcs-protocol-over-ssh instead of using scp.)
msg6370 (view) Author: droundy Date: 2008-10-21.14:05:18
Maybe we should make this windows-specific behavior, since ssh prompts
just fine on posix machines?

David
msg6371 (view) Author: zooko Date: 2008-10-21.15:35:21
On Oct 21, 2008, at 8:05 AM, David Roundy wrote:

> Maybe we should make this windows-specific behavior, since ssh prompts
> just fine on posix machines?

I thought that something similar could happen on unix, but I don't  
recall an instance of it actually happening.  I'll ask Brian Warner  
(who originally reported this issue to me, and who almost never uses  
Windows) about it.

It is probably a lot more common Windows, for various reasons,  
including the fact that Windows users are less likely to use ssh  
directly on a frequent basis, and the fact that some common  
installations of darcs on Windows have a separate (putty) ssh for  
darcs than the one that the user actually normal uses (e.g. cygwin ssh).

So, in short, +1 on passing stdout/stderr from ssh through on Windows.

By the way, I'm still not clear on what noisy I-didn't-need-to-see- 
that messages we will actually see, with modern darcs >= 2.0.0 on the  
server...

Regards,

Zooko
msg6372 (view) Author: droundy Date: 2008-10-21.17:03:37
On Tue, Oct 21, 2008 at 09:34:02AM -0600, zooko wrote:
> By the way, I'm still not clear on what noisy
> I-didn't-need-to-see-that messages we will actually see, with modern
> darcs >= 2.0.0 on the server...

I think it's more common to see ugly messages without darcs-2 on the
server, but it was enough to scare users like SPJ...

David
msg7941 (view) Author: zooko Date: 2009-07-09.22:15:14
Here's a user report of how darcs's behavior of hiding all ssh output from the 
user caused a problem for the user:

http://lists.osuosl.org/pipermail/darcs-users/2009-July/020374.html
msg8526 (view) Author: kowey Date: 2009-08-27.01:50:44
We need to fix this.

I proposed a rough strategy in msg5901 based on some kind of fine-grained
filtering where we only pass through stuff we don't already recognise as noise.

If that's not going to be feasible, we should at least the last resort option of
being stderr noisy on Windows so people don't get mysterious hangs.

It'd be a good idea to check the Exec, External and SSH modules to figure out
what's going on right now.
msg10117 (view) Author: kowey Date: 2010-03-04.14:21:31
I think this bit some folks on Haskell Cafe recently.  
http://www.haskell.org/pipermail/haskell-cafe/2010-March/074055.html

Now that we've got this program of picking out nice ProbablyEasy bugs
(for new Darcs hackers) to work on during hacking sprints, I nominate
this one for ZuriHac.
msg14660 (view) Author: JeffFoster Date: 2011-08-14.13:06:55
Removing the probably easy tag.

The problem with filtering the messages is that the only access to the
output of the external program is through a Handle type.  This is
opaque, so it's difficult to filter.

We experimented by using createProcess in conjunction with CreatePipe. 
The basic idea is simple:

  applySomeFilter :: (String -> String) -> IO ()
  applySomeFilter f = do
    (_,Just hout,_,_) <- createProcess (proc "cat" ["/dev/zero"]){
std_out = CreatePipe }
    readWrite hout stdout f
  
  readWrite :: Handle -> Handle -> (String -> String) -> IO ()
  readWrite from to f = do
    x <- hGetContents from
    hPutStr to (f x)

However, it gets very complicated in the general case.  For example,
what if putty/scp goes mad and outputs exceedingly long lines or binary
content?

Perhaps the easiest way forward is to pass through binary content, and
assume that text input is less than N characters per line.  This should
make it possible to filter out particular lines.
msg14939 (view) Author: noreply Date: 2012-01-01.17:01:50
The following patch sent by Eric Kow <kowey@darcs.net> updated issue issue845 with
status=has-patch

* Resolve issue845: pass ssh stderr through. 
Ignore-this: 95fb98b084b3c09a360fa99e61099c25

There does not seem to be any reason to hide it, as we are using
the -q flag in pscp.
msg14964 (view) Author: noreply Date: 2012-01-05.23:28:40
The following patch sent by Eric Kow <kowey@darcs.net> updated issue issue845 with
status=resolved;resolvedin=2.8.0 HEAD

* Resolve issue845: pass ssh stderr through. 
Ignore-this: 95fb98b084b3c09a360fa99e61099c25

There does not seem to be any reason to hide it, as we are using
the -q flag in pscp.
History
Date User Action Args
2008-05-14 13:38:11zookocreate
2008-05-14 13:48:33koweylinkissue846 superseder
2008-05-14 13:50:35koweysetstatus: unread -> unknown
priority: feature
title: pass through stderr from ssh -> pass through stderr from ssh (because ssh prompts can block)
nosy: + wglozer, eivuokko, rgm, kowey, jaredj
messages: + msg4684
topic: + Windows, SSH, FauxBug
assignedto: kowey
2008-05-14 13:52:32koweysetstatus: unknown -> has-patch
nosy: tommy, beschmi, kowey, wglozer, zooko, eivuokko, dagit, rgm, jaredj
2008-05-14 13:55:36koweysetnosy: tommy, beschmi, kowey, wglozer, zooko, eivuokko, dagit, rgm, jaredj
messages: + msg4685
2008-05-14 13:56:43zookosetnosy: tommy, beschmi, kowey, wglozer, zooko, eivuokko, dagit, rgm, jaredj
messages: + msg4686
2008-05-14 14:02:12koweysetnosy: tommy, beschmi, kowey, wglozer, zooko, eivuokko, dagit, rgm, jaredj
messages: + msg4689
2008-05-15 12:13:12koweysetstatus: has-patch -> resolved-in-unstable
nosy: tommy, beschmi, kowey, wglozer, zooko, eivuokko, dagit, rgm, jaredj
messages: + msg4711
2008-05-15 13:48:23rgmsetnosy: - rgm
2008-05-19 15:35:05koweylinkissue866 superseder
2008-08-31 21:16:42zookosetstatus: resolved-in-unstable -> has-patch
nosy: tommy, beschmi, kowey, wglozer, zooko, eivuokko, dagit, jaredj
messages: + msg5853
2008-09-01 09:22:53koweysetnosy: tommy, beschmi, kowey, wglozer, zooko, eivuokko, dagit, jaredj
messages: + msg5856
2008-09-01 11:47:36zookosetnosy: tommy, beschmi, kowey, wglozer, zooko, eivuokko, dagit, jaredj
messages: + msg5870
2008-09-01 11:54:44koweysetnosy: tommy, beschmi, kowey, wglozer, zooko, eivuokko, dagit, jaredj
messages: + msg5871
2008-09-01 11:56:30zookosetnosy: tommy, beschmi, kowey, wglozer, zooko, eivuokko, dagit, jaredj
messages: + msg5872
2008-09-02 07:35:12koweysetnosy: tommy, beschmi, kowey, wglozer, zooko, eivuokko, dagit, jaredj
messages: + msg5880
2008-09-02 07:36:40koweysetstatus: has-patch -> needs-reproduction
nosy: tommy, beschmi, kowey, wglozer, zooko, eivuokko, dagit, jaredj
assignedto: kowey ->
title: pass through stderr from ssh (because ssh prompts can block) -> wish: pass through and filter stderr from ssh (because ssh prompts can block)
2008-09-04 11:42:57koweysetnosy: tommy, beschmi, kowey, wglozer, zooko, eivuokko, dagit, jaredj
messages: + msg5901
title: wish: pass through and filter stderr from ssh (because ssh prompts can block) -> pass through stderr from ssh (because ssh prompts can block)
2008-10-21 13:02:58zookosetnosy: + dmitry.kurochkin, droundy, simon, thorkilnaur
messages: + msg6367
2008-10-21 13:06:10koweysetnosy: droundy, tommy, beschmi, kowey, wglozer, zooko, eivuokko, dagit, simon, thorkilnaur, jaredj, dmitry.kurochkin
messages: + msg6368
2008-10-21 13:38:07zookosetnosy: droundy, tommy, beschmi, kowey, wglozer, zooko, eivuokko, dagit, simon, thorkilnaur, jaredj, dmitry.kurochkin
messages: + msg6369
2008-10-21 14:05:20droundysetnosy: droundy, tommy, beschmi, kowey, wglozer, zooko, eivuokko, dagit, simon, thorkilnaur, jaredj, dmitry.kurochkin
messages: + msg6370
2008-10-21 15:35:24zookosetnosy: droundy, tommy, beschmi, kowey, wglozer, zooko, eivuokko, dagit, simon, thorkilnaur, jaredj, dmitry.kurochkin
messages: + msg6371
2008-10-21 17:03:40droundysetnosy: droundy, tommy, beschmi, kowey, wglozer, zooko, eivuokko, dagit, simon, thorkilnaur, jaredj, dmitry.kurochkin
messages: + msg6372
2009-07-09 22:15:22zookosetnosy: + kirby
messages: + msg7941
2009-07-10 10:33:28droundysetnosy: - droundy
2009-08-06 21:04:29adminsetnosy: - beschmi
2009-08-11 00:13:02adminsetnosy: - dagit
2009-08-25 17:31:38adminsetnosy: + darcs-devel, - simon
2009-08-27 01:50:51koweysetstatus: needs-reproduction -> needs-implementation
nosy: tommy, kowey, wglozer, darcs-devel, zooko, eivuokko, thorkilnaur, jaredj, dmitry.kurochkin, kirby
topic: + Target-2.4, - FauxBug
messages: + msg8526
2009-08-27 14:34:00adminsetnosy: tommy, kowey, wglozer, darcs-devel, zooko, eivuokko, thorkilnaur, jaredj, dmitry.kurochkin, kirby
2009-09-14 10:52:33koweysettopic: + Target-2.5, - Target-2.4
nosy: tommy, kowey, wglozer, darcs-devel, zooko, eivuokko, thorkilnaur, jaredj, dmitry.kurochkin, kirby
2010-03-04 14:21:40koweysettopic: + ProbablyEasy
nosy: + uzytkownik
messages: + msg10117
2010-06-15 20:51:57adminsetmilestone: 2.5.0
2010-06-15 20:59:18adminsettopic: - Target-2.5
2010-07-25 14:34:15tux_rockersetmilestone: 2.5.0 -> 2.8.0
2010-09-09 18:59:42koweysetnosy: - darcs-devel
2011-08-14 13:06:57JeffFostersettopic: - ProbablyEasy
messages: + msg14660
2012-01-01 17:01:50noreplysetstatus: needs-implementation -> has-patch
messages: + msg14939
2012-01-05 23:28:41noreplysetstatus: has-patch -> resolved
messages: + msg14964
resolvedin: 2.8.0