summaryrefslogtreecommitdiff
path: root/src/mailman_pgp/commands/eml_key.py
diff options
context:
space:
mode:
authorJ08nY2017-07-15 17:11:58 +0200
committerJ08nY2017-07-15 17:11:58 +0200
commitd88a146b547d047c60e4bf3b26e7d5a0bd1b4ccb (patch)
tree52ad990d4bae221081f5b983fe74d039d5ba9a1b /src/mailman_pgp/commands/eml_key.py
parent9aba062ddfa74f3064606fffaa5d2aa8d789dc95 (diff)
downloadmailman-pgp-d88a146b547d047c60e4bf3b26e7d5a0bd1b4ccb.tar.gz
mailman-pgp-d88a146b547d047c60e4bf3b26e7d5a0bd1b4ccb.tar.zst
mailman-pgp-d88a146b547d047c60e4bf3b26e7d5a0bd1b4ccb.zip
Diffstat (limited to 'src/mailman_pgp/commands/eml_key.py')
-rw-r--r--src/mailman_pgp/commands/eml_key.py31
1 files changed, 29 insertions, 2 deletions
diff --git a/src/mailman_pgp/commands/eml_key.py b/src/mailman_pgp/commands/eml_key.py
index 1b6dc9f..deb396a 100644
--- a/src/mailman_pgp/commands/eml_key.py
+++ b/src/mailman_pgp/commands/eml_key.py
@@ -16,8 +16,10 @@
# this program. If not, see <http://www.gnu.org/licenses/>.
"""The key email command."""
+from email.mime.text import MIMEText
from email.utils import parseaddr
+from mailman.email.message import UserNotification
from mailman.interfaces.command import ContinueProcessing, IEmailCommand
from mailman.interfaces.pending import IPendings
from mailman.interfaces.subscriptions import ISubscriptionManager
@@ -29,6 +31,7 @@ from zope.interface import implementer
from mailman_pgp.database import transaction
from mailman_pgp.model.address import PGPAddress
from mailman_pgp.model.list import PGPMailingList
+from mailman_pgp.pgp.mime import MIMEWrapper
from mailman_pgp.pgp.wrapper import PGPWrapper
from mailman_pgp.workflows.base import CONFIRM_REQUEST
from mailman_pgp.workflows.key_change import (CHANGE_CONFIRM_REQUEST,
@@ -193,15 +196,39 @@ def _cmd_sign(pgp_list, mlist, msg, msgdata, arguments, results):
pass
+def _cmd_receive(pgp_list, mlist, msg, msgdata, arguments, results):
+ if len(arguments) != 1:
+ print('Extraneous argument/s: ' + ','.join(arguments[1:]),
+ file=results)
+ return ContinueProcessing.no
+
+ email = _get_email(msg)
+ if not email:
+ print('No email to send list public key.', file=results)
+ return ContinueProcessing.no
+
+ msg = UserNotification(email, mlist.request_address,
+ '{} public key'.format(mlist.fqdn_listname))
+ msg.set_type('multipart/mixed')
+ msg['MIME-Version'] = '1.0'
+ msg.attach(MIMEText('Here is the public key you requested.'))
+ wrapped = MIMEWrapper(msg)
+ msg = wrapped.attach_key(pgp_list.pubkey)
+
+ msg.send(mlist)
+ return ContinueProcessing.yes
+
+
SUBCOMMANDS = {
'set': _cmd_set,
'confirm': _cmd_confirm,
'change': _cmd_change,
'revoke': _cmd_revoke,
- 'sign': _cmd_sign
+ 'sign': _cmd_sign,
+ 'receive': _cmd_receive
}
-ARGUMENTS = '<' + '|'.join(SUBCOMMANDS.keys()) + '>'
+ARGUMENTS = '<' + '|'.join(SUBCOMMANDS) + '>'
@public