$ uname -a A_BLOG_ABOUT_UNIX_TOOLS_AND_THE_BEAUTY_OF_SIMPLE_SYSTEMS
SYS.YEAR  2026
← Back to articles
2026-10-31ARTICLE

Muug Baron

Running Red Baron on FreeBSD

Diagnose a 1997 Linux browser: an allocator workaround and a kernel repair

Manitoba Unix Users Group · MUUG

An installation and debugging guide for the existing Bastille jail baron.

Verified 2026-10-26: local help and modern HTTPS content rendered in Red Baron. The numbered steps use the allocator workaround. A second option repairs Linuxulator in a test kernel; BARONVM ran the original allocator on 2026-10-28.


What runs in the jail

  • Red Baron runs with its original Linux/i386 libraries on FreeBSD 15.1.
  • A small replacement library supplies its memory-allocation functions.
  • TigerVNC displays the browser on a 24-bit X11 desktop.
  • WRP and native Chromium let it display modern HTTPS pages.

Verified: the local Help Index, HTTPS rendering, form submission, and an image-map click. Sustained browsing has not been tested.


Presentation sequence

  1. Identify Red Baron and the Linux runtime it expects.
  2. Prepare the Linux libraries and X11 desktop: steps 1–8.
  3. Diagnose the failure using syscall traces, a core, and disassembly.
  4. Option 1: replace the allocator and verify local help: steps 9–12.
  5. Option 2: repair Linuxulator in a matching kernel and test it in BARONVM.
  6. Install WRP and Chromium for modern websites: steps 13–18.

The diagnostic slides include the commands and byte offsets. The allocator slides show all five replacement functions; the VNC helper source is in the appendix.


What was Red Baron?

  • Red Hat's branded Spyglass-derived commercial web browser.
  • Shipped as a proprietary binary, without source code, with boxed Red Hat Linux.
  • First included in Red Hat Linux 4.0, October 1996.
  • The version used here: Red Baron 3.10, from Red Hat Linux 4.2, May 1997.
  • A Linux/i386 executable using X11, Motif, and libc5.

Sources: Fedora's Red Hat history, Red Hat's 4.2 announcement.


What Red Baron 3.10 can render

Feature Capability of this build
HTML Text, links, lists, tables, forms, frames, and image maps.
Presentation Older HTML attributes and browser preferences control appearance.
JavaScript No engine or support found in the inspected help and binary; treat as unsupported.
CSS No stylesheet support found; treat as unsupported.

“HTML 3.2-era” describes its capabilities; full standards compliance has not been established.

WRP uses Chromium to render modern pages. It does not add JavaScript or CSS execution to Red Baron itself.


Images, audio, and external helpers

Media Evidence in the installed browser
Images GIF, JPEG, and XBM are documented as built in.
PNG No built-in support found.
AU/SND and AIFF audio Format recognition and sound-player messages are present; playback is unverified.
WAV and MIDI MIME-related strings are present; built-in playback is not established.
Other formats Can be assigned to external helper applications.

Not tested: audio playback, animated GIFs, and image-format edge cases. Recognizing a file type does not prove it can be played.


Red Baron’s relationship to Mosaic and Internet Explorer

When What was happening
1993 NCSA Mosaic made graphical web browsing popular.
1994 Spyglass built its commercial Mosaic implementation; Netscape emerged.
1995 Microsoft's Internet Explorer grew from licensed Spyglass technology.
1996–97 Red Hat shipped its own Spyglass-derived browser: Red Baron.

Red Baron and early Internet Explorer both used browser technology supplied by Spyglass.

Sources: NCSA history, Spyglass project lead Eric Sink, Fedora history.


Why Red Hat stopped shipping Red Baron

  • Fedora's history identifies 4.2 as the last release to ship Red Baron.
  • Fedora describes the browser as “very buggy.”
  • By June 1998, Red Hat 5.1 included the proprietary Netscape browser.

The historical account cites reliability problems. It does not identify this allocator failure as the reason Red Baron was discontinued.

Source: Fedora's Red Hat history.


Linux is the kernel; a distribution is the system

Linux distribution
  applications + desktop + services + command-line tools
  C library + runtime loader
  Linux kernel
  • Many distributions combine Linux with GNU tools and GNU libc (glibc).
  • Other combinations exist: musl libc (MIT), BusyBox, different init systems.
  • “Runs on Linux” does not identify the libraries a binary needs.

References: GNU's system/kernel distinction, musl libc.


The C library is part of a program’s binary interface

Layer What it supplies
C library malloc, strcpy, printf; many syscall wrappers.
Kernel Memory mappings, processes, files, networking, protection.
Base / distribution Libraries, loader, tools, services, administration.
  • FreeBSD develops its kernel, libc, loader, and core tools as one base system.
  • Linux distributions assemble those pieces from multiple projects.
  • libc5, glibc, musl, and FreeBSD libc are not interchangeable binaries.

Context: FreeBSD: what is FreeBSD?.


How Linuxulator runs Linux binaries on FreeBSD

Red Baron + Linux libraries       FreeBSD shell + FreeBSD libraries
             |                                  |
       Linux system calls                FreeBSD system calls
             |                                  |
        Linuxulator ----------------> FreeBSD kernel
  • The CPU executes the i386 instructions directly on this amd64 host.
  • Linuxulator implements the Linux application binary interface (ABI) in FreeBSD.
  • The old Linux libraries remain part of the process.

Source: FreeBSD Handbook: Linux Binary Compatibility.


A system call crosses into the kernel

malloc()                       C library function in userspace
   |
Linux brk request              EAX = 45, argument in EBX
   |
int $0x80                      enter kernel via Linux/i386 ABI
   |
Linuxulator handler            interpret Linux arguments and semantics
   |
FreeBSD VM operations          result translated back to Linux ABI

A compatible syscall implementation must match the arguments, return values, and error behavior expected by Linux programs.

Reference: Linux i386 syscall table.


ELF identifies the loader and required libraries

ELF is the executable and shared-library file format used here.

Executable
  PT_INTERP   -> which runtime loader to start
  DT_NEEDED   -> which shared libraries are required
  symbols + relocations -> which names need addresses filled in

The kernel starts the named loader. The loader maps libraries and connects imported names such as malloc to implementations.

Reference: FreeBSD runtime-linker manual source.


Build-time linking and runtime library loading

Name Job
ld Build-time linker: combines objects and records dependencies.
FreeBSD rtld Native runtime linker: /libexec/ld-elf.so.1.
Red Baron's loader Linux /lib/ld-linux.so.1, named in its ELF interpreter.

Red Baron’s ELF interpreter selects Linux’s loader, which resolves its library dependencies and LD_PRELOAD settings.

Installing FreeBSD's 32-bit runtime does not supply a Linux libc5 runtime.

Reference: FreeBSD rtld manual source.


The jail, paths, and display used in the commands

Piece Verified setup
Jail Bastille VNET jail baron, 192.168.3.31
Userspace FreeBSD 15.1-RELEASE-p4, amd64
Linux runtime Five RPMs under /compat/linux, plus X11 data
Source/cache /root/redbaron-install inside the jail
Desktop/browser account root, home /root, as used by the installed helper
Desktop vnc-session: Xvnc :1, 800×600×24, Fluxbox
Viewer access SSH tunnel to 127.0.0.1:5901 in the jail
Modern rendering Native WRP + Chromium, 127.0.0.1:8080, account wrp

1. Connect to the existing jail

On the workstation:

ssh baron

In baron, as root:

pkg install -y tigervnc-server fluxbox xauth xset xsetroot \
  xwininfo curl font-misc-misc font-adobe-75dpi \
  font-adobe-100dpi font-bh-75dpi

The VNC/desktop packages are already installed here. Adobe bitmap fonts supply Helvetica; the Bigelow Holmes fonts supply Lucida Typewriter, also requested during the WRP demonstration.


2. Copy the RPMs and allocator source

On the workstation, from this project directory:

ssh baron 'install -d /root/redbaron-install /compat/linux'
scp -r redbaron-freebsd-jail/media \
  baron:/root/redbaron-install/
scp redbaron-freebsd-jail/malloc_shim.c \
  baron:/root/redbaron-install/

Five RPMs supply the browser and its Linux libraries. A sixth RPM will supply missing X11 data.


3. Extract the Linux runtime

In baron, as root:

cd /root/redbaron-install
for rpm in redbaron-3.1-1.i386.rpm \
  libc-5.3.12-18.i386.rpm ld.so-1.7.14-4.i386.rpm \
  XFree86-libs-3.2-9.i386.rpm xpm-3.4i-1.i386.rpm; do
    bsdtar -xf "media/$rpm" -C /compat/linux
done
brandelf -t Linux /compat/linux/usr/lib/redbaron/redbaron_3.10

bsdtar extracts RPM payloads. brandelf selects the Linux ABI; it does not translate machine code.


4. Restore library names and the loader cache

ln -sf libc.so.5.3.12 /compat/linux/lib/libc.so.5
ln -sf libm.so.5.0.6 /compat/linux/lib/libm.so.5
ln -sf libdl.so.1.7.14 /compat/linux/lib/libdl.so.1
cat > /compat/linux/etc/ld.so.conf <<'EOF'
/lib
/usr/lib
/usr/X11R6/lib
EOF
/compat/linux/sbin/ldconfig

Use the Linux ldconfig to create links matching each library’s embedded runtime name (SONAME) and rebuild the old loader cache. This includes X11 .so.6 links and libXpm.so.4.


5. Install the original X11 data files

cd /root/redbaron-install
ARCHIVE=https://legacy.redhat.com/pub/redhat/linux/4.2/en/os/i386
fetch -o media/XFree86-3.2-9.i386.rpm \
  "$ARCHIVE/RedHat/RPMS/XFree86-3.2-9.i386.rpm"
bsdtar -xf media/XFree86-3.2-9.i386.rpm -C /compat/linux \
  usr/X11R6/lib/X11

This is a sixth RPM: XFree86, distinct from XFree86-libs extracted in step 3. It supplies XKeysymDB, locale tables, and other X11 data needed for startup.


Check the Linux dependencies

LD_TRACE_LOADED_OBJECTS=1 \
LD_LIBRARY_PATH=/lib:/usr/lib:/usr/X11R6/lib \
  /compat/linux/usr/lib/redbaron/redbaron_3.10

Selected output from baron:

libXt.so.6  => /usr/X11R6/lib/libXt.so.6
libX11.so.6 => /usr/X11R6/lib/libX11.so.6
libc.so.5   => /lib/libc.so.5

All seven dependencies resolved. The next steps prepare the X11 display before reproducing the remaining startup failure.


6. Start the desktop with vnc-session

In baron, as root:

/usr/local/bin/vnc-session start
/usr/local/bin/vnc-session status

The existing helper starts Xvnc :1, 800×600, depth 24, port 5901, and Fluxbox. It also sets the bitmap font path.

start refreshes fonts when the display already exists. To change an existing server's depth, use vnc-session restart; this closes its desktop applications.

Full helper source in the appendix.


7. Verify the display depth and font path

DISPLAY=:1 xwininfo -root | grep -E 'Depth:|Visual Class:'
DISPLAY=:1 xset q

Expect Depth: 24, TrueColor, and a font path containing:

/usr/local/share/fonts/misc
/usr/local/share/fonts/75dpi
/usr/local/share/fonts/100dpi
built-ins

16-bit depth caused the unsupported-visual error. Missing Adobe fonts produced Helvetica FontStruct warnings followed by a segmentation fault.


8. Connect the VNC viewer through SSH

On the workstation:

ssh -N -L 15901:127.0.0.1:5901 baron

In another workstation terminal, for TigerVNC Viewer:

vncviewer 127.0.0.1::15901

Use the existing VNC password. The helper currently uses -localhost no, so it also listens on the jail's network interfaces; the SSH tunnel does not disable that listener.


Enable core dumps before reproducing the crash

On the FreeBSD host, as root—not inside the jail:

sysctl kern.coredump=1

Inside baron, in /bin/sh:

ulimit -c unlimited

Reproduce the crash without the allocator preload. With kern.corefile=%N.core, the dump is named redbaron_3.10.core in the crashing process’s working directory.

After capture, restore the previous host setting: sysctl kern.coredump=0 if core dumping was previously disabled. This setting affects other processes on the host too.


Capture the crash without the allocator replacement

Inside baron, as root, in /bin/sh:

umask 077
CAPTURE_DIR=$(mktemp -d /root/redbaron-install/crash.XXXXXX)
cd "$CAPTURE_DIR"
unset LD_PRELOAD LD_32_PRELOAD
ktrace -di -f redbaron.ktrace env \
  DISPLAY=:1 LANG=C LC_ALL=C REDBARON=/usr/lib/redbaron \
  XKEYSYMDB=/usr/X11R6/lib/X11/XKeysymDB \
  LD_LIBRARY_PATH=/lib:/usr/lib:/usr/X11R6/lib \
  /compat/linux/usr/lib/redbaron/redbaron_3.10 \
  -url file:/usr/lib/redbaron/help/index.htm
kdump -f redbaron.ktrace > redbaron.kdump.txt
ls -lh "$CAPTURE_DIR/redbaron_3.10.core"

The segmentation fault is expected. Each run uses a new directory to preserve previous captures. Restore the host’s previous core-dump setting after capture.


The syscall trace ends with a null-address fault

Fresh selected trace lines, without the allocator preload:

CALL  linux_brk(0x82ee290)
RET   linux_brk 137293824/0x82ef000
PSIG  SIGSEGV SIG_DFL code=SEGV_MAPERR

The returned heap-end address differs from the request, and the process then faults at address zero. A syscall trace does not identify the C function that accessed that address.

Saved excerpt


The core identifies a string copy to address zero

Faulting instruction pointer:  0x2840643f
Inside libc5:                  strcpy
Destination:                   0x00000000
Source:                        "Spyglass"

The browser tried the equivalent of:

strcpy(NULL, "Spyglass");

strcpy copies text into destination memory; here it tries to copy "Spyglass" to NULL, which points to no valid destination, causing the crash.

The following slides recover the instruction and arguments from the core, then trace the null destination back to malloc.


Identify the core format before decoding registers

The recorded example uses the core saved in /root. For a new capture, set CORE to its file in $CAPTURE_DIR and recalculate the offsets from its headers.

Inside baron, in /bin/sh:

CORE=/root/redbaron_3.10.core
LIBC=/compat/linux/lib/libc.so.5.3.12
file "$CORE"
readelf -h "$CORE"
readelf -n "$CORE"

The file is an ELF32, little-endian, Intel 80386 core. A core stores process memory and metadata called notes. Selected output:

Notes at file offset 0x334, length 0xd4c:
Owner   Data size   Description
CORE    0x90        NT_PRSTATUS

NT_PRSTATUS contains the saved registers. Use the Linux/i386 layout written by Linuxulator.


Locate the saved registers in the core note

Read the note header and owner:

od -An -tx1 -j $((0x334)) -N 20 "$CORE"
05 00 00 00 90 00 00 00 01 00 00 00 43 4f 52 45
00 00 00 00

The header is 12 bytes: owner length 5, descriptor length 0x90, type 1. The owner is CORE plus NUL, padded to eight bytes.

Descriptor begins: 0x334 + 12 + 8 = 0x348
Registers begin:   descriptor + 72 bytes = 0x390

The preceding 72 bytes hold signal information, masks, process IDs, and times.


Read EIP, the instruction pointer

Each register is four bytes. Linux/i386 stores them in this order:

ebx ecx edx esi edi ebp eax ds es fs gs orig_eax
 eip cs eflags esp ss

EIP is register 12, counting from zero:

File offset = 0x348 + 72 + 12*4 = 0x3c0
od -An -tx1 -j $((0x3c0)) -N 4 "$CORE"
od -An -tx4 -j $((0x3c0)) -N 4 "$CORE"
3f 64 40 28
2840643f

Little-endian decoding gives EIP = 0x2840643f.


Find the memory segment containing the fault

readelf -l "$CORE"
readelf -l "$LIBC"

Selected LOAD fields, with unrelated columns omitted:

             File offset  Virtual addr  File size  Flags
Core LOAD:   0x3da000     0x28399000    0x93000    R E
libc LOAD:   0x000000     0x00000000    0x92472    R E

EIP lies in that core segment:

0x28399000 <= 0x2840643f < 0x2842c000

A LOAD row has no library name. This core has no NT_FILE pathname note; compare its bytes with the library next.


Match the core’s memory segment to libc5

Compare all 0x92472 file-backed bytes of libc5's first LOAD:

dd if="$CORE" bs=1 skip=$((0x3da000)) \
  count=$((0x92472)) 2>/dev/null | sha256
dd if="$LIBC" bs=1 count=$((0x92472)) \
  2>/dev/null | sha256

Both produce the same SHA256:

91e0f48bab58aa124b6f5a471fc66b47d0fcd53296878f53d3b3b082e8c9e487

The segment matches libc5. Its ELF virtual address is zero, so its load bias, the address added to its ELF addresses, is 0x28399000.

Fault inside libc = 0x2840643f - 0x28399000 = 0x6d43f

The faulting instruction writes a byte in strcpy

readelf -s "$LIBC" | grep ' strcpy$'
objdump -d --start-address=0x6d42c \
  --stop-address=0x6d44a "$LIBC"

The symbol starts at 0x6d42c, so our fault is strcpy+0x13. Selected disassembly:

6d42c: pushl %esi
6d42d: movl  0x8(%esp), %esi    # destination
6d431: movl  0xc(%esp), %edx    # source
...
6d43c: movb  (%edx), %al
6d43e: incl  %edx
6d43f: movb  %al, (%ecx,%edx)   # faulting store

The instruction attempts a one-byte store. The next step uses the saved registers to calculate its destination address.


The saved registers identify address zero

Read ECX, EDX, ESI, and ESP from the same register block:

od -An -tx4 -j $((0x348+72+4)) -N 12 "$CORE"
od -An -tx4 -j $((0x348+72+15*4)) -N 4 "$CORE"
ECX        EDX        ESI
f7d94222   0826bdde   00000000

ESP
ffffb148

At the faulting store:

(ECX + EDX) & 0xffffffff = 0x00000000
ESI, the original destination, is also zero.

ESP is the stack pointer. It locates the return address and arguments saved by the function call.


Recover the destination and source arguments

readelf -l places the stack LOAD at virtual 0xfffdc000, file offset 0x4c1000. Translate saved ESP to a core offset:

file offset = LOAD offset + (address - LOAD virtual address)
od -An -tx4 -j $((0x4c1000+0xffffb148-0xfffdc000)) \
  -N 16 "$CORE"
282affb0 0807037e 00000000 0826bddd
Stack position Meaning Value
ESP Saved caller ESI 0x282affb0
ESP+4 Return address 0x0807037e
ESP+8 Destination 0x00000000
ESP+12 Source 0x0826bddd

Recover the source string from process memory

The source address lies in the executable LOAD at virtual 0x08000000, core file offset 0x2000:

od -An -tc -j $((0x2000+0x0826bddd-0x08000000)) \
  -N 9 "$CORE"
S p y g l a s s \0

The stack gives a null destination and a source pointer. The bytes at that source give "Spyglass", including its NUL terminator.

strcpy(NULL, "Spyglass");

The null destination and source bytes establish this call directly from the captured process state.


Trace the null destination back to malloc

objdump -d --start-address=0x8070310 \
  --stop-address=0x8070381 \
  /compat/linux/usr/lib/redbaron/redbaron_3.10
objdump -d --start-address=0x8141580 \
  --stop-address=0x81415a4 \
  /compat/linux/usr/lib/redbaron/redbaron_3.10

The instructions show:

main:      0x8070360 calls 0x8141580 (SM_Malloc)
           0x8070368 saves returned EAX at 0x82ea26c
           0x8070373 loads it; 0x8070378 pushes it
           0x8070379 calls strcpy@plt
           0x807037e is the return address in our core

SM_Malloc: 0x8141587 calls malloc@plt
           returns that pointer unchanged

How a failed allocation caused the crash

main
  -> SM_Malloc
       -> imported malloc in libc5
       <- NULL
  <- NULL
  -> strcpy(NULL, "Spyglass")
  -> SIGSEGV
  • The executable retained useful function names.
  • SM_Malloc used the PLT, an imported-function trampoline.
  • main used the returned pointer without checking it.

brk returned a different address

Requested logical heap end:  0x082ee290
Returned address:            0x082ef000 (next 4 KiB boundary)
  • The raw Linux brk syscall returns the new logical break on success.
  • Page-based backing does not require a page-rounded logical result.
  • Linuxulator returned a rounded address: a Linux ABI compatibility bug.
  • An independent probe reproduces the mismatch without libc5 or Red Baron.

The next slide shows why libc5 interprets this result as failed heap growth.

ABI reference: Linux brk(2), C library/kernel differences.


Why libc5 reports an allocation failure

The installed libc5's __sbrk requests heap space using raw Linux brk:

18305: int  $0x80           # issue brk, syscall 45
...
18318: cmpl %ecx, %edi      # requested address versus returned address
1831a: jne  0x18328         # mismatch: take the error path
...
1832d: movl $0xc, (%eax)    # errno = ENOMEM
18333: movl $0xffffffff, %eax # return (void *)-1
  • The heap-growth helpers convert that failure to NULL for the allocator.
  • malloc returns NULL; Red Baron passes it to strcpy without checking.
  • Two defects: Linuxulator's incompatible return and Red Baron's unchecked allocation failure.

Disassembly commands, helper details, and the independent probe: Linuxulator brk investigation.


Two ways to repair the startup failure

Option What changes Allocation path
1. Preload workaround Replace five user-level allocation functions. Shim → mmap/munmap → Linuxulator.
2. Kernel repair Correct Linuxulator's logical-break state and ELF lower bound. Original libc5 → brk → corrected Linuxulator.
  • Option 1 works in the existing baron jail with its current host kernel.
  • Option 2 ran without the allocator shim in a separate BARONVM guest.
  • Both retain the original browser and its Linux libraries.

We finish option 1's installation first, then examine the kernel repair.


Option 1: replace library functions with LD_PRELOAD

  • LD_PRELOAD asks the runtime loader to load a chosen library before ordinary dependencies.
  • That library can supply replacement implementations of imported functions.
  • Red Baron’s executable and other libraries remain in use.
  • SunOS 4.0, 1988: LD_PRELOAD was an undocumented feature, present in its binaries and source but absent from its documentation.

We use it to load our allocation functions before libc5’s implementations.

Context: SunOS 4.0 change notes, shared libraries, p. 8, OpenBSD loader history.


How the loader selects our replacement malloc

Ordinary launch:    imported malloc -> libc5 malloc
With our preload:  imported malloc -> shim malloc
Variable tested Red Baron's Linux loader
LD_PRELOAD Loaded the requested library.
LD_32_PRELOAD Did not trigger preloading.
LIB_32_PRELOAD Did not trigger preloading.

This process uses the Linux loader, so the working variable is LD_PRELOAD.


The shim bypasses brk, not Linuxulator

Original allocation path:
Red Baron -> libc5 malloc -> brk -> Linuxulator -> FreeBSD VM
                            <- rounded result
          <- NULL -> unchecked strcpy -> SIGSEGV

With LD_PRELOAD:
Red Baron -> shim malloc -> mmap -> Linuxulator -> FreeBSD VM
          <- usable memory
  • We intercept user-level library functions, not the brk syscall.
  • The shim uses mmap/munmap instead of libc5's heap-growth path.
  • Linuxulator still handles those calls and the application's other Linux syscalls.
  • This is an application workaround; it does not repair Linuxulator's brk.

Replace all five allocation-related functions

The replacement shared library is a shim: it keeps the function interfaces and changes how memory is allocated.

Function Why it belongs in the shim
malloc Obtain memory with mmap, avoiding libc5's brk path.
calloc Check multiplication overflow; allocate zero-filled storage through the shim.
realloc Read the shim's header; allocate, copy, and release compatible storage.
free Read the shim's header and release the mapping with munmap.
strdup Copy strings into memory allocated by the shim.

These functions must use the same allocation layout. They do not all call brk; replacing the family prevents incompatible allocation and release.


The replacement allocator uses mmap instead of brk

Linux mmap, syscall 90
    |
    v
[ 16-byte header ][ requested bytes ... page rounding ... ]
^ mapping base   ^ pointer returned to Red Baron
  • Private anonymous memory, initially zero-filled; 16-byte aligned pointer.
  • Header records mapped length, requested length, and an ownership marker.
  • realloc: allocate → copy → release; free: Linux munmap, syscall 91.
  • Direct Linux syscalls avoid libc5’s brk path; Linuxulator still services them.

malloc: calculate the allocation size

Reserve space for the allocation header and requested data, checking that size calculations cannot overflow.

void *
malloc(size_t size)
{
    struct linux_mmap_args args;
    struct allocation_header *header;
    u32 needed;
    u32 mapping_length;
    long result;
    if (size == 0)
        size = 1;
    if (size > 0xffffffffU - (u32)sizeof(*header) - (PAGE_SIZE - 1U))
        return (void *)0;
    needed = (u32)sizeof(*header) + size;
    mapping_length = (needed + PAGE_SIZE - 1U) & ~(PAGE_SIZE - 1U);

malloc: map memory and return a pointer

Map memory, record the allocation sizes, and return a pointer immediately after the header.

    args.addr = 0;
    args.len = mapping_length;
    args.prot = PROT_READ | PROT_WRITE;
    args.flags = MAP_PRIVATE | MAP_ANONYMOUS;
    args.fd = 0xffffffffU;
    args.offset = 0;
    result = linux_syscall1(LINUX_SYS_MMAP, &args);
    if (syscall_failed(result))
        return (void *)0;
    header = (struct allocation_header *)(unsigned long)result;
    header->magic = HEADER_MAGIC;
    header->mapping_length = mapping_length;
    header->requested_length = size;
    header->reserved = 0;
    return (void *)(header + 1);
}

free: release a matching allocation

free finds the header before the returned pointer and unmaps the complete allocation.

void
free(void *pointer)
{
    struct allocation_header *header;
    if (pointer == (void *)0)
        return;
    header = ((struct allocation_header *)pointer) - 1;
    if (header->magic != HEADER_MAGIC)
        return;
    header->magic = 0;
    (void)linux_syscall2(LINUX_SYS_MUNMAP, header, header->mapping_length);
}

calloc: check the array size, then allocate

calloc allocates count × size bytes and returns zero-filled memory; the multiplication must not overflow.

void *
calloc(size_t count, size_t size)
{
    size_t total;
    if (count != 0 && size > 0xffffffffU / count)
        return (void *)0;
    total = count * size;
    /* Anonymous mappings are zero-filled by the kernel. */
    return malloc(total);
}

realloc: handle NULL, zero size, and allocation headers

realloc reads the shim’s header to find the existing size; NULL and zero-size requests have separate behavior.

void *
realloc(void *pointer, size_t size)
{
    struct allocation_header *header;
    void *replacement;
    size_t copy_length;
    if (pointer == (void *)0)
        return malloc(size);
    if (size == 0) {
        free(pointer);
        return (void *)0;
    }
    header = ((struct allocation_header *)pointer) - 1;
    if (header->magic != HEADER_MAGIC)
        return (void *)0;

realloc: allocate, copy, then release

Copy the smaller of the old and new sizes. If allocation fails, retain the original block and its contents.

    replacement = malloc(size);
    if (replacement == (void *)0)
        return (void *)0;
    copy_length = header->requested_length < size
        ? header->requested_length : size;
    copy_bytes((unsigned char *)replacement,
        (const unsigned char *)pointer, copy_length);
    free(pointer);
    return replacement;
}

strdup: copy strings using the replacement allocator

strdup allocates and returns a copy of a string. Its result must use memory that the replacement free and realloc can handle.

char *
strdup(const char *source)
{
    size_t length;
    char *copy;
    if (source == (const char *)0)
        return (char *)0;
    for (length = 0; source[length] != '\0'; length++)
        ;
    if (length == 0xffffffffU)
        return (char *)0;
    copy = (char *)malloc(length + 1U);
    if (copy != (char *)0)
        copy_bytes((unsigned char *)copy,
            (const unsigned char *)source, length + 1U);
    return copy;
}

9. Build and install the Linux/i386 shim

cd /root/redbaron-install
cc -target i386-unknown-linux-gnu -m32 -O2 -fPIC \
  -ffreestanding -fno-builtin -fno-stack-protector \
  -fno-asynchronous-unwind-tables -c malloc_shim.c
ld -m elf_i386 --hash-style=sysv -shared \
  -soname libredbaron_compat.so \
  -o libredbaron_compat.so malloc_shim.o
brandelf -t Linux libredbaron_compat.so
install -m 0755 libredbaron_compat.so \
  /compat/linux/usr/lib/redbaron/libredbaron_compat.so

Audit with file, readelf -d, and readelf -Ws: ELF32, SysV HASH, five exports, no libc dependency.


10. Install the Red Baron launcher

In baron, as root:

cat > /usr/local/bin/redbaron <<'EOF'
#!/bin/sh
set -eu
export DISPLAY="${DISPLAY:-:1}"
export HOME="${HOME:-/root}"
export XAUTHORITY="${XAUTHORITY:-$HOME/.Xauthority}"
export REDBARON=/usr/lib/redbaron
export LANG=C
export LC_ALL=C
export XKEYSYMDB=/usr/X11R6/lib/X11/XKeysymDB

export LD_LIBRARY_PATH=/lib:/usr/lib:/usr/X11R6/lib
export LD_PRELOAD=/usr/lib/redbaron/libredbaron_compat.so
exec /compat/linux/usr/lib/redbaron/redbaron_3.10 "$@"
EOF
chmod 0755 /usr/local/bin/redbaron

11. Launch Red Baron with the allocator replacement

For an interactive test in the jail:

/usr/local/bin/redbaron -url file:/usr/lib/redbaron/help/index.htm

For a detached demonstration started over SSH:

daemon -f -p /var/run/redbaron.pid \
  -o /root/.vnc/redbaron.log \
  /usr/local/bin/redbaron \
  -url file:/usr/lib/redbaron/help/index.htm

Use -url. A bare address makes this executable print usage and exit. vnc-session starts the desktop; Red Baron is launched separately.


12. Verify the process and the rendered page

In the jail:

/usr/local/bin/vnc-session status
pgrep -fl redbaron
sockstat -4 -l | grep 5901
tail -n 20 /root/.vnc/redbaron.log
DISPLAY=:1 xwininfo -root -tree | grep 'Help Index'

After the font-path correction, the live check found a “Help Index” window, a running browser, and no font warnings in its launch log. Check the page in VNC as well. The earlier screenshot and allocator checks remain in the diagnostic record.


Red Baron displaying its own help

height:480px

Captured from the earlier :2 demo on 2026-10-26; the current guide uses :1.


Option 2: preserve the logical break in the kernel

The patch keeps three values distinct:

Value Meaning
vm_brk Exact byte address returned to the Linux process.
vm_brk_min Lowest permitted address, protecting the executable's memory.
Existing VM accounting Page-rounded mappings and resource-limit checks.

kern_break still performs the mapping work. Linuxulator requests Linux return semantics:

new = (uintptr_t)args->dsend;
(void)kern_break(td, &new, true);
td->td_retval[0] = (register_t)new;

Native FreeBSD callers pass false, retaining their rounded success values and native errors.

Source: consolidated kernel patch.


libc5 uses spare space in the final ELF page

End of executable memory:   0x082ee268  (_end, including BSS)
First libc5 brk request:    0x082ee290  (_end + 40 bytes)
End of mapped page:         0x082ef000
  • The request is above the executable's memory end, inside an existing page.
  • Using the page boundary as the minimum wrongly rejects that request.
  • The ELF loader now records the exact memory end as the Linux lower bound.
  • The initial brk(0) result can remain page aligned; a later request can use the spare bytes below it.

Correcting rounded success returns alone was insufficient: the earlier kernel passed 28 checks while this libc5 startup still failed.


Keep break state consistent with the address space

Operation Patch behavior
New VM space Initialize the saved break and lower bound.
brk(0) or a refused request Return the current exact break; preserve mappings.
Successful resize Update the logical break after the VM operation succeeds.
Shared-VM callers Hold the map lock and capture each call's result before unlocking.
fork Copy the break and lower bound under the same lock as the mappings.
exec Clear old state, then establish the new executable's lower bound.

The repair covers more than one return statement: queries, process creation, program replacement, and concurrent calls must agree.


Apply the current-main repair and regression tests

In the build workspace, use a clean FreeBSD source tree at main revision 61c70dc16a79. Run from this presentation's project directory, outside the baron SSH session:

cd ../linux-brk
BRK_SRC=/path/to/clean-freebsd-src
patch -C -p1 -d "$BRK_SRC" < upstream/0001-linuxulator-logical-brk.patch
patch -C -p1 -d "$BRK_SRC" < upstream/0002-linuxulator-brk-tests.patch
patch -p1 -d "$BRK_SRC" < upstream/0001-linuxulator-logical-brk.patch
patch -p1 -d "$BRK_SRC" < upstream/0002-linuxulator-brk-tests.patch
  • Patch 1 repairs the kernel; patch 2 supplies ATF/Kyua regressions.
  • This is a local review proposal, not a FreeBSD 15.1 release update.
  • It changes vmspace layout and kern_break's interface: rebuild the kernel and its modules together.

Base: 61c70dc16a79efcb9db732d37706cd311f555d9a. Patch workflow and status.


Build and boot a matching BARONVM guest

A jail uses its host kernel. The kernel repair was tested in a separate VM:

# In ../linux-brk, with the patched source and prepared guest inputs:
BRK_SRC=/path/to/patched-freebsd-src
BRK_OBJ=/path/to/matching-objects
SRC="$BRK_SRC" OBJ="$BRK_OBJ" ./baron-test/build-kernel.sh
SRC="$BRK_SRC" OBJ="$BRK_OBJ" ./baron-test/build-image.py
sudo ./baron-test/run-bhyve.sh
  • BARONVM has 512 MiB RAM, two CPUs, Xvnc, and the original Linux runtime.
  • The guest boots its rebuilt kernel and matching Linuxulator modules.
  • Shut down an existing guest before rebuilding its disk; rebuilding resets guest data.

Requires the compiled syscall helper and prepared guest userland: BARONVM setup, helper build instructions.


The patched guest uses the original allocator

The guest launcher clears the preload and runs the executable directly:

export DISPLAY=:1
export HOME=/root
export REDBARON=/compat/linux/usr/lib/redbaron
export LD_LIBRARY_PATH=/lib:/usr/lib:/usr/X11R6/lib
unset LD_PRELOAD
exec "$REDBARON/redbaron_3.10" -url file:/usr/lib/redbaron/help/index.htm

Recorded guest trace, with the allocator shim absent:

linux_brk(0x082ee290) -> 0x082ee290
linux_brk(0x082ef000) -> 0x082ef000
linux_brk(0x082f2000) -> 0x082f2000

The original executable, loader, and libc5 were unchanged. Red Baron displayed Help Index and followed a local help link.


Kernel repair: recorded validation and limits

Check Recorded BARONVM result, 2026-10-28
libc5 first request, with and without a prior query Both legacy modes passed.
General Linux/i386 syscall suite 28/28 passed.
ATF/Kyua in an extended guest 3/3 cases passed, including native FreeBSD behavior.
Original Red Baron without allocator preload Local help rendered; a help link worked.
amd64 BARONVM, GENERIC, and LINT builds Passed.

Upstream acceptance is not established. Other architectures, Linux/amd64 runtime, a full world build, and sustained browser use were not checked.

Evidence and limits: end-to-end investigation, validation record.


Added video playback through a native helper

  • A video link launches native FreeBSD mpv inside Red Baron's document area.
  • The optional redbaron-video launcher uses a separate browser profile.
  • A small additional preload clears Linux loader variables before native helpers start.
  • Verified: a linked MP4 test clip, pause, quit, resize, and cleanup at end of file.
  • This is a MIME helper: HTML5 video, streaming websites, and audio delivery through VNC are not added.

Demo: open http://127.0.0.1:8091/ in the video-enabled browser and click the test clip. Press Space to pause/resume, q to close playback before navigating.

Source, installation, screenshot, and test limits.


Possible stability effects of replacing the allocator

The replacement bypasses the allocation failure observed during startup.

  • Calls resolved to the shim avoid libc5’s heap-growth behavior and bookkeeping.
  • Separate mappings change allocation layout and memory reuse.
  • Unmapping freed blocks may make some stale accesses fail sooner.
  • Those changes can also hide application bugs or produce different crashes.

The startup fix is verified. An overall stability improvement would require comparable browsing workloads.


Why this FreeBSD setup needed fewer launch tools

Piece FreeBSD investigation Modern Linux report
Paths seen by the old program /compat/linux compatibility root Bubblewrap filesystem namespace
Launch Shell → Linux executable Shell → setarch → bwrap → executable
Memory allocation setup Preloaded allocator Allocator + setarch personality flags
Display Xvnc + fonts X socket + auth bind + fonts

The /compat/linux directory supplies the paths expected by the Linux program. This setup launches it without setarch or Bubblewrap.


Requirements confirmed by the working installation

  1. The Linux runtime needs matching libraries and the original X11 data.
  2. The trace and core identify a failed allocation followed by a null-pointer write.
  3. Repair allocation either with the preload workaround or a matching patched kernel; the latter keeps libc5's original allocator.
  4. The browser needs -url, a 24-bit display, bitmap fonts, and locale/key-symbol data.
  5. The local Help Index verifies rendering before an external website is introduced.

With local rendering verified, WRP adds modern website rendering in the same jail.


Arch Linux (Omarchy): runtime and allocation

The Omarchy report describes six groups of problems and fixes:

  1. Missing runtime: extract six original RPMs into a private tree; patch copies to use an available loader and an old-format library cache.
  2. Allocation crashes: replace libc5's allocator with an mmap allocator; make free a no-op to avoid later stale-pointer crashes. Memory leaks remain.
  3. Loader compatibility: use setarch i386 -L, SysV symbol hashes, and compatible stack alignment; pass LD_PRELOAD through env for the 32-bit browser.

Arch Linux (Omarchy): rendering and desktop integration

  1. Fonts and text: decompress and index bitmap fonts, add aliases, and patch the null-font crash; correct the patch's swapped operands so lines have distinct baselines.
  2. DNS: call res_init() after the replacement allocator is available, allowing libc5 to read the resolver configuration.
  3. Desktop controls: supply OSF key names, activate menu shortcuts, set a visible cursor, and fix clipboard conversion failures that terminate the browser under Xwayland.

Remaining issues: bold-italic body text, odd <TT> spacing, and sites requiring a Host: header.

Source: Omarchy Linux presentation.


WRP lets Red Baron display modern websites

Antoni Sawicki / Tenox · tenox7/wrp

  • WRP and native FreeBSD Chromium run inside baron.
  • Chromium fetches HTTPS and executes modern HTML, CSS, and JavaScript.
  • Red Baron receives a GIF image and a clickable image map over local HTTP.
  • Simple HTML mode is another option.

All three components run in the jail. Chromium handles external websites, so the jail still needs network access.


How Red Baron, WRP, and Chromium communicate

Inside the Bastille jail baron:

Red Baron           WRP                Native Chromium
Linux/i386          FreeBSD/amd64       FreeBSD/amd64
    |                  |                     |
    |-- HTTP/forms --->|-- DevTools --------->|
    |                  |                     |-- HTTPS --> Website
    |<-- GIF + map ----|<-- rendered page ----|
    |-- click x,y ---->|-- click in page ---->|

WRP listens only on 127.0.0.1:8080 inside the jail. Red Baron uses that address directly; VNC remains on port 5901.


13. Install native Chromium

Inside baron, as root: Chromium was absent from quarterly but available in the latest ports repository.

install -d /usr/local/etc/pkg/repos
cat > /usr/local/etc/pkg/repos/FreeBSD.conf <<'EOF'
FreeBSD-ports: {
  url: "pkg+https://pkg.FreeBSD.org/FreeBSD:15:amd64/latest"
}
EOF
pkg update
pkg install -y chromium ca_root_nss font-bh-75dpi
/usr/local/bin/chrome --version
vnc-session start

Verified: Chromium 156.0.8078.47. This changes the ports repository for this jail; its base system and the old Linux libraries stay separate.


14. Install the FreeBSD WRP release

install -d /root/redbaron-install/wrp
cd /root/redbaron-install/wrp
fetch -o wrp-amd64-freebsd \
  https://github.com/tenox7/wrp/releases/download/4.10.3/wrp-amd64-freebsd
expected=2d433c5fea4aa29906f68a8d366cb18025e8f1fab74a31a89c5f3d311ca91d7d
test "$(sha256 -q wrp-amd64-freebsd)" = "$expected" && \
  install -m 0755 wrp-amd64-freebsd /usr/local/bin/wrp

The expected SHA256 is the digest published with the 4.10.3 GitHub release asset. Stop if it does not match.

The 4.10.3 release asset contains an upstream version banner of 4.9.3. Use the release URL and checksum to identify the installed binary.


15. Give WRP its own account and log

pw usershow wrp >/dev/null 2>&1 || \
  pw useradd wrp -d /var/db/wrp -m \
  -s /usr/sbin/nologin -c 'Web Rendering Proxy'
install -d -o wrp -g wrp -m 0700 /var/db/wrp
install -o wrp -g wrp -m 0600 /dev/null /var/log/wrp.log

WRP and Chromium run as wrp, with home /var/db/wrp. Chromium runs headless, without a visible desktop window.

The next slide installs a native FreeBSD service to start them together.


16. Install the WRP service

Save this as /usr/local/etc/rc.d/wrp:

#!/bin/sh
# PROVIDE: wrp
# REQUIRE: NETWORKING
# KEYWORD: shutdown

. /etc/rc.subr
name=wrp
rcvar=wrp_enable
load_rc_config "$name"
: ${wrp_enable:=NO}

pidfile=/var/run/wrp.pid
procname=/usr/local/bin/wrp
# Chromium workers can outlive their parent on this FreeBSD build.
stop_postcmd='pkill -U wrp -x chrome || true'
command=/usr/sbin/daemon
command_args="-f -p ${pidfile} -u wrp -o /var/log/wrp.log \
/usr/local/bin/wrp -b /usr/local/bin/chrome \
-l 127.0.0.1:8080 -t gif -g 640x400x216 -ua="

run_rc_command "$1"

17. Enable, start, and check WRP

chmod 0755 /usr/local/etc/rc.d/wrp
sysrc wrp_enable=YES
service wrp start
service wrp status
sockstat -4 -l | grep 8080
curl --retry 5 --retry-connrefused --retry-delay 1 \
  --max-time 30 --fail --silent --show-error \
  -o /dev/null 'http://127.0.0.1:8080/?url=https%3A%2F%2Fexample.com%2F'
tail -n 10 /var/log/wrp.log

Expect wrp listening on 127.0.0.1:8080, a successful HTTPS navigation, and an encoded GIF. The HTTP listener may need a moment after service startup.

Manage it with service wrp stop, start, restart, or status. WRP is enabled for subsequent jail boots.


18. Browse an HTTPS page through WRP

In baron, launch Red Baron on its existing VNC desktop:

/usr/local/bin/redbaron -url http://127.0.0.1:8080/
  1. Enter https://example.com/ in the WRP form and click Go.
  2. Click a link or control in the rendered image; WRP forwards the click coordinates to Chromium.
  3. Use WRP’s Bk (back), Up, and Dn (down) controls to navigate.

A direct starting URL also works:

/usr/local/bin/redbaron \
  -url 'http://127.0.0.1:8080/?url=https%3A%2F%2Fexample.com%2F'

The workstation only needs its VNC viewer and SSH tunnel to port 5901.


Red Baron displaying a modern page through WRP

height:440px

Verified: WRP form submission loaded https://www.freebsd.org/. Clicking the image opened the site’s mobile menu; WRP logged the forwarded coordinates 593,40.


WRP capabilities and testing limits

  • Chromium handles modern websites; Red Baron still handles WRP's old-style HTML and GIF.
  • Simple HTML mode can be useful for articles and documentation.
  • Rendering adds latency, and some sites reject automated browsers.
  • WRP's service is loopback-only, with no persistent login profile configured.

The checks cover local help, two HTTPS pages, form submission, and an image-map click. A sustained browsing workload remains untested.

Reference: WRP modes and usage.


Questions

  • Linuxulator runs Red Baron with its original Linux libraries.
  • Option 1 preloads five allocation functions using mmap/munmap.
  • Option 2 repairs Linuxulator's brk and ELF lower bound, keeping libc5's allocator.
  • WRP and native Chromium supply modern website rendering in the same jail.

Both approaches ran local help. The kernel repair was verified in a separate VM; sustained browser stability remains untested.


Sources: history and the experiments


Sources: binary compatibility, loading, and WRP


Appendix: vnc-session

Source copied from baron:/usr/local/bin/vnc-session, 2026-10-26, without modification. The following slides contain the complete script in order.

  • Defaults: display :1, depth 24, 800×600, port 5901.
  • start: create credentials if needed, start Xvnc, refresh fonts, start Fluxbox.
  • status, stop, restart, xterm: manage the desktop.
  • password: prints a locally stored password; do not run it during screen sharing.

This helper uses root's desktop and listens on network interfaces. Its stop command also stops Fluxbox processes beyond a particular display.


Appendix: VNC display, fonts, and file paths

#!/bin/sh
set -eu

DISPLAY_NUM=${DISPLAY_NUM:-1}
DISPLAY=":$DISPLAY_NUM"
GEOMETRY=${GEOMETRY:-800x600}
DEPTH=${DEPTH:-24}
RFBPORT=${RFBPORT:-5901}
VNC_DIR=${VNC_DIR:-/root/.vnc}
VNC_PASS_FILE=${VNC_PASS_FILE:-$VNC_DIR/passwd}
VNC_PASS_TEXT=${VNC_PASS_TEXT:-$VNC_DIR/vnc-password}
VNC_LOG=${VNC_LOG:-$VNC_DIR/xvnc.log}
VNC_PID=${VNC_PID:-/var/run/xvnc.pid}
FONT_PATH=${FONT_PATH:-/usr/local/share/fonts/misc,/usr/local/share/fonts/75dpi,/usr/local/share/fonts/100dpi,built-ins}


Appendix: command usage and environment settings

usage() {
    cat <<USAGE
usage: vnc-session {start|stop|restart|status|password|xterm}

Environment overrides:
  DISPLAY_NUM=$DISPLAY_NUM
  GEOMETRY=$GEOMETRY
  DEPTH=$DEPTH
  RFBPORT=$RFBPORT
  FONT_PATH=$FONT_PATH
USAGE
}


Appendix: check the display and refresh fonts

is_vnc_up() {
    env DISPLAY="$DISPLAY" xset q >/dev/null 2>&1
}

refresh_session() {
    env DISPLAY="$DISPLAY" xset fp= "$FONT_PATH" >/dev/null 2>&1 || true
    env DISPLAY="$DISPLAY" xset fp rehash >/dev/null 2>&1 || true
    env DISPLAY="$DISPLAY" xsetroot -cursor_name left_ptr >/dev/null 2>&1 || true

    if command -v fluxbox >/dev/null 2>&1 && ! pgrep -x fluxbox >/dev/null 2>&1; then
        env DISPLAY="$DISPLAY" fluxbox >/dev/null 2>&1 &
    fi
}


Appendix: create the VNC authentication files

create_password() {
    install -d -m 700 "$VNC_DIR"
    if [ ! -s "$VNC_PASS_FILE" ]; then
        pw=$(openssl rand -base64 18)
        printf "%s\n" "$pw" | vncpasswd -f > "$VNC_PASS_FILE"
        chmod 600 "$VNC_PASS_FILE"
        printf "%s\n" "$pw" > "$VNC_PASS_TEXT"
        chmod 600 "$VNC_PASS_TEXT"
    fi
}


Appendix: start Xvnc

start_vnc() {
    if is_vnc_up; then
        refresh_session
        echo "Xvnc is already running on $DISPLAY"
        return
    fi

    create_password
    rm -f "/tmp/.X${DISPLAY_NUM}-lock" "/tmp/.X11-unix/X${DISPLAY_NUM}"

    daemon -p "$VNC_PID" -o "$VNC_LOG" \
        /usr/local/bin/Xvnc "$DISPLAY" \
        -geometry "$GEOMETRY" \
        -depth "$DEPTH" \
        -rfbport "$RFBPORT" \
        -SecurityTypes VncAuth \
        -rfbauth "$VNC_PASS_FILE" \
        -AlwaysShared=1 \
        -AcceptSetDesktopSize=0 \
        -localhost no \
        -fp "$FONT_PATH"


Appendix: wait for the X11 display to become ready

    for _ in 1 2 3 4 5 6 7 8 9 10; do
        if is_vnc_up; then
            refresh_session
            echo "Started Xvnc on $DISPLAY port $RFBPORT"
            return
        fi
        sleep 1
    done

    echo "Xvnc did not become ready; see $VNC_LOG" >&2
    exit 1
}


Appendix: stop Xvnc and Fluxbox

stop_vnc() {
    if [ -s "$VNC_PID" ]; then
        pid=$(cat "$VNC_PID")
        kill "$pid" 2>/dev/null || true
        rm -f "$VNC_PID"
    fi
    pkill -f "Xvnc $DISPLAY" 2>/dev/null || true
    pkill fluxbox 2>/dev/null || true
    rm -f "/tmp/.X${DISPLAY_NUM}-lock" "/tmp/.X11-unix/X${DISPLAY_NUM}"
    echo "Stopped Xvnc on $DISPLAY"
}


Appendix: handle start, stop, and restart commands

case "${1:-}" in
    start)
        start_vnc
        ;;
    stop)
        stop_vnc
        ;;
    restart)
        stop_vnc
        start_vnc
        ;;

Appendix: handle status, password, and xterm commands

    status)
        if is_vnc_up; then
            echo "Xvnc is running on $DISPLAY port $RFBPORT"
        else
            echo "Xvnc is not running on $DISPLAY"
            exit 1
        fi
        ;;
    password)
        create_password
        cat "$VNC_PASS_TEXT"
        ;;
    xterm)
        start_vnc
        env DISPLAY="$DISPLAY" xterm >/dev/null 2>&1 &
        ;;
    -h|--help|help|"")
        usage
        ;;
    *)
        echo "unknown command: $1" >&2
        usage >&2
        exit 64
        ;;
esac