Skip to main content

6. Implementation Rules

WILL and DO are used only at the beginning of the connection to obtain and grant permission for future negotiations.

Once the two hosts have exchanged a WILL and a DO, the sender of the DO NEW-ENVIRON is free to request that environment variables be sent. Only the sender of the DO may send requests (IAC SB NEW-ENVIRON SEND IAC SE) and only the sender of the WILL may transmit actual environment information (via the IAC SB NEW-ENVIRON IS ... IAC SE command). Though this option may be used at any time throughout the life of the telnet connection, the exchange of environment information will usually happen at the startup of the connection. This is because many operating systems only have mechanisms for propagating environment information at process creation, so the information is needed before the user logs in.

The receiving host is not required to put all variables that it receives into the environment. For example, if the client should send across USERVAR "TERM" VALUE "xterm" as an environment variable, and the TERMINAL-TYPE [3] option has already been used to determine the terminal type, the server may safely ignore the TERM variable. Also, some startup information may be used in other ways; for example, the values for "USER", "ACCT" and "PROJ" values might be used to decide which account to log into, and might never be put into the users environment. In general, if the server has already determined the value of an environment variable by some more accurate means, or if it does not understand a variable name, it may ignore the value sent in the NEW-ENVIRON option. The server may also prefer to just put all unknown information into the users environment. This is the suggested method of implementation, because it allows the user the most flexibility.

The following is an example of use of the option:

Host1                            Host2
IAC DO NEW-ENVIRON
IAC WILL NEW-ENVIRON
[ Host1 is now free to request environment information ]
IAC SB NEW-ENVIRON SEND VAR
"USER" VAR "ACCT" VAR USERVAR
IAC SE
[ The server has now explicitly asked for the USER and ACCT
variables, the default set of well known environment variables,
and the default set of user defined variables. Note that the
client includes the USER information twice; once because it was
explicitly asked for, and once because it is part of the
default environment. ]
IAC SB NEW-ENVIRON IS VAR "USER"
VALUE "joe" VAR "ACCT" VALUE
"kernel" VAR "USER" VALUE "joe"
VAR "DISPLAY" VALUE "foo:0.0"
USERVAR "SHELL" VALUE "/bin/csh"
IAC SE

It is legal for a client to respond with an empty environment (no data between the IAC SB and IAC SE) when no well-defined or user variables are currently defined. For example:

IAC SB NEW-ENVIRON IS IAC SE

is a valid response to any of the following:

IAC SB NEW-ENVIRON SEND IAC SE
IAC SB NEW-ENVIRON SEND VAR IAC SE
IAC SB NEW-ENVIRON SEND USERVAR IAC SE
IAC SB NEW-ENVIRON SEND VAR USERVAR IAC SE

(The last example is equivalent to the first...)

The earlier version of this specification [RFC 1408] incorrectly reversed the values for VAR and VALUE, which put the specification at odds with existing implementations. In order to resolve that problem, as well as other minor problems, a new option number has been assigned to the NEW-ENVIRON option. This allows implementations of this memo to interoperate with no ambiguity.

For a discussion on how to implement to interoperate with the various implementations that pre-date this memo, see [RFC 1571].

It is expected that any implementation that supports the Telnet NEW-ENVIRON option will support all of this specification.