fix: one-shot-token.so fails to load on musl/Alpine hosts (ARC runners)#2538
fix: one-shot-token.so fails to load on musl/Alpine hosts (ARC runners)#2538
Conversation
…ine hosts The one-shot-token.so LD_PRELOAD library was compiled against glibc with _FORTIFY_SOURCE enabled, causing __fprintf_chk to be linked in. On musl-based hosts (Alpine Linux / ARC self-hosted runners) this caused: Error relocating /tmp/awf-lib/one-shot-token.so: __fprintf_chk: symbol not found Changes: - Dockerfile: add -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=0 to gcc flags - build.sh: same flags for local builds - entrypoint.sh: add runtime compatibility probe (chroot mode) using /host/bin/true before committing to LD_PRELOAD; graceful degradation with a warning if the .so fails to load on the host libc - README.md: document the fix and update limitations section Agent-Logs-Url: https://github.com/github/gh-aw-firewall/sessions/2f8a6925-e4bb-4c25-a59c-f4734dadfba2 Co-authored-by: lpcox <15877973+lpcox@users.noreply.github.com>
✅ Coverage Check PassedOverall Coverage
📁 Per-file Coverage Changes (1 files)
Coverage comparison generated by |
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
There was a problem hiding this comment.
Pull request overview
This PR aims to improve reliability of the agent’s one-shot-token.so LD_PRELOAD library when running in chroot mode on musl/Alpine-based hosts (e.g., ARC runners), by adjusting compilation flags to avoid fortified glibc symbol dependencies and adding a runtime compatibility probe with graceful fallback.
Changes:
- Add
-U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=0to theone-shot-token.sobuild in the agent Dockerfile and the localbuild.sh. - Add a runtime probe in
containers/agent/entrypoint.shto avoid enabling LD_PRELOAD when the host loader/libc can’t load the library. - Update
one-shot-tokenREADME to document the build flag rationale and chroot limitations.
Show a summary per file
| File | Description |
|---|---|
| containers/agent/one-shot-token/README.md | Documents the new build flags and updates limitations language for musl/glibc behavior. |
| containers/agent/one-shot-token/build.sh | Adds the same compile flags for local builds (but currently has a blocking script issue). |
| containers/agent/entrypoint.sh | Adds a host compatibility probe before setting LD_PRELOAD in chroot mode. |
| containers/agent/Dockerfile | Adds the compile flags during image build to reduce glibc fortified-symbol linkage. |
Copilot's findings
Tip
Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
- Files reviewed: 4/4 changed files
- Comments generated: 3
| # Probe compatibility with the host's dynamic linker before committing to LD_PRELOAD. | ||
| # The .so is compiled against glibc; on musl-based hosts (Alpine/ARC runners) it will | ||
| # fail to load with "symbol not found: __fprintf_chk". Running the host's /bin/true | ||
| # (which uses the host's own libc) surfaces this error without breaking anything. | ||
| if LD_PRELOAD=/host/tmp/awf-lib/one-shot-token.so /host/bin/true 2>/dev/null; then | ||
| ONE_SHOT_TOKEN_LIB="/tmp/awf-lib/one-shot-token.so" | ||
| echo "[entrypoint] One-shot token library copied to chroot at ${ONE_SHOT_TOKEN_LIB}" | ||
| else | ||
| echo "[entrypoint][WARN] one-shot-token.so failed to load on host libc (e.g. musl/Alpine)" |
| # -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=0: disable glibc fortification macros | ||
| # (e.g. __fprintf_chk) so the .so loads on musl-based hosts (Alpine/ARC runners) | ||
| gcc -shared -fPIC \ | ||
| -fvisibility=hidden \ | ||
| -O2 -Wall -Wextra -s \ | ||
| -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=0 \ | ||
| -o "${OUTPUT_FILE}" \ | ||
| "${SOURCE_FILE}" \ |
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
|
@copilot address the review feedback |
- entrypoint.sh: run LD_PRELOAD compatibility probe inside chroot /host so the ELF interpreter resolves against the host filesystem (avoids false negatives on glibc containers with musl hosts) - entrypoint.sh: broaden warning message to reflect general linker incompatibility rather than only __fprintf_chk - build.sh: define SOURCE_FILE and OUTPUT_FILE variables (were referenced but never defined, causing local builds to fail) - build.sh: fix stale comment claiming Rust/Cargo build Agent-Logs-Url: https://github.com/github/gh-aw-firewall/sessions/74ad4f01-8832-4d73-b9bc-ee83a6ad7882 Co-authored-by: lpcox <15877973+lpcox@users.noreply.github.com>
Done in 4114e61. Three issues addressed:
|
🔬 Smoke Test Results
PR: fix: one-shot-token.so fails to load on musl/Alpine hosts (ARC runners) Overall: PASS (MCP and HTTP confirmed; file test skipped due to unexpanded template vars)
|
|
Smoke Test Results ✅ GitHub MCP: Last 2 merged PRs retrieved Status: PASS
|
Chroot Version Comparison Results
Result: ❌ Not all tests passed. Python and Node.js versions differ between host and chroot environments. The
|
Smoke Test: Copilot BYOK (Offline) Mode
Running in BYOK offline mode ( PR by Overall: PARTIAL PASS (BYOK inference ✅; pre-step outputs not substituted)
|
Smoke Test
Warning Firewall blocked 1 domainThe following domain was blocked by the firewall during workflow execution:
network:
allowed:
- defaults
- "registry.npmjs.org"See Network Configuration for more information.
|
Smoke Test Results
Overall: FAIL —
|
🏗️ Build Test Suite Results
Overall: 8/8 ecosystems passed — ✅ PASS
|
one-shot-token.socompiled against glibc pulls in__fprintf_chk(a_FORTIFY_SOURCEartifact), causing LD_PRELOAD to fail withsymbol not found: __fprintf_chkon musl-based hosts (Alpine DinD / ARC self-hosted runners).Changes
Dockerfile+build.sh: Add-U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=0togccflags — eliminates the__fprintf_chkdependency while preserving all other hardening:gcc -shared -fPIC -fvisibility=hidden -O2 -Wall -s \ -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=0 \ -o /usr/local/lib/one-shot-token.so one-shot-token.c -ldl -lpthreadentrypoint.sh(chroot mode): Add a runtime compatibility probe before settingONE_SHOT_TOKEN_LIB. Uses the host's own/bin/trueto surface linker failures before committing toLD_PRELOAD; degrades gracefully with a warning rather than crashing on incompatible hosts:README.md: Update build snippet and limitations to reflect musl compatibility and graceful degradation.