2

I need to transport inside TERM variable, additional data, using the syntax:

TERM=xterm:VAR1=data1:var2=data2:...

At the server side these data are splitted up in real variables. But, the telnet server of a Debian is closing the connection where TERM variable has ":" or additional "=".

The Debian is:

# uname -a
Linux server 3.16.0-4-amd64 #1 SMP Debian 3.16.7-ckt20-1+deb8u2 (2016-01-02) x86_64 GNU/Linux

Are there ways to setup the server to not check uncommon characters in the TERM variable ?

EDIT - NOTES:

This is a legacy environment working between SCO and AIX that way. Now we need to add a Linux server which telnet server should accept arbitrary data in TERM variable.

2

This is a deliberate security choice. You can however configure your telnetd server to pass through the TERM variable, though its value will be converted to lowercase. The actual checking for legal TERM values is not done by in.telnetd itself, but by the login program, telnetlogin that the server calls. You can configure your telnetd server to run some other login program instead, for example an intermediate shell script which will unmangle the variable before continuing with the login. Eg to test this, create file /tmp/mytelnetlogin with contents:

#!/bin/bash
export MYTERM=$TERM
export TERM=dumb
exec /usr/lib/telnetlogin "$@"

and do chmod +x on it. Then run your own test version of telnetd on port 9999:

sudo sudo -u telnetd /usr/sbin/in.telnetd -debug 9999 -L /tmp/mytelnetlogin

and connect to it with your variable in the environment:

TERM='A=1:b=2' telnet localhost 9999

You should see a login prompt, and after login an echo $MYTERM will show the value a=1:b=2 which you can then manipulate as you usually do. Obviously, for a real solution you need to put the -L option in /etc/inetd.conf, and not use /tmp for the script.

Note that telnetlogin is a setuid-root program, that is expected to be called from the user id telnetd. This is to allow inetd to run the server as non-root, and only use root for the login.

If you prefer to ignore this security measure, you can run in.telnetd as root and get it to run the standard login, /bin/login. You do not then need the intermediate mytelnetlogin script to manipulate the variable. Eg:

sudo /usr/sbin/in.telnetd -debug 9999 -L /bin/login

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.