From 0bd88f7cf4293c37527732ace3926ffd29005766 Mon Sep 17 00:00:00 2001 From: Thomas Oettli Date: Thu, 30 Sep 2021 18:04:36 +0200 Subject: [PATCH] prepare to merge with pyquarantine project --- MANIFEST.in | 4 +-- README.md | 20 ++++++------ {pymodmilter => pyquarantine}/__init__.py | 16 +++++----- .../_runtime_patches.py | 6 ++-- {pymodmilter => pyquarantine}/action.py | 10 +++--- {pymodmilter => pyquarantine}/base.py | 6 ++-- {pymodmilter => pyquarantine}/cli.py | 6 ++-- {pymodmilter => pyquarantine}/conditions.py | 10 +++--- {pymodmilter => pyquarantine}/config.py | 6 ++-- .../docs/pyquarantine.conf.example | 6 ++-- .../docs/templates/disclaimer_html.template | 0 .../docs/templates/disclaimer_text.template | 0 .../docs/templates/notification.template | 29 ++++++++++++++++++ pyquarantine/docs/templates/removed.png | Bin 0 -> 2136 bytes {pymodmilter => pyquarantine}/mailer.py | 6 ++-- .../misc/openrc/pyquarantine-milter.confd | 4 +-- .../misc/openrc/pyquarantine-milter.initd | 2 +- {pymodmilter => pyquarantine}/modify.py | 10 +++--- {pymodmilter => pyquarantine}/notify.py | 10 +++--- {pymodmilter => pyquarantine}/rule.py | 10 +++--- {pymodmilter => pyquarantine}/run.py | 28 ++++++++--------- {pymodmilter => pyquarantine}/storage.py | 14 ++++----- {pymodmilter => pyquarantine}/whitelist.py | 6 ++-- setup.cfg | 2 +- setup.py | 21 +++++++------ test-pymodmilter | 9 ------ 26 files changed, 133 insertions(+), 108 deletions(-) rename {pymodmilter => pyquarantine}/__init__.py (96%) rename {pymodmilter => pyquarantine}/_runtime_patches.py (97%) rename {pymodmilter => pyquarantine}/action.py (87%) rename {pymodmilter => pyquarantine}/base.py (91%) rename {pymodmilter => pyquarantine}/cli.py (99%) rename {pymodmilter => pyquarantine}/conditions.py (95%) rename {pymodmilter => pyquarantine}/config.py (98%) rename pymodmilter/docs/pymodmilter.conf.example => pyquarantine/docs/pyquarantine.conf.example (96%) rename {pymodmilter => pyquarantine}/docs/templates/disclaimer_html.template (100%) rename {pymodmilter => pyquarantine}/docs/templates/disclaimer_text.template (100%) create mode 100644 pyquarantine/docs/templates/notification.template create mode 100644 pyquarantine/docs/templates/removed.png rename {pymodmilter => pyquarantine}/mailer.py (92%) rename pymodmilter/misc/openrc/pymodmilter.confd => pyquarantine/misc/openrc/pyquarantine-milter.confd (56%) rename pymodmilter/misc/openrc/pymodmilter.initd => pyquarantine/misc/openrc/pyquarantine-milter.initd (95%) rename {pymodmilter => pyquarantine}/modify.py (97%) rename {pymodmilter => pyquarantine}/notify.py (97%) rename {pymodmilter => pyquarantine}/rule.py (89%) rename {pymodmilter => pyquarantine}/run.py (83%) rename {pymodmilter => pyquarantine}/storage.py (97%) rename {pymodmilter => pyquarantine}/whitelist.py (97%) delete mode 100755 test-pymodmilter diff --git a/MANIFEST.in b/MANIFEST.in index 89bd49f..f29efd2 100644 --- a/MANIFEST.in +++ b/MANIFEST.in @@ -1,3 +1,3 @@ include LICENSE README.md -recursive-include pymodmilter/docs * -recursive-include pymodmilter/misc * +recursive-include pyquarantine/docs * +recursive-include pyquarantine/misc * diff --git a/README.md b/README.md index a349d98..2c5e99f 100644 --- a/README.md +++ b/README.md @@ -1,25 +1,27 @@ -# pymodmilter +# pyquarantine A pymilter based sendmail/postfix pre-queue filter with the ability to add, remove and modify e-mail headers. The project is currently in beta status, but it is already used in a productive enterprise environment that processes about a million e-mails per month. The basic idea is to define rules with conditions and actions which are processed when all conditions are true. ## Dependencies -Pymodmilter is depending on these python packages, but they are installed automatically if you are working with pip. -* [pymilter](https://pythonhosted.org/pymilter/) -* [netaddr](https://github.com/drkjam/netaddr/) +pyquarantine is depending on these python packages, but they are installed automatically if you are working with pip. +* [jsonschema](https://github.com/Julian/jsonschema) +* [pymilter](https://github.com/sdgathman/pymilter) +* [netaddr](https://github.com/drkjam/netaddr) +* [peewee](https://github.com/coleifer/peewee) * [BeautifulSoup](https://www.crummy.com/software/BeautifulSoup/) ## Installation -* Install pymodmilter with pip and copy the example config file. +* Install pyquarantine with pip and copy the example config file. ```sh -pip install pymodmilter -cp /etc/pymodmilter/pymodmilter.conf.example /etc/pymodmilter/pymodmilter.conf +pip install pyquarantine +cp /etc/pyquarantine/pyquarantine.conf.example /etc/pyquarantine/pyquarantine.conf ``` -* Modify /etc/pymodmilter/pymodmilter.conf according to your needs. +* Modify /etc/pyquarantine/pyquarantine.conf according to your needs. ## Configuration options -Pymodmilter uses a config file in JSON format. The config file has to be JSON valid with the exception of allowed comment lines starting with **#**. The options are described below. +pyquarantine uses a config file in JSON format. The config file has to be JSON valid with the exception of allowed comment lines starting with **#**. The options are described below. Rules and actions are processed in the given order. ### Global diff --git a/pymodmilter/__init__.py b/pyquarantine/__init__.py similarity index 96% rename from pymodmilter/__init__.py rename to pyquarantine/__init__.py index 34c5d61..c46681b 100644 --- a/pymodmilter/__init__.py +++ b/pyquarantine/__init__.py @@ -1,15 +1,15 @@ -# PyMod-Milter is free software: you can redistribute it and/or modify +# pyquarantine is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # -# PyMod-Milter is distributed in the hope that it will be useful, +# pyquarantine is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License -# along with PyMod-Milter. If not, see . +# along with pyquarantine. If not, see . # __all__ = [ @@ -27,9 +27,9 @@ __all__ = [ "whitelist", "ModifyMilter"] -__version__ = "1.2.0" +__version__ = "2.0.0" -from pymodmilter import _runtime_patches +from pyquarantine import _runtime_patches import Milter import logging @@ -44,9 +44,9 @@ from email.policy import SMTPUTF8 from io import BytesIO from netaddr import IPNetwork, AddrFormatError -from pymodmilter.base import CustomLogger, MilterMessage -from pymodmilter.base import replace_illegal_chars -from pymodmilter.rule import Rule +from pyquarantine.base import CustomLogger, MilterMessage +from pyquarantine.base import replace_illegal_chars +from pyquarantine.rule import Rule class ModifyMilter(Milter.Base): diff --git a/pymodmilter/_runtime_patches.py b/pyquarantine/_runtime_patches.py similarity index 97% rename from pymodmilter/_runtime_patches.py rename to pyquarantine/_runtime_patches.py index 4d868ea..aef4656 100644 --- a/pymodmilter/_runtime_patches.py +++ b/pyquarantine/_runtime_patches.py @@ -1,15 +1,15 @@ -# PyMod-Milter is free software: you can redistribute it and/or modify +# pyquarantine is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # -# PyMod-Milter is distributed in the hope that it will be useful, +# pyquarantine is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License -# along with PyMod-Milter. If not, see . +# along with pyquarantine. If not, see . # import encodings diff --git a/pymodmilter/action.py b/pyquarantine/action.py similarity index 87% rename from pymodmilter/action.py rename to pyquarantine/action.py index ce0deda..cb30822 100644 --- a/pymodmilter/action.py +++ b/pyquarantine/action.py @@ -1,21 +1,21 @@ -# PyMod-Milter is free software: you can redistribute it and/or modify +# pyquarantine is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # -# PyMod-Milter is distributed in the hope that it will be useful, +# pyquarantine is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License -# along with PyMod-Milter. If not, see . +# along with pyquarantine. If not, see . # __all__ = ["Action"] -from pymodmilter import modify, notify, storage -from pymodmilter.conditions import Conditions +from pyquarantine import modify, notify, storage +from pyquarantine.conditions import Conditions class Action: diff --git a/pymodmilter/base.py b/pyquarantine/base.py similarity index 91% rename from pymodmilter/base.py rename to pyquarantine/base.py index a88671a..70be625 100644 --- a/pymodmilter/base.py +++ b/pyquarantine/base.py @@ -1,15 +1,15 @@ -# PyMod-Milter is free software: you can redistribute it and/or modify +# pyquarantine is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # -# PyMod-Milter is distributed in the hope that it will be useful, +# pyquarantine is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License -# along with PyMod-Milter. If not, see . +# along with pyquarantine. If not, see . # __all__ = [ diff --git a/pymodmilter/cli.py b/pyquarantine/cli.py similarity index 99% rename from pymodmilter/cli.py rename to pyquarantine/cli.py index 2f7b8c8..d7d733e 100644 --- a/pymodmilter/cli.py +++ b/pyquarantine/cli.py @@ -20,8 +20,8 @@ import logging.handlers import sys import time -from pymodmilter.config import get_milter_config -from pymodmilter import __version__ as version +from pyquarantine.config import get_milter_config +from pyquarantine import __version__ as version def _get_quarantine(quarantines, name): @@ -316,7 +316,7 @@ def main(): formatter_class=formatter_class) parser.add_argument( "-c", "--config", help="Config file to read.", - default="/etc/pymodmilter/pymodmilter.conf") + default="/etc/pyquarantine/pyquarantine.conf") parser.add_argument( "-d", "--debug", help="Log debugging messages.", diff --git a/pymodmilter/conditions.py b/pyquarantine/conditions.py similarity index 95% rename from pymodmilter/conditions.py rename to pyquarantine/conditions.py index 9761c2f..3ec4b88 100644 --- a/pymodmilter/conditions.py +++ b/pyquarantine/conditions.py @@ -1,15 +1,15 @@ -# PyMod-Milter is free software: you can redistribute it and/or modify +# pyquarantine is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # -# PyMod-Milter is distributed in the hope that it will be useful, +# pyquarantine is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License -# along with PyMod-Milter. If not, see . +# along with pyquarantine. If not, see . # __all__ = ["Conditions"] @@ -18,8 +18,8 @@ import logging import re from netaddr import IPAddress, IPNetwork, AddrFormatError -from pymodmilter import CustomLogger -from pymodmilter.whitelist import DatabaseWhitelist +from pyquarantine import CustomLogger +from pyquarantine.whitelist import DatabaseWhitelist class Conditions: diff --git a/pymodmilter/config.py b/pyquarantine/config.py similarity index 98% rename from pymodmilter/config.py rename to pyquarantine/config.py index 6b6f336..c729ad3 100644 --- a/pymodmilter/config.py +++ b/pyquarantine/config.py @@ -1,15 +1,15 @@ -# PyMod-Milter is free software: you can redistribute it and/or modify +# pyquarantine is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # -# PyMod-Milter is distributed in the hope that it will be useful, +# pyquarantine is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License -# along with PyMod-Milter. If not, see . +# along with pyquarantine. If not, see . # __all__ = [ diff --git a/pymodmilter/docs/pymodmilter.conf.example b/pyquarantine/docs/pyquarantine.conf.example similarity index 96% rename from pymodmilter/docs/pymodmilter.conf.example rename to pyquarantine/docs/pyquarantine.conf.example index e7e5d02..c062f75 100644 --- a/pymodmilter/docs/pymodmilter.conf.example +++ b/pyquarantine/docs/pyquarantine.conf.example @@ -1,4 +1,4 @@ -# This is an example /etc/pymodmilter.conf file. +# This is an example /etc/pyquarantine/pyquarantine.conf file. # Copy it into place before use. # # The file is in JSON format. @@ -176,14 +176,14 @@ # Notes: Path to a file which contains the html representation of the disclaimer. # Value: [ FILE_PATH ] # - "html_template": "/etc/pymodmilter/templates/disclaimer_html.template", + "html_template": "/etc/pyquarantine/templates/disclaimer_html.template", # Option: text_template # Type: String # Notes: Path to a file which contains the text representation of the disclaimer. # Value: [ FILE_PATH ] # - "text_template": "/etc/pymodmilter/templates/disclaimer_text.template", + "text_template": "/etc/pyquarantine/templates/disclaimer_text.template", # Option: error_policy # Type: String diff --git a/pymodmilter/docs/templates/disclaimer_html.template b/pyquarantine/docs/templates/disclaimer_html.template similarity index 100% rename from pymodmilter/docs/templates/disclaimer_html.template rename to pyquarantine/docs/templates/disclaimer_html.template diff --git a/pymodmilter/docs/templates/disclaimer_text.template b/pyquarantine/docs/templates/disclaimer_text.template similarity index 100% rename from pymodmilter/docs/templates/disclaimer_text.template rename to pyquarantine/docs/templates/disclaimer_text.template diff --git a/pyquarantine/docs/templates/notification.template b/pyquarantine/docs/templates/notification.template new file mode 100644 index 0000000..f41a4ad --- /dev/null +++ b/pyquarantine/docs/templates/notification.template @@ -0,0 +1,29 @@ + + +

Quarantine notification

+ + + + + + + + + + + + + + + + + + + + + +
Envelope-From:{ENVELOPE_FROM}
From:{FROM}
Envelope-To:{ENVELOPE_TO}
To:{TO}
Subject:{SUBJECT}

+

Preview of the original e-mail

+ {HTML_TEXT} + + diff --git a/pyquarantine/docs/templates/removed.png b/pyquarantine/docs/templates/removed.png new file mode 100644 index 0000000000000000000000000000000000000000..a5081b7f7c5d1a977fecaaca8076afd98b71283a GIT binary patch literal 2136 zcmZvec|6p67sr3Y2xZWyT!~y{xw13Dlr>8X8s(OK8%)N?jJ+@nYS1*6+_BSG>K2|X z7g-`}V;QncBfG{L5^gn?`*82`yk5^A&mZUeI_G@P`F{U-pU>-%>}<>-$Il)I003fX zVTuF*5cJS@=i@p&U3=~vU4ZaNb7P=l;N0?I0QNOP7y-bm$0znYcn)L!yB4?c03g_Y zWT5WAXWjt7yJl%>bR*n#E!QejwoEXwu?hS*%Jmc?0EU^WoQ>UY8~3?@rLQ|XJ65`2K!8{Ul7i5W5wsM94)}dkOfeDHgmLeQR5Am~2Dz&d>6gBw=!ET@yTP`o@1%n5R3s|H2M) zqrA#{Ic*drEL2oFm{Ws7%@>vC_;|?#0mhgtJ%p;O!4Rjvi?u_=4J9Gwq)5bwk`74` zBPgp=jG3Iq>AzhY9mRTBzh0?ar%V3<^d~+V)VMyX{#Nl4(~YO%YlD5*CRU6;NN$cDIf~FfYwFER72- zz0M!7dek)+1lMPE>Q+%}yM|Sja#9IZ6a<#N2gIgIr25u*70MUed&_+8Q6fwPDJ^={ zL@uX#S104W)%z8dbt2Qu(A2C6kmFH@J#}DpKy(#cp(-BI|2-1UPP-^{^Zl>o0tE?+ z+vCX>)^8}aL$1k{3!I-h6DGdJ6X=olf|yR!Fi+ zr$D>FcfKkeQb7T^^PaWzVh^>(1_p1Bo)RZx|v_~>n7X^Alsz(_5luF8A@mW z^SdJo%Wjem*&px-vzW?1;eh5RM(}v#-hI`y-TbVI6NC+}(@pD2pnCL5-ZA%TCRyux z_#fY7KQ!;=A2UzuR~g_>j)-E7486FDVQ%B(q+e>^zO1gnzC^SMbAB1=$+Q?lI~eqI zP1mVEfJf!pp5so(nR`EI;4#e4Qpsv-JB*)Y* z@CDQh?A$Yv_eyNb(4pt0-G;1Unc|Y;-sQrEtr1ow(pK`;9lfLoqcQqW$__0p(XvD~fHD zr>l;-H^XTz)k%&F`iIIvJ?U{p;^v6WM~de$7e4*%kiGj-RFe?jfCBA1*OY}J#OOE~qsjF$)-0|0Xn&--b-l$h@c57`` zZ?{%=a#ErL=fxy8ulvU>yVy@TlaxDy&1wsk@>`RARS+VK1kZQS(TmozxL{U|?!De_ zi?RlVHYl%&@mL53Z#PZniuxQx!N9exxTItz=s)%|EpGV-WHaukIc%um>zc(JDe27k zKlSQx(GpN%gGrZ+bp}K=>?8dP_jQtmQhPzdxCrrGl69@dp2L+j?0mEP#B9kr&hO-S zh~Wimih{W7cH!wsyxnG9`O=jWs`}M9)6ca}?+HRR7nN?8;ePZnVDXNp2H#`%5xrM^ z8lG$|rtf0x$xgXnO0H}cKT{-oJ;PDW)4&RrAGDH}`ZW#m z{LIVK)4cQMx<3q0mKFQ(jL9V;D-v2yrfZ9@@-wa@gm3w-rHMpu z%3o@=B5k;XzKfg#`Uq8^KyQvi`;i^djRb?58i1Eqoj|7g$ncW%${r zlgL=A9VdfI)wJ1P=peQc>O6jX)S$W2-_0AZ(|bzfNN{hlGal~y{oS;$FD72C#OTA7L(`QLS&A^dDJIw3Ww! zzIA+`N)(EB?`fZKg-3Nb>brDIE|*JDacVz(u`w$sE_wD%Y)uVa;!g;@));0x@6blb zq5REBBIl5q^CM2mtvNOVj<#?!z@&G|)k9!ax2u!!^pVzvRL>B&Jdbkw;faO&i K(+XqvxPJpND*fjG literal 0 HcmV?d00001 diff --git a/pymodmilter/mailer.py b/pyquarantine/mailer.py similarity index 92% rename from pymodmilter/mailer.py rename to pyquarantine/mailer.py index 51a913c..b5bea6c 100644 --- a/pymodmilter/mailer.py +++ b/pyquarantine/mailer.py @@ -1,15 +1,15 @@ -# PyMod-Milter is free software: you can redistribute it and/or modify +# pyquarantine is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # -# PyMod-Milter is distributed in the hope that it will be useful, +# pyquarantine is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License -# along with PyMod-Milter. If not, see . +# along with pyquarantine. If not, see . # import logging diff --git a/pymodmilter/misc/openrc/pymodmilter.confd b/pyquarantine/misc/openrc/pyquarantine-milter.confd similarity index 56% rename from pymodmilter/misc/openrc/pymodmilter.confd rename to pyquarantine/misc/openrc/pyquarantine-milter.confd index 6c5e71d..277e442 100644 --- a/pymodmilter/misc/openrc/pymodmilter.confd +++ b/pyquarantine/misc/openrc/pyquarantine-milter.confd @@ -1,8 +1,8 @@ -# /etc/conf.d/pymodmilter: config file for /etc/init.d/pymodmilter +# /etc/conf.d/pyquarantine: config file for /etc/init.d/pyquarantine # Start the daemon as the user. You can optionally append a group name here also. # USER="daemon" # USER="daemon:nobody" -# Optional parameters for pymodmilter +# Optional parameters for pyquarantine # MILTER_OPTS="" diff --git a/pymodmilter/misc/openrc/pymodmilter.initd b/pyquarantine/misc/openrc/pyquarantine-milter.initd similarity index 95% rename from pymodmilter/misc/openrc/pymodmilter.initd rename to pyquarantine/misc/openrc/pyquarantine-milter.initd index 70160aa..8bf697f 100755 --- a/pymodmilter/misc/openrc/pymodmilter.initd +++ b/pyquarantine/misc/openrc/pyquarantine-milter.initd @@ -4,7 +4,7 @@ user=${USER:-daemon} milter_opts="${MILTER_OPTS:-}" pidfile="/run/${RC_SVCNAME}.pid" -command="/usr/bin/pymodmilter" +command="/usr/bin/pyquarantine-milter" command_args="${milter_opts}" command_background=true command_user="${user}" diff --git a/pymodmilter/modify.py b/pyquarantine/modify.py similarity index 97% rename from pymodmilter/modify.py rename to pyquarantine/modify.py index 6cdfac0..f57e460 100644 --- a/pymodmilter/modify.py +++ b/pyquarantine/modify.py @@ -1,15 +1,15 @@ -# PyMod-Milter is free software: you can redistribute it and/or modify +# pyquarantine is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # -# PyMod-Milter is distributed in the hope that it will be useful, +# pyquarantine is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License -# along with PyMod-Milter. If not, see . +# along with pyquarantine. If not, see . # __all__ = [ @@ -30,8 +30,8 @@ from copy import copy from email.message import MIMEPart from email.policy import SMTPUTF8 -from pymodmilter import replace_illegal_chars -from pymodmilter.base import CustomLogger +from pyquarantine import replace_illegal_chars +from pyquarantine.base import CustomLogger class AddHeader: diff --git a/pymodmilter/notify.py b/pyquarantine/notify.py similarity index 97% rename from pymodmilter/notify.py rename to pyquarantine/notify.py index f1ef95e..56ca4ba 100644 --- a/pymodmilter/notify.py +++ b/pyquarantine/notify.py @@ -1,15 +1,15 @@ -# PyMod-Milter is free software: you can redistribute it and/or modify +# pyquarantine is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # -# PyMod-Milter is distributed in the hope that it will be useful, +# pyquarantine is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License -# along with PyMod-Milter. If not, see . +# along with pyquarantine. If not, see . # __all__ = [ @@ -30,8 +30,8 @@ from html import escape from os.path import basename from urllib.parse import quote -from pymodmilter.base import CustomLogger -from pymodmilter import mailer +from pyquarantine.base import CustomLogger +from pyquarantine import mailer class BaseNotification: diff --git a/pymodmilter/rule.py b/pyquarantine/rule.py similarity index 89% rename from pymodmilter/rule.py rename to pyquarantine/rule.py index a596e34..e0e003b 100644 --- a/pymodmilter/rule.py +++ b/pyquarantine/rule.py @@ -1,21 +1,21 @@ -# PyMod-Milter is free software: you can redistribute it and/or modify +# pyquarantine is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # -# PyMod-Milter is distributed in the hope that it will be useful, +# pyquarantine is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License -# along with PyMod-Milter. If not, see . +# along with pyquarantine. If not, see . # __all__ = ["Rule"] -from pymodmilter.action import Action -from pymodmilter.conditions import Conditions +from pyquarantine.action import Action +from pyquarantine.conditions import Conditions class Rule: diff --git a/pymodmilter/run.py b/pyquarantine/run.py similarity index 83% rename from pymodmilter/run.py rename to pyquarantine/run.py index 22548b7..4cbce22 100644 --- a/pymodmilter/run.py +++ b/pyquarantine/run.py @@ -1,15 +1,15 @@ -# PyMod-Milter is free software: you can redistribute it and/or modify +# pyquarantine is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # -# PyMod-Milter is distributed in the hope that it will be useful, +# pyquarantine is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License -# along with PyMod-Milter. If not, see . +# along with pyquarantine. If not, see . # __all__ = ["main"] @@ -20,25 +20,25 @@ import logging import logging.handlers import sys -from pymodmilter import mailer -from pymodmilter import ModifyMilter -from pymodmilter import __version__ as version -from pymodmilter.config import get_milter_config +from pyquarantine import mailer +from pyquarantine import ModifyMilter +from pyquarantine import __version__ as version +from pyquarantine.config import get_milter_config def main(): python_version = ".".join([str(v) for v in sys.version_info[0:3]]) python_version = f"{python_version}-{sys.version_info[3]}" - "Run PyMod-Milter." + "Run pyquarantine." parser = argparse.ArgumentParser( - description="PyMod milter daemon", + description="pyquarantine-milter daemon", formatter_class=lambda prog: argparse.HelpFormatter( prog, max_help_position=45, width=140)) parser.add_argument( "-c", "--config", help="Config file to read.", - default="/etc/pymodmilter/pymodmilter.conf") + default="/etc/pyquarantine/pyquarantine.conf") parser.add_argument( "-s", @@ -125,10 +125,10 @@ def main(): sysloghandler = logging.handlers.SysLogHandler( address="/dev/log", facility=logging.handlers.SysLogHandler.LOG_MAIL) sysloghandler.setFormatter( - logging.Formatter("pymodmilter: %(message)s")) + logging.Formatter("pyquarantine: %(message)s")) root_logger.addHandler(sysloghandler) - logger.info("pymodmilter starting") + logger.info("pyquarantine-milter starting") # register milter factory class Milter.factory = ModifyMilter @@ -139,13 +139,13 @@ def main(): rc = 0 try: - Milter.runmilter("pymodmilter", socketname=socket, timeout=600) + Milter.runmilter("pyquarantine", socketname=socket, timeout=600) except Milter.milter.error as e: logger.error(e) rc = 255 mailer.queue.put(None) - logger.info("pymodmilter stopped") + logger.info("pyquarantine-milter stopped") sys.exit(rc) diff --git a/pymodmilter/storage.py b/pyquarantine/storage.py similarity index 97% rename from pymodmilter/storage.py rename to pyquarantine/storage.py index 9dd54af..597e2dd 100644 --- a/pymodmilter/storage.py +++ b/pyquarantine/storage.py @@ -1,15 +1,15 @@ -# PyMod-Milter is free software: you can redistribute it and/or modify +# pyquarantine is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # -# PyMod-Milter is distributed in the hope that it will be useful, +# pyquarantine is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License -# along with PyMod-Milter. If not, see . +# along with pyquarantine. If not, see . # __all__ = [ @@ -27,10 +27,10 @@ from datetime import datetime from glob import glob from time import gmtime -from pymodmilter.base import CustomLogger -from pymodmilter.conditions import Conditions -from pymodmilter.config import ActionConfig -from pymodmilter.notify import Notify +from pyquarantine.base import CustomLogger +from pyquarantine.conditions import Conditions +from pyquarantine.config import ActionConfig +from pyquarantine.notify import Notify class BaseMailStorage: diff --git a/pymodmilter/whitelist.py b/pyquarantine/whitelist.py similarity index 97% rename from pymodmilter/whitelist.py rename to pyquarantine/whitelist.py index ca34851..34a923a 100644 --- a/pymodmilter/whitelist.py +++ b/pyquarantine/whitelist.py @@ -1,15 +1,15 @@ -# PyMod-Milter is free software: you can redistribute it and/or modify +# pyquarantine is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # -# PyMod-Milter is distributed in the hope that it will be useful, +# pyquarantine is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License -# along with PyMod-Milter. If not, see . +# along with pyquarantine. If not, see . # __all__ = [ diff --git a/setup.cfg b/setup.cfg index f3d2f8a..90d059a 100644 --- a/setup.cfg +++ b/setup.cfg @@ -1,2 +1,2 @@ [metadata] -version = attr: pymodmilter.__version__ +version = attr: pyquarantine.__version__ diff --git a/setup.py b/setup.py index f9d6689..a27fe09 100644 --- a/setup.py +++ b/setup.py @@ -4,14 +4,14 @@ def read_file(fname): with open(fname, 'r') as f: return f.read() -setup(name = "pymodmilter", +setup(name = "pyquarantine", author = "Thomas Oettli", author_email = "spacefreak@noop.ch", description = "A pymilter based sendmail/postfix pre-queue filter.", license = "GPL 3", keywords = "header quarantine milter", - url = "https://github.com/spacefreak86/pymodmilter", - packages = ["pymodmilter"], + url = "https://github.com/spacefreak86/pyquarantine", + packages = ["pyquarantine"], long_description = read_file("README.md"), long_description_content_type = "text/markdown", classifiers = [ @@ -28,20 +28,23 @@ setup(name = "pymodmilter", include_package_data = True, entry_points = { "console_scripts": [ - "pymodmilter=pymodmilter.run:main" + "pyquarantine-milter=pyquarantine.run:main", + "pyquarantine=pyquarantine.run:main", ] }, data_files = [ ( - "/etc/pymodmilter", + "/etc/pyquarantine", [ - "pymodmilter/docs/pymodmilter.conf.example" + "pyquarantine/docs/pyquarantine.conf.example" ] ), ( - "/etc/pymodmilter/templates", + "/etc/pyquarantine/templates", [ - "pymodmilter/docs/templates/disclaimer_html.template", - "pymodmilter/docs/templates/disclaimer_text.template" + "pyquarantine/docs/templates/disclaimer_html.template", + "pyquarantine/docs/templates/disclaimer_text.template", + "pyquarantine/docs/templates/notification.template", + "pyquarantine/docs/templates/removed.png" ] ) ], diff --git a/test-pymodmilter b/test-pymodmilter deleted file mode 100755 index fbe25a8..0000000 --- a/test-pymodmilter +++ /dev/null @@ -1,9 +0,0 @@ -#!/usr/bin/env python - -import sys -import pymodmilter.run - -if __name__ == '__main__': - sys.exit( - pymodmilter.run.main() - )