X-Git-Url: https://git.sommitrealweird.co.uk/onak.git/blobdiff_plain/f5f103192a4105438bee90bbf85e7407f73b49ca..393d83b8760584006eaefd6fc370abead228e02a:/onak-mail.pl diff --git a/onak-mail.pl b/onak-mail.pl index 1c3647c..6799b3d 100755 --- a/onak-mail.pl +++ b/onak-mail.pl @@ -6,10 +6,9 @@ # Copyright 2002 Project Purple # Released under the GPL. # -# $Id: onak-mail.pl,v 1.8 2003/10/11 22:17:17 noodles Exp $ -# use strict; +use Fcntl ':flock'; use IPC::Open3; my %config; @@ -38,6 +37,8 @@ sub readconfig { $config{'mta'} = $1; } elsif (/^pks_bin_dir (.*)/) { $config{'pks_bin_dir'} = $1; + } elsif (/^db_dir (.*)/) { + $config{'db_dir'} = $1; } elsif (/^syncsite (.*)/) { push @{$config{'syncsites'}}, $1; } @@ -59,6 +60,10 @@ sub submitupdate { my @data = @_; my (@errors, @mergedata); + open(LOCKFILE, '>'.$config{'db_dir'}.'/onak-mail.lck'); + flock(LOCKFILE, LOCK_EX); + print LOCKFILE "$$"; + open3(\*MERGEIN, \*MERGEOUT, \*MERGEERR, $config{'pks_bin_dir'}."/onak", "-u", "add"); @@ -69,6 +74,9 @@ sub submitupdate { @errors = ; close MERGEERR; + flock(LOCKFILE, LOCK_UN); + close(LOCKFILE); + return @mergedata; }