Project Home
Project Home
Documents
Documents
Wiki
Wiki
Discussion Forums
Discussions
Project Information
Project Info
Forum Topic - telnet session shall inherit environment of main session: (4 Items)
   
telnet session shall inherit environment of main session  
Hi,

I set some enviroment variables in my boot script, which in the end opens a ksh. The environment variables I set appear 
to be part of the environment of this shell.

When I telnet to this system though, how can I make sure it also has the same environment? It must take its environment 
from somewhere (e.g. 'set' prints out a lot). How to let a telnet session inherit the environment variables of the 
session I have on the serial terminal?

Note I'm on an embedded target so there's no .profile, etc. just inetd/telnetd, terminfo etc.


- Malte
Re: telnet session shall inherit environment of main session  
as initd and telnetd both are using fork()/exec()
I would expect that your shell gets the env you have set before starting intd.
Did you set your env before starting initd/telnetd?
Re: telnet session shall inherit environment of main session  
> Did you set your env before starting initd/telnetd?

Yes I did, but it still does not inherit my environent. However it seems that telnetd is trying to create a certain 
'well defined and secure' environment so it removes everything except a few certain standard environment variables.

The only solution I found is to explicitly create the desired environment using an /etc/profile script.

Re: telnet session shall inherit environment of main session  
Looking into services/telnetd/sys_term.c, it appears that the slave end of telnetd will call a function named 
'scrub_env()' which will erase the environment except for the following variables:
   XAUTH, XAUTHORITY, DISPLAY, TERM, EDITOR, PAGER, LOGNAME, 
   POSIXLY_CORRECT, TERMCAP, PRINTER

So you should be able to inherit (from inetd's environment) e.g. the terminal type (TERM), but not e.g. the home 
directory (HOME).

- Thomas