tempfile icon indicating copy to clipboard operation
tempfile copied to clipboard

File persisted with 600 permissions

Open MarinPostma opened this issue 2 years ago • 3 comments

I have noticed that the permission of a persisted NamedTempFile is 600, but I was expecting it to be 644 (default permissions when creating a file).

I could be mistaken, but i found no mention of that in the doc? Maybe this could be part of the persist documentation?

I can issue a PR if needed.

MarinPostma avatar Dec 01 '21 17:12 MarinPostma

More documentation would definitely be helpful. Specifically:

  1. We need documentation on NamedTempFile::new explaining the default mode.
  2. We need documentation on Builder explaining the defaults.
  3. We need documentation on persist stating that it leaves the mode as-is (e.g., defaults to 600).

Unfortunately, I can't think of a good way to actually change this behavior:

  1. We assume that the tempfile directory may be shared, so we create files with 600.
  2. If we change the mode after persisting, the operation wouldn't be atomic, which may cause even harder to track down issues.

Ideally, we'd, provide a way to set the default mode in the Builder. There was a patch to do this, but, IIRC, it wasn't cross platform.

Stebalien avatar Dec 01 '21 17:12 Stebalien

@Stebalien do you know where to find said patch? Perhaps there's a way to make it cross-platform.

assarbad avatar Nov 13 '22 20:11 assarbad

@assarbad https://github.com/Stebalien/tempfile/pull/61

Stebalien avatar Nov 15 '22 21:11 Stebalien

We can now set default permissions (Builder::permissions), so I'll consider this fixed.

Stebalien avatar Apr 16 '24 22:04 Stebalien