Doors in dosemu2 under Docker, tested with a real FOSSIL door

doors/dosemu2 builds dosemu2, fdpp and comcom64 from source on Ubuntu (no
PPA) and runs a door with the caller's line on COM1 behind dosemu2's
FOSSIL: rundoor bridges the container's stdio to the port with socat,
the door's directory on F: and the node's drop files on G:.  It runs as
the BBS's user (not root, which dosemu2 refuses), with no network, and
goes when the door ends or the caller hangs up.  {uid}/{gid} fill in the
BBS's own ids for docker run --user; make doors-image builds it.

testdoor/FOSDOOR.COM, a FOSSIL door in assembly, reads DOOR.SYS, writes
CP437 and ANSI and echoes keys; TestDosemuDoor plays it through the BBS
when the image is built, hangs up in it and checks the container is gone.
README, sample config and service notes (the docker group's risk).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01AFQhReUqUc7F5srk2hViqr
This commit is contained in:
Claude committed 2026-10-10 21:31:51 +00:00
1 parent bb65fc1fc5
commit 41c3eb0758
9 files changed
+209 -26

No files matched your search

+5 -1
View File
@@ -19,7 +19,11 @@ install: bbs
install -D -m 0640 bbs.conf.sample $(DESTDIR)/etc/bbs/bbs.conf; \
fi
# the dosemu2 image DOS doors run in (Docker; it builds dosemu2 from source)
doors-image:
docker build -t bbs-dosemu2 doors/dosemu2
clean:
rm -f bbs
.PHONY: all bbs test install clean
.PHONY: all bbs test install clean doors-image
+77 -1
View File
@@ -58,6 +58,8 @@ What there is:
newsreaders and exchanged with other news servers (INN and the like)
- FidoNet (or any FTN network): message areas that are echoes, netmail
as private mail, and a binkp mailer to exchange packets with links
- doors: DOS door games in dosemu2 (in Docker), with a FOSSIL on COM1
and the usual drop files, or any Linux program, for text callers
- new users sign themselves up (or not: `new_users = no`)
- SQLite storage, one file
@@ -378,6 +380,70 @@ graphics (see PCOMM's *3270 Emulator User's Reference*, "Host Graphics"). The f
[3270 Data Stream Programmer's Reference, GA23-0059-07](https://bitsavers.org/pdf/ibm/3174/GA23-0059-07_3270_Data_Stream_Programmers_Reference_199206.pdf)
and Greg Price's [3270 Graphics](https://www.prycroft6.com.au/misc/3270grfx.html).
## Doors
Text callers (telnet, modem, rlogin) open doors with *D* on the main menu.
A door is a program the BBS hands the caller's line to: it writes the drop
files doors read (DOOR.SYS, DORINFO1.DEF, DOOR32.SYS and CHAIN.TXT, in the
node's own directory), runs the door, and joins the two until the door
ends, the caller hangs up (the door is stopped), the door's time limit
runs out, or the caller types nothing for the idle time. A door's output
in CP437 is shown as UTF-8 to UTF-8 terminals, and what they type goes
back as CP437; a CP437 terminal (SyncTERM, NetRunner, a modem caller) gets
the bytes as they are. 3270 callers do not see doors: doors are ANSI.
**DOS doors** run in dosemu2, in Docker. `doors/dosemu2` builds the image:
dosemu2 with its fdpp kernel and comcom64 shell, built from source on
Ubuntu (no PPA needed):
```
make doors-image ; docker build -t bbs-dosemu2 doors/dosemu2
```
In the container the door's drive is F: (`/doors`, mount your doors there)
and the node's drop files are on G: (`/node`); the caller is on COM1 behind
dosemu2's own FOSSIL driver, which is what DOS doors talk to. The image's
`rundoor DOSDIR COMMAND` loads the FOSSIL, goes to the door's directory and
runs it; what the door shows on its own screen (not COM1) and dosemu2's
messages go to `dosemu.out` in the node's directory, and the command's
own errors (Docker's) to `door.log` there.
```
[door lord]
description = Legend of the Red Dragon
command = docker run --rm -i --network none --name bbs-door{node} --user {uid}:{gid} -v /srv/doors:/doors -v {dir}:/node bbs-dosemu2 'F:\LORD' 'START.BAT {node}'
dir = /var/lib/bbs/doors/node{node}
time_limit = 60
cleanup = docker rm -f bbs-door{node}
```
`{node}`, `{dir}` (the node's directory), `{uid}` and `{gid}` (the BBS's
own: the door writes the node's files as the BBS), `{userid}`,
`{minutes}`, `{rows}`, `{cols}` and `{baud}` are filled in. Most doors are
told where the drop file is on their command line or in their own
configuration: here that is `G:\DOOR.SYS` (or `G:\DORINFO1.DEF`, ...).
Each node has its own directory, so multi-node doors work; `single = yes`
lets one caller at a time into a door that is not. dosemu2 runs the door
under its CPU emulator unless the host offers `/dev/kvm` to the container
(`--device /dev/kvm`, untried here); a door starts in about a second
under the emulator.
**Linux doors**: any program that talks to a terminal on its standard
input and output, with `pty = yes` for one that wants a terminal (most
do), and `charset = utf-8` for one that writes UTF-8. DOOR32.SYS says
`door32_comm = local` to them.
The BBS runs `docker` itself, so its user must be allowed to: the
`docker` group (which is as good as root: think twice), or rootless Docker
or Podman (`command = podman run ...`). The door's container has no
network (`--network none`), runs as the BBS's user, not root, and is
removed when the door ends or the caller hangs up.
It was tried with a FOSSIL door of its own (`doors/dosemu2/testdoor`,
which reads DOOR.SYS, writes CP437 and ANSI and echoes keys) through the
whole BBS: the caller types, the door answers, the caller hangs up in it
and the container goes.
## Newsgroups and NNTP
A message area becomes a newsgroup when it is given a newsgroup name. Its
@@ -580,6 +646,10 @@ modem.
safe base name; files, sessions, packets, bundles and messages have size
limits. Netmail's sender is what the message says, as anywhere in
FidoNet: it is not proof of who wrote it.
- Doors: a DOS door runs in a container with no network, as the BBS's
user, seeing only the doors' directory and its node's; the caller's
line is joined to it only through COM1. Hanging up, the time limit and
the idle time stop it. The drop files carry no password.
- The log has logins, failures, posts and mail sent (never passwords or
message text).
@@ -599,6 +669,8 @@ modem.
| `internal/nntp` | the NNTP server and the peers' client |
| `internal/ftn` | FidoNet's formats: addresses, Type 2+ packets, messages, kludges, character sets |
| `internal/fido` | the BBS on FidoNet: tosser, scanner, netmail, the binkp mailer |
| `internal/door` | doors: drop files, running a door on the caller's line |
| `doors/dosemu2` | the Docker image DOS doors run in: dosemu2, its FOSSIL on COM1 |
| `internal/xfer` | XMODEM, YMODEM, ZMODEM and Kermit, both ways |
| `internal/logo` | the logo: a PNG, or the name in a pixel font |
| `internal/bbs` | the BBS itself: nodes, logins, new users, posting, cleaning text |
@@ -636,4 +708,8 @@ nodes exchanging echomail by binkp (SEEN-BY, PATH, threads, forwarding),
netmail and replies, wrong passwords, unknown addresses and impostors,
dupes, loops, bad and foreign packets, the echo-newsgroup gateway, and,
when binkd and CrashMail are installed, a hub run by them: echomail and
netmail both ways, calling it and called by it.
netmail both ways, calling it and called by it. Doors: the drop files,
the runner (CP437 and UTF-8, time limit, hanging up, idle, single-caller
doors, a pseudo-terminal), a caller opening a door from the menu, and,
when the bbs-dosemu2 image is built, a real DOS door talking by FOSSIL in
it.
+6 -4
View File
@@ -233,12 +233,14 @@ address = 127.0.0.1:2513
; the node's own directory and joins the caller's line to the door until it
; ends, the caller hangs up, or the time is up. One section each
;
; A DOS door, in dosemu2 in Docker (doors/dosemu2: docker build -t
; bbs-dosemu2 doors/dosemu2). D: is /srv/doors, E: the node's drop files,
; and the caller is on COM1 behind a FOSSIL
;
; A DOS door, in dosemu2 in Docker (make doors-image). F: is /srv/doors,
; G: the node's drop files; the caller is on COM1 behind a FOSSIL. The BBS
; must run as a user in the docker group, not root: --user {uid}:{gid}
; runs the door as that user, so that it can write the node's directory
;[door lord]
;description = Legend of the Red Dragon
;command = docker run --rm -i --name bbs-door{node} -v /srv/doors:/doors -v {dir}:/node bbs-dosemu2 'D:\LORD' 'START.BAT {node}'
;command = docker run --rm -i --network none --name bbs-door{node} --user {uid}:{gid} -v /srv/doors:/doors -v {dir}:/node bbs-dosemu2 'F:\LORD' 'START.BAT {node}'
; the node's directory ({node} its number): mounted as /node above
;dir = /var/lib/bbs/doors/node{node}
;drop_files = door.sys dorinfo1.def door32.sys chain.txt
+3
View File
@@ -8,6 +8,9 @@ User=bbs
Group=bbs
# for [listen menu]'s socket_group = asterisk
SupplementaryGroups=asterisk
# for DOS doors in Docker (README, "Doors"): the docker group is as good as
# root, so think twice; rootless Docker or Podman is the safer way
#SupplementaryGroups=asterisk docker
RuntimeDirectory=bbs
RuntimeDirectoryMode=0750
StateDirectory=bbs
+19 -12
View File
@@ -1,14 +1,17 @@
# DOS doors for the BBS: dosemu2 (with the fdpp kernel and the comcom64
# shell), built from source as dosemu2's own Dockerfile.debian does (on Ubuntu, which has every
# build dependency), so
# that no PPA is needed. The BBS runs a door as
# shell), built from source as dosemu2's own Dockerfile.debian does (on
# Ubuntu, which has every build dependency), so that no PPA is needed.
#
# docker run --rm -i -v DOORS:/doors -v NODEDIR:/node bbs-dosemu2 \
# rundoor 'CD \LORD' 'LORD.EXE /N{node}'
# docker build -t bbs-dosemu2 doors/dosemu2 (or: make doors-image)
#
# and the caller's line is the door's COM1 (a FOSSIL is loaded).
# The BBS runs a door as
#
# docker build -t bbs-dosemu2 doors/dosemu2
# docker run --rm -i --network none --user UID:GID \
# -v /srv/doors:/doors -v NODEDIR:/node bbs-dosemu2 'F:\LORD' 'LORD.EXE'
#
# with the caller's line on the door's COM1, behind dosemu2's FOSSIL: see
# rundoor. The pieces are built at their newest; pin them with the *_REF
# build arguments (a tag or a commit each).
ARG BASE=ubuntu:26.04
@@ -50,12 +53,16 @@ ARG DEBIAN_FRONTEND=noninteractive
COPY --from=builder /debs /debs
RUN apt-get update && \
apt-get install -y --no-install-recommends socat \
$(ls /debs/*.deb | grep -v -e '-dev_' -e '/thunk-gen' -e '/dj64_' -e '/dj32_' -e '/djstub_') && \
/debs/dosemu2_*.deb /debs/comcom64_*.deb /debs/comcom32_*.deb /debs/dj64_*.deb \
/debs/libdjdev64-0_*.deb /debs/libdjstub64-0_*.deb /debs/libfdldr*.deb /debs/libfdpp*.deb && \
rm -rf /debs /var/lib/apt/lists/*
RUN useradd -m -u 1000 door && mkdir -p /doors /node && chown door /node
# any user but root (dosemu2 will not run a port's program as root): the
# BBS's own, with --user, so that the drop files are its; dosemu2's own
# files go in a home under /tmp
RUN useradd -m door && mkdir -p /doors /node
COPY rundoor /usr/local/bin/rundoor
COPY dosemurc /home/door/.dosemurc
RUN chmod 755 /usr/local/bin/rundoor && chown door /home/door/.dosemurc
COPY dosemurc /etc/dosemu-door.conf
RUN chmod 755 /usr/local/bin/rundoor && chmod 644 /etc/dosemu-door.conf
USER door
WORKDIR /home/door
WORKDIR /tmp
ENTRYPOINT ["/usr/local/bin/rundoor"]
+1
View File
@@ -5,3 +5,4 @@ $_cpu_vm_dpmi = "auto"
$_sound = (off)
$_mouse_internal = (off)
$_hogthreshold = (1)
$_layout = "us"
+24 -7
View File
@@ -3,23 +3,35 @@
# line (this program's standard input and output) on COM1, behind
# dosemu2's FOSSIL.
#
# D: is /doors, the doors (mount them there: -v /srv/doors:/doors)
# E: is /node, this node's drop files (-v /var/lib/bbs/doors/node1:/node)
# F: is /doors, the doors (mount them there: -v /srv/doors:/doors)
# G: is /node, this node's drop files (-v /var/lib/bbs/doors/node1:/node)
#
# rundoor 'D:\LORD' 'LORD.EXE /PE:\'
# rundoor 'F:\LORD' 'LORD.EXE /PG:\'
#
# The door's screen (dosemu's console) goes to /node/dosemu.out, not to the
# caller: the caller sees only what the door sends to COM1.
set -eu
case ${1:-} in
[A-Za-z]:*) ;;
*) echo "usage: rundoor DOSDIR COMMAND... (DOSDIR with its drive: F:\\LORD)" >&2
exit 2 ;;
esac
if [ $# -lt 2 ]; then
echo "usage: rundoor DOSDIR COMMAND..." >&2
exit 2
fi
if [ "$(id -u)" = 0 ]; then
# dosemu2 will not attach a COM port's program as root
echo "rundoor: run me as a user (docker run --user), not root" >&2
exit 2
fi
dir=$1
shift
cmd=$*
sock=/tmp/com1.sock
export HOME=/tmp/dosemu-home
mkdir -p "$HOME"
rm -f "$sock"
# the batch file the door runs from: the FOSSIL, the door's directory, the door
@@ -27,14 +39,19 @@ printf '@ECHO OFF\r\nFOSSIL\r\n%s\r\nCD %s\r\n%s\r\n' "${dir%%:*}:" "$dir" "$cmd
# COM1's other end: socat, which dosemu2 runs on the port's pty, joins it
# to this socket; the socat here joins the socket to the caller
socat -b 4096 UNIX-LISTEN:"$sock",unlink-early STDIO &
# (the caller's input kept on fd 3: a background job's input is /dev/null)
exec 3<&0
socat -b 4096 UNIX-LISTEN:"$sock",unlink-early STDIO <&3 3<&- 2>/dev/null &
bridge=$!
dos=
trap 'kill $bridge 2>/dev/null; kill $dos 2>/dev/null' TERM INT HUP
dosemu -n -f /home/door/.dosemurc \
-I "serial { com 1 exec 'socat -b 4096 STDIO,raw,echo=0 UNIX-CONNECT:$sock' }" \
-d /doors -d /node -q -E 'E:\DOOR.BAT' </dev/null >/node/dosemu.out 2>&1 &
dosemu -f /etc/dosemu-door.conf \
-I "serial { com 1 exec \"socat -b 4096 STDIO,raw,echo=0 UNIX-CONNECT:$sock\" }" \
-d /doors -d /node -dumb -q -E 'G:\DOOR.BAT' </dev/null 3<&- >/node/dosemu.out 2>&1 &
dos=$!
# the caller gone (the line closed): the door goes too
(while kill -0 $bridge 2>/dev/null; do sleep 1; done; kill $dos 2>/dev/null) &
status=0
wait $dos || status=$?
kill $bridge 2>/dev/null || true
+4 -1
View File
@@ -102,7 +102,8 @@ func Split(s string) ([]string, error) {
// Expand fills in a word: {node} the node number, {dir} the drop files'
// directory, {userid} the user's number, {minutes} the minutes left,
// {rows} and {cols} the screen, {baud} the line's rate.
// {rows} and {cols} the screen, {baud} the line's rate, {uid} and {gid}
// the BBS's own (for docker run --user, so the door writes as the BBS).
func Expand(w string, in *Info, dir string) string {
return strings.NewReplacer(
"{node}", fmt.Sprint(in.Node),
@@ -112,6 +113,8 @@ func Expand(w string, in *Info, dir string) string {
"{rows}", fmt.Sprint(in.Rows),
"{cols}", fmt.Sprint(in.Cols),
"{baud}", fmt.Sprint(in.Baud),
"{uid}", fmt.Sprint(os.Getuid()),
"{gid}", fmt.Sprint(os.Getgid()),
).Replace(w)
}
+70
View File
@@ -0,0 +1,70 @@
package server
import (
"os"
"os/exec"
"path/filepath"
"testing"
"time"
"github.com/Neo-Desktop/bbs-sec/internal/door"
)
// TestDosemuDoor: a caller plays a DOS door (testdoor/FOSDOOR.COM, which
// talks by FOSSIL) in the bbs-dosemu2 image, when Docker has it.
func TestDosemuDoor(t *testing.T) {
if err := exec.Command("docker", "image", "inspect", "bbs-dosemu2").Run(); err != nil {
t.Skip("no bbs-dosemu2 image (docker build -t bbs-dosemu2 doors/dosemu2)")
}
e := start(t, nil, &Listener{Name: "modem", Kind: "raw", Address: "modem.sock", ANSI: "no"})
doors := filepath.Join(e.dir, "dos")
os.MkdirAll(filepath.Join(doors, "TEST"), 0755)
com, err := os.ReadFile("../../doors/dosemu2/testdoor/FOSDOOR.COM")
if err != nil {
t.Fatal(err)
}
os.WriteFile(filepath.Join(doors, "TEST", "FOSDOOR.COM"), com, 0644)
// the node's directory, writable by the door's user (the BBS's own, but
// these tests may run as root, which dosemu2 will not run doors as)
node := filepath.Join(e.dir, "node1")
os.Mkdir(node, 0777)
os.Chmod(node, 0777)
cmd, _ := door.Split(`docker run --rm -i --name bbs-test-door{node} --user 4242:4242 -v ` + doors +
`:/doors -v {dir}:/node bbs-dosemu2 'F:\TEST' 'FOSDOOR.COM G:\DOOR.SYS'`)
e.b.Doors = []*door.Door{{Name: "FOSSIL test", Command: cmd, Dir: filepath.Join(e.dir, "node{node}"),
DropFiles: door.DropFiles, Charset: door.CP437, TimeLimit: time.Minute, CommType: 1,
Cleanup: []string{"docker", "rm", "-f", "bbs-test-door{node}"}}}
d := e.dial("modem.sock")
d.expect("Name (or NEW): ")
d.send("alice\r")
d.expect("Password: ")
d.send("alicepass1\r")
d.expect("Command: ")
d.send("D")
d.expect("Door number (Enter to go back): ")
d.send("1\r")
d.expect("FOSDOOR: the FOSSIL works.")
d.expect("Hello, alice")
d.expect("Type keys, Q to quit.")
d.send("z")
d.expect("You typed z")
d.send("q")
d.expect("Bye!")
d.expect("Back on ")
// in again, and hang up in it: the door's container goes
d.expect("Door number (Enter to go back): ")
d.send("1\r")
d.expect("Type keys, Q to quit.")
d.c.Close()
for i := 0; ; i++ {
out, _ := exec.Command("docker", "ps", "-q", "--filter", "name=bbs-test-door").Output()
if len(out) == 0 {
break
}
if i == 100 {
t.Fatal("the door's container is still running after the caller hung up")
}
time.Sleep(100 * time.Millisecond)
}
}