liske / needrestart

Restart daemons after library updates.
GNU General Public License v2.0
423 stars 67 forks source link

Needrestart reports cron.service when it runs scripts that use file locking on itself #242

Open moschlar opened 2 years ago

moschlar commented 2 years ago

We have (at least) two Perl scripts that are run via Cron and they use File::NFSLock to get a lock on themselves:

use Fcntl qw(LOCK_EX LOCK_NB);
use File::NFSLock;

my $lock = File::NFSLock->new($0, LOCK_EX|LOCK_NB);

Apparently, this causes the files' own modification date to be set to the time of the lock creation (in addition to creating a $0.NFSLock file) which leads to needrestart reporting it:

[Core] #46608 is a NeedRestart::Interp::Perl
[Perl] #46608: source=/usr/local/adsm/adsm-check-nasbackups
[Core] #46608 uses obsolete script file(s):
[Core] #46608  /usr/local/adsm/adsm-check-nasbackups
[main] #46608 is a child of #46605
[main] #46605 exe => /bin/bash
[main] #46605 is cron.service

I don't know if there is the possibility for a general solution here (I can of course blacklist these scripts explicitly, but maybe there is a way to easily detect the situation).

liske commented 2 years ago

I don't see a generic way how to detect and handle this (and I would not expect any locking in /usr at all).