Repository navigation
fix: harden update cache boundary - #72
Merged
Merged
Conversation
This was referenced Sep 28, 2026
Reject FIFOs and other special files at the cache and refresh-lease paths with an lstat pre-check, O_NONBLOCK opens, and an fstat device/inode revalidation so diagnostic commands never block on them. Treat the cache as advisory for explicit check-update: an unavailable lease or cache write no longer turns a successful registry check into an error. The result adds optional cacheUpdated and cacheWarning fields and human output prints one stderr warning. Skip cache reads, writes, and automatic refreshes when running as UID 0 or when the nearest existing cache ancestor is not owned by the current UID, without creating directories or repairing foreign-owned state. Closes #57 Closes #62 Closes #70
abruption
force-pushed
the
fix/update-cache-boundary
branch
from
September 29, 2026 00:23
24c8e12 to
d15c9f3
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
update.lockare checked withlstatas private regular files before opening, opened withO_NOFOLLOW | O_NONBLOCK, and revalidated withfstat(device/inode) after opening. The final verification open inwriteUpdateCacheis also non-blocking. A FIFO now yields an invalid cache (cache_file_is_not_private) or an unavailable lease (refresh_lock_is_not_private) immediately.check-updateuses a newcheckForUpdate()that treats the cache as advisory. If the lease or cache write fails, a successful registry result is still reported withstatus: "ok"and exit 0. Lease contention without a fresh cache still returnsrefresh_in_progress, and registry failures still exit 3. Human output prints one stderr warning (update cache not updated: <reason>); JSON mode keeps stderr empty.mkdirin the read, write, and lease paths, including the background refresh child. It returnscache_user_is_elevatedfor UID 0, andcache_root_owner_mismatch/cache_root_is_unsafe/cache_root_unavailablewhen the nearest existing ancestor of the cache directory is not a directory owned by the current UID. Automatic notices and refresh scheduling are skipped in that case. Nothing is chowned or chmodded to repair foreign-owned state.Closes #57
Closes #62
Closes #70
Type
Safety impact
No change to lock probing, owner validation, or signaling. JSON output changes are additive:
checkUpdateResultgains optionalcacheUpdated: booleanandcacheWarning: string | null. Both are optional in the schema and the TypeScript types and are documented indocs/json-v1.mdas "Since 0.4.1"; the statement that cache-write failures exit 3 was removed.Checklist
npm run checkpassesnpm run lintpassesnpm testpasses (95 pass, 0 fail)npm run smoke:packagepassesNotes
list --jsonwith a FIFO at the cache file blocks indefinitely onmainand exits 0 immediately with this change.check-updatein an unusable cache location; this follows fix: explicit check-update fails when the cache directory is not writable #62 (report the registry result, with the reason incacheWarning) and never creates directories in a foreign-owned home.XDG_CACHE_HOMEdoes not exist and its nearest existing ancestor is not owned by the current user (for example a new directory under/tmp), the cache is now not used. This fails in the safe direction.HOME/XDG_CACHE_HOMEand injected fetch only; optionaluidparameters were added as test seams.