From d1f029c694aac0636fa00fdee503258397358c52 Mon Sep 17 00:00:00 2001 From: Andreas Bachlechner <62039342+bachandi@users.noreply.github.com> Date: Fri, 25 Feb 2022 09:49:26 +0100 Subject: [PATCH] Fix the lock file access if the accessing user is not the owner of the lockfile in a world readable directory. --- lib/Monitorix.pm | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/Monitorix.pm b/lib/Monitorix.pm index 988775c..d3b3ff3 100644 --- a/lib/Monitorix.pm +++ b/lib/Monitorix.pm @@ -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); }