Skip to the text
KDOS
Menu
kdos.dev KDOS from Scratch KDOS 0.2 · 4dd4a10 · 2026-11-30 Contents Index

226.2. kdos-boxsock-0.2.0

Per-launcher tagged Wayland socket in a box's private runtime directory — the security-context-v1 engine

Version 0.2.0, release 1
Source tree src/system/kdos-boxsock/
Phase 42_graphics (Graphics Stack), 166 of 189 in build order
Licence MIT
Homepage https://github.com/kunaldawn/kdos
Build time 0.1 SBU
Installed size 25.6 KiB in 1 file
Recipe src/system/kdos-boxsock/kpkgbuild

About

kdos-boxsock gives each launcher of a box its own Wayland socket, so KWin always knows which box a window comes from. It

  1. binds the socket in the box’s private runtime directory, $XDG_RUNTIME_DIR/kdos/box/<box>/;
  2. hands it to KWin through the security-context-v1 protocol, tagged with the launcher’s id as the app id, the box as the instance id and the engine io.kdos.appbox+private or io.kdos.appbox+tagged;
  3. prints ready <path>;
  4. stays alive, holding the descriptor that keeps the tag valid.

Every client that connects on that socket is tagged by KWin itself and never sees the tag, so it cannot forge or drop it. KWin’s sandbox filter and its grants (read by the instance id from the box’s profile), the window’s application id, the box’s title-bar colour rule and the sandbox badge all read that tag.

kdos-appbox starts one before it runs a launcher in a box and points the program’s WAYLAND_DISPLAY at the socket. When kdos-boxsock prints error <reason> instead, the box does not start and the reason is what the person sees.

It is a program of its own for two reasons: kdos-appbox run replaces itself with the container command, so it cannot hold the descriptor for the box’s lifetime, and kdos-appbox links no Wayland library. It is box infrastructure beside kdos-appbox and the boxes’ init, and links no toolkit. Its arguments, its lock and its exit codes are in The daemons.

Why it is in KDOS

The comment above it in script/phases/42_graphics/packages.d/src-system.txt:

The security-context-v1 sandbox engine: one tagged Wayland socket per box. Separate from kdos-appbox because run execs distrobox and cannot hold the context's close fd, and because kdos-appbox links no libraries.

Sources

None: the port builds from its own directory, /kdos/src/system/kdos-boxsock.

Dependencies

Depends on: wayland, wayland-protocols.

Required by (1): kdos-appbox.

Installation

From the repository root, inside the build container, this is the line kdosbuild runs for the port:

script/chroot/exec.sh bash -c 'source script/phases/42_graphics/phase.env && kpkg install kdos-boxsock'

What kpkg does

kpkg runs these steps, in this order, as root inside the chroot. The port directory is /kdos/src/system/kdos-boxsock.

1. Verify every declared source. Each file a sha256 = line names, found in the port directory or in /var/cache/kpkg/sources, must hash to its line; a mismatch stops the build before anything is unpacked.

2. Unpack. The work directory is emptied and the first source is unpacked into $SRC with its top directory stripped; any later tarball lands unstripped beside it in $SRC_ROOT, and a file that is not a tarball is copied into $SRC.

SRC_ROOT=/var/cache/kpkg/work/kdos-boxsock
SRC=$SRC_ROOT/kdos-boxsock-0.2.0
PKG=$SRC_ROOT/pkg
rm -rf "$SRC_ROOT"
mkdir -p "$SRC" "$PKG"

Every config.guess and config.sub older than automake’s is then replaced with automake’s, so a configure script recognises the musl target.

3. Build. build.sh is sourced in a subshell under set -e, from $SRC, with name, version, release and the five paths PKGNAME, PORT_SRC, SRC_ROOT, SRC and PKG set as shell variables. Its body, verbatim:

XML="$(pkg-config --variable=pkgdatadir wayland-protocols)/staging/security-context/security-context-v1.xml"
SCANNER="$(pkg-config --variable=wayland_scanner wayland-scanner)"

"$SCANNER" client-header "$XML" security-context-v1-client-protocol.h
"$SCANNER" private-code  "$XML" security-context-v1-protocol.c

gcc $CFLAGS -O2 -Wall -Wextra \
	-I. \
	$(pkg-config --cflags wayland-client) \
	-o kdos-boxsock "$PORT_SRC"/main.c security-context-v1-protocol.c \
	$(pkg-config --libs wayland-client) $LDFLAGS

install -Dm755 kdos-boxsock "$PKG/usr/bin/kdos-boxsock"

The common switches of each build system are explained in the Flag glossary.

4. Package. kpkg removes libtool archives, the info directory index, mimeinfo.cache and every fonts.dir from $PKG, copies the source’s licence files into /usr/share/licenses/kdos-boxsock, prunes what the image does not ship, lints the tree and rolls it reproducibly:

tar --sort=name --format=gnu --numeric-owner --owner=0 --group=0 \
    --mtime=@$SOURCE_DATE_EPOCH \
    --use-compress-program='xz -9 -T0 --block-size=32MiB --no-adjust' \
    -cf kdos-boxsock-0.2.0-1.tar.xz -C "$PKG" .

5. Adopt. kpkgadd installs the package’s files over the root, refusing a path another package owns, records the file list in /var/lib/kpkg/db/kdos-boxsock, and runs the triggers its paths call for.

Other files in the port directory, read by build.sh: main.c.

Contents

Installed programs: kdos-boxsock.

Notes