Opened 3 years ago

Closed 2 years ago

#32604 closed Cleanup/optimization (fixed)

File uploads larger than FILE_UPLOAD_MAX_MEMORY_SIZE get wrong unix group based on setgid

Reported by: Gavin Wahl Owned by: Mateo Radman
Component: File uploads/storage Version: 3.1
Severity: Normal Keywords:
Cc: Triage Stage: Ready for checkin
Has patch: yes Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no

Description

My MEDIA_ROOT directory has setgid set to force the group of newly created files. For file uploads less than FILE_UPLOAD_MAX_MEMORY_SIZE, django creates a file inside MEDIA_ROOT and the group is set as expected. For larger files, django creates a temporary file in another directory, then moves it to MEDIA_ROOT. Since the file was created in a temporary directory, it doesn't get the correct group. I expect uploaded media files to get the group from MEDIA_ROOT, despite whatever magic django internals are doing.

This can not be fixed with FILE_UPLOAD_PERMISSIONS, because that only sets permissions, not the group of the file.

The permissions form of this bug is referenced here: https://github.com/django-cms/django-filer/issues/1031

Change History (8)

comment:1 by Carlton Gibson, 3 years ago

Component: UncategorizedFile uploads/storage
Triage Stage: UnreviewedAccepted
Type: UncategorizedCleanup/optimization

OK, yes, this is related to #27334 (also #28540) - if we can make a similar adjustment for the group it should be acceptable.

comment:2 by Mateo Radman, 2 years ago

Owner: changed from nobody to Mateo Radman
Status: newassigned

comment:3 by Mateo Radman, 2 years ago

Has patch: set

comment:4 by Mateo Radman, 2 years ago

Hi,
Is there anything else that needs to be done here?
Thanks!

comment:5 by Mariusz Felisiak, 2 years ago

Patch needs improvement: set

comment:6 by Mateo Radman, 2 years ago

Patch needs improvement: unset

comment:7 by Mariusz Felisiak, 2 years ago

Triage Stage: AcceptedReady for checkin

comment:8 by Mariusz Felisiak <felisiak.mariusz@…>, 2 years ago

Resolution: fixed
Status: assignedclosed

In 884b4c2:

Fixed #32604 -- Made file upload respect group id when uploading to a temporary file.

Note: See TracTickets for help on using tickets.
Back to Top