Skip to content

Make the Shell Secret Readers Run on macOS #3933

Open

Description

@ptr727

lib/sh/secrets.sh reads a file's mode and owner with GNU stat -c, at secret_shape_verdict (stat -c '%a' and stat -c '%U'). It also splits a path with readarray -d / in secret_state, which needs bash 4.4 or later. docs/host-setup.md lists macOS as a supported host-install platform. On a stock macOS host, BSD stat rejects -c and the system bash is 3.2. So every present secret file is refused with "the mode of ... could not be read", or the path walk fails, whatever the file's actual mode.

Why It Matters Now

The #3932 change, configure.sh apply's secrets group, is the first caller that puts the library on a hub-checkout path a macOS maintainer host runs. On macOS that group would refuse every secret, set nothing, and exit non-zero after every other group was applied. Before #3932, the library's only callers ran on Linux hosts carrying a host-secrets repository.

Reproduce

On macOS with no GNU coreutils on PATH, construct a private file and ask the library about it:

d="$(mktemp -d)"; printf 'x' > "$d/example"; chmod 600 "$d/example"
bash -c '. lib/sh/secrets.sh; secret_verdict "$1"' _ "$d/example"

The expected answer is readable. The answer on BSD stat is a refused sentence about an unreadable mode.

Proposal

Read the mode and owner portably, choosing stat -f '%Lp'/%Su where stat -c is unavailable, or one probe chosen once. Replace readarray -d with a loop that runs on bash 3.2, or state a bash 4.4 floor that host_gate.py enforces on macOS. Then extend tests/test_secrets_sh.py to cover whichever probe is chosen. The library is carried byte-for-byte, so the fix lands here at its canonical source.

🤖 Generated with Claude Code

Activity

  1. added
    bug
    pre-existing
    script
    on Nov 8, 2026
  2. ptr727 commented on Nov 24, 2026

    @ptr727
    OwnerAuthor

    The away-mode backlog-burndown run (2026-11-24, round 3) split this issue's one open choice, a bash 3.2 loop versus a bash 4.4 floor for readarray -d, into decision #4408. This issue stays held for a macOS host, since the defect reproduces only there and no CI job runs on macOS. The portable stat half needs no answer.

  3. ptr727 commented on Nov 25, 2026

    @ptr727
    OwnerAuthor

    Decision #4408 is answered (2026-11-25): macOS gets a bash 4.4 floor, enforced by scripts/host_gate.py through a bash entry in spec/host-tools.json. lib/sh/secrets.sh keeps readarray -d. The portable stat half of this issue is unchanged.

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

    bugpre-existingscript

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions