Skip to content

NAR: both walks open a regular file without following a symlink, as upstream's dump does - #118

Merged
AniAthena merged 1 commit into
mainfrom
nar/open-without-following
Dec 4, 2026
Merged

AniAthena merged 1 commit into
mainfrom
nar/open-without-following

Conversation

@AniAthena

@AniAthena AniAthena commented Dec 4, 2026 •

Copy link
Copy Markdown
Collaborator

Both walks opened a regular file by name through GHC's openFile, which follows a symlink, so a regular file replaced by a symlink to another regular file between its lstat and its open was archived as a regular file holding the target's bytes. Upstream's dump opens without following one in the file's place: O_NOFOLLOW at 2.24.9 and openFileEnsureBeneathNoSymlinks at 2.36.0 (posix-source-accessor.cc).

A new openWalkedFile opens the file for both walks: on POSIX by its raw path bytes with O_NOFOLLOW, non-blocking so a FIFO swapped in is still refused by the size read rather than waiting for a writer, and on Windows by name as before. A symlink is refused at the open as a NarWalkError for WalkReadFile. Tests swap the file for a symlink through the executable-bit resolver, which runs after the classification and before the open, for each walk. readFileBytes's comment now names where upstream reads the recorded size.

O_NOFOLLOW covers only the file's own place: upstream also refuses a symlink among its ancestors, which needs a walk by directory descriptors in both walks and is #119.

Closes #117

@AniAthena
AniAthena marked this pull request as ready for review December 4, 2026 21:11
aoinoikaz
aoinoikaz previously approved these changes Dec 4, 2026
@AniAthena
AniAthena force-pushed the nar/open-without-following branch from 4bbbc52 to 3225260 Compare December 4, 2026 21:31
@AniAthena
AniAthena merged commit 2ff0dfd into main Dec 4, 2026
12 checks passed
@AniAthena
AniAthena deleted the nar/open-without-following branch December 4, 2026 22:28
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.

NAR: both walks open a regular file through a symlink, where upstream's dump refuses one at the open

2 participants