Support smfi_chgfrom and smfi_addrcpt_par.

This commit is contained in:
Stuart Gathman
2008-11-21 20:42:52 +00:00
parent 394e7c6b8e
commit f12bcf9af9
3 changed files with 55 additions and 5 deletions
+51 -3
View File
@@ -35,6 +35,9 @@ $ python setup.py help
libraries=["milter","smutil","resolv"] libraries=["milter","smutil","resolv"]
* $Log$ * $Log$
* Revision 1.11 2007/09/25 02:26:29 customdesigned
* Update license.
*
* Revision 1.10 2006/02/12 02:00:42 customdesigned * Revision 1.10 2006/02/12 02:00:42 customdesigned
* Resolve FIXME for wrap_close. * Resolve FIXME for wrap_close.
* *
@@ -339,6 +342,7 @@ static char milter_set_flags__doc__[] =
Set flags for filter capabilities; OR of one or more of:\n\ Set flags for filter capabilities; OR of one or more of:\n\
ADDHDRS - filter may add headers\n\ ADDHDRS - filter may add headers\n\
CHGBODY - filter may replace body\n\ CHGBODY - filter may replace body\n\
CHGFROM - filter may replace body\n\
ADDRCPT - filter may add recipients\n\ ADDRCPT - filter may add recipients\n\
DELRCPT - filter may delete recipients\n\ DELRCPT - filter may delete recipients\n\
CHGHDRS - filter may change/delete headers"; CHGHDRS - filter may change/delete headers";
@@ -1013,6 +1017,30 @@ milter_addheader(PyObject *self, PyObject *args) {
#endif #endif
} }
#ifdef SMFIF_CHGFROM
static char milter_chgfrom__doc__[] =
"chgfrom(sender,params) -> None\n\
Change the envelope sender (MAIL From) of the current message.\n\
A filter which calls smfi_chgfrom must have set the CHGFROM flag\n\
in set_flags() before calling register.\n\
This function can only be called from the EOM callback.";
static PyObject *
milter_chgfrom(PyObject *self, PyObject *args) {
char *sender;
char *params;
SMFICTX *ctx;
PyThreadState *t;
if (!PyArg_ParseTuple(args, "sz:chgfrom", &sender, &params))
return NULL;
ctx = _find_context(self);
if (ctx == NULL) return NULL;
t = PyEval_SaveThread();
return _thread_return(t,smfi_chgfrom(ctx, sender, params),
"cannot change sender");
}
#endif
static char milter_chgheader__doc__[] = static char milter_chgheader__doc__[] =
"chgheader(field, int, value) -> None\n\ "chgheader(field, int, value) -> None\n\
Change/delete a header in the message. \n\ Change/delete a header in the message. \n\
@@ -1042,22 +1070,33 @@ milter_chgheader(PyObject *self, PyObject *args) {
} }
static char milter_addrcpt__doc__[] = static char milter_addrcpt__doc__[] =
"addrcpt(string) -> None\n\ "addrcpt(string,params=None) -> None\n\
Add a recipient to the envelope. It must be in the same format\n\ Add a recipient to the envelope. It must be in the same format\n\
as is passed to the envrcpt callback in the first tuple element.\n\ as is passed to the envrcpt callback in the first tuple element.\n\
If params is used, you must pass ADDRCPT_PAR to set_flags().\n\
This function can only be called from the EOM callback."; This function can only be called from the EOM callback.";
static PyObject * static PyObject *
milter_addrcpt(PyObject *self, PyObject *args) { milter_addrcpt(PyObject *self, PyObject *args) {
char *rcpt; char *rcpt;
char *params = 0;
SMFICTX *ctx; SMFICTX *ctx;
PyThreadState *t; PyThreadState *t;
int rc;
if (!PyArg_ParseTuple(args, "s:addrcpt", &rcpt)) return NULL; if (!PyArg_ParseTuple(args, "s|z:addrcpt", &rcpt)) return NULL;
ctx = _find_context(self); ctx = _find_context(self);
if (ctx == NULL) return NULL; if (ctx == NULL) return NULL;
t = PyEval_SaveThread(); t = PyEval_SaveThread();
return _thread_return(t,smfi_addrcpt(ctx, rcpt), "cannot add recipient"); if (params)
#ifdef SMFIF_ADDRCPT_PAR
rc = smfi_addrcpt_par(ctx,rcpt,params);
#else
rc = MI_FAILURE;
#endif
else
rc = smfi_addrcpt(ctx,rcpt);
return _thread_return(t,rc, "cannot add recipient");
} }
static char milter_delrcpt__doc__[] = static char milter_delrcpt__doc__[] =
@@ -1198,6 +1237,9 @@ static PyMethodDef context_methods[] = {
#endif #endif
#ifdef SMFIR_PROGRESS #ifdef SMFIR_PROGRESS
{ "progress", milter_progress, METH_VARARGS, milter_progress__doc__}, { "progress", milter_progress, METH_VARARGS, milter_progress__doc__},
#endif
#ifdef SMFIF_CHGFROM
{ "chgfrom", milter_chgfrom, METH_VARARGS, milter_chgfrom__doc__},
#endif #endif
{ NULL, NULL } { NULL, NULL }
}; };
@@ -1299,6 +1341,9 @@ initmilter(void) {
setitem(d,"CHGBODY", SMFIF_CHGBODY); setitem(d,"CHGBODY", SMFIF_CHGBODY);
setitem(d,"MODBODY", SMFIF_MODBODY); setitem(d,"MODBODY", SMFIF_MODBODY);
setitem(d,"ADDRCPT", SMFIF_ADDRCPT); setitem(d,"ADDRCPT", SMFIF_ADDRCPT);
#ifdef SMFIF_ADDRCPT_PAR
setitem(d,"ADDRCPT_PAR", SMFIF_ADDRCPT_PAR);
#endif
setitem(d,"DELRCPT", SMFIF_DELRCPT); setitem(d,"DELRCPT", SMFIF_DELRCPT);
setitem(d,"CHGHDRS", SMFIF_CHGHDRS); setitem(d,"CHGHDRS", SMFIF_CHGHDRS);
setitem(d,"V1_ACTS", SMFI_V1_ACTS); setitem(d,"V1_ACTS", SMFI_V1_ACTS);
@@ -1306,6 +1351,9 @@ initmilter(void) {
setitem(d,"CURR_ACTS", SMFI_CURR_ACTS); setitem(d,"CURR_ACTS", SMFI_CURR_ACTS);
#ifdef SMFIF_QUARANTINE #ifdef SMFIF_QUARANTINE
setitem(d,"QUARANTINE",SMFIF_QUARANTINE); setitem(d,"QUARANTINE",SMFIF_QUARANTINE);
#endif
#ifdef SMFIF_CHGFROM
setitem(d,"CHGFROM",SMFIF_CHGFROM);
#endif #endif
setitem(d,"CONTINUE", SMFIS_CONTINUE); setitem(d,"CONTINUE", SMFIS_CONTINUE);
setitem(d,"REJECT", SMFIS_REJECT); setitem(d,"REJECT", SMFIS_REJECT);
+3 -1
View File
@@ -3,7 +3,7 @@
# rpmbuild -ba --target=i386,noarch pymilter.spec # rpmbuild -ba --target=i386,noarch pymilter.spec
%define __python python2.4 %define __python python2.4
%define version 0.8.11 %define version 0.8.12
%define release 1%{?dist}.py24 %define release 1%{?dist}.py24
# what version of RH are we building for? # what version of RH are we building for?
%define redhat7 0 %define redhat7 0
@@ -266,6 +266,8 @@ chmod a+x $RPM_BUILD_ROOT%{libdir}/start.sh
rm -rf $RPM_BUILD_ROOT rm -rf $RPM_BUILD_ROOT
%changelog %changelog
* Fri Nov 12 2008 Stuart Gathman <stuart@bmsi.com> 0.8.12-1
- Support chgfrom and addrcpt_par
* Sat Oct 11 2008 Stuart Gathman <stuart@bmsi.com> 0.8.11-1 * Sat Oct 11 2008 Stuart Gathman <stuart@bmsi.com> 0.8.11-1
- Support greylisting - Support greylisting
- Recognize vacation messages as autoreplies. - Recognize vacation messages as autoreplies.
+1 -1
View File
@@ -16,7 +16,7 @@ if sys.version < '2.2.3':
DistributionMetadata.download_url = None DistributionMetadata.download_url = None
# NOTE: importing Milter to obtain version fails when milter.so not built # NOTE: importing Milter to obtain version fails when milter.so not built
setup(name = "pymilter", version = '0.8.11', setup(name = "pymilter", version = '0.8.12',
description="Python interface to sendmail milter API", description="Python interface to sendmail milter API",
long_description="""\ long_description="""\
This is a python extension module to enable python scripts to This is a python extension module to enable python scripts to