Here is a minimalistic patch for poprelayd version 1.5
to work with MTA Exim (version 3.36) and POP/IMAP
Daemon Cyrus (version 2.0.17).
This patch also contains a small modification to work
with log files which are copied and then truncated
(instead of rotated).
The patched daemon is running at our site since a few
weeks without problems.
Patch:
--- poprelay-1.5/poprelayd.orig Wed Jan 22 05:35:50 2003
+++ poprelay-1.5/poprelayd Fri May 9 10:04:12 2003
@@ -1,6 +1,6 @@
#!/usr/bin/perl
#
-# poprelayd - update /etc/mail/popip based on POP logins
+# poprelayd - update /etc/popip based on POP logins
#
# This code was written by Curt Sampson
<cjs@cynic.net> and placed into
# the public domain in 1998 by Western Internet
Portal Services, Inc.
@@ -37,13 +37,13 @@
# Configuration settings.
#
-$config_file="/etc/mail/poprelay.conf";
+$config_file="/etc/poprelay.conf";
# Defaults:
$logfile = "/var/log/maillog"; # POP3 daemon log.
$pidfile = "/var/run/poprelayd.pid"; # Where we put
our PID.
-$dbfile = "/etc/mail/popip.db"; #
Sendmail map to update.
+$dbfile = "/etc/popip.db"; # Sendmail map
to update.
$dbtype = "DB_HASH";
$timeout_minutes = 3000; # Minutes an
entry lasts. (3000 = ~ 2 days)
$log_wait_interval = 5; #
Number of seconds between checks
@@ -117,12 +117,12 @@
}
sub adddb {
- my $addr = $_[0];
+ my $addr = $_[0]."\000";
$db{$addr} = time;
}
sub removedb {
- my $addr = $_[0];
+ my $addr = $_[0]."\000";
delete $db{$addr};
}
@@ -193,6 +193,14 @@
($junk, $lfino, $junk) = POSIX::fstat($lffd);
}
+ # Check if the current position is beyond the size.
+ # This indicates a truncated logfile. (rotate by
copy + truncate)
+ if (POSIX::lseek($lffd, 0, &POSIX::SEEK_CUR) >
(POSIX::fstat($lffd))[7]) {
+ if (POSIX::lseek($lffd, 0, &POSIX::SEEK_END) ==
-1) {
+ die "Can't seek to end of $logfile\n";
+ }
+ }
+
return undef;
}
@@ -303,7 +311,7 @@
unless ( tie(%db, "DB_File", $dbfile,
O_RDWR|O_CREAT, 0644, $$dbtype) ) {
#Can't tie to the $dbfile
print ("Couldn't open $dbfile. Trying
to create a new one\n");
- system("makemap hash $dbfile < /dev/null");
+ system("/usr/local/bin/exim_dbmbuild
/dev/null $dbfile.db");
}
untie %db;
die "Can't write to $pidfile" unless ( (-w
$pidfile) || (! -e $pidfile) );
Exim configuration excerpt:
host_accept_relay = localhost : net-dbm;/etc/popip.db
Patch