From f8713651cce8849153761dbcb87cfadef5f05a13 Mon Sep 17 00:00:00 2001 From: David Goodwin Date: Sat, 14 Sep 2019 21:27:46 +0100 Subject: [PATCH] explode if $run_dir is not specified; make a config setting and perhaps shift the onus onto the user rather than having to deal with tmpfiles.d etc See: https://github.com/postfixadmin/postfixadmin/issues/78 --- ADDITIONS/fetchmail.pl | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/ADDITIONS/fetchmail.pl b/ADDITIONS/fetchmail.pl index c6ad9f9d..3a4a03a1 100644 --- a/ADDITIONS/fetchmail.pl +++ b/ADDITIONS/fetchmail.pl @@ -26,6 +26,9 @@ our $db_username="mail"; # database password our $db_password="CHANGE_ME!"; +# Where to create a lockfile; please ensure path exists. +our $run_dir="/var/run/fetchmail"; + # instead of changing this script, you can put your settings to /etc/mail/postfixadmin/fetchmail.conf # just use perl syntax there to fill the variables listed above (without the "our" keyword). Example: # $db_username = 'mail'; @@ -40,7 +43,7 @@ if (-f "/etc/mail/postfixadmin/fetchmail.conf") { openlog("fetchmail-all", "pid", "mail"); sub log_and_die { - my($message) = @_; + my($message) = @_; syslog("err", $message); die $message; } @@ -59,8 +62,6 @@ while ($_ = shift @ARGS1) { } } -$run_dir="/var/run/fetchmail"; - # use specified config file if (-e $configfile) { do $configfile; @@ -72,6 +73,10 @@ if($db_type eq "Pg" || $db_type eq "mysql") { log_and_die "unsupported db_type $db_type"; } +if(!-d $run_dir) { + log_and_die("Please create: $run_dir"); +} + $lock_file=$run_dir . "/fetchmail-all.lock"; $lockmgr = LockFile::Simple->make(-autoclean => 1, -max => 1);