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
mode
security concern
#85547
Comments
import os
import stat
import os.path
def problem(tmp_path):
# result:
#
# create temp file
fd = os.open(tmp_path, os.O_CREAT, 0o660)
os.close(fd)
def solution(tmp_path):
# result:
#
old_umask = os.umask(0)
# create temp file
fd = os.open(tmp_path, os.O_CREAT, 0o660)
os.close(fd)
os.umask(old_umask)
def main():
tmp_path = '_testing-chmod'
problem(tmp_path)
# solution(tmp_path)
if __name__ == '__main__':
main() This result is not same for all os and distro, on multiple linux system for example the results will be different. I think Python should account for such behavior by default as it can lead to file/dir creation with security issues. |
It is expected behavior on Posix system. See https://pubs.opengroup.org/onlinepubs/9699919799/functions/umask.html What is the problem? |
I am closing this as its not a issue anymore... I was trying to solve a problem that has become a core feature! |
Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.
Show more details
GitHub fields:
bugs.python.org fields:
The text was updated successfully, but these errors were encountered: