mirror of
https://github.com/freedombox/FreedomBox.git
synced 2026-01-21 07:55:00 +00:00
- Use dedicated directory for uploads - Uploaded backup archives are owned by root and read-only (0o600) Signed-off-by: Joseph Nuthalapati <njoseph@riseup.net> [sunil: Fix checking the relativeness of file path before removing] [sunil: Create backups upload path recursively] Signed-off-by: Sunil Mohan Adapa <sunil@medhas.org> Reviewed-by: Sunil Mohan Adapa <sunil@medhas.org>
27 lines
645 B
Python
27 lines
645 B
Python
# SPDX-License-Identifier: AGPL-3.0-or-later
|
|
"""
|
|
Decorators for the backup views.
|
|
"""
|
|
|
|
import functools
|
|
|
|
from . import privileged, SESSION_PATH_VARIABLE
|
|
|
|
|
|
def delete_tmp_backup_file(function):
|
|
"""Decorator to delete uploaded backup files.
|
|
|
|
XXX: Implement a better way to delete uploaded files.
|
|
|
|
"""
|
|
|
|
@functools.wraps(function)
|
|
def wrapper(request, *args, **kwargs):
|
|
path = request.session.get(SESSION_PATH_VARIABLE, None)
|
|
if path:
|
|
privileged.remove_uploaded_archive(path)
|
|
del request.session[SESSION_PATH_VARIABLE]
|
|
return function(request, *args, **kwargs)
|
|
|
|
return wrapper
|