Skip to content

Use lchmod for zip extract

Matthew Bradburn requested to merge mbradburn/use-lchmod-for-zip-extract into main

What does this MR do?

It switches the zip archive extractor to use lchmod() to set extracted file modes instead of os.Chmod().

Why was this MR needed?

Chmod() follows symlinks, creating a situation in which we attempt to set the mode bits on a symlink but end up modifying the mode bits on the referenced file instead.

What's the best way to test this MR?

I tested it by running a CI pipeline that creates a cache archive containing a symlink that references a file also in the cache, and then in another job it extracts the cache and checks the mode bits on the cached files. I did this on windows (with pwsh), debian, and macos. This is the best way I could think of to test it, but I'd be interested in additional ideas.

What are the relevant issue numbers?

#27496 (closed)

Merge request reports