fix: accountInfo: get rid of a warn()

This occurred since v3.01.99-rc1 when requesting an accountInfo
of an account without an ingress_piv_policy set.

Use of uninitialized value  in concatenation (.) or string at /usr/share/perl/5.28/Term/ANSIColor.pm line 510.
 at /opt/bastion/bin/plugin/restricted/../../../lib/perl/OVH/Bastion.pm line 41.
OVH::Bastion::__ANON__("Use of uninitialized value \ in concatenation (.) or st"...) called at /usr/share/perl/5.28/Term/ANSIColor.pm line 510
Term::ANSIColor::colored(undef, "green") called at /opt/bastion/bin/plugin/restricted/accountInfo line 178
This commit is contained in:
Stéphane Lesimple 2021-02-19 16:50:22 +00:00 committed by Stéphane Lesimple
parent ce692ed517
commit 8a0f7c6b4f

View file

@ -175,7 +175,8 @@ if (OVH::Bastion::is_auditor(account => $self)) {
$fnret = OVH::Bastion::account_config(account => $account, public => 1, key => OVH::Bastion::OPT_ACCOUNT_INGRESS_PIV_POLICY); $fnret = OVH::Bastion::account_config(account => $account, public => 1, key => OVH::Bastion::OPT_ACCOUNT_INGRESS_PIV_POLICY);
$ret{'ingress_piv_enforced'} = ($fnret && $fnret->value eq 'yes') ? 1 : 0; # keep for backwards compat $ret{'ingress_piv_enforced'} = ($fnret && $fnret->value eq 'yes') ? 1 : 0; # keep for backwards compat
$ret{'ingress_piv_policy'} = $fnret->value || undef; $ret{'ingress_piv_policy'} = $fnret->value || undef;
osh_info "- PIV policy for ingress keys on this account is set to " . colored($ret{'ingress_piv_policy'}, $ret{'ingress_piv_policy'} eq 'default' ? 'blue' : 'green'); my $ingress_piv_policy_print = $ret{'ingress_piv_policy'} ? $ret{'ingress_piv_policy'} : 'default';
osh_info "- PIV policy for ingress keys on this account is set to " . colored($ingress_piv_policy_print, $ingress_piv_policy_print eq 'default' ? 'blue' : 'green');
$fnret = OVH::Bastion::account_config(account => $account, public => 1, key => OVH::Bastion::OPT_ACCOUNT_INGRESS_PIV_GRACE); $fnret = OVH::Bastion::account_config(account => $account, public => 1, key => OVH::Bastion::OPT_ACCOUNT_INGRESS_PIV_GRACE);
if ($fnret && $fnret->value > time()) { if ($fnret && $fnret->value > time()) {