Commits
- Commit:
62bc6ad6d22682fe40cccf5536d7f746bc0d83e2- From:
- Alisdair MacLeod <git@alisdairmacleod.co.uk>
- Date:
migrate off github
- Commit:
aa3d42441d6a7314454191888aeac21682cf2cfe- From:
- Alisdair MacLeod <git@alisdairmacleod.co.uk>
- Date:
Portability: Add shims for timingsafe_bcmp, arc4random_buf, and timegm
- Commit:
efaf222244a17c530f5e2150244957d925fbb58a- From:
- Alisdair MacLeod <git@alisdairmacleod.co.uk>
- Date:
Cleanup: Remove unused database queries and add strsep shim
- Commit:
cf0bb562ad08cfea921890bb5060eb1cd68f8023- From:
- Alisdair MacLeod <git@alisdairmacleod.co.uk>
- Date:
Batch safe characters in cgi_html_escape with fwrite
Instead of calling fputc for each non-special character, track
runs of safe characters and emit them in a single fwrite call.
Reduces function call overhead for typical alphanumeric inputs.
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
- Commit:
d5d6368fec7b23d11d7729deb2291eb9c7751b58- From:
- Alisdair MacLeod <git@alisdairmacleod.co.uk>
- Date:
Add index on bookings(day) for day-specific queries
The existing UNIQUE indexes have (desk, day) and (user, day) as
their column order, so queries that filter by day alone cannot
seek directly. This index lets the day bookings and LEFT JOIN
queries use an index scan instead of a full table scan.
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
- Commit:
22f3a7ce67aefccfc7d2c6871c9168ec89319e29- From:
- Alisdair MacLeod <git@alisdairmacleod.co.uk>
- Date:
Combine bookingform's two queries into a single LEFT JOIN
The booking form page previously ran separate queries for day
bookings and available desks, each requiring its own
prepare/bind/step/finalize cycle. A single LEFT JOIN query
returns all desks with their booking status in one pass,
halving the SQLite overhead for this route.
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
- Commit:
77f906b3cf1c549a28c0cd767e2244e470f598bf- From:
- Alisdair MacLeod <git@alisdairmacleod.co.uk>
- Date:
Use stack buffer for URI path copy instead of strdup
CGI request URIs are short (the longest valid path is
/book/YYYY-MM-DD at 16 characters). A 256-byte stack buffer
avoids one heap allocation per request.
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
- Commit:
b91d801835eb928cf8379ebefe2add66ed98f61c- From:
- Alisdair MacLeod <git@alisdairmacleod.co.uk>
- Date:
Use stack buffer for POST body instead of heap allocation
MAX_BODY is 4096, well within stack limits. The content_length
check already ensures the read will not overflow. This avoids a
malloc/free pair on every POST request.
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
- Commit:
a35d82dbb6d02edf3c6e603e21a30fde949599ca- From:
- Alisdair MacLeod <git@alisdairmacleod.co.uk>
- Date:
Remove -lpthread from default LDFLAGS
deskd is single-threaded. On macOS the shared SQLite library
resolves pthread symbols through its own linkage. On OpenBSD
with static linking the linker pulls in only the symbols that
SQLite actually references; if the static build fails, restore
-lpthread via the LDFLAGS override.
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
- Commit:
8f34b0f4f187ee290cf1095cc20b67197f0995b5- From:
- Alisdair MacLeod <git@alisdairmacleod.co.uk>
- Date:
Remove unused -lm from LDFLAGS
No application code uses math.h functions. On a static build the
linker would only pull in referenced symbols, but removing the
flag avoids unnecessary library scanning during the link step.
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
- Commit:
ff0a1945f4ecd2b95886d5b5f6cc48c4970cbe2b- From:
- Alisdair MacLeod <git@alisdairmacleod.co.uk>
- Date:
Use hex lookup table instead of snprintf for CSRF token encoding
Replace 16 snprintf("%02x") calls with direct table lookups.
snprintf parses the format string on every iteration; the lookup
table converts each byte to two hex characters with simple shifts
and masks.
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
- Commit:
41a02e31da797206529ed55ab14333524a6f10f1- From:
- Alisdair MacLeod <git@alisdairmacleod.co.uk>
- Date:
Enable -Os optimization for smaller binary output
The default optimization level (-O0) leaves dead code and misses
size-reducing transformations. -Os is preferred over -O2 as it
avoids aggressive inlining and loop unrolling that inflate the
binary, which matters for a statically linked CGI deployment.
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
- Commit:
3662c36f8b9e00bf7bc822238a379e542b15320e- From:
- Alisdair MacLeod <git@alisdairmacleod.co.uk>
- Date:
Buffer stdout to reduce write(2) syscalls per CGI response
CGI route handlers make dozens of small printf/fputs calls. Under
the CGI model stdout is piped to the web server and line-buffered
by default, so each newline triggers a separate write(2) syscall.
Switching to full buffering batches the entire response into one
or two writes that flush when the process exits.
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
- Commit:
89b827214e68c971373e4ceca0eeb36663ab6b02- From:
- Alisdair MacLeod <git@alisdairmacleod.co.uk>
- Via:
- Alisdair MacLeod <131350026+admacleod@users.noreply.github.com>
- Date:
Redirect unknown routes to home page instead of returning 404
Users with old bookmarks or shortcuts were getting a plain-text 404
error after d3b734c. Use a 302 temporary redirect to / so they land
on the bookings page instead, without permanently caching the redirect.
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
- Commit:
13e4d4f78b59136f0e590fbb4cb79a4c94551576- From:
- Alisdair MacLeod <git@alisdairmacleod.co.uk>
- Via:
- Alisdair MacLeod <131350026+admacleod@users.noreply.github.com>
- Date:
Unveil /dev/urandom and SQLITE_TMPDIR for SQLite on OpenBSD
SQLite internally opens /dev/urandom to seed its PRNG and searches
/var/tmp, /usr/tmp, /tmp for temporary files. Both are blocked by
the unveil sandbox, producing spurious accounting log entries.
Unveil /dev/urandom unconditionally so SQLite gets proper entropy
instead of falling back to time()+getpid(). For temp files, unveil
the path in SQLITE_TMPDIR when set, letting deployers point it at
the database directory already inside the chroot.
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
- Commit:
01e922766d6d214c765b616653c460adbd97d277- From:
- Alisdair MacLeod <git@alisdairmacleod.co.uk>
- Via:
- Alisdair MacLeod <131350026+admacleod@users.noreply.github.com>
- Date:
Modernize C style: declarations at point-of-use and const qualifiers
Move variable declarations from top-of-block to point of first use
(C99/C23 style), add const qualifiers to locals and value parameters
where appropriate, and remove #include directives made redundant by
transitive includes through project headers.
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
- Commit:
ef786819d823cd662e0e6261c2c9ed7c1e581be7- From:
- Alisdair MacLeod <git@alisdairmacleod.co.uk>
- Via:
- Alisdair MacLeod <131350026+admacleod@users.noreply.github.com>
- Date:
Replace vmactions/openbsd-vm with cross-platform-actions/action
vmactions/openbsd-vm has a known reliability issue (vmactions/openbsd-vm#11)
where the SSH connection to the VM drops mid-test, causing SIGPIPE failures.
cross-platform-actions/action is faster and more stable.
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
- Commit:
50af281a189d13ce6e0d8bd8c06798ec2181338e- From:
- Alisdair MacLeod <git@alisdairmacleod.co.uk>
- Via:
- Alisdair MacLeod <131350026+admacleod@users.noreply.github.com>
- Date:
Refactor routing to branch on path first, then method
The flat if/else chain checked (method, path) pairs and required a
separate block that re-enumerated every known path for the 405 case.
Restructure as nested branches: outer level matches path, inner
level matches method with a per-path else → 405 fallback. This
makes each route self-contained so new paths cannot accidentally
miss the 405 case.
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
- Commit:
d3b734c59c04287dfb0438550d99c8f1b69c06c0- From:
- Alisdair MacLeod <git@alisdairmacleod.co.uk>
- Via:
- Alisdair MacLeod <131350026+admacleod@users.noreply.github.com>
- Date:
Return 404 for unknown routes and 405 for unsupported methods
The catch-all in the request router previously returned 400 for both
unknown paths and unsupported methods. Split it into two branches:
known paths with the wrong method now return 405 Method Not Allowed,
and unrecognised paths return 404 Not Found.
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
- Commit:
d421a781300d0f29c6f8fb47e6c438e19823e255- From:
- Alisdair MacLeod <git@alisdairmacleod.co.uk>
- Via:
- Alisdair MacLeod <131350026+admacleod@users.noreply.github.com>
- Date:
Update routing tests to expect correct HTTP status codes
Change route-unknown to expect 404 Not Found instead of 400, and
route-wrong-method to expect 405 Method Not Allowed instead of 400.
These tests will fail until the routing logic in deskd.c is updated
to distinguish unknown paths from unsupported methods.
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
- Commit:
2895fd6ddcae6c90b53efeaf9f56e9cc0e748689- From:
- Alisdair MacLeod <git@alisdairmacleod.co.uk>
- Via:
- Alisdair MacLeod <131350026+admacleod@users.noreply.github.com>
- Date:
Add 12 missing integration test cases
Cover previously untested code paths: routing catch-all (unknown
routes, wrong methods), missing CSRF cookie (vs mismatch), missing
day parameter in cancel form, empty request body on book, cancel of
non-existent booking, past-booking filtering on the bookings page,
empty day query parameter on dateform, no-desks-configured edge case
on bookingform, and HTML escaping of desk names and usernames to
guard against XSS regressions.
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
- Commit:
c64c0d1524ca88914520c823d244c150e24926dc- From:
- Alisdair MacLeod <git@alisdairmacleod.co.uk>
- Via:
- Alisdair MacLeod <131350026+admacleod@users.noreply.github.com>
- Date:
Statically link deskd for chroot deployment
The binary runs inside an OpenBSD httpd chroot with no access to
shared libraries. Add -static to the default link flags via a
LDFLAGS_STATIC variable that can be overridden (e.g. LDFLAGS_STATIC=
on macOS where static linking is not supported).
SQLite's static library depends on pthread and math, so add -lpthread
and -lm to the link flags.
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
- Commit:
4cc61ea32e287e330ce1c4c965bdafefe43695dc- From:
- Alisdair MacLeod <git@alisdairmacleod.co.uk>
- Via:
- Alisdair MacLeod <131350026+admacleod@users.noreply.github.com>
- Date:
Add make test recipe and simplify CI to use it
Add a test target that depends on the deskd binary and runs the
integration test suite. Simplify the CI workflow to just make test.
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
- Commit:
e2fff6102aa98dcb31c0df10189d4734573b53d2- From:
- Alisdair MacLeod <git@alisdairmacleod.co.uk>
- Via:
- Alisdair MacLeod <131350026+admacleod@users.noreply.github.com>
- Date:
Update actions/checkout to v6
v4 uses Node.js 20 which is deprecated on GitHub Actions runners
and will be forced to Node.js 24 starting June 2026.
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
- Commit:
61e578392ff6b798d3ac93bd416ad55b80b5171d- From:
- Alisdair MacLeod <git@alisdairmacleod.co.uk>
- Via:
- Alisdair MacLeod <131350026+admacleod@users.noreply.github.com>
- Date:
Document unveil and pledge rationale in main()
Expand comments to explain why the database parent directory is
unveiled rather than the file itself, why unveil(NULL, NULL) locks
the path list, and why fattr is included in the pledge promises.
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
