Bug 1524 - Problem with non-interactive logins and bash on Solaris
Summary: Problem with non-interactive logins and bash on Solaris
Status: CLOSED WONTFIX
Alias: None
Product: Portable OpenSSH
Classification: Unclassified
Component: sshd (show other bugs)
Version: 5.1p1
Hardware: UltraSPARC Solaris
: P2 normal
Assignee: Assigned to nobody
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2008-09-12 12:23 AEST by Chris O'Regan
Modified: 2011-01-24 12:33 AEDT (History)
3 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Chris O'Regan 2008-09-12 12:23:56 AEST
We just upgraded OpenSSH on our Solaris systems from 4.7p1 to 5.1p1. Now bash no longer executes .bashrc when a user starts a non-interactively ssh session. Note that this is for Solaris 9 and 10.

From the bash man page (under INVOCATION):

"When bash is started non-interactively, to run a shell script, for
example, it looks for the variable BASH_ENV in the environment, expands
its value if it appears there, and uses the expanded value as the name
of a file to read and execute."

If I set BASH_ENV in ~/.ssh/environment (and set PermitUserEnvironment to "yes" in sshd_config) then I can run any file I specify. Setting this option, however, does not sound safe for normal use.

"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, if that file exists and is
readable."

I have tried several versions of bash including the latest (v3.2) and all exhibit the problem with OpenSSH 5.1p1; .bashrc should run but it doesn't. This leads me to believe that OpenSSH is the culprit.

Interactive login sessions work fine; bash runs .bash_profile as per the INVOCATION section. Also works fine with older versions of OpenSSH.
Comment 1 Knut Omang 2008-10-16 05:40:35 AEDT
I experience what seems to be the same problem on Fedora Core 9,

version: openssh-5.1p1-2.fc9
Comment 2 Tomas Mraz 2008-10-16 07:35:01 AEDT
The current openssh server uses pipes instead of sockets to communicate with the shell. bash recognized stdin as socket and called .bashrc in this case. With pipe as stdin the bash runs as any other non-interactive shell and doesn't read .bashrc.
There is also possibility to recompile bash so it recognizes ssh through the environment variable SSH_CLIENT.
Comment 3 Damien Miller 2010-04-24 08:52:45 AEST
The problem here is bash making an unwarranted assumption about the environment it operated in. OpenSSH has always used either pipes or socketpairs depending on the operating system it was running on, so bash's assumption was incorrect for platforms other than Linux anyway.

Apparently there is compile-time flag that one can set for bash that resolves the problem: https://bugzilla.redhat.com/attachment.cgi?id=321287&action=diff (I haven't tried it)
Comment 4 Damien Miller 2011-01-24 12:33:40 AEDT
Move resolved bugs to CLOSED after 5.7 release