]> git.ipfire.org Git - thirdparty/mkosi.git/commitdiff
config.py: add config_default_proxy_exclude()
authorMarc Herbert <marc.herbert@intel.com>
Fri, 7 Nov 2025 02:04:19 +0000 (18:04 -0800)
committerDaan De Meyer <daan.j.demeyer@gmail.com>
Tue, 11 Nov 2025 17:08:56 +0000 (18:08 +0100)
Automagically defaulting --proxy-url to a proxy value found in the
environment is nice. But it backfires seriously when not ignoring the
no_proxy= value in the same environment, because it effectively blocks
access to internal mirrors with timeouts and/or confusing error
messages.

Signed-off-by: Marc Herbert <marc.herbert@intel.com>
mkosi/config.py

index 6e791f3682998e5f5587a8b1d0d0498963638463..7c5e1bfeabebe5dca9cf7cf6fb6eb72f6147c080 100644 (file)
@@ -1087,6 +1087,21 @@ def config_default_proxy_url(namespace: dict[str, Any]) -> Optional[str]:
     return None
 
 
+def config_default_proxy_exclude(namespace: dict[str, Any]) -> Optional[list[str]]:
+    names = ("no_proxy", "NO_PROXY")
+
+    for env in namespace["environment"]:
+        k, _, v = cast(str, env).partition("=")
+        if k in names:
+            return v.split(",")
+
+    for k, v in os.environ.items():
+        if k in names:
+            return v.split(",")
+
+    return None
+
+
 def config_default_proxy_peer_certificate(namespace: dict[str, Any]) -> Optional[Path]:
     for p in (Path("/etc/pki/tls/certs/ca-bundle.crt"), Path("/etc/ssl/certs/ca-certificates.crt")):
         if p.exists():
@@ -3916,6 +3931,8 @@ SETTINGS: list[ConfigSetting[Any]] = [
     ConfigSetting(
         dest="proxy_exclude",
         section="Build",
+        default_factory=config_default_proxy_exclude,
+        default_factory_depends=("environment",),
         metavar="HOST",
         parse=config_make_list_parser(delimiter=","),
         help="Don't use the configured proxy for the specified host(s)",