fix(docker): clear the world bit on uv cache entries instead of deleting .lock

uv creates its cache locks 0666 itself (umask-independent): the root .lock
and one <entry>.lock per wheel/sdist entry. `-name .lock -delete` only got
the root ones, left the per-entry locks world-writable (and copied into
every $HERMES_HOME/cache/uv by the seed), and deleted setuptools'
_vendor/.lock from an unpacked cached wheel. Drop o+w by mode instead;
this is what the docker test asserts and removes no cache content.

Refs #139327

Co-authored-by: Bear Huddleston <196404565+BearHuddleston@users.noreply.github.com>
This commit is contained in:
Maciej Lisiewski
2026-11-14 12:05:03 +01:00
parent 2e6b319ba9
commit a98abb3868
2 changed files with 6 additions and 6 deletions

View File

@@ -543,13 +543,13 @@ COPY --chmod=0644 docker/profile-hermes-path.sh /etc/profile.d/hermes.sh
# image these are shared, non-secret package metadata, read by UID 10000.
# uv's environment locks are build-only and may be world-writable. Remove
# them after all builds; never relax permissions on mutable PM/home state.
# uv's cache tree scatters its own .lock files (cache root, per-sdist
# build dirs) through /opt/hermes/uv-cache — sweep those too, they only
# exist so concurrent build-time uv processes can flock them and the
# runtime re-creates any it needs in the writable machine cache.
# uv also creates its cache locks 0666 (the root .lock and one <entry>.lock
# per wheel/sdist entry), and the seed copy into $HERMES_HOME/cache/uv keeps
# modes. Drop the world bit instead of deleting by name: "*.lock" also matches
# files inside unpacked wheels (setuptools/_vendor/.lock).
RUN mkdir -p /opt/data && chmod 0644 /opt/hermes/tools/facts.json && \
rm -f /opt/hermes/.venv/.lock /opt/hermes/pm-runtime/.lock && \
find /opt/hermes/uv-cache -name .lock -delete
find /opt/hermes/uv-cache ! -type l -perm -0002 -exec chmod o-w {} +
# Build helpers use system Python above; TUI gateway children need the sealed runtime.
ENV HERMES_PYTHON=/opt/hermes/.venv/bin/python
VOLUME [ "/opt/data" ]

View File

@@ -62,7 +62,7 @@ for relative in ('pm-runtime/pm-runtime.json', 'tools/facts.json', 'manifest.jso
for relative in ('.venv/.lock', 'pm-runtime/.lock'):
path = Path('/opt/hermes') / relative
assert not path.exists() or not os.access(path, os.W_OK), path
# uv creates its cache .lock files 0666 under buildkit's umask; the seed copies modes.
# uv creates its cache lock files 0666 whatever the umask; the seed copies modes.
for parent, dirs, files in os.walk('/opt/hermes/uv-cache'):
for name in dirs + files:
path = Path(parent) / name