Steward 0.1.0 (in development): a DHCPv4 server with a web UI, API and CLI

Subnets served per interface, pools, reservations, options at three
levels, leases in SQLite saved before the ACK, ping and decline conflict
checks, validated changes with history and undo, users and tokens, an
audit log, a Kea importer, a sandboxed systemd unit and Debian packages.
Tested with real udhcpc and dhcpcd clients in Docker (scripts/e2e.sh).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
abrown38andClaude Opus 5.5 committed 2026-10-14 12:14:07 +01:00
commit 3c0808591f
111 files changed
+17851

No files matched your search

+16
View File
@@ -0,0 +1,16 @@
Package: steward-cli
Version: @VERSION@
Architecture: @ARCH@
Maintainer: @MAINTAINER@
Installed-Size: @SIZE@
Section: net
Priority: optional
Description: command line client for Steward, the DHCP server
steward is the command line client for Steward servers (stewardd):
subnets, pools, reservations, options, leases and DHCP activity, the
history of changes with undo, users and tokens, and importing Kea.
It talks to stewardd's REST API with an API token, or, on the server
itself, to stewardd's local socket.
.
Install this package alone to manage Steward from another machine; the
steward package (the server) depends on it.
+21
View File
@@ -0,0 +1,21 @@
Package: steward
Version: @VERSION@
Architecture: @ARCH@
Maintainer: @MAINTAINER@
Installed-Size: @SIZE@
Depends: systemd, steward-cli (= @VERSION@)
Section: net
Priority: optional
Description: DHCPv4 server with a web UI, a REST API and a CLI
Steward is a DHCPv4 server: subnets served per network interface, pools,
reservations and options, with leases kept in SQLite. It is configured
through a web UI, a REST API and the steward command line client. Every
change is validated as a whole before it is used, and recorded in a
history where it can be undone. Users and API tokens have permissions,
and every change is audited. It can import a Kea configuration and its
leases.
.
This package is the server: stewardd (as the systemd service steward)
with its daily backup timer. The steward CLI comes from steward-cli,
which can also be installed on its own on other machines. stewardd isn't
started on a first install: see /usr/share/doc/steward/docs/install.md.
+57
View File
@@ -0,0 +1,57 @@
#!/bin/sh
# Steward: runs after the package's files are in place.
set -e
if [ "$1" = configure ]; then
# The steward system user and Steward's directories: /etc/steward,
# /var/lib/steward and /var/backups/steward.
systemd-sysusers steward.conf
systemd-tmpfiles --create steward.conf || true
# An example configuration on the first install; an existing one is
# never touched.
if [ ! -e /etc/steward/steward.yaml ]; then
/usr/bin/stewardd config --example > /etc/steward/steward.yaml.dpkg-new
chown root:steward /etc/steward/steward.yaml.dpkg-new
chmod 0640 /etc/steward/steward.yaml.dpkg-new
mv /etc/steward/steward.yaml.dpkg-new /etc/steward/steward.yaml
fi
# The daily database backup (steward-backup.timer) is on by default. An
# administrator's 'systemctl disable steward-backup.timer' is remembered
# by deb-systemd-helper and kept across upgrades. Before 'stewardd init'
# the backup skips itself (there is no database yet).
if command -v deb-systemd-helper >/dev/null 2>&1; then
deb-systemd-helper unmask steward-backup.timer >/dev/null || true
if deb-systemd-helper --quiet was-enabled steward-backup.timer; then
deb-systemd-helper enable steward-backup.timer >/dev/null || true
else
deb-systemd-helper update-state steward-backup.timer >/dev/null || true
fi
elif [ -z "$2" ] && [ -d /run/systemd/system ]; then
systemctl enable steward-backup.timer >/dev/null 2>&1 || true
fi
if [ -d /run/systemd/system ]; then
systemctl daemon-reload || true
if systemctl is-enabled --quiet steward-backup.timer 2>/dev/null; then
systemctl start steward-backup.timer || true
fi
# An upgrade restarts a running stewardd (its database is upgraded
# when it starts). A first install starts nothing: Steward needs
# 'stewardd init' first.
if [ -n "$2" ] && systemctl is-active --quiet steward.service; then
systemctl restart steward.service || echo "steward: restarting stewardd failed; see 'journalctl -u steward'" >&2
fi
fi
if [ -z "$2" ]; then
echo "Steward is installed. Next: create the database and start it, as described"
echo "in /usr/share/doc/steward/docs/install.md:"
echo " sudo -u steward stewardd init && sudo systemctl enable --now steward"
echo "Stop any other DHCP server first (Kea, dnsmasq, isc-dhcp-server): only one"
echo "can listen on an interface's port 67. 'steward import kea' brings Kea's setup over."
fi
fi
exit 0
+35
View File
@@ -0,0 +1,35 @@
#!/bin/sh
# Steward: runs after the package's files are removed.
set -e
case "$1" in
remove|purge)
if [ -d /run/systemd/system ]; then
systemctl daemon-reload || true
fi
;;
esac
# The backup timer's enabled state (see postinst): masked while the
# package is removed, forgotten on purge.
if command -v deb-systemd-helper >/dev/null 2>&1; then
case "$1" in
remove)
deb-systemd-helper mask steward-backup.timer >/dev/null || true
;;
purge)
deb-systemd-helper purge steward-backup.timer >/dev/null || true
deb-systemd-helper unmask steward-backup.timer >/dev/null || true
;;
esac
fi
# Even a purge keeps Steward's data: the database in /var/lib/steward holds
# the configuration and the leases. Remove it by hand when you no longer
# need it.
if [ "$1" = purge ]; then
echo "steward: kept /etc/steward, /var/lib/steward and /var/backups/steward;"
echo "remove them by hand if unused."
fi
exit 0
+16
View File
@@ -0,0 +1,16 @@
#!/bin/sh
# Steward: runs before the package's files are removed (also on upgrades).
set -e
# On removal (not on upgrade) stop stewardd and the backup timer and remove
# stewardd's boot-time link (postrm deals with the timer's). Clients keep
# their addresses until their leases run out.
if [ "$1" = remove ] && [ -d /run/systemd/system ]; then
systemctl stop steward.service steward-backup.timer steward-backup.service 2>/dev/null || true
systemctl disable steward.service 2>/dev/null || true
if ! command -v deb-systemd-helper >/dev/null 2>&1; then
systemctl disable steward-backup.timer 2>/dev/null || true
fi
fi
exit 0
+44
View File
@@ -0,0 +1,44 @@
# Steward: one database backup, run daily by steward-backup.timer.
# Installed as /etc/systemd/system/steward-backup.service (see
# docs/operations.md#backups). What to keep, and where, is in the backup:
# section of /etc/steward/steward.yaml.
[Unit]
Description=Steward database backup
Documentation=file:///usr/local/share/doc/steward/docs/operations.md
# Nothing to back up before 'stewardd init'.
ConditionPathExists=/var/lib/steward/steward.db
[Service]
Type=oneshot
ExecStart=/usr/local/bin/stewardd --config /etc/steward/steward.yaml backup
User=steward
Group=steward
UMask=0077
Nice=10
IOSchedulingClass=idle
# If you change backup.dir in steward.yaml, allow the new one too:
# 'systemctl edit steward-backup.service' and add ReadWritePaths=/new/dir.
ProtectSystem=strict
ReadWritePaths=/var/lib/steward -/var/backups/steward
ProtectHome=yes
PrivateTmp=yes
PrivateDevices=yes
PrivateNetwork=yes
NoNewPrivileges=yes
CapabilityBoundingSet=
ProtectKernelTunables=yes
ProtectKernelModules=yes
ProtectKernelLogs=yes
ProtectControlGroups=yes
ProtectClock=yes
ProtectHostname=yes
RestrictNamespaces=yes
RestrictRealtime=yes
RestrictSUIDSGID=yes
LockPersonality=yes
MemoryDenyWriteExecute=yes
RestrictAddressFamilies=AF_UNIX
SystemCallArchitectures=native
SystemCallFilter=@system-service
SystemCallErrorNumber=EPERM
+20
View File
@@ -0,0 +1,20 @@
# Steward: runs steward-backup.service (a database backup) every day.
# Installed as /etc/systemd/system/steward-backup.timer. Change the schedule
# with 'systemctl edit steward-backup.timer', e.g.
# [Timer]
# OnCalendar=
# OnCalendar=*-*-* 02:30
# and keep backup.retention in steward.yaml above the new interval.
[Unit]
Description=Daily Steward database backup
Documentation=file:///usr/local/share/doc/steward/docs/operations.md
[Timer]
OnCalendar=daily
# Spread the start over an hour, and catch up on a run missed while the
# machine was off.
RandomizedDelaySec=1h
Persistent=true
[Install]
WantedBy=timers.target
+63
View File
@@ -0,0 +1,63 @@
# Steward: the DHCP server, its REST API and web UI.
# Installed as /etc/systemd/system/steward.service (see docs/install.md).
[Unit]
Description=Steward DHCP server (with web UI and API)
Documentation=file:///usr/local/share/doc/steward/README.md
After=network-online.target
Wants=network-online.target
[Service]
Type=notify
NotifyAccess=main
ExecStart=/usr/local/bin/stewardd --config /etc/steward/steward.yaml serve
# SIGHUP rereads the TLS certificate.
ExecReload=/bin/kill -HUP $MAINPID
Restart=on-failure
RestartSec=2s
User=steward
Group=steward
UMask=0027
# /var/lib/steward: the database (configuration and leases).
StateDirectory=steward
StateDirectoryMode=0750
ConfigurationDirectory=steward
ConfigurationDirectoryMode=0750
# /run/steward: the local API socket (steward.sock), for root and the
# steward user.
RuntimeDirectory=steward
RuntimeDirectoryMode=0750
# Sandboxing: stewardd writes only its own state.
ProtectSystem=strict
ProtectHome=yes
PrivateTmp=yes
PrivateDevices=yes
NoNewPrivileges=yes
# The only privilege stewardd gets: listening on ports below 1024 (DHCP's
# port 67). Binding each socket to its interface (SO_BINDTODEVICE) and the
# ping check (an unprivileged ping socket) need nothing more.
CapabilityBoundingSet=CAP_NET_BIND_SERVICE
AmbientCapabilities=CAP_NET_BIND_SERVICE
ProtectKernelTunables=yes
ProtectKernelModules=yes
ProtectKernelLogs=yes
ProtectControlGroups=yes
ProtectClock=yes
ProtectHostname=yes
RestrictNamespaces=yes
RestrictRealtime=yes
RestrictSUIDSGID=yes
LockPersonality=yes
MemoryDenyWriteExecute=yes
# AF_NETLINK lets stewardd read the interfaces and their addresses.
RestrictAddressFamilies=AF_UNIX AF_INET AF_INET6 AF_NETLINK
SystemCallArchitectures=native
SystemCallFilter=@system-service
SystemCallErrorNumber=EPERM
[Install]
WantedBy=multi-user.target
# 'systemctl restart stewardd' works too (the daemon's binary is stewardd).
Alias=stewardd.service
+2
View File
@@ -0,0 +1,2 @@
# Steward's system user (installed as /usr/lib/sysusers.d/steward.conf).
u steward - "Steward DHCP server" /var/lib/steward
+8
View File
@@ -0,0 +1,8 @@
# Directories Steward needs (installed as /usr/lib/tmpfiles.d/steward.conf).
# Apply with: systemd-tmpfiles --create steward.conf
#
# Type Path Mode User Group
d /etc/steward 0750 root steward
d /var/lib/steward 0750 steward steward
# Database backups (steward-backup.timer; backup.dir in steward.yaml).
d /var/backups/steward 0700 steward steward