lookup-domain.pl, no where to be found

16 posts / 0 new
Last post
#1 Mon, 05/26/2008 - 05:54
bmorin

lookup-domain.pl, no where to be found

Hello,

I have a very generic, stock installation, CentOS5, and Virtualmin with all the updates. None of my domains are receiving email. I think it has to do with lookup-domain.pl. I searched the forums, and found what the script should be, and created it, but I think it needs to exist other places than /etc/webmin/virtual-server/lookup-domain.pl.

For that matter, it is no where on the system, not even in /usr/share, or /usr/lib. So I think something didn't install right, but I can't figure out what.

Here is a sample log entry for an email that isn't getting delivered: (domains obfuscated) [code:1]May 25 18:17:00 www postfix/local[16940]: 0CD2D1398017: to=<rwood.fron_line_er_sp_ce@www.ma_est_cdocum_nt_.com>, orig_to=<rwood@fron_line_er_sp_ce.com>, relay=local, delay=0.25, delays=0.24/0/0/0.01, dsn=2.0.0, status=sent (delivered to command: /usr/bin/procmail-wrapper -o -a $DOMAIN -d $LOGNAME)[/code:1]

However it seems that the script isn't working right.

[code:1] > ls /var/mail/rwood.fron_line_er_sp_ce /var/mail/rwood.fron_line_er_sp_ce

> /etc/webmin/virtual-server/lookup-domain.pl rwood.fron_line_er_sp_ce <no output>[/code:1]

Debugging lookup-domain.sh leads me to "/etc/webmin/miniserv.conf", and the root entry, which is "/usr/libexec/webmin", so according to the script, it is looking for "/usr/libexec/webmin/virtual-server/lookup-domain.pl", and it doesn't exist.

So I think something didn't happen right during setup. I'd appreciate any help in troubleshooting this, or finding out the contents of "/usr/libexec/webmin/virtual-server/lookup-domain.pl", as that might fix everything.

Thanks much.

--Brian

Sun, 06/07/2009 - 07:22
ronald
ronald's picture

This is what the file &quot;/usr/libexec/webmin/virtual-server/lookup-domain.pl&quot; says. I have centos 5 too:
[code:1]
#!/usr/bin/perl
# Returns the domain ID for some user, if the domain has spam enabled and
# if the user is not approaching his quota

$no_acl_check++;
@ARGV == 1 || die &quot;usage: lookup-domain.pl &lt;username&gt;&quot;;
use Socket;

# Get the message size
while($got = read(STDIN, $buf, 1024)) {
$size += $got;
}
$margin = $size*2+5*1024*1024;

# First, try connecting to the lookup-domain-daemon.pl process
socket(DAEMON, PF_INET, SOCK_STREAM, getprotobyname(&quot;tcp&quot;&Acirc;&laquo;&Acirc;&raquo;));
$rv = connect(DAEMON, pack_sockaddr_in(11000, inet_aton(&quot;127.0.0.1&quot;&Acirc;&laquo;&Acirc;&raquo;)));
if ($rv) {
select(DAEMON); $| = 1; select(STDOUT);
print DAEMON $ARGV[0],&quot;\n&quot;;
$fromdaemon = &lt;DAEMON&gt;;
$fromdaemon =~ s/\r|\n//g;
close(DAEMON);
}
if ($fromdaemon) {
# We have an answer from the server process
($did, $dname, $spam, $spamc, $quotaleft) = split(/\t/, $fromdaemon);
if (!$did || !$spam) {
# No such user, or user's domain doesn't have spam enabled -
# don't do spam check
}
elsif ($spamc || $quotaleft eq &quot;UNLIMITED&quot;&Acirc;&laquo;&Acirc;&raquo;) {
# Domain is using spamc, or user has no quota, or quota disabled
# Do spam check.
print $did,&quot;\n&quot;;
}
elsif ($quotaleft &lt; $margin) {
# Too close to quota - don't check
}
else {
# Do spam check
print $did,&quot;\n&quot;;
}
exit(0);
}

# Open the cache DBM
$cachefile = &quot;$ENV{'WEBMIN_VAR'}/lookup-domain-cache&quot;;
eval &quot;use SDBM_File&quot;;
dbmopen(%usercache, $cachefile, 0700);
eval &quot;\$usercache{'1111111111'} = 1&quot;;
if ($@) {
dbmclose(%usercache);
eval &quot;use NDBM_File&quot;;
dbmopen(%usercache, $cachefile, 0700);
}

# Check our cache first, in case we have just done this user
$now = time();
if (defined($usercache{$ARGV[0]})) {
($cachespam, $cachequota, $cacheuquota, $cachetime, $cacheclient) =
split(/ /, $usercache{$ARGV[0]});
$cacheclient ||= &quot;spamassassin&quot;;
if ($now - $cachetime &lt; 60*60) {
if (!$cachespam) {
# Domain doesn't have spam enabled, so don't do check
$cacheuquota += $size;
&amp;update_cache();
exit(0);
}
elsif ($cacheclient eq &quot;spamc&quot;&Acirc;&laquo;&Acirc;&raquo;) {
# Using spamc, so quotas don't matter
$cacheuquota += $size;
&amp;update_cache();
print $cachespam,&quot;\n&quot;;
exit(0);
}
elsif ($cachequota &amp;&amp; $cacheuquota+$margin &gt;= $cachequota) {
# User is over quota, so don't do spam check
$cacheuquota += $size;
$cacheuquota = $cachequota
if ($cacheuquota &gt; $cachequota);
&amp;update_cache();
exit(0);
}
else {
# User is under quota, so proceed
$cacheuquota += $size;
&amp;update_cache();
print $cachespam,&quot;\n&quot;;
exit(0);
}
}
}

# Lookup the user for real
do './virtual-server-lib.pl';
$d = &amp;get_user_domain($ARGV[0]);
if (!$d || !$d-&gt;{'spam'}) {
$cachespam = $cachequota = $cacheuquota = 0;
$cachetime = $now;
&amp;update_cache();
exit(0);
}

# See what kind of quotas are relevant
$qmode = &amp;mail_under_home() &amp;&amp; &amp;has_home_quotas() ? &quot;home&quot; :
&amp;has_mail_quotas() ? &quot;mail&quot; : undef;
if (!$qmode) {
# None .. so run spam checks
$cachespam = $d-&gt;{'id'};
$cachequota = $cacheuquota = 0;
$cachetime = $now;
&amp;update_cache();
print &quot;$d-&gt;{'id'}\n&quot;;
exit(0);
}

# Check if the domain is using spamc or spamassassin
$cacheclient = &amp;get_domain_spam_client($d);

# Check if the user is approaching his quota
@users = &amp;list_domain_users($d, 0, 1, 0, 1);
($user) = grep { $_-&gt;{'user'} eq $ARGV[0] ||
&amp;replace_atsign($_-&gt;{'user'}) eq $ARGV[0] } @users;
if (!$user) {
# Couldn't find him?! So do the spam check
$cachespam = $d-&gt;{'id'};
$cachequota = $cacheuquota = 0;
$cachetime = $now;
&amp;update_cache();
print &quot;$d-&gt;{'id'}\n&quot;;
exit(0);
}
if ($qmode eq &quot;home&quot;&Acirc;&laquo;&Acirc;&raquo;) {
($quota, $uquota) = ($user-&gt;{'quota'}, $user-&gt;{'uquota'});
}
else {
($quota, $uquota) = ($user-&gt;{'mquota'}, $user-&gt;{'umquota'});
}
$bsize = &amp;quota_bsize($qmode);
$quota *= $bsize;
$uquota *= $bsize;
if ($user-&gt;{'nospam'}) {
# Spam filtering disabled for this user
$cachespam = 0;
}
elsif ($cacheclient eq &quot;spamc&quot;&Acirc;&laquo;&Acirc;&raquo;) {
# Using spamc, so quotas don't matter since spam processing is run
# by a daemon
print &quot;$d-&gt;{'id'}\n&quot;;
}
elsif ($quota &amp;&amp; $uquota+$margin &gt;= $quota) {
# Over quota, or too close to it
}
else {
# Under quota ... do the spam check
print &quot;$d-&gt;{'id'}\n&quot;;
}
$cachespam = $d-&gt;{'id'};
$cachequota = $quota;
$cacheuquota = $uquota;
$cachetime = $now;
&amp;update_cache();

sub update_cache
{
$usercache{$ARGV[0]} = join(&quot; &quot;, $cachespam, $cachequota, $cacheuquota, $cachetime, $cacheclient);
dbmclose(%usercache);
}[/code:1]

Sun, 06/07/2009 - 07:23
ronald
ronald's picture

This is what the file &quot;/usr/libexec/webmin/virtual-server/lookup-domain.pl&quot; says. I have centos 5 too:
[code:1]
#!/usr/bin/perl
# Returns the domain ID for some user, if the domain has spam enabled and
# if the user is not approaching his quota

$no_acl_check++;
@ARGV == 1 || die &quot;usage: lookup-domain.pl &lt;username&gt;&quot;;
use Socket;

# Get the message size
while($got = read(STDIN, $buf, 1024)) {
$size += $got;
}
$margin = $size*2+5*1024*1024;

# First, try connecting to the lookup-domain-daemon.pl process
socket(DAEMON, PF_INET, SOCK_STREAM, getprotobyname(&quot;tcp&quot;&Acirc;&laquo;&Acirc;&raquo;));
$rv = connect(DAEMON, pack_sockaddr_in(11000, inet_aton(&quot;127.0.0.1&quot;&Acirc;&laquo;&Acirc;&raquo;)));
if ($rv) {
select(DAEMON); $| = 1; select(STDOUT);
print DAEMON $ARGV[0],&quot;\n&quot;;
$fromdaemon = &lt;DAEMON&gt;;
$fromdaemon =~ s/\r|\n//g;
close(DAEMON);
}
if ($fromdaemon) {
# We have an answer from the server process
($did, $dname, $spam, $spamc, $quotaleft) = split(/\t/, $fromdaemon);
if (!$did || !$spam) {
# No such user, or user's domain doesn't have spam enabled -
# don't do spam check
}
elsif ($spamc || $quotaleft eq &quot;UNLIMITED&quot;&Acirc;&laquo;&Acirc;&raquo;) {
# Domain is using spamc, or user has no quota, or quota disabled
# Do spam check.
print $did,&quot;\n&quot;;
}
elsif ($quotaleft &lt; $margin) {
# Too close to quota - don't check
}
else {
# Do spam check
print $did,&quot;\n&quot;;
}
exit(0);
}

# Open the cache DBM
$cachefile = &quot;$ENV{'WEBMIN_VAR'}/lookup-domain-cache&quot;;
eval &quot;use SDBM_File&quot;;
dbmopen(%usercache, $cachefile, 0700);
eval &quot;\$usercache{'1111111111'} = 1&quot;;
if ($@) {
dbmclose(%usercache);
eval &quot;use NDBM_File&quot;;
dbmopen(%usercache, $cachefile, 0700);
}

# Check our cache first, in case we have just done this user
$now = time();
if (defined($usercache{$ARGV[0]})) {
($cachespam, $cachequota, $cacheuquota, $cachetime, $cacheclient) =
split(/ /, $usercache{$ARGV[0]});
$cacheclient ||= &quot;spamassassin&quot;;
if ($now - $cachetime &lt; 60*60) {
if (!$cachespam) {
# Domain doesn't have spam enabled, so don't do check
$cacheuquota += $size;
&amp;update_cache();
exit(0);
}
elsif ($cacheclient eq &quot;spamc&quot;&Acirc;&laquo;&Acirc;&raquo;) {
# Using spamc, so quotas don't matter
$cacheuquota += $size;
&amp;update_cache();
print $cachespam,&quot;\n&quot;;
exit(0);
}
elsif ($cachequota &amp;&amp; $cacheuquota+$margin &gt;= $cachequota) {
# User is over quota, so don't do spam check
$cacheuquota += $size;
$cacheuquota = $cachequota
if ($cacheuquota &gt; $cachequota);
&amp;update_cache();
exit(0);
}
else {
# User is under quota, so proceed
$cacheuquota += $size;
&amp;update_cache();
print $cachespam,&quot;\n&quot;;
exit(0);
}
}
}

# Lookup the user for real
do './virtual-server-lib.pl';
$d = &amp;get_user_domain($ARGV[0]);
if (!$d || !$d-&gt;{'spam'}) {
$cachespam = $cachequota = $cacheuquota = 0;
$cachetime = $now;
&amp;update_cache();
exit(0);
}

# See what kind of quotas are relevant
$qmode = &amp;mail_under_home() &amp;&amp; &amp;has_home_quotas() ? &quot;home&quot; :
&amp;has_mail_quotas() ? &quot;mail&quot; : undef;
if (!$qmode) {
# None .. so run spam checks
$cachespam = $d-&gt;{'id'};
$cachequota = $cacheuquota = 0;
$cachetime = $now;
&amp;update_cache();
print &quot;$d-&gt;{'id'}\n&quot;;
exit(0);
}

# Check if the domain is using spamc or spamassassin
$cacheclient = &amp;get_domain_spam_client($d);

# Check if the user is approaching his quota
@users = &amp;list_domain_users($d, 0, 1, 0, 1);
($user) = grep { $_-&gt;{'user'} eq $ARGV[0] ||
&amp;replace_atsign($_-&gt;{'user'}) eq $ARGV[0] } @users;
if (!$user) {
# Couldn't find him?! So do the spam check
$cachespam = $d-&gt;{'id'};
$cachequota = $cacheuquota = 0;
$cachetime = $now;
&amp;update_cache();
print &quot;$d-&gt;{'id'}\n&quot;;
exit(0);
}
if ($qmode eq &quot;home&quot;&Acirc;&laquo;&Acirc;&raquo;) {
($quota, $uquota) = ($user-&gt;{'quota'}, $user-&gt;{'uquota'});
}
else {
($quota, $uquota) = ($user-&gt;{'mquota'}, $user-&gt;{'umquota'});
}
$bsize = &amp;quota_bsize($qmode);
$quota *= $bsize;
$uquota *= $bsize;
if ($user-&gt;{'nospam'}) {
# Spam filtering disabled for this user
$cachespam = 0;
}
elsif ($cacheclient eq &quot;spamc&quot;&Acirc;&laquo;&Acirc;&raquo;) {
# Using spamc, so quotas don't matter since spam processing is run
# by a daemon
print &quot;$d-&gt;{'id'}\n&quot;;
}
elsif ($quota &amp;&amp; $uquota+$margin &gt;= $quota) {
# Over quota, or too close to it
}
else {
# Under quota ... do the spam check
print &quot;$d-&gt;{'id'}\n&quot;;
}
$cachespam = $d-&gt;{'id'};
$cachequota = $quota;
$cacheuquota = $uquota;
$cachetime = $now;
&amp;update_cache();

sub update_cache
{
$usercache{$ARGV[0]} = join(&quot; &quot;, $cachespam, $cachequota, $cacheuquota, $cachetime, $cacheclient);
dbmclose(%usercache);
}[/code:1]

Tue, 05/27/2008 - 16:44
bmorin

Thanks for posting that Ronald.

Apparently there is something else wrong here, as that didn't do it.

I find it really odd that a stock installation didn't create these things. It must have failed to create a bunch of other stuff as well. I'm concerned I might have to re-install or something. I've already got production domains.

I purchased a license of pro, but haven't heard back from Virtualmin with a license key, hopefully thier support will help.

Wed, 05/28/2008 - 03:28 (Reply to #4)
sgrayban

You can get your serial here --&gt; http://www.virtualmin.com/serial/

Sun, 06/07/2009 - 07:23
ronald
ronald's picture

This is what the file &quot;/usr/libexec/webmin/virtual-server/lookup-domain.pl&quot; says. I have centos 5 too:
[code:1]
#!/usr/bin/perl
# Returns the domain ID for some user, if the domain has spam enabled and
# if the user is not approaching his quota

$no_acl_check++;
@ARGV == 1 || die &quot;usage: lookup-domain.pl &lt;username&gt;&quot;;
use Socket;

# Get the message size
while($got = read(STDIN, $buf, 1024)) {
$size += $got;
}
$margin = $size*2+5*1024*1024;

# First, try connecting to the lookup-domain-daemon.pl process
socket(DAEMON, PF_INET, SOCK_STREAM, getprotobyname(&quot;tcp&quot;&Acirc;&laquo;&Acirc;&raquo;));
$rv = connect(DAEMON, pack_sockaddr_in(11000, inet_aton(&quot;127.0.0.1&quot;&Acirc;&laquo;&Acirc;&raquo;)));
if ($rv) {
select(DAEMON); $| = 1; select(STDOUT);
print DAEMON $ARGV[0],&quot;\n&quot;;
$fromdaemon = &lt;DAEMON&gt;;
$fromdaemon =~ s/\r|\n//g;
close(DAEMON);
}
if ($fromdaemon) {
# We have an answer from the server process
($did, $dname, $spam, $spamc, $quotaleft) = split(/\t/, $fromdaemon);
if (!$did || !$spam) {
# No such user, or user's domain doesn't have spam enabled -
# don't do spam check
}
elsif ($spamc || $quotaleft eq &quot;UNLIMITED&quot;&Acirc;&laquo;&Acirc;&raquo;) {
# Domain is using spamc, or user has no quota, or quota disabled
# Do spam check.
print $did,&quot;\n&quot;;
}
elsif ($quotaleft &lt; $margin) {
# Too close to quota - don't check
}
else {
# Do spam check
print $did,&quot;\n&quot;;
}
exit(0);
}

# Open the cache DBM
$cachefile = &quot;$ENV{'WEBMIN_VAR'}/lookup-domain-cache&quot;;
eval &quot;use SDBM_File&quot;;
dbmopen(%usercache, $cachefile, 0700);
eval &quot;\$usercache{'1111111111'} = 1&quot;;
if ($@) {
dbmclose(%usercache);
eval &quot;use NDBM_File&quot;;
dbmopen(%usercache, $cachefile, 0700);
}

# Check our cache first, in case we have just done this user
$now = time();
if (defined($usercache{$ARGV[0]})) {
($cachespam, $cachequota, $cacheuquota, $cachetime, $cacheclient) =
split(/ /, $usercache{$ARGV[0]});
$cacheclient ||= &quot;spamassassin&quot;;
if ($now - $cachetime &lt; 60*60) {
if (!$cachespam) {
# Domain doesn't have spam enabled, so don't do check
$cacheuquota += $size;
&amp;update_cache();
exit(0);
}
elsif ($cacheclient eq &quot;spamc&quot;&Acirc;&laquo;&Acirc;&raquo;) {
# Using spamc, so quotas don't matter
$cacheuquota += $size;
&amp;update_cache();
print $cachespam,&quot;\n&quot;;
exit(0);
}
elsif ($cachequota &amp;&amp; $cacheuquota+$margin &gt;= $cachequota) {
# User is over quota, so don't do spam check
$cacheuquota += $size;
$cacheuquota = $cachequota
if ($cacheuquota &gt; $cachequota);
&amp;update_cache();
exit(0);
}
else {
# User is under quota, so proceed
$cacheuquota += $size;
&amp;update_cache();
print $cachespam,&quot;\n&quot;;
exit(0);
}
}
}

# Lookup the user for real
do './virtual-server-lib.pl';
$d = &amp;get_user_domain($ARGV[0]);
if (!$d || !$d-&gt;{'spam'}) {
$cachespam = $cachequota = $cacheuquota = 0;
$cachetime = $now;
&amp;update_cache();
exit(0);
}

# See what kind of quotas are relevant
$qmode = &amp;mail_under_home() &amp;&amp; &amp;has_home_quotas() ? &quot;home&quot; :
&amp;has_mail_quotas() ? &quot;mail&quot; : undef;
if (!$qmode) {
# None .. so run spam checks
$cachespam = $d-&gt;{'id'};
$cachequota = $cacheuquota = 0;
$cachetime = $now;
&amp;update_cache();
print &quot;$d-&gt;{'id'}\n&quot;;
exit(0);
}

# Check if the domain is using spamc or spamassassin
$cacheclient = &amp;get_domain_spam_client($d);

# Check if the user is approaching his quota
@users = &amp;list_domain_users($d, 0, 1, 0, 1);
($user) = grep { $_-&gt;{'user'} eq $ARGV[0] ||
&amp;replace_atsign($_-&gt;{'user'}) eq $ARGV[0] } @users;
if (!$user) {
# Couldn't find him?! So do the spam check
$cachespam = $d-&gt;{'id'};
$cachequota = $cacheuquota = 0;
$cachetime = $now;
&amp;update_cache();
print &quot;$d-&gt;{'id'}\n&quot;;
exit(0);
}
if ($qmode eq &quot;home&quot;&Acirc;&laquo;&Acirc;&raquo;) {
($quota, $uquota) = ($user-&gt;{'quota'}, $user-&gt;{'uquota'});
}
else {
($quota, $uquota) = ($user-&gt;{'mquota'}, $user-&gt;{'umquota'});
}
$bsize = &amp;quota_bsize($qmode);
$quota *= $bsize;
$uquota *= $bsize;
if ($user-&gt;{'nospam'}) {
# Spam filtering disabled for this user
$cachespam = 0;
}
elsif ($cacheclient eq &quot;spamc&quot;&Acirc;&laquo;&Acirc;&raquo;) {
# Using spamc, so quotas don't matter since spam processing is run
# by a daemon
print &quot;$d-&gt;{'id'}\n&quot;;
}
elsif ($quota &amp;&amp; $uquota+$margin &gt;= $quota) {
# Over quota, or too close to it
}
else {
# Under quota ... do the spam check
print &quot;$d-&gt;{'id'}\n&quot;;
}
$cachespam = $d-&gt;{'id'};
$cachequota = $quota;
$cacheuquota = $uquota;
$cachetime = $now;
&amp;update_cache();

sub update_cache
{
$usercache{$ARGV[0]} = join(&quot; &quot;, $cachespam, $cachequota, $cacheuquota, $cachetime, $cacheclient);
dbmclose(%usercache);
}[/code:1]

Wed, 05/28/2008 - 10:33
Joe
Joe's picture

Hi Brian,

The lookup-domain.pl script only exists on the Pro version of Virtualmin, as it is used for per-domain spam and virus filtering. The GPL install doesn't create it at all, as it shouldn't even refer to that file from /etc/procmailrc. On a typical GPL install, /etc/procmailrc only contains :

DEFAULT=$HOME/Maildir/
ORGMAIL=$HOME/Maildir/

or if your email is in /var/mail, something like :

DEFAULT=/var/mail/$USER
ORGMAIL=/var/mail/$USER

Did you create /etc/procmailrc manually on your system?

--

Check out the forum guidelines!

Wed, 05/28/2008 - 11:32
bmorin

Thanks for the postings guys, I'm upgrading to pro now, I didn't realize that about the GPL version. I think my system was looking for the lookup-domain.pl even though I had the GPL version.

I'll post as soon as the pro version is finished installing.

Wed, 05/28/2008 - 12:58 (Reply to #8)
sgrayban

It shouldn't -- Jamie/Joe must have forgotten to remove that bit of code.

Sun, 06/07/2009 - 07:23
ronald
ronald's picture

This is what the file &quot;/usr/libexec/webmin/virtual-server/lookup-domain.pl&quot; says. I have centos 5 too:
[code:1]
#!/usr/bin/perl
# Returns the domain ID for some user, if the domain has spam enabled and
# if the user is not approaching his quota

$no_acl_check++;
@ARGV == 1 || die &quot;usage: lookup-domain.pl &lt;username&gt;&quot;;
use Socket;

# Get the message size
while($got = read(STDIN, $buf, 1024)) {
$size += $got;
}
$margin = $size*2+5*1024*1024;

# First, try connecting to the lookup-domain-daemon.pl process
socket(DAEMON, PF_INET, SOCK_STREAM, getprotobyname(&quot;tcp&quot;&Acirc;&laquo;&Acirc;&raquo;));
$rv = connect(DAEMON, pack_sockaddr_in(11000, inet_aton(&quot;127.0.0.1&quot;&Acirc;&laquo;&Acirc;&raquo;)));
if ($rv) {
select(DAEMON); $| = 1; select(STDOUT);
print DAEMON $ARGV[0],&quot;\n&quot;;
$fromdaemon = &lt;DAEMON&gt;;
$fromdaemon =~ s/\r|\n//g;
close(DAEMON);
}
if ($fromdaemon) {
# We have an answer from the server process
($did, $dname, $spam, $spamc, $quotaleft) = split(/\t/, $fromdaemon);
if (!$did || !$spam) {
# No such user, or user's domain doesn't have spam enabled -
# don't do spam check
}
elsif ($spamc || $quotaleft eq &quot;UNLIMITED&quot;&Acirc;&laquo;&Acirc;&raquo;) {
# Domain is using spamc, or user has no quota, or quota disabled
# Do spam check.
print $did,&quot;\n&quot;;
}
elsif ($quotaleft &lt; $margin) {
# Too close to quota - don't check
}
else {
# Do spam check
print $did,&quot;\n&quot;;
}
exit(0);
}

# Open the cache DBM
$cachefile = &quot;$ENV{'WEBMIN_VAR'}/lookup-domain-cache&quot;;
eval &quot;use SDBM_File&quot;;
dbmopen(%usercache, $cachefile, 0700);
eval &quot;\$usercache{'1111111111'} = 1&quot;;
if ($@) {
dbmclose(%usercache);
eval &quot;use NDBM_File&quot;;
dbmopen(%usercache, $cachefile, 0700);
}

# Check our cache first, in case we have just done this user
$now = time();
if (defined($usercache{$ARGV[0]})) {
($cachespam, $cachequota, $cacheuquota, $cachetime, $cacheclient) =
split(/ /, $usercache{$ARGV[0]});
$cacheclient ||= &quot;spamassassin&quot;;
if ($now - $cachetime &lt; 60*60) {
if (!$cachespam) {
# Domain doesn't have spam enabled, so don't do check
$cacheuquota += $size;
&amp;update_cache();
exit(0);
}
elsif ($cacheclient eq &quot;spamc&quot;&Acirc;&laquo;&Acirc;&raquo;) {
# Using spamc, so quotas don't matter
$cacheuquota += $size;
&amp;update_cache();
print $cachespam,&quot;\n&quot;;
exit(0);
}
elsif ($cachequota &amp;&amp; $cacheuquota+$margin &gt;= $cachequota) {
# User is over quota, so don't do spam check
$cacheuquota += $size;
$cacheuquota = $cachequota
if ($cacheuquota &gt; $cachequota);
&amp;update_cache();
exit(0);
}
else {
# User is under quota, so proceed
$cacheuquota += $size;
&amp;update_cache();
print $cachespam,&quot;\n&quot;;
exit(0);
}
}
}

# Lookup the user for real
do './virtual-server-lib.pl';
$d = &amp;get_user_domain($ARGV[0]);
if (!$d || !$d-&gt;{'spam'}) {
$cachespam = $cachequota = $cacheuquota = 0;
$cachetime = $now;
&amp;update_cache();
exit(0);
}

# See what kind of quotas are relevant
$qmode = &amp;mail_under_home() &amp;&amp; &amp;has_home_quotas() ? &quot;home&quot; :
&amp;has_mail_quotas() ? &quot;mail&quot; : undef;
if (!$qmode) {
# None .. so run spam checks
$cachespam = $d-&gt;{'id'};
$cachequota = $cacheuquota = 0;
$cachetime = $now;
&amp;update_cache();
print &quot;$d-&gt;{'id'}\n&quot;;
exit(0);
}

# Check if the domain is using spamc or spamassassin
$cacheclient = &amp;get_domain_spam_client($d);

# Check if the user is approaching his quota
@users = &amp;list_domain_users($d, 0, 1, 0, 1);
($user) = grep { $_-&gt;{'user'} eq $ARGV[0] ||
&amp;replace_atsign($_-&gt;{'user'}) eq $ARGV[0] } @users;
if (!$user) {
# Couldn't find him?! So do the spam check
$cachespam = $d-&gt;{'id'};
$cachequota = $cacheuquota = 0;
$cachetime = $now;
&amp;update_cache();
print &quot;$d-&gt;{'id'}\n&quot;;
exit(0);
}
if ($qmode eq &quot;home&quot;&Acirc;&laquo;&Acirc;&raquo;) {
($quota, $uquota) = ($user-&gt;{'quota'}, $user-&gt;{'uquota'});
}
else {
($quota, $uquota) = ($user-&gt;{'mquota'}, $user-&gt;{'umquota'});
}
$bsize = &amp;quota_bsize($qmode);
$quota *= $bsize;
$uquota *= $bsize;
if ($user-&gt;{'nospam'}) {
# Spam filtering disabled for this user
$cachespam = 0;
}
elsif ($cacheclient eq &quot;spamc&quot;&Acirc;&laquo;&Acirc;&raquo;) {
# Using spamc, so quotas don't matter since spam processing is run
# by a daemon
print &quot;$d-&gt;{'id'}\n&quot;;
}
elsif ($quota &amp;&amp; $uquota+$margin &gt;= $quota) {
# Over quota, or too close to it
}
else {
# Under quota ... do the spam check
print &quot;$d-&gt;{'id'}\n&quot;;
}
$cachespam = $d-&gt;{'id'};
$cachequota = $quota;
$cacheuquota = $uquota;
$cachetime = $now;
&amp;update_cache();

sub update_cache
{
$usercache{$ARGV[0]} = join(&quot; &quot;, $cachespam, $cachequota, $cacheuquota, $cachetime, $cacheclient);
dbmclose(%usercache);
}[/code:1]

Wed, 05/28/2008 - 13:47
bmorin

<b>JamieCameron wrote:</b>
<div class='quote'>The lookup-domain.pl script only exists on the Pro version of Virtualmin, as it is used for per-domain spam and virus filtering. The GPL install doesn't create it at all, as it shouldn't even refer to that file from /etc/procmailrc. On a typical GPL install, /etc/procmailrc only contains :
DEFAULT=$HOME/Maildir/
ORGMAIL=$HOME/Maildir/
or if your email is in /var/mail, something like :

DEFAULT=/var/mail/$USER
ORGMAIL=/var/mail/$USER
Did you create /etc/procmailrc manually on your system? </div>

I did not create the /etc/procmailrc file. It currently looks like this after I have installed PRO:
&gt; cat /etc/procmailrc
DROPPRIVS=yes
:0fw
| /usr/bin/spamc
:0
* ^X-Spam-Status: Yes
$HOME/spam
DEFAULT=$HOME/Maildir/
ORGMAIL=$HOME/Maildir/

After the pro install, I still do not have /etc/webmin/virtual-server/lookup-domain.pl, but the daemon is there and running, and it exists in /usr/libexec/webmin/virtual-server/lookup-domain.pl, not sure what that means.

Sun, 06/07/2009 - 07:23 (Reply to #11)
sgrayban

This is what yours should look like:

$ cat /etc/procmailrc
DROPPRIVS=yes
LOGFILE=/var/log/procmail.log
TRAP=/etc/webmin/virtual-server/procmail-logger.pl
:0wi
VIRTUALMIN=|/etc/webmin/virtual-server/lookup-domain.pl $LOGNAME
:0
* ?/usr/bin/test &quot;$VIRTUALMIN&quot; != &quot;&quot;
{
INCLUDERC=/etc/webmin/virtual-server/procmail/$VIRTUALMIN
}
ORGMAIL=/var/spool/mail/$LOGNAME
DEFAULT=/var/spool/mail/$LOGNAME
DROPPRIVS=yes

Sun, 06/07/2009 - 07:23 (Reply to #12)
sgrayban

This is what yours should look like:

$ cat /etc/procmailrc
DROPPRIVS=yes
LOGFILE=/var/log/procmail.log
TRAP=/etc/webmin/virtual-server/procmail-logger.pl
:0wi
VIRTUALMIN=|/etc/webmin/virtual-server/lookup-domain.pl $LOGNAME
:0
* ?/usr/bin/test &quot;$VIRTUALMIN&quot; != &quot;&quot;
{
INCLUDERC=/etc/webmin/virtual-server/procmail/$VIRTUALMIN
}
ORGMAIL=/var/spool/mail/$LOGNAME
DEFAULT=/var/spool/mail/$LOGNAME
DROPPRIVS=yes

Wed, 05/28/2008 - 19:22
Joe
Joe's picture

You can force re-generation of the /etc/procmailrc file with the commands :

rm /etc/procmailrc
cd /usr/libexec/webmin
WEBMIN_CONFIG=/etc/webmin WEBMIN_VAR=/var/webmin /usr/libexec/webmin/run-postinstalls.pl virtual-server

--

Check out the forum guidelines!

Fri, 05/30/2008 - 03:37
oic

Sorry to side track a bit...

I am using GPL version. my /etc/procmailrc look like:
DEFAULT=$HOME/Maildir/

However, the mail modules seems look for email at /var/spool/mail . How to configure it so that it look at ~/Maildir instead?

Many thanks!

OIC

Fri, 05/30/2008 - 05:29 (Reply to #15)
oic

sorry, i got the answer now! it is in the module config page, though the option name is not clear. thanks!

Topic locked