Commit 5b3d9d5b authored by frankiejol's avatar frankiejol
Browse files

refactor(auth): do not connect again to LDAP if failed

When LDAP server was down all the fronted was slowed. Now it won't
try to connect to LDAP again if it failed.
parent e57cfee6
......@@ -21,10 +21,12 @@ Initializes the submodules
sub init {
my ($config, $db_con) = @_;
if ($config->{ldap}) {
if ($config->{ldap} && (!defined $LDAP_OK || $LDAP_OK) ) {
eval {
$LDAP_OK = 0;
require Ravada::Auth::LDAP;
Ravada::Auth::LDAP::init($config);
Ravada::Auth::LDAP::_connect_ldap();
$LDAP_OK = 1;
};
warn $@ if $@;
......
......@@ -537,6 +537,7 @@ sub test_pass_storage($with_posix_group) {
my @args = ( $name, $with_posix_group, $$, $storage);
push @args, ($algorithm) if $algorithm;
$Ravada::Auth::LDAP_OK=undef;
Ravada::Auth::LDAP::init();
my $user = test_user(@args);
......
......@@ -478,6 +478,7 @@ for my $vm_name ( vm_names() ) {
}
my $ldap;
$Ravada::Auth::LDAP_OK = undef;
eval { $ldap = Ravada::Auth::LDAP::_init_ldap_admin() } if $vm;
if ($@ =~ /Bad credentials/) {
......
......@@ -1814,7 +1814,7 @@ sub init_ldap_config($file_config='t/etc/ravada_ldap.conf'
$config->{vm}=['KVM','Void'];
delete $config->{ldap}->{ravada_posix_group} if !$with_posix_group;
my $fly_config = "/var/tmp/ravada_".base_domain_name().".conf";
my $fly_config = "/var/tmp/ravada_".base_domain_name().".$$.conf";
DumpFile($fly_config, $config);
$RVD_BACK = undef;
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment