summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorJoey Hess <joeyh@joeyh.name>2016-09-14 13:25:12 -0400
committerJoey Hess <joeyh@joeyh.name>2016-09-14 13:25:55 -0400
commit8d1185c3884f8125cedf9c4c8060cb5d360e9ef4 (patch)
tree98c4d23ffcd5a316f397b5d9fb0d61d4bac2a888
parent57a3a1725f93541f8eb6ddbdeb429fbc37bb4025 (diff)
downloadkeysafe-8d1185c3884f8125cedf9c4c8060cb5d360e9ef4.tar.gz
Another fix to gpg secret key list parser.
gpg2 2.1.15 seems to have added some new fields to the --with-colons --list-secret-keys output. These include "fpr" and "grp", and come before the "uid" line. So, the parser was giving up before it saw the name. Fix by continueing to look for the uid line until the next "sec" line.
-rw-r--r--CHANGELOG1
-rw-r--r--Gpg.hs4
2 files changed, 4 insertions, 1 deletions
diff --git a/CHANGELOG b/CHANGELOG
index 7f64e2d..b3c7f06 100644
--- a/CHANGELOG
+++ b/CHANGELOG
@@ -7,6 +7,7 @@ keysafe (0.20160832) UNRELEASED; urgency=medium
* Server-side rate limiting and DOS protection.
* server: Added --months-to-fill-half-disk option, defaulting to 12.
* Several new dependencies.
+ * Another fix to gpg secret key list parser.
-- Joey Hess <id@joeyh.name> Thu, 01 Sep 2016 11:42:27 -0400
diff --git a/Gpg.hs b/Gpg.hs
index 9a743f0..4522cfb 100644
--- a/Gpg.hs
+++ b/Gpg.hs
@@ -42,8 +42,10 @@ listSecretKeys = map mk . parse . lines <$> readProcess "gpg"
parse = extract [] Nothing . map (splitOn ":")
extract c (Just keyid) (("uid":_:_:_:_:_:_:_:_:userid:_):rest) =
extract ((userid, keyid):c) Nothing rest
- extract c (Just keyid) rest =
+ extract c (Just keyid) rest@(("sec":_):_) =
extract (("", keyid):c) Nothing rest
+ extract c (Just keyid) (_:rest) =
+ extract c (Just keyid) rest
extract c _ [] = c
extract c _ (("sec":_:_:_:keyid:_):rest) =
extract c (Just keyid) rest