[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[cpx] Test for catchalls (before installing CPX)
- Subject: [cpx] Test for catchalls (before installing CPX)
- From: Steve Yates <steve@xxxxxxxxxxx>
- Date: Sun, 13 Feb 2005 13:55:36 -0600
I wrote a little script that will test all domains in local-host-names and the account hostname to ensure catchalls are present for all of them, and thought I would share it with the list for use before you install CPX. It's in PHP, which is probably going to drive the Perl folks nuts :) but it'll run fine as long as the server has PHP installed.
- Steve Yates
- ITS, Inc.
- C code. C code run. Run, code, run. Please?
~ Taglines by Taglinator - www.srtware.com ~
====begin====
#!/usr/local/bin/php
<?php
$vut = file('/etc/mail/virtusertable');
$lhn = file('/etc/mail/local-host-names');
// eliminate all non-catchall virtmaps
while (list($key, $val) = each($vut)) {
if (substr($val, 0, 1) == '@') {
$catchalls[] = $val;
}
}
$vmok = true;
foreach ($lhn as $d) {
if (rtrim($d) != 'localhost') {
$vmok = testvmap(rtrim("@$d")) && $vmok;
}
}
$vmok = testvmap('@'.getenv('HOST')) && $vmok;
if ($vmok) {
echo "No missing catchalls were detected.\n";
}
function testvmap($d) {
global $catchalls;
$found = false;
foreach ($catchalls as $virtmap) {
$found = (strpos($virtmap, $d) === 0);
if ($found) { break; }
}
if (!$found) {
echo "No catchall for $d\n";
}
return $found;
}
?>
====end====
======================================================================
This is <cpx@xxxxxxxxxxxxx> <http://www.groupmail.org/lists/cpx/>
Before posting a question, please search the archives (see above URL).
Home |
Main Index |
Thread Index