From 8309804bd3eb5f07f6b3f1293425284a1da26bcd Mon Sep 17 00:00:00 2001 From: thorpejosh Date: Thu, 11 Jul 2024 21:55:18 +0800 Subject: [PATCH] strip whitespaces when loading secrets --- docker/main/rootfs/usr/local/go2rtc/create_config.py | 2 +- frigate/api/auth.py | 2 +- frigate/config.py | 2 +- frigate/plus.py | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/docker/main/rootfs/usr/local/go2rtc/create_config.py b/docker/main/rootfs/usr/local/go2rtc/create_config.py index 44d2170ee..30cbbaf69 100644 --- a/docker/main/rootfs/usr/local/go2rtc/create_config.py +++ b/docker/main/rootfs/usr/local/go2rtc/create_config.py @@ -23,7 +23,7 @@ if os.path.isdir("/run/secrets"): if secret_file.startswith("FRIGATE_"): FRIGATE_ENV_VARS[secret_file] = Path( os.path.join("/run/secrets", secret_file) - ).read_text() + ).read_text().strip() config_file = os.environ.get("CONFIG_FILE", "/config/config.yml") diff --git a/frigate/api/auth.py b/frigate/api/auth.py index 9245056ed..d2a43c3d7 100644 --- a/frigate/api/auth.py +++ b/frigate/api/auth.py @@ -89,7 +89,7 @@ def get_jwt_secret() -> str: # check docker secrets elif os.path.isfile(os.path.join("/run/secrets", JWT_SECRET_ENV_VAR)): logger.debug(f"Using jwt secret from {JWT_SECRET_ENV_VAR} docker secret file.") - jwt_secret = Path(os.path.join("/run/secrets", JWT_SECRET_ENV_VAR)).read_text() + jwt_secret = Path(os.path.join("/run/secrets", JWT_SECRET_ENV_VAR)).read_text().strip() # check for the addon options file elif os.path.isfile("/data/options.json"): with open("/data/options.json") as f: diff --git a/frigate/config.py b/frigate/config.py index bfa00f601..ffc8c3921 100644 --- a/frigate/config.py +++ b/frigate/config.py @@ -64,7 +64,7 @@ if os.path.isdir("/run/secrets") and os.access("/run/secrets", os.R_OK): if secret_file.startswith("FRIGATE_"): FRIGATE_ENV_VARS[secret_file] = Path( os.path.join("/run/secrets", secret_file) - ).read_text() + ).read_text().strip() DEFAULT_TRACKED_OBJECTS = ["person"] DEFAULT_ALERT_OBJECTS = ["person", "car"] diff --git a/frigate/plus.py b/frigate/plus.py index 7c4564562..bc4d3621e 100644 --- a/frigate/plus.py +++ b/frigate/plus.py @@ -42,7 +42,7 @@ class PlusApi: and os.access("/run/secrets", os.R_OK) and PLUS_ENV_VAR in os.listdir("/run/secrets") ): - self.key = Path(os.path.join("/run/secrets", PLUS_ENV_VAR)).read_text() + self.key = Path(os.path.join("/run/secrets", PLUS_ENV_VAR)).read_text().strip() # check for the addon options file elif os.path.isfile("/data/options.json"): with open("/data/options.json") as f: