aboutsummaryrefslogtreecommitdiff
path: root/src/mailman_pgp/model
diff options
context:
space:
mode:
authorJ08nY2017-08-10 18:32:22 +0200
committerJ08nY2017-08-10 18:32:22 +0200
commita973479205cec0d5fbf162030906ce405b3698b2 (patch)
treea4b84cdc6988ab953ba6f99dae9f920d3522c39f /src/mailman_pgp/model
parent5fc418fe1be80e1fe8170919c0caf1dae63d4275 (diff)
downloadmailman-pgp-a973479205cec0d5fbf162030906ce405b3698b2.tar.gz
mailman-pgp-a973479205cec0d5fbf162030906ce405b3698b2.tar.zst
mailman-pgp-a973479205cec0d5fbf162030906ce405b3698b2.zip
Diffstat (limited to 'src/mailman_pgp/model')
-rw-r--r--src/mailman_pgp/model/fs_key.py2
-rw-r--r--src/mailman_pgp/model/list.py15
-rw-r--r--src/mailman_pgp/model/tests/test_list.py11
3 files changed, 23 insertions, 5 deletions
diff --git a/src/mailman_pgp/model/fs_key.py b/src/mailman_pgp/model/fs_key.py
index b72c76f..3ba9aca 100644
--- a/src/mailman_pgp/model/fs_key.py
+++ b/src/mailman_pgp/model/fs_key.py
@@ -108,7 +108,7 @@ class FSKey:
def shred(self):
try:
size = getsize(self.key_path)
- for _ in range(10):
+ for _ in range(50):
with open(self.key_path, 'wb') as f:
data = urandom(size)
f.write(data)
diff --git a/src/mailman_pgp/model/list.py b/src/mailman_pgp/model/list.py
index 13d4430..84cb3bc 100644
--- a/src/mailman_pgp/model/list.py
+++ b/src/mailman_pgp/model/list.py
@@ -20,6 +20,7 @@ from mailman.database.types import Enum, SAUnicode
from mailman.interfaces.action import Action
from mailman.interfaces.listmanager import IListManager, ListDeletingEvent
from mailman.interfaces.member import MemberRole
+from os import system
from public import public
from sqlalchemy import Boolean, Column, Integer
from sqlalchemy.orm import reconstructor
@@ -154,11 +155,17 @@ class PGPMailingList(Base):
@classhandler.handler(ListDeletingEvent)
def on_delete(event):
shred = config.get_value('keypairs', 'shred')
+ shred_command = config.get_value('keypairs', 'shred_command')
+ delete = config.get_value('keypairs', 'delete')
pgp_list = PGPMailingList.for_list(event.mailing_list)
if pgp_list:
with transaction() as session:
- if shred:
- pgp_list.fs_key.shred()
- else:
- pgp_list.fs_key.delete()
+ if delete:
+ if shred:
+ if shred_command:
+ system(shred_command + ' ' + pgp_list.key_path)
+ else:
+ pgp_list.fs_key.shred()
+ else:
+ pgp_list.fs_key.delete()
session.delete(pgp_list)
diff --git a/src/mailman_pgp/model/tests/test_list.py b/src/mailman_pgp/model/tests/test_list.py
index aa07a79..9bb0a4e 100644
--- a/src/mailman_pgp/model/tests/test_list.py
+++ b/src/mailman_pgp/model/tests/test_list.py
@@ -50,6 +50,17 @@ class TestPGPMailingList(TestCase):
getUtility(IListManager).delete(self.mlist)
self.assertFalse(exists(key_path))
+ def test_shred_key_command(self):
+ self.addCleanup(config.set, 'keypairs', 'shred_command', '')
+ config.set('keypairs', 'shred_command', 'shred')
+ key_path = PGPMailingList.for_list(self.mlist).key_path
+ with open(key_path, 'rb') as f:
+ before = f.read()
+ getUtility(IListManager).delete(self.mlist)
+ with open(key_path, 'rb') as f:
+ after = f.read()
+ self.assertNotEqual(before, after)
+
def test_delete_key(self):
self.addCleanup(config.set, 'keypairs', 'shred', 'yes')
config.set('keypairs', 'shred', 'no')