public inbox for pbs-devel@lists.proxmox.com
 help / color / mirror / Atom feed
From: Martin Markert <keinemelodien@icloud.com>
To: pbs-devel@lists.proxmox.com
Subject: [PATCH proxmox] fix #6768: openid: add connect and global timeout to http client
Date: Wed,  2 Dec 2026 12:32:28 +0100	[thread overview]
Message-ID: <20261202113228.18432-1-keinemelodien@icloud.com> (raw)

Without any timeout, a single unreachable address of the OpenID
provider, e.g. an IPv6 route that silently drops packets, makes the
discovery request block forever. In PBS this hangs the auth-url call
and with it the whole proxmox-backup-api daemon, so even PAM logins
fail until the daemon is killed.

Set a connect timeout, which ureq splits over all resolved addresses,
so a working IPv4 address still gets used after the IPv6 one timed
out, and a global timeout as upper bound for the whole request.

Tested with a provider name resolving to a dropped IPv6 and a
reachable IPv4 address: without this patch the request hung for more
than 90 s, with it the request succeeds via IPv4 after 6.7 s, and
fails with a timeout after 10 s if no address is reachable.

Signed-off-by: Martin Markert <keinemelodien@icloud.com>
---
 proxmox-openid/src/http_client.rs | 22 ++++++++++++++++------
 1 file changed, 16 insertions(+), 6 deletions(-)

diff --git a/proxmox-openid/src/http_client.rs b/proxmox-openid/src/http_client.rs
index a21e1d5..a9bbb4f 100755
--- a/proxmox-openid/src/http_client.rs
+++ b/proxmox-openid/src/http_client.rs
@@ -1,5 +1,6 @@
 use std::env;
 use std::io::Read;
+use std::time::Duration;
 
 use http::method::Method;
 
@@ -35,13 +36,22 @@ pub enum Error {
     Other(String),
 }
 
+// Without timeouts a single unreachable address of the provider (e.g. a broken IPv6 route that
+// silently drops packets) blocks the request forever. With a connect timeout, ureq splits it over
+// all resolved addresses and falls back to the next one, so a working IPv4 address still gets used.
+const CONNECT_TIMEOUT: Duration = Duration::from_secs(10);
+const GLOBAL_TIMEOUT: Duration = Duration::from_secs(20);
+
 fn ureq_agent() -> Result<ureq::Agent, Error> {
-    let mut config = ureq::Agent::config_builder().tls_config(
-        ureq::tls::TlsConfig::builder()
-            .provider(ureq::tls::TlsProvider::NativeTls)
-            .root_certs(ureq::tls::RootCerts::PlatformVerifier)
-            .build(),
-    );
+    let mut config = ureq::Agent::config_builder()
+        .timeout_connect(Some(CONNECT_TIMEOUT))
+        .timeout_global(Some(GLOBAL_TIMEOUT))
+        .tls_config(
+            ureq::tls::TlsConfig::builder()
+                .provider(ureq::tls::TlsProvider::NativeTls)
+                .root_certs(ureq::tls::RootCerts::PlatformVerifier)
+                .build(),
+        );
     if let Ok(val) = env::var("all_proxy").or_else(|_| env::var("ALL_PROXY")) {
         let proxy = ureq::Proxy::new(&val).map_err(Box::new)?;
         config = config.proxy(Some(proxy));
-- 
2.54.0 (Apple Git-157)




                 reply	other threads:[~2026-12-02 13:09 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20261202113228.18432-1-keinemelodien@icloud.com \
    --to=keinemelodien@icloud.com \
    --cc=pbs-devel@lists.proxmox.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
Service provided by Proxmox Server Solutions GmbH | Privacy | Legal