[issue29214] Standard open() does not allow to specify file permissions.

2017-07-26 Thread Giampaolo Rodola'
Changes by Giampaolo Rodola' : -- nosy: +giampaolo.rodola ___ Python tracker ___ ___ Python-bugs-list mailing list Unsubscribe: https

[issue29214] Standard open() does not allow to specify file permissions.

2017-01-11 Thread Christian Heimes
Christian Heimes added the comment: I like the partial opener trick. Can we have the examples in the public documentation of open(), too? -- ___ Python tracker ___ _

[issue29214] Standard open() does not allow to specify file permissions.

2017-01-10 Thread STINNER Victor
STINNER Victor added the comment: > @haypo, suppose, one thread wants file with permissions A, and other thread > wants permissions B. If they will "set" them through umask(), race condition > may occur. Ok, let's say thta you want file "x" with permission A=0o777 and file "y" with permission

[issue29214] Standard open() does not allow to specify file permissions.

2017-01-10 Thread Serhiy Storchaka
Serhiy Storchaka added the comment: If you needs non-default permission for particular file, you can use one of available ways mentioned above. I think this issue can be closed. The original issues are resolved: 1. os.open() (corresponding to syscall open()) allows this. 2. There are other way

[issue29214] Standard open() does not allow to specify file permissions.

2017-01-10 Thread Марк Коренберг
Марк Коренберг added the comment: @haypo, suppose, one thread wants file with permissions A, and other thread wants permissions B. If they will "set" them through umask(), race condition may occur. -- ___ Python tracker

[issue29214] Standard open() does not allow to specify file permissions.

2017-01-10 Thread Christian Heimes
Christian Heimes added the comment: Victor, you are correct. That was exactly my point. The most secure way is to tighten security and set umask to 0o077. It's basically a white list or locked down approach. With umask 0o077 all subsequent files, directories and other resources will be created

[issue29214] Standard open() does not allow to specify file permissions.

2017-01-10 Thread STINNER Victor
STINNER Victor added the comment: I don't understand the problem with umask(). It's standard and affect all code even C extension calling directly or indirectly open(). It is more secure to use umask() than setting mode on a few Python open() calls no? For example, Python creates .pyc files. You

[issue29214] Standard open() does not allow to specify file permissions.

2017-01-10 Thread Brett Cannon
Brett Cannon added the comment: The point Serhiy is trying to make is that not everyone needs or cares about setting specific file permissions. Python's built-in open() function has not supported this for 26 years and so there's obviously not that much of a need if this has not consistently co

[issue29214] Standard open() does not allow to specify file permissions.

2017-01-09 Thread Марк Коренберг
Марк Коренберг added the comment: Such construction is not so easy. Especially for beginners. Not everyone even uses context managers to work with files. They will try to use os.chmod(). More clever will use os.fchmod(fileobj.fileno()). And in rare case someone asks about race condition betwee

[issue29214] Standard open() does not allow to specify file permissions.

2017-01-09 Thread Serhiy Storchaka
Serhiy Storchaka added the comment: open(..., opener=partial(os.open, mode=0o644)) Not every combination of functions deserves a new parameter of a builtin. -- ___ Python tracker __

[issue29214] Standard open() does not allow to specify file permissions.

2017-01-09 Thread Марк Коренберг
Марк Коренберг added the comment: so, io.open() should just pass that value down to implementation. implementation should use this value instead of hard-coded 0o666. -- ___ Python tracker _

[issue29214] Standard open() does not allow to specify file permissions.

2017-01-09 Thread Марк Коренберг
Марк Коренберг added the comment: I expect this: open(, perms=0o644) Why not? -- ___ Python tracker ___ ___ Python-bugs-list mai

[issue29214] Standard open() does not allow to specify file permissions.

2017-01-09 Thread Brett Cannon
Brett Cannon added the comment: I agree with Serhiy that I don't think this is necessary for io.open() when os.open() supports this. But this really can't be discussed further until someone provides a clear design proposal on how to make this work with io.open(). -- nosy: +brett.canno

[issue29214] Standard open() does not allow to specify file permissions.

2017-01-09 Thread Марк Коренберг
Марк Коренберг added the comment: Permissions -- are very important thing. As I think, such high-level functions should not hide that important functionality from end-users. Also, it is not difficult to make a patch (as I think). -- ___ Python track

[issue29214] Standard open() does not allow to specify file permissions.

2017-01-09 Thread Serhiy Storchaka
Serhiy Storchaka added the comment: io.open() is high-level function. It handles buffering, encoding, newline translating. It is even higher-level than C's fopen(). Syscall open() is low-level. Python os.open() is an interface to this low-level feature. There is a connection between low and h

[issue29214] Standard open() does not allow to specify file permissions.

2017-01-09 Thread Марк Коренберг
Марк Коренберг added the comment: 1. Yes, I'm reporting problem about standard open(), not os.open(). 2. Yes, I know about umask. But unfortunatelly, umask affects whole process, including all threads, so it is not possible to force specific permissions without of race conditions with other thr

[issue29214] Standard open() does not allow to specify file permissions.

2017-01-09 Thread Christian Heimes
Christian Heimes added the comment: I would be nice to have a public API to set permissions of files for io.open(), too. Note to your note: the actual permission is influenced by the process' global umask. If you are concerned about security, you should set the umask to 0o077 early.

[issue29214] Standard open() does not allow to specify file permissions.

2017-01-09 Thread STINNER Victor
STINNER Victor added the comment: You can actually specify permission: fd = os.open("document.txt", os.O_WRONLY | os.O_CREAT, 0o777) fp = open(fd, "wb") with fp: ... You can also use the dir_fd parameter for even better security ;-) Is your request for the standard open() function, rather t

[issue29214] Standard open() does not allow to specify file permissions.

2017-01-09 Thread Christian Heimes
Changes by Christian Heimes : -- nosy: +christian.heimes ___ Python tracker ___ ___ Python-bugs-list mailing list Unsubscribe: https:

[issue29214] Standard open() does not allow to specify file permissions.

2017-01-09 Thread Марк Коренберг
Changes by Марк Коренберг : -- versions: +Python 3.7 ___ Python tracker ___ ___ Python-bugs-list mailing list Unsubscribe: https://ma

[issue29214] Standard open() does not allow to specify file permissions.

2017-01-09 Thread Марк Коренберг
Changes by Марк Коренберг : -- type: -> behavior ___ Python tracker ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.

[issue29214] Standard open() does not allow to specify file permissions.

2017-01-09 Thread Марк Коренберг
New submission from Марк Коренберг: 1. Syscall open() allows that. 2. This is important to prevent race-conditions between creating a file with default permissions and calling fchmod(). -- components: Library (Lib) messages: 285044 nosy: mmarkk priority: normal severity: normal status: