Skip to content

feat(extract): add --preserve-permissions option to maintain original file modes - #24

Merged
zombocoder merged 2 commits into
mainfrom
fix/extract-permissions-umask
Oct 24, 2026
Merged

zombocoder merged 2 commits into
mainfrom
fix/extract-permissions-umask

Conversation

@zombocoder

Copy link
Copy Markdown
Owner

This pull request introduces improved and more consistent handling of file and directory permissions when creating and extracting containers, with special attention to cross-platform (POSIX/Windows) behavior. It adds a new --preserve-permissions option to extraction, ensures modes are recorded and restored correctly, documents these behaviors, and adds comprehensive tests.

Permission handling improvements:

  • Added a new --preserve-permissions option to the extract command, allowing users to restore exact archived permission bits instead of applying the umask, including for existing directories. [1] [2] [3] [4] [5] [6] [7] [8]
  • Extraction now applies the umask to file and directory modes by default, matching tar behavior, and only restores archived modes exactly with --preserve-permissions. [1] [2]
  • Existing directories retain their permissions unless --preserve-permissions is used, preventing accidental permission loosening. [1] [2]

Cross-platform (Windows/POSIX) compatibility:

  • On Windows, bfc create now records conventional POSIX permissions (0644 for files, 0755 for directories/executables), ignoring the CRT's emulated permissions, for consistency across platforms. [1] [2] [3] [4]

Documentation updates:

  • Updated the README.md to document the new --preserve-permissions option, the default umask behavior, and clarify cross-platform permission handling. [1] [2]

Testing:

  • Added comprehensive shell tests to verify correct permission handling, umask application, and the effect of --preserve-permissions for both files and directories.

CI improvements:

  • Enhanced CI to check that archives created on Windows record the expected POSIX permissions.

@zombocoder
zombocoder merged commit afdc0ff into main Oct 24, 2026
11 checks passed
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.

1 participant