Repository navigation
filesync: keep a symlink's permission bits out of a host directory's digest - #15168
Merged
Merged
Conversation
…digest
A symlink has permission bits of its own on macOS, taken from the umask it
was created under. On Linux a symlink is always 0777. The client sent the
host's bits, the engine hashed them, and the mirror's link was 0777 either
way, since Linux has no bits to set on it. So one tree had one digest from a
macOS client and another from a Linux client:
$ ln -s notes.md tree/latest.md # macOS, umask 022: lrwxr-xr-x
$ dagger -m core api call host directory --path tree digest
sha256:523803c6...
# the same tree from a Linux client, or with the link made under umask 000
sha256:e1ee8b8a...
This is the case dagger#13389 fixed for host xattrs: metadata that cannot
round-trip through the Linux mirror is not source identity.
Send 0777 for a symlink from the client, next to the uid, gid and xattrs it
already normalizes. Hash a symlink as 0777 in the engine too, so a client
older than this change gets the same digest: the engine accepts clients back
to v0.19.0. A file's and a directory's bits are still sent and hashed.
A macOS client's digest of a tree with symlinks changes once. A Linux
client's does not.
Fixes dagger#15167
Signed-off-by: Dan Shaw <[email protected]>
Signed-off-by: Dan Shaw <[email protected]>
Signed-off-by: Dan Shaw <[email protected]>
dshaw
marked this pull request as ready for review
November 13, 2026 23:51
sipsma
approved these changes
Nov 17, 2026
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.
Fixes #15167
The digest of a host directory depends on a symlink's permission bits, so the same tree has one digest from a macOS client and another from a Linux client.
Reproduce
Needs only the CLI. Same digests on v1.0.0-beta.25 and v1.0.0-beta.27, and with a CLI built from main (
3991a28b9d) against a v1.0.0-beta.27 engine.macOS client:
Linux client, same engine:
sha256:e1ee8b8a…three times, since a symlink is always0777there.Cause
normalizeLocalImportStatclears uid, gid and xattrs before the client sends a stat, and sends the mode as the host reports it.statHashhashes the mode it was sent.localFS.Symlinkcreates the link in the mirror andrewriteMetadataskips chmod for symlinks, so the mirror's link is0777whatever was sent.This is the case #13389 fixed for host xattrs: metadata that cannot round-trip through the Linux mirror is not source identity.
Change
0777for a symlink, next to the other normalization.0777, so a client older than this change gets the same digest (the engine accepts clients back to v0.19.0).A file's and a directory's bits are still sent and hashed.
A macOS client's digest of a tree with symlinks changes once. A Linux client's does not.
Tested
TestSyncDigestIgnoresSymlinkPermissionssyncs one tree with the link reported as0755and as0777and compares the digests, cold and warm. It fails without thehash.gochange and passes with it.TestNormalizeLocalImportStatSymlinkPermissionsfor the client.go test ./engine/filesync/ ./engine/client/passes.sha256:e1ee8b8a…three times.hack/build: the released v1.0.0-beta.27 CLI and a CLI built from main both printsha256:e1ee8b8a…three times.Not tested: an engine built from main as the like-for-like engine without the change (the released v1.0.0-beta.27 engine stands in for it), the integration suite, and a Windows client.
Checklist
dagger check '*:lint'passes.dagger check golangci-lint:lint-allpasses.dagger generaterun on the branch: every generator finished and it reports no changes to apply.changie new.