fix: preserve file permissions during unpack operation#1
Open
erik-at-flipside wants to merge 1 commit intomainfrom
Open
fix: preserve file permissions during unpack operation#1erik-at-flipside wants to merge 1 commit intomainfrom
erik-at-flipside wants to merge 1 commit intomainfrom
Conversation
c1bbdc7 to
21185e8
Compare
- Parse ZIP central directory to extract Unix file permissions - Restore executable permissions using chmodSync after unpacking files - Skip permission restoration on Windows (Unix-only feature) - Add comprehensive test to verify executable and regular file permissions are preserved - Fix test setup to use npm instead of yarn for consistent build process Fixes issue where executable files lose their execute permissions after being packed and unpacked, which is critical for extensions containing binary executables or shell scripts. 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
21185e8 to
c8f7931
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
chmodSync()after unpacking filesProblem
When packing extensions that contain executable files (like binary executables or shell scripts), the unpack operation was not preserving the original file permissions. This meant that executable files would lose their execute permissions (
-rwxr-xr-x→-rw-r--r--), breaking functionality for extensions that depend on executable binaries.Solution
The fix involves:
fs.chmodSync()to restore Unix file permissions after writing each fileTest Plan
npminstead ofyarnfor consistencyTechnical Details
The pack operation already correctly stores Unix permissions in the ZIP file's external attributes field (implemented in modelcontextprotocol#14). This PR completes the round-trip by extracting and restoring those permissions during unpack.
The ZIP central directory format stores file permissions in the upper 16 bits of the external attributes field. The fix parses this metadata and maps it back to the original file paths for restoration.
🤖 Generated with Claude Code