pgstef / check_pgbackrest

pgBackRest backup check plugin for Nagios
PostgreSQL License
37 stars 14 forks source link

Can't cd /var/lib/nagios #2

Closed Krysztophe closed 5 years ago

Krysztophe commented 5 years ago

It seems that a sudo -u check_pgbackrest is not possible, it always returns /var/lib/nagios: Permission denied

A workaround is possible with sudo -iu and allowing bash -c check_pgbackrest but it would be better to solve the problem at root. It seems that no_chdir=1 solve the problem, but that involves modifying the regex too.

@@ -579,9 +579,10 @@ sub check_wal_archives {
                                         push @filelist_simplified, substr($filename, 0, 24);
                                     });
         }else{
-            find ( sub {
+            find ( { wanted => sub {
                 return unless -f;
                 return unless qr/[0-9A-F]{24}.*$suffix$/;

@@ -591,6 +592,7 @@ sub check_wal_archives {

                 push @filelist, [$_, (stat($File::Find::name))[9,7], $File::Find::name];
                 push @filelist_simplified, substr($_, 0, 24);
+              } , no_chdir => 1
             }, $archives_dir );
         }

I may submit a real PR someday.

pgstef commented 5 years ago

PR merged. I close this issue then. Thanks