net-mail/zarafa: add spamd handler patch and the send as patch

(Portage version: 2.2.0_alpha37/svn/Linux x86_64, RepoMan options: --force)

git-svn-id: https://svn.disconnected-by-peer.at/svn/linamh/trunk/mds@2912 6952d904-891a-0410-993b-d76249ca496b
This commit is contained in:
geos_one 2011-06-08 19:54:54 +00:00
parent f3426269b2
commit dc7ad91ee8
6 changed files with 272 additions and 2 deletions

View File

@ -2,6 +2,11 @@
# Copyright 1999-2011 Gentoo Foundation; Distributed under the GPL v2
# $Header: $
08 Jun 2011; Mario Fetka <mario.fetka@gmail.com>
+files/6.40.8.27223/Datux-sendas.patch, zarafa-6.40.8.27223.ebuild,
+files/6.40.8.27223/Datux-spamhook.patch, +files/junklearn.dspam:
add spamd handler patch and the send as patch
27 May 2011; Mario Fetka <mario.fetka@gmail.com>
files/6.40.8.27223/zarafa-6.40.2-libtcmalloc_shared-1.patch,
files/6.40.8.27223/zarafa-6.40.2-sysconfig2confd-1.patch:

View File

@ -25,6 +25,8 @@ AUX 6.40.7.26119/zarafa-6.40.2-libtcmalloc_shared-1.patch 857 RMD160 7112bfd1b5c
AUX 6.40.7.26119/zarafa-6.40.2-sysconfig2confd-1.patch 8497 RMD160 1838567e668a32833d22e286defa73877cb515d2 SHA1 4ce13564cfc80598636b1c94028db3613feeb98c SHA256 cd1128ec66f18c887b6b304648e3a94b9aea782e363a303fc636b8f66b43fc5f
AUX 6.40.7.26119/zarafa-6.40.6-force_latin1.patch 618 RMD160 8fc093050c3368c770d11326cf2402511f8d7c14 SHA1 5a7a6669308166ffb8117090411c3df9827408aa SHA256 e8caa41fb4a285e59ab8b3a2a6c0b5733423f70dbc55798d6c1472202deab496
AUX 6.40.7.26119/zarafa-6.40.6-package.patch 2135 RMD160 30804eb455510967a5cfc2f9fe9bd699f906a9df SHA1 725f55210166e3453eae6bb58d1a417c6b0021ad SHA256 e441b08807753388e561653adcb9e3de8def54e3c343105dc25d95c1a1e0997d
AUX 6.40.8.27223/Datux-sendas.patch 1429 RMD160 bd2b502775fb84bd6899bb3892d36d19ee3d5b8d SHA1 07a5887d02d0ddbd368c46e50eb4267f73aac9f7 SHA256 852e7fc30df15fc534ff6697f8735ee02fe013f2fcb2c7dcd0b4b5f79b9b1032
AUX 6.40.8.27223/Datux-spamhook.patch 9895 RMD160 b1143f3e2057ee8d1b0a03e757086501769645a6 SHA1 a108a95087ba83f9c1fb0da42ffc5eef1d3755da SHA256 57d4fe122acc168b508b06a0a99ee9dc093080116918d2043fca02bc7022ed2b
AUX 6.40.8.27223/fix-pthread.patch 2101 RMD160 aafbca78c32dc5c248ff044b9fd35ae3e5882649 SHA1 44f7ac8d8e36209c811b0e1cde5dbfdcc1cdab0d SHA256 f3e8324db43fb626aadb0bf334852d7a1b194333b120c7de643a89a37a1cc99c
AUX 6.40.8.27223/fix-zarafaserver-uuid-linkage.patch 1394 RMD160 f88c3d41e5af48713d5ba5a4f9a9add75724bb45 SHA1 59aadb0eb993c7a552018c37e715bee7caaa1a12 SHA256 c452efb1f6b4deec5f32471b3998d6b9a40a2eacba959b76b3abae7d82e80e22
AUX 6.40.8.27223/fix-zarafastats-uuid-linkage.patch 1051 RMD160 9713fa23bd16cb69111ecb39f840f8b7026d8f21 SHA1 ca04f80dce737ad10821c2e1bb84cd8f4ea5b9c5 SHA256 a1c0febb372dba9241cd87eded9d0e5940748cf01285a8eee0e43fa38a63fc03
@ -39,6 +41,7 @@ AUX 7.0.0.3.25734/fix-zarafastats-uuid-linkage.patch 542 RMD160 bc73d6373502e2fc
AUX 7.0.0.3.25734/zarafa-6.40.2-libtcmalloc_shared-1.patch 857 RMD160 7112bfd1b5c1bf628f33521138d76ebdc9e8fa84 SHA1 638f39aa252c644362952becd5eb28fe06db8743 SHA256 c66f888d89a07c2c962f60aae81dee5b97cc2f0c0d4b5f725309f9f7509bea55
AUX 7.0.0.3.25734/zarafa-6.40.2-sysconfig2confd-1.patch 8497 RMD160 1838567e668a32833d22e286defa73877cb515d2 SHA1 4ce13564cfc80598636b1c94028db3613feeb98c SHA256 cd1128ec66f18c887b6b304648e3a94b9aea782e363a303fc636b8f66b43fc5f
AUX 7.0.0.3.25734/zarafa-7.0.0-package.patch 1784 RMD160 758723bb63c1cfcac251f73aa8141a93a912f37f SHA1 e201be373c5840021dfaf9ecd59078e3547578d1 SHA256 91850122f5abb6754d726fb447d8fa03be134d823232397c6934facff28dfdde
AUX junklearn.dspam 924 RMD160 84a39d3297c075f3e4906b40cd84be8e47b90690 SHA1 cfd81182aaec691e7f415709d0db3189bbf9366c SHA256 5060aa1c0fd3e103c0243f5372ec4a393d4aebc7ed7c69a9475adead50d6b37e
AUX zarafa-dagent.rc6 2016 RMD160 45cbcb81da30a34be4202f3d9b84f38b12ecf57b SHA1 aaccebd9658dc8da88a32f7300922557fd4c621c SHA256 696d0f7b0c41814ca15d775b0595eb46b95fc59e1cf2a30935eba2c717ff16d6
AUX zarafa-gateway.rc6 747 RMD160 c6094f036814bb289eade6f309b9c48ed6b683d5 SHA1 6182824447f9373badf2b2536d41190451fbceb0 SHA256 d08eb9eb5e548dca24e644aee4196aa135ef79d74d244675eeb9ea47594311b0
AUX zarafa-ical.rc6 663 RMD160 db306a10e7777889e9460488575cbdd1ddc9037e SHA1 8fa807d0da22ab4fc1f3156c3a7dc0fe3cdab1ad SHA256 1eec0c538a0264eb2757b5687c8285394f899740bc4cba913115f82ccab703e2
@ -66,7 +69,7 @@ DIST zcp-source-6.40.5-24860.tgz 7075378 RMD160 1d350cb5dd0df326f3c96ace088f8a40
EBUILD zarafa-6.40.5.24860.ebuild 6477 RMD160 8eaabfabf480dc46d5eac5e237951c1bc75bff9f SHA1 cc05fa3a7ac388c250f5f7935c08ab51a1597961 SHA256 b296f4d589b2b0d8ae64aff1bfe37a98d316d2d659af802d9b316a2c0986028b
EBUILD zarafa-6.40.6.25584.ebuild 6723 RMD160 72550113d78f6864caa8122ffeb08bb3c79412b3 SHA1 76ffb4521e5465ad31af130d1d332212f4835cae SHA256 42dcf7aa4750b6bf7e8574f7894441bac4595371462c57371be9c0800083bba9
EBUILD zarafa-6.40.7.26119.ebuild 6777 RMD160 fe359cd63aca023aa83fad9a95abe0239b732a82 SHA1 6f343990be1fba33e2e06fa08f52ff57a4f47f7c SHA256 03b75c59a78e6afdbac9e8be7ef683cb42b7346e3879756057951c2f8ad38fdc
EBUILD zarafa-6.40.8.27223.ebuild 6793 RMD160 e6dab0607401ac1a78415b275b845aaf660eeecc SHA1 792d09cc253baaa11e2afefdbaf16df84e002b5e SHA256 6f795926064e99b7698509e3c3cfa2f4f351acfb302c17fe2ac13e820e308439
EBUILD zarafa-6.40.8.27223.ebuild 6876 RMD160 f7bed3f7e0966f9c7d5ec2df5bd2a7ccc289516d SHA1 c46fa293266f24fc96545bfd7c5f26790287aa0b SHA256 ac14b86a94ce8807c9a319200d885cce74df90ad4ac9e05bf2ef91baf13d0332
EBUILD zarafa-7.0.0.3.25734.ebuild 6767 RMD160 7cfdab79030913daa2f8c64114a25db32dbda881 SHA1 b159c7d13e2b7f50a8aa9e5e0f7b730b25b422f8 SHA256 a51e0f2b582e03f2f3d755cbf0ae3aded472edacd614fbfbedb758e34f8e1ec7
MISC ChangeLog 4152 RMD160 9804d764f1259caf5afb901e175ee6d9e0b8a028 SHA1 f4ff8dcb5dcde4b8a73f235f8efdb6a09cdaa0fa SHA256 665d7e0bc49a875815eb36170032d2c89268cf0ad6666b5faa464d769847ef5a
MISC ChangeLog 4390 RMD160 a9f5e75e3fd9349a33ac300745648c2aee49eff8 SHA1 24a761a9a8aa7b9c2ecd73c56c53c8f76d85e83d SHA256 aa19c361375d20eec47969171196f6c6488e1b73f33b09e402c3d09899b293c8
MISC metadata.xml 1238 RMD160 c82938e77f387291d6a1c3bf9b0d802f2878dd12 SHA1 b5738f14922c69e78cfb867acdc65eeea25977bf SHA256 2c13f98be5fa8bdaf21ac86bcd00bbeb8944df5615de0cfce35ae4c00ef4b4d5

View File

@ -0,0 +1,25 @@
diff -u -r zarafa-6.40.3/spooler/Spooler.cpp zarafa-6.40.3.new/spooler/Spooler.cpp
--- zarafa-6.40.3/spooler/Spooler.cpp 2010-10-20 14:16:24.000000000 +0000
+++ zarafa-6.40.3.new/spooler/Spooler.cpp 2010-11-10 15:58:43.000000000 +0000
@@ -935,6 +935,7 @@
{ "fax_domain", "", CONFIGSETTING_RELOADABLE },
{ "fax_international", "+", CONFIGSETTING_RELOADABLE },
{ "always_send_delegates", "no", CONFIGSETTING_RELOADABLE },
+ { "always_send_as", "no", CONFIGSETTING_RELOADABLE },
{ "always_send_tnef", "no", CONFIGSETTING_RELOADABLE },
{ "allow_redirect_spoofing", "yes", CONFIGSETTING_RELOADABLE },
{ "allow_delegate_meeting_request", "yes", CONFIGSETTING_RELOADABLE },
diff -u -r zarafa-6.40.3/spooler/mailer.cpp zarafa-6.40.3.new/spooler/mailer.cpp
--- zarafa-6.40.3/spooler/mailer.cpp 2010-10-20 14:16:24.000000000 +0000
+++ zarafa-6.40.3.new/spooler/mailer.cpp 2010-11-10 15:58:09.000000000 +0000
@@ -1949,6 +1949,10 @@
HrGetOneProp(lpMessage, PR_AUTO_FORWARDED, &lpAutoForward) == hrSuccess && lpAutoForward->Value.b)
{
bAllowSendAs = true;
+ } else if (strcmp(g_lpConfig->GetSetting("always_send_as"), "yes") == 0) {
+ //use always_send_as to allow everybody to send as someone else.
+ //(some users hate the 'on behalf of' text, and dont want to do the extra configuration)
+ bAllowSendAs = true;
} else {
hr = HrGetOneProp(lpUserStore, PR_MAILBOX_OWNER_ENTRYID, &lpPropOwner);

View File

@ -0,0 +1,199 @@
diff -rupN zarafa-6.40.0-orig/provider/libserver/ZarafaCmd.cpp zarafa-6.40.0/provider/libserver/ZarafaCmd.cpp
--- zarafa-6.40.0-orig/provider/libserver/ZarafaCmd.cpp 2010-05-31 19:28:59.000000000 +0200
+++ zarafa-6.40.0/provider/libserver/ZarafaCmd.cpp 2010-07-20 17:22:07.995625072 +0200
@@ -7244,6 +7244,166 @@ typedef struct{
SOURCEKEY sSourceKey;
SOURCEKEY sParentSourceKey;
}COPYITEM;
+//SPAM HOOK
+//This function parses an e-mail to the /etc/zarafa/userscripts/junklearn script. With 2 arguments:
+//ham or spam
+//message id
+//and pipes the mail header to the script.
+//This script wil be inhaled by MoveObjects();
+/////////////////////////////////////////////////////////////////////////////////////////////////
+int SpamHook(ECDatabase *lpDatabase,int ulId,int ulDestFolderId)
+{
+
+ ALLOC_DBRESULT();
+ ECRESULT er = erSuccess;
+ std::string shScriptPath = g_lpSessionManager->GetConfig()->GetSetting("junklearn_script");
+
+ //If shScriptPath doesn't exist skip spam hook.
+ if(fopen(shScriptPath.c_str(),"r")) {
+
+ //Get store object ID via message object id
+ unsigned int storeId;
+ er = g_lpSessionManager->GetCacheManager()->GetStore(ulId,&storeId,NULL);
+ if(er != erSuccess)
+ {
+ g_lpSessionManager->GetLogger()->Log(EC_LOGLEVEL_WARNING,"SpamHook: error while retrieve source folder.");
+ goto exit;
+ }
+
+ //get deleted items folder entry id
+ strQuery="SELECT val_binary FROM properties WHERE hierarchyid="+stringify(storeId)+" AND tag="+stringify(PROP_ID(PR_IPM_WASTEBASKET_ENTRYID));
+ er = lpDatabase->DoSelect(strQuery, &lpDBResult);
+ if(er != erSuccess) {
+ g_lpSessionManager->GetLogger()->Log(EC_LOGLEVEL_WARNING,"SpamHook: error while retrieve wastebasket entryid from DB.");
+ goto exit;
+ }
+ lpDBRow = lpDatabase->FetchRow(lpDBResult);
+ lpDBLen = lpDatabase->FetchRowLengths(lpDBResult);
+ int shNumRows=lpDatabase->GetNumRows(lpDBResult);
+ if(shNumRows<1)
+ {
+ g_lpSessionManager->GetLogger()->Log(EC_LOGLEVEL_WARNING,"SpamHook: error while retrieve wastebasket entryid, empty DB result.");
+ goto exit;
+ }
+
+ //Convert 'deleted items' entryid to objectid.
+ entryId* wasteBucketEntryId = new entryId[0];
+ wasteBucketEntryId->__ptr=(unsigned char*)lpDBRow[0];
+ wasteBucketEntryId->__size=lpDBLen[0];
+ unsigned int wasteBucketFolderId;
+ er=g_lpSessionManager->GetCacheManager()->GetObjectFromEntryId(wasteBucketEntryId,&wasteBucketFolderId);
+ delete wasteBucketEntryId;
+ if(er!=erSuccess)
+ {
+ g_lpSessionManager->GetLogger()->Log(EC_LOGLEVEL_WARNING,"SpamHook: error while retrieve wastebasket entryid, converting to objectID.");
+ goto exit;
+ }
+ FREE_DBRESULT();
+
+ //Get 'junk folder' entryId.
+ strQuery="SELECT val_binary FROM receivefolder LEFT JOIN mvproperties ON receivefolder.objid=mvproperties.hierarchyid WHERE receivefolder.storeid="+stringify(storeId)+" AND receivefolder.messageclass='IPC' AND mvproperties.tag="+stringify(PROP_ID(PR_ADDITIONAL_REN_ENTRYIDS))+" AND mvproperties.orderid=4";
+ er = lpDatabase->DoSelect(strQuery, &lpDBResult);
+ if(er != erSuccess) {
+ g_lpSessionManager->GetLogger()->Log(EC_LOGLEVEL_WARNING,"SpamHook: error while retrieve junkfolder entryids from DB.");
+ goto exit;
+ }
+ lpDBRow = lpDatabase->FetchRow(lpDBResult);
+ lpDBLen = lpDatabase->FetchRowLengths(lpDBResult);
+ shNumRows=lpDatabase->GetNumRows(lpDBResult);
+ if(shNumRows<1)
+ {
+ g_lpSessionManager->GetLogger()->Log(EC_LOGLEVEL_WARNING,"SpamHook: error while retrieve junkfolder entryid, empty DB result.");
+ goto exit;
+ }
+
+ //Convert 'junk folder' entryid to objectid.
+ entryId* junkFolderEntryId = new entryId[0];
+ junkFolderEntryId->__ptr=(unsigned char*)lpDBRow[0];
+ junkFolderEntryId->__size=lpDBLen[0];
+ unsigned int junkFolderId;
+ er=g_lpSessionManager->GetCacheManager()->GetObjectFromEntryId(junkFolderEntryId,&junkFolderId);
+ delete junkFolderEntryId;
+ if(er!=erSuccess)
+ {
+ g_lpSessionManager->GetLogger()->Log(EC_LOGLEVEL_WARNING,"SpamHook: error while retrieve junkfolder entryid, converting to objectID.");
+ goto exit;
+ }
+ FREE_DBRESULT();
+
+ //Get source folder object ID. (Actually we should check if mail came from subfolders in the 'deleted items folder', which I think never happens.)
+ unsigned int srcFolderId;
+ er=g_lpSessionManager->GetCacheManager()->GetParent(ulId,&srcFolderId);
+ if(er!=erSuccess)
+ {
+ g_lpSessionManager->GetLogger()->Log(EC_LOGLEVEL_WARNING,"SpamHook: error while retrieve src folder id.");
+ goto exit;
+ }
+
+ //Check if object is ham or spam
+ string shMailStatus;
+ //if destination folder is junk, mark as spam
+ if(ulDestFolderId==junkFolderId)
+ shMailStatus="spam";
+ else
+ {
+ //if destination folder is not TRASH and de source folder is JUNK, mark as ham
+ if(ulDestFolderId!=wasteBucketFolderId && srcFolderId==junkFolderId)
+ shMailStatus="ham";
+ }
+
+ //Only call hook script if the mail is marked as ham or spam.
+ if(!shMailStatus.empty()) {
+
+ //Get the mail from the DB.
+ strQuery="SELECT val_string FROM properties WHERE tag="+stringify(PROP_ID(PR_TRANSPORT_MESSAGE_HEADERS))+" AND hierarchyid= "+stringify(ulId);
+ er = lpDatabase->DoSelect(strQuery, &lpDBResult);
+ if(er != erSuccess) {
+ g_lpSessionManager->GetLogger()->Log(EC_LOGLEVEL_WARNING,"SpamHook: db error while retrieve mail header.");
+ goto exit;
+ }
+ lpDBRow = lpDatabase->FetchRow(lpDBResult);
+ int shNumRows=lpDatabase->GetNumRows(lpDBResult);
+
+ if(shNumRows>0) {
+
+ // Execute the hook:
+ FILE *shFilePtr;
+ shScriptPath=shScriptPath+" "+shMailStatus+" "+stringify(ulId);
+ shFilePtr=popen(shScriptPath.c_str(),"w");
+ fputs(lpDBRow[0],shFilePtr);
+ int shExitCode=pclose(shFilePtr);
+ if(!WIFEXITED(shExitCode)) {
+ g_lpSessionManager->GetLogger()->Log(EC_LOGLEVEL_WARNING,"SpamHook: "+shScriptPath+" was terminated abnormally.");
+ goto exit;
+ }
+ //If script exit with non 0, exit..
+ if(WEXITSTATUS(shExitCode)!=0) {
+ g_lpSessionManager->GetLogger()->Log(EC_LOGLEVEL_WARNING,"SpamHook: error "+shScriptPath+" exits with: "+stringify(shExitCode));
+ er=ZARAFA_E_UNKNOWN;
+ goto exit;
+ }
+ g_lpSessionManager->GetLogger()->Log(EC_LOGLEVEL_INFO,"SpamHook: "+shScriptPath+" successfully executed.");
+ er=erSuccess;
+ }
+ else {
+ g_lpSessionManager->GetLogger()->Log(EC_LOGLEVEL_WARNING,"SpamHook: warning mail header empty or this object is no e-mail");
+ }
+
+ // Free database results
+ FREE_DBRESULT();
+ }
+ }
+ else {
+ g_lpSessionManager->GetLogger()->Log(EC_LOGLEVEL_INFO,"SpamHook: skipping, script "+shScriptPath+" not found");
+ er=erSuccess;
+ }
+exit:
+ // Free database results
+ FREE_DBRESULT();
+
+ return er;
+}
+
// Move one or more messages and/or moved a softdeleted message to a normal message
ECRESULT MoveObjects(ECSession *lpSession, ECDatabase *lpDatabase, ECListInt* lplObjectIds, unsigned int ulDestFolderId, unsigned int ulSyncId)
@@ -8096,6 +8256,17 @@ SOAP_ENTRY_START5(copyObjects, *result,
// @note The object type checking wille be done in MoveObjects or CopyObject
+//SPAMHOOK
+/////////////////////////////////////
+ //Iterate over all mail ids and initiate spamhook.
+ for(iObjectId = lObjectIds.begin(); iObjectId != lObjectIds.end(); iObjectId++)
+ {
+ //Ignore the result
+ int shResult=SpamHook(lpDatabase,*iObjectId,ulDestFolderId);
+ }
+//SPAMHOOK END
+////////////////////////////////////
+
//check copy or a move
if(ulFlags & FOLDER_MOVE ) { // A move
er = MoveObjects(lpecSession, lpDatabase, &lObjectIds, ulDestFolderId, ulSyncId);
diff -rupN zarafa-6.40.0-orig/provider/server/ECServer.cpp zarafa-6.40.0/provider/server/ECServer.cpp
--- zarafa-6.40.0-orig/provider/server/ECServer.cpp 2010-05-31 19:28:59.000000000 +0200
+++ zarafa-6.40.0/provider/server/ECServer.cpp 2010-07-20 17:26:25.119624516 +0200
@@ -670,6 +670,7 @@ int running_server(char *szName, char *s
{ "deletegroup_script", "/etc/zarafa/userscripts/deletegroup", CONFIGSETTING_RELOADABLE},
{ "createcompany_script", "/etc/zarafa/userscripts/createcompany", CONFIGSETTING_RELOADABLE },
{ "deletecompany_script", "/etc/zarafa/userscripts/deletecompany", CONFIGSETTING_RELOADABLE },
+ { "junklearn_script", "/etc/zarafa/userscripts/junklearn", CONFIGSETTING_RELOADABLE },
{ "user_safe_mode", "no", CONFIGSETTING_RELOADABLE },
// Storename format

View File

@ -0,0 +1,35 @@
#!/bin/bash
#WARNING: Don't trust the piped input, its from the end-user. use filtering!
IFS=$' ';
DSPAM_CMD="/usr/bin/dspamc";
#Catch stdin en fetch signature and recipient.
DSPAM_HEADER="`sed 's/[^a-zA-Z0-9 :_.-]//g' | grep -i -e ^X-DSPAM-Signature: -e ^X-DSPAM-Recipient: | tail -n2` " || exit 1
DSPAM_USER="`echo \"$DSPAM_HEADER\" | grep -i ^X-DSPAM-Recipient: | cut -d ' ' -f 2`";
DSPAM_SIGNATURE="`echo \"$DSPAM_HEADER\" | grep -i ^X-DSPAM-Signature: | cut -d ' ' -f 2`";
#Catch parameters
STATUS="$1";
MAIL_ID="$2";
if [[ "$DSPAM_SIGNATURE" && "$DSPAM_USER" && "$STATUS" && "$MAIL_ID" ]]; then
if [ "$STATUS" == "ham" ]; then
CLASS="innocent";
else
CLASS="spam";
fi
logger "$DSPAM_CMD --source=error --class=\"$CLASS\" --signature=\"$DSPAM_SIGNATURE\" --user \"$DSPAM_USER\""
$DSPAM_CMD --source=error --class="$CLASS" --signature="$DSPAM_SIGNATURE" --user "$DSPAM_USER";
exit $?;
fi
exit 1;

View File

@ -170,6 +170,9 @@ src_install() {
insinto /etc/zarafa
doins installer/linux/*.cfg || die "Failed to install config files"
exeinto /etc/zarafa/userscripts/
newexe "${FILESDIR}"/junklearn.dspam junklearn
dodir /var/log/zarafa
keepdir /var/log/zarafa