From: Baptiste Beauplat Date: Sat, 11 Sep 2021 14:02:33 +0200 Subject: Use /tmp as default location for statefile Statefile are created by default in /var/lib/centreon/centplugins, which might not exist on the system or standard users might not have access to it. Using /tmp will allow any user to run the plugins. To prevent other users from reading potentially sensitive information, tempfiles are created with a 0600 mode. This is a convenience patch to make plugins work by default with all users. centreon-plugins already have a --statefile-dir option to change the default if needed. Forwarded: not-needed --- src/centreon/plugins/statefile.pm | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/centreon/plugins/statefile.pm b/src/centreon/plugins/statefile.pm index 3047650..cd2d1e9 100644 --- a/src/centreon/plugins/statefile.pm +++ b/src/centreon/plugins/statefile.pm @@ -25,7 +25,7 @@ use warnings; use Data::Dumper; use centreon::plugins::misc; -my $default_dir = '/var/lib/centreon/centplugins'; +my $default_dir = '/tmp'; if ($^O eq 'MSWin32') { $default_dir = 'C:/Windows/Temp'; } @@ -433,6 +433,7 @@ sub write { ); } open FILE, '>', $self->{statefile_dir} . '/' . $self->{statefile}; + chmod 0600, $self->{statefile_dir} . '/' . $self->{statefile}; print FILE $serialized; close FILE; }