diff --git a/pandora_server/lib/PandoraFMS/Config.pm b/pandora_server/lib/PandoraFMS/Config.pm index 899f3ac753..2eae1e3e95 100644 --- a/pandora_server/lib/PandoraFMS/Config.pm +++ b/pandora_server/lib/PandoraFMS/Config.pm @@ -413,6 +413,9 @@ sub pandora_load_config { $pa_config->{"warmup_unknown_interval"} = 300; # 6.1 $pa_config->{"warmup_unknown_on"} = 1; # 6.1 + # External .enc files for XML::Parser. + $pa_config->{"enc_dir"} = ""; # > 6.0SP4 + # Check for UID0 if ($pa_config->{"quiet"} != 0){ if ($> == 0){ @@ -913,6 +916,9 @@ sub pandora_load_config { $pa_config->{'warmup_unknown_interval'}= clean_blank($1); $pa_config->{'warmup_unknown_on'} = 0 if ($pa_config->{'warmup_unknown_interval'} == 0); # On by default. } + elsif ($parametro =~ m/^enc_dir\s+(.*)/i) { + $pa_config->{'enc_dir'} = clean_blank($1); + } } # end of loop for parameter # # Set to RDBMS' standard port diff --git a/pandora_server/lib/PandoraFMS/DataServer.pm b/pandora_server/lib/PandoraFMS/DataServer.pm index 282d51848c..20d83157d1 100644 --- a/pandora_server/lib/PandoraFMS/DataServer.pm +++ b/pandora_server/lib/PandoraFMS/DataServer.pm @@ -25,6 +25,7 @@ use threads::shared; use Thread::Semaphore; use Time::Local; +use XML::Parser::Expat; use XML::Simple; use POSIX qw(setsid strftime); @@ -71,6 +72,29 @@ sub new ($$;$) { # Call the constructor of the parent class my $self = $class->SUPER::new($config, DATASERVER, \&PandoraFMS::DataServer::data_producer, \&PandoraFMS::DataServer::data_consumer, $dbh); + # Load external .enc files for XML::Parser. + if ($config->{'enc_dir'} ne '') { + if (opendir(my $dh, $config->{'enc_dir'})) { + while (my $enc_file = readdir($dh)) { + + # Ignore unknown files. + next unless ($enc_file =~ m/.enc$/); + + # Load the .enc file. + eval { + local $SIG{__DIE__} = {}; + XML::Parser::Expat::load_encoding($config->{'enc_dir'} . '/' . $enc_file); + }; + if ($@) { + print_message ($config, " [WARNING] Error loading encoding file: $enc_file", 1); + } + } + closedir($dh); + } else { + print_message($config, " [WARNING] Error opening directory " . $config->{'enc_dir'} . ": $!", 1); + } + } + bless $self, $class; return $self; }