mirror of
https://github.com/ovh/the-bastion.git
synced 2024-09-20 23:15:58 +08:00
fix: use local $_ before while(<>) loops
This closes a range of bugs that can happen if a function using $_ implicitly in a while is called in a grep {} or map {} which also uses $_
This commit is contained in:
parent
2193ee487d
commit
b942131092
|
@ -307,6 +307,7 @@ sub sys_delmemberfromgroup {
|
||||||
# manually patching /etc/group... eew :(
|
# manually patching /etc/group... eew :(
|
||||||
my $contents;
|
my $contents;
|
||||||
if (open(my $fh, '<', '/etc/group')) {
|
if (open(my $fh, '<', '/etc/group')) {
|
||||||
|
local $_ = undef;
|
||||||
while (<$fh>) {
|
while (<$fh>) {
|
||||||
if (/^\Q$group\E:/) {
|
if (/^\Q$group\E:/) {
|
||||||
s/([:,])\Q$user\E(?:,|$)/$1/;
|
s/([:,])\Q$user\E(?:,|$)/$1/;
|
||||||
|
|
|
@ -124,6 +124,7 @@ sub get_hashes_list {
|
||||||
|
|
||||||
my %metadata;
|
my %metadata;
|
||||||
if (open(my $metadatafd, '<', "$currentname.metadata")) {
|
if (open(my $metadatafd, '<', "$currentname.metadata")) {
|
||||||
|
local $_ = undef;
|
||||||
while (<$metadatafd>) {
|
while (<$metadatafd>) {
|
||||||
chomp;
|
chomp;
|
||||||
m{^([A-Z0-9_-]+)=(.+)$} or next;
|
m{^([A-Z0-9_-]+)=(.+)$} or next;
|
||||||
|
|
|
@ -361,6 +361,7 @@ sub get_ssh_pub_key_info {
|
||||||
$shortfp =~ s/^.{12}//;
|
$shortfp =~ s/^.{12}//;
|
||||||
|
|
||||||
#print "looking for shortfingerprint=$shortfp...\n";
|
#print "looking for shortfingerprint=$shortfp...\n";
|
||||||
|
local $_ = undef;
|
||||||
while (<$fh_blacklist>) {
|
while (<$fh_blacklist>) {
|
||||||
/^\Q$shortfp\E$/ or next;
|
/^\Q$shortfp\E$/ or next;
|
||||||
close($fh_blacklist);
|
close($fh_blacklist);
|
||||||
|
|
Loading…
Reference in a new issue