openssh-SNAP-20001207 scp "Bad file descriptor" sort-of work-around

James james at amethyst.nurealm.net
Sat Dec 9 01:30:44 EST 2000


Richard wrote

> Under this definition, scp is indeed starting a non-interactive shell: it
> runs ssh in a subprocess, to run scp in server mode as a remote command on
> the other side. SSH does not allocate a pty on the remote side for
> commands (unless forced to with the -t option).  Your shell is run as
> "<shell> -c scp ..." to start the remote scp, and isatty(0) will return
> false.

Ok, this helps.  All I know for sure is that bash-1.14.7(1) is calling
~/.bashrc, since any output from ~/.bashrc is returned to scp.

>From the bash man page, the only shell mode from which bash will call
~/.bashrc is from:

       Non-login interactive shells:
         On startup (subject to the -norc and -rcfile options):
               if ~/.bashrc exists, source it.

>> You say "Your shell initialisation for non-interactive sessions must not
>> produce any output."  Well, it does not, really, none at all, zip.

> How have you tested this?

I have not tested this - I'm making a rash assumption.  I had asked earlier
"What's the easiest way to invoke a for-sure non-interactive session for
testing?", but the distinction is moot until resolving the mode in which
bash is running.

>> And still, scp breaks.  scp is NOT starting a _non-interactive_ shell.

> What definition of "non-interactive shell" are you using?

Only indirectly, the definition quoted above (and previously) which describes
bash's "Non-login interactive shells" and, again indirectly, the definition,
also from the man page, of bash's "Non-interactive shells".

       Non-interactive shells:
         On startup:
               if the environment variable ENV is non-null, expand
               it and source the file it names, as if the command
                       if [ "$ENV" ]; then . $ENV; fi
               had been executed, but do not use PATH to search
               for the pathname.  When not started in Posix mode, bash
               looks for BASH_ENV before ENV.

I'm assuming that a non-interactive shell is a shell that is not an
interactive shell and that the definition of "Non-interactive shells" is
exclusive (meaning "does NOT also source ~/.bashrc"). My ENV is empty or
unset, and I'm assuming scp does not set ENV or BASH_ENV.

If I understand you (and Damien), since the method used to invoke bash is
definitely _not_ "one whose standard input and output are both connected  to
terminals  (as  determined  by isatty(3)), or one started with the -i
option", and thereby, also according bash(1), _not_ a method invoking an
"interactive shell", therefor, either bash-1.14.7(1) is broken or bash(1) is
broken.

Does that seem to be a fair interpretation?

Again, please Cc me, as I'm not subscribed to the list.

Thanks.


James Feeney






More information about the openssh-unix-dev mailing list