scp not tolerant of extraneous shell messages

Bryan Henderson bryanh at giraffe-data.com
Wed Jul 3 10:05:14 EST 2002


>Ummm.  Why do you assume that scp is using a pty?
>It doesn't do that for me

Aha.  The mystery unfolds.  Scp is not in fact using a pty; the shell's
Standard Input is not a terminal, and the shell does not consider itself
to be an interactive shell (per Bash's $- variable).

My indication that it is interactive was the fact that it ran .bashrc,
which is specifically intended to set up an interactive shell session.
I went back to Bash documentation, and found this gem:  "Bash attempts 
to determine when it is being run by the remote shell daemon, usually
Rshd.  If Bash determines it is being run by Rshd, it reads and executes
commands from ~/.bashrc..."  It does not say what black magic Bash uses
to determine it is being run by Rshd, but it seems reasonable to assume
that Ssh/Scp is falling into this trap.  This is a major hack in Bash,
and I think the most reasonable thing is to unhack it by putting logic
in .bashrc to skip the whole thing if the shell is not interactive.

That means Scp and Sftp don't have to worry about ignoring messages
that are intended for interactive users.  I still think it would do
more good than harm for them to do so (after all, if Bash is broken,
it's broken), but I guess I'm not nearly as righteous about it now.

I still have debugging and error message improvements that will make
this sort of thing easier to track down;  I will submit a patch.

-- 
Bryan Henderson                                    Phone 408-621-2000
San Jose, California



More information about the openssh-unix-dev mailing list