Database Resynchronization

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.
Post Reply
scarletkeeper
New user
New user
Posts: 4
Joined: 2014-05-11 07:06

Database Resynchronization

Post by scarletkeeper » 2014-05-11 07:47

I have been trying to user Kaspersky 10 AV to check incoming emails, however I couldn't get the DOS script to return any value other than 0. I tried Exit 1, Exit /B 1 etc... The windows event logs show that Kaspersky is in fact finding the virus. Error cores 101 or 102 are being returned by Kaspersky, but the DOS script is not passing the correct value back to the hmailserver. I have worked around this by just letting Kaspersky delete or not delete the .eml file and let hmail go on as usual thinking that there wasn't a virus.

On a related note, I am trying to figure out how to do sa-learn for spamassassin, however if I simply run it on the directories it will learn from the .eml file and delete the file afterward.

In both cases the eml file can potentially be deleted. There is a synchronization program that comes with hmail. Does the synchronization program also check for and remove orphaned database entries as well? or does it only add orphaned .eml files to the database.

Everything works, but I'm concerned I will end up with many many orphaned database entries that don't relate to emails.

User avatar
mattg
Moderator
Moderator
Posts: 20305
Joined: 2007-06-14 05:12
Location: 'The Outback' Australia

Re: Database Resynchronization

Post by mattg » 2014-05-11 12:09

If hMailserver doesn't find a file that it thinks should be there, I will create a dummy file of the same name, saying that it can't find the original
Just 'cause I link to a page and say little else doesn't mean I am not being nice.
https://www.hmailserver.com/documentation

scarletkeeper
New user
New user
Posts: 4
Joined: 2014-05-11 07:06

Re: Database Resynchronization

Post by scarletkeeper » 2014-05-11 17:38

Is there anyone that would mind pointing me to the correct database files that relate the physical path to the email file? I looked through the DB and found the messages table that has the name of the file, but not the path. I would like to write a script that purges the database of orphaned records.

Thanks

percepts
Senior user
Senior user
Posts: 5282
Joined: 2009-10-20 16:33
Location: Sceptred Isle

Re: Database Resynchronization

Post by percepts » 2014-05-11 18:49

The idea is that you tell your AV program not to scan the hmail data folder and then hmail will delete the email if your av program returns a virus found code. That way you don't have to mess about trying to clear up the mess that your AV program has created. Hmail takes care of it without screwing up your data folder contents.

In short you are trying to write functionality which hmail already has inbuilt.

I think you should work out how to use your AV and get it to return a consistent value to hmail so that hmail can handle it.

If you tell it to detect but not delete then I think you will get a 102 code which you can put in hmail. If it doesn't return the value to hmail then your script must be wrong.

scarletkeeper
New user
New user
Posts: 4
Joined: 2014-05-11 07:06

Re: Database Resynchronization

Post by scarletkeeper » 2014-05-12 04:17

I agree with you. I would much prefer to get the script to work with the AV rather than write a script to change the database. I am however at my wits end trying to get it to work. The script DOES return 101 and 102 from Kaspersky but the dos script will not return any other value than 0 (at least that's what hmail says). I've attached the code.

Code: Select all

set scanner="C:\Program Files\Kaspersky Lab\Kaspersky Endpoint Security 10 for Windows\avp.com"
%scanner% scan %1 /i4 /fa -es:10
if %errorlevel% == 101 goto virus
if %errorlevel% == 102 goto virus

:exit
exit /b 0

:virus
exit /b 1


I've also tried just exit 1, echo FAIL, and a few others I forget.

For the other issue, I guess I can just do sa-learn for spam on one dedicated email account, ham on another dedicated account, and afterward manually delete them from within the email client (Thunderbird).
Last edited by scarletkeeper on 2014-05-12 04:45, edited 1 time in total.

scarletkeeper
New user
New user
Posts: 4
Joined: 2014-05-11 07:06

Re: Database Resynchronization

Post by scarletkeeper » 2014-05-12 04:35

So basically you were right and my code was wrong. For anyone else trying to get this to work, I finally got the following code to work beautifully for me with KAV 10

Code: Select all

set scanner="C:\Program Files\Kaspersky Lab\Kaspersky Endpoint Security 10 for Windows\avp.com"
%scanner% scan %1 /i0 /fa -es:10
IF %ERRORLEVEL% EQU 101 goto virus
IF %ERRORLEVEL% EQU 102 goto virus

:exit
exit 0

:virus
exit 1
Just copy/paste the code into a .bat file "c:\KAV10SCAN.bat" for example. In the hmailserver AV settings under "External Virus Scanner", put a return value of 1 and for the scanner executable field put:

C:\KAV10SCAN.bat "%FILE%"

For the sa-learn, is it acceptable to run it on forwarded emails, or should they be the exact email copied from the folder?

alescan
Normal user
Normal user
Posts: 45
Joined: 2014-11-11 17:29
Location: Italy
Contact:

Re: Database Resynchronization

Post by alescan » 2017-06-12 14:44

scarletkeeper wrote:So basically you were right and my code was wrong. For anyone else trying to get this to work, I finally got the following code to work beautifully for me with KAV 10

Code: Select all

set scanner="C:\Program Files\Kaspersky Lab\Kaspersky Endpoint Security 10 for Windows\avp.com"
%scanner% scan %1 /i0 /fa -es:10
IF %ERRORLEVEL% EQU 101 goto virus
IF %ERRORLEVEL% EQU 102 goto virus

:exit
exit 0

:virus
exit 1
Just copy/paste the code into a .bat file "c:\KAV10SCAN.bat" for example. In the hmailserver AV settings under "External Virus Scanner", put a return value of 1 and for the scanner executable field put:

C:\KAV10SCAN.bat "%FILE%"

For the sa-learn, is it acceptable to run it on forwarded emails, or should they be the exact email copied from the folder?
I just tried but it return detection failed. Return code: 0.
I'm using kaspersky small office security 5
HMS 5.6.7 B2425 on Win Server 2016 Standard with SQL Server 2014 SP2

alescan
Normal user
Normal user
Posts: 45
Joined: 2014-11-11 17:29
Location: Italy
Contact:

Re: Database Resynchronization

Post by alescan » 2017-06-13 09:17

I modified the script like this:

Code: Select all

set scanner="C:\Program Files (x86)\Kaspersky Lab\Kaspersky Small Office Security 17.0.0\avp.com"
%scanner% scan "%1" /i0 /fa -es:15 /RA:"C:\users\administrator\desktop\log.txt"

if %errorlevel% == 3 goto virus

:exit
exit /b 0

:virus
exit /b 1
If I run it from a prompt it works but when I test it on hmail it give me the same error detection failed. Return code: 0.
HMS 5.6.7 B2425 on Win Server 2016 Standard with SQL Server 2014 SP2

User avatar
mattg
Moderator
Moderator
Posts: 20305
Joined: 2007-06-14 05:12
Location: 'The Outback' Australia

Re: Database Resynchronization

Post by mattg » 2017-06-14 00:39

My guess is that the user that the hMailserver service runs under (probably local system) can't access that log file to write to it
Just 'cause I link to a page and say little else doesn't mean I am not being nice.
https://www.hmailserver.com/documentation

alescan
Normal user
Normal user
Posts: 45
Joined: 2014-11-11 17:29
Location: Italy
Contact:

Re: Database Resynchronization

Post by alescan » 2017-06-14 08:36

I also tried without the logfile and modifiy the service to be started with the administrator account but it doesen't matter, the error is still the same.
HMS 5.6.7 B2425 on Win Server 2016 Standard with SQL Server 2014 SP2

Post Reply