Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

apply override_rc deterministically #280

Merged
merged 1 commit into from
Feb 25, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions ex/needrestart.conf
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ $nrconf{blacklist} = [
#];

# Override service default selection (hash of regex).
# Regexes are checked in lexical order; the first matching regex will be used.
$nrconf{override_rc} = {
# DBus
qr(^dbus) => 0,
Expand Down
4 changes: 3 additions & 1 deletion needrestart
Original file line number Diff line number Diff line change
Expand Up @@ -1016,6 +1016,8 @@ if(defined($opt_l) && !$uid) {
}
}

my @sorted_override_rc_keys = sort keys %{$nrconf{override_rc}};

foreach my $rc (sort { lc($a) cmp lc($b) } keys %restart) {
# always combine restarts in one systemctl command
local $nrconf{systemctl_combine} = 1 unless($opt_r eq 'l');
Expand All @@ -1033,7 +1035,7 @@ if(defined($opt_l) && !$uid) {

# don't restart greylisted services...
my $restart = !$nrconf{defno};
foreach my $re (keys %{$nrconf{override_rc}}) {
foreach my $re (@sorted_override_rc_keys) {
next unless($rc =~ /$re/);

$restart = $nrconf{override_rc}->{$re};
Expand Down