fix(portforwarding): undefined var when managing group port forwards

pull/597/head
jon4hz 5 months ago
parent f438a0aeaa
commit 6cd3b2aeed
No known key found for this signature in database
GPG Key ID: 4B0AFE9E7118898E

@ -17,11 +17,11 @@ use OVH::Bastion::Helper;
# Fetch command options
my $fnret;
my ($result, @optwarns);
my $group;
my ($group, $deletedLocalPort);
eval {
local $SIG{__WARN__} = sub { push @optwarns, shift };
$result = GetOptions(
"group=s" => sub { $group //= $_[1] },
"group=s" => sub { $group //= $_[1] },
"deleted-local-port=i" => sub { $deletedLocalPort //= $_[1] },
);
};
@ -82,7 +82,8 @@ foreach my $member (@$members) {
my @errors;
my @success;
foreach my $account (@accounts_to_update) {
$fnret = OVH::Bastion::generate_account_sshd_forwarding_config(account => $account, deletedLocalPort => $deletedLocalPort);
$fnret =
OVH::Bastion::generate_account_sshd_forwarding_config(account => $account, deletedLocalPort => $deletedLocalPort);
if ($fnret) {
push @success, $account;
}

@ -145,7 +145,7 @@ if ($fnret && $fnret->err ne 'OK_NO_CHANGE' && $remotePort) {
# Now regenerate the sshd config for all members of this group
my @sshd_command = qw{ sudo -n -u root -- /usr/bin/env perl -T };
push @sshd_command, $OVH::Bastion::BASEPATH . '/bin/helper/osh-groupGenerateSshdConfig';
push @sshd_command, '--group', $group;
push @sshd_command, '--group', $group;
push @sshd_command, '--deleted-local-port', $fnret->value->{'localPort'} if defined $fnret->value->{'localPort'};
my $sshd_fnret = OVH::Bastion::helper(cmd => \@sshd_command);

Loading…
Cancel
Save