From f282a74e59bc76420b346d10626413f490a2844f Mon Sep 17 00:00:00 2001 From: jochen Date: Mon, 23 Nov 2026 12:26:39 +0100 Subject: [PATCH] gitea: the patch spool is read by the module's own account Review round 1: since gitea runs as its own account, the tools no longer run as the machine's account that owns the forge-patches directory; they read and remove the named file as any other account may. Builds: design 47 H2 H-A-543 --- modules/gitea/README.md | 5 +++-- modules/gitea/cmd/forge/patchfile.go | 2 +- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/modules/gitea/README.md b/modules/gitea/README.md index 321c54e1f..2da6d395a 100644 --- a/modules/gitea/README.md +++ b/modules/gitea/README.md @@ -72,8 +72,9 @@ Approve names. **A patch too large to type** (novox/hq issue 852: a feature's diff is megabytes) goes as `patch_file`, with `patch_sha256`. The caller writes the patch into the module's spool directory `forge-patches` -(`/var/lib/mesh/forge-patches`, mode 0733 and owned by the machine's account, which the tools run as: anyone writes, -nobody lists; the bundle is given its path as `MESH_GITEA_PATCH_DIR`) and names it: `patch_file` is the file's NAME, +(`/var/lib/mesh/forge-patches`, mode 0733 and owned by the machine's account: anyone writes, nobody lists, and the +tools, which run as the module's own account gitea, read and remove the named file as any other account may; the bundle +is given its path as `MESH_GITEA_PATCH_DIR`) and names it: `patch_file` is the file's NAME, 32 to 64 characters of `0-9a-f` that the caller chooses at random, never a path. The tool then reads that one file, applies it exactly as it applies `patch` (same size limit, same answer) and removes it once it has found it, whether the commit was made or not. A file refused before that (a bad name, a missing hash or spool directory, a name with no diff --git a/modules/gitea/cmd/forge/patchfile.go b/modules/gitea/cmd/forge/patchfile.go index ba040f916..0a4b0fa7c 100644 --- a/modules/gitea/cmd/forge/patchfile.go +++ b/modules/gitea/cmd/forge/patchfile.go @@ -15,7 +15,7 @@ import ( // A patch too large to type into a call is handed over as a file (novox/hq issue 852). The caller writes it into // one spool directory the module declares (mode 0733: anyone writes, nobody lists) and names it in patch_file, -// with the file's SHA-256. The tool runs as the machine's account, so it reads nothing but that directory: the +// with the file's SHA-256. The tool runs as the module's own account gitea, and reads nothing but that directory: the // name is 32 to 64 characters of [0-9a-f], so it holds no separator and no dot; the file must be a regular file // (never a symlink); and its hash must be the caller's, because without the sticky bit another writer could have // replaced it. The file is removed once taken, whether the commit was made or not.