Running OS X and Windows on Mac Intel 

Just got an Macbook to test run OS X and Windows XP SP2. There is tip which may help other users to install Windows:

1. Boot into Mac OS X.
2. In BootCamp Assistant, remove the Windows partition.
3. Reboot per request.
4. In BootCamp Assistant, repartition for Windows.
5. Reboot into XP Installer.

Always try above if somethings go wrong
[ add comment ] permalink ( 3.1 / 69 )
AWSTATS setup on OS X Tiger Server 

Setup AWSTATS on OS X Tiger Server is plain easy. Check this link for step by step setup
http://www.afp548.com/article.php?story ... 3205258972

But there is one thing bite me - the Apache log format. Apache's default combined log format is like this:

LogFormat "%h %l %u %t \"%r\" %>s %b \"%{Referer}i\" \"%{User-Agent}i\"" combined

So I followed the AWSTATS setup instruction to use the combined format for my virtual domain, and watch the log format while browsing the virtual website, the first column of log line always shows the virtual domain server IP instead of visiting IP. Used the same combined log format on OS X Tiger client, no problem at all. After digging around, I found out that Tiger server use "%{PC-Remote-Addr}i" to replace "%h" as the visiting IP. The combined log format on Tiger Server should be like this:

LogFormat "%{PC-Remote-Addr}i %l %u %t \"%r\" %>s %b \"%{Referer}i\" \"%{User-Agent}i\"" combined

There is no documentation mentioned about this as I search around, Apparently, Tiger is trying to do good thing, but on the contrary bite us.

I did not run the awstats configure script to make changes to apache config file. just manually edit a httpd_awstats.conf and include it in httpd.conf. I also copied awstats.model.conf to awstats.virtualdomain.conf , changed the "LogFile", "SiteDomain", "HostAlias" parameter to match the virtual domain and run the update script:

/Library/WebServer/awstats/tools/awstats_updateall.pl -awstatsprog=/Library/WebServer/awstats/wwwroot/cgi-bin/awstats.pl now

To view the virtual domain awstats, the link should be like this:

http://myhost/awstats/awstats.pl?config=SiteDomain


[ add comment ] permalink ( 3 / 70 )
Use SpamAssassin Message.pm module to fetch email attachment 

Here is a little script I wrote to fetch email attachment. If user got spam and forward it as attachment to me, I could use this script to rip the attachment and feeds it to sa-learn, the bayes learning engine of SA.

#!/usr/bin/perl
use strict;
use warnings;

use Mail::SpamAssassin::Message;

my $fh;
open $fh, "<", shift or die "Could not open message file:$!";
my @message = <$fh>;

my $msg = Mail::SpamAssassin::Message->new(
{
'message' => \@message,
}
) || die "Message error?";

#my $msg = Mail::SpamAssassin::Message->new() || die "Message error?";

#foreach my $p ($msg->find_parts(qr/^(text|image|application)\b/i, 1)) {
foreach my $p ($msg->find_parts(qr/^message\b/i, 0)) {
eval {
no warnings ;
my $type = $p->{'type'};
my $attachname = $p->{'name'};
print "Content type is: $type\n";
print "write file name: $attachname\n";
open my $out, ">", "$attachname" || die "Can't write file $attachname:$!";
binmode $out;
print $out $p->decode();
};
# warn $@ if $@;
}
[ add comment ] permalink ( 3.1 / 81 )
Re-queueing quarantined spam 

I happen to know that one amavisd user misfiltered 10000 emails as spam, and want to release them. How that could be achieved. Here is the relevant discussion link:
http://marc.theaimsgroup.com/?l=amavis- ... 84&w=2

The following both solutions are that we get mail_id from the quarantined *.gz file itself, typical file like this : spam-*******.gz, the '*******' is the mail_id.

The config in amavisd.conf should be:

-------------
$policy_bank{'AM.PDP-SOCK'} = {
protocol => 'AM.PDP', # Amavis policy delegation protocol
auth_required_release => 0, # don't require secret_id for
amavisd-release
};

$interface_policy{'SOCK'} = 'AM.PDP-SOCK';
----------------------


Scenario 1:
If the mail log is in MySQL, and spam are quarantined as *.gz file, we just pipe the mail_id to amavisd-release

Use the on-liner perl:

perl -e 'opendir(my $dir, "/var/amavis/quarantine"); \
print "$_\n" for map { /spam-(.*?)\.gz/ } readdir($dir); ' |
amavisd-release -

Scenario 2:
If the mail log is not in MySQL and spam are quarantined in *.gz, amavisd-release needs the full quarantine file name, not just mail_id, so we use different one-liner perl

perl -e 'opendir(my $dir, "/var/amavis/quarantine");\
print "$_\n" for grep { /^spam/} readdir($dir); ' | amavisd-release -
[ add comment ] permalink ( 3 / 71 )
Amavisd-2.3.3 and SA's sa-update 

If system are running on Amavisd-new-2.3.3 and SA version older than 3.1.5. the rules updated by sa-update will not accessed by amavisd unless add one line code to Mail::SpamAssassin->new( LOCAL_STATE_DIR => '/var/lib',). The relevant discussion link:
http://www.mail-archive.com/amavis-user ... 05859.html

[ add comment ] permalink ( 3 / 81 )

Back Next