]> git.ipfire.org Git - thirdparty/bind9.git/commitdiff
Don't export openssl-related env vars unless set
authorTom Krizek <tkrizek@isc.org>
Wed, 28 Feb 2024 09:44:58 +0000 (10:44 +0100)
committerNicki Křížek <nicki@isc.org>
Thu, 9 May 2024 15:08:09 +0000 (17:08 +0200)
If OPENSSL_CONF is exported as an empty string, it will cause issues on
rhel9fips. Allow the environment variables to be set and exported, but
make sure to only export them if they have been set by the user.

bin/tests/system/isctest/vars/all.py
bin/tests/system/isctest/vars/openssl.py

index 2126c1c220433afd6c5b91a5b0cb8ce7c4a7cc64..3c2bc9251be53b397c5d21c173310e2cca17730a 100644 (file)
@@ -22,7 +22,8 @@ from .openssl import OPENSSL_VARS
 class VarLookup(ChainMap):
     """A dictionary-like structure to coalesce the variables from different
     modules without making a copy (which would prevent updating these values
-    from inside the modules)."""
+    from inside the modules). Values which are None are treated as unset when
+    iterating."""
 
     def __init__(self, *maps):
         keys = set()
index 1dcef67faf92a0e9632c2e8920bb98112b2c1862..5659222c09da199999b724381c38c06b1a7376aa 100644 (file)
 
 import os
 import re
+from typing import Optional
 
 from .. import log
 
 
 OPENSSL_VARS = {
-    "OPENSSL_CONF": os.getenv("OPENSSL_CONF", ""),
-    "SOFTHSM2_CONF": os.getenv("SOFTHSM2_CONF", ""),
-    "SOFTHSM2_MODULE": "",
-    "ENGINE_ARG": "",
+    "OPENSSL_CONF": os.getenv("OPENSSL_CONF", None),
+    "SOFTHSM2_CONF": os.getenv("SOFTHSM2_CONF", None),
+    "SOFTHSM2_MODULE": None,
+    "ENGINE_ARG": None,
 }
 
 
-def parse_openssl_config(path: str):
-    if not os.path.isfile(path):
+def parse_openssl_config(path: Optional[str]):
+    if path is None or not os.path.isfile(path):
+        OPENSSL_VARS["ENGINE_ARG"] = None
+        OPENSSL_VARS["SOFTHSM2_MODULE"] = None
+        os.environ.pop("ENGINE_ARG", None)
+        os.environ.pop("SOFTHSM2_MODULE", None)
         return
+
     regex = re.compile(r"([^=]+)=(.*)")
     log.debug(f"parsing openssl config: {path}")
     with open(path, "r", encoding="utf-8") as conf: