# 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;
$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;
}
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");
@errors = <MERGEERR>;
close MERGEERR;
+ flock(LOCKFILE, LOCK_UN);
+ close(LOCKFILE);
+
return @mergedata;
}