HOWTO: Install SpamAssassin 3.1 using Cygwin (updated)

Use this forum if you have installed hMailServer and want to ask a question related to a production release of hMailServer. Before posting, please read the troubleshooting guide. A large part of all reported issues are already described in detail here.

Was this HOW-TO helpful to you?

YES, I'm now happily killing SPAM with SpamAssassin.
14
56%
NO, It's confusing and doesn't work. I'm going back to ASSP!
11
44%
 
Total votes: 25

GlenC
Senior user
Senior user
Posts: 680
Joined: 2004-08-17 23:31
Location: Santiago, Chile

HOWTO: Install SpamAssassin 3.1 using Cygwin (updated)

Post by GlenC » 2005-11-26 21:02

This How-To will help you install Spamassassin 3.1.0 with a site-wide config using pretty much the default plug-ins in a Win32/Cygwin environement. It has been my experience that this is the most stable environment for running SA. I highly recommend using Cygwin's Perl package, running Activestate Perl adds a whole new set of complications to the mix and so I can't help you much if you choose to go that route. Special Note: A little Unix experience is extremely helpful if you are going to try this method. Extra Special Special Note Note: If your computer blows up while following this How-To.. bla bla bla ... I am not responsible.

My current setup:
  • Dell Inspiron 8200 - Mobile Intel 4-M(1.7GHz), 1GB Ram
    Windows XP Professional SP2
    hMailserver 4.2 build 174 (MySQL v.4.1.13-nt)
    Cygwin 1.5.18-1
PREREQUISITES
1. Install Cygwin (Install from http://www.cygwin.com)
2. Install these packages through the CYGWIN package installer: (Shown are the versions I used)
  • BASE
    ----ALL packages under this category
    INTERPRETERS
    -----Perl 5.8.7-4
    DEVEL
    -----GCC core 3.4.4-1
    -----Make 3.80-1
    -----GCC-MingW core 20050522-1
    -----Binutils 20050610-1
    NET
    -----Inetutils 1.3.2-30
    DATABASE
    -----libdb3.1 Sleepycat 3.1 Berkeley DB Devel
    -----libdb3.1 Sleepycat 3.1 Berkeley DB Runtime
    ADMIN
    -----cygrunsrv
3. Open a cygwin prompt (the installation should have created a shortcut for this, if not, open a DOS box and type "c:\cygwin\cygwin". You shouild now have a Unix like prompt.)
4. Type "cpan" then hit return. Then, at the cpan prompt, type the following lines followed by return: (Mostly it is pretty much automatic with little prompting. Note that some packages will ask to install additional packages.)
  • install DB_File
    install Time::HiRes
    install Net::DNS (Say NO to network tests!)
    install HTML::Parser
    install Digest::SHA1
    install MIME::Base64
    install Mail::SPF::Query (if using SPF plugin)
    install IP::Country::Fast (if using relaycountry plugin)
Finally, make sure the cygwin bin directory is in your path (i.e. c:\cygwin\bin)

INSTALLING SPAMASSASSIN
  • 1. Download SpamAssassin 3.1.0 from http://www.spamassassin.org (Note: You CAN install SpamAssassin using CPAN. Not tested by me though)
    2. Unzip the SpamAssassin source to your cygwin home directory (i.e. C:\cygwin\home\username )
    3. Open a Cygwin prompt and CD to the SpamAssassin source directory.
    4. Type the following commands:

Code: Select all

perl Makefile.PL
make
make install
CONFIGURING
My advice here is to make minimal changes until you have SpamAssassin/SpamD operating properly. Having said that here are the locations of the config files:
  • C:\cygwin\etc\mail\spamassassin\local.cf (for general configuration)
    C:\cygwin\home\username\.spamassassin\user_prefs (for per user configuration)
    C:\cygwin\etc\mail\spamassassin\init.pre (for loading of some plugins)
    C:\cygwin\etc\mail\spamassassin\v310.pre (for loading version 3.1 specific plugins)
At a minimum you should probably make the following changes to the local.cf config file. Locate or add the following lines, edit as required and save. Be sure to set the username directory properly in the path statements below.

Code: Select all

# General Parameters - see SA docs for explanation
report_contact		postmaster@yourdomain.com
dns_available		test

# Bayes
use_bayes		1

# Miscellaneous Entries 
auto_whitelist_path		/cygdrive/c/cygwin/home/username/.spamassassin/auto-whitelist
auto_whitelist_file_mode 0700
bayes_path		/cygdrive/c/cygwin/home/username/.spamassassin/bayes
bayes_file_mode 0700
That's it, SpamAssassin is installed and ready for testing.

TESTING
Run the following test from a cygwin prompt to determine spamassassin is operating properly. Examine the output closely and try to correct any errors before making any further modifications.

Code: Select all

spamassassin -D --lint
Now try running mail samples through. These sample files are found in the SpamAssassin source directory. Again, examine the output closely.

Code: Select all

spamassassin -tD < sample-nonspam.txt
spamassassin -tD < sample-spam.txt
INTEGRATING WITH HMAILSERVER (skip this if know you want to run SpamD instead, which is preferred)
  • 1. Open hMailserver Administrator and enable scripting. (Settings; Advanced; Scripts, check "Active")
    2. Click on the box labeled "Show Scripts" and then open the file "Eventhandlers.vbs" for editing.
    3. Remove the tick ' from in front of the section "Sub OnDeliverMessage(oMessage)"
    4. Replace or edit the section "Sub OnDeliverMessage(oMessage)" to add the following:

Code: Select all

Sub OnDeliverMessage(oMessage)
fname = oMessage.filename
Dim infile, testfile, sh
Dim fso
Set fso = createobject("Scripting.FileSystemObject")
If Not fso.fileexists(fname) then
	result.Value = 0
	Exit sub
End If

infile = fso.getabsolutepathname(fname)
testfile = infile & ".tmp"
fso.CopyFile infile, testfile
Set sh = CreateObject("WScript.Shell")

'CALL SPAMASSASSIN
Dim cmd, rc
cmd = "cmd /c perl -S -T -w spamassassin < """ & testfile & """ > """ & infile & """"
rc = sh.Run( cmd , 0 , TRUE)
result.Value = 0
fso.Deletefile testfile
Set fso = Nothing
End Sub
RUNNING WITH SPAMD
This is the way to go if you are looking for speed at the expense of memory. Instead of loading a new instance of SpamAssassin for each scan, 5 (configurable) instances are preloaded and are accessed as required. Instead of calling SpamAssassin directly we will use a client, SpamC, to communicate with the SpamD service. I prefer to run SpamD and SpamC with the -u option (username). This gives me a site-wide config with far less issues /permissions problems.
  • 1. Install the cygwin package cygrunsrv
    2. Install spamd as a service with the following command:

Code: Select all

cygrunsrv -I SpamD -p /usr/bin/spamd -a "-l -s /var/log/SpamD.log --round-robin"

EDIT: I removed -u username from the command. This is not really required and caused some problems for some users.
Note: This will install SpamD as a service, set the path to c:/cygwin/bin and, execute it with the following options:
  • -l This allows you to use spamc to learn a msg as ham, spam, or to forget what it previously learned.
    -s This sets the log path to C:/cygwin/var/log/spamd.log
    -u This sets the user that is running spamd (set username as required)
    --round-robin Use the old style spawn method
INTEGRATING SPAMD WITH HMAILSERVER
  • 1. Open hMailserver Administrator and enable scripting. (Settings; Advanced; Scripts, check "Active")
    2. Click on the box labeled "Show Scripts" and then open the file "Eventhandlers.vbs" for editing.
    3. Remove the tick ' from in front of the section "Sub OnDeliverMessage(oMessage)"
    4. Replace or edit the section "Sub OnDeliverMessage(oMessage)" to add the following:
    (note: change username to the username running SpamD)

Code: Select all

Sub OnDeliverMessage(oMessage)
fname = oMessage.filename
Dim infile, testfile, sh
Dim fso
Set fso = createobject("Scripting.FileSystemObject")
If Not fso.fileexists(fname) then
	result.Value = 0
	Exit sub
End If

infile = fso.getabsolutepathname(fname)
testfile = infile & ".tmp"
fso.CopyFile infile, testfile
Set sh = CreateObject("WScript.Shell")

'CALL SPAMASSASSIN
Dim cmd, rc
cmd = "cmd /c spamc -E -u username < """ & testfile & """ > """ & infile & """"
rc = sh.Run( cmd , 0 , TRUE)
result.Value = 0
fso.Deletefile testfile
Set fso = Nothing
End Sub
BAYES TRAINING
Before Bayes features kick in, SpamAssassin must be trained with at least 200 msgs each of Spam and Ham. Some experimentation may be required on your part in order to find the best way to do this, but to give you an idea, here is one way to do it:
  • 1. Create two directories, one for Ham and one for Spam
    2. Carefully sort and then place 200 minimum messages of each type into the directories.
    3. Run the following commands from a cygwin prompt: (modify as required)

Code: Select all

sa-learn --ham -u username --progress /cygdrive/c/path/to/ham/folder
sa-learn --spam -u username --progress /cygdrive/c/path/to/spam/folder
Note the paths!! cygwin is a little strange in this regard. If for example, I created the folder C:\Spam for my spam training, I would use the following sa-learn command:

Code: Select all

sa-learn --spam -u username --progress /cygdrive/c/Spam
You should see a progress bar progress across the screen as msgs are learned and tokens are created.
Afterwards, running the following command should give you a somewhat cryptic status of your Bayes database:

Code: Select all

sa-learn --dump magic
Now, if you examine the headers of messages you should see bayes scoring included.

ADDING OTHER SA FEATURES
I'm currently running with SpamD and the following plug-ins enabled with no problems. Note that some of these require installation of additional Perl modules in order to work:
  • Hashcash
    SPF
    URIDNSBL
    RelayCountry
    Antivirus (note: this is not an antivirus replacement)
    AWL
    Textcat
    AutolearnThreshold
    WhiteListSubject
    DomainKeys
    MIMEHeader
    ReplaceTags
Other Features worth looking into:
  • Per user Bayes settings utilzing MySQL DB (I haven't tried yet, not enough users)
    DCC
    Pyzor
    SpamCop reporting
    ClamAV integration
That's it... good luck, and please provide feedback here on your experience.
Last edited by GlenC on 2006-01-10 02:01, edited 3 times in total.

maverick
New user
New user
Posts: 23
Joined: 2005-12-08 21:44

Problems installing SpamAssassin

Post by maverick » 2005-12-08 21:47

While doing step 4, I get errors in cpan that says

Code: Select all

cpan> install Mail::SPF::Query
Warning: Cannot install Mail::SPF::Query, don't know what it is.
Try the command

    i /Mail::SPF::Query/

to find objects with matching identifiers.
This occurs for all of step 4

Any Ideas????

GlenC
Senior user
Senior user
Posts: 680
Joined: 2004-08-17 23:31
Location: Santiago, Chile

Post by GlenC » 2005-12-08 22:12

That is strange, what happens if you do the suggested i/Mail::SPF::Query?

Usually an error like that implies you mistyped the command, or didn't use proper upper/ lowercase. But from what you pasted that doesn't appear to be the case.

maverick
New user
New user
Posts: 23
Joined: 2005-12-08 21:44

Post by maverick » 2005-12-08 22:14

Code: Select all

cpan> i /Mail::SPF::Query/
No objects found of any type for argument /Mail::SPF::Query/

cpan>

maverick
New user
New user
Posts: 23
Joined: 2005-12-08 21:44

Post by maverick » 2005-12-08 22:18

I got it to work, XP sp2 was blocking my perl :lol:

GlenC
Senior user
Senior user
Posts: 680
Joined: 2004-08-17 23:31
Location: Santiago, Chile

Post by GlenC » 2005-12-08 22:20

ok... cool
let us know how the install goes.

Glenn
Normal user
Normal user
Posts: 65
Joined: 2004-12-04 20:57

Post by Glenn » 2005-12-23 16:02

Thanks for your how-to. I've installed it and it works till I want to integrate it with Hmailserver. I've tested it with and without to run SpamD, but when I enable scripting I get totally empty messages. What is going wrong?

I'm running on W2003 SP1 with HMS 4.1.1.B140. I've followed exactly your how-to and this is my EventHandlers (you have a mistake in your HOW-TO ;)):

Code: Select all

'   Sub OnClientConnect(oClient)
'   End Sub

'   Sub OnAcceptMessage(oClient, oMessage)
'   End Sub

Sub OnDeliverMessage(oMessage)
fname = oMessage.filename
Dim infile, testfile, sh
Dim fso
Set fso = createobject("Scripting.FileSystemObject")
If Not fso.fileexists(fname) then
   result.Value = 0
   Exit sub
End If

infile = fso.getabsolutepathname(fname)
testfile = infile & ".tmp"
fso.CopyFile infile, testfile
Set sh = CreateObject("WScript.Shell")

'CALL SPAMASSASSIN
Dim cmd, rc
cmd = "cmd /c perl -S -T -w spamassassin < """ & testfile & """ > """ & infile & """"
rc = sh.Run( cmd , 0 , TRUE)
result.Value = 0
fso.Deletefile testfile
Set fso = Nothing
End Sub
What is going wrong?

GlenC
Senior user
Senior user
Posts: 680
Joined: 2004-08-17 23:31
Location: Santiago, Chile

Post by GlenC » 2005-12-23 19:11

I do not see a problem with your script. But if you are getting empty messages it is likely that for some reason spamassassin is failing to run. Is perl in your path? Do you see any errors at all when you run "spamassassin -D --lint" from a cygwin prompt?

I don't run W2003 so I am unsure of the setup but could it be a permission thing?

For troubleshooting you can use this code snippit, place it after the "result.Value=0". It should prevent any message loss while you are testing.

Code: Select all

If fso.GetFile(infile).Size = 0 Then				'Failsafe: In the event an error causes a zero byte msg
	fso.CopyFile testfile, infile
	oMessage.HeaderValue("X-Spam-Failsafe) = "Spamassassin Failsafe"
   oMessage.Save()
End if
By the way, where is the mistake in the HOW-TO? I need to fix it but I don't see it.

Glenn
Normal user
Normal user
Posts: 65
Joined: 2004-12-04 20:57

Post by Glenn » 2005-12-24 14:01

GlenC wrote:I do not see a problem with your script. But if you are getting empty messages it is likely that for some reason spamassassin is failing to run. Is perl in your path? Do you see any errors at all when you run "spamassassin -D --lint" from a cygwin prompt?
This is in my Path:

Code: Select all

C:\Perl\bin\;%SystemRoot%\system32;%SystemRoot%;%SystemRoot%\System32\Wbem;
When I run spamassassin -D --lint sometimes I get module not installed ('require' failed), but I've installed al the modules you said in your how-to. I can't see no more errors. FYI: the samples spam.txt and non-spam.txt both work!

I don't run W2003 so I am unsure of the setup but could it be a permission thing?
No, I'm working and run it as the Administrator.
For troubleshooting you can use this code snippit, place it after the "result.Value=0". It should prevent any message loss while you are testing.

Code: Select all

If fso.GetFile(infile).Size = 0 Then				'Failsafe: In the event an error causes a zero byte msg
	fso.CopyFile testfile, infile
	oMessage.HeaderValue("X-Spam-Failsafe) = "Spamassassin Failsafe"
   oMessage.Save()
End if
Yes, now I don't get empty message but the full message. But, when I see the code, it should add the header "X-SPam-Failsafe = Spamassassin Failsafe" but the header isn't added when I look into the headers!
By the way, where is the mistake in the HOW-TO? I need to fix it but I don't see it.
In your how-to you said that we should edit "EventHandler.vbs" but according to the documentation of HMS it is "EventHandlers.vbs". A little mistake ;)

GlenC
Senior user
Senior user
Posts: 680
Joined: 2004-08-17 23:31
Location: Santiago, Chile

Post by GlenC » 2005-12-24 15:14

oK... maybe I see a problem. Are you running Activestate Perl in addition to Cygwin Perl? If so, you really might want to consider removing activestate and only using the Cygwin Perl. Although I did run both at one time, it really makes troubleshooting hard when you have a problem. At any rate, you should remove the reference to "C:\Perl\bin" and replace it with the path to the cygwin perl executable... on my machine that is "C:\cygwin\bin.

Your --lint tests are probably ok. It tests for a lot of things and modules that aren't installed will show the "require" line. On my machine I get 3 of these require failed lines, one for INET6, SSL and Razor2, all of which are options I chose not to install.

Not sure why the Message header is not added... it's probably just poor, unworkable scripting on my part, but the important thing is that it prevents the message from being lost.

I think the path issue will cure your problem though. Good luck!

Glenn
Normal user
Normal user
Posts: 65
Joined: 2004-12-04 20:57

Post by Glenn » 2005-12-24 16:32

I've changed the PATH, rebooted the server and it didn't work. I removed the "Failsafe" code and it WORKS now :D That's very nice!

So maybe you have to check your failsafe code. Thanks for your how-to!

Maybe you can change one thing. This are the headers now:

Code: Select all

X-Spam-Checker-Version: SpamAssassin 3.1.0 (2005-09-13) on JONATHAN
X-Spam-Level: 
X-Spam-Status: No, score=0.0 required=5.0 tests=UNPARSEABLE_RELAY 
	autolearn=failed version=3.1.0
Received: FROM [194.109.24.27] BY mail.crediblehosting.nl with hMailServer ; Sat, 24 Dec 2005 15:27:30 +0100
Received: from webmail.xs4all.nl (dovemail3.xs4all.nl [194.109.26.5])
	by smtp-vbr7.xs4all.nl (8.13.3/8.13.3) with ESMTP id jBOERP8Q081465
	for <removed>; Sat, 24 Dec 2005 15:27:25 +0100 (CET)
	(envelope-from removed)
Received: from 82.92.94.129
        (SquirrelMail authenticated user glennhoo)
        by webmail.xs4all.nl with HTTP;
        Sat, 24 Dec 2005 15:27:25 +0100 (CET)
Message-ID: <21734.82.92.94.129.1135434445.squirrel@webmail.xs4all.nl>
Date: Sat, 24 Dec 2005 15:27:25 +0100 (CET)
Subject: dasdasd
From: [removed]
To: [removed]
User-Agent: SquirrelMail/1.4.5
MIME-Version: 1.0
Content-Type: text/plain;charset=iso-8859-1
Content-Transfer-Encoding: 8bit
X-Virus-Scanned: by XS4ALL Virus Scanner
I think it's a 'better look' to have the added headers not at the head of the e-mail but at the bottom. Can you change this?

Edit: Weird, I just receive a spam message and the spam headers are at the end....

GlenC
Senior user
Senior user
Posts: 680
Joined: 2004-08-17 23:31
Location: Santiago, Chile

Post by GlenC » 2005-12-24 16:59

Hmm... that is strange about the failsafe code. :? But I'm glad it is working for you.

As for the headers... at one time they were placed at the end of the headers, but in order to maintain compatibility with Domainkeys, the SA developers moved them. From the changelog:

Code: Select all

- modify header ordering for DomainKeys compatibility, by placing markup
  headers at the top of the message instead at the bottom of the list.
Also, have you trained your Bayes? It appears your autolearn has a problem.

Code: Select all

failed: means that autolearning was attempted, but couldn't complete. This happens if SpamAssassin can't gain a lock on the Bayes database files, etc
Thanks for the feedback too!

Glenn
Normal user
Normal user
Posts: 65
Joined: 2004-12-04 20:57

Post by Glenn » 2005-12-24 17:05

GlenC wrote:Hmm... that is strange about the failsafe code. :? But I'm glad it is working for you.

As for the headers... at one time they were placed at the end of the headers, but in order to maintain compatibility with Domainkeys, the SA developers moved them. From the changelog:

Code: Select all

- modify header ordering for DomainKeys compatibility, by placing markup
  headers at the top of the message instead at the bottom of the list.
Ok.
Also, have you trained your Bayes? It appears your autolearn has a problem.

Code: Select all

failed: means that autolearning was attempted, but couldn't complete. This happens if SpamAssassin can't gain a lock on the Bayes database files, etc
No, I haven't done that yet. I'm now collecting the 200 msgs each of Spam and Ham so I can build the 'database'. I've bayes turned off right now so the message won't appear in the future.
Thanks for the feedback too!
YWC.

jhsieh64
New user
New user
Posts: 9
Joined: 2005-07-13 02:50

Errors in the log

Post by jhsieh64 » 2005-12-24 19:25

I followed the instructions as much as possible but I still run into problems.
Can someone enlighten me on what I did wrong?
the attached is the log file.

Code: Select all

[3464] error: locker: safe_lock: cannot create tmp lockfile /cygdrive/c/home/Jack/.spamassassin/auto-whitelist.lock.user.3464 for /cygdrive/c/home/Jack/.spamassassin/auto-whitelist.lock: No such file or directory
Sat Dec 24 11:51:37 2005 [3464] error: locker: safe_lock: cannot create tmp lockfile /cygdrive/c/home/Jack/.spamassassin/auto-whitelist.lock.user.3464 for /cygdrive/c/home/Jack/.spamassassin/auto-whitelist.lock: No such file or directory
[3464] warn: auto-whitelist: open of auto-whitelist file failed: locker: safe_lock: cannot create tmp lockfile /cygdrive/c/home/Jack/.spamassassin/auto-whitelist.lock.user.3464 for /cygdrive/c/home/Jack/.spamassassin/auto-whitelist.lock: No such file or directory
Sat Dec 24 11:51:37 2005 [3464] warn: auto-whitelist: open of auto-whitelist file failed: locker: safe_lock: cannot create tmp lockfile /cygdrive/c/home/Jack/.spamassassin/auto-whitelist.lock.user.3464 for /cygdrive/c/home/Jack/.spamassassin/auto-whitelist.lock: No such file or directory
[3464] error: Can't call method "finish" on an undefined value at /usr/lib/perl5/site_perl/5.8/Mail/SpamAssassin/Plugin/AWL.pm line 397.
Sat Dec 24 11:51:37 2005 [3464] error: Can't call method "finish" on an undefined value at /usr/lib/perl5/site_perl/5.8/Mail/SpamAssassin/Plugin/AWL.pm line 397.
[3464] info: spamd: server started on port 783/tcp (running version 3.1.0)
Sat Dec 24 11:51:38 2005 [3464] info: spamd: server started on port 783/tcp (running version 3.1.0)
[3464] info: spamd: server pid: 3464
Sat Dec 24 11:51:38 2005 [3464] info: spamd: server pid: 3464
[3464] info: spamd: server successfully spawned child process, pid 3496
C:\cygwin\bin\perl.exe (3496): *** could not load wsock32, Win32 error 126
ild process, pid 3496
[3464] info: spamd: server successfully spawned child process, pid 2860
Sat Dec 24 11:51:40 2005 [3464] info: spamd: server successfully spawned child process, pid 2860
[3464] info: spamd: handled cleanup of child pid 3496 due to SIGCHLD
C:\cygwin\bin\perl.exe (2860): *** could not load wsock32, Win32 error 126
496 due to SIGCHLD
[3464] info: spamd: server successfully spawned child process, pid 3440
Sat Dec 24 11:51:42 2005 [3464] info: spamd: server successfully spawned child process, pid 3440
[3464] info: spamd: handled cleanup of child pid 2860 due to SIGCHLD
C:\cygwin\bin\perl.exe (3440): *** could not load wsock32, Win32 error 126
860 due to SIGCHLD
[3464] info: spamd: handled cleanup of child pid 3440 due to SIGCHLD
Sat Dec 24 11:51:42 2005 [3464] info: spamd: handled cleanup of child pid 3440 due to SIGCHLD
[3464] info: spamd: server successfully spawned child process, pid 2984
C:\cygwin\bin\perl.exe (2984): *** could not load wsock32, Win32 error 126
ild process, pid 2984
[3464] info: spamd: server successfully spawned child process, pid 2368
Sat Dec 24 11:51:45 2005 [3464] info: spamd: server successfully spawned child process, pid 2368
[3464] info: spamd: handled cleanup of child pid 2984 due to SIGCHLD
C:\cygwin\bin\perl.exe (2368): *** could not load wsock32, Win32 error 126
984 due to SIGCHLD
[3464] info: spamd: handled cleanup of child pid 2368 due to SIGCHLD
Sat Dec 24 11:51:45 2005 [3464] info: spamd: handled cleanup of child pid 2368 due to SIGCHLD
[3464] info: spamd: server successfully spawned child process, pid 1080
C:\cygwin\bin\perl.exe (1080): *** could not load wsock32, Win32 error 126
ild process, pid 1080
[3464] info: spamd: server successfully spawned child process, pid 3372
Sat Dec 24 11:51:48 2005 [3464] info: spamd: server successfully spawned child process, pid 3372
[3464] info: spamd: handled cleanup of child pid 1080 due to SIGCHLD
C:\cygwin\bin\perl.exe (3372): *** could not load wsock32, Win32 error 126
080 due to SIGCHLD
[3464] info: spamd: handled cleanup of child pid 3372 due to SIGCHLD
Sat Dec 24 11:51:48 2005 [3464] info: spamd: handled cleanup of child pid 3372 due to SIGCHLD
[3464] info: spamd: server successfully spawned child process, pid 2248
C:\cygwin\bin\perl.exe (2248): *** could not load wsock32, Win32 error 126
ild process, pid 2248
[3464] info: spamd: server successfully spawned child process, pid 548
Sat Dec 24 11:51:51 2005 [3464] info: spamd: server successfully spawned child process, pid 548
[3464] info: spamd: handled cleanup of child pid 2248 due to SIGCHLD
C:\cygwin\bin\perl.exe (548): *** could not load wsock32, Win32 error 126
2248 due to SIGCHLD
[3464] info: spamd: server successfully spawned child process, pid 3876
Sat Dec 24 11:51:52 2005 [3464] info: spamd: server successfully spawned child process, pid 3876
[3464] info: spamd: handled cleanup of child pid 548 due to SIGCHLD
C:\cygwin\bin\perl.exe (3876): *** could not load wsock32, Win32 error 126
48 due to SIGCHLD
[3464] info: spamd: handled cleanup of child pid 3876 due to SIGCHLD
Sat Dec 24 11:51:52 2005 [3464] info: spamd: handled cleanup of child pid 3876 due to SIGCHLD
[3464] info: spamd: server successfully spawned child process, pid 3332
C:\cygwin\bin\perl.exe (3332): *** could not load wsock32, Win32 error 126
C:\cygwin\bin\perl.exe (3668): *** could not load wsock32, Win32 error 126
[3464] info: spamd: server successfully spawned child process, pid 3668
Sat Dec 24 11:51:54 2005 [3464] info: spamd: server successfully spawned child process, pid 3668
[3464] info: spamd: handled cleanup of child pid 3332 due to SIGCHLD
Sat Dec 24 11:51:54 2005 [3464] info: spamd: handled cleanup of child pid 3332 due to SIGCHLD
[3464] info: spamd: handled cleanup of child pid 3668 due to SIGCHLD
Sat Dec 24 11:51:54 2005 [3464] info: spamd: handled cleanup of child pid 3668 due to SIGCHLD
[3464] info: spamd: server successfully spawned child process, pid 3768
C:\cygwin\bin\perl.exe (3768): *** could not load wsock32, Win32 error 126
ild process, pid 3768
[3464] info: spamd: server successfully spawned child process, pid 2904
.
.
.
Thanks much!

GlenC
Senior user
Senior user
Posts: 680
Joined: 2004-08-17 23:31
Location: Santiago, Chile

Post by GlenC » 2005-12-24 20:35

Does the user "Jack" exist on your system? If so, did cygwin create that directory? (/cygdrive/c/home/Jack/.spamassassin)

Also ensure when you start Spamd and when you call SpamC that you use the "-u Jack" switch. You might have other issues too. Did your --lint test go ok when you ran that?

jhsieh64
New user
New user
Posts: 9
Joined: 2005-07-13 02:50

Post by jhsieh64 » 2005-12-24 22:10

GlenC wrote:Does the user "Jack" exist on your system? If so, did cygwin create that directory? (/cygdrive/c/home/Jack/.spamassassin)

Also ensure when you start Spamd and when you call SpamC that you use the "-u Jack" switch. You might have other issues too. Did your --lint test go ok when you ran that?
Jack exists in the system and being the only user (with administrative right).
I checked the config file again and change the lines so that it look like:
auto_whitelist_path /cygdrive/c/cygwin/home/Jack/.spamassassin/auto-whitelist
auto_whitelist_file_mode 0700
bayes_path /cygdrive/c/cygwin/home/Jack/.spamassassin/bayes
bayes_file_mode 0700
apparently I missed the "cygwin" part for the path.
Yes, I did use -u Jack switch and the --lint test went OK too.

this is the out put for "ls -al" under /cygdrive/c/cygwin/home/Jack/.spamassassin/

Code: Select all

total 4832
drwx------+ 2 Jack None       0 Dec 24 15:02 .
drwx------+ 6 Jack None       0 Dec 23 18:30 ..
-rw-------  1 Jack None   24576 Dec 23 18:37 auto-whitelist
-rw-------  1 Jack None    2406 Dec 23 18:37 bayes_journal
-rw-------  1 Jack None  655360 Dec 23 11:24 bayes_seen
-rw-------  1 Jack None 5455872 Dec 23 11:24 bayes_toks
-rw-r--r--  1 Jack None    1487 Dec 11 21:29 user_prefs
here is the log files after I made the path correction.

Code: Select all

[3840] warn: bayes: cannot open bayes databases /cygdrive/c/cygwin/home/Jack/.spamassassin/bayes_* R/O: tie failed: Permission denied
Sat Dec 24 14:31:58 2005 [3840] warn: bayes: cannot open bayes databases /cygdrive/c/cygwin/home/Jack/.spamassassin/bayes_* R/O: tie failed: Permission denied
[3840] error: locker: safe_lock: cannot create tmp lockfile /cygdrive/c/cygwin/home/Jack/.spamassassin/auto-whitelist.lock.user.3840 for /cygdrive/c/cygwin/home/Jack/.spamassassin/auto-whitelist.lock: Permission denied
Sat Dec 24 14:32:04 2005 [3840] error: locker: safe_lock: cannot create tmp lockfile /cygdrive/c/cygwin/home/Jack/.spamassassin/auto-whitelist.lock.user.3840 for /cygdrive/c/cygwin/home/Jack/.spamassassin/auto-whitelist.lock: Permission denied
[3840] warn: auto-whitelist: open of auto-whitelist file failed: locker: safe_lock: cannot create tmp lockfile /cygdrive/c/cygwin/home/Jack/.spamassassin/auto-whitelist.lock.user.3840 for /cygdrive/c/cygwin/home/Jack/.spamassassin/auto-whitelist.lock: Permission denied
Sat Dec 24 14:32:04 2005 [3840] warn: auto-whitelist: open of auto-whitelist file failed: locker: safe_lock: cannot create tmp lockfile /cygdrive/c/cygwin/home/Jack/.spamassassin/auto-whitelist.lock.user.3840 for /cygdrive/c/cygwin/home/Jack/.spamassassin/auto-whitelist.lock: Permission denied
[3840] error: Can't call method "finish" on an undefined value at /usr/lib/perl5/site_perl/5.8/Mail/SpamAssassin/Plugin/AWL.pm line 397.
Sat Dec 24 14:32:04 2005 [3840] error: Can't call method "finish" on an undefined value at /usr/lib/perl5/site_perl/5.8/Mail/SpamAssassin/Plugin/AWL.pm line 397.
[3840] info: spamd: server started on port 783/tcp (running version 3.1.0)
Sat Dec 24 14:32:05 2005 [3840] info: spamd: server started on port 783/tcp (running version 3.1.0)
[3840] info: spamd: server pid: 3840
Sat Dec 24 14:32:05 2005 [3840] info: spamd: server pid: 3840
[3840] info: spamd: server successfully spawned child process, pid 4084
C:\cygwin\bin\perl.exe (4084): *** could not load wsock32, Win32 error 126
ild process, pid 4084
[3840] info: spamd: server successfully spawned child process, pid 2248
Sat Dec 24 14:32:07 2005 [3840] info: spamd: server successfully spawned child process, pid 2248
[3840] info: spamd: handled cleanup of child pid 4084 due to SIGCHLD
C:\cygwin\bin\perl.exe (2248): *** could not load wsock32, Win32 error 126
084 due to SIGCHLD
[3840] info: spamd: handled cleanup of child pid 2248 due to SIGCHLD
Sat Dec 24 14:32:07 2005 [3840] info: spamd: handled cleanup of child pid 2248 due to SIGCHLD
[3840] info: spamd: server successfully spawned child process, pid 1080
C:\cygwin\bin\perl.exe (1080): *** could not load wsock32, Win32 error 126
ild process, pid 1080
Thanks for helping.

GlenC
Senior user
Senior user
Posts: 680
Joined: 2004-08-17 23:31
Location: Santiago, Chile

Post by GlenC » 2005-12-24 23:54

Open a cygwin prompt and change to the /home/Jack/.spamassassin directory then chmod 777 each file in the directory. (this is temporary for troubleshooting) For some reason your files are mode 0600. i.e.:

Code: Select all

chmod 777 bayes_toks
You have some other issues too but we'll try to tackle this one at a time.

jhsieh64
New user
New user
Posts: 9
Joined: 2005-07-13 02:50

Post by jhsieh64 » 2005-12-25 00:29

I ran the following in the .spamassassin directoy:

Code: Select all

chmod 777 *
and here is the "ls -al" out put:

Code: Select all

total 4832
drwx------+ 2 Jack None       0 Dec 24 15:02 .
drwx------+ 6 Jack None       0 Dec 23 18:30 ..
-rwxrwxrwx  1 Jack None   24576 Dec 23 18:37 auto-whitelist
-rwxrwxrwx  1 Jack None    2406 Dec 23 18:37 bayes_journal
-rwxrwxrwx  1 Jack None  655360 Dec 23 11:24 bayes_seen
-rwxrwxrwx  1 Jack None 5455872 Dec 23 11:24 bayes_toks
-rwxrwxrwx  1 Jack None    1487 Dec 11 21:29 user_prefs
And here is the updated log:

Code: Select all

[3644] error: locker: safe_lock: cannot create tmp lockfile /cygdrive/c/cygwin/home/Jack/.spamassassin/auto-whitelist.lock.user.3644 for /cygdrive/c/cygwin/home/Jack/.spamassassin/auto-whitelist.lock: Permission denied
Sat Dec 24 17:22:45 2005 [3644] error: locker: safe_lock: cannot create tmp lockfile /cygdrive/c/cygwin/home/Jack/.spamassassin/auto-whitelist.lock.user.3644 for /cygdrive/c/cygwin/home/Jack/.spamassassin/auto-whitelist.lock: Permission denied
[3644] warn: auto-whitelist: open of auto-whitelist file failed: locker: safe_lock: cannot create tmp lockfile /cygdrive/c/cygwin/home/Jack/.spamassassin/auto-whitelist.lock.user.3644 for /cygdrive/c/cygwin/home/Jack/.spamassassin/auto-whitelist.lock: Permission denied
Sat Dec 24 17:22:45 2005 [3644] warn: auto-whitelist: open of auto-whitelist file failed: locker: safe_lock: cannot create tmp lockfile /cygdrive/c/cygwin/home/Jack/.spamassassin/auto-whitelist.lock.user.3644 for /cygdrive/c/cygwin/home/Jack/.spamassassin/auto-whitelist.lock: Permission denied
[3644] error: Can't call method "finish" on an undefined value at /usr/lib/perl5/site_perl/5.8/Mail/SpamAssassin/Plugin/AWL.pm line 397.
Sat Dec 24 17:22:45 2005 [3644] error: Can't call method "finish" on an undefined value at /usr/lib/perl5/site_perl/5.8/Mail/SpamAssassin/Plugin/AWL.pm line 397.
[3644] info: spamd: server started on port 783/tcp (running version 3.1.0)
Sat Dec 24 17:22:46 2005 [3644] info: spamd: server started on port 783/tcp (running version 3.1.0)
[3644] info: spamd: server pid: 3644
Sat Dec 24 17:22:46 2005 [3644] info: spamd: server pid: 3644
[3644] info: spamd: server successfully spawned child process, pid 2968
C:\cygwin\bin\perl.exe (2968): *** could not load wsock32, Win32 error 126
ild process, pid 2968
[3644] info: spamd: server successfully spawned child process, pid 3396
Sat Dec 24 17:22:47 2005 [3644] info: spamd: server successfully spawned child process, pid 3396
[3644] info: spamd: handled cleanup of child pid 2968 due to SIGCHLD
C:\cygwin\bin\perl.exe (3396): *** could not load wsock32, Win32 error 126
968 due to SIGCHLD
[3644] info: spamd: handled cleanup of child pid 3396 due to SIGCHLD
Sat Dec 24 17:22:47 2005 [3644] info: spamd: handled cleanup of child pid 3396 due to SIGCHLD
[3644] info: spamd: server successfully spawned child process, pid 3540
C:\cygwin\bin\perl.exe (3540): *** could not load wsock32, Win32 error 126
ild process, pid 3540
[3644] info: spamd: server successfully spawned child process, pid 1368
Sat Dec 24 17:22:49 2005 [3644] info: spamd: server successfully spawned child process, pid 1368
[3644] info: spamd: handled cleanup of child pid 3540 due to SIGCHLD
C:\cygwin\bin\perl.exe (1368): *** could not load wsock32, Win32 error 126
540 due to SIGCHLD
[3644] info: spamd: server successfully spawned child process, pid 2828
Sat Dec 24 17:22:54 2005 [3644] info: spamd: server successfully spawned child process, pid 2828
[3644] info: spamd: handled cleanup of child pid 1368 due to SIGCHLD
C:\cygwin\bin\perl.exe (2828): *** could not load wsock32, Win32 error 126
368 due to SIGCHLD
[3644] info: spamd: handled cleanup of child pid 2828 due to SIGCHLD
Sat Dec 24 17:22:54 2005 [3644] info: spamd: handled cleanup of child pid 2828 due to SIGCHLD
[3644] info: spamd: server successfully spawned child process, pid 3412
C:\cygwin\bin\perl.exe (3412): *** could not load wsock32, Win32 error 126
ild process, pid 3412
.
.
.
Thanks again.

GlenC
Senior user
Senior user
Posts: 680
Joined: 2004-08-17 23:31
Location: Santiago, Chile

Post by GlenC » 2005-12-25 00:47

That apparently shows that the bayes problem is permissions.... We knocked off maybe two lines from the log :) Change back to your home directory and chmod the directory .spamassassin to 0777 (We'll need to change these back to something sensible later when we get it all working)

GlenC
Senior user
Senior user
Posts: 680
Joined: 2004-08-17 23:31
Location: Santiago, Chile

Post by GlenC » 2005-12-25 01:00

By the way, from what I have read so far while googling... Win32 error 126 means "dll not found" So, you might want to make sure wsock32.dll is in your path (C:\WINDOWS\system32 for me) Also check the permissions on it. Mine has "Users" as "Read and Read & Execute" Administrators and SYSTEM have "Full Control"

jhsieh64
New user
New user
Posts: 9
Joined: 2005-07-13 02:50

Post by jhsieh64 » 2005-12-25 19:08

Thanks for your help so far.
path "C:\WINDOWS\SYSTEM32" is in place. and I changed the permissons to "full control" for "user"

also I ran chmod 777 to the .spamassassin dictory.

here is the new log file:

Code: Select all

[3492] info: spamd: server started on port 783/tcp (running version 3.1.0)
Sun Dec 25 12:02:27 2005 [3492] info: spamd: server started on port 783/tcp (running version 3.1.0)
[3492] info: spamd: server pid: 3492
Sun Dec 25 12:02:27 2005 [3492] info: spamd: server pid: 3492
[3492] info: spamd: server successfully spawned child process, pid 3948
C:\cygwin\bin\perl.exe (3948): *** could not load wsock32, Win32 error 126
ild process, pid 3948
[3492] info: spamd: server successfully spawned child process, pid 2248
Sun Dec 25 12:02:27 2005 [3492] info: spamd: server successfully spawned child process, pid 2248
[3492] info: spamd: handled cleanup of child pid 3948 due to SIGCHLD
C:\cygwin\bin\perl.exe (2248): *** could not load wsock32, Win32 error 126
948 due to SIGCHLD
[3492] info: spamd: server successfully spawned child process, pid 3148
Sun Dec 25 12:02:28 2005 [3492] info: spamd: server successfully spawned child process, pid 3148
[3492] info: spamd: handled cleanup of child pid 2248 due to SIGCHLD
C:\cygwin\bin\perl.exe (3148): *** could not load wsock32, Win32 error 126
248 due to SIGCHLD
[3492] info: spamd: server successfully spawned child process, pid 548
C:\cygwin\bin\perl.exe (548): *** could not load wsock32, Win32 error 126
hild process, pid 548
[3492] info: spamd: handled cleanup of child pid 3148 due to SIGCHLD
Sun Dec 25 12:02:28 2005 [3492] info: spamd: handled cleanup of child pid 3148 due to SIGCHLD
[3492] info: spamd: handled cleanup of child pid 548 due to SIGCHLD
Sun Dec 25 12:02:28 2005 [3492] info: spamd: handled cleanup of child pid 548 due to SIGCHLD
[3492] info: spamd: server successfully spawned child process, pid 3156
C:\cygwin\bin\perl.exe (3156): *** could not load wsock32, Win32 error 126
ild process, pid 3156
.
.
.
seems like we have taken care of the .spamassassin permission problem, now we only have the wsock32 problem.
I will try to search for a solution on google. if I find anything useful I will post it here.
thanks.

jhsieh64
New user
New user
Posts: 9
Joined: 2005-07-13 02:50

Post by jhsieh64 » 2005-12-25 22:39

Problem solved!
need to "chmod 777 wsock32.dll"

Thank you GlenC !!

GlenC
Senior user
Senior user
Posts: 680
Joined: 2004-08-17 23:31
Location: Santiago, Chile

Post by GlenC » 2005-12-26 00:51

REALLY? Holy cow... I never would have thought one would have to do that! By the way, for the .spamassassin file modes, I think 0700 is the recommended permissions for those files.

Happy Holidays to ya.

webavant
Normal user
Normal user
Posts: 103
Joined: 2005-12-22 04:10
Contact:

Post by webavant » 2006-01-05 14:21

I'm pretty sure I followed your guide quite well. I've been getting this error showing up in SpamD.log and none of my spam emails subjects are being prepended with "***SPAM***" at all. I trained it on 300 ham and spam messages as well. This is the error in SpamD.log:
[848] info: spamd: handled cleanup of child pid 2456 due to SIGCHLD
[2540] error: spamd: setuid to uid 500 failed
Thu Jan 5 07:16:17 2006

GlenC
Senior user
Senior user
Posts: 680
Joined: 2004-08-17 23:31
Location: Santiago, Chile

Post by GlenC » 2006-01-05 14:48

Are you trying to run SpamD as the username "Administrator"?

webavant
Normal user
Normal user
Posts: 103
Joined: 2005-12-22 04:10
Contact:

Post by webavant » 2006-01-05 21:03

yes as administrator

GlenC
Senior user
Senior user
Posts: 680
Joined: 2004-08-17 23:31
Location: Santiago, Chile

Post by GlenC » 2006-01-05 21:35

That is something I didn't foresee when I wrote this tutorial. I know in Unix you cannot run SpamD as Root. I believe that is the same problem here. You will need to run it as another user I think. Either your normal user logon, or you can probably create another user specifically for SpamD. (If Administrator is your normal logon then keep in mind when troubleshooting that whatever you execute from the cygwin shell is going to behave differently than SpadD run as a another user... because of the permissions)

Please let me know if this fixes it so I can update the tutorial.

webavant
Normal user
Normal user
Posts: 103
Joined: 2005-12-22 04:10
Contact:

Post by webavant » 2006-01-06 18:48

So jhsieh64 was running as user, "jack". How do I create a new user under cygwin? Or do I have to change the SpamD service RunAs to another user instead of Local System account in the Windows Services Console?

GlenC
Senior user
Senior user
Posts: 680
Joined: 2004-08-17 23:31
Location: Santiago, Chile

Post by GlenC » 2006-01-06 19:17

This is going to be a little guesswork on my part because I'm not a cygwin "expert". But I believe you first have to create the user in Windows. I think an ordinary user would work but it may need to be a Power User. After that, you probably need to reboot. I would then try starting spamd (from a cygwin shell) using the -u username switch. I think at this point it will create the /home/username/.spamassassin directory and you can proceed with bayes training. Just remember that everything you do from the shell will need to use the -u username swtich, that includes sa-learn and testing with spamc.

If it doesn't create the directory, you may need to log in as that user and try these steps again.

When you start spamd you may want to use the -D switch so you can get more debug info while you are in the shell.

As for the spamd service, I am assuming you are running it with cygrunsrv... so you will need to reinstall the service using the -u username switch (or find the entry in your registry and edit it).

Hope this helps (works).

webavant
Normal user
Normal user
Posts: 103
Joined: 2005-12-22 04:10
Contact:

Post by webavant » 2006-01-07 07:18

Yes, in other words, go back through the sections of the tutorial involving usernames after creating the windows user. I thought of that as well, but haven't tried it yet. My first guess was to change the "log on as" properties in the Windows Services Console, but that didn't work. Thank you, very helpful... I'm going to try this after dinner and get back to you.

While I have your attention, do you know how to automate the creation of a new SpamD.log after it reaches, oh say 100kB offhand? I am assuming I'll have to research how to administer syslog, but maybe you know offhand. Thanks again.

webavant
Normal user
Normal user
Posts: 103
Joined: 2005-12-22 04:10
Contact:

Post by webavant » 2006-01-07 10:13

I don't know what to do... I keep getting the same "setuid to uid 500 failed" attempting to run as Administrator or another user with Admin priveleges. I tried editing the /etc/passwd file to change the UID to 544 but I don't know if that is even necessary or appropriate. I am not sure what to do at this point. I'm going to try to follow your how-to from the beginning again I suppose.

GlenC
Senior user
Senior user
Posts: 680
Joined: 2004-08-17 23:31
Location: Santiago, Chile

Post by GlenC » 2006-01-07 19:28

hmmm... well, this is uncharted territory for me here so I tried to duplicate what you would need to do. I created a user in windows "spamd". I then opened a cygwin prompt and did these two commands to update the passwd and group files:

Code: Select all

mkpasswd -l > /etc/passwd
mkgroup -l > /etc/group
I then logged into windows with the spamd user and opened a cygwin prompt... that created my home directory.

Logging back into windows again as GlenC I opened the /etc/passwd file and manually edited the GID for the user spamd to be 544 (administrators) vice 513 (none) I then attempted to start spamd from a cygwin prompt with -u spamd switch and I basically got the same result you had... cannot setuid to 1017 (which is the spamd user on my machine).

However, I went ahead and installed the service using cygrunsrv with the same switch -u spamd and from my logs it appears that it was working.

The only thing I can guess is that the local system account can start spamd and allow it to setuid whereas my attempt to do it from a cygwin shell doesn't work.

I hope this takes you a little further along.

username makes much difference. (it definitely makes a difference with the other tools, spamc and sa-learn).

GlenC
Senior user
Senior user
Posts: 680
Joined: 2004-08-17 23:31
Location: Santiago, Chile

Post by GlenC » 2006-01-08 00:28

Try starting SpamD without the -u username option. If it works that way then you can modify uninstall and reinstall the service without it. I just tested and it doesn't appear that running spamd without the username has any strange effects. (although it definitely makes a difference with the other tools, spamc and sa-learn).

webavant
Normal user
Normal user
Posts: 103
Joined: 2005-12-22 04:10
Contact:

Post by webavant » 2006-01-10 09:19

Thanks, GlenC, I did as you suggested. I tried restarting all of the services and everything short of rebooting. Now no SpamD.log file is created at all. Something must be wrong. My entry for the user in /etc/passwd file looks like this:
SpamD:unused_by_nt/2000/xp:1017:544:SpamD,U-U15197382\SpamD,S-1-5-21-817659700-1669421612-1443601059-1017:/home/SpamD:/bin/bash
In case that means anything to you. I know I am thoroughly confused.

webavant
Normal user
Normal user
Posts: 103
Joined: 2005-12-22 04:10
Contact:

Post by webavant » 2006-01-10 09:27

To add to that, I'm receiving blank emails, even though everything looks ok in the hMailServer logs, it is writing blank messages to the drive.

GlenC
Senior user
Senior user
Posts: 680
Joined: 2004-08-17 23:31
Location: Santiago, Chile

Post by GlenC » 2006-01-10 15:29

ok... just to make sure we are both on the same page... here is where I think you are, correct me if I am wrong.
  • 1. You have a user "SpamD" in the "Administrators Group"
    2. Your registry entry for starting spamd ("AppArgs" located on my machine at HKLM\SYSTEM\ControlSet001\Services\SpamD\Parameters) is

    Code: Select all

    -l -s /var/log/SpamD.log --round-robin
    3. The SpamD service is started.
    4. You are using -exactly- this script for eventhandlers:

    Code: Select all

    Sub OnDeliverMessage(oMessage)
    fname = oMessage.filename
    Dim infile, testfile, sh
    Dim fso
    Set fso = createobject("Scripting.FileSystemObject")
    If Not fso.fileexists(fname) then
       result.Value = 0
       Exit sub
    End If
    
    infile = fso.getabsolutepathname(fname)
    testfile = infile & ".tmp"
    fso.CopyFile infile, testfile
    Set sh = CreateObject("WScript.Shell")
    
    'CALL SPAMASSASSIN
    Dim cmd, rc
    cmd = "cmd /c spamc -E -u SpamD < """ & testfile & """ > """ & infile & """"
    rc = sh.Run( cmd , 0 , TRUE)
    result.Value = 0
    fso.Deletefile testfile
    Set fso = Nothing
    End Sub
I'm thinking it should be working at this point. Oh, one other thing. Is 1017 the UID that cygwin assigned for the SpamD user or did you change it to that? If you changed it, I'm not sure what kind of result that might have. Changing the groupt id to 544 is okay, but if you changed 1017 you might want to revert it to what it was before.

If this doesn't work, I can message you an email address and maybe it will be a little easier to troubleshoot in that way.

webavant
Normal user
Normal user
Posts: 103
Joined: 2005-12-22 04:10
Contact:

Post by webavant » 2006-01-11 04:54

Actually, in the registry, I had:
-l -s /var/log/SpamD.log -u SpamD --round-robin
And in the eventhandlers script:
cmd = "cmd /c spamc -E < """ & testfile & """ > """ & infile & """"
So I fixed them as you specified and stopped/restarted SpamD and hMail services. I am still getting blank emails, however the SpamD.log is now being created and the SUID error is no longer there.

Here is what is in SpamD.log:
[908] info: spamd: server started on port 783/tcp (running version 3.1.0)
Tue Jan 10 21:10:45 2006 [908] info: spamd: server started on port 783/tcp (running version 3.1.0)
[908] info: spamd: server pid: 908
Tue Jan 10 21:10:45 2006 [908] info: spamd: server pid: 908
[908] info: spamd: server successfully spawned child process, pid 188
Tue Jan 10 21:10:45 2006 [908] info: spamd: server successfully spawned child process, pid 188
The last couple of lines repeat a few times.

webavant
Normal user
Normal user
Posts: 103
Joined: 2005-12-22 04:10
Contact:

Post by webavant » 2006-01-11 06:07

OMG: I cannot believe this was the problem: When I enter "spamc" at the command line it says "not recognized" even though I have had c:\cygwin\bin in my PATH environmental variable the entire time. When I execute spamc directly from c:\cygwin\bin it works! I don't know why this would be, but I replaced "spamc" in the EventHandlers.vbs with "c:\\cygwin\\bin\\spamc" and it works. I am not sure if I was getting blank emails from the beginning since I was focusing on the SID issue in SpamD.log, but the errors are gone in SpamD.log and is now displaying lines like this:
[2304] info: spamd: clean message (-1.0/5.0) for SpamD:18 in 0.2 seconds, 1461 bytes.
which is a good sign. So now I'll start training. Do you have any links to good tutorials for user-level training/config?

webavant
Normal user
Normal user
Posts: 103
Joined: 2005-12-22 04:10
Contact:

Post by webavant » 2006-01-11 06:11

OK I made the most obvious mistake... in PATH I had the driver letter lower-case, which is a no-no. Someone please tell me to RTFM.

GlenC
Senior user
Senior user
Posts: 680
Joined: 2004-08-17 23:31
Location: Santiago, Chile

Post by GlenC » 2006-01-11 14:35

That is really good news! I had no idea that Windows saw a difference between a lower and upper case C in the path statement. (I have mixed upper and lower in my environment.) :roll:

By user-level training, do you mean a way for users to submit mis-identified spam and ham for training? One easy way is to have a shared set of ham and spam folders that users can drop messages into, and then have a bat file that executes sa-learn every night. There is another method though... in SA 3.1 you can send the mis-identified mail as an attachment and use spamc to send to to SA for training. If you are interested in that method, I'll cook up another HOW-TO (I don't really want to put it here because it might confuse someone trying to get the basic SA working)

webavant
Normal user
Normal user
Posts: 103
Joined: 2005-12-22 04:10
Contact:

Post by webavant » 2006-01-12 05:35

I am not at all familiar yet with the user-level separation in SA vs. out-of-the-box (default) configuration. I'll just tell you what I am hoping and perhaps you can suggest a few concepts for me to research and look into. I want to implement one of the webmail interfaces like Squirrel Mail, Horde, RoundCube or anything else you might be able to suggest. What I am hoping to accomplish is to have a webmail that supports all of the best features including but not limited to: transfer emails between folders, mark email as spam/ham for SA to process and SA user-level configuration (adjust scoring, etc...). Ideally it would be nice to have hMailServer's web admin features all tied in as well, but I am looking for a tried-an-true, popular solution and I don't believe that it's been done before. Have you any ideas?

Thanks again for all of your help, by the way.

GlenC
Senior user
Senior user
Posts: 680
Joined: 2004-08-17 23:31
Location: Santiago, Chile

Post by GlenC » 2006-01-12 15:56

webavant wrote:Have you any ideas?
I don't think you are going to find it all in one package. The thing about SA is that it is geeky... meaning you can do quite a few things with it but it takes some scrounging around and some work to get things working exactly like you want it. Personally I like that about it... I don't mind spending some time playing with it. For someone running a production server this might not be acceptable though. Anyway....
It sounds like you probably want users to be able to make their own configs, and possibly have their own bayes dbs. I would recommend setting up SA so that it uses MySQL database. There are instructions for setting up the database, along with required schema, in the SA source /sql directory. There are some tools for configuration that can be used here (including some plugins for SM http://wiki.apache.org/spamassassin/WebUserInterfaces I also posted some code in the other thread about how to parse the recipients list so you can scan mail using each users preferences here: http://www.hmailserver.com/forum/viewto ... &start=135
I am not running mine in this way, so I'll be of limited help if you get stuck. But I'm sure someone else will chime in if you need help.
webavant wrote:Thanks again for all of your help, by the way.
Anytime! :)

jabaah
New user
New user
Posts: 3
Joined: 2006-02-08 13:52

Post by jabaah » 2006-02-08 13:57

Is it possible to learn spam from specific imap-folders?
I have in every mailbox a "spam-folder" and the users could move not detected spam-mails to this personal INBOX/spam folder. I would run a scheduled task which learned from these "spam"-folders. Have anyone a idea?

GlenC
Senior user
Senior user
Posts: 680
Joined: 2004-08-17 23:31
Location: Santiago, Chile

Post by GlenC » 2006-02-10 04:16

I don't see any way of doing this. It's just one folder in IMAP but it's thousands of folders in the data directory. If you want to do something similar you should set up a network share to drag messages into. Or, if you are using ver 3.1 and spamd, you can use the "tell" feature of spamd. Then you can have users email their mis-marked mail as attachments to a specific HAM or SPAM address and train it that way. I have a script that works pretty well for this if you want to do it this way.

jabaah
New user
New user
Posts: 3
Joined: 2006-02-08 13:52

Post by jabaah » 2006-02-16 17:52

I work on a vb-script for learning spam-mails from user spam-folders.
I think it could work, because i extract the file-path from the database.
My problem is that the file-path looks like

C:\path-to-hmail-datafolder\E5\{5E9E5F85-D837-46F3-9C5F-8E66802C7F6C}.eml

The sa-learn-script ignores the "{" and "}" from the filename and return an error like

No such file or directory

Does anyone know how to make sa-learn take the full filename??

Many many thanks

crawdad
New user
New user
Posts: 29
Joined: 2005-07-27 10:01

Post by crawdad » 2006-02-18 15:40

In PREREQUISITES / install DB_File

When I type "install DB_File" It says it can not be found. The rest of the installs worked. Any ideas?

crawdad
New user
New user
Posts: 29
Joined: 2005-07-27 10:01

Post by crawdad » 2006-02-18 15:40

In PREREQUISITES...install DB_File

When I type "install DB_File" It says it can not be found. The rest of the installs worked. Any ideas?


In INSTALLING SPAMASSASSIN

perl Makefile.PL
make
make install

perl Makefile.PL - went through a cycle and worked
make and make install did nothing.
ie
C:\cygwin\home\user\spamassassin>make
'make' is not recognized as an internal or external command,
operable program or batch file
.

GlenC
Senior user
Senior user
Posts: 680
Joined: 2004-08-17 23:31
Location: Santiago, Chile

Post by GlenC » 2006-02-18 16:22

Doesn't seem right that DB_File is not found. I just checked and it is a valid package. Are you sure you were in cpan when you typed that command?

make is one of the prereq packages. It should have installed into c:\cygwin\bin, and that directory should be in your path.

crawdad
New user
New user
Posts: 29
Joined: 2005-07-27 10:01

Post by crawdad » 2006-02-18 16:36

Doesn't seem right that DB_File is not found. I just checked and it is a valid package. Are you sure you were in cpan when you typed that command?
I get this..

Code: Select all

cpan> install DB_file
Warning: Cannot install DB_file, don't know what it is.
Try the command

    i /DB_file/

to find objects with matching identifiers.

GlenC
Senior user
Senior user
Posts: 680
Joined: 2004-08-17 23:31
Location: Santiago, Chile

Post by GlenC » 2006-02-18 16:56

DB_ F ile

it's case sensistive

webavant
Normal user
Normal user
Posts: 103
Joined: 2005-12-22 04:10
Contact:

Post by webavant » 2006-02-18 20:25

jabaah you might have to 'cancel' the curly-brace characters '{' and '}' as I'm not sure how Perl interprets the curly-brace characters inside a string. Check some Perl forums/resources. Post a how-to and some examples when you get it working! :D

crawdad
New user
New user
Posts: 29
Joined: 2005-07-27 10:01

Post by crawdad » 2006-02-18 23:51

I already have perl installed in a different directory. I think that it is messing up this process. Does this look correct?

Code: Select all

user@server ~/spamassassin
$ spamassassin -tD > sample-nonspam.txt
[2704] dbg: logger: adding facilities: all
[2704] dbg: logger: logging level is DBG
[2704] dbg: generic: SpamAssassin version 3.1.0
[2704] dbg: config: score set 0 chosen.
[2704] dbg: util: running in taint mode? yes
[2704] dbg: util: taint mode: deleting unsafe environment variables, resetting PATH
[2704] dbg: util: PATH included '/usr/local/bin', keeping
[2704] dbg: util: PATH included '/usr/bin', keeping
[2704] dbg: util: PATH included '/bin', keeping
[2704] dbg: util: PATH included '/usr/X11R6/bin', keeping
[2704] dbg: util: PATH included '/cygdrive/c/NetServer/bin/stable/perl/bin', kee
ping
[2704] dbg: util: PATH included '/cygdrive/c/Perl/bin', which doesn't exist, dro
pping
[2704] dbg: util: PATH included '/cygdrive/c/WINDOWS/system32', keeping
[2704] dbg: util: PATH included '/cygdrive/c/WINDOWS', keeping
[2704] dbg: util: PATH included '/cygdrive/c/WINDOWS/System32/Wbem', keeping
[2704] dbg: util: final PATH set to: /usr/local/bin:/usr/bin:/bin:/usr/X11R6/bin
:/cygdrive/c/NetServer/bin/stable/perl/bin:/cygdrive/c/WINDOWS/system32:/cygdriv
e/c/WINDOWS:/cygdrive/c/WINDOWS/System32/Wbem
[2704] dbg: dns: is Net::DNS::Resolver available? yes
[2704] dbg: dns: Net::DNS version: 0.55
[2704] dbg: dns: name server: ip.goes.here.0, family: 2, ipv6: 0
This is after I enter:

Code: Select all

user@server ~/spamassassin
$ spamassassin -tD > sample-nonspam.txt
Somethings wrong cause Cygwin prompt just hangs there.

Does Cygwin have to be installed at root?

GlenC
Senior user
Senior user
Posts: 680
Joined: 2004-08-17 23:31
Location: Santiago, Chile

Post by GlenC » 2006-02-19 14:13

I honestly can't say for sure, but I do believe it is recommended to leave it at the root position. That said, I really don't see any problems with your output above.

jabaah
New user
New user
Posts: 3
Joined: 2006-02-08 13:52

Post by jabaah » 2006-02-20 18:52

It works!!!!

Everyone who wants to learn and delete spam-mails from user-folder could use/test this script:

Code: Select all

'v1.0*************************************************************************************
' File:   spam_learn_and_delete.vbs
'
' Description:
' This script find mails from a spamfolder within a account learned and deletes the mails
' if they are older than a specific daytime
'
' Variables
' DAYS_TO_KEEP: All Mails older then X Days will be deleted
' SCAN_FOLDER: Specified IMAP-Folder eg: INBOX/xxxx
' CONN_STRING: Information for MySQL ODBC Connection (build-in sql Port=3307)
' NewFilePath: Windows path to spamfolder for rename and learn
' NewFilePath1: Cygwin path for sa-learn
'*****************************************************************************************

'------> Variables <-----------------------------------------------------------------------
Set MyShell = CreateObject("WScript.Shell")
Set MyFiles = CreateObject("Scripting.FileSystemObject")

Const DAYS_TO_KEEP = "3"
Const SCAN_FOLDER = "Spam"
Const CONN_STRING = "DRIVER={MySQL ODBC 3.51 Driver};SERVER=localhost;PORT=3306;DATABASE=hmailserver;UID=root;PWD=Password;"

Dim hMail, hDomain, hAccount, sql, conn, rst, DomainID, AccountID, MsgID, TempID
Dim filesys, MsgPath, cmd, objFSO
Dim NewFile, NewFile1, NewFilePath, NewFileName, NewFileName1, NewFileExt, NewFileTemp

NewFilePath = "c:\Programme\hMailServer\Data\spam\"
NewFilePath1 = "/cygdrive/C/Programme/hMailServer/Data/spam/"

'------> Start Mainprogram <---------------------------------------------------------------
DomainID = -1
AccountID = -1

Set hMail = CreateObject("hMailServer.Application")
Set conn = CreateObject("ADODB.Connection")
Set rst = CreateObject("ADODB.Recordset")
Set filesys = CreateObject("Scripting.FileSystemObject")
Set objFSO = CreateObject("Scripting.FileSystemObject")

conn.ConnectionString = CONN_STRING
conn.Open
sql = "select hm_messages.messageid, "_
    & "hm_messages.messageaccountid, hm_messages.messagefilename, hm_accounts.accountdomainid " _
    & "from hm_messages inner join "_
    & "hm_imapfolders on (hm_messages.messagefolderid=" _
    & "hm_imapfolders.folderid) " _
    & "inner join hm_accounts on (hm_messages.messageaccountid=hm_accounts.accountid) " _
    & "where hm_imapfolders.foldername='" & SCAN_FOLDER & "' and hm_messages.messagecreatetime " _
    & "<= ADDDATE(CURDATE(), INTERVAL -" & DAYS_TO_KEEP & " DAY) " _
    & "ORDER BY hm_accounts.accountdomainid, hm_messages.messageaccountid"

rst.Open sql, conn

Do Until rst.EOF
'------> copy/rename spam-mails to a fix place <-------------------------------------------
    MsgPath = rst.Fields("messagefilename").Value
    Set objFSO = CreateObject("Scripting.FileSystemObject")
    NewFileTemp = Lcase(right(MsgPath,42))
    NewFileName1 = Lcase(left(NewFileTemp,37))
    NewFileName = Lcase(right(NewFileName1,36))
    NewFileExt = Lcase(right(NewFileTemp,4))

    Set objFSO = CreateObject("Scripting.FileSystemObject")
    NewFile = NewFilePath & NewFileName & NewFileExt
    objFSO.CopyFile MsgPath , NewFile , OverWriteFiles

'------> learn and delete the copied mails <-----------------------------------------------
    NewFile1 = NewFilePath1 & NewFileName & NewFileExt
    cmd = "%comspec% /c C:\cygwin\bin\bash -c '/bin/sa-learn --spam -u administrator --progress " & NewFile1 & "' >> C:\cygwin\var\log\spam-lernen.log"
    Return = MyShell.Run(cmd,0,True)
    objFSO.DeleteFile NewFile

'------> find and delete mails from database and filesystem <------------------------------
    TempID = rst.Fields("accountdomainid").Value
    If TempID <> DomainID Then
        Set hDomain = hMail.Domains.ItemByDBID(TempID)
    End If

    TempID = rst.Fields("messageaccountid").Value
    If TempID <> AccountID Then
        Set hAccount = hDomain.Accounts.ItemByDBID(TempID)
    End If

    MsgID = rst.Fields("messageid").Value
    hAccount.Messages.DeleteByDBID MsgID

    rst.MoveNext
Loop

rst.Close
conn.Close
Set rst = Nothing
Set conn = Nothing 
Set hMailMessages = Nothing
The Script based on the "delete"-Script from philip and i modified it for learning and deleting spam-mails, it doesn't work very fast, but it works...
I'm not perfect in VB-Script, maybe someone have a better idea for this solutions he/she let me know this...

jabaah

martinorth
New user
New user
Posts: 6
Joined: 2006-04-10 12:04

How can I export the messages of an imap folder to a dir?

Post by martinorth » 2006-04-10 12:12

Hello,

I have allready installed cygwin with sa. Now I have to run the sa-learn comand to train the spam filter. I also use squirellmail to read my mail.
I collected 1.500 spam mails and moved them to the junk-e-mail imap folder and my inbox only contains nice ham.

To run the sa-learn comand I need the spam and ham messages in different directories. Does anybody know a way to export the two folders?

Thanks

Martin Orth

maverick
New user
New user
Posts: 23
Joined: 2005-12-08 21:44

back to spam

Post by maverick » 2006-04-26 23:05

I have sa installed, but have never trained it. I am really stuggling for some reason with this. You said to point sa-learn to a dir, but are there txt files or eml files or what in the dir. also, will it read sub dir so that I can have all my users forward their spam to an account and have it re learn once in a while??

GlenC
Senior user
Senior user
Posts: 680
Joined: 2004-08-17 23:31
Location: Santiago, Chile

Post by GlenC » 2006-04-27 20:12

What I originally did was this: I use thunderbird, so I created two folders within tbird and copied a few hundred spam to one folder and a few hundred ham to another. Thunderbirds directory structure presents these as two separate directories in your profile. I then ran sa-learn on those directories (I think using the -mbox option).

You can also drag .eml files into two separate folders and run it in that way too.

Nowadays I do it a different way, I enabled the "tell" option for spamd and I have two accounts set up in hmail, one for spam and one for ham. My Eventhandler script detects mails to those accounts and runs a special spamc command for those accounts. You can attach several (maybe hundreds, I´ve never tested extensively) of spam or ham emails to one email and train in that way. This has the advantage of allowing users to report (and correct the bayes db) false positives and negatives.

I´ll post the script if anyone is interested in this.

webavant
Normal user
Normal user
Posts: 103
Joined: 2005-12-22 04:10
Contact:

Post by webavant » 2006-06-29 10:24

GlenC: Remember me? I have been using your script for a few months now and every once in a while there is some sort of buffer overflow or something that causes the SpamD.log to grow to 1GB or so within a few hours, also there will be an EML file in the data directory for hMail that grows at a similar rate.

Otherwise, good stuff man! Thanks.

GlenC
Senior user
Senior user
Posts: 680
Joined: 2004-08-17 23:31
Location: Santiago, Chile

Post by GlenC » 2006-06-29 15:29

Strange, I wonder if this is a cygwin issue? I have a similar problem only mine occurs with the freshclam log. Filled my hard drive and shut me down cold about a month ago. Anyway, glad the script works for you, it's a near nightmare install but worth it in the end I think. :)

webavant
Normal user
Normal user
Posts: 103
Joined: 2005-12-22 04:10
Contact:

Post by webavant » 2006-06-29 19:04

It's very strange. It almost looks like a memory problem or something... I deleted my SpamD.log to free up some space as quickly as possible, but I save the suspect 1GB+ eml file. I did a 'less' on it and saw this:
Return-Path: <>
Message-ID: <5999AD8F-0801-4197-A3AD-4BA9CE09B71B@xxx.com>
Date: Mon, 26 Jun 2006 09:02:16 -0700
From: mailer-daemon@xxx.com
To: tkyper@xxx.com
Subject: Undeliverable: 75% off Regular price for VlAGRA !!! uve gypkt z
X-hMailServer-LoopCount: 1

Your message did not reach some or all of the intended recipients.

Sent: Wed, 26 Apr 2006 12:44:51 +0400
Subject: 75% off Regular price for VlAGRA !!! uve gypkt z

The following recipient(s) could not b^@^@^@^A`<C2><E2>^A^@^B<90><C6>^@^@^@^D^@^@^@_^@^@^@^K^@^@^@u'^@^@^@^@^@^@^@^@^@^@<ED><BB>:|@<80><D4>^@R<BC>:|<C8>C ^@^L<BB><E8>^@^@^@^@^@<C8>C ^@@<80><D4>^@
And so on with lots of unviewable binary interspersed with bits of information from the Windows registry containing text like "Software\Clients\Mail\Exchange\Protocols\Mailto" and "Microsoft Internet Explorer 5.0 Error Log". There's some bits of what looks like was a spam email containing lots of HTML as well. After all of that, it just repeats zeroes for most of the rest of the file with some variances here-and-there.


Explorer.exe crashes often on this same machine when browsing directories through Terminal Services. I'm wondering if faulty memory or something like that might cause this, but if so, I'm surprised the machine has even lasted this long.[/quote]

Post Reply