Deepcopy writeable config file
This commit is contained in:
parent
05172328d5
commit
6a08551402
1 changed files with 6 additions and 3 deletions
|
@ -2,7 +2,7 @@
|
||||||
# WDK (Web Key Directory) Manager: Facilitates discovery of keys by third-parties
|
# 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
|
# 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
|
from cryptography.hazmat.primitives import hashes
|
||||||
|
|
||||||
env = utils.load_environment()
|
env = utils.load_environment()
|
||||||
|
@ -131,20 +131,23 @@ def parse_wkd_list():
|
||||||
config = {}
|
config = {}
|
||||||
except:
|
except:
|
||||||
config = {}
|
config = {}
|
||||||
|
|
||||||
|
writeable = copy.deepcopy(config)
|
||||||
for u, k in config.items():
|
for u, k in config.items():
|
||||||
try:
|
try:
|
||||||
key = email_compatible_with_key(u, k)
|
key = email_compatible_with_key(u, k)
|
||||||
# Key is compatible
|
# Key is compatible
|
||||||
|
|
||||||
index = []
|
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)):
|
for i in range(0, len(key.uids)):
|
||||||
if key.uids[i].email == u:
|
if key.uids[i].email == u:
|
||||||
index.append(i)
|
index.append(i)
|
||||||
uidlist.append((u, k, index))
|
uidlist.append((u, k, index))
|
||||||
except:
|
except:
|
||||||
config.pop(u)
|
writeable.pop(u)
|
||||||
removed.append((u, k))
|
removed.append((u, k))
|
||||||
# Shove the updated configuration back in the file
|
# Shove the updated configuration back in the file
|
||||||
wkdfile.truncate(0)
|
wkdfile.truncate(0)
|
||||||
wkdfile.write(rtyaml.dump(config))
|
wkdfile.write(rtyaml.dump(writeable))
|
||||||
return (removed, uidlist)
|
return (removed, uidlist)
|
||||||
|
|
Loading…
Reference in a new issue