瀏覽代碼

build(mail): trim the vendored curl to what mail reaches, and declare the deps

Two defects that would only have surfaced on a customer box.

The deb Depends lists are hand-maintained: create-debs.sh copies each
control template verbatim and never runs dpkg-shlibdeps, so a new shared
library does not appear by itself. The runner needs ca-certificates,
because the vendored curl detects the CA bundle at CONFIGURE time and
bakes the path in, and TLS verification is on and never relaxed - without
that file every mail connection fails as mail_tls_untrusted, which reads
as a broken mail server rather than a missing package. It also needs
libidn2-0, since the vendored curl keeps IDN support. Both confirmed with
ldd against the built binary rather than reasoned about.

zlib, zstd and brotli are now off. They are HTTP content encodings and
HTTP is compiled out, so they could never be reached, but curl found them
on the build host and they had become real dependencies of the package
for capabilities the code cannot use. ldd confirms the binary no longer
links any of them, and curl's feature line no longer advertises them.

IDN is deliberately NOT compiled out. Mail hostnames are usually ASCII,
but breaking an internationalised one to save a dependency is the wrong
trade.

405 tests pass against the vendored build with the trimmed configuration.
fszontagh 1 月之前
父節點
當前提交
fa26da34a8
共有 3 個文件被更改,包括 16 次插入 和 1 次删除
  1. 1 0
      CLAUDE.md
  2. 1 1
      packaging/deb/templates/control.runner
  3. 14 0
      runner/CMakeLists.txt

+ 1 - 0
CLAUDE.md

@@ -131,6 +131,7 @@ docker run -d --name svapi-dev -p 8080:8080 -e SMARTBOTIC_VECTORAPI_KEY=dev svap
 - **QuickJS is pinned to an exact quickjs-ng tag** (`SVAPI_QUICKJS_TAG`, `runner/CMakeLists.txt`). QuickJS bytecode carries **no version stamp**, so a silent upgrade makes a cached blob *misread* rather than fail. quickjs-ng, not Bellard's tree: the module/promise/stack entry points the core needs (`JS_GetModuleNamespace`, `JS_PromiseState`, `JS_SetMaxStackSize`, `JS_IsJobPending`) are public API there. `JsBytecode` is an in-process cache only - never persist it without a QuickJS build fingerprint.
 - **QuickJS's job queue belongs to the `JSRuntime`, not the `JSContext`.** A fresh context per run is therefore *not* enough to isolate tenants: a run that times out mid-microtask leaves its jobs queued, and they would execute inside the next tenant's run. The core flushes them with the deadline forced into the past and marks the runtime `poisoned()` if anything survives; the pool destroys a poisoned runtime instead of leasing it out. An OOM poisons it too.
 - **`/etc/smartbotic-vectorapi` must stay mode 0751, not 0750.** The runner runs as its own user and needs `+x` to traverse the directory to `runner.json`; it still cannot list it, and the server's `0640` files stay unreadable to it. Both `server.postinst` and `runner.postinst` set it, and a server upgrade resetting it to `0750` breaks the runner on its **next restart** - a failure that surfaces weeks later with no obvious cause.
+- **The deb `Depends` lists are HAND-MAINTAINED** - `create-debs.sh` copies each `control.*` template verbatim and never runs `dpkg-shlibdeps`, so a new shared-library dependency does **not** appear by itself; it surfaces as a service that refuses to start on a customer box. The mail surface added two to `control.runner`, both confirmed with `ldd` against the built binary rather than guessed: **`ca-certificates`**, because the vendored curl detects the CA bundle at CONFIGURE time and bakes the path in, and with TLS verification always on a missing bundle makes *every* mail connection fail as `mail_tls_untrusted` (which reads as a broken mail server, not a missing package); and **`libidn2-0`**, because the vendored curl keeps IDN support. IDN is deliberately not compiled out - mail hostnames are usually ASCII, but breaking an internationalised one to save a dependency is the wrong trade. **zlib, zstd and brotli are deliberately absent**: they are HTTP content encodings, HTTP is compiled out of the vendored curl, and leaving them enabled made them real package dependencies for capabilities the code cannot reach.
 - **Installing the runner does not enable functions.** `config.json` ships with no `functions.runners` endpoints, and the server disables the function routes when the list is empty (answering 503). An operator has to add the endpoint by hand, and set the same `SVAPI_RUNNER_TOKEN` in both `vectorapi.env` and `runner.env`.
 - **cpp-httplib is pinned (`cmake/Dependencies.cmake`) and the pin carries its reasoning.** Currently v0.59.0. Check for an upgrade periodically: it serves the public HTTP surface AND every outbound call, upstream ships security fixes most releases, and we were 17 releases behind before anyone looked. When evaluating one, judge each fix against **what this service actually reaches** rather than the changelog's severity - `CPPHTTPLIB_REQUEST_URI_MAX_LENGTH` (8192, enforced before routing) means a long-path attack answers 414 before routing and never reaches the regex matcher, so the headline regex stack-overflow fix was never our exposure (verified against a running server, after first proving which process held the port - an earlier run of this test hit an unrelated service listening on the port I had picked), while the request-PARSING fixes (chunked transfer-coding matching, Content-Length truncation, chunk-size control characters) are. Deliberately NOT on the newest release when its fixes are for backends or features we do not use.
 - **Monaco** is bundled locally (`webui/src/monacoSetup.ts`) so the editor works offline - do not revert to the CDN loader.

+ 1 - 1
packaging/deb/templates/control.runner

@@ -12,7 +12,7 @@ Description: Smartbotic VectorAPI - server-side function runner
 Homepage: https://smartbotics.ai
 Section: contrib/utils
 Priority: optional
-Depends: libsmartbotic-db-client (>= 2.12.0), libssl3t64, libsystemd0, libspdlog1.15, tzdata
+Depends: libsmartbotic-db-client (>= 2.12.0), libssl3t64, libsystemd0, libspdlog1.15, tzdata, ca-certificates, libidn2-0
 Recommends: smartbotic-vectorapi (= {{VERSION}})
 Breaks: smartbotic-vectorapi (<< {{UPSTREAM_VERSION}})
 Installed-Size: {{INSTALLED_SIZE}}

+ 14 - 0
runner/CMakeLists.txt

@@ -109,6 +109,14 @@ if(SVAPI_VENDOR_CURL)
     set(USE_NGTCP2 OFF CACHE BOOL "" FORCE)
     set(USE_QUICHE OFF CACHE BOOL "" FORCE)
     set(CURL_DISABLE_NTLM ON CACHE BOOL "" FORCE)
+    # zlib, zstd and brotli are HTTP CONTENT ENCODINGS. With HTTP compiled out
+    # they can never be reached, and left enabled they are found on the build
+    # host and become real shared-library dependencies of the .deb for no
+    # benefit. Turned off so the package's dependency list matches what the
+    # code can actually use.
+    set(CURL_ZLIB OFF CACHE STRING "" FORCE)
+    set(CURL_ZSTD OFF CACHE STRING "" FORCE)
+    set(CURL_BROTLI OFF CACHE STRING "" FORCE)
     # HTTP is compiled OUT on purpose. ctx.fetch is cpp-httplib, with its own
     # SSRF guard, its own address pinning and its own outbound defaults; two
     # HTTP clients with two sets of defaults is exactly how the two drift.
@@ -150,6 +158,12 @@ if(SVAPI_VENDOR_CURL)
             GIT_SHALLOW    TRUE)
     endif()
     FetchContent_MakeAvailable(curl)
+    # curl detects the CA bundle AT CONFIGURE TIME and bakes the path in
+    # (/etc/ssl/certs/ca-certificates.crt on Debian, which is the release build
+    # host and the target both). TLS verification is on and never relaxed, so
+    # without that file EVERY mail connection fails as mail_tls_untrusted - a
+    # failure that looks like a broken server rather than a missing package.
+    # That is why the runner package depends on ca-certificates.
     set(SVAPI_CURL_TARGET CURL::libcurl)
 else()
     # The escape hatch, and what the dev loop uses: a system libcurl builds in