From 6b3411f63b1ff23c2a33ee8957000942fbeb6428 Mon Sep 17 00:00:00 2001 From: Jens Langhammer Date: Mon, 26 Oct 2020 19:07:08 +0100 Subject: [PATCH] root: fix permission denied error for backups --- Dockerfile | 4 +++- Makefile | 2 +- docs/installation/reverse-proxy.md | 3 ++- passbook/core/tasks.py | 10 +++++++++- pyproject.toml | 3 +++ 5 files changed, 18 insertions(+), 4 deletions(-) create mode 100644 pyproject.toml diff --git a/Dockerfile b/Dockerfile index 3b5d729f2..bc8a1a87c 100644 --- a/Dockerfile +++ b/Dockerfile @@ -32,7 +32,9 @@ RUN apt-get update && \ groupadd -g 999 docker_999 && \ adduser --system --no-create-home --uid 1000 --group --home /passbook passbook && \ usermod -a -G docker_998 passbook && \ - usermod -a -G docker_999 passbook + usermod -a -G docker_999 passbook && \ + mkdir /backups && \ + chown passbook:passbook /backups COPY ./passbook/ /passbook COPY ./manage.py / diff --git a/Makefile b/Makefile index 8cff3b3e9..50f47a097 100644 --- a/Makefile +++ b/Makefile @@ -12,7 +12,7 @@ lint-fix: lint: pyright passbook e2e lifecycle - bandit -r passbook e2e lifecycle + bandit -r passbook e2e lifecycle -x node_modules pylint passbook e2e lifecycle prospector diff --git a/docs/installation/reverse-proxy.md b/docs/installation/reverse-proxy.md index aee7773bd..2e677bb45 100644 --- a/docs/installation/reverse-proxy.md +++ b/docs/installation/reverse-proxy.md @@ -34,7 +34,8 @@ server { proxy_set_header X-Forwarded-Proto https; proxy_set_header X-Forwarded-Port 443; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; - proxy_set_header Host $http_host; + # This needs to be set inside the location block, very important. + proxy_set_header Host $host; proxy_set_header Upgrade $http_upgrade; proxy_set_header Connection $connection_upgrade; } diff --git a/passbook/core/tasks.py b/passbook/core/tasks.py index 65d9da22d..01fd1e1d4 100644 --- a/passbook/core/tasks.py +++ b/passbook/core/tasks.py @@ -4,6 +4,7 @@ from io import StringIO from boto3.exceptions import Boto3Error from botocore.exceptions import BotoCoreError, ClientError +from dbbackup.db.exceptions import CommandConnectorError from django.contrib.humanize.templatetags.humanize import naturaltime from django.core import management from django.utils.timezone import now @@ -50,5 +51,12 @@ def backup_database(self: MonitoredTask): # pragma: no cover ) ) LOGGER.info("Successfully backed up database.") - except (IOError, BotoCoreError, ClientError, Boto3Error) as exc: + except ( + IOError, + BotoCoreError, + ClientError, + Boto3Error, + PermissionError, + CommandConnectorError, + ) as exc: self.set_status(TaskResult(TaskResultStatus.ERROR).with_error(exc)) diff --git a/pyproject.toml b/pyproject.toml new file mode 100644 index 000000000..03e86e477 --- /dev/null +++ b/pyproject.toml @@ -0,0 +1,3 @@ +[tool.black] +target-version = ['py38'] +exclude = 'node_modules'