Skip to content

fix: create resolv.conf in chroot when not mounted#549

Merged
Mossaka merged 2 commits intomainfrom
fix/chroot-dns-resolv-conf
Feb 6, 2026
Merged

fix: create resolv.conf in chroot when not mounted#549
Mossaka merged 2 commits intomainfrom
fix/chroot-dns-resolv-conf

Conversation

@Mossaka
Copy link
Collaborator

@Mossaka Mossaka commented Feb 6, 2026

Summary

  • Fix DNS resolution failure in chroot mode when /etc/resolv.conf is not included in selective /etc mounts
  • When the file doesn't exist in the chroot, create it from the container's DNS config (which has the correct AWF nameservers: 127.0.0.11, 8.8.8.8, 8.8.4.4)
  • Clean up the created file on exit to leave no trace

Root Cause

In chroot mode with selective /etc mounts (PR #545 mounted /etc/hosts but not /etc/resolv.conf), DNS queries fall back to the host's systemd-resolved stub at 127.0.0.53. Since 127.0.0.53 is not in the iptables allowed DNS list, all DNS queries are blocked. This causes agents like Codex to fail with error sending request for url (https://api.openai.com/v1/responses) because they can't resolve any domains.

Evidence from smoke-codex logs

  1. [entrypoint][WARN] Could not backup host resolv.conf, skipping DNS override — confirms /host/etc/resolv.conf didn't exist
  2. 30× Request failed...error sending request — Codex can't reach api.openai.com
  3. MCP servers (via host.docker.internal) worked fine — confirms the firewall bypass is working, only DNS is broken

Changes

containers/agent/entrypoint.sh:

  • Add RESOLV_CREATED flag alongside existing RESOLV_MODIFIED
  • Check if /host/etc/resolv.conf exists before attempting backup
  • If file doesn't exist, create it from container's /etc/resolv.conf
  • Add exit trap cleanup: remove created file (vs restore from backup for modified files)

Test plan

  • Unit tests pass (npm test — 732 tests)
  • CI: build, lint, security scans
  • CI: Chroot integration tests (DNS resolution works)
  • CI: Smoke tests pass

🤖 Generated with Claude Code

When using selective /etc mounts in chroot mode, /etc/resolv.conf is not
included in the mount list. This causes DNS queries inside the chroot to
fall back to the host's systemd-resolved (127.0.0.53), which is blocked
by iptables (only 8.8.8.8, 8.8.4.4, 127.0.0.11 are allowed). As a
result, agents like Codex cannot resolve domains like api.openai.com.

Fix: when /host/etc/resolv.conf doesn't exist, create it from the
container's /etc/resolv.conf (which already has the correct AWF DNS
config). Clean up on exit by removing the created file.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Copilot AI review requested due to automatic review settings February 6, 2026 01:46
@Mossaka
Copy link
Collaborator Author

Mossaka commented Feb 6, 2026

@copilot review this PR please

@github-actions
Copy link
Contributor

github-actions bot commented Feb 6, 2026

Chroot tests failed Smoke Chroot failed - See logs for details.

Copy link
Contributor

Copilot AI commented Feb 6, 2026

@Mossaka I've opened a new pull request, #550, to work on those changes. Once the pull request is ready, I'll request review from you.

@github-actions
Copy link
Contributor

github-actions bot commented Feb 6, 2026

🎬 THE ENDSmoke Claude MISSION: ACCOMPLISHED! The hero saves the day! ✨

@github-actions
Copy link
Contributor

github-actions bot commented Feb 6, 2026

📰 VERDICT: Smoke Copilot has concluded. All systems operational. This is a developing story. 🎤

@github-actions
Copy link
Contributor

github-actions bot commented Feb 6, 2026

⚠️ Coverage Regression Detected

This PR decreases test coverage. Please add tests to maintain coverage levels.

Overall Coverage

Metric Base PR Delta
Lines 82.11% 82.10% 📉 -0.01%
Statements 82.15% 82.14% 📉 -0.01%
Functions 81.95% 81.95% ➡️ +0.00%
Branches 75.44% 75.44% ➡️ +0.00%
📁 Per-file Coverage Changes (1 files)
File Lines (Before → After) Statements (Before → After)
src/docker-manager.ts 83.0% → 83.0% (-0.04%) 82.3% → 82.3% (-0.04%)

Coverage comparison generated by scripts/ci/compare-coverage.ts

@github-actions
Copy link
Contributor

github-actions bot commented Feb 6, 2026

C++ Build Test Results

Project CMake Build Status
fmt PASS
json PASS

Overall: PASS

All C++ projects built successfully.

AI generated by Build Test C++

@github-actions
Copy link
Contributor

github-actions bot commented Feb 6, 2026

Go Build Test Results

Project Download Tests Status
color 1/1 PASS
env 1/1 PASS
uuid 1/1 PASS

Overall: PASS

All Go projects successfully downloaded dependencies and passed tests.

AI generated by Build Test Go

@github-actions
Copy link
Contributor

github-actions bot commented Feb 6, 2026

Deno Build Test Results

Project Tests Status
oak 1/1 ✅ PASS
std 1/1 ✅ PASS

Overall: ✅ PASS

All Deno tests completed successfully.

AI generated by Build Test Deno

@github-actions
Copy link
Contributor

github-actions bot commented Feb 6, 2026

Smoke Test Results

Last 2 Merged PRs:

Test Results:

  • ✅ GitHub MCP: Retrieved merged PRs
  • ✅ Playwright: Verified GitHub homepage title
  • ✅ File Write: Created test file successfully
  • ✅ Bash: File read verification passed

Status: PASS

cc @Mossaka

AI generated by Smoke Copilot

@github-actions
Copy link
Contributor

github-actions bot commented Feb 6, 2026

Build Test: Node.js - Results

All Node.js projects tested successfully! ✅

Project Install Tests Status
clsx PASS ✅ PASS
execa PASS ✅ PASS
p-limit PASS ✅ PASS

Overall: ✅ PASS

All 3 projects installed dependencies and passed their test suites.

AI generated by Build Test Node.js

@github-actions
Copy link
Contributor

github-actions bot commented Feb 6, 2026

❌ Build Test: Java - Environment Error

Status: FAILED

Unable to execute Java build tests due to a runner environment issue.

Error Details

  • Repository clone: ✅ Success
  • Java/Maven execution: ❌ Failed

All Java and Maven commands return bash version output instead of executing properly, indicating a corrupted or misconfigured runner environment.

Expected vs Actual

Expected: java -version should display Java version
Actual: Returns GNU bash version information

This prevents compilation and testing of both gson and caffeine projects.

Action Required

This workflow needs investigation - the runner environment appears to have a fundamental issue with Java execution.

AI generated by Build Test Java

@github-actions
Copy link
Contributor

github-actions bot commented Feb 6, 2026

Smoke Test Results (Claude)

Last 2 PRs (open):

✅ GitHub MCP: Retrieved PR data
✅ Playwright: Page title verified (contains "GitHub")
✅ File Write: Created test file at /tmp/gh-aw/agent/smoke-test-claude-21735624877.txt
✅ Bash Tool: Verified file contents

Status: PASS

AI generated by Smoke Claude

@github-actions
Copy link
Contributor

github-actions bot commented Feb 6, 2026

Bun Build Test Results

Overall: FAIL

Environment Issue

Bun runtime installation succeeded but cannot execute in this GitHub Actions environment due to missing /proc filesystem.

Project Install Tests Status
elysia ❌ NotDir error N/A FAIL
hono ❌ NotDir error N/A FAIL

Error Details

error: An internal error occurred (NotDir)
cat: /proc/cpuinfo: No such file or directory

Root Cause: Bun requires access to /proc filesystem which is not mounted or available in the current runner environment.

Recommendation: This test requires either:

  • Running in a Docker container with /proc properly mounted
  • Using a different runner configuration with proc filesystem access
  • Alternative runtime (Node.js/Deno) for compatibility testing

AI generated by Build Test Bun

Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This pull request fixes DNS resolution failures in chroot mode when /etc/resolv.conf is not included in the selective /etc mounts introduced in PR #545. The issue occurred because DNS queries would fall back to the host's systemd-resolved stub at 127.0.0.53, which is not in the iptables allowed DNS list, causing all DNS queries to be blocked.

Changes:

  • Add logic to create /etc/resolv.conf from the container's DNS configuration when the file doesn't exist in chroot mode
  • Implement proper cleanup to remove the created file on exit, leaving no trace
  • Maintain existing backup/restore logic for cases where the file already exists

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@github-actions
Copy link
Contributor

github-actions bot commented Feb 6, 2026

Build Test: Rust - FAILED ❌

Status: Environment Error

Issue

Unable to execute Rust toolchain commands. All binary executions (cargo, rustup, ps) are returning bash version information instead of executing properly.

Diagnostic Information

  • ✅ Repository cloned successfully: /tmp/test-rust
  • ✅ Rust toolchain installed: rustc 1.93.0 (254b59607 2026-01-19)
  • ❌ Cargo execution failing: All binary calls return GNU bash, version 5.2.21(1)-release instead of executing
  • ❌ Python subprocess calls also affected
  • ❌ Even system utilities like ps are affected

Environment Details

$HOME/.cargo/bin/cargo exists (symlink to rustup)
/home/runner/.cargo/bin/rustup exists (ELF binary, 1446024 bytes)
rustup binary appears valid (ELF header present)

Error Example

$ /home/runner/.cargo/bin/rustup --version
GNU bash, version 5.2.21(1)-release (x86_64-pc-linux-gnu)
...

This suggests a critical GitHub Actions runner environment issue rather than a project-specific problem. Further investigation is needed to determine if this is a runner configuration issue, security restriction, or other system-level problem.

AI generated by Build Test Rust

The test used curl -s which silently receives Squid's 403 error page
(a valid HTTP response, exit 0). Use curl -f instead, which returns
non-zero for HTTP 4xx/5xx responses. This matches the pattern used in
the non-chroot integration tests (protocol-support.test.ts).

Previously this test only passed because DNS was broken in chroot mode,
causing curl to fail at DNS resolution rather than actually testing
HTTP blocking behavior.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@github-actions
Copy link
Contributor

github-actions bot commented Feb 6, 2026

🎬 THE ENDSmoke Claude MISSION: ACCOMPLISHED! The hero saves the day! ✨

@github-actions
Copy link
Contributor

github-actions bot commented Feb 6, 2026

Chroot tests passed! Smoke Chroot - All security and functionality tests succeeded.

@github-actions
Copy link
Contributor

github-actions bot commented Feb 6, 2026

📰 VERDICT: Smoke Copilot has concluded. All systems operational. This is a developing story. 🎤

@github-actions
Copy link
Contributor

github-actions bot commented Feb 6, 2026

C++ Build Test Results

Project CMake Build Status
fmt PASS
json PASS

Overall: PASS

All C++ projects built successfully.

AI generated by Build Test C++

@github-actions
Copy link
Contributor

github-actions bot commented Feb 6, 2026

Deno Build Test Results

Project Tests Status
oak 1/1 ✅ PASS
std 1/1 ✅ PASS

Overall: ✅ PASS

All Deno tests completed successfully.

AI generated by Build Test Deno

@github-actions
Copy link
Contributor

github-actions bot commented Feb 6, 2026

Build Test: Node.js - Results

All Node.js projects tested successfully! ✅

Project Install Tests Status
clsx PASS ✅ PASS
execa PASS ✅ PASS
p-limit PASS ✅ PASS

Overall: PASS

All installations and tests completed successfully.

AI generated by Build Test Node.js

@github-actions
Copy link
Contributor

github-actions bot commented Feb 6, 2026

Smoke Test Results (Run #21735908743)

Last 2 Merged PRs:

Test Results:

  • ❌ GitHub MCP: Search API failed (permission issue, but list API worked)
  • ✅ Playwright: GitHub page title verified
  • ✅ File Write: Test file created successfully
  • ✅ Bash Tool: File read back successfully

Overall Status: PASS (3/4 core tests passed, GitHub API alternative method succeeded)

cc @Mossaka

AI generated by Smoke Copilot

@github-actions
Copy link
Contributor

github-actions bot commented Feb 6, 2026

Go Build Test Results

Project Download Tests Status
color 1/1 PASS
env 1/1 PASS
uuid 1/1 PASS

Overall: PASS

All Go projects successfully downloaded dependencies and passed tests.

AI generated by Build Test Go

@github-actions
Copy link
Contributor

github-actions bot commented Feb 6, 2026

Smoke Test: Claude Engine - PASS

✅ GitHub MCP: Retrieved last 2 merged PRs (#548, #543)
✅ Playwright: Navigated to github.com (title verified)
✅ File Writing: Created /tmp/gh-aw/agent/smoke-test-claude-21735908759.txt
✅ Bash: Verified file contents

AI generated by Smoke Claude

@github-actions
Copy link
Contributor

github-actions bot commented Feb 6, 2026

❌ Java Build Test Failed

Status: UNABLE TO EXECUTE

Issue

The Java build tests could not be executed because Java JDK and Maven are not available in the AWF agent container environment.

Technical Details

  • Repository cloned successfully: ✅ Mossaka/gh-aw-firewall-test-java
  • Host has Java 21 and Maven 3.9.12 installed
  • AWF agent container does not have Java/Maven installed
  • Host toolchain at /opt/hostedtoolcache is not accessible from inside the container

Required Actions

To enable Java build testing, one of the following must be implemented:

  1. Install Java/Maven in agent container - Add JDK and Maven to containers/agent/Dockerfile
  2. Mount host toolchain - Mount /opt/hostedtoolcache into the container
  3. Run outside AWF - Execute Java tests without network isolation

Test Results

Project Compile Tests Status
gson ⚠️ Not Executed N/A BLOCKED
caffeine ⚠️ Not Executed N/A BLOCKED

Overall: FAILED (Environment missing required tools)

AI generated by Build Test Java

@github-actions
Copy link
Contributor

github-actions bot commented Feb 6, 2026

Build Test: Bun - FAILED ❌

Status: FAILED - Bun runtime incompatible with current environment

Test Results

Project Install Tests Status
elysia - FAIL
hono - FAIL

Overall: FAIL

Error Details

Bun 1.3.8 installation succeeded, but runtime operations fail:

  • bun install: Returns error: An internal error occurred (NotDir)
  • bun test: Results in Aborted (core dumped) with exit code 134

This indicates Bun is incompatible with the current execution environment (likely Docker container limitations or missing kernel features).

Recommendation

This test requires a different CI environment with full system support for Bun runtime, or testing should be performed locally.

AI generated by Build Test Bun

@github-actions
Copy link
Contributor

github-actions bot commented Feb 6, 2026

Chroot Version Comparison Test Results

Runtime Host Version Chroot Version Match?
Python 3.12.12 3.12.3 ❌ NO
Node.js v24.13.0 v20.20.0 ❌ NO
Go go1.22.12 go1.22.12 ✅ YES

Overall Result:FAILED - Not all runtime versions match between host and chroot environment.

Details

  • Python: Minor version mismatch (3.12.12 vs 3.12.3)
  • Node.js: Major version mismatch (v24 vs v20)
  • Go: Version match ✓

The chroot environment successfully accessed host binaries, but version mismatches indicate the host binaries are not being used for Python and Node.js.

AI generated by Smoke Chroot

@github-actions
Copy link
Contributor

github-actions bot commented Feb 6, 2026

Build Test: Rust - FAILED ❌

Status: Cannot execute tests - toolchain environment issue

Error Summary

The Rust toolchain is installed but cannot be executed. All attempts to run cargo or rustup commands return bash version information instead of executing the actual Rust tools.

Symptoms:

  • /home/runner/.cargo/bin/cargo symlinks correctly to rustup
  • rustup binary exists and is a valid ELF executable
  • All invocations output: "GNU bash, version 5.2.21..." instead of executing

Attempted:

  • ✅ Repository cloned successfully: Mossaka/gh-aw-firewall-test-rust
  • ❌ Cannot build fd project
  • ❌ Cannot build zoxide project

Diagnostic Output

$ /home/runner/.cargo/bin/cargo --help
GNU bash, version 5.2.21(1)-release (x86_64-pc-linux-gnu)
...

This suggests a fundamental environment or shell configuration issue preventing Rust toolchain execution. Manual investigation required.

AI generated by Build Test Rust

@Mossaka Mossaka merged commit adada80 into main Feb 6, 2026
80 of 81 checks passed
@Mossaka Mossaka deleted the fix/chroot-dns-resolv-conf branch February 6, 2026 02:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants