Reviving ApplixWare on FreeBSD 15.1
Reviving ApplixWare on FreeBSD 15.1
ApplixWare was a commercial office suite for UNIX, a family of operating systems associated with technical workstations and servers. FreeBSD is a Unix-like operating system in that tradition.
ApplixWare originated from an earlier UNIX office environment called Alis in the 1980s, was renamed Aster*x around 1991, and became ApplixWare in 1993. It was designed primarily for UNIX workstations before being ported to Linux. There was even a release for FreeBSD.
Our starting assumption is that ApplixWare works on FreeBSD 3.5.1. If it fails on FreeBSD 15.1, changes made in the intervening years are a reasonable place to investigate. That loosely guides the investigation: observe a failure, identify the interface involved, then compare what it expected on 3.5.1 with what 15.1 provides. We look for what changed and how it changed, using traces and before/after tests to check each proposed explanation. The assumption gives us a direction; it does not identify the cause of every error in advance.
This investigation follows that 1999 FreeBSD release through startup on FreeBSD 15.1, ending with a visible Words word-processor window. Each failure reveals another compatibility boundary. The goal is to explain what the evidence shows and make the startup experiment repeatable; opening a window does not establish that the whole office suite works.
1. ApplixWare Jail
I already have Bastille configured on a FreeBSD 15.1 amd64 server. The host is that server. A FreeBSD jail, like a Linux container, has its own files and processes but shares the host's kernel. Bastille manages the jail.
This guide starts with a working Bastille installation, configured storage and
networking, and the 15.1-RELEASE base available. Complete the
Bastille getting-started guide
first if those prerequisites are missing. The jail must reach package and
archive servers, and your VNC viewer must be able to reach the jail's address.
Substitute an unused address on your network for 192.168.3.51/24.
Create the jail
Run the commands from a root sh session on the host, in a writable directory
for captured logs and screenshots. Keep that session open for the shell
functions defined later.
Create and start a FreeBSD 15.1 jail named applix151 with bastille:
bastille create applix151 15.1-RELEASE 192.168.3.51/24
bastille start applix151
Throughout the post, jexec applix151 ... means “run this command inside the
jail.” With jexec applix151 sh -c '...', the quoted shell script runs there.
Commands beginning with bastille also run on the host; bastille cmd runs a
command in the named jail.
2. VNC Desktop
Install a minimal set of packages inside the jail:
bastille pkg applix151 install -y \
tigervnc-server xset xauth xsetroot xterm font-misc-misc fluxbox curl
This gives us an ordinary amd64 jail and the packages needed for a small graphical desktop.
ApplixWare is graphical, but the server does not need a physical monitor. TigerVNC provides a virtual X display inside the jail and sends its desktop to a VNC viewer on another computer. X11 is the window system the application uses; Fluxbox supplies window borders and lets us move windows around.
The packages from the previous step provide that desktop. DISPLAY=:1 tells
an X application to use the virtual display we are about to start. The VNC
viewer reaches the same desktop over network port 5901.
Start the VNC server
Run TigerVNC's Xvnc directly with password authentication:
jexec applix151 sh -c '
install -d -m 700 /root/.vnc
pw=$(openssl rand -base64 18)
printf "%s\n" "$pw" | vncpasswd -f > /root/.vnc/passwd
chmod 600 /root/.vnc/passwd
printf "%s\n" "$pw" > /root/.vnc/vnc-password
chmod 600 /root/.vnc/vnc-password
daemon -p /var/run/xvnc.pid -o /root/.vnc/xvnc.log \
/usr/local/bin/Xvnc :1 -rfbport 5901 \
-geometry 800x600 -depth 16 \
-SecurityTypes VncAuth -rfbauth /root/.vnc/passwd \
-AlwaysShared=1 -AcceptSetDesktopSize=0 \
-localhost no \
-fp /usr/local/share/fonts/misc,built-ins
'
The daemon wrapper starts the server in the background, saves its process ID
with -p, and writes its output to the log named by -o.
The options below are described in the TigerVNC Xvnc manual and the X server manual:
| Argument | Purpose |
|---|---|
:1 |
Selects X display 1, used by applications through DISPLAY=:1. |
-rfbport 5901 |
Listens on TCP port 5901 for VNC viewers. |
-geometry 800x600 |
Sets the desktop to 800 by 600 pixels, a compact size for the old Applix dialogs. |
-depth 16 |
Uses 16 bits of color information per pixel. |
-SecurityTypes VncAuth |
Requires VNC password authentication. |
-rfbauth /root/.vnc/passwd |
Reads the password file created by vncpasswd. |
-AlwaysShared=1 |
Allows viewers to share the desktop instead of requesting exclusive access. |
-AcceptSetDesktopSize=0 |
Prevents viewers from resizing the desktop, keeping its geometry stable. |
-localhost no |
Allows viewers on other machines to connect. |
-fp /usr/local/share/fonts/misc,built-ins |
Sets the font path to the installed miscellaneous fonts and the server's built-in fonts. |
VncAuth does not encrypt the desktop connection. Use a trusted network or an
SSH tunnel, and restrict access to port 5901 accordingly.
Initialize the desktop
After Xvnc is ready, set its font path, select the pointer cursor, and start
Fluxbox:
jexec applix151 sh -c '
env DISPLAY=:1 xset fp= /usr/local/share/fonts/misc,built-ins
env DISPLAY=:1 xset fp rehash
env DISPLAY=:1 xsetroot -cursor_name left_ptr
env DISPLAY=:1 fluxbox >/root/.vnc/fluxbox.log 2>&1 &
'
The built-ins entry supplies the server's built-in fonts, including the cursor
font used by xsetroot. Fluxbox provides the window manager for this desktop.
Connect and verify the desktop
jexec applix151 env DISPLAY=:1 xset q
jexec applix151 sockstat -4 -l | grep 5901
xset q proves that the jail can connect to X display :1. sockstat proves
that the VNC server is listening on port 5901. Optionally launch an X
terminal before testing ApplixWare, as the simplest check that the display
accepts clients:
jexec applix151 sh -c 'env DISPLAY=:1 xterm >/dev/null 2>&1 &'
The VNC password is stored in:
jexec applix151 cat /root/.vnc/vnc-password
Connect your VNC viewer to 192.168.3.51:5901 using that password. Seeing
Fluxbox and the test terminal establishes that a modern application can draw
windows here. Leave this desktop running while we investigate Applix.
If startup fails, inspect the server log:
jexec applix151 tail -50 /root/.vnc/xvnc.log
3. Download the CD and try its launcher
With the desktop ready, we can bring in the application. The preserved image
is Applixware_Office_for_FreeBSD_Walnut_Creek_November_1999.iso.
Download the Walnut Creek CD image inside the jail, display its size and SHA-256
checksum, then extract it directly to /applixware1999cdrom. FreeBSD's tar
can read the ISO filesystem directly:
jexec applix151 sh -c '
set -eu
work=/root/applix-investigation
iso=Applixware_Office_for_FreeBSD_Walnut_Creek_November_1999.iso
url=https://archive.org/download/Applixware_Office_for_FreeBSD_Walnut_Creek_November_1999/Applixware_Office_for_FreeBSD_Walnut_Creek_November_1999.iso
mkdir -p "$work" /applixware1999cdrom
cd "$work"
fetch -o "$iso" "$url"
stat -f "%N: %z bytes" "$iso"
sha256 "$iso"
tar -xpf "$iso" -C /applixware1999cdrom
test -x /applixware1999cdrom/applix
'
stat prints the filename and exact size in bytes; sha256 prints its SHA-256
checksum. Record these values with your investigation results. The ISO stays
at /root/applix-investigation inside the jail. The final test verifies that
the extracted launcher exists and is executable.
Recorded values for Applixware_Office_for_FreeBSD_Walnut_Creek_November_1999.iso:
Size: 577765376 bytes
SHA256: e8377eac39069e18653ae8ea296c056fbe1301a52969125313e4ac39413defc7
Compare your download's size and SHA-256 checksum with these values before continuing.
This is an extracted copy of the CD contents, not the final writable ApplixWare installation; we will make a separate runtime tree when we reach application startup.
The first attempt
The jail so far is an ordinary amd64 FreeBSD 15.1 system, so run the original launcher directly and read what actually happens:
jexec applix151 /applixware1999cdrom/applix
# jexec applix151 /applixware1999cdrom/applix
ELF interpreter /usr/libexec/ld-elf.so.1 not found, error 8
Abort trap
ELF is the executable-file format used here. A binary is a program already compiled into machine instructions. A shared library is a separate file providing reusable functions, such as drawing windows or reading user accounts. A function is a named operation that a program can call with input values. A dynamically linked program relies on some of those functions being connected to library code when it starts. The loader brings the executable and its libraries into memory and connects those calls.
Below those libraries is the kernel introduced in Section 1. Libraries request services such as opening files through system calls. Finding all the library files therefore solves only the first startup problem: their requests must also be compatible with the current kernel.
This launcher expects /usr/libexec/ld-elf.so.1, and on this amd64 jail that path is
the 64-bit loader. error 8 is ENOEXEC, "Exec format error": the kernel
opened the file, but the named interpreter cannot start this binary. The shell
also reported the death as a signal. A signal is a notification delivered
to a process by the operating system; some signals terminate it.
Abort trap is signal 6 (SIGABRT),
reported as status 134 (128 + 6).
Check what kind of executable this really is instead of guessing:
jexec applix151 file /applixware1999cdrom/applix
# jexec applix151 file /applixware1999cdrom/applix
/applixware1999cdrom/applix: ELF 32-bit LSB executable, Intel i386, version 1 (SYSV), dynamically linked, interpreter /usr/libexec/ld-elf.so.1, not stripped
Here i386 identifies 32-bit Intel-compatible machine code; amd64 identifies its 64-bit counterpart. These use different instruction and address formats, so a 64-bit loader cannot simply load the 32-bit program.
The binary is 32-bit i386, and its interpreter path points at a 64-bit loader,
so the sizes do not match and the kernel refuses to run it. The ldd tool
lists shared-library dependencies. Here it confirms the
same boundary from userland, because FreeBSD's ldd delegates a 32-bit binary
to the helper /usr/bin/ldd32, which is not installed yet:
jexec applix151 ldd /applixware1999cdrom/applix
# jexec applix151 ldd /applixware1999cdrom/applix
ldd: /usr/bin/ldd32: No such file or directory
FreeBSD can run 32-bit binaries on amd64 only when the 32-bit loader and
libraries are available, so the evidence now justifies installing them. The
FreeBSD-base repository contains packaged base-system components and is
separate from the ordinary ports/packages repository; it is disabled by
default, so enable it first, then install the FreeBSD-set-lib32 package:
bastille cmd applix151 sh -c '
mkdir -p /usr/local/etc/pkg/repos/
echo "FreeBSD-base: { enabled: yes }" > /usr/local/etc/pkg/repos/FreeBSD.conf
pkg install -y FreeBSD-set-lib32
'
Verify the three installed pieces are present:
jexec applix151 ls -l /libexec/ld-elf32.so.1 /usr/bin/ldd32 /usr/lib32/libc.so.7
Their roles are:
/libexec/ld-elf32.so.1: loads 32-bit FreeBSD ELF programs./usr/bin/ldd32: lets the normallddcommand inspect 32-bit executables./usr/lib32/libc.so.7: the modern 32-bit FreeBSD C library.
FreeBSD-set-lib32 supplies the amd64 system's compatibility runtime for
executing 32-bit FreeBSD programs. It does not supply ApplixWare's old
FreeBSD 3.x libraries; those are staged in Section 4.
Run the launcher again with the 32-bit runtime installed:
jexec applix151 /applixware1999cdrom/applix
# jexec applix151 /applixware1999cdrom/applix
ld-elf32.so.1: Shared object "libX11.so.6" not found, required by "applix"
This message is from the 32-bit runtime loader, ld-elf32.so.1, which the
FreeBSD-set-lib32 package installed. It has opened the Applix launcher and
read its shared-library dependency list, but it cannot find libX11.so.6 in
the 32-bit library search path. libX11.so.6 is the X11 client library;
without it, a graphical X application cannot even finish dynamic linking.
ldd on a 32-bit executable now delegates to the helper /usr/bin/ldd32.
To find the missing libX11.so.6, start with the library name reported by the
loader and match it to the operating system Applix was built for. The matching
contract is the ABI, or application binary interface: the function names,
argument formats, and memory layouts that compiled programs expect.
The FreeBSD 3.5.1 i386 package archive contains XFree86 4.0's libX11.so.6.
Using that library keeps X11 on the same FreeBSD 3.x side of the compatibility
boundary as Applix's libc.so.3 and libm.so.2.
4. Follow the missing-library errors
ApplixWare's launcher now runs far enough for the dynamic loader to report the old libraries it cannot find. The commands below obtain them from public FreeBSD release and package sources in the same order the failures force them.
Start with a private library area. /usr/local/lib32/compat holds the old
FreeBSD libraries. /usr/local/lib32/compat/applix is the first directory in
ApplixWare's LD_32_LIBRARY_PATH, the list of directories its 32-bit loader
searches for libraries. We place the matching old libraries there so the loader
finds them before any other copies.
jexec applix151 mkdir -p \
/usr/local/lib32/compat \
/usr/local/lib32/compat/applix \
/usr/local/lib
The first direct-launch failure after adding 32-bit base support is
libX11.so.6, so add the matching FreeBSD 3.5.1 i386 X11 library next. The
archived package is XFree86-libraries-4.0.tgz; although the package contains
the complete XFree86 library kit, only its libX11 shared-library link and
versioned target are needed here.
Download the archived package without installing it into the jail package database:
jexec applix151 sh -c '
set -eu
work=/var/tmp/applix-compat-libs
archive=$work/freebsd351-packages
mkdir -p "$archive"
fetch -o "$archive/XFree86-libraries-4.0.tgz" \
https://archive.freebsd.org/old-releases/i386/3.5.1-RELEASE/packages/All/XFree86-libraries-4.0.tgz
'
The package prefix is /usr/X11R6, so its archive members begin with lib/.
Confirm the two members and extract them directly into the Applix-first compat
directory. --strip-components 1 removes lib/ and retains each filename:
jexec applix151 sh -c '
set -eu
work=/var/tmp/applix-compat-libs
package=$work/freebsd351-packages/XFree86-libraries-4.0.tgz
applix=/usr/local/lib32/compat/applix
mkdir -p "$applix"
tar -tzvf "$package" "lib/libX11.so*"
tar -xzvf "$package" -C "$applix" --strip-components 1 \
"lib/libX11.so*"
'
The readelf -d command reads the library’s dynamic-linking metadata. Inspect
the extracted library:
jexec applix151 readelf -d /usr/local/lib32/compat/applix/libX11.so.6
Its SONAME, the name used to identify the shared library, is libX11.so.6.
It has no DT_NEEDED entries naming further library dependencies. Unlike modern
libX11, this version does not introduce libxcb,
libXau, or libXdmcp into the process. It speaks the stable X11 wire
protocol successfully to the FreeBSD 15.1 jail's Xvnc server.
Register those directories with the 32-bit runtime linker cache. This is the
32-bit form of ldconfig; plain ldconfig only updates the native 64-bit
linker cache on this host:
jexec applix151 ldconfig -32 \
/usr/lib32 \
/usr/local/lib32/compat \
/usr/local/lib32/compat/applix \
/applixware1999cdrom/axdata/axshlib
Verify that the 32-bit linker cache can now see the copied X11 library:
jexec applix151 ldconfig -32 -r | grep 'libX11\.so\.6'
# jexec applix151 ldconfig -32 -r | grep 'libX11\.so\.6'
161:-lX11.6 => /usr/local/lib32/compat/applix/libX11.so.6
ldconfig -32 -r only reads the cache and prints each entry with a
host-specific index; the listing itself does not affect how the launcher runs.
The line to look for ends in the copied library path.
Then try the launcher again with only the X11 library added:
jexec applix151 /applixware1999cdrom/applix
# jexec applix151 /applixware1999cdrom/applix
ld-elf32.so.1: Shared object "libm.so.2" not found, required by "applix"
The failure moves forward. The 32-bit X11 client library is now present, so the loader reaches the older FreeBSD 3.x libraries Applix was linked against.
This is the same kind of dynamic-loader failure as libX11.so.6, but now the
missing library is from old FreeBSD base instead of X11. libm.so.2 is the old
math library ABI Applix was linked against. The modern jail has newer 32-bit
libraries, but not this FreeBSD 3.x SONAME.
To identify the source, use the SONAME: libm.so.2 is too old for modern
FreeBSD pkgbase, and Applix is already known to be a FreeBSD 3.x-era binary.
The matching place to look is the final FreeBSD 3.x i386 release archive:
https://archive.freebsd.org/old-releases/i386/3.5.1-RELEASE/bin/
Inside that split bin distribution, the file is
usr/lib/libm.so.2.
ldd shows the remaining direct old-library failures:
jexec applix151 sh -c '
env LD_32_LIBRARY_PATH=/usr/local/lib32/compat/applix:/usr/local/lib32/compat:/applixware1999cdrom/axdata/axshlib \
ldd /applixware1999cdrom/applix
'
libm.so.2 => not found
libc.so.3 => not found
libc.so.3 is the old FreeBSD 3.x C library ABI. Once ldd reports both
libm.so.2 and libc.so.3 as not found, the next fix is no longer about X11;
it is about staging the old FreeBSD 3.x runtime libraries that Applix was built
to use.
libc.so.3 is the central C runtime library Applix was built to use. It supplies
basic operations: requesting kernel services, reading and writing files,
reserving memory, looking up accounts, and reading environment variables
(settings passed to a program when it starts). Stdio, short for standard
input/output, is its family of buffered file-reading and file-writing functions.
The matching source is the same FreeBSD 3.5.1 i386 bin distribution as libm.so.2, where it lives as
usr/lib/libc.so.3. A FreeBSD 4.11 compat3x archive also contains
libc.so.3, but the FreeBSD 3.5.1 bin archive is preferred here because it
also supplies the matching ELF libm.so.2 needed by the same Applix binary.
Now fetch the archived FreeBSD 3.5.1 i386 base distribution rather than a newer compatibility package:
https://archive.freebsd.org/old-releases/i386/3.5.1-RELEASE/bin/
FreeBSD 3.5.1 was the final FreeBSD 3.x release, so it is a good source for the
latest FreeBSD 3 userland ABI libraries. The release archive is split into
bin.?? chunks. For this release the real chunk range is bin.aa through
bin.dz, plus bin.ea through bin.eg. Download the checksum file and those
chunks with curl:
jexec applix151 sh -c '
set -eu
pkg install -y curl;
work=/var/tmp/applix-compat-libs
src=https://archive.freebsd.org/old-releases/i386/3.5.1-RELEASE/bin
mkdir -p "$work/freebsd351-bin"
cd "$work/freebsd351-bin"
curl -fL --retry 3 -O "$src/CHECKSUM.MD5"
curl -fL --retry 3 -O "$src/bin.[a-d][a-z]"
curl -fL --retry 3 -O "$src/bin.e[a-g]"
'
Verify the chunks before extracting anything; do not concatenate or extract the archive until all chunk checksums match:
jexec applix151 sh -c '
set -eu
work=/var/tmp/applix-compat-libs
cd "$work/freebsd351-bin"
awk '\''/^MD5 \(bin\.[a-z][a-z]\)/ {
gsub(/[()]/, "", $2)
print $2, $4
count++
}
END { if (!count) exit 1 }'\'' CHECKSUM.MD5 > chunk-checksums
while read -r file expected; do
actual=$(md5 -q "$file")
[ "$actual" = "$expected" ] || {
echo "checksum mismatch for $file: $actual != $expected" >&2
exit 1
}
done < chunk-checksums
'
No output and a zero exit status mean every downloaded chunk matched.
CHECKSUM.MD5 also lists bin.inf and bin.mtree, which are not part of the
bin.?? chunk set fetched above, so the filter matches only two-letter chunk
names. The parser must succeed and find at least one chunk before verification
starts. The loop reads a file rather than a pipeline, so a failed checksum, or a
listed chunk that is missing on disk, makes the whole command fail.
Confirm that the old FreeBSD 3.x C and math libraries needed by the top-level
applix launcher are inside the archive:
jexec applix151 sh -c '
set -eu
work=/var/tmp/applix-compat-libs
cd "$work/freebsd351-bin"
cat bin.* | tar -tzf - \
"usr/lib/lib[mc].so*"
'
Extract only those launcher libraries directly into the Applix-first compat
directory. These archive paths do not have a leading /, so
--strip-components 2 removes usr/lib and leaves the library filenames:
jexec applix151 sh -c '
set -eu
work=/var/tmp/applix-compat-libs
applix=/usr/local/lib32/compat/applix
mkdir -p "$applix"
cd "$work/freebsd351-bin"
cat bin.* | tar -xzvf - -C "$applix" --strip-components 2 \
"usr/lib/lib[mc].so*"
'
Refresh the cache again and verify all direct launcher dependencies:
jexec applix151 ldconfig -32 \
/usr/lib32 \
/usr/local/lib32/compat \
/usr/local/lib32/compat/applix \
/applixware1999cdrom/axdata/axshlib
jexec applix151 sh -c '
env LD_32_LIBRARY_PATH=/usr/local/lib32/compat/applix:/usr/local/lib32/compat:/applixware1999cdrom/axdata/axshlib \
ldd /applixware1999cdrom/applix
'
Expected key lines:
libX11.so.6 => /usr/local/lib32/compat/applix/libX11.so.6
libm.so.2 => /usr/local/lib32/compat/applix/libm.so.2
libc.so.3 => /usr/local/lib32/compat/applix/libc.so.3
Run Applix again with the 32-bit library path:
jexec applix151 sh -c '
env LD_32_LIBRARY_PATH=/usr/local/lib32/compat/applix:/usr/local/lib32/compat:/applixware1999cdrom/axdata/axshlib \
/applixware1999cdrom/applix
rc=$?
printf "return code=%s, signal=%s\n" "$rc" "$((rc >= 128 ? rc - 128 : 0))"
'
The loader is now satisfied, so the next failure is inside runtime startup:
Bad system call
return code=140, signal=12
We have moved past missing library files. The next question is which system call caused the process to stop.
On FreeBSD, Bad system call corresponds to SIGSYS:
jexec applix151 awk '$3 == 12' /usr/include/sys/signal.h
# jexec applix151 awk '$3 == 12' /usr/include/sys/signal.h
#define SIGSYS 12 /* non-existent system call invoked */
Shells commonly encode signal termination as 128 + signal, so status 140 is
128 + 12. The truss tool records calls from the process into the kernel.
Trace the same launch without a preload and save the complete trace:
jexec applix151 sh -c '
env LD_32_LIBRARY_PATH=/usr/local/lib32/compat/applix:/usr/local/lib32/compat:/applixware1999cdrom/axdata/axshlib \
truss -f -o /tmp/applix-no-shim.truss /applixware1999cdrom/applix
grep -E "sigaction|SIGSYS|process killed" /tmp/applix-no-shim.truss
'
Recorded excerpt from /tmp/applix-no-shim.truss:
compat.freebsd32_sigaction() ERR#78 'Function not implemented'
SIGNAL 12 (SIGSYS) code=SI_KERNEL
process killed, signal = 12
ERR#78 is ENOSYS: FreeBSD 3.x libc attempted its old i386 sigaction
system-call interface, which FreeBSD 15.1 no longer implements in that form.
The kernel then delivered SIGSYS. This is the first runtime boundary the
shim must translate.
5. Investigate the runtime failures
The old libraries get the process loaded, but they do not make old libc behavior
correct on a FreeBSD 15.1 kernel and jail. We use a preload shim:
it is a small shared library named in LD_32_PRELOAD, so the dynamic loader
loads it before the old libc.so.3. That lets the shim intercept only the few
functions that need help while leaving the real libc.so.3 in place. In this
guide, "broken" means "the FreeBSD 3.x libc assumption is no longer true on
FreeBSD 15.1", not that libc.so.3 was wrong for its original system.
The ABI introduced in Section 3 also governs the order and size of values in memory and how a function receives its arguments. Finding a library with the right filename gets us through loading; its calls must also make sense to the current system.
FreeBSD 15.1's C library is named libc.so.7. Below, “libc3” means the old
libc.so.3 we extracted, and “libc7” means the modern 32-bit C library installed
with the base compatibility runtime. We will use modern implementations where
needed and translate the old arguments before passing them along.
How a preload shim interposes
The practical idea is to supply a replacement function with the same name, translate its inputs, and call the modern implementation. The application keeps making its original call; the shim changes which implementation receives it.
A symbol is a name recorded in a binary for a function or a data object. An undefined symbol is a reference whose implementation must come from another loaded object. A library exports a symbol when it makes that implementation available to other objects. A shared object is a shared library; both terms occur in loader messages.
The executable's ELF dynamic section records required libraries as
DT_NEEDED entries. At startup, the runtime loader:
- maps the executable into memory;
- loads its required shared objects;
- connects undefined dynamic symbols, such as
sigaction, to definitions in the loaded objects; and - adjusts stored addresses, called relocations, so calls reach those definitions.
Normally, the loader searches the executable and its ordinary dependencies in
its standard global symbol order. LD_PRELOAD asks it to load an additional
shared object before those ordinary dependencies. A definition in the
preloaded object can therefore be selected before a definition with the same
name in libc. This behavior is called symbol interposition.
Without a preload, the lookup for sigaction resolves to old libc3, which then
reaches the obsolete kernel interface:
Applix reference to sigaction
|
v
FreeBSD 3.5.1 libc.so.3: sigaction
|
v
obsolete kernel interface -> ENOSYS -> SIGSYS
With the shim preloaded, the first matching dynamic definition changes:
Applix reference to sigaction
|
v
preloaded libc3-shim-02.so: sigaction <- selected first
|
v
translate the old structure
|
v
modern 32-bit libc.so.7: sigaction
Preloading affects dynamically resolved symbols only. It does not rewrite the executable, replace direct system calls, or automatically make incompatible data structures compatible; the shim must export the expected name and perform the required ABI translation itself.
Why LD_32_PRELOAD and not LD_PRELOAD? FreeBSD amd64 distinguishes native
and 32-bit loader variables:
LD_PRELOAD native 64-bit processes
LD_32_PRELOAD 32-bit processes
ApplixWare is a 32-bit i386 executable, so plain LD_PRELOAD is the wrong
variable. LD_32_PRELOAD names one or more 32-bit shared objects that
ld-elf32.so.1 must load before the executable's normal dependencies. It does
not remove libc.so.3 (only the selected symbol is interposed), and it does not
add library search directories — LD_32_LIBRARY_PATH continues to be used for
that.
The shim cannot call libc7 through its own exported name. Calling sigaction
by name from inside the shim would resolve back to the shim's own interposed
function and call itself repeatedly. The shim instead uses dlopen() to open
libc.so.7. The returned handle identifies that particular library. dlsym() looks up a function's address in
it. A pointer stores a memory address; a function pointer lets code call
a function at that address. Keeping those addresses lets the shim call the
modern implementations directly.
We will save the two evidence-backed versions as libc3-shim-01.c and
libc3-shim-02.c inside /root in the jail. Stage 01 translates the signal
interfaces; Stage 02 adds account lookup. The complete file-creation commands
for both stages are in Appendix A. Stage 02 contains the complete shim needed
to run ApplixWare; the remaining steps supply its libraries, application data,
and fonts.
Stage 01: the signal ABI
The SIGSYS from the trace is the first kernel boundary worth explaining
before writing the wrapper. The generated 32-bit syscall table on the host
identifies the failing entry and its guard:
46 = compat.freebsd32_sigaction
The entry is guarded by the old COMPAT_43 kernel option. The generated table
defines its compat() selector as:
#ifdef COMPAT_43
#define compat(n, name) \
.sy_narg = n, .sy_call = (sy_call_t *)__CONCAT(o, name)
#else
#define compat(n, name) \
.sy_narg = 0, .sy_call = (sy_call_t *)nosys
#endif
Check the running kernel configuration:
sysctl -n kern.conftxt | grep COMPAT_43
It produces no output: this kernel does not include COMPAT_43; old syscall 46
points to nosys, which returns ENOSYS (ERR#78). This explains the trace
without assuming that libc3 itself was defective on FreeBSD 3.x — its kernel
interface is simply no longer enabled.
In the C examples, a struct groups related fields in memory. A pointer
refers to that memory; NULL means no address. A word here is a 32-bit
storage unit. A header is a source file describing the types and functions
available to C code.
A signal handler is a function called when a signal arrives. A signal mask records which signals are temporarily blocked. The field order and size matter because the old program and modern library read the same bytes differently.
Calling modern libc with the old structure pointer unchanged would be unsafe.
The old 32-bit action layout used by syscall 46 is 12 bytes in the order
handler, mask, flags:
struct osigaction32 {
uint32_t sa_u; /* 32-bit handler pointer */
osigset_t sa_mask; /* one 32-bit mask word */
int sa_flags;
};
The current 32-bit layout is 24 bytes in the order handler, flags, mask[4],
because modern sigset_t contains four 32-bit words:
#define _SIG_WORDS 4
typedef struct __sigset {
__uint32_t __bits[_SIG_WORDS];
} __sigset_t;
The shim must preserve the old layout at its exported entry point, construct
the modern layout before calling libc7, and translate an output action back to
the old layout. The launcher’s dynamically resolved sigaction reference
allows the preload to intercept the call.
For this entry, the difference is:
- libc3 side:
sigaction()uses the old i386 layouthandler, mask, flags, with one 32-bit mask word;sigprocmask()likewise uses one mask word. - libc7 / FreeBSD 15.1 side: the modern i386 layout is
handler, flags, mask[4]. - shim behavior: translate old structures to the modern layout, call the corresponding libc7 function, and translate returned values back.
- create in the shim: resolve modern
sigaction(),sigprocmask(), andsignal(); export the two translated interfaces; and ignoreSIGSYSduring initialization as protection while bringing up other old syscall paths.
The important operation is copying each old field into its modern position.
This excerpt runs when the caller supplies a new signal action; act->mask
means “the mask field in the structure addressed by act.” memset() first
clears the modern structure, leaving its extra mask words zero:
memset(&m_act, 0, sizeof(m_act));
m_act.handler = act->handler;
m_act.flags = act->flags;
m_act.mask[0] = act->mask;
The translated structure is then passed to the modern function. If the caller also requests the previous action, the wrapper copies the result back into the old layout:
ret = rl_sigaction ? rl_sigaction(sig, ap, op) : -1;
if (ret == 0 && oact && op) {
oact->handler = m_oact.handler;
oact->flags = m_oact.flags;
oact->mask = m_oact.mask[0];
}
Here ret == 0 means the modern call succeeded. The conditional call returns
-1 if its function address could not be found. sigprocmask() follows the
same pattern for a signal mask: expand one word to four before the call and
copy the first word back afterward.
Use the complete file-creation command in
Appendix A.1 to write
/root/libc3-shim-01.c inside the jail, then return here. The excerpts above
explain the translation; the appendix includes initialization and both wrappers.
The launch also needs Applix's runtime locations: AXHOME is the application
root, AXGFSDIR points to its font metrics, AXLANG selects the language, and
AX_TEMP_DIR selects temporary storage. -wp requests Words, its word processor.
Use one shell function for every stage so every launch records both the raw
return code and the signal calculated as return code - 128. Before each
launch, stop the old helpers and remove their temporary state inside this
dedicated test jail. Otherwise, a new launcher can reuse helpers that still
have an earlier shim loaded. This closes any existing Applix session; save
documents before running a test.
run_shim()
{
shim=$1
jexec applix151 sh -c '
pkill -x axmain 2>/dev/null || true
pkill -x axnet 2>/dev/null || true
rm -f /tmp/axl* /tmp/.axnetipc /tmp/.ax*
'
jexec applix151 env \
LD_32_LIBRARY_PATH=/usr/local/lib32/compat/applix:/usr/local/lib32/compat:/applixware1999cdrom/axdata/axshlib \
LD_32_PRELOAD="$shim" \
AXHOME=/applixware1999cdrom \
AXGFSDIR=/applixware1999cdrom/axdata/fontmetrics/gallium \
AXLANG=english_us \
AX_TEMP_DIR=/tmp \
DISPLAY=:1 \
timeout --foreground 10 /applixware1999cdrom/applix -wp
rc=$?
printf 'return code=%s, signal=%s\n' "$rc" "$((rc >= 128 ? rc - 128 : 0))"
}
The timeout --foreground option matters here. Applix forks detached helper
processes (axnet) that keep the shell's output open. Without --foreground,
timeout waits for that helper's process group and reports 124 even after the
launcher itself has exited; --foreground makes timeout report the launcher's
own status, which is what the recorded return code values below show. A
plain timeout run may therefore print the same messages but end with 124.
After writing /root/libc3-shim-01.c with Appendix A.1, build it now.
The translation is ready; this test asks which startup failure comes next.
A .c file contains source code; cc compiles it into a .so shared library.
-m32 selects 32-bit output, -shared makes a loadable library, and
-fPIC makes its code usable at different memory addresses. -Wall -Wextra
enable compiler warnings; -o names the output file. A successful build
normally produces no output; stop if the compiler reports errors:
jexec applix151 cc -m32 -shared -fPIC -Wall -Wextra \
-o /usr/local/lib/libc3-shim-01.so \
/root/libc3-shim-01.c
The stage ships both sigaction() and sigprocmask() together. The original
investigation tested the sigaction translation alone first; startup then
reached old syscall 48 (compat.sigprocmask), an identical COMPAT_43 -> nosys -> ENOSYS boundary, so the second wrapper was added before recording a stage.
The kernel matches this: with the trace, compat.sigprocmask() reported
ERR#78 ENOSYS, and the failed call was the only evidence needed before
nm -D was used to confirm the launcher imports it.
Confirm the new library exports the expected surface before running it:
jexec applix151 nm -D /usr/local/lib/libc3-shim-01.so |
egrep ' (sigaction|sigprocmask)$'
Expected symbol types:
T sigaction
T sigprocmask
T means the shared object globally defines executable code with that name;
the addresses printed by nm vary between builds. These exports confirm the
wrappers are present; they do not establish the object’s architecture. The
-m32 build option selects 32-bit output, which can also be checked with
file. Run it with the common capture function:
run_shim /usr/local/lib/libc3-shim-01.so
# run_shim /usr/local/lib/libc3-shim-01.so
get user name: No such file or directory
return code=1, signal=0
The signal failure is gone, but startup now prints a different error and exits with status 1. The words suggest a user lookup; they do not yet tell us which function failed or whether a file is actually missing. Next we trace the running program to discover the calls behind the message.
Stage 02: verifying the failing call
Trace functions without naming a suspect
truss shows system calls: requests to the kernel to open files, read data,
and write output. It does not show ordinary C library calls. DTrace's pid
provider can trace functions in a running process, including those in its
shared libraries. We start broadly rather than guessing a function name.
This step requires DTrace to be available inside the jail, with its devices
exposed and permission to trace the jail's processes. The following check
should print DTrace is available; it does not yet test function tracing:
jexec applix151 dtrace -q -n 'BEGIN { printf("DTrace is available\n"); exit(0); }'
On the investigation machine, asiabsd, this check worked, but function
tracing initially failed with failed to control pid ...: process exited with status 1. The same control failure occurred with ordinary system programs.
DTrace's debug log reported rtld_db agent initialization failed: it could
not inspect the runtime linker, the program that loads shared libraries.
The jail shares its base-system files with a Bastille release on the host. The process mappings reported the runtime linker's backing file under the host's release path, which did not exist inside the jail. Check the path reported for the jail's shell and the actual linker files:
jexec applix151 sh -c 'procstat -v $$ | grep ld-elf'
jexec applix151 ls -l /libexec/ld-elf.so.1 /libexec/ld-elf32.so.1
On asiabsd, the reported paths were:
/mnt/tank/finch/usr/local/bastille/releases/15.1-RELEASE/libexec/ld-elf.so.1
/mnt/tank/finch/usr/local/bastille/releases/15.1-RELEASE/libexec/ld-elf32.so.1
These are path excerpts, not complete procstat lines. The first linker is
64-bit; Applix uses the second, 32-bit linker. Inside the jail they are
available at /libexec/ld-elf.so.1 and /libexec/ld-elf32.so.1 respectively.
The linker installation is correct; DTrace is trying to open a path that is
only meaningful on the host.
If your jail has the same mismatch, create a temporary symbolic link so that DTrace can find the files. Replace the release path below with the one reported on your machine. This command creates an alias for the jail's root; it does not replace the runtime linker. Do not replace an existing release directory or link:
jexec applix151 mkdir -p /mnt/tank/finch/usr/local/bastille/releases
jexec applix151 ln -s / \
/mnt/tank/finch/usr/local/bastille/releases/15.1-RELEASE
jexec applix151 cmp /libexec/ld-elf32.so.1 \
/mnt/tank/finch/usr/local/bastille/releases/15.1-RELEASE/libexec/ld-elf32.so.1
cmp prints nothing and returns status 0 when the files match. This workaround
made function tracing work on asiabsd; changing DTrace's startup timing from
postinit to preinit did not fix the path problem.
Create a script that records every symbolized function entry and return:
jexec applix151 sh <<'SH'
cat >/root/02-broad-functions.d <<'DTRACE'
#pragma D option quiet
pid$target:::entry
{
printf("%llu tid=%d E %s`%s a0=0x%llx a1=0x%llx a2=0x%llx\n",
(unsigned long long)timestamp, tid, probemod, probefunc,
(unsigned long long)arg0, (unsigned long long)arg1,
(unsigned long long)arg2);
}
pid$target:::return
{
printf("%llu tid=%d R %s`%s result=0x%llx\n",
(unsigned long long)timestamp, tid, probemod, probefunc,
(unsigned long long)arg1);
}
DTRACE
SH
$target is the process started by DTrace. The empty module and function
fields match all available functions. E marks entry and R marks return;
probemod identifies the executable or library, and probefunc identifies
the function. The timestamp and thread ID help order events. At entry,
arg0 through arg2 are raw candidate arguments; at return, arg1 is the
return value. These values need the function's interface to interpret them:
a string argument is still a memory address, and a function returning no value
has no meaningful result to decode.
Run Stage 01 with the same libraries and a separate temporary directory for Applix's IPC files, leaving existing sessions intact:
jexec applix151 sh -c '
work=$(mktemp -d /tmp/applix-stage02.XXXXXX) || exit 1
env LD_32_LIBRARY_PATH=/usr/local/lib32/compat/applix:/usr/local/lib32/compat:/applixware1999cdrom/axdata/axshlib \
LD_32_PRELOAD=/usr/local/lib/libc3-shim-01.so \
AXHOME=/applixware1999cdrom \
AXGFSDIR=/applixware1999cdrom/axdata/fontmetrics/gallium \
AXLANG=english_us AX_TEMP_DIR="$work" DISPLAY=:1 \
timeout 30 dtrace -q -x nolibs -x evaltime=postinit \
-x bufsize=16m -x switchrate=100hz \
-o /tmp/stage02-broad-functions.log -s /root/02-broad-functions.d \
-c "/applixware1999cdrom/applix -wp" \
>/tmp/stage02-broad.stdout 2>/tmp/stage02-broad.stderr
rc=$?
printf "DTrace exit status: %s\n" "$rc"
cat /tmp/stage02-broad.stderr
wc -l /tmp/stage02-broad-functions.log
tail -n 80 /tmp/stage02-broad-functions.log
'
-c starts Applix under tracing, and evaltime=postinit evaluates the probes
after its initialization sections. nolibs skips DTrace's standard script
libraries, which this script does not need. The buffer size and switching
rate allow DTrace to collect and drain the many events; check standard error
for dropped-record warnings. The timeout limits the experiment to 30 seconds.
DTrace's exit status describes the tracing command, not Applix's success.
The measured broad run on asiabsd captured 32,042 events, with no reported
drops. Applix printed get user name: Invalid argument. Near the end of the
log, getpwuid returned zero, followed by perror, strerror, and the exit
path. Inspecting the earlier calls within that lookup also revealed dbopen.
After discovering these names, filter the log to make the sequence readable:
jexec applix151 grep -E '(getpwuid|dbopen|perror|strerror) ' \
/tmp/stage02-broad-functions.log
Recorded excerpt; timestamps, thread IDs, additional arguments, and the final
returns from perror and strerror are omitted:
E libc.so.3`getpwuid a0=0x0
E libc.so.3`dbopen a0=0x2820e54d
R libc.so.3`dbopen result=0x805f040
R libc.so.3`getpwuid result=0x0
E libc.so.3`perror a0=0x8059693
E libc.so.3`strerror a0=0x16
Now we have function names from the running program, without searching
strings or disassembling the executable. getpwuid looks up an account by its
numeric user ID (UID); UID 0 is root. Its zero return is NULL, meaning no
account record was returned. dbopen returned a nonzero database handle, so
opening the database succeeded. We still need to decode the string pointers
and the error number.
Decode the discovered calls
The focused script follows the interfaces of the functions we just observed:
getpwuid takes a numeric UID, dbopen and perror take a string as their
first argument, and strerror takes an error number. DTrace's copyinstr()
reads a string from the traced process's memory.
jexec applix151 sh <<'SH'
cat >/root/02-getpwuid.d <<'DTRACE'
#pragma D option quiet
pid$target::getpwuid:entry
{ printf("%s`%s(%u)\n", probemod, probefunc, (uint32_t)arg0); }
pid$target::getpwuid:return
{ printf("%s`%s returned 0x%lx\n", probemod, probefunc, (uintptr_t)arg1); }
pid$target::dbopen:entry
{ printf("%s`%s(\"%s\")\n", probemod, probefunc, copyinstr((uintptr_t)arg0)); }
pid$target::perror:entry
{ printf("%s`%s(\"%s\")\n", probemod, probefunc, copyinstr((uintptr_t)arg0)); }
pid$target::strerror:entry
{ printf("%s`%s(%d)\n", probemod, probefunc, (int)arg0); }
DTRACE
SH
Rerun Stage 01 with these focused probes:
jexec applix151 sh -c '
work=$(mktemp -d /tmp/applix-stage02.XXXXXX) || exit 1
env LD_32_LIBRARY_PATH=/usr/local/lib32/compat/applix:/usr/local/lib32/compat:/applixware1999cdrom/axdata/axshlib \
LD_32_PRELOAD=/usr/local/lib/libc3-shim-01.so \
AXHOME=/applixware1999cdrom \
AXGFSDIR=/applixware1999cdrom/axdata/fontmetrics/gallium \
AXLANG=english_us AX_TEMP_DIR="$work" DISPLAY=:1 \
timeout 30 dtrace -q -x nolibs -x evaltime=postinit \
-s /root/02-getpwuid.d -c "/applixware1999cdrom/applix -wp"
'
Measured output on asiabsd; the error message and trace records use different
output streams, so their displayed order is not a timeline:
get user name: Invalid argument
libc.so.3`getpwuid(0)
libc.so.3`dbopen("/etc/spwd.db")
libc.so.3`getpwuid returned 0x0
libc.so.3`perror("get user name")
libc.so.3`strerror(22)
This establishes the failing sequence directly: the old libc.so.3 looks up
UID 0, opens /etc/spwd.db, returns no account record, and receives Applix's
"get user name" label in perror. perror() prints that label followed by
the text for the current errno, an error number retained by C library code.
strerror(22) produces Invalid argument; the earlier suffix No such file or directory corresponds to error number 2. Neither suffix identifies the
precise database failure, and errno may have survived from an earlier
operation. The stable observation is the failed lookup followed by the label.
If you created the temporary release-path alias above, remove it after tracing. Substitute the same release path you used when creating it:
jexec applix151 unlink /mnt/tank/finch/usr/local/bastille/releases/15.1-RELEASE
The scripts and logs remain available inside the jail. The temporary Applix directories can be inspected separately; neither trace stops existing sessions.
Compare that failed lookup with the modern jail's account interface:
jexec applix151 getent passwd 0
jexec applix151 ls -l /etc/spwd.db /usr/lib32/libc.so.7
root:*:0:0:Charlie &:/root:/bin/sh
-rw------- 1 root wheel 40960 ... /etc/spwd.db
-r--r--r-- 1 root wheel 1920200 ... /usr/lib32/libc.so.7
The old launcher reports an account-lookup failure, while getent finds
the account using the modern runtime. That points to incompatibility in the
old account reader, rather than a missing root account. The next experiment
is to intercept getpwuid() and delegate it to modern 32-bit libc.so.7.
We will test the result by rerunning the same launcher.
getpwnam() is included in the final shim because later modules use
by-name lookups against the same old database reader; the dlopen()/dlsym()
pattern below applies to both.
Add getpwuid() and getpwnam() wrappers that delegate directly to modern
libc.so.7 through dlopen()/dlsym().
This bypasses the FreeBSD 3.x account reader. The hypothesis is that modern lookup can supply the account entry Applix needs, without making the old reader understand the modern database. We do not need to identify the exact parser failure to test that change.
Why is there no structure translation here, as there was for signals?
The account lookup returns a pointer to a struct passwd, an account record.
To check which part of that record Applix uses, inspect the launcher's
account-lookup branch. It reads the first field, pw_name, the user name.
The archived FreeBSD 3.5.1 pwd.h and the installed FreeBSD 15.1
pwd.h both place that pointer first. Both libraries used in the process are
32-bit, so that field also has the same pointer size. This supports returning
the modern record directly for this branch. It does not establish that every
field, later caller, or lifetime assumption is compatible.
The following disassembly check verifies that field access; function tracing alone does not show which fields the caller reads:
jexec applix151 objdump -dr --start-address=0x804c814 --stop-address=0x804c82c \
/applixware1999cdrom/applix
Recorded excerpt; address setup and argument-pushing instructions are omitted:
804c81a: 8b 10 movl (%eax), %edx
804c824: e8 2f ec ff ff calll 0x804b458 <strcpy@plt>
The first instruction reads the pointer at the start of the returned account
record. The call to strcpy() copies the user name. This is the specific
field access verified on asiabsd; the later Stage 02 launch tests whether
startup crosses this branch.
For this entry, the difference is:
- libc3 side:
getpwuid()andgetpwnam()use the old FreeBSD 3.x account database code and file/database assumptions. - libc7 / FreeBSD 15.1 side: account lookup understands the jail's current passwd/spwd database format and configured account-lookup services.
- shim behavior: export the same old function names, but delegate the lookup to
libc.so.7and return the modern result to Applix. - create in the shim: export
struct passwd *getpwuid(uid_t)andstruct passwd *getpwnam(const char *), resolve the real modern functions withdlsym(), and fall back toerrno = ENOENTonly if delegation is not available.
#include <sys/types.h>
#include <errno.h>
#include <pwd.h>
static struct passwd *(*rl_getpwuid)(uid_t);
static struct passwd *(*rl_getpwnam)(const char *);
Add these two assignments to libc7_init() after the signal-symbol lookups:
rl_getpwuid = dlsym(libc7_h, "getpwuid");
rl_getpwnam = dlsym(libc7_h, "getpwnam");
Then add the exported wrappers:
struct passwd *
getpwuid(uid_t uid)
{
if (!libc7_h)
libc7_init();
if (rl_getpwuid)
return rl_getpwuid(uid);
errno = ENOENT;
return NULL;
}
struct passwd *
getpwnam(const char *name)
{
if (!libc7_h)
libc7_init();
if (rl_getpwnam)
return rl_getpwnam(name);
errno = ENOENT;
return NULL;
}
Use the complete file-creation command in
Appendix A.2 to write
/root/libc3-shim-02.c inside the jail, then return here. It contains both
signal wrappers from Stage 01 and the account wrappers explained above;
you do not need to combine the excerpts by hand.
After writing the complete file from Appendix A.2, build the account-lookup variant. This test keeps the signal fix and changes the account reader:
jexec applix151 cc -m32 -shared -fPIC -Wall -Wextra \
-o /usr/local/lib/libc3-shim-02.so \
/root/libc3-shim-02.c
Confirm it still exports the whole earlier surface plus the new wrapper:
jexec applix151 nm -D /usr/local/lib/libc3-shim-02.so |
egrep ' (getpwuid|sigaction|sigprocmask)$'
Expected symbol types:
T getpwuid
T sigaction
T sigprocmask
Run stage 02:
run_shim /usr/local/lib/libc3-shim-02.so
# run_shim /usr/local/lib/libc3-shim-02.so
ld-elf32.so.1: Shared object "libg++.so.4" not found, required by "axmain"
/applixware1999cdrom/axdata/axmain: Operation not permitted
return code=1, signal=0
The before/after check is the same run_shim command with freshly reset
helpers: Stage 01 printed get user name and exited with status 1;
Stage 02 no longer printed that error. The launcher still returns a nonzero
status, but for a different reason: with the account lookup working, startup
proceeds far enough to launch the axmain helper, which then fails because its
old C++ runtime is not staged yet (the libg++.so.4 line above). The
focused DTrace run identified the failed lookup before adding the wrapper;
the disappearance of that error shows startup crossing the account-lookup
boundary.
This is behavioral validation, not a direct measurement of a library function's
return value. The shim source shows how it delegates to libc7, and the symbol
check confirms that it exports getpwuid. These observations do not reveal
the returned pointer's address or every internal operation in either library.
The account error disappearing is progress, but it is not proof that Words has
opened.
The launcher hands work to other processes: axnet handles IPC (communication
between processes), and axmain is an application helper. Their libraries and
the visible desktop are the next things to check.
Resolving ApplixWare's own runtime libraries
An earlier test without the CD's axdata/axshlib directory in the search path
failed during the handoff to axmain:
ld-elf32.so.1: Shared object "libshelf.so" not found, required by "axmain"
/applixware1999cdrom/axdata/axmain: Operation not permitted
The commands above already include that directory, so this particular error should not recur when following them. It explains why that part of the path matters: a preload adds an object, but does not add library search directories.
The loader reports only a name, so locate the file before editing any path:
jexec applix151 find /applixware1999cdrom -type f -name libshelf.so -print
# jexec applix151 find /applixware1999cdrom -type f -name libshelf.so -print
/applixware1999cdrom/axdata/axshlib/libshelf.so
With that directory in LD_32_LIBRARY_PATH, the next missing name belongs to
the helper’s old C++ runtime:
run_shim /usr/local/lib/libc3-shim-02.so
Recorded error excerpt from that launch:
ld-elf32.so.1: Shared object "libg++.so.4" not found, required by "axmain"
Each fixed name exposes the next. Do not infer library names from the order of
the error messages; read the binary's dynamic section instead. This is the
first point in the timeline where the old C++ and GNU regex libraries enter the
dependency graph. Inspect the ELF NEEDED entries:
jexec applix151 readelf -d /applixware1999cdrom/axdata/axmain | grep NEEDED
jexec applix151 readelf -d /applixware1999cdrom/axdata/axshlib/libshelf.so | grep NEEDED
jexec applix151 readelf -d /applixware1999cdrom/axdata/axshlib/libfontfs.so | grep NEEDED
Dependency summary from the recorded NEEDED entries (not literal tool output):
axmain: libshelf.so, libX11.so.6, libg++.so.4, libstdc++.so.2, libm.so.2, libc.so.3
libshelf.so: libX11.so.6, libaxel.so, libaxdb.so, libfontfs.so, libg++.so.4, libstdc++.so.2, libm.so.2
libfontfs.so: libgnuregex.so.2
Each NEEDED entry is a direct dependency; the loader stops startup when one
cannot be found, so fixing one library exposes the next. libg++.so.4 and
libstdc++.so.2 are direct dependencies of axmain and libshelf.so, while
libgnuregex.so.2 is a direct dependency of libfontfs.so and a transitive
dependency of libshelf.so. The dependency path is therefore:
axmain -> libshelf.so
-> libg++.so.4
-> libstdc++.so.2
-> ... -> libfontfs.so -> libgnuregex.so.2
Extract them from the already downloaded FreeBSD 3.5.1 archive directly into the Applix-first compat directory. These must be the 32-bit FreeBSD 3.5.1 libraries; do not substitute modern libraries merely because their names are similar:
jexec applix151 sh -c '
set -eu
work=/var/tmp/applix-compat-libs
applix=/usr/local/lib32/compat/applix
mkdir -p "$applix"
cd "$work/freebsd351-bin"
cat bin.* | tar -xzvf - -C "$applix" --strip-components 2 \
"usr/lib/libgnuregex.so*" \
"usr/lib/libg++.so*" \
"usr/lib/libstdc++.so*"
'
jexec applix151 ldconfig -32 \
/usr/lib32 \
/usr/local/lib32/compat \
/usr/local/lib32/compat/applix \
/applixware1999cdrom/axdata/axshlib
Run a fresh Stage 02 test in the background, then inspect after five seconds.
The first command saves launch output on the host; sleep 5 waits five seconds.
ps lists running processes, and the filter selects Applix commands:
run_shim /usr/local/lib/libc3-shim-02.so > stage02-launch.log 2>&1 &
sleep 5
jexec applix151 sh -c '
ps -ax -o command= |
grep -E "^/applixware1999cdrom/(applix|axdata/(axnet|axmain))([[:space:]]|$)"
'
Recorded process excerpt; arguments marked ... are omitted:
/applixware1999cdrom/axdata/axnet /tmp/.axnetipc -fork
/applixware1999cdrom/axdata/axmain -helper ... -servicename axmain:root::1
/applixware1999cdrom/applix -wp
If the process list is empty or a helper exits, inspect the saved launch output:
cat stage02-launch.log
That gets the Words startup path alive. A running process is still not evidence
of a visible Words window. With the FreeBSD 3.5.1 libX11.so.6, truss shows axmain connecting directly to
/tmp/.X11-unix/X1 and exchanging X11 requests and replies. There are no
loader probes for libxcb, libXau, libXdmcp, libXcursor, libXfixes, or
libXrender; those were artifacts of using a modern X11 stack, not Applix
dependencies.
Stage 02 is sufficient to run ApplixWare once the matching libraries,
writable application tree, and fonts are in place. Keep using
/usr/local/lib/libc3-shim-02.so for the remaining launches; no further shim
changes are needed.
6. From a running helper to a visible Words window
The helpers can start without leaving a usable application window. At this point we need to check application data and fonts as well as executable code.
One test used a mounted CD as AXHOME, rather than the extracted copy we made
above. Its trace exposed another assumption in Applix's startup:
open("/applixware1999cdrom/ax_prof4x", O_WRONLY|O_CREAT|O_TRUNC, 0666) ERR#30 'Read-only file system'
access("/applixware1999cdrom", W_OK) ERR#30 'Read-only file system'
_exit(0x1)
ERR#30 is EROFS, or "Read-only file system". Applix is trying to create or
rewrite profile/state files under AXHOME, but in this run AXHOME still
points at the CD image mount. ISO/CD-ROM content is read-only, so startup exits
even though the binary, libraries, shim, and X display are now mostly working.
_exit(0x1) is the process leaving with status 1 after deciding it cannot use
that read-only runtime tree.
Our extracted copy is already writable, so the same read-only error is not
expected in this sequence. The trace still establishes that Applix needs a
writable application root. Make a separate runtime tree at
/usr/local/applixware so the extracted CD remains our source copy:
jexec applix151 install -d -m 755 /usr/local/applixware
jexec applix151 sh -c '
(cd /applixware1999cdrom && tar -cf - .) |
(cd /usr/local/applixware && tar -xpf -)
'
If the copy is interrupted, compare the important runtime directories. In the
failed run, axdata and axart were incomplete, so axmain loaded far enough
to create transient X windows and then exited:
jexec applix151 sh -c '
for d in axdata axfonts axlocal axart axlang axfilter builder template system rtgate; do
s=$(find "/applixware1999cdrom/$d" -type f 2>/dev/null | wc -l)
t=$(find "/usr/local/applixware/$d" -type f 2>/dev/null | wc -l)
printf "%s source=%s target=%s\n" "$d" "$s" "$t"
done
'
For the verified tree, the key counts included:
axdata source=6062 target=6062
axart source=2109 target=2109
Now that /usr/local/applixware exists, add the Applix font directory to the
running VNC server's font path:
jexec applix151 sh -c '
DISPLAY=:1 xset fp= /usr/local/share/fonts/misc,/usr/local/applixware/axfonts/all_pcf,built-ins
DISPLAY=:1 xset fp rehash
DISPLAY=:1 xsetroot -cursor_name left_ptr
'
The Applix font path must include three pieces:
/usr/local/share/fonts/misc: ordinary X bitmap fonts used by Fluxbox and X tools./usr/local/applixware/axfonts/all_pcf: ApplixWare's bundled PCF fonts, now available at the installed runtime path.built-ins: the X server built-in font set, including the cursor font used by named cursors.
Keep built-ins when adding the Applix directory. It preserves the cursor
font checked in Section 2; the Applix directory adds the fonts used by the
legacy dialogs and document windows.
Launch Words in the background with the writable runtime tree, then inspect its processes. This closes existing Applix sessions; save documents first:
jexec applix151 sh -c '
pkill -x axmain 2>/dev/null || true
pkill -x axnet 2>/dev/null || true
rm -f /tmp/axl* /tmp/.axnetipc /tmp/.ax*
DISPLAY=:1 xset fp= /usr/local/share/fonts/misc,/usr/local/applixware/axfonts/all_pcf,built-ins
DISPLAY=:1 xset fp rehash
DISPLAY=:1 xsetroot -cursor_name left_ptr
env \
LD_32_LIBRARY_PATH=/usr/local/lib32/compat/applix:/usr/local/lib32/compat:/usr/local/applixware/axdata/axshlib \
LD_32_PRELOAD=/usr/local/lib/libc3-shim-02.so \
AXHOME=/usr/local/applixware \
AXGFSDIR=/usr/local/applixware/axdata/fontmetrics/gallium \
AXLANG=english_us \
AX_TEMP_DIR=/tmp \
DISPLAY=:1 \
/usr/local/applixware/applix -wp >/root/applix-words.log 2>&1 &
'
sleep 5
jexec applix151 sh -c '
ps -ax -o command= |
grep -E "^/usr/local/applixware/(applix|axdata/(axnet|axmain))([[:space:]]|$)"
'
Recorded process excerpt after five seconds:
/usr/local/applixware/axdata/axnet /tmp/.axnetipc -fork
/usr/local/applixware/axdata/axmain -helper ... -servicename axmain:root::1
/usr/local/applixware/applix -wp
If the process list is empty or the Words window does not appear, inspect the application log before changing another setting:
jexec applix151 tail -40 /root/applix-words.log
That confirms the launcher, helper, old libraries, shim, writable runtime tree,
and X display all got far enough to start the Words module process tree from
the applix151 jail. Check the VNC viewer as well: the expected visual result
is the Words word-processor window, including its menu and document area,
rather than only the Fluxbox desktop or a briefly appearing dialog.
The recorded reproduction saved a full-screen XWD capture and a PNG version
on asiabsd. The preserved PNG below was retrieved and visually inspected
on October 10, 2026: it shows the Words menus, toolbar, blank document page,
and status bar. This is a saved result, not a new launch performed during
that inspection.

Capture your own result with xwd, an X11 screen-dump tool. This creates /root/applix-words.xwd inside the jail and
copies it to the current host working directory:
bastille pkg applix151 install -y xwd xwud
jexec applix151 env DISPLAY=:1 xwd -silent -root -out /root/applix-words.xwd
jexec applix151 cat /root/applix-words.xwd > applix-words.xwd
test -s applix-words.xwd
The xwd manual
documents -root (capture the full display) and -out (save to a file).
The capture and final file-size check produce no output on success; package
installation prints its normal progress. To view
the captured image inside the same VNC desktop, run xwud, the matching image
viewer, then close its window when finished. Its
-in option
selects the saved image:
jexec applix151 env DISPLAY=:1 xwud -in /root/applix-words.xwd &
Compare the captured image with the expected Words window described above. The process list alone is not proof that a usable window appeared.
At this point "no errors" does not mean the launcher prints a success message; Applix is a graphical program, so a successful command leaves the application and its helper processes running while the UI appears in VNC. The important change is that the previous loader, libc, account lookup, signal, read-only filesystem, font, and cursor errors no longer appear.
7. What the successful run establishes
The recorded Words window is the result we were looking for. Starting from possible compatibility changes since FreeBSD 3.5.1, we supplied the matching 32-bit libraries, used system-call traces to identify the signal mismatch, and used broad then focused function traces to identify the failed account lookup. Comparing the old and modern interfaces led to the two shim stages.
Stage 02 is sufficient for running ApplixWare. The remaining startup work is configuration: a writable application tree and the expected fonts. A running launcher alone is insufficient evidence of a usable window; check the VNC viewer as well. The visible Words window verifies that startup path, rather than every feature of the suite.
Repeatable launches and cleanup
Now that the manual startup works, Appendix B provides a generic vnc-session
helper, Appendix C provides vnc-applix for launching the suite in VNC, and
Appendix D provides applix-wrapper for the application environment. Install
the helpers as described in their appendices before using them.
vnc-applix wp stops existing Applix helpers and removes their temporary state
before launching Words. This closes existing Applix sessions; save documents
first. vnc-applix status checks whether the VNC desktop responds, not whether
Words is running. Confirm Words in the viewer and inspect its processes and
log as described in Section 6.
jexec applix151 /usr/local/bin/vnc-applix wp
jexec applix151 /usr/local/bin/vnc-applix status
When finished testing, stop the Applix helpers and remove their temporary state inside this dedicated jail:
jexec applix151 sh -c '
pkill -x axmain 2>/dev/null || true
pkill -x axnet 2>/dev/null || true
rm -f /tmp/axl* /tmp/.axnetipc /tmp/.ax*
'
Stop the manually started VNC desktop only after finishing the investigation:
jexec applix151 sh -c '
if test -s /var/run/xvnc.pid; then
kill "$(cat /var/run/xvnc.pid)"
rm -f /var/run/xvnc.pid
fi
pkill -x fluxbox 2>/dev/null || true
'
Historical note: executable-stack setting
An executable stack allows a process to run instructions from the memory normally used for active function calls and local variables. This is a historical configuration note, not an established startup fix. Read the host setting without changing it:
sysctl kern.elf32.nxstack
# sysctl kern.elf32.nxstack
kern.elf32.nxstack: 1
That is the historical value from the original investigation. The setting is
host-wide, and its value varies by host: the reproduction jail asiabsd
reported 0, confirmed again during the read-only inspection. The notes also
suggested sysctl kern.elf32.nxstack=0
for possible module-startup problems, but provide no specific failure or
before/after test establishing that it was required. It therefore does not
belong among the demonstrated fixes; it affects stack execution protection for
all 32-bit processes, not a jail-local application option.
Appendix A. Complete shim sources
The main investigation shows only the relevant C excerpts. These complete commands create the files used at each stage. Paste the block for the stage you are following, then return to its compile-and-test step in Section 5.
A.1. Stage 01: signal translation
Write the signal-only source, then return to Stage 01.
jexec applix151 tee /root/libc3-shim-01.c >/dev/null <<'SOURCE'
#include <dlfcn.h>
#include <string.h>
#ifndef RTLD_LOCAL
#define RTLD_LOCAL 0
#endif
static void *libc7_h;
static int (*rl_sigaction)(int, const void *, void *);
static int (*rl_sigprocmask)(int, const void *, void *);
#define APPLIX_SIGSYS 12
#define APPLIX_SIG_IGN ((void (*)(int))1)
static void (*(*rl_signal)(int, void (*)(int)))(int);
struct old_sigaction {
void *handler;
unsigned int mask;
int flags;
};
struct new_sigaction {
void *handler;
int flags;
unsigned int mask[4];
};
static void
libc7_init(void)
{
if (libc7_h)
return;
libc7_h = dlopen("libc.so.7", RTLD_LAZY | RTLD_LOCAL);
if (!libc7_h)
return;
rl_sigaction = dlsym(libc7_h, "sigaction");
rl_sigprocmask = dlsym(libc7_h, "sigprocmask");
rl_signal = dlsym(libc7_h, "signal");
if (rl_signal)
rl_signal(APPLIX_SIGSYS, APPLIX_SIG_IGN);
}
int
sigaction(int sig, const struct old_sigaction *act, struct old_sigaction *oact)
{
struct new_sigaction m_act;
struct new_sigaction m_oact;
struct new_sigaction *ap = NULL;
struct new_sigaction *op = NULL;
int ret;
if (!libc7_h)
libc7_init();
if (act) {
memset(&m_act, 0, sizeof(m_act));
m_act.handler = act->handler;
m_act.flags = act->flags;
m_act.mask[0] = act->mask;
ap = &m_act;
}
if (oact)
op = &m_oact;
ret = rl_sigaction ? rl_sigaction(sig, ap, op) : -1;
if (ret == 0 && oact && op) {
oact->handler = m_oact.handler;
oact->flags = m_oact.flags;
oact->mask = m_oact.mask[0];
}
return ret;
}
int
sigprocmask(int how, const unsigned int *set, unsigned int *oset)
{
unsigned int m_set[4];
unsigned int m_oset[4];
void *sp = NULL;
void *op = NULL;
int ret;
if (!libc7_h)
libc7_init();
memset(m_set, 0, sizeof(m_set));
memset(m_oset, 0, sizeof(m_oset));
if (set) {
m_set[0] = *set;
sp = m_set;
}
if (oset)
op = m_oset;
ret = rl_sigprocmask ? rl_sigprocmask(how, sp, op) : -1;
if (ret == 0 && oset && op)
*oset = m_oset[0];
return ret;
}
SOURCE
A.2. Stage 02: account lookup
This complete source keeps Stage 01's signal translation and adds modern account lookup. Return to Stage 02 after writing it.
jexec applix151 tee /root/libc3-shim-02.c >/dev/null <<'SOURCE'
#include <sys/types.h>
#include <errno.h>
#include <pwd.h>
#include <dlfcn.h>
#include <string.h>
#ifndef RTLD_LOCAL
#define RTLD_LOCAL 0
#endif
static struct passwd *(*rl_getpwuid)(uid_t);
static struct passwd *(*rl_getpwnam)(const char *);
static void *libc7_h;
static int (*rl_sigaction)(int, const void *, void *);
static int (*rl_sigprocmask)(int, const void *, void *);
#define APPLIX_SIGSYS 12
#define APPLIX_SIG_IGN ((void (*)(int))1)
static void (*(*rl_signal)(int, void (*)(int)))(int);
struct old_sigaction {
void *handler;
unsigned int mask;
int flags;
};
struct new_sigaction {
void *handler;
int flags;
unsigned int mask[4];
};
static void
libc7_init(void)
{
if (libc7_h)
return;
libc7_h = dlopen("libc.so.7", RTLD_LAZY | RTLD_LOCAL);
if (!libc7_h)
return;
rl_sigaction = dlsym(libc7_h, "sigaction");
rl_sigprocmask = dlsym(libc7_h, "sigprocmask");
rl_signal = dlsym(libc7_h, "signal");
rl_getpwuid = dlsym(libc7_h, "getpwuid");
rl_getpwnam = dlsym(libc7_h, "getpwnam");
if (rl_signal)
rl_signal(APPLIX_SIGSYS, APPLIX_SIG_IGN);
}
int
sigaction(int sig, const struct old_sigaction *act, struct old_sigaction *oact)
{
struct new_sigaction m_act;
struct new_sigaction m_oact;
struct new_sigaction *ap = NULL;
struct new_sigaction *op = NULL;
int ret;
if (!libc7_h)
libc7_init();
if (act) {
memset(&m_act, 0, sizeof(m_act));
m_act.handler = act->handler;
m_act.flags = act->flags;
m_act.mask[0] = act->mask;
ap = &m_act;
}
if (oact)
op = &m_oact;
ret = rl_sigaction ? rl_sigaction(sig, ap, op) : -1;
if (ret == 0 && oact && op) {
oact->handler = m_oact.handler;
oact->flags = m_oact.flags;
oact->mask = m_oact.mask[0];
}
return ret;
}
int
sigprocmask(int how, const unsigned int *set, unsigned int *oset)
{
unsigned int m_set[4];
unsigned int m_oset[4];
void *sp = NULL;
void *op = NULL;
int ret;
if (!libc7_h)
libc7_init();
memset(m_set, 0, sizeof(m_set));
memset(m_oset, 0, sizeof(m_oset));
if (set) {
m_set[0] = *set;
sp = m_set;
}
if (oset)
op = m_oset;
ret = rl_sigprocmask ? rl_sigprocmask(how, sp, op) : -1;
if (ret == 0 && oset && op)
*oset = m_oset[0];
return ret;
}
struct passwd *
getpwuid(uid_t uid)
{
if (!libc7_h)
libc7_init();
if (rl_getpwuid)
return rl_getpwuid(uid);
errno = ENOENT;
return NULL;
}
struct passwd *
getpwnam(const char *name)
{
if (!libc7_h)
libc7_init();
if (rl_getpwnam)
return rl_getpwnam(name);
errno = ENOENT;
return NULL;
}
SOURCE
Appendix B. Complete vnc-session
Run this complete block on the host to install /usr/local/bin/vnc-session
inside the jail. The final chmod 755 command makes the script executable. This helper is generic:
it starts a VNC desktop with Fluxbox and xterm, but it does not know anything
about ApplixWare.
jexec applix151 tee /usr/local/bin/vnc-session >/dev/null <<'SCRIPT'
#!/bin/sh
set -eu
DISPLAY_NUM=${DISPLAY_NUM:-1}
DISPLAY=":$DISPLAY_NUM"
GEOMETRY=${GEOMETRY:-800x600}
DEPTH=${DEPTH:-16}
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,built-ins}
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
}
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
}
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
}
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"
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
}
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"
}
case "${1:-}" in
start)
start_vnc
;;
stop)
stop_vnc
;;
restart)
stop_vnc
start_vnc
;;
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
SCRIPT
jexec applix151 chmod 755 /usr/local/bin/vnc-session
Appendix C. Complete vnc-applix
Run this complete block on the host to install /usr/local/bin/vnc-applix
inside the jail. The final chmod 755 command makes the script executable.
jexec applix151 tee /usr/local/bin/vnc-applix >/dev/null <<'SCRIPT'
#!/bin/sh
set -eu
DISPLAY_NUM=${DISPLAY_NUM:-1}
DISPLAY=":$DISPLAY_NUM"
GEOMETRY=${GEOMETRY:-800x600}
DEPTH=${DEPTH:-16}
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/applix-xvnc.log}
VNC_PID=${VNC_PID:-/var/run/applix-xvnc.pid}
DEFAULT_AXHOME=/usr/local/applixware
if [ ! -x "$DEFAULT_AXHOME/applix" ]; then
DEFAULT_AXHOME=/applixware1999cdrom
fi
AXHOME=${AXHOME:-$DEFAULT_AXHOME}
FONT_PATH=${FONT_PATH:-/usr/local/share/fonts/misc,$AXHOME/axfonts/all_pcf,built-ins}
APPLIX_BIN=${APPLIX_BIN:-$AXHOME/applix}
LIBC3_SHIM=${LIBC3_SHIM:-/usr/local/lib/libc3-shim-02.so}
APPLIX_LIB32_COMPAT=${APPLIX_LIB32_COMPAT:-/usr/local/lib32/compat}
APPLIX_LIB32_APPLIX=${APPLIX_LIB32_APPLIX:-$APPLIX_LIB32_COMPAT/applix}
AXDATA=${AXDATA:-$AXHOME/axdata}
AXSHLIB=${AXSHLIB:-$AXDATA/axshlib}
AXGFSDIR=${AXGFSDIR:-$AXDATA/fontmetrics/gallium}
AXLANG=${AXLANG:-english_us}
AX_TEMP_DIR=${AX_TEMP_DIR:-/tmp}
usage() {
cat <<USAGE
usage: vnc-applix {start|stop|restart|status|password|wp|gr|ss|builder|presents|applix}
Environment overrides:
DISPLAY_NUM=$DISPLAY_NUM
GEOMETRY=$GEOMETRY
DEPTH=$DEPTH
RFBPORT=$RFBPORT
USAGE
}
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
}
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
}
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"
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
}
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"
}
cleanup_applix_state() {
pkill axmain 2>/dev/null || true
pkill axnet 2>/dev/null || true
rm -f "$AX_TEMP_DIR"/axl* "$AX_TEMP_DIR"/.axnetipc \
"$AX_TEMP_DIR"/.ax* "$AX_TEMP_DIR"/.axsc* 2>/dev/null || true
}
run_applix() {
start_vnc
cleanup_applix_state
env \
LD_32_LIBRARY_PATH="$APPLIX_LIB32_APPLIX:$APPLIX_LIB32_COMPAT:$AXSHLIB" \
LD_32_PRELOAD="$LIBC3_SHIM" \
AXHOME="$AXHOME" \
AXGFSDIR="$AXGFSDIR" \
AXLANG="$AXLANG" \
AX_TEMP_DIR="$AX_TEMP_DIR" \
DISPLAY="$DISPLAY" \
"$APPLIX_BIN" "$@"
}
case "${1:-}" in
start)
start_vnc
;;
stop)
stop_vnc
;;
restart)
stop_vnc
start_vnc
;;
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"
;;
wp)
run_applix -wp
;;
gr)
run_applix -gr
;;
ss)
run_applix -ss
;;
builder)
run_applix -builder
;;
presents)
run_applix -presents
;;
applix)
shift
run_applix "$@"
;;
-h|--help|help|"")
usage
;;
*)
echo "unknown command: $1" >&2
usage >&2
exit 64
;;
esac
SCRIPT
jexec applix151 chmod 755 /usr/local/bin/vnc-applix
Appendix D. Complete applix-wrapper
Run this complete block on the host to install /usr/local/bin/applix-wrapper
inside the jail. The final chmod 755 command makes the script executable.
jexec applix151 tee /usr/local/bin/applix-wrapper >/dev/null <<'SCRIPT'
#!/bin/sh
set -eu
DEFAULT_AXHOME=/usr/local/applixware
if [ ! -x "$DEFAULT_AXHOME/applix" ]; then
DEFAULT_AXHOME=/applixware1999cdrom
fi
AXHOME=${AXHOME:-$DEFAULT_AXHOME}
AXDATA=${AXDATA:-$AXHOME/axdata}
AXSHLIB=${AXSHLIB:-$AXDATA/axshlib}
AXGFSDIR=${AXGFSDIR:-$AXDATA/fontmetrics/gallium}
AXLANG=${AXLANG:-english_us}
AX_TEMP_DIR=${AX_TEMP_DIR:-/tmp}
DISPLAY=${DISPLAY:-:1}
VNC_APPLIX=${VNC_APPLIX:-/usr/local/bin/vnc-applix}
APPLIX_BIN=${APPLIX_BIN:-$AXHOME/applix}
LIBC3_SHIM=${LIBC3_SHIM:-/usr/local/lib/libc3-shim-02.so}
APPLIX_LIB32_COMPAT=${APPLIX_LIB32_COMPAT:-/usr/local/lib32/compat}
APPLIX_LIB32_APPLIX=${APPLIX_LIB32_APPLIX:-$APPLIX_LIB32_COMPAT/applix}
LD_32_LIBRARY_PATH=${LD_32_LIBRARY_PATH:-$APPLIX_LIB32_APPLIX:$APPLIX_LIB32_COMPAT:$AXSHLIB}
LD_32_PRELOAD=${LD_32_PRELOAD:-$LIBC3_SHIM}
cleanup_applix_state() {
pkill axmain 2>/dev/null || true
pkill axnet 2>/dev/null || true
rm -f \
"$AX_TEMP_DIR"/axl* \
"$AX_TEMP_DIR"/.axnetipc \
"$AX_TEMP_DIR"/.ax* \
"$AX_TEMP_DIR"/.axsc* \
2>/dev/null || true
}
usage() {
cat >&2 <<EOF
usage: $(basename "$0") [applix-flag-or-args...]
Examples:
$(basename "$0") -wp
$(basename "$0") -gr
$(basename "$0") -ss
$(basename "$0") -presents
$(basename "$0") -builder
Environment overrides:
AXHOME=$AXHOME
DISPLAY=$DISPLAY
LIBC3_SHIM=$LIBC3_SHIM
EOF
exit 64
}
case "${1:-}" in
-h|--help)
usage
;;
esac
if [ -x "$VNC_APPLIX" ]; then
"$VNC_APPLIX" start
fi
if [ ! -x "$APPLIX_BIN" ]; then
echo "missing Applix launcher: $APPLIX_BIN" >&2
exit 66
fi
if [ ! -r "$LIBC3_SHIM" ]; then
echo "missing libc3 shim: $LIBC3_SHIM" >&2
exit 66
fi
cleanup_applix_state
export AXHOME AXGFSDIR AXLANG AX_TEMP_DIR DISPLAY
export LD_32_LIBRARY_PATH LD_32_PRELOAD
exec "$APPLIX_BIN" "$@"
SCRIPT
jexec applix151 chmod 755 /usr/local/bin/applix-wrapper