Skip to content

Conversation

@sitaktif
Copy link
Contributor

In write_source_file, the output file should honor the current umask when marking files as writable. Not doing so ends up in situations where the file is e.g. created as 664 when initially generated with write_source_file but then a git clone/checkout/subtree would create it as 644. This can cause confusion to the user, and might unnecessarily be treated as a file change by some tooling.

From man 2 chmod, describing chmod [who]+[perm]:

If no value is supplied for [who], each permission bit specified in
[perm], for which the corresponding bit in the file mode creation mask
(see umask(2)) is clear, is set.

In write_source_file, the output file should honor the current umask
when marking files as writable. Not doing so ends up in situations where
the file is e.g. created as 664 when initially generated with
`write_source_file` but then a git clone/checkout/subtree would create
it as 644. This can cause confusion to the user, and might unnecessarily
be treated as a file change by some tooling.

From `man 2 chmod`, describing `chmod [who]+[perm]`:

> If no value is supplied for [who], each permission bit specified in
> [perm], for which the corresponding bit in the file mode creation mask
> (see umask(2)) is clear, is set.
Copy link
Collaborator

@gregmagolan gregmagolan left a comment

Choose a reason for hiding this comment

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

Thanks for the fix!

@gregmagolan gregmagolan merged commit 1fcede5 into bazel-contrib:main Dec 4, 2024
22 checks passed
@sitaktif sitaktif deleted the write-source-file-respect-umask branch December 4, 2024 23:27
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.

2 participants