similar to what PMG/TFAConfig.pm already does.
Otherwise, sub-routine calls would still be affected leading to
unexpected results, like the issue fixed by commit "cluster config:
restrict slurp scope to avoid issue parsing network interfaces".
Signed-off-by: Fiona Ebner <f.ebner@proxmox.com>
sub read_pmg_acme_challenge_config {
my ($filename, $fh) = @_;
- local $/ = undef; # slurp mode
- my $raw = defined($fh) ? <$fh> : '';
+ my $raw = defined($fh) ? do { local $/ = undef; <$fh> } : '';
return PVE::ACME::Challenge->parse_config($filename, $raw);
}
sub read_pmg_conf {
my ($filename, $fh) = @_;
- local $/ = undef; # slurp mode
-
my $raw;
- $raw = <$fh> if defined($fh);
+ $raw = do { local $/ = undef; <$fh> } if defined($fh);
return PMG::Config::Base->parse_config($filename, $raw);
}
sub read_pmg_ldap_conf {
my ($filename, $fh) = @_;
- local $/ = undef; # slurp mode
-
- my $raw = defined($fh) ? <$fh> : '';
+ my $raw = defined($fh) ? do { local $/ = undef; <$fh> } : '';
return __PACKAGE__->parse_config($filename, $raw);
}
sub read_pmg_node_config {
my ($filename, $fh) = @_;
- local $/ = undef; # slurp mode
- my $raw = defined($fh) ? <$fh> : '';
+ my $raw = defined($fh) ? do { local $/ = undef; <$fh> } : '';
my $digest = Digest::SHA::sha1_hex($raw);
my $conf = PVE::JSONSchema::parse_config($config_schema, $filename, $raw);
$conf->{digest} = $digest;
sub read_pmg_pbs_conf {
my ($filename, $fh) = @_;
- local $/ = undef; # slurp mode
-
- my $raw = defined($fh) ? <$fh> : '';
+ my $raw = defined($fh) ? do { local $/ = undef; <$fh> } : '';
return __PACKAGE__->parse_config($filename, $raw);
}
my $read_rsa_priv_key = sub {
my ($filename, $fh) = @_;
- local $/ = undef; # slurp mode
-
- my $input = <$fh>;
+ my $input = do { local $/ = undef; <$fh> };
return Crypt::OpenSSL::RSA->new_private_key($input);
my $read_rsa_pub_key = sub {
my ($filename, $fh) = @_;
- local $/ = undef; # slurp mode
-
- my $input = <$fh>;
+ my $input = do { local $/ = undef; <$fh> };
return Crypt::OpenSSL::RSA->new_public_key($input);
};
my $read_csrf_secret = sub {
my ($filename, $fh) = @_;
- local $/ = undef; # slurp mode
-
- my $input = <$fh>;
+ my $input = do { local $/ = undef; <$fh> };
return Digest::SHA::hmac_sha256_base64($input);
};