-
Notifications
You must be signed in to change notification settings - Fork 110
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
Make permissions and ownership? configurable while persisting #137
Comments
Implementation wise, I think the most realistic approach is to make permissions on the temporary file configurable and then make persist keep those. Ownership could be configured through the On Linux this would correspond to passing |
As far as I know, persist should keep the permissions. So you should be able to:
This library does not support persisting temporary files created with |
Would it be possible to remove the For example without tmpfile::tmpfile();
let tmp_file_path = format!("/proc/self/fd/{}", tmp_file.as_raw_fd());
nix::unistd::linkat(
None,
&tmp_file_path[..],
None,
&file_path[..],
nix::unistd::LinkatFlags::SymlinkFollow,
)?; |
IIRC, the problem is MacOS and the BDSs. On those platforms, temporary
files are implemented by creating then immediately unlinking, and
there's no way to "relink" (last I checked).
|
Ok yeah, so I'm wondering if removing the flag preventing the file from being copied on platforms where it can be - is that a feature or a secruity concern? I don't know if the absense of a flag is a feature - maybe this is pedantic but it feels like a move to be more inline with the OS defaults IMHO. I'm trying to imagine the malicious use of this but I haven't been able to come up with anything yet. So I don't know: If we only removed that flag what would we be potentially disrupting for users of tmpfile? |
Ah, no. I'm happy to accept a patch to remove that ( |
Since getting umask is hard, it just copies a file mode from the known good source. Stebalien/tempfile#137
For Git does the same by default. As per the policy of providing cross-platform features only, implementing this would be out of scope though. Would you be open to a contribution if this was an exceptional case? Thank you 🙏 |
Related issues: #30, #114
It might not be possible to support on all platforms, but it would still be nice to have it at least on unix. This issue is specifically about permissions / ownership of the persisted file rather than the temporary file, but I would also be quite happy with an option to configure permissions on the temporary, if they get carried over to the persisted file.
My use case is to atomically write files with given permissions / ownership by first writing to a temporary file and then persisting it (relying on rename likely being atomic), so just changing these after the fact will slightly defeat the purpose..
The text was updated successfully, but these errors were encountered: