Repository navigation
fix(sandbox): support rootless Podman and refuse rootless Docker - #57
Merged
Merged
Conversation
nishide-dev
marked this pull request as ready for review
October 3, 2026 20:37
nishide-dev
commented
Oct 3, 2026
nishide-dev
left a comment
Owner
Author
There was a problem hiding this comment.
Verdict: APPROVE
#47 の受け入れ条件(rootless Podman の CI job、Podman 固有の差の修正、capability の中からの確認、rootless Docker の扱いの決定)を満たしています。must-fix / should-fix はありません。nit を下に挙げます。
確認したこと
- ゲート(clone した PR branch):
cargo fmt --check、cargo clippy --workspace --all-targets --all-features --locked -D warnings、cargo test --workspace --all-features --lockedは全て通過。 - Docker(OrbStack、
texrun-engine:latestを build し直し)でTEXRUN_REQUIRE_SANDBOX=1 TEXRUN_REQUIRE_TEXLIVE=1 TEXRUN_TEST_BACKEND=containerの container test 一式(texrun-sandbox42 + 21、texrun-texlivecontainer 14 / scenarios 11 / security 14、texrun-previewcontainer 4 / real_tools 13、CLI container 8)が通過、label 付きの container の残り 0。退行はありません。 - CI の
sandbox (podman): 委譲後のcgroup.controllersがcpuset cpu io memory pids、podman infoがrootless=true cgroups=v2 manager=systemd、crun。test の件数はsandbox(Docker)job と全て同じで ignored 0、container の残り無し。job 全体で約 2 分 30 秒。 - #58 との衝突:
git merge-treeではdocs/development.mdの隣接行(残った container の手での削除の段落)だけが衝突し、コードは自動で merge できます。後から merge する側で 1 段落を手で直す程度です。
観点ごとの評価
capability の確認
- shell が
execの前に自分の/proc/self/statusを読む方式は妥当です。no-new-privilegesと空の bounding set の下ではexec後に capability は増えず(file capability も setuid も効かない)、shell の Cap* が全て 0 ならexec後のプログラムも 0 です。非 root でCapEffが元から空になる点を踏まえてCapBndまで見ているのも正しいです。 - 最初の行の出どころ: 行は対象のプログラムの起動前に書かれ、stdout の先頭に
MARKERがあることを要求しているので、プログラムが偽の行を先に出すことはできません。probe では外側のREPORT_PIDSの shell と--initは stdout に何も書かないので、先頭は reporting shell の出力に限られます。/proc/self/statusが読めない・項目が欠けるなどの場合もREQUIREDの欠落で fail-closed になります。行は検査結果に関わらず除去されるので、program の stdout は壊れません(unit test あり)。 - probe と
Session::startで確認し、compile ごとには確認しない点: 確かめている性質は「この runtime がこの flag の組をどう適用するか」で、compile の container は probe と同じcontainer_spec(mount 以外同一)で作られ、CLI は必ず compile の前に probe するので、妥当だと考えます(nit 1 を参照)。preview は実際に使うexecの経路で確かめているのも良いです。
Podman 固有の修正
--unsetenv-all --http-proxy=falseで env が allowlist +HOSTNAMEになることは、既存のthe_container_is_isolated_and_unprivilegedとセッションの test のHOME HOSTNAME PATH PWDの完全一致で Podman でも確認されています。明示の--envは--unsetenv-allの対象外なので、spec の env は残ります。- OOM:
memory.eventsのoom_killは subtree の集計なので、container の cgroup 全体の OOM kill を数えられます。container の中の shell による報告なので助言的な情報であり、偽れるのはその文書自身の diagnostic だけ、Docker では runtime の記録との OR なので隠すこともできない、という整理は §2 の既存の pids の扱いと一貫しています。take_pids_reportをoutcome()より前に呼ぶようprocess.rsの順序を変えた点も正しいです。 - image の ID と HostConfig の Podman 表記: test の修正と docs の記述は CI の実測と合っています。
rootless の runtime の検出
- rootless Docker:
SecurityOptionsのname=rootlessで判定し、出力が想定外ならUnavailable(fail-closed)。autoではdetectが理由を残して Podman に進み、Podman も無ければ両方の理由が message に並びます。理由と代わり(rootless Podman か root の daemon)を示す message も分かりやすいです。 - rootless Podman: cgroup v2 と memory / pids / cpu の委譲を検出時に確認し、足りないものを message に出します。仮にすり抜けても
HostConfigの照合で fail-closed になる、という二重化の説明も正確です。
CI job
- Docker を止めて
docker versionが失敗することを確かめる手順、[email protected]のDelegate=の drop-in、linger とuser@の restart、XDG_RUNTIME_DIR/DBUS_SESSION_BUS_ADDRESSの設定は適切です。controller が足りなければ texrun 自身の検出がTEXRUN_REQUIRE_SANDBOX=1で test を落とすので、step で別に assert しなくても検出できます。 permissions: contents: readのまま、persist-credentials: false、action は SHA 固定、ci-successのneedsに追加、ifもsandboxjob と同じで、問題ありません。
nit
- probe を経ない library 利用では capability を中から確かめない。
ContainerEngine::run/compileは probe 無しでも呼べ、その場合 Podman ではHostConfigの「CapDrop が空でない」だけになります。現状の呼び出し元は CLI だけで、CLI は必ず probe するので実害はありません。ContainerEngineの doc に「capability の確認はprobeで行うので、compile の前に probe すること」を 1 文足すか、runで probe が成功していなければ(versionがNoneなら)先に probe する、のどちらかを推奨します。 Session::oom_killedの Podman の経路のコスト。container_limit_exceededは最大 10 回 poll するので、Podman ではinspectとexec(timeout 10 秒)が最大 10 回ずつ走ります。SIGKILLの後だけなので通常は問題になりませんが、execが詰まった場合に最悪で長く待つことになります。Podman の場合はoom_kill_countを 1 回だけ読む(counter は kill の時点で既に増えているので、poll の必要は Docker の非同期な記録ほど無い)か、poll 全体に時間の上限を設けると良さそうです。また counter は session 全体の累計なので、ある tool が OOM になった後に別の理由でSIGKILLされた tool も OOM と報告されます。気になるなら tool の実行前の値と比べる方法があります(助言的な情報なので、doc に一言でも十分です)。- test の対称性。 session の isolation test(
crates/texrun-sandbox/tests/container.rsの exec の方)はcapeffだけを見ていて、run の方に足したcapbndの assert がありません。Session::startの確認で覆われてはいますが、同じ 1 行を足すと対になります。同じ test の// The image's PATH and the runtime's HOSTNAME, besides the spec's.という comment は、Podman では--unsetenv-allで image のENVが入らなくなったので「spec のPATH」に直すと正確です(PR の差分外ですが、この PR で意味が変わったので)。 - #58 との衝突。 上記のとおり
docs/development.mdの 1 段落だけです。後に merge する側で、#58 の段落の書き換えとこの PR の「(Podman ではpodmanに読み替える)」の両方を残してください。
…odman Co-Authored-By: Claude Opus 5.5 <[email protected]>
Co-Authored-By: Claude Opus 5.5 <[email protected]>
nishide-dev
force-pushed
the
ci/rootless-podman
branch
from
October 3, 2026 21:05
7372505 to
8268dd5
Compare
3 tasks
nishide-dev
added a commit
that referenced
this pull request
Oct 6, 2026
## 概要 `v*` の tag を push するだけで、検証 → engine image の公開 → **release notes 付き** の GitHub release の作成(source tar 添付)まで完了するようにする。release notes は前の版の tag から今回の tag までの commit(= squash merge した PR タイトル、Conventional Commits)を git-cliff で分類して生成し、インストール方法・image の tag / digest・`gh attestation verify`・source tar の説明を定型で付ける。既存 release の notes だけを作り直す workflow も追加する(v0.1.0 の notes を埋めるのに使う)。 ## 変更内容 - `cliff.toml`(新規): git-cliff の設定。type で分類(`feat` → Features / `fix` → Bug fixes / `perf` → Performance / `docs` → Documentation / `refactor`・`test`・`build`・`chore` → Other changes)。`chore(deps)` は Dependencies に「N dependency updates: #a, #b」の 1 行にまとめる(PR 番号はタイトル行の末尾の `(#N)` だけから取る。番号の無いものは件数にだけ数える)。`!` / `BREAKING CHANGE:` は Breaking changes にも載せる。Conventional でない commit も Other changes に残す。**すべての行は commit のタイトル(1 行目 = PR タイトル)だけから作り**、PR 本文や footer の文面は載せない。末尾の `(#N)` を PR へのリンクにし、`@name` は mention にならないよう code にし、前の版との compare リンクを付ける。 - `.github/scripts/release-notes-test.sh` / `release-notes-test.expected.md`(新規): 使い捨ての repository に main の squash merge と同じ形の fixture の commit(PR 本文付き、実際の Dependabot 形式の本文付き(単独・group)、PR 番号の無い `chore(deps)`、日本語の `BREAKING CHANGE:` footer + attribution、GitHub の Revert、`@name` を含むタイトル)を作り、notes の「What's changed」を期待値と比べる。PR の `notes` job で毎回実行する。 - `.github/scripts/release-notes.sh`(新規): `release-notes.sh <tag> [<digest>]` で notes の Markdown を出力する。 - 安定版は前の安定版から(間の prerelease を畳み込む: `--ignore-tags '^v.*-'`)、prerelease は直前の tag から、最初の版は全履歴。git-cliff の `--context` から対象 tag の release だけを選んで `--from-context` で描画するので、HEAD が tag より先(main)でも同じ notes になる。 - tag がまだ無い場合は「最後の tag 〜 HEAD」をその版としてプレビューする。digest を省略すると placeholder。 - tag が HEAD の祖先でない、semver でない、digest の形式が違う、対象の commit が無い、などはエラー。 - `.github/workflows/engine-image.yml` - `publish` が `digest` を output する。 - `release` が checkout(`fetch-depth: 0`)→ git-cliff(`taiki-e/install-action` を SHA pin、`[email protected]`。install-action が checksum を検証)→ notes 生成(job summary にも出す)→ release の作成(`--notes-file`。版に `-` があれば prerelease にする既存の扱いを維持)。 - release が既にある場合(手で作った / 再実行)は、notes を生成したもので **上書き** してから asset を upload する。 - `.github/workflows/release-notes.yml`(新規): notes の生成だけを行う workflow。image の公開・release の作成はしない。 - `pull_request`(`cliff.toml`・script・この workflow の変更時): fixture の test の後、PR の head commit(merge ref ではなく。`Merge … into …` の行が入らない)で、最後の tag(現状 v0.1.0、全履歴)の notes と、次の版(patch + 1)としての「最後の tag 以降」の notes を job summary と artifact `release-notes` に出す。digest は GHCR から引く(未公開の版は placeholder)。 - `workflow_dispatch`(`tag`、`update`): `update=false`(既定)は dry run。`update=true` は `gh release edit --notes-file` で既存 release の notes を置き換える(main か tag 上の実行のみ。image が GHCR に無い版は失敗)。 - 権限: 生成する `notes` job は `contents: read`。書き込む `update` job だけが `contents: write` で、repository の code は実行しない(artifact を受け取って `gh release edit` するだけ)。 - docs - `docs/development.md`: release 手順を「tag を push するだけ」に更新し、「release notes」節(分類の規則、notes の文面は PR タイトルで決まること、ローカルでの生成方法、作り直し方)を追加。 - `CONTRIBUTING.md`: PR タイトルが release notes の 1 行になること、type / description の書き方の注意、notes の PR check を追記。 - `docs/security.md`(権限の記述)、`docs/engine-image.md`(digest は release notes に載る)を追随。 ## 設計判断 - **git-cliff を採用**(GitHub の自動生成 + `.github/release.yml` ではなく): この repo は PR にラベルを付けない運用で、GitHub の自動生成はラベルでしか分類できない。git-cliff は commit の type で分類でき、PR タイトル = commit タイトルの運用にそのまま合う。API を使わず(`--offline`)git の履歴だけで決まるので、PR 上やローカルでも同じ結果を再現できる。 - **既存 release の notes は上書き**: notes は git の履歴と公開済みの digest から決定的に作られるので、再実行で上書きしても結果は同じ。手で先に release を作った場合も、生成した notes に揃える(docs に明記。公開後の手修正は、作り直すと消える)。 - **CHANGELOG.md は置かない**: tag ごとに CHANGELOG 更新の commit / PR が必要になり、運用が増えるため。GitHub release を changelog とし、必要なら同じ `cliff.toml` から `git cliff` でいつでも全履歴を出せる。 - **notes の作り直しは別 workflow**: engine-image.yml の `workflow_dispatch` は image の公開と結び付いているので、notes だけの経路を分けた。image は再公開せず、digest は GHCR にある既存の版から引く。 - **notes の生成は image の公開後**: digest が要るため `release` job で生成する。設定の誤りは PR 上の `Release notes / notes` で先に検出する。万一 `release` で失敗しても image は公開済みで、`gh run rerun --failed` でやり直せる(既存の手順どおり)。 - **git-cliff の版**: `2.14.2` を両 workflow で固定(install-action の manifest の sha256 で検証)。install-action 自体は SHA pin で、Dependabot の対象。 ## 確認方法 - [x] `actionlint`(全 workflow)、`shellcheck .github/scripts/release-notes.sh` - [x] ローカルで git-cliff 2.14.2(公式 release の tar を sha512 で確認)を使って生成 - `release-notes.sh v0.1.0 sha256:b611…` → 下記(v0.1.0 までの全履歴、32 commit) - `release-notes.sh v0.1.1` → v0.1.0 以降の差分(この PR の commit のみ)のプレビュー - 使い捨ての clone で `v0.2.0-rc.1` / `v0.2.0-rc.2` / `v0.2.0` を打って確認: rc.2 は rc.1 からの差分、v0.2.0 は v0.1.0 からの全部(rc の分を畳み込む)。tag が HEAD の祖先でない場合・semver でない tag・不正な digest はエラーになる - `release-notes-test.sh`: 期待値どおり(下記)。修正前の `cliff.toml` に戻して実行すると、Dependabot の行が `3 dependency updates (Dependabot):,,` に、Breaking changes が日本語の footer + `🤖 Generated with …` に、Revert の行が本文付きに、`@octocat` が mention になり、test が失敗することを確認した - レビュー対応の後も v0.1.0 の notes は変わらない(前回の出力と diff なし) - [x] `CONTRIBUTING.md` / `docs/development.md`: タイトルだけが載ること、`@name` を書かないこと、`jq` が要ること、`update` は通常 `--ref main` で実行すること(v0.1.0 の tag の上には workflow が無い)、fixture の test を追記 - [x] PR 上の `Release notes / notes` が、v0.1.0 と v0.1.1(プレビュー)の notes を job summary と artifact に出す(GHCR から v0.1.0 の digest を引く) - `workflow_dispatch` の dry run は、新規 workflow が default branch に入るまで dispatch できないため、merge 後に `gh workflow run release-notes.yml --ref main -f tag=v0.1.0` で確認する(PR 上の `pull_request` の実行が同じ生成を行う) - tag の push・release の作成 / 編集・publish を有効にした実行はしていない - Rust のコードは変更していない(cargo の品質ゲートは CI で確認) ### 生成例: v0.1.0(digest は GHCR の実際の値) <details> <summary>v0.1.0 の notes(全文)</summary> ````markdown ## What's changed ### Features - **core**: Define compile domain model and engine interface ([#20](#20)) - **workspace**: Add isolated compile workspaces ([#21](#21)) - **diagnostics**: Parse LaTeX logs into structured diagnostics ([#23](#23)) - **texlive**: Add latexmk engine ([#30](#30)) - **preview**: Render PDF pages to PNG previews ([#31](#31)) - **cli**: Add compile command ([#34](#34)) - **workspace**: Exclude nested output directories by path ([#38](#38)) - **diagnostics**: Locate missing packages and fold fatal errors ([#40](#40)) - **diagnostics**: Report BibTeX failures ([#42](#42)) - **process**: Apply resource limits before exec through a gate ([#44](#44)) - **process**: Limit CPU, memory and process count ([#45](#45)) - **sandbox**: Add a container backend for the TeX engine ([#50](#50)) - **sandbox**: Render previews inside the container ([#52](#52)) - **sandbox**: Reclaim containers left by killed runs and report the process limit ([#53](#53)) - **sandbox**: Reclaim leftovers from a previous boot ([#58](#58)) ### Bug fixes - **workspace**: Refine exclusion and collection edge cases ([#29](#29)) - **texlive**: Restore the build after #39 and #40 ([#43](#43)) - **sandbox**: Accept engine images without labels ([#55](#55)) - **sandbox**: Support rootless Podman and refuse rootless Docker ([#57](#57)) - **sandbox**: Detect OOM kills reliably on Docker ([#61](#61)) ### Documentation - Add contribution guidelines and MIT license ([#15](#15)) - Add initial README ([#18](#18)) - **security**: Define the MVP security model and execution limits ([#22](#22)) - Update README to reflect the completed MVP ([#37](#37)) - Rewrite the README ([#59](#59)) ### Other changes - Initialize repository - Bootstrap Rust workspace and toolchain ([#16](#16)) - **ci**: Add quality gates and dependency checks ([#19](#19)) - **docker**: Add TeX Live development environment ([#17](#17)) - Add TeX Live integration fixtures and CI job ([#33](#33)) - **process**: Extract shared subprocess execution ([#39](#39)) - **ci**: Publish the engine image to GHCR ([#51](#51)) ## Install ```bash cargo install --locked --git https://github.com/nishide-dev/texrun --tag v0.1.0 texrun ``` See the [README](https://github.com/nishide-dev/texrun/blob/v0.1.0/README.md#installation) for the requirements and the tools each backend needs. ## Engine image The container backend (`--backend container`) runs TeX in the engine image of this version, `ghcr.io/nishide-dev/texrun-engine:0.1.0` (linux/amd64, linux/arm64). texrun never pulls it; pull it once: ```bash docker pull ghcr.io/nishide-dev/texrun-engine:0.1.0 ``` Published versions are never overwritten. To use exactly this image, pin its digest: ```bash docker pull ghcr.io/nishide-dev/texrun-engine@sha256:b611748f16d50c00982da2e52b51939d50167bebbc22b35ab8741d1c39e00d1b texrun compile --backend container --container-image ghcr.io/nishide-dev/texrun-engine@sha256:b611748f16d50c00982da2e52b51939d50167bebbc22b35ab8741d1c39e00d1b main.tex ``` The image has an SBOM, SLSA provenance and a signed GitHub artifact attestation: ```bash gh attestation verify oci://ghcr.io/nishide-dev/texrun-engine:0.1.0 -R nishide-dev/texrun ``` ## Source of the engine image `texrun-engine-0.1.0-sources.tar` (below) has the Debian source packages (`.dsc`, `.orig.tar.*`, `.debian.tar.*`) of every package in the image, for both platforms, at exactly the installed versions (`packages.txt` and `SHA256SUMS` inside): the corresponding source of its GPL / AGPL programs. See [docs/engine-image.md](https://github.com/nishide-dev/texrun/blob/v0.1.0/docs/engine-image.md#licenses). ```` </details> ### 生成例: v0.1.0 以降の main の差分(次の版のプレビュー) ````markdown ## What's changed ### Bug fixes - **ci**: Build release notes lines from commit titles only ### Other changes - **ci**: Generate release notes from conventional commits - **ci**: Write release notes on tag push and add a notes-only workflow **Full diff**: [v0.1.0...v0.1.1](v0.1.0...v0.1.1) ```` (以下の Install / Engine image / Source は v0.1.0 と同じ形で、digest は placeholder。squash merge 後は 1 commit になる) ### 生成例: fixture(`release-notes-test.expected.md`) ````markdown ## What's changed ### Breaking changes - **cli**: Rename --json flag to --format json ([#4](#4)) ### Features - **cli**: Rename --json flag to --format json ([#4](#4)) ### Bug fixes - **diagnostics**: Report the error `@octocat` found ([#7](#7)) ### Other changes - Revert "fix(core): handle empty logs ([#5](#5))" ([#6](#6)) ### Dependencies - 3 dependency updates: [#2](#2), [#3](#3) **Full diff**: [v0.1.0...v0.2.0](v0.1.0...v0.2.0) ```` ## 補足 - merge 後、v0.1.0 の notes を埋めるには: `gh workflow run release-notes.yml --ref main -f tag=v0.1.0`(dry run、summary で確認)の後に `gh workflow run release-notes.yml --ref main -f tag=v0.1.0 -f update=true`。 - notes の文面は PR タイトルで決まる。merge 後に誤りに気付いた場合は release を手で編集できるが、作り直すと消える。 - 推奨(任意): `release-notes.yml` の `update` job にも、engine-image.yml と同様に `environment` を付けることを検討できる(docs/security.md の「release の入口」)。 🤖 Generated with [Claude Code](https://claude.com/claude-code) --------- Co-authored-by: Claude Opus 5.5 <[email protected]>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
概要
container backend を rootless Podman で CI テストする job を追加し、実行して見つかった Podman 固有の差を修正した。あわせて、capability が全て落ちていることを
HostConfigの表記ではなく container の中のプロセスの capability の集合で確認するよう強化し、rootless Docker は検出して使わない(Unavailable)と決めた。変更内容
sandbox (podman)job(ci-successに追加)autoと test が Podman しか使えないようにする)、systemd の user manager を linger で起動して[email protected]にDelegate=cpu cpuset io memory pidsを追加、podman infoで rootless / cgroup v2 / 委譲された controller を確認するpodman buildで作り(cache 無しで約 45 秒)、sandboxjob と同じ test(texrun-sandbox、texrun-texliveのcontainer/scenarios/security、texrun-previewのcontainer/real_tools、CLI のcontainer)を実行し、container が残っていないことを確認する。job 全体で約 3 分texrun_sandbox::capability_report/take_capability_report: プログラムを小さな/bin/shの下で起動し、execの前にCapInh/CapPrm/CapEff/CapBnd/CapAmbを stdout の最初の行に書かせ、全て空であることを確認して行を取り除く。非 root ではCapEffは元から空なので bounding set も確認するUnavailable。preview のSessionも起動直後にexecで同じ確認をし、通らなければRefused。Docker と Podman で同じ確認container=podmanなどを足していた → Podman には--unsetenv-all --http-proxy=falseを付けるState.OOMKilledを記録しない(cgroup のoom_killは増える)→ compile の container では process 数を報告する shell がoom_killも報告し、Container::outcomeに反映する。preview の session では Podman の場合にexecでoom_killを読む(どちらも助言的な情報として文書化)sha256:の無い 16 進数を返す(そのまま使えるので test 側を修正)HostConfigの CapDrop の列挙、CPU の quota / period、RLIMIT_*の名前、回収の状態名は既存の対応で動くことを CI で確認docker infoのSecurityOptionsにname=rootlessがあれば、理由と代わり(rootless Podman、root の daemon)を示してUnavailable(autoでは次の Podman を試す)Unavailable(HostConfigの照合でも fail-closed)docs/security.md§2・§4(比較表、「rootless の runtime」、capability の確認)、docs/development.md、README を更新確認方法
cargo check --workspace --all-targets --all-features --lockedcargo fmt --all -- --checkcargo clippy --workspace --all-targets --all-features --locked -- -D warningscargo test --workspace --all-features --lockedcargo deny --locked check、actionlintTEXRUN_REQUIRE_SANDBOX=1、退行無し、container の残り無し)sandbox(Docker)とsandbox (podman)(rootless Podman 4.9.3、crun 1.14、conmon 2.1.10)が green関連 Issue
Closes #47
補足
reclaim.rsは test の fake runtime にinfoの応答を 1 行足しただけ。🤖 Generated with Claude Code