enh(plugin): handle empty login/password (#5060)

Co-authored-by: Sophie Depassio <sdepassio@centreon.com>
This commit is contained in:
omercier 2024-06-13 15:56:34 +02:00 committed by GitHub
parent 0294d1d560
commit f2a2184662
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 13 additions and 5 deletions

View File

@ -67,7 +67,7 @@ sub check_options {
$self->{mqtt_ssl_key} = $options{option_results}->{mqtt_ssl_key};
$self->{mqtt_username} = $options{option_results}->{mqtt_username};
$self->{mqtt_password} = $options{option_results}->{mqtt_password};
$self->{mqtt_allow_unsecure} = $options{option_results}->{mqtt_allow_unsecure};
$self->{mqtt_allow_insecure} = $options{option_results}->{mqtt_allow_insecure};
$self->{mqtt_timeout} = $options{option_results}->{mqtt_timeout};
}
@ -93,7 +93,7 @@ sub set_mqtt_options {
} else {
$self->{mqtt} = Net::MQTT::Simple->new($self->{mqtt_host} . ':' . $self->{mqtt_port});
}
$self->{mqtt}->login($self->{mqtt_username}, $self->{mqtt_password}) if (defined($self->{mqtt_username}) && defined($self->{mqtt_password}));
$self->{mqtt}->login($self->{mqtt_username}, $self->{mqtt_password}) if (!centreon::plugins::misc::is_empty($self->{mqtt_username}) && !centreon::plugins::misc::is_empty($self->{mqtt_password}));
$self->{connection_set} = 1;
}
@ -195,7 +195,7 @@ MQTT password.
=item B<--mqtt-allow-insecure>
Allow unsecure login (default: 0).
Allow insecure login (default: 0).
=item B<--mqtt-timeout>
@ -205,6 +205,6 @@ MQTT timeout (default: 5).
=head1 DESCRIPTION
B<mqtt>.
B<MQTT>.
=cut
=cut

View File

@ -13,7 +13,15 @@
--force-oid
--map-speed-dsl
--mqtt
--mqtt-allow-insecure
--mqtt-ca-certificate
--mqtt-password
--mqtt-port
--mqtt-ssl
--mqtt-ssl-certificate
--mqtt-ssl-key
--mqtt-timeout
--mqtt-username
--nagvis-perfdata
--oid-display
--oid-extra-display