Empty ini sections causes portal crash (fixes #167)
This commit is contained in:
parent
6008516967
commit
3f076ea350
|
@ -153,7 +153,8 @@ sub getConf {
|
||||||
delete $r->{reVHosts};
|
delete $r->{reVHosts};
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
print STDERR "Warning: key is not defined, set it in the manager !\n"
|
print STDERR
|
||||||
|
"Warning: key is not defined, set it in the manager !\n"
|
||||||
unless ( $r->{key} );
|
unless ( $r->{key} );
|
||||||
eval {
|
eval {
|
||||||
$r->{cipher} = Lemonldap::NG::Common::Crypto->new(
|
$r->{cipher} = Lemonldap::NG::Common::Crypto->new(
|
||||||
|
@ -179,7 +180,7 @@ sub getConf {
|
||||||
# @return Lemonldap::NG configuration
|
# @return Lemonldap::NG configuration
|
||||||
sub getLocalConf {
|
sub getLocalConf {
|
||||||
my ( $self, $section, $file, $loaddefault ) = @_;
|
my ( $self, $section, $file, $loaddefault ) = @_;
|
||||||
my $r;
|
my $r = {};
|
||||||
|
|
||||||
$section ||= DEFAULTSECTION;
|
$section ||= DEFAULTSECTION;
|
||||||
$file ||= DEFAULTCONFFILE;
|
$file ||= DEFAULTCONFFILE;
|
||||||
|
@ -196,9 +197,9 @@ sub getLocalConf {
|
||||||
if ( $section eq CONFSECTION ) {
|
if ( $section eq CONFSECTION ) {
|
||||||
$msg =
|
$msg =
|
||||||
"Cannot read $file to get configuration access parameters.";
|
"Cannot read $file to get configuration access parameters.";
|
||||||
return 0;
|
return $r;
|
||||||
}
|
}
|
||||||
return 0;
|
return $r;
|
||||||
}
|
}
|
||||||
|
|
||||||
# Parse ini file
|
# Parse ini file
|
||||||
|
@ -206,19 +207,19 @@ sub getLocalConf {
|
||||||
|
|
||||||
unless ( defined $cfg ) {
|
unless ( defined $cfg ) {
|
||||||
$msg = "Local config error: " . @Config::IniFiles::errors;
|
$msg = "Local config error: " . @Config::IniFiles::errors;
|
||||||
return 0;
|
return $r;
|
||||||
}
|
}
|
||||||
|
|
||||||
# Check if default section exists
|
# Check if default section exists
|
||||||
unless ( $cfg->SectionExists(DEFAULTSECTION) ) {
|
unless ( $cfg->SectionExists(DEFAULTSECTION) ) {
|
||||||
$msg = "Default section (" . DEFAULTSECTION . ") is missing.";
|
$msg = "Default section (" . DEFAULTSECTION . ") is missing.";
|
||||||
return 0;
|
return $r;
|
||||||
}
|
}
|
||||||
|
|
||||||
# Check if configuration section exists
|
# Check if configuration section exists
|
||||||
if ( $section eq CONFSECTION and !$cfg->SectionExists(CONFSECTION) ) {
|
if ( $section eq CONFSECTION and !$cfg->SectionExists(CONFSECTION) ) {
|
||||||
$msg = "Configuration section (" . CONFSECTION . ") is missing.";
|
$msg = "Configuration section (" . CONFSECTION . ") is missing.";
|
||||||
return 0;
|
return $r;
|
||||||
}
|
}
|
||||||
$configFiles->{$file} = $cfg;
|
$configFiles->{$file} = $cfg;
|
||||||
}
|
}
|
||||||
|
@ -231,7 +232,7 @@ sub getLocalConf {
|
||||||
eval "\$r->{$_} = $r->{$_}";
|
eval "\$r->{$_} = $r->{$_}";
|
||||||
if ($@) {
|
if ($@) {
|
||||||
$msg = "Warning: error in file $file: $@.";
|
$msg = "Warning: error in file $file: $@.";
|
||||||
return 0;
|
return $r;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -241,7 +242,7 @@ sub getLocalConf {
|
||||||
return $r if ( $section eq DEFAULTSECTION );
|
return $r if ( $section eq DEFAULTSECTION );
|
||||||
|
|
||||||
# Check if requested section exists
|
# Check if requested section exists
|
||||||
return 0 unless $cfg->SectionExists($section);
|
return $r unless $cfg->SectionExists($section);
|
||||||
|
|
||||||
# Load section parameters
|
# Load section parameters
|
||||||
foreach ( $cfg->Parameters($section) ) {
|
foreach ( $cfg->Parameters($section) ) {
|
||||||
|
@ -250,7 +251,7 @@ sub getLocalConf {
|
||||||
eval "\$r->{$_} = $r->{$_}";
|
eval "\$r->{$_} = $r->{$_}";
|
||||||
if ($@) {
|
if ($@) {
|
||||||
$msg = "Warning: error in file $file: $@.";
|
$msg = "Warning: error in file $file: $@.";
|
||||||
return 0;
|
return $r;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user