Project

General

Profile

Patch #21137 ยป 0001-Rescue-network-level-errors-with-LDAP-auth-to-avoid-.patch

Holger Just, 2015-11-03 11:06

View differences:

app/models/auth_source_ldap.rb
require 'timeout'
class AuthSourceLdap < AuthSource
NETWORK_EXCEPTIONS = [
Net::LDAP::LdapError,
Errno::ECONNABORTED, Errno::ECONNREFUSED, Errno::ECONNRESET,
Errno::EHOSTDOWN, Errno::EHOSTUNREACH,
SocketError
]
validates_presence_of :host, :port, :attr_login
validates_length_of :name, :host, :maximum => 60, :allow_nil => true
validates_length_of :account, :account_password, :base_dn, :maximum => 255, :allow_blank => true
......
return attrs.except(:dn)
end
end
rescue Net::LDAP::LdapError => e
rescue *NETWORK_EXCEPTIONS => e
raise AuthSourceException.new(e.message)
end
......
ldap_con = initialize_ldap_con(self.account, self.account_password)
ldap_con.open { }
end
rescue Net::LDAP::LdapError => e
rescue *NETWORK_EXCEPTIONS => e
raise AuthSourceException.new(e.message)
end
......
results << attrs
end
results
rescue Net::LDAP::LdapError => e
rescue *NETWORK_EXCEPTIONS => e
raise AuthSourceException.new(e.message)
end
    (1-1/1)