Fix the lock file access if the accessing user is not the owner of the lockfile in a world readable directory.

This commit is contained in:
Andreas Bachlechner 2022-02-25 09:49:26 +01:00
parent 8f7deef03f
commit d1f029c694
1 changed files with 1 additions and 1 deletions

View File

@ -518,7 +518,7 @@ sub lockfile_handler {
my $lock_file = "/tmp/monitorix.lock";
my $lockfile_was_available = (-e $lock_file);
open(my $fh, ">>", $lock_file) or die "Can't open $lock_file: $!";
open(my $fh, ($lockfile_was_available ? "+<" : ">>"), $lock_file) or die "Can't open $lock_file: $!"; # If the file already exists we open it without the O_CREATE flag due to the limitations introduced by fs.protected_regular.
if (!$lockfile_was_available) {
chmod(0666, $lock_file);
}