Skip to content

Fix Android execpolicy lock fallback#4

Draft
GFernie wants to merge 3 commits into
mainfrom
fix/android-execpolicy-lock-fallback
Draft

Fix Android execpolicy lock fallback#4
GFernie wants to merge 3 commits into
mainfrom
fix/android-execpolicy-lock-fallback

Conversation

@GFernie

@GFernie GFernie commented Mar 25, 2026

Copy link
Copy Markdown
Owner

Fixes #3.

Summary

Allow persistent approval amendments on Android/Termux to proceed when advisory file locking is unsupported, while keeping the existing failure path on non-Android targets.

Problem

On Termux, choosing p for “always allow” approves the command but then fails to persist the rule because updating default.rules hits an unsupported file lock operation.

Observed interactive failure:

✔ You approved codex to always run commands that start with printf 'probe' > /data/data/com.termux/files/home/approval-probe-fixed-3.txt

⚠ Failed to apply execpolicy amendment: failed to update rules file /data/data/com.termux/files/home/.codex/rules/default.rules: failed to lock policy file /data/data/com.termux/files/home/.codex/rules/default.rules: lock() not supported

The command still executes, but the allow rule is not persisted.

Change

The source fix is in codex-rs/execpolicy/src/amend.rs.

On Android only, lock() not supported is treated as a non-fatal advisory-lock miss when appending execpolicy amendments. Unsupported lock errors still fail on non-Android targets.

The branch also carries the fork inventory updates in patches/README.md and verify-patches.sh, consistent with how this fork tracks its maintained deltas.

Validation

  • cargo test -p codex-execpolicy
  • bash verify-patches.sh
  • Fresh rebuilt codex binary on this device at target/ci-test/codex
  • Interactive --ask-for-approval on-request repro using the rebuilt binary
  • Confirmed that choosing persistent approval writes a prefix_rule entry to ~/.codex/rules/default.rules
  • Confirmed that the previous Failed to apply execpolicy amendment ... failed to lock policy file ... lock() not supported warning does not occur in the rebuilt flow

Allow persistent approval amendments to proceed on Android when file locking is reported as unsupported, while keeping unsupported lock errors as failures on non-Android targets. This matches Termux behaviour without widening the fallback elsewhere.

Record the fork delta in the patch inventory and generate a dedicated patch artifact so the compatibility change is tracked in the same way as the other Termux-specific runtime patches.

Verified with cargo test -p codex-execpolicy and bash verify-patches.sh. A full cargo build -p codex-cli could not be completed on-device because clang failed during the final link step with a bus error.

Co-authored-by: Codex <codex@openai.com>
GFernie and others added 2 commits March 25, 2026 22:34
Keep the execpolicy fix tracked through source changes and the Termux patch inventory rather than treating it like a Bazel or toolchain patch file.

This matches the existing meaning of the files under patches/, which are carried upstream and dependency patch assets rather than a general store of generated fork diffs.

Verified with bash verify-patches.sh.

Co-authored-by: Codex <codex@openai.com>
Add a Termux-backed regression test for execpolicy rule persistence. This exercises the real append path on Android instead of relying only on mocked Unsupported lock results.

The fix is now verified three ways: cargo test -p codex-execpolicy, verify-patches.sh, and an interactive rebuilt codex session where persistent approval wrote a prefix_rule to default.rules without the previous lock() failure.

Co-authored-by: Codex <codex@openai.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Persistent approval fails to update execpolicy rules on Termux

1 participant