Inheriting environment - sshd server to shell child

Bryan Henderson bryanh at giraffe-data.com
Wed Jan 1 05:47:07 EST 2003


This was mysteriously bounced from the list when I sent it last week,
so here's another try.

The context is that I am suggesting that there be an option to allow
shells spawned by sshd to inherit the environment of the sshd process.
Today, Sshd does this for the special case of Cygwin, but starts the
environment fresh on every other platform.

>All critical variables should be in your /etc/profile or your csh/tcsh
>equiv.

I disagree.  I know that is traditionally where these variables are
set, but it isn't the logical place to do it, which is why I don't
have my system set up that way.  /etc/profile and other shell profiles
are the appropriate place to set variables that pertain to the
(interactive) use of that shell.  But some environment variable
settings apply to any program running anywhere, under any shell or not
involving a shell at all.  Some variables could conceivably be
necessary in order to start up the shell and run its profile.

Going back to when the traditional roles of Init, login programs,
shells, shell profiles, and such were invented, the parameters of
system-wide scope were compiled in to every program installed on the
system.  That's still true of most of them.  But the modern trend is
toward more binary portability, and I follow that.  I prefer, for 
example, not to have any file paths compiled into programs I run.
I use the environment variables they provide to give path information.

So I maintain environment variables.  Init sets them via initscript in
every process it spawns.  A few are even set via kernel boot
parameters and inherited by all of Init's progeny.  Traditional logins
work fine because I use the -p option on Login ("preserve
environment").  Ssh via Openssh defeats the plan, though.  Openssh
would have me set those environment variables one place for every
process _except_ shells spawned by sshd, but in each shell profile for
shells spawned by sshd.

My particular system, of course, is not the issue.  I'll run the sshd
that works for me.  The issue is that there is more logic in retaining
the environment than in discarding it, and I believe the Cygwin
requirement is based in the basic rightness of that, not any
fundamental difference between Cygwin and real Unix.

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



More information about the openssh-unix-dev mailing list