G
G
Grigory Dikiy2017-08-14 15:29:52
linux
Grigory Dikiy, 2017-08-14 15:29:52

Django. File permissions after writing?

Good afternoon! There is a production server with Django.
UWSGI settings like this:

[uwsgi]
project = posudahome
uid = dikiigr
gid = www-data
...

Used in conjunction with nginx, and my dikiigr user is added to the www-data group.
Django has a model that handles the synchronization of xls files. So, if I actually load this file, then I get rights of this type:
-rw------- 1 dikiigr www-data 10573824 Aug 14 12:11 7947dc95-d4a4-4903-80e4-759e6a7c1ed7.xls

At that time, if you load images into the same model, then the rights are different:
-rw-r--r-- 1 dikiigr www-data    35480 Aug 14 12:24 612b8260-63dc-45bd-9bd8-41b73c673e2f.jpg

I can not understand what is the problem and how can I give the rights to my www-data group when loading, at least for reading. And why does Django have such strange behavior or am I missing something?
PS I saw a solution with os.chmod(path, mode), but this is a bad option because it requires unnecessary gestures

Answer the question

In order to leave comments, you need to log in

1 answer(s)
G
Grigory Dikiy, 2017-08-14
@frilix

Googling, I found out that django has a permissions parameter.
Decision:
If this isn't given or is None, you'll get operating-system dependent behavior. On most platforms, temporary files will have a mode of 0o600, and files saved from memory will be saved using the system's standard umask.
Which means it is platform dependent and you need to force this mask to not be taken by default

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question