Skip to content

NVR with realtime local object detection for IP cameras

strip whitespaces when loading secrets (#12393)

Josh Thorpe8f51f7b4c458
diff --git a/docker/main/rootfs/usr/local/go2rtc/create_config.py b/docker/main/rootfs/usr/local/go2rtc/create_config.py
index 44d2170eed..6855b3b893 100644
--- a/docker/main/rootfs/usr/local/go2rtc/create_config.py
+++ b/docker/main/rootfs/usr/local/go2rtc/create_config.py
@@ -21,9 +21,9 @@ FRIGATE_ENV_VARS = {k: v for k, v in os.environ.items() if k.startswith("FRIGATE
if os.path.isdir("/run/secrets"):
for secret_file in os.listdir("/run/secrets"):
if secret_file.startswith("FRIGATE_"):
- FRIGATE_ENV_VARS[secret_file] = Path(
- os.path.join("/run/secrets", secret_file)
- ).read_text()
+ FRIGATE_ENV_VARS[secret_file] = (
+ Path(os.path.join("/run/secrets", secret_file)).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 9245056ed0..57064eab6e 100644
--- a/frigate/api/auth.py
+++ b/frigate/api/auth.py
@@ -89,7 +89,9 @@ 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 bfa00f6014..c62ccd9f1b 100644
--- a/frigate/config.py
+++ b/frigate/config.py
@@ -62,9 +62,9 @@ FRIGATE_ENV_VARS = {k: v for k, v in os.environ.items() if k.startswith("FRIGATE
if os.path.isdir("/run/secrets") and os.access("/run/secrets", os.R_OK):
for secret_file in os.listdir("/run/secrets"):
if secret_file.startswith("FRIGATE_"):
- FRIGATE_ENV_VARS[secret_file] = Path(
- os.path.join("/run/secrets", secret_file)
- ).read_text()
+ FRIGATE_ENV_VARS[secret_file] = (
+ Path(os.path.join("/run/secrets", secret_file)).read_text().strip()
+ )
DEFAULT_TRACKED_OBJECTS = ["person"]
DEFAULT_ALERT_OBJECTS = ["person", "car"]
diff --git a/frigate/plus.py b/frigate/plus.py
index 7c45645622..83203356ca 100644
--- a/frigate/plus.py
+++ b/frigate/plus.py
@@ -42,7 +42,9 @@ 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: