Skip to content

fix(publish): S_IFREG + create_system=3 on wheel scripts (1.2.13) - #35

Merged
zackees merged 2 commits into
mainfrom
fix/publish-exec-bit
Apr 19, 2026
Merged

zackees merged 2 commits into
mainfrom
fix/publish-exec-bit

Conversation

@zackees

@zackees zackees commented Apr 19, 2026 •

Copy link
Copy Markdown
Collaborator

Summary

Every zccache Linux/macOS wheel shipped to PyPI has had the bundled zccache binary install without execute permissions:

/usr/local/bin/zccache: Permission denied (exit 126)

Two bits both need to be set for pip's wheel installer to apply the script's mode bits; both were missing in ci/publish.py:

  1. info.create_system = 3 (Unix). The default is 0 (DOS), under which pip interprets external_attr as DOS file attributes rather than Unix mode, so the perm bits are ignored entirely.
  2. stat.S_IFREG (regular-file type bit, 0o100000) OR-ed into the mode. pip calls stat.S_ISREG() on the upper 16 bits of external_attr before applying the mode; without IFREG the test returns False and pip falls back to umask defaults (0o644) even when 0o755 is set.

With both corrected, script entries now ship external_attr=0x81ed0000 — byte-identical to uv / ruff / maturin-built wheels.

Context

Surfaced during the FastLED/fbuild 2.1.20 postmortem (FastLED/fbuild#143). fbuild had the same S_IFREG bug but did set create_system=3. zccache is missing both, which means its wheels have been broken on non-Windows essentially since the publish script was written.

Ecosystem-wide audit tracking issue: zackees/self#25.

Also included: version bump to 1.2.13

1.2.12's PyPI filenames are permanently burned — PyPI doesn't allow re-uploading, so shipping the fix requires a fresh version. Cargo.toml workspace version + all 18 =1.2.12 intra-workspace pins + Cargo.lock bumped.

Verification

Rebuild any wheel locally from dist/ and check:

import zipfile, stat
with zipfile.ZipFile('dist/wheels/zccache-1.2.13-py3-none-manylinux_2_17_x86_64.whl') as z:
    for i in z.infolist():
        if '.data/scripts/' in i.filename:
            m = i.external_attr >> 16
            ok = i.create_system == 3 and stat.S_ISREG(m) and m & 0o100
            print(f'{i.filename}: external_attr=0x{i.external_attr:08x}  ok={ok}')

Expected (post-fix): external_attr=0x81ed0000 ok=True.
Previously: external_attr=0x01ed0000 ok=False (and create_system=0, so the S_ISREG test wasn't even the first failure — the create_system guard fails first).

Test plan

  • cargo check --workspace clean after version bumps
  • uv lock clean
  • ./publish cuts 1.2.13 and Step 6 (or equivalent post-upload check) passes
  • pip install zccache==1.2.13 && zccache --help on Linux returns exit 0

Follow-ups for the wider audit

Per zackees/self#25:

  • Add a post-build assertion to ci/publish.py that rejects any wheel whose .data/scripts/* entries don't have create_system=3 and S_ISREG(mode) and mode & 0o100. Turns this bug class into a build-time failure.
  • Consider landing a canonical publish.py in zackees/python-rust-build-chain so future Rust+Python repos copy a known-good pattern.

🤖 Generated with Claude Code

zackees and others added 2 commits April 19, 2026 01:58
Every zccache Linux/macOS wheel shipped to PyPI has had the
bundled `zccache` binary install without execute permissions:

    /usr/local/bin/zccache: Permission denied  (exit 126)

Two bits both need to be set for pip/installer to apply the mode
bits to the unpacked script, and both were missing:

- `info.create_system = 3` tells the unpacker to interpret
  external_attr as Unix mode bits. The default is 0 (DOS) under
  which the unpacker interprets external_attr as DOS file
  attributes and ignores Unix perms entirely.
- `stat.S_IFREG` is the regular-file type bit. pip calls
  `stat.S_ISREG()` on the upper 16 bits and falls back to umask
  defaults (0o644) when it's missing, even when 0o755 is set.

With both corrected, script entries now ship external_attr
0x81ed0000 — byte-identical to uv / ruff / maturin-built wheels.

This was discovered during the FastLED/fbuild 2.1.20 postmortem
that found the exact same bug (S_IFREG) shipped there. zccache is
worse because it's also missing create_system=3, so its wheels
have been broken on non-Windows since the script was written.

Ecosystem-wide audit: zackees/self#25.

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
First release with working Linux/macOS script permissions on the
bundled `zccache` binary. Prior releases are all broken on
non-Windows: `zccache: Permission denied` on any command.

Release notes vs 1.2.12:

- fix(publish): set S_IFREG + create_system=3 on wheel script
  entries so pip applies +x to the bundled binary on install

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
@zackees zackees changed the title Fix/publish exec bit fix(publish): S_IFREG + create_system=3 on wheel scripts (1.2.13) Apr 19, 2026
@zackees
zackees merged commit d91b5ab into main Apr 19, 2026
7 of 8 checks passed
@codecov

codecov Bot commented Apr 19, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

zackees added a commit to FastLED/fbuild that referenced this pull request Apr 19, 2026
1.2.12 is the last zccache release that ships broken Linux/macOS
wheels — the bundled `zccache` binary lacks +x and every cache
operation fails with `Permission denied`. The upstream fix landed
in zccache 1.2.13 (forge-ci/zccache#35: S_IFREG + create_system=3
on wheel script entries). Bumping the floor so fresh pip installs
of fbuild 2.1.21 don't pin themselves to a broken zccache.

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
zackees added a commit to FastLED/fbuild that referenced this pull request Apr 19, 2026
1.2.12 is the last zccache release that ships broken Linux/macOS
wheels — the bundled `zccache` binary lacks +x and every cache
operation fails with `Permission denied`. The upstream fix landed
in zccache 1.2.13 (forge-ci/zccache#35: S_IFREG + create_system=3
on wheel script entries). Bumping the floor so fresh pip installs
of fbuild 2.1.21 don't pin themselves to a broken zccache.

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
zackees added a commit to FastLED/fbuild that referenced this pull request Apr 19, 2026
1.2.12 is the last zccache release that ships broken Linux/macOS
wheels — the bundled `zccache` binary lacks +x and every cache
operation fails with `Permission denied`. The upstream fix landed
in zccache 1.2.13 (forge-ci/zccache#35: S_IFREG + create_system=3
on wheel script entries). Bumping the floor so fresh pip installs
of fbuild 2.1.21 don't pin themselves to a broken zccache.

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
@zackees
zackees deleted the fix/publish-exec-bit branch November 5, 2026 05:56
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.

1 participant