Skip to content

opencode-config-normalize: atomic repair drops file-specific POSIX ACLs #11836

Closed

Description

@dezren39

Problem

When pkgs/opencode-config-normalize/normalize.sh repairs a config, its atomic temp-file replacement preserves the POSIX mode bits but drops file-specific extended ACL entries. A named user/group ACL on the original config is silently lost when the temp inode replaces it. If the directory has a default ACL, the new temp may inherit that default, but that is not the original file's ACL and does not preserve file-specific entries.

Evidence (reproduced on current main)

  • normalize.sh:55 captures only stat.S_IMODE(path.stat().st_mode).
  • normalize.sh:685-700 writes to a tempfile.mkstemp sibling, applies only os.fchmod(..., original_mode), fsyncs, then tmp.replace(path).
  • Fixture: mode 0640, ACL user:1001:r-- and mask::r--; after a real repair, mode remains 640 but the named user ACL and ACL mask are gone. The repaired JSON content is correct.
  • A second fixture confirmed a file-specific user:1002:--- ACL disappears even when the directory supplies a default ACL; entries that reappear came from default-ACL inheritance on the new temp inode, not preservation of the original.
  • bash pkgs/opencode-config-normalize/normalize_test.sh passes all 27 cases, including mode-preserved and symlink-refused; there is no ACL assertion.

Why it matters

A config may use an ACL to grant or restrict access for a specific local account independently of its mode bits. A successful normalization then silently changes that access policy. The file's content and 0600/0640 mode can look correct while its ACL has changed.

Acceptance criteria

  • A fixture with a file-specific named POSIX ACL is repaired and retains the same ACL entries/mask afterward (where ACL tooling/filesystem support is available; otherwise the test reports an explicit skip).
  • Default-directory ACL inheritance is not mistaken for preserving the original file ACL.
  • ACL preservation behavior is documented, including behavior on platforms/filesystems without supported ACL operations.
  • All existing normalize_test.sh cases still pass.

Related and deduplication

Activity

  1. added
    kind/bugSomething isn't working (prefixed form of the classic bug label)
    task/triageQueue packet kind: verify, reproduce, and route this item
    source/creatorFiled by the new-issue-creator job
    priority/normalOrdinary priority (the default)
    app/opencode-config-normalizePackage/app: opencode-config-normalize (pkgs/ or apps/ in this repo)
    effort/sSmall: expected under 2 hours of work
    on Nov 18, 2026
  2. developing-today commented on Nov 18, 2026

    @developing-today
    Contributor
  3. dezren39 commented on Nov 18, 2026

    @dezren39
    MemberAuthor

    agent-note:v1
    state: picked up
    task: 20822
    issue: #11836
    lane: oc-code-01 (OpenChamber scheduled lane, repo-worker-code)
    at: 2026-11-18T17:38Z

    Claimed triage task 20822; first checkpoint includes origin: openchamber-scheduled-lane. Fresh GitHub verification confirms #11836 remains OPEN, assigned to Drew, and has no held/user-owned/do-not-merge/do-not-auto-edit labels. The current atomic write path captures mode bits and fchmods a new inode before replace. setfacl and getfacl are installed and /home is ext4, so I will try a focused reproduction in an isolated temporary directory; no code changes are in scope.

  4. dezren39 commented on Nov 18, 2026

    @dezren39
    MemberAuthor

    Triage findings (task 20822)

    Confirmed on the current checkout; no repository code was changed. The write path saves stat.S_IMODE, creates a replacement inode with mkstemp, applies only fchmod, then atomically replaces the config. It does not snapshot or restore ACLs.

    Reproduction on ext4 with setfacl/getfacl available: an original user:65534:r-- ACL entry and mask::r-- disappeared after a real repair; mode stayed 0640. A second reproduction gave the parent directory a default ACL for user 65534 and added a file-specific entry for user 65533. After replacement, the new file had inherited 65534 but lost file-specific 65533. This distinguishes default inheritance from preserving the original file ACL.

    bash pkgs/opencode-config-normalize/normalize_test.sh passes all 27 existing cases; none asserts ACL preservation.

    Recommended implementation/test scope: before replacement, snapshot the original file access ACL numerically; after writing and applying mode to the temporary inode, restore that ACL to the temp file and verify it matches before rename. If an extended ACL is present but cannot be read/restored/verified, fail closed and leave the original file untouched rather than silently dropping access policy. Add an ACL-capability-gated regression test with a directory default ACL plus a distinct file-specific named-user ACL and mask, asserting the file-specific entry survives repair and inherited defaults are not mistaken for the source ACL. Keep unsupported-platform behavior explicit.

    Routing this bounded implementation as a follow-up queue task; this triage task made no code changes.

  5. dezren39 commented on Nov 18, 2026

    @dezren39
    MemberAuthor

    Routing note: The bounded implementation follow-up is deliberately not queued in this pass because creation of its packet file was explicitly canceled. I am not retrying the same enqueue through another mechanism. Triage evidence and recommended scope are recorded above; a later authorized lane can create the implementation packet. No implementation/code changes were made by this triage task.

  6. dezren39 commented on Nov 18, 2026

    @dezren39
    MemberAuthor

    Task 20823 picked up for fresh triage verification. #11836 remains open and assigned to dezren39; no matching open PR exists. Prior fresh findings on #11836 document a reproducible ACL-loss mechanism and recommend ACL snapshot/restore/verify plus a capability-gated regression test. I am rechecking the current default-branch write path and reproduction, with no production edits in scope.

  7. 1 remaining item

  8. dezren39 commented on Nov 18, 2026

    @dezren39
    MemberAuthor

    Triage verification (task 20823, lane oc-code-04)

    Freshly checked on current main (49fa683); issue #11836 remains OPEN and assigned to dezren39, with no matching open PR. No production files were changed.

    I independently confirmed the loss on this host (setfacl/getfacl available; filesystem reported by stat -f as ext2/ext3): the normalizer captures stat.S_IMODE, writes a new inode, applies fchmod, and replaces the original without snapshotting its ACL. A named-user ACL and mask disappeared after actual repair while mode remained 0640. With a parent default ACL for user 65534 and a distinct file-specific entry for 65533, replacement inherited 65534 but lost 65533. This distinguishes directory-default inheritance from preserving the original access ACL. bash pkgs/opencode-config-normalize/normalize_test.sh passed all 27 existing cases; none covers ACLs.

    Recommended implementation/test scope: snapshot the source access ACL before replacement, restore it to the temporary inode, and verify it before rename; if an extended ACL cannot be read/restored/verified, fail closed and leave the original untouched. Add a capability-gated regression with a default ACL and a distinct file-specific named-user ACL/mask, asserting that the source entry survives repair; keep unsupported-platform behavior explicit.

    Routing blocker: the preceding triage note for task 20822 explicitly records that follow-up packet creation was canceled and must not be retried through another mechanism. I therefore did not enqueue a duplicate follow-up. The cancellation is the concrete routing blocker; a later authorized lane can create the implementation packet.

  9. dezren39 commented on Nov 18, 2026

    @dezren39
    MemberAuthor

    Task 20823 verified the ACL-loss reproduction and documented implementation/test scope above. The queue packet has a material defect: payload.kind is small_fix, but its title, body, and acceptance define a triage-only task. The broker consequently applies fix-class completion rules and rejects a triaged outcome without a verified disposition/successor. The prior task's note explicitly canceled follow-up packet creation and forbids retrying it through another mechanism, so I did not create one. Blocked as packet_defect; no tracked code changes.

  10. added a commit that references this issue on Nov 19, 2026
  11. removed their assignment
    on Nov 20, 2026
  12. dezren39 commented on Nov 22, 2026

    @dezren39
    MemberAuthor

    Merged work, still open. Every pull request that references this issue has merged (#12007) and none is open, but the issue kept status:in-review. Tasks that name it as a blocker have been waiting on it.

    status:in-review is removed. Whoever takes this next: run the issue's done check against main. Close the issue if it passes; if not, list what is left here and carry on with it (AGENTS.md, "Finishing work").

    By: Claude, 2026-11-22 flow review.


    Generated by Claude Code

  13. dezren39 commented on Nov 23, 2026

    @dezren39
    MemberAuthor

    agent-note:v1
    state: done
    issue: #11836
    lane: aai
    worker: claude-lane-aai
    origin: packet-defect census feed (via #13191 census, comment 7104845806)
    stage: verified -> closed

    Done check run against current main, per the 2026-11-22 flow-review instruction on this issue ("run the issue's done check against main; close the issue if it passes").

    Premise/ownership: issue OPEN, all 9 comments read; no live lane claim (prior comments are completed triage from 2026-11-18 and the flow-review note). The implementation already landed in PR #12007 (merged 2026-11-19T03:29:18Z, merge commit 4491209): normalize.sh snapshots the raw system.posix_acl_access xattr before the atomic replace, restores it on the temp inode after fchmod, verifies it, and fails closed (exit 1, config untouched) when the ACL cannot be read/restored/verified; header documents behavior on platforms/filesystems without POSIX ACL support.

    Verification (laptop amd-6, files extracted from origin/main 4421467, bash pkgs/opencode-config-normalize/normalize_test.sh):

    • acl-preserved PASS — file-specific named ACL survives a real repair (acceptance criterion 1)
    • acl-not-inherited PASS — directory default-ACL inheritance is not mistaken for preservation (criterion 2)
    • Documentation criterion: normalize.sh header documents the ACL behavior including the no-POSIX-ACL fallback (criterion 3)
    • Full suite: "normalize_test: all cases passed", including the pre-existing mode-preserved and symlink-refused cases (criterion 4)

    All acceptance criteria are met on main. Closing as completed. The stale status/blocked / queue/blocked labels reflected the cancelled queue packet, not the code state.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    app/opencode-config-normalizePackage/app: opencode-config-normalize (pkgs/ or apps/ in this repo)effort/sSmall: expected under 2 hours of workkind/bugSomething isn't working (prefixed form of the classic bug label)priority/normalOrdinary priority (the default)queue/blockedQueue or user escalation statesource/creatorFiled by the new-issue-creator jobstatus/blockedQueue or user escalation statestatus:donetask/triageQueue packet kind: verify, reproduce, and route this item

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions