From 256178c6c3c83a06c9b5e5307ea1307fa052c727 Mon Sep 17 00:00:00 2001 From: Jamie Cameron Date: Fri, 26 Jul 2024 21:04:55 -0700 Subject: [PATCH] sometimes LDAP connect fails with sigpipe --- ldap-client/ldap-client-lib.pl | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/ldap-client/ldap-client-lib.pl b/ldap-client/ldap-client-lib.pl index d59224f69..be91ad25f 100755 --- a/ldap-client/ldap-client-lib.pl +++ b/ldap-client/ldap-client-lib.pl @@ -235,6 +235,7 @@ if ($ldap_hosts) { &find_svalue("port", $conf) || ($use_ssl == 1 ? 636 : 389); foreach my $h (@hosts) { + local $SIG{'PIPE'} = 'ignore'; eval { $ldap = Net::LDAP->new($h, port => $port, scheme => $use_ssl == 1 ? 'ldaps' : 'ldap', @@ -267,10 +268,18 @@ elsif ($uri) { elsif (!$port && $proto eq "ldaps") { $port = 636; } - $ldap = Net::LDAP->new($host, port => $port, - scheme => $proto, - inet6 => &should_use_inet6($host)); - if (!$ldap) { + local $SIG{'PIPE'} = 'ignore'; + eval { + $ldap = Net::LDAP->new($host, port => $port, + scheme => $proto, + inet6 => &should_use_inet6($host)); + }; + if ($@) { + $err = &text('ldap_econn2', + "$host", "$port", + &html_escape($@)); + } + elsif (!$ldap) { $err = &text('ldap_econn', "$host","$port"); }