Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

I'm looking for a simple way to accept telnet connections without providing a shell interface, kind of like a MUD server. I'm actually looking to serve static content, more like:

telnet towel.blinkenlights.nl

The server will have to launch a new instance of a third-party application (in this case, VLC) for each new telnet connection, and deliver the application's output (ASCII video rendering) directly to the remote user.

Any suggestions for where I can start here?

share|improve this question

3 Answers 3

up vote 1 down vote accepted

The simple-minded solution is to make VLC the users' login shell, as in:

joe:AU03oahyYRjl6:1234:56:Joe Smith:/usr/joe:/usr/bin/cvlc

or whatever program you want to run.  A limitation to this is that you cannot specify command-line arguments.  You probably need to have normal passwd entries:

joe:AU03oahyYRjl6:1234:56:Joe Smith:/usr/joe:/bin/sh

and then give each user a .profile that says

exec /usr/bin/cvlc --(your options) playlist.xspf

or whatever arguments you want.

I'm not sure what you mean by "ASCII video rendering".  Do you want to play audio/video on the user's workstation?  Is the user running an X11 server?  If so, you should put

w=`who am i`
d=`expr "$w" : '.*(\(.*\))'`

into the .profile, and then add

--x11-display "$d":0

to your options. Warning: there are various conditions that can cause this to fail.

share|improve this answer
    
ASCII video rendering probably means aalib –  Alan Curry Aug 20 '12 at 21:27
    
That's correct. I'm experimenting with an aalib-based telnet video player. I'll see if it's possible to adapt your solution to use a shell script wrapper. The other complication is that the telnet server should accept anonymous logins (and no user login). Port 22 uses an IP whitelist, but port 23 will have to be wide open. Thanks for the response. I'll have to look into the security implications further before accepting it, but I appreciate the effort you've put in. I don't have enough rep to vote up just yet. –  Mikkel Aug 20 '12 at 21:35
    
Well, most (it not all) versions of *nix let you configure users with no password. If you created a user of, say, vlc, with no password, and publicized that, would that satisfy your anonymity requirement? –  Scott Aug 20 '12 at 21:45
    
You could add logic to vlc's .profile to validate the source address, but that would provide very little security. –  Scott Aug 20 '12 at 21:52
    
Looks like this functionality is supported in telnetd on Ubuntu, but I'm still investigating. I have, however, managed to get the video to play for an authenticated user test by writing a simple shell script and setting it as login shell: #!/bin/bash \n cvlc -V aa /var/local/vlc/test.mp4 (Using \n in place of newline here because Superuser collapses line breaks in replies.) –  Mikkel Aug 20 '12 at 22:07

http://www.dest-unreach.org/socat/doc/socat.html#EXAMPLE_ADDRESS_EXEC

socat TCP4-LISTEN:5555,fork,tcpwrap=script \
EXEC:/bin/myscript,chroot=/home/sandbox,su-d=sandbox,pty,stderr

a simple server that accepts connections (TCP4-LISTEN) and fork's a new child process for each connection; every child acts as single relay. The client must match the rules for daemon process name "script" in /etc/hosts.allow and /etc/hosts.deny, otherwise it is refused access (see "man 5 hosts_access"). For EXEC'uting the program, the child process chroot's to /home/sandbox, su's to user sandbox, and then starts the program /home/sandbox/bin/myscript. Socat and myscript communicate via a pseudo tty (pty); myscript's stderr is redirected to stdout, so its error messages are transferred via socat to the connected client.

You could change 5555 to 23 (Telnet's default port number)

Change /bin/myscript to your VLC script or binary.


http://www.dest-unreach.org/socat/doc/socat.html#ADDRESS_TYPES

EXEC:<command-line>

Forks a sub process that establishes communication with its parent process and invokes the specified program with execvp() . <command-line> is a simple command with arguments separated by single spaces. If the program name contains a '/', the part after the last '/' is taken as ARGV[0]. If the program name is a relative path, the execvp() semantics for finding the program via $PATH apply. After successful program start, socat writes data to stdin of the process and reads from its stdout using a UNIX domain socket generated by socketpair() per default.


I believe similar solutions are possible using netcat or inetd

share|improve this answer

If this is a linux system, use inetd or xinetd. Create a new service pointing to the standard telnet port and specify your executable as the actual service.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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