Skip to content

fix: respect process umask when creating files - #776

Open
devk0n wants to merge 1 commit into
stevearc:masterfrom
devk0n:fix-respect-umask
Open

fix: respect process umask when creating files#776
devk0n wants to merge 1 commit into
stevearc:masterfrom
devk0n:fix-respect-umask

Conversation

@devk0n

@devk0n devk0n commented Aug 22, 2026

Copy link
Copy Markdown

Summary

Use standard pre-umask creation modes for new files and directories so Oil respects the process umask.

Previously Oil requested:

  • files as 0644
  • directories as 0755

Because a process umask can only remove permission bits, users with a group-writable umask such as 0002 still received 0644 files and 0755 directories.

This changes the creation modes to:

  • files: 0666
  • directories: 0777

and allows the operating system to apply the process umask normally.

Example

With:

umask 0002

Oil now creates:

  • files as 0664
  • directories as 0775

With:

umask 0022

the existing behavior is preserved:

  • files as 0644
  • directories as 0755

With:

umask 0000

Oil creates:

  • files as 0666
  • directories as 0777

Implementation

Updated the creation modes used by:

  • fs.touch
  • mkdirp
  • local directory creation
  • macOS trash user-entry directory creation

Intentional private modes, such as secure temporary files and trash infrastructure using 0700, are left unchanged.

No post-creation chmod is performed.

Tests

Added integration coverage for both 0002 and 0022 umasks.

Verified with:

./run_tests.sh tests/files_spec.lua
./run_tests.sh
stylua --check lua tests
luacheck lua tests --formatter plain
./scripts/nvim-typecheck-action/typecheck.sh --workdir scripts/nvim-typecheck-action lua

All tests pass.

@github-actions
github-actions Bot requested a review from stevearc August 22, 2026 16:19
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