summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDaniel Kahn Gillmor <dkg@fifthhorseman.net>2012-09-11 16:02:11 -0400
committerDaniel Kahn Gillmor <dkg@fifthhorseman.net>2012-09-11 16:02:11 -0400
commit8fe76e1bb054e843aa57715d01ab629953eaa419 (patch)
tree4d5b0849cb65dded77b19ff5eb4fc6f276925bef
parent8ce435fb4fcdf055db0b81007579ea76c003cdd6 (diff)
fetch all keys instead of the first 5 (and work better with gpg 2.0.19, which apparently does not retrieve keys from gpg --search if the --batch argument is also present)
-rw-r--r--Changelog4
-rw-r--r--src/share/common25
2 files changed, 23 insertions, 6 deletions
diff --git a/Changelog b/Changelog
index 96a60cf..48956dd 100644
--- a/Changelog
+++ b/Changelog
@@ -2,8 +2,10 @@ monkeysphere (0.36~pre) unstable; urgency=low
* keytrans no longer confuses user IDs across different keys (closes MS
#2682)
+ * fetch all available keys from keyserver instead of first 5 (closes MS
+ #1046)
- -- Daniel Kahn Gillmor <dkg@fifthhorseman.net> Mon, 20 Dec 2010 19:31:30 -0500
+ -- Daniel Kahn Gillmor <dkg@fifthhorseman.net> Tue, 11 Sep 2012 15:45:51 -0400
monkeysphere (0.35) upstream;
diff --git a/src/share/common b/src/share/common
index 87cef61..f9be05a 100644
--- a/src/share/common
+++ b/src/share/common
@@ -595,11 +595,10 @@ is_gpg_version_greater_equal() {
}
# retrieve all keys with given user id from keyserver
-# FIXME: need to figure out how to retrieve all matching keys
-# (not just first N (5 in this case))
gpg_fetch_userid() {
local returnCode=0
local userID
+ local foundkeyids
if [ "$CHECK_KEYSERVER" != 'true' ] ; then
return 0
@@ -608,16 +607,32 @@ gpg_fetch_userid() {
userID="$1"
log verbose " checking keyserver $KEYSERVER... "
- echo 1,2,3,4,5 | \
+ foundkeyids="$(echo | \
gpg --quiet --batch --with-colons \
--command-fd 0 --keyserver "$KEYSERVER" \
- --search ="$userID" &>/dev/null
+ --search ="$userID" 2>/dev/null)"
returnCode="$?"
if [ "$returnCode" != 0 ] ; then
log error "Failure ($returnCode) searching keyserver $KEYSERVER for user id '$userID'"
+ else
+ log debug " keyserver raw output:
+-----
+$foundkeyids
+-----"
+ foundkeyids="$(printf "%s" "$foundkeyids" | grep '^pub:' | cut -f2 -d: | sed 's/^/0x/')"
+ log verbose " Found keyids on keyserver: $(printf "%s" "$foundkeyids" | tr '\n' ' ')"
+ if [ -n "$foundkeyids" ]; then
+ echo | gpg --quiet --batch --with-colons \
+ --command-fd 0 --keyserver "$KEYSERVER" \
+ --recv-keys $foundkeyids &>/dev/null
+ returnCode="$?"
+ if [ "$returnCode" != 0 ] ; then
+ log error "Failure ($returnCode) receiving keyids ($foundkeyids) from keyserver $KEYSERVER"
+ fi
+ fi
fi
-
+
return "$returnCode"
}