diff --git a/AGENTS.template.md b/AGENTS.template.md index 0865356..91de608 100644 --- a/AGENTS.template.md +++ b/AGENTS.template.md @@ -167,7 +167,7 @@ These were decided deliberately. Do not undo them without the maintainer's say-s - The linter loads `libclang` at runtime by name. `CRAFTER_BUILD_LIBCLANG` pins an exact path and must fail loudly when wrong, never fall back to another library. - crafter-build's Flatpak has `--talk-name=org.freedesktop.Flatpak`, and the permission is the whole sandbox's: anything that runs there can run commands on the host through `flatpak-spawn --host`. That is every process of crafter-build's sandbox: crafter-build itself, every `project.cpp` it loads with its scripts, the builds of its dependencies and pragma dependencies, the programs `-r` and `test` start, and whatever `flatpak run --command=` and `flatpak enter` start in it, the debuggers of the README's Debugging section and the programs under them included. crafter-build's own code uses it only through `HostCommand` in `:Platform`, which builds the command lines of `RunHostFlatpak`, `RunHostFlatpakBuilder` and `HostFlatpakUnavailable`'s probes, for the host's `flatpak` and `flatpak-builder` behind `install` and `bundle`; add no other host command to crafter-build. `RunHostFlatpak` is exported for the tests, and gives a `project.cpp` nothing the sandbox does not. The trust model allows the permission because `--filesystem=host` already lets sandboxed code write `~/.bashrc`, `~/.config/autostart` and `~/.config/systemd/user`: it makes running something on the host immediate, not newly possible, for everything the sandbox runs. - CI creates a release for each release tag with the workflow's own token, pushes nothing to git, and signs the Flatpak repo with the key mounted from the runner host. Do not add secrets to the workflow or echo the environment in it. -- Tests write only under `fs::temp_directory_path()` and the fixture's own `bin/` and `build/`, and in the caches of what they run, unless they point `XDG_CACHE_HOME` elsewhere: crafter-build's, what a build puts there, and wasmtime's, the modules the wasm tests run. Keep it that way. Two tests write elsewhere, and both remove what they make: `tests/HeadlessCompositor`, which makes its compositors' directories in a directory of its own in `$XDG_RUNTIME_DIR`, or in `/tmp` when that is not a directory, and has one made in `/tmp` itself, as crafter-build makes it where there is no `$XDG_RUNTIME_DIR`, because a socket's path holds 107 bytes and a temp directory's path can use them up, and a later run removes what a killed run of it left once that has not changed for a minute (`PrivateDirectory`); and `tests/HostFlatpak`, which in the Flatpak makes its two projects in the sandbox's `/tmp`, the place it asks the host about, under fixed names, so that its next run that makes them removes what a killed one left. +- Tests write only under `fs::temp_directory_path()` and the fixture's own `bin/` and `build/`, and in the caches of what they run, unless they point `XDG_CACHE_HOME` elsewhere: crafter-build's, what a build puts there, and wasmtime's, the modules the wasm tests run. Keep it that way. Two tests write elsewhere, and both remove what they make, and a later run removes what a killed one left once that has not changed for a minute (`PrivateDirectory`): `tests/HeadlessCompositor`, which makes its compositors' directories in a directory of its own in `$XDG_RUNTIME_DIR`, or in `/tmp` when that is not a directory, and has one made in `/tmp` itself, as crafter-build makes it where there is no `$XDG_RUNTIME_DIR`, because a socket's path holds 107 bytes and a temp directory's path can use them up; and `tests/HostFlatpak`, which in the Flatpak makes a directory of its own in the sandbox's `/tmp`, the place it asks the host about. ## CI and publishing diff --git a/tests/HostFlatpak/main.cpp b/tests/HostFlatpak/main.cpp index 7aba938..9ffdb38 100644 --- a/tests/HostFlatpak/main.cpp +++ b/tests/HostFlatpak/main.cpp @@ -79,11 +79,18 @@ int main() { } at = info.find("filesystems=", at + 1); } + // Both in a directory of this run's own there, a PrivateDirectory, + // removed at the end of this block: every sandbox of the app has the + // same /tmp, so two runs at once would ask about, and remove, the + // same projects, and what a run that is killed leaves goes when a + // later one is made, once it has not changed for a minute. + const PrivateDirectory own("/tmp", "crafter-build-host-flatpak-"); + const fs::path& scratch = own.path; const fs::path link = fixture / "build" / "to-tmp"; fs::create_directories(link.parent_path(), ec); fs::remove(link, ec); - fs::create_directory_symlink("/tmp", link, ec); - const std::array unseen = {"/tmp/crafter-build-host-flatpak", link / "crafter-build-host-flatpak-linked"}; + fs::create_directory_symlink(scratch, link, ec); + const std::array unseen = {scratch / "project", link / "linked"}; for (const fs::path& project : unseen) { if (tmpShared) { std::println("an override shares the host's /tmp with the sandbox, so the host sees {}: left out", project.string()); @@ -100,6 +107,8 @@ int main() { Check(fs::is_empty(project, ec), std::format("and asking leaves nothing in {}", project.string())); fs::remove_all(fs::weakly_canonical(project, ec), ec); } + // The link goes with the directory it leads to. + fs::remove(link, ec); // From a working directory only the sandbox has, the host is reached // all the same, and sees the fixture. if (permitted) {