Skip to content

chore(musl): revert static shim libkrunfw dlopen change (#937)#1019

Merged
DorianZheng merged 2 commits into
mainfrom
revert/pr-937
Jul 23, 2026
Merged

chore(musl): revert static shim libkrunfw dlopen change (#937)#1019
DorianZheng merged 2 commits into
mainfrom
revert/pr-937

Conversation

@DorianZheng

@DorianZheng DorianZheng commented Jul 23, 2026

Copy link
Copy Markdown
Member

Summary

Reverts #937 (squash commit 2411669).

Not a byte-exact revert — three conflict resolutions keep post-#937 work intact:

How to verify

cargo metadata --offline
BOXLITE_DEPS_STUB=1 cargo check -p libkrun-sys --features krun,krunfw
BOXLITE_DEPS_STUB=1 cargo check -p boxlite --tests --features krun
BOXLITE_DEPS_STUB=1 cargo check --workspace --exclude boxlite-guest --features boxlite/krun
bash -n scripts/build/*.sh
make fmt:check:rust

boxlite-guest is excluded on macOS hosts: it is Linux-only by compile_error! guard, unchanged by this PR.

https://claude.ai/code/session_01TKsDvm6v2jB7ZKDVCSUzMA

Summary by CodeRabbit

  • New Features

    • Added configurable libkrun logging based on RUST_LOG, with output directed to standard error.
    • Improved runtime discovery, including support for explicit runtime directories alongside embedded runtimes.
  • Improvements

    • Streamlined debug and release builds for the runtime and CLI.
    • Improved static builds and cross-platform packaging reliability.
    • Sandboxed processes now receive a more limited environment for improved isolation.
  • Documentation

    • Updated CLI and development instructions to reflect the revised build commands.
    • Updated integration test setup guidance.

This reverts commit 2411669.

Conflicts resolved against post-merge work, keeping later changes:
- src/boxlite/src/runtime/backend.rs: UnsupportedNetworkBackend was
  deleted by #992; it stays deleted instead of resurfacing without
  the cfg gates #937 had added.
- src/boxlite/Cargo.toml: the rest feature keeps the hyper-rustls and
  rustls deps added by the tunnels work.
- scripts/build/build-runtime.sh: #1009's sed-portability tweak only
  applied to the rewritten script; the pre-#937 script is restored.

Claude-Session: https://claude.ai/code/session_01TKsDvm6v2jB7ZKDVCSUzMA
@DorianZheng
DorianZheng requested a review from a team as a code owner July 23, 2026 03:36
@boxlite-agent

boxlite-agent Bot commented Jul 23, 2026

Copy link
Copy Markdown

📦 BoxLite review — couldn't complete

claude exited 1

stdout:
{"is_error":true,"duration_api_ms":0,"num_turns":1,"stop_reason":"stop_sequence","session_id":"14abcf7b-5a43-4f98-a85a-8c14bc5834f2","total_cost_usd":0,"usage":{"input_tokens":0,"cache_creation_input_tokens":0,"cache_read_input_tokens":0,"output_tokens":0,"server_tool_use":{"web_search_requests":0,"web_fetch_requests":0},"service_tier":"standard","cache_creation":{"ephemeral_1h_input_tokens":0,"ephemeral_5m_input_tokens":0},"inference_geo":"","iterations":[],"speed":"standard"},"modelUsage":{},"permission_denials":[],"terminal_reason":"api_error","fast_mode_state":"off","subtype":"success","api_error_status":403,"result":"Your organization has disabled Claude subscription access for Claude Code · Use an Anthropic API key instead, or ask your admin to enable access","type":"result","duration_ms":331,"uuid":"7373b59e-18af-4686-931d-642a573df708"}

stderr:
<empty>

powered by BoxLite

@cla-assistant

cla-assistant Bot commented Jul 23, 2026

Copy link
Copy Markdown

CLA assistant check
Thank you for your submission! We really appreciate it. Like many open source projects, we ask that you sign our Contributor License Agreement before we can accept your contribution.


tester seems not to be a GitHub user. You need a GitHub account to be able to sign the CLA. If you have already a GitHub account, please add the email address used for this commit to your account.
You have signed the CLA already but the status is still pending? Let us recheck it.

@coderabbitai

coderabbitai Bot commented Jul 23, 2026

Copy link
Copy Markdown

Review Change Stack

Caution

Review failed

The pull request is closed.

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: d0b866cc-388f-4491-8649-d75ff26f3bfa

📥 Commits

Reviewing files that changed from the base of the PR and between 8778293 and b49a628.

📒 Files selected for processing (3)
  • .github/workflows/e2e-local.yml
  • docs/development/cli.md
  • docs/guides/README.md

📝 Walkthrough

Walkthrough

The PR replaces profile-based Makefile wiring with explicit runtime and CLI targets, rewrites runtime/native build orchestration, converts libkrun integration to direct FFI bindings, narrows sandbox environment propagation, removes external kernel configuration, and updates CI, manifests, and development documentation.

Changes

Runtime and native build changes

Layer / File(s) Summary
Runtime and CLI build orchestration
make/*, scripts/build/*, .cargo/config.toml, src/guest/.cargo/config.toml, src/shim/*
Runtime and CLI builds now use explicit debug/release targets; runtime assembly discovers libraries and validates static guest binaries.
libkrun native build and FFI integration
src/deps/libkrun-sys/*, src/boxlite/build.rs, src/boxlite/src/vmm/krun/*
Native libkrun builds use vendored-source validation and platform toolchain helpers, while Rust exposes direct libkrun FFI bindings and initializes libkrun logging.
Sandbox and shim environment propagation
src/boxlite/src/jailer/*, src/boxlite/src/vmm/controller/spawn.rs
Sandboxed processes now retain library lookup paths and selected Rust diagnostic variables instead of the removed environment allowlist.
CI, manifests, and build documentation
.github/workflows/*, Cargo.toml, **/Cargo.toml, docs/*, src/boxlite/tests/*
CI checkout and publishing steps, workspace lint configuration, crate manifests, and build instructions are updated for the revised build model.

Estimated code review effort: 4 (Complex) | ~60 minutes

Sequence Diagram(s)

sequenceDiagram
  participant Make
  participant build-runtime.sh
  participant boxlite-build
  participant libkrun-sys
  participant boxlite-cli
  Make->>build-runtime.sh: build runtime with selected profile
  build-runtime.sh->>boxlite-build: collect runtime libraries
  boxlite-build->>libkrun-sys: build or locate native dependencies
  Make->>boxlite-cli: cargo build with matching profile
Loading

Possibly related PRs

Suggested reviewers: g4614, law-chain-hot

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly states this PR reverts the musl static-shim libkrunfw dlopen change.
Description check ✅ Passed The description covers the summary and verification steps, though it folds changes into Summary instead of a separate Changes section.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch revert/pr-937

Warning

There were issues while running some tools. Please review the errors and either fix the tool's configuration or disable the tool if it's a critical failure.

🔧 Checkov (3.3.8)
.github/workflows/e2e-local.yml

Traceback (most recent call last):
File "/usr/local/bin/checkov", line 2, in
from checkov.main import Checkov
ModuleNotFoundError: No module named 'checkov'


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@DorianZheng DorianZheng added the e2e-local Triggers the local (in-process) E2E suite on the self-hosted runner label Jul 23, 2026

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 5

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
src/deps/libgvproxy-sys/build.rs (1)

115-141: 🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win

Use target env vars in build.rs, not host-only #[cfg].

Build scripts run on the host, so #[cfg(target_os = ...)] selects linker directives by the machine running build.rs, while CARGO_CFG_TARGET_ARCH still reflects the target. Cross-OS targets would get the wrong output, e.g. macOS host → Linux target emitting macOS frameworks or dynamic resolv instead of Linux static resolv. Restore CARGO_CFG_TARGET_OS-based branching for these cargo:rustc-link-* directives.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@src/deps/libgvproxy-sys/build.rs` around lines 115 - 141, Update the
linker-directive branching in build.rs to inspect the target OS via
CARGO_CFG_TARGET_OS rather than compile-time #[cfg(target_os = ...)] conditions.
Preserve the existing macOS framework directives, Linux architecture-specific
static resolv search paths and linking, and non-Linux resolv linking, selecting
each based on the target environment variable.
🧹 Nitpick comments (1)
src/deps/libkrun-sys/build.rs (1)

921-927: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

Register BOXLITE_BUILD_LIBKRUNFW for rerun detection.

The Linux build() branches on BOXLITE_BUILD_LIBKRUNFW (source build vs. prebuilt download), but main() only emits rerun-if-env-changed for BOXLITE_DEPS_STUB and (macOS) BOXLITE_LIBKRUN_CC_LINUX. Toggling BOXLITE_BUILD_LIBKRUNFW won't trigger a rebuild on incremental builds, so the switch silently won't take effect until something else invalidates the build.

♻️ Proposed fix
     println!("cargo:rerun-if-env-changed=BOXLITE_DEPS_STUB");
+    #[cfg(target_os = "linux")]
+    println!("cargo:rerun-if-env-changed=BOXLITE_BUILD_LIBKRUNFW");
     #[cfg(target_os = "macos")]
     println!("cargo:rerun-if-env-changed=BOXLITE_LIBKRUN_CC_LINUX");
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@src/deps/libkrun-sys/build.rs` around lines 921 - 927, Add
`println!("cargo:rerun-if-env-changed=BOXLITE_BUILD_LIBKRUNFW");` in `main()`
alongside the existing environment-variable rerun directives, so changes to the
variable used by `build()` invalidate the build script and apply the selected
source or prebuilt path.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In @.github/workflows/e2e-local.yml:
- Around line 142-145: Update the GitHub App token configuration used by
start-runner to explicitly grant only registration-token access, read access for
runners, and write access to repository variables, using the action’s
permission- inputs. Confirm the GitHub App installation is restricted to this
repository and does not inherit broader installation scopes.

In `@docs/development/cli.md`:
- Around line 15-17: Specify a fenced-block language for the code block
containing ./target/debug/boxlite by adding text or bash to its opening fence,
resolving the markdownlint MD040 warning.

In `@docs/guides/README.md`:
- Around line 62-64: Update the build script entries in the documentation tree
listing to use the actual names build-guest.sh and build-shim.sh, matching the
scripts under scripts/build; leave the build-runtime.sh entry unchanged.

In `@src/boxlite/src/runtime/embedded.rs`:
- Around line 200-207: Update the release branch of the dir_name selection in
embedded runtime initialization so cache directories include
env!("BOXLITE_MANIFEST_HASH"), preventing rebuilt releases with the same
crate::VERSION from reusing stale extracted runtimes. Preserve the existing
debug cache-key behavior and ensure the extraction fast path distinguishes
manifests before accepting an existing .complete stamp.

In `@src/boxlite/src/util/mod.rs`:
- Around line 103-106: Update the runtime library setup in the binary-spawning
flow to read BOXLITE_RUNTIME_DIR, split its configured paths into lib_dirs, and
forward the variable through cmd.env(...). Preserve its highest-priority
override behavior relative to the embedded runtime fallback, so custom runtime
directories and their sibling libraries remain available to spawned shims.

---

Outside diff comments:
In `@src/deps/libgvproxy-sys/build.rs`:
- Around line 115-141: Update the linker-directive branching in build.rs to
inspect the target OS via CARGO_CFG_TARGET_OS rather than compile-time
#[cfg(target_os = ...)] conditions. Preserve the existing macOS framework
directives, Linux architecture-specific static resolv search paths and linking,
and non-Linux resolv linking, selecting each based on the target environment
variable.

---

Nitpick comments:
In `@src/deps/libkrun-sys/build.rs`:
- Around line 921-927: Add
`println!("cargo:rerun-if-env-changed=BOXLITE_BUILD_LIBKRUNFW");` in `main()`
alongside the existing environment-variable rerun directives, so changes to the
variable used by `build()` invalidate the build script and apply the selected
source or prebuilt path.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: 337120e5-6987-4726-a879-6d24e0cae247

📥 Commits

Reviewing files that changed from the base of the PR and between b1ba38a and 8778293.

⛔ Files ignored due to path filters (1)
  • Cargo.lock is excluded by !**/*.lock
📒 Files selected for processing (61)
  • .cargo/config.toml
  • .github/workflows/build-runtime.yml
  • .github/workflows/e2e-local.yml
  • .github/workflows/lint.yml
  • .github/workflows/test.yml
  • Cargo.toml
  • docs/development/cli.md
  • docs/guides/README.md
  • make/build.mk
  • make/coverage.mk
  • make/dev.mk
  • make/help.mk
  • make/quality.mk
  • make/test.mk
  • make/vars.mk
  • scripts/build/build-cli.sh
  • scripts/build/build-guest.sh
  • scripts/build/build-libseccomp.sh
  • scripts/build/build-runtime.sh
  • scripts/build/build-shim.sh
  • scripts/build/common.sh
  • scripts/build/fix-go-symbols.sh
  • sdks/c/Cargo.toml
  • sdks/node/Cargo.toml
  • sdks/python/Cargo.toml
  • src/boxlite/Cargo.toml
  • src/boxlite/build.rs
  • src/boxlite/src/disk/ext4.rs
  • src/boxlite/src/jailer/bwrap.rs
  • src/boxlite/src/jailer/common/rlimit.rs
  • src/boxlite/src/jailer/mod.rs
  • src/boxlite/src/jailer/process_env.rs
  • src/boxlite/src/jailer/sandbox/bwrap.rs
  • src/boxlite/src/jailer/shim_copy.rs
  • src/boxlite/src/runtime/constants.rs
  • src/boxlite/src/runtime/embedded.rs
  • src/boxlite/src/util/binary_finder.rs
  • src/boxlite/src/util/mod.rs
  • src/boxlite/src/vmm/controller/spawn.rs
  • src/boxlite/src/vmm/krun/context.rs
  • src/boxlite/src/vmm/krun/engine.rs
  • src/boxlite/src/vmm/krun/kernel.rs
  • src/boxlite/src/vmm/krun/mod.rs
  • src/boxlite/tests/README.md
  • src/boxlite/tests/health_check.rs
  • src/cli/Cargo.toml
  • src/cli/README.md
  • src/deps/bubblewrap-sys/Cargo.toml
  • src/deps/e2fsprogs-sys/Cargo.toml
  • src/deps/libgvproxy-sys/Cargo.toml
  • src/deps/libgvproxy-sys/build.rs
  • src/deps/libkrun-sys/Cargo.toml
  • src/deps/libkrun-sys/build.rs
  • src/deps/libkrun-sys/src/lib.rs
  • src/guest/.cargo/config.toml
  • src/guest/Cargo.toml
  • src/shared/Cargo.toml
  • src/shim/.cargo/config.toml
  • src/shim/Cargo.toml
  • src/shim/build.rs
  • src/test-utils/Cargo.toml
💤 Files with no reviewable changes (22)
  • src/shared/Cargo.toml
  • src/guest/Cargo.toml
  • src/deps/bubblewrap-sys/Cargo.toml
  • src/deps/e2fsprogs-sys/Cargo.toml
  • src/shim/.cargo/config.toml
  • scripts/build/build-cli.sh
  • src/boxlite/src/jailer/process_env.rs
  • src/boxlite/src/vmm/krun/mod.rs
  • src/boxlite/src/jailer/mod.rs
  • sdks/node/Cargo.toml
  • sdks/c/Cargo.toml
  • make/vars.mk
  • src/cli/Cargo.toml
  • src/shim/Cargo.toml
  • sdks/python/Cargo.toml
  • src/test-utils/Cargo.toml
  • scripts/build/common.sh
  • Cargo.toml
  • src/deps/libgvproxy-sys/Cargo.toml
  • .github/workflows/test.yml
  • src/boxlite/src/vmm/krun/kernel.rs
  • src/boxlite/src/runtime/constants.rs

Comment on lines +142 to 145
uses: actions/create-github-app-token@v1
with:
client-id: ${{ vars.APP_CLIENT_ID }}
app-id: ${{ vars.GH_APP_ID }}
private-key: ${{ secrets.GH_APP_PRIVATE_KEY }}

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔒 Security & Privacy | 🟠 Major | ⚡ Quick win

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
set -euo pipefail

echo "Locate workflow:"
fd -a 'e2e-local.yml|e2e' .github/workflows 2>/dev/null || true

echo
echo "Relevant workflow section:"
sed -n '120,170p' .github/workflows/e2e-local.yml 2>/dev/null || true

echo
echo "Search GH app token usage:"
rg -n "create-github-app-token|GITHUB_TOKEN|GH_APP|permissions:|contents:|pull-requests:|actions:|repository-projects|variables|runner" .github/workflows -S || true

Repository: boxlite-ai/boxlite

Length of output: 16393


🌐 Web query:

actions/create-github-app-token v1 permission inputs defaults grants all permissions

💡 Result:

Yes, by default, the actions/create-github-app-token action creates a token that inherits all of the permissions currently granted to the GitHub App installation [1][2][3]. It does not grant all possible GitHub permissions, but rather all permissions that have been configured for that specific app's installation on the target repository or account [1][4]. If you do not specify any permission-* inputs, the action omits the permissions parameter in its underlying GitHub REST API call, resulting in the token being created with the full set of permissions available to the installation [2][3][5]. The action documentation explicitly recommends explicitly listing the permissions required for your use case to follow the principle of least privilege [1][4]. You can restrict the token's permissions by providing the desired access level (e.g., 'read' or 'write') for specific permissions using the permission-* input prefix (e.g., permission-pull-requests: read) [1][6][5]. Note that: - The installation permissions are set when an app is installed, and administrators must approve new permissions if the app's scope is updated later [1][3]. - You cannot use the action to grant permissions that the app installation itself does not possess; doing so will result in an error [1][4]. - When you provide permission-* inputs, the action correctly restricts the token to only those specified permissions [7][8].

Citations:


🏁 Script executed:

#!/bin/bash
set -euo pipefail

echo "start-runner action-token and subsequent steps:"
sed -n '138,270p' .github/workflows/e2e-local.yml | cat -n

echo
echo "Later token usages:"
sed -n '276,320p' .github/workflows/e2e-local.yml | cat -n

echo
echo "stop-runner:"
sed -n '532,565p' .github/workflows/e2e-local.yml | cat -n

Repository: boxlite-ai/boxlite

Length of output: 10697


Scope the GitHub App token to the needed APIs.

start-runner only needs runner registration/listing and the EC2_E2E_INSTANCE_ID repository-variable write. Add explicit permission- inputs (registration-token, read/ for runners, and variables: write) so the App token does not inherit any installation scopes beyond what these calls require. Also confirm the App installation is limited to this repository.

🧰 Tools
🪛 zizmor (1.26.1)

[error] 142-142: dangerous use of GitHub App tokens (github-app): app token inherits blanket installation permissions

(github-app)

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In @.github/workflows/e2e-local.yml around lines 142 - 145, Update the GitHub
App token configuration used by start-runner to explicitly grant only
registration-token access, read access for runners, and write access to
repository variables, using the action’s permission- inputs. Confirm the GitHub
App installation is restricted to this repository and does not inherit broader
installation scopes.

Source: Linters/SAST tools

Comment thread docs/development/cli.md Outdated
Comment thread docs/guides/README.md Outdated
Comment thread src/boxlite/src/runtime/embedded.rs Outdated
Comment thread src/boxlite/src/util/mod.rs Outdated
Applies all five CodeRabbit findings on #1019:

- embedded.rs: key the extracted-runtime cache by manifest hash on every
  profile (re-applies #937's fix) so a same-version rebuild with changed
  assets cannot reuse a stale directory.
- util/mod.rs: forward BOXLITE_RUNTIME_DIR to the child and add its paths
  to the shim's library search path (re-applies #937's fix) so an explicit
  runtime override resolves its sibling libraries.
- e2e-local.yml: scope the App token to Administration + Variables instead
  of inheriting all installation permissions.
- docs/guides/README.md: name the real scripts (build-guest.sh/build-shim.sh).
- docs/development/cli.md: give the fenced block a language (MD040).

Claude-Session: https://claude.ai/code/session_01TKsDvm6v2jB7ZKDVCSUzMA
@DorianZheng
DorianZheng merged commit cd02c6b into main Jul 23, 2026
49 of 51 checks passed
@DorianZheng
DorianZheng deleted the revert/pr-937 branch July 23, 2026 05:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

e2e-local Triggers the local (in-process) E2E suite on the self-hosted runner

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant