Alias patch for ZCP 7.2.0

This commit is contained in:
Christoph Haas UIBK 2015-04-29 13:38:34 -07:00
parent 4d336b7d8d
commit 961eb228fa

View File

@ -1,9 +1,9 @@
diff -ruN --exclude=.svn spooler/alias.cpp ZARAFA_SPOOLER/alias.cpp diff -ruN '--exclude=.svn' orig/zarafa-7.2.0/spooler/alias.cpp zarafa-7.2.0/spooler/alias.cpp
--- spooler/alias.cpp 1970-01-01 01:00:00.000000000 +0100 --- orig/zarafa-7.2.0/spooler/alias.cpp 1969-12-31 19:00:00.000000000 -0500
+++ ZARAFA_SPOOLER/alias.cpp 2013-05-03 00:48:14.339367400 +0200 +++ zarafa-7.2.0/spooler/alias.cpp 2015-03-09 13:16:49.487933628 -0400
@@ -0,0 +1,150 @@ @@ -0,0 +1,150 @@
+/* +/*
+ * Copyright 2013 Christoph Haas <christoph.h@sprinternet.at> + * Copyright 2015 Christoph Haas <christoph.h@sprinternet.at>
+ * + *
+ * This program is free software: you can redistribute it and/or modify + * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by + * it under the terms of the GNU General Public License as published by
@ -70,7 +70,7 @@ diff -ruN --exclude=.svn spooler/alias.cpp ZARAFA_SPOOLER/alias.cpp
+ AliasData data; + AliasData data;
+ int count = 0; + int count = 0;
+ +
+ while ( getline(ssLine, sPart, ';') ) { + while ( getline(ssLine, sPart, ';') ) {
+ sPart = trim(sPart, " \t\r\n"); + sPart = trim(sPart, " \t\r\n");
+ +
+ if(count == 0) { + if(count == 0) {
@ -152,13 +152,12 @@ diff -ruN --exclude=.svn spooler/alias.cpp ZARAFA_SPOOLER/alias.cpp
+ +
+ return name; + return name;
+} +}
\ No newline at end of file diff -ruN '--exclude=.svn' orig/zarafa-7.2.0/spooler/alias.h zarafa-7.2.0/spooler/alias.h
diff -ruN --exclude=.svn spooler/alias.h ZARAFA_SPOOLER/alias.h --- orig/zarafa-7.2.0/spooler/alias.h 1969-12-31 19:00:00.000000000 -0500
--- spooler/alias.h 1970-01-01 01:00:00.000000000 +0100 +++ zarafa-7.2.0/spooler/alias.h 2015-03-09 13:13:50.543932736 -0400
+++ ZARAFA_SPOOLER/alias.h 2013-04-27 20:54:19.619037700 +0200
@@ -0,0 +1,52 @@ @@ -0,0 +1,52 @@
+/* +/*
+ * Copyright 2013 Christoph Haas <christoph.h@sprinternet.at> + * Copyright 2015 Christoph Haas <christoph.h@sprinternet.at>
+ * + *
+ * This program is free software: you can redistribute it and/or modify + * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by + * it under the terms of the GNU General Public License as published by
@ -209,10 +208,10 @@ diff -ruN --exclude=.svn spooler/alias.h ZARAFA_SPOOLER/alias.h
+ wstring getAliasName (void); + wstring getAliasName (void);
+ bool check_mail (wchar_t *e1, wchar_t *e2); + bool check_mail (wchar_t *e1, wchar_t *e2);
+}; +};
diff -ruN --exclude=.svn spooler/mailer.cpp ZARAFA_SPOOLER/mailer.cpp diff -ruN '--exclude=.svn' orig/zarafa-7.2.0/spooler/mailer.cpp zarafa-7.2.0/spooler/mailer.cpp
--- spooler/mailer.cpp 2013-02-28 17:13:18.000000000 +0100 --- orig/zarafa-7.2.0/spooler/mailer.cpp 2015-03-05 10:54:04.000000000 -0500
+++ ZARAFA_SPOOLER/mailer.cpp 2013-05-03 10:14:51.555584600 +0200 +++ zarafa-7.2.0/spooler/mailer.cpp 2015-03-09 13:39:14.851941692 -0400
@@ -50,6 +50,7 @@ @@ -45,6 +45,7 @@
#include "platform.h" #include "platform.h"
#include "mailer.h" #include "mailer.h"
#include "archive.h" #include "archive.h"
@ -220,15 +219,7 @@ diff -ruN --exclude=.svn spooler/mailer.cpp ZARAFA_SPOOLER/mailer.cpp
#include <mapitags.h> #include <mapitags.h>
#include <mapiext.h> #include <mapiext.h>
@@ -82,6 +83,7 @@ @@ -1839,7 +1840,7 @@
#include <list>
#include <algorithm>
+
using namespace std;
extern ECConfig *g_lpConfig;
@@ -1758,7 +1760,7 @@
*/ */
HRESULT CheckSendAs(IAddrBook *lpAddrBook, IMsgStore *lpUserStore, IMAPISession *lpAdminSession, ECSender *lpMailer, HRESULT CheckSendAs(IAddrBook *lpAddrBook, IMsgStore *lpUserStore, IMAPISession *lpAdminSession, ECSender *lpMailer,
ULONG ulOwnerCB, LPENTRYID lpOwnerEID, ULONG ulRepresentCB, LPENTRYID lpRepresentEID, ULONG ulOwnerCB, LPENTRYID lpOwnerEID, ULONG ulRepresentCB, LPENTRYID lpRepresentEID,
@ -237,7 +228,7 @@ diff -ruN --exclude=.svn spooler/mailer.cpp ZARAFA_SPOOLER/mailer.cpp
{ {
HRESULT hr = hrSuccess; HRESULT hr = hrSuccess;
bool bAllowed = false; bool bAllowed = false;
@@ -1770,10 +1772,9 @@ @@ -1851,7 +1852,7 @@
LPSPropValue lpRepresentProps = NULL; LPSPropValue lpRepresentProps = NULL;
SPropValue sSpoofEID = {0}; SPropValue sSpoofEID = {0};
ULONG ulCmpRes = 0; ULONG ulCmpRes = 0;
@ -245,15 +236,12 @@ diff -ruN --exclude=.svn spooler/mailer.cpp ZARAFA_SPOOLER/mailer.cpp
+ SizedSPropTagArray(5, sptaIDProps) = { 5, { PR_DISPLAY_NAME_W, PR_EC_SENDAS_USER_ENTRYIDS, PR_DISPLAY_TYPE, PR_SMTP_ADDRESS_W, PR_EMAIL_ADDRESS_W } }; + SizedSPropTagArray(5, sptaIDProps) = { 5, { PR_DISPLAY_NAME_W, PR_EC_SENDAS_USER_ENTRYIDS, PR_DISPLAY_TYPE, PR_SMTP_ADDRESS_W, PR_EMAIL_ADDRESS_W } };
ULONG cValues = 0; ULONG cValues = 0;
-
hr = SMTPToZarafa(lpAddrBook, ulRepresentCB, lpRepresentEID, &sSpoofEID.Value.bin.cb, (LPENTRYID*)&sSpoofEID.Value.bin.lpb); @@ -1901,7 +1902,19 @@
if (hr != hrSuccess)
hr = ContactToZarafa(lpUserStore, lpAddrBook, ulRepresentCB, lpRepresentEID, &sSpoofEID.Value.bin.cb, (LPENTRYID*)&sSpoofEID.Value.bin.lpb);
@@ -1810,6 +1811,18 @@
if (lpRepresentProps[2].ulPropTag != PR_DISPLAY_TYPE) { // Required property for a mailuser object if (lpRepresentProps[2].ulPropTag != PR_DISPLAY_TYPE) { // Required property for a mailuser object
hr = MAPI_E_NOT_FOUND; hr = MAPI_E_NOT_FOUND;
+ - g_lpLogger->Log(EC_LOGLEVEL_NOTICE, "CheckSendAs(): PR_DISPLAY_TYPE missing %x", hr);
+ // we are checking a simple textfile for matches. + // we are checking a simple textfile for matches.
+ // if the users smtp-address is matching we allow the sending + // if the users smtp-address is matching we allow the sending
+ if(strcmp(g_lpConfig->GetSetting("use_alias_file"), "yes") == 0) { + if(strcmp(g_lpConfig->GetSetting("use_alias_file"), "yes") == 0) {
@ -261,18 +249,19 @@ diff -ruN --exclude=.svn spooler/mailer.cpp ZARAFA_SPOOLER/mailer.cpp
+ g_lpLogger->Log(EC_LOGLEVEL_INFO,"alias found in acl: %ls -> %ls", lpOwnerProps[3].Value.lpszW, lpRepresentProps[4].Value.lpszW); + g_lpLogger->Log(EC_LOGLEVEL_INFO,"alias found in acl: %ls -> %ls", lpOwnerProps[3].Value.lpszW, lpRepresentProps[4].Value.lpszW);
+ hr = hrSuccess; + hr = hrSuccess;
+ bAllowed = true; + bAllowed = true;
+ }else { + } else {
+ g_lpLogger->Log(EC_LOGLEVEL_ERROR,"alias not found in acl: %ls -> %ls", lpOwnerProps[3].Value.lpszW, lpRepresentProps[4].Value.lpszW); + g_lpLogger->Log(EC_LOGLEVEL_ERROR,"alias not found in acl: %ls -> %ls", lpOwnerProps[3].Value.lpszW, lpRepresentProps[4].Value.lpszW);
+ } + }
+ } else {
+ g_lpLogger->Log(EC_LOGLEVEL_NOTICE, "CheckSendAs(): PR_DISPLAY_TYPE missing %x", hr);
+ } + }
goto exit; goto exit;
} }
bHasStore = (lpRepresentProps[2].Value.l == DT_MAILUSER);
@@ -2166,6 +2179,15 @@ @@ -2271,6 +2284,15 @@
ULONG ulResult = 0;
ArchiveResult archiveResult; ArchiveResult archiveResult;
+
+ Alias aliasCheck; + Alias aliasCheck;
+ +
+ if(strcmp(g_lpConfig->GetSetting("use_alias_file"), "yes") == 0) { + if(strcmp(g_lpConfig->GetSetting("use_alias_file"), "yes") == 0) {
@ -281,10 +270,11 @@ diff -ruN --exclude=.svn spooler/mailer.cpp ZARAFA_SPOOLER/mailer.cpp
+ } else { + } else {
+ g_lpLogger->Log(EC_LOGLEVEL_INFO,"Alias checking disabled"); + g_lpLogger->Log(EC_LOGLEVEL_INFO,"Alias checking disabled");
+ } + }
+
sending_options sopt; sending_options sopt;
@@ -2334,7 +2356,7 @@ imopt_default_sending_options(&sopt);
@@ -2438,7 +2460,7 @@
if (!bAllowDelegate) { if (!bAllowDelegate) {
hr = CheckSendAs(lpAddrBook, lpUserStore, lpAdminSession, lpMailer, lpPropOwner->Value.bin.cb, (LPENTRYID)lpPropOwner->Value.bin.lpb, hr = CheckSendAs(lpAddrBook, lpUserStore, lpAdminSession, lpMailer, lpPropOwner->Value.bin.cb, (LPENTRYID)lpPropOwner->Value.bin.lpb,
@ -293,19 +283,11 @@ diff -ruN --exclude=.svn spooler/mailer.cpp ZARAFA_SPOOLER/mailer.cpp
if (hr != hrSuccess) if (hr != hrSuccess)
goto exit; goto exit;
@@ -2363,7 +2385,6 @@ diff -ruN '--exclude=.svn' orig/zarafa-7.2.0/spooler/Makefile.am zarafa-7.2.0/spooler/Makefile.am
sPropSender[1].Value.LPSZ = _T("ZARAFA"); --- orig/zarafa-7.2.0/spooler/Makefile.am 2015-03-05 10:52:42.000000000 -0500
sPropSender[2].ulPropTag = PR_SENDER_EMAIL_ADDRESS_W; +++ zarafa-7.2.0/spooler/Makefile.am 2015-03-09 13:40:47.467933464 -0400
sPropSender[2].Value.LPSZ = lpUser->lpszMailAddress;
-
sPropSender[3].ulPropTag = PR_SENDER_ENTRYID;
sPropSender[3].Value.bin.cb = lpUser->sUserId.cb;
sPropSender[3].Value.bin.lpb = lpUser->sUserId.lpb;
diff -ruN --exclude=.svn spooler/Makefile.am ZARAFA_SPOOLER/Makefile.am
--- spooler/Makefile.am 2013-02-28 16:11:57.000000000 +0100
+++ ZARAFA_SPOOLER/Makefile.am 2013-04-27 13:12:21.888888200 +0200
@@ -28,7 +28,7 @@ @@ -28,7 +28,7 @@
$(PROG_LIBS) $(PYTHON_LIBS) $(PROG_LIBS) $(PYTHON_LIBS) $(XML2_LIBS)
zarafa_dagent_SOURCES = DAgent.cpp rules.cpp rules.h LMTP.cpp LMTP.h archive.cpp archive.h PyMapiPlugin.cpp PyMapiPlugin.h PythonSWIGRuntime.h zarafa_dagent_SOURCES = DAgent.cpp rules.cpp rules.h LMTP.cpp LMTP.h archive.cpp archive.h PyMapiPlugin.cpp PyMapiPlugin.h PythonSWIGRuntime.h
-zarafa_spooler_SOURCES = Spooler.cpp mailer.cpp mailer.h archive.cpp archive.h PyMapiPlugin.cpp PyMapiPlugin.h PythonSWIGRuntime.h -zarafa_spooler_SOURCES = Spooler.cpp mailer.cpp mailer.h archive.cpp archive.h PyMapiPlugin.cpp PyMapiPlugin.h PythonSWIGRuntime.h
@ -313,20 +295,20 @@ diff -ruN --exclude=.svn spooler/Makefile.am ZARAFA_SPOOLER/Makefile.am
BUILT_SOURCES=PythonSWIGRuntime.h BUILT_SOURCES=PythonSWIGRuntime.h
diff -ruN --exclude=.svn spooler/Makefile.in ZARAFA_SPOOLER/Makefile.in diff -ruN '--exclude=.svn' orig/zarafa-7.2.0/spooler/Makefile.in zarafa-7.2.0/spooler/Makefile.in
--- spooler/Makefile.in 2013-02-28 16:13:50.000000000 +0100 --- orig/zarafa-7.2.0/spooler/Makefile.in 2015-03-05 10:52:53.000000000 -0500
+++ ZARAFA_SPOOLER/Makefile.in 2013-04-27 13:28:39.964779800 +0200 +++ zarafa-7.2.0/spooler/Makefile.in 2015-03-09 13:43:20.163932624 -0400
@@ -66,7 +66,7 @@ @@ -83,7 +83,7 @@
am__v_lt_ = $(am__v_lt_$(AM_DEFAULT_VERBOSITY)) am__v_lt_ = $(am__v_lt_@AM_DEFAULT_V@)
am__v_lt_0 = --silent am__v_lt_0 = --silent
am_zarafa_spooler_OBJECTS = Spooler.$(OBJEXT) mailer.$(OBJEXT) \ am_zarafa_spooler_OBJECTS = Spooler.$(OBJEXT) mailer.$(OBJEXT) \
- archive.$(OBJEXT) PyMapiPlugin.$(OBJEXT) - archive.$(OBJEXT) PyMapiPlugin.$(OBJEXT)
+ archive.$(OBJEXT) PyMapiPlugin.$(OBJEXT) alias.$(OBJEXT) + archive.$(OBJEXT) PyMapiPlugin.$(OBJEXT) alias.$(OBJEXT)
zarafa_spooler_OBJECTS = $(am_zarafa_spooler_OBJECTS) zarafa_spooler_OBJECTS = $(am_zarafa_spooler_OBJECTS)
zarafa_spooler_DEPENDENCIES = ${top_builddir}/inetmapi/libinetmapi.la \ zarafa_spooler_DEPENDENCIES = ${top_builddir}/inetmapi/libinetmapi.la \
${top_builddir}/mapi4linux/src/libmapi.la \ ${top_builddir}/mapi4linux/src/libmapi.la \
@@ -391,7 +391,7 @@ @@ -410,7 +410,7 @@
$(PROG_LIBS) $(PYTHON_LIBS) $(PROG_LIBS) $(PYTHON_LIBS) $(XML2_LIBS)
zarafa_dagent_SOURCES = DAgent.cpp rules.cpp rules.h LMTP.cpp LMTP.h archive.cpp archive.h PyMapiPlugin.cpp PyMapiPlugin.h PythonSWIGRuntime.h zarafa_dagent_SOURCES = DAgent.cpp rules.cpp rules.h LMTP.cpp LMTP.h archive.cpp archive.h PyMapiPlugin.cpp PyMapiPlugin.h PythonSWIGRuntime.h
-zarafa_spooler_SOURCES = Spooler.cpp mailer.cpp mailer.h archive.cpp archive.h PyMapiPlugin.cpp PyMapiPlugin.h PythonSWIGRuntime.h -zarafa_spooler_SOURCES = Spooler.cpp mailer.cpp mailer.h archive.cpp archive.h PyMapiPlugin.cpp PyMapiPlugin.h PythonSWIGRuntime.h
@ -334,7 +316,7 @@ diff -ruN --exclude=.svn spooler/Makefile.in ZARAFA_SPOOLER/Makefile.in
BUILT_SOURCES = PythonSWIGRuntime.h BUILT_SOURCES = PythonSWIGRuntime.h
CLEANFILES = PythonSWIGRuntime.h CLEANFILES = PythonSWIGRuntime.h
EXTRA_DIST = PythonSWIGRuntime.h EXTRA_DIST = PythonSWIGRuntime.h
@@ -492,6 +492,7 @@ @@ -514,6 +514,7 @@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/Spooler.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/Spooler.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/archive.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/archive.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/mailer.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/mailer.Po@am__quote@
@ -342,49 +324,56 @@ diff -ruN --exclude=.svn spooler/Makefile.in ZARAFA_SPOOLER/Makefile.in
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/rules.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/rules.Po@am__quote@
.cpp.o: .cpp.o:
diff -ruN --exclude=.svn spooler/README.txt ZARAFA_SPOOLER/README.txt diff -ruN '--exclude=.svn' orig/zarafa-7.2.0/spooler/README.txt zarafa-7.2.0/spooler/README.txt
--- spooler/README.txt 1970-01-01 01:00:00.000000000 +0100 --- orig/zarafa-7.2.0/spooler/README.txt 1969-12-31 19:00:00.000000000 -0500
+++ ZARAFA_SPOOLER/README.txt 2013-04-28 01:20:13.946002000 +0200 +++ zarafa-7.2.0/spooler/README.txt 2015-03-09 13:58:45.579943321 -0400
@@ -0,0 +1,26 @@ @@ -0,0 +1,74 @@
+README for the alias extension: +README for the alias extension:
+ +
+___BUILDING___: +___PREPARATION___:
+
+First read: http://www.zarafa.com/wiki/index.php/Compiling_source_code +First read: http://www.zarafa.com/wiki/index.php/Compiling_source_code
+ +
+For Debian 7 and ZCP 7.2 you can read my blog post: https://blog.sprinternet.at/2015/03/zarafa-zcp-7-2-auf-debian-wheezy-kompilieren/
+
+
+___BUILDING___:
+
+cd path/to/zarafa-source +cd path/to/zarafa-source
+./configure --enable-release --disable-static --with-userscript-prefix=/etc/zarafa/userscripts --with-quotatemplate-prefix=/etc/zarafa/quotamails --enable-python --enable-unicode --disable-swig --disable-tcmalloc +./configure --enable-unicode --enable-release --enable-python --prefix=/usr --with-gsoap-prefix=/opt/zarafa/ --with-ical-prefix=/opt/zarafa/ --with-vmime-prefix=/opt/zarafa/
+make +make
+checkinstall +checkinstall
+ +
+
+___GENERAL___: +___GENERAL___:
+ +
+The alias checking reads its rules from an ansi textfile. +The alias checking reads its rules from an ansi textfile.
+Each rule needs to be on a new line. The sender mailaddress, alias mailaddress and alias display name are seperated by a semicolon +Each rule needs to be on a new line. The sender mailaddress, alias mailaddress and alias display name are seperated by a semicolon
+
+E.g: +E.g:
+ +
+user@zarafa.de;aliasforuser@zarafa.de;Alias Username +user@zarafa.de;aliasforuser@zarafa.de;Alias Username
+user2@zarafa.com;aliasforuser2@zarafa.de;Alias2 Displayname +user2@zarafa.com;aliasforuser2@zarafa.de;Alias2 Displayname
+ +
+Changes to this file would be applied immediately. +Changes to this file would be applied immediately.
+ +Info: Display name is currentl not in use.
+ +
+ +
+___CONFIGURATION___: +___CONFIGURATION___:
+ +
+The default path for the rule file is: /etc/zarafa/alias.txt +The default path for the rule file is: /etc/zarafa/alias.txt
+
+You can enable/disable the extension in the spooler.cfg file. +You can enable/disable the extension in the spooler.cfg file.
+
+WARNING: you have to restart the patched/recompiled spooler version once before you add the new config parameters! +WARNING: you have to restart the patched/recompiled spooler version once before you add the new config parameters!
+ +
+New configuration parameters: +New configuration parameters:
+ +
+use_alias_file (Values: yes, no ; Default: yes) +use_alias_file (Values: yes, no ; Default: yes)
+alias_file (Values: Path to alias file ; Default: /etc/zarafa/alias.txt) +alias_file (Values: Path to alias file ; Default: /etc/zarafa/alias.txt)
\ No newline at end of file diff -ruN '--exclude=.svn' orig/zarafa-7.2.0/spooler/Spooler.cpp zarafa-7.2.0/spooler/Spooler.cpp
diff -ruN --exclude=.svn spooler/Spooler.cpp ZARAFA_SPOOLER/Spooler.cpp --- orig/zarafa-7.2.0/spooler/Spooler.cpp 2015-03-05 10:54:04.000000000 -0500
--- spooler/Spooler.cpp 2013-02-28 17:13:18.000000000 +0100 +++ zarafa-7.2.0/spooler/Spooler.cpp 2015-03-09 13:48:39.411933242 -0400
+++ ZARAFA_SPOOLER/Spooler.cpp 2013-04-27 13:15:02.096661200 +0200 @@ -1147,6 +1147,8 @@
@@ -1142,6 +1142,8 @@
{ "plugin_enabled", "yes" }, { "plugin_enabled", "yes" },
{ "plugin_path", "/var/lib/zarafa/spooler/plugins" }, { "plugin_path", "/var/lib/zarafa/spooler/plugins" },
{ "plugin_manager_path", "/usr/share/zarafa-spooler/python" }, { "plugin_manager_path", "/usr/share/zarafa-spooler/python" },
@ -393,3 +382,4 @@ diff -ruN --exclude=.svn spooler/Spooler.cpp ZARAFA_SPOOLER/Spooler.cpp
{ NULL, NULL }, { NULL, NULL },
}; };
// SIGSEGV backtrace support // SIGSEGV backtrace support