Merge branch 'ent-6030-Problema-codificacion' into 'develop'

Ent 6030 problema codificacion

See merge request artica/pandorafms!3329
This commit is contained in:
Daniel Rodriguez 2020-07-01 17:55:16 +02:00
commit 5397586470
4 changed files with 31 additions and 5 deletions

View File

@ -276,6 +276,9 @@ $table->data[$i++][1] = html_print_checkbox_switch('event_storm_protection', 1,
$table->data[$i][0] = __('Command Snapshot');
$table->data[$i++][1] = html_print_checkbox_switch('command_snapshot', 1, $config['command_snapshot'], true);
$table->data[$i][0] = __('Change remote config encoding');
$table->data[$i++][1] = html_print_checkbox_switch('use_custom_encoding', 1, $config['use_custom_encoding'], true);
$table->data[$i][0] = __('Server logs directory');
$table->data[$i++][1] = html_print_input_text(
'server_log_dir',

View File

@ -287,6 +287,10 @@ function config_update_config()
$error_update[] = __('Command Snapshot');
}
if (!config_update_value('use_custom_encoding', get_parameter('use_custom_encoding', 0))) {
$error_update[] = __('Use custom encoding');
}
if (!config_update_value('server_log_dir', io_safe_input(strip_tags(io_safe_output(get_parameter('server_log_dir')))))) {
$error_update[] = __('Server logs directory');
}
@ -2799,6 +2803,10 @@ function config_process_config()
config_update_value('event_storm_protection', 0);
}
if (!isset($config['use_custom_encoding'])) {
config_update_value('use_custom_encoding', 0);
}
if (!isset($config['server_log_dir'])) {
config_update_value('server_log_dir', '');
}

View File

@ -177,6 +177,8 @@ sub pandora_get_sharedconfig ($$) {
$pa_config->{"event_storm_protection"} = pandora_get_tconfig_token ($dbh, 'event_storm_protection', 0);
$pa_config->{"use_custom_encoding"} = pandora_get_tconfig_token ($dbh, 'use_custom_encoding', 0);
if ($pa_config->{'include_agents'} eq '') {
$pa_config->{'include_agents'} = 0;
}
@ -472,6 +474,7 @@ sub pandora_load_config {
$pa_config->{"stats_interval"} = 300;
$pa_config->{"agentaccess"} = 1;
$pa_config->{"event_storm_protection"} = 0;
$pa_config->{"use_custom_encoding"} = 0;
$pa_config->{"node_metaconsole"} = 0; # > 7.0NG
# -------------------------------------------------------------------------

View File

@ -374,14 +374,26 @@ our $THRRUN :shared = 1;
################################################################################
## Reads a file and returns entire content or undef if error.
################################################################################
sub read_file {
my $path = shift;
sub read_file($;$) {
my ($path, $enc) = @_;
my $_FILE;
if (!defined($enc)) {
if( !open($_FILE, "<", $path) ) {
# failed to open, return undef
return undef;
}
} else {
if ( $enc eq '' ) {
$enc = 'utf8';
}
if( !open($_FILE, "<:encoding($enc)", $path) ) {
# failed to open, return undef
return undef;
}
}
# Slurp configuration file content.
my $content = do { local $/; <$_FILE> };