Skip to content

Commit

Permalink
core: fix regression of false positives for processes running in chro…
Browse files Browse the repository at this point in the history
…ot or mountns (#317)
  • Loading branch information
liske committed Nov 28, 2024
1 parent 7c276d3 commit e17b564
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions needrestart
Original file line number Diff line number Diff line change
Expand Up @@ -530,15 +530,21 @@ if(defined($opt_l)) {
# orphaned binary
$restart++ if (defined($exe) && $exe =~ s/ \(deleted\)$//); # Linux
$restart++ if (defined($exe) && $exe =~ s/^\(deleted\)//); # Linux VServer
$restart++ unless(defined($ptable->{$pid}->{exec}));
print STDERR "$LOGPREF #$pid uses obsolete binary $exe\n" if($restart && $nrconf{verbosity} > 1);

# ignore blacklisted binaries
next if(grep { $exe =~ /$_/; } @{$nrconf{blacklist}});

# Sync $exe with the initial value from Proc:ProcessTable to prevent race
# Sync $exe with the initial value from Proc::ProcessTable to prevent race
# conditions in later checks.
$exe = $ptable->{$pid}->{exec} if(defined($ptable->{$pid}->{exec}));
if(defined($ptable->{$pid}->{exec})) {
$exe = $ptable->{$pid}->{exec};
}
# Proc::ProcessTable's exec field is undef if the file is not accessible in
# the root mountns, so the value of $exe is used instead.
else {
$ptable->{$pid}->{exec} = $exe;
}

# read file mappings (Linux 2.0+)
unless($restart) {
Expand Down

0 comments on commit e17b564

Please sign in to comment.