From 6a0855140233446e9a9af5daa7ddcf75c69a983d Mon Sep 17 00:00:00 2001 From: David Duque Date: Tue, 8 Dec 2020 22:30:43 +0000 Subject: [PATCH] Deepcopy writeable config file --- management/wkd.py | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/management/wkd.py b/management/wkd.py index 1b5f20c..45c6b86 100644 --- a/management/wkd.py +++ b/management/wkd.py @@ -2,7 +2,7 @@ # WDK (Web Key Directory) Manager: Facilitates discovery of keys by third-parties # Current relevant documents: https://tools.ietf.org/id/draft-koch-openpgp-webkey-service-11.html -import pgp, utils, rtyaml, mailconfig +import pgp, utils, rtyaml, mailconfig, copy from cryptography.hazmat.primitives import hashes env = utils.load_environment() @@ -131,20 +131,23 @@ def parse_wkd_list(): config = {} except: config = {} + + writeable = copy.deepcopy(config) for u, k in config.items(): try: key = email_compatible_with_key(u, k) # Key is compatible index = [] + writeable[u] = key.fpr # Swap with the full-length fingerprint (if somehow this was changed by hand) for i in range(0, len(key.uids)): if key.uids[i].email == u: index.append(i) uidlist.append((u, k, index)) except: - config.pop(u) + writeable.pop(u) removed.append((u, k)) # Shove the updated configuration back in the file wkdfile.truncate(0) - wkdfile.write(rtyaml.dump(config)) + wkdfile.write(rtyaml.dump(writeable)) return (removed, uidlist)