Posts Tagged ‘telnet’

Running a DOS-based BBS through Linux and Telnet

Since social networking has gotten OUT OF FREAKING CONTROL, a certain nostalgia has dwelled deep within me to reconnect to my roots of BBSing.

Some sites like BBS Corner claim that BBSes are even stronger now than they were in the past, in due, part to the internet and not having to dial long distance, and because most of us are broadband and can get speedier connections to telnet boards or it’s much more feasible to operate multinode setups on newer hardware.

What I will discuss, is a very simplistic way to get your BBS online (in a headless fashion) without an over-engineered solution such as VmodemD or using predefined DosBox instances.  If you have a router, you’ll have to learn how to port forward on your own.  This is outside the scope of this blog.  Although there is nothing WRONG with using VmodemD or the online example of how to get a multinode Renegade BBS setup over telnet in linux I find them to be over-engineered solutions.  I have tested this with Renegade BBS and Oblivion/2 BBS, but I suspect it will work with just about any DOS (non win32 dos) BBS software.

There’s one caveat: perhaps it’s just SyncTerm‘s implementation of Z-modem or Y-modem-g (SEXYZ), but I still haven’t gotten a reliable file transfer to work right, yet.  But who really cares?  Zmodem is basically a way of transferring files without TCP/IP’s error-correction state, which tends to mimic TCP/IP (which you don’t need since you’re using TCP/IP, right? This will just slow things down) and Y-modem-g, well, I still haven’t really find a free solution for that.  Bah, I digress, here’s how it goes (online door games will work this method, too, such as LORD, and Pimpwars, etc…) nothing:

I’ll assume you’re using Ubuntu linux, but it doesn’t really matter.  Grab yourself a copy of dosemu 1.4.0 and install it (install the latest “freedos”, as well).  Make sure you can run dosemu before you proceed any further.  Also, I will not be covering howto do that, since you could just RTFM for dosemu.

I have been informed that directly copying and pasting this stuff may not work, mainly in the way double quotes are translated during the copy and paste process, or how wordpress decides to render them.

1) I find it easy to have two copies of dosemu’s config: 1 for local use (installing things, configuring, maintenance, etc), and a mirror of this same one, with 1 minor detail changed – scroll down all the way to Serial Port Settings and change this line:
$_com1 = "virtual"

Save and exit.  This file will be used for the BBS/telnet script you will write in the next few steps.
2) load up dosemu with your first config file:

dosemu -n -f /etc/dosemu/dosemu.conf-vanilla (or something similar)

Install your environment as your normally would, like pkzip/pkunzip, fossil driver (bnu/X00 – I prefer BNU), share.exe, exitemu, etc…

VERY IMPORTANT – Make sure the last line of your autoexec.bat is: unix -e

config.sys should be similar to this:

rem config.sys for DOSEMU + FreeDOS
rem note that the initial "D:" is set to "Z:" at the end
SWITCHES=/F
DOS=UMB,HIGH
dosdata=umb
lastdrive=Z
files=40
stacks=0
buffers=10
devicehigh=c:\dosemu\ems.sys
shellhigh=c:\command.com /e:1024 /p

At this point, you should be able to type “exitemu” and it should exit your dosemu instance.  If it does not, you did not properly install freedos or the other required dosemu utilities.  This is a required utility.
3) Now you need to make a batch file to load your BBS with:
example C:\BBS.BAT

@echo off
break off
break=off
c:
cd\WHEREVER_YOU_PUT_SHARE.EXE
SHARE.EXE
cd\WHEREVER_YOU_PUT_BNU.COM
bnu.com /L0:57600,8N1 /F
SET DSZLOG=C:\OBV2\DSZLOG.%1
cd\OBV2
obv.exe -b 57600 -A -N %1
exitemu

Save that file and exit.  You will have to configure your BBS software for each node to use COM1 before attempting anything further.  Yes, I know it sounds ludicrous, but it works, trust me.
4) Install telnetd/in.telnetd with xinetd
5) Make sure your /etc/services line with port 23 tcp / telnet is uncommented
6) Make your /etc/xinetd.d/telnet match this:


# default: off
# description: An xinetd internal service which echo's characters back to
# clients.
# This is the tcp version.
service telnet
{
disable= no
port= 23
socket_type= stream
protocol= tcp
user= some valid user to run as
wait= no
server= /usr/sbin/in.telnetd
server_args= -n -h -L /usr/sbin/bbs
}

7)  Now, create /usr/sbin/bbs similarly to this:


#!/bin/bash
export HOME=/home/some valid user to run as/
unset DISPLAY
total=10
current_sessions=`ps aux | grep in.telnetd | grep bbs | grep -v grep | wc -l`
if [ $current_sessions -ge $total ]; then
echo "Too many connections, please try again later."
sleep 2
echo "Goodbye."
sleep 1
else
NODE=1
       for i in `seq 1 $total` ; do
                if [ -e "/tmp/bbsnode$i" ] ;
                then
                        DUMMY=1
                else
                        let NODE=$i
                        touch /tmp/bbsnode$i
                        break
                fi
        done
echo "Loading MYBBS [node $NODE/$total]..."
sleep 2
/usr/local/bin/dosemu.bin -n -f /etc/dosemu/dosemu.conf-BBS -E "C:\BBS.bat $NODE"
echo "Goodbye."
        rm -rf /tmp/bbsnode$NODE
sleep 1
fi

8) Give that script execute permissions: sudo chmod +x /usr/sbin/bbs
9) Restart xinetd: sudo /etc/init.d/xinetd restart
10) Try it out, take it for a test spin: telnet localhost
Debugging:
You might want to make sure you can run the BBS in LOCAL mode with your vanilla dosemu conf file first if it’s not working.
Feel free to leave comments or suggestions.
If you’ve spotted the obvious denial of service attack that can be done on this computer (with determining how many active nodes there are), I’m more than welcome to hear any ideas on how to fix it, but so far it seems to work pretty well!
Ciao!