Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

contenthash: clear ModeIrregular before sending to archive/tar #5665

Merged
merged 1 commit into from
Jan 16, 2025

Conversation

jsternberg
Copy link
Collaborator

Clears ModeIrregular from the checksum generation. This may be sent by the client when the version of Go used is post Go 1.23. The behavior of os.Stat was modified in Go 1.23 to set ModeIrregular on reparse points in Windows. This clears ModeIrregular when any mode is set which was the previous behavior of os.Stat.

Fixes docker/for-win#14083.

Clears ModeIrregular from the checksum generation. This may be sent by
the client when the version of Go used is post Go 1.23. The behavior of
`os.Stat` was modified in Go 1.23 to set `ModeIrregular` on reparse
points in Windows. This clears `ModeIrregular` when any mode is set
which was the previous behavior of `os.Stat`.

Signed-off-by: Jonathan A. Sternberg <jonathan.sternberg@docker.com>
@jsternberg jsternberg force-pushed the clear-mode-irregular branch from 5887a6c to 45177da Compare January 15, 2025 19:03
Copy link
Member

@tonistiigi tonistiigi left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So are these files created as regular empty files on transfer?

// bit to regular files with non-handled reparse points.
// Current versions of Go now apply them to directories too.
// archive/tar.FileInfoHeader does not handle the irregular bit.
if stat.Mode&uint32(os.ModeType&^os.ModeIrregular) != 0 {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Isn't the negation wrong in the condition here?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The intention is to use os.ModeType but to remove os.ModeIrregular because os.ModeIrregular&os.ModeType will always return non-zero. so this uses the os.ModeType constant but removes os.ModeIrregular from it.

It's a bit tricky because the original condition checks if m&os.ModeType == 0 and sets os.ModeIrregular if it is. But, because we've now set os.ModeIrregular, the condition will always be true so the reverse doesn't work.

@jsternberg
Copy link
Collaborator Author

I think they should get created as regular directories. Files will be excluded from this behavior and will still return an error which is what they previously did. While I used os.ModeType to cover everything like named pipes and others, I think the only things that get irregular set are directories with certain attributes.

@tonistiigi
Copy link
Member

. Files will be excluded from this behavior and will still return an error which is what they previously did.

Where is that error happening?

@jsternberg
Copy link
Collaborator Author

@tonistiigi tonistiigi added this to the v0.19.0 milestone Jan 15, 2025
@thompson-shaun thompson-shaun merged commit f55aa54 into moby:master Jan 16, 2025
97 checks passed
@jsternberg jsternberg deleted the clear-mode-irregular branch January 16, 2025 21:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

failed to solve: archive/tar: unknown file mode ?rwxr-xr-x while following official tutorial
3 participants