Skip to content
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

open_file(…, 'w', atomic=True) sets or resets permissions to 600, ignoring umask #1376

Closed
andersk opened this issue Aug 25, 2019 · 2 comments
Milestone

Comments

@andersk
Copy link
Contributor

andersk commented Aug 25, 2019

Files are normally created with permission 666 & umask as expected:

>>> click.open_file('/tmp/test1', 'w').close()
>>> oct(os.stat('/tmp/test1').st_mode)
'0o100644'

However, opening a new or existing file with atomic=True sets or resets its permissions to 600 unconditionally:

>>> click.open_file('/tmp/test2', 'w', atomic=True).close()
>>> oct(os.stat('/tmp/test2').st_mode)
'0o100600'
>>> click.open_file('/tmp/test1', 'w', atomic=True).close()
>>> oct(os.stat('/tmp/test1').st_mode)
'0o100600'

I’d expect a new file created with atomic=True to be created with the usual permission 666 & umask, and an existing file opened with atomic=True to have the previous permissions preserved. (There’s probably no way to preserve permissions atomically; taking the previous permissions at the time of the initial open is fine.)

@iwhiz
Copy link

iwhiz commented Sep 1, 2019

Could you please tell me the operating system you working with??

andersk added a commit to andersk/click that referenced this issue Sep 19, 2019
Fixes pallets#1376.

Signed-off-by: Anders Kaseorg <andersk@mit.edu>
andersk added a commit to andersk/click that referenced this issue Sep 19, 2019
Fixes pallets#1376.

Signed-off-by: Anders Kaseorg <andersk@mit.edu>
andersk added a commit to andersk/click that referenced this issue Sep 19, 2019
Fixes pallets#1376.

Signed-off-by: Anders Kaseorg <andersk@mit.edu>
andersk added a commit to andersk/click that referenced this issue Oct 3, 2019
Fixes pallets#1376.

Signed-off-by: Anders Kaseorg <andersk@mit.edu>
@Minkey27
Copy link

Minkey27 commented Jan 13, 2020

Could you please tell me the operating system you working with??

I'm running OS X, the problem also occurs on Debian

davidism pushed a commit to andersk/click that referenced this issue Feb 17, 2020
Fixes pallets#1376.

Signed-off-by: Anders Kaseorg <andersk@mit.edu>
@davidism davidism added this to the 7.1 milestone Feb 17, 2020
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Nov 13, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants