Skip to content

Explicitly disable chown for file writes #32

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Feb 7, 2020

Conversation

paulhayes
Copy link
Contributor

Due to a bug in write-file-atomic saving to a permissionless filesystem ( eg fat32, exfat ) in linux without explicitly setting chown to false, causes the write to fail. As noted here: npm/write-file-atomic#58

By simply setting chown argument explicitly, this error will not occur.

Due to a bug in write-file-atomic saving to a permissionless filesystem ( eg fat32, exfat ) in linux without explicitly setting chown to false, causes the write to fail. As noted here: npm/write-file-atomic#58

By simply setting chown argument explicitly, this error will not occur.
@sindresorhus
Copy link
Owner

Can you elaborate on why it's not needed?

@paulhayes
Copy link
Contributor Author

Can you elaborate on why it's not needed?

Sure. Currently the code is calling write-file with no chown option setting. This has the unintended consequence of chowning the file to current user ( due to the behaviour of write-file-atomic ).

It's not necessary to chown a file to write to it, only that the permissions be correct. On linux permissionless filesystems like exfat and fat32 the entire filesystem is normally owned by root, and trying to chown it causes as permissions error.

The best solution is to simply specify to write-file-atomic to not change the owner of the file being written to.

@sindresorhus sindresorhus changed the title Explicitly disable chown for file writes. Not needed and dangerous. Explicitly disable chown for file writes Feb 7, 2020
@sindresorhus sindresorhus merged commit 43e44a6 into sindresorhus:master Feb 7, 2020
@sindresorhus
Copy link
Owner

Thanks for elaborating.

@paulhayes
Copy link
Contributor Author

You're welcome. Thanks for incorporating the change.

@paulhayes paulhayes deleted the patch-1 branch April 4, 2020 23:21
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