Merge commit 'dkg/master'
[monkeysphere.git] / src / share / common
index 96fea7721ac3fdc31e7b922b82871a1cf4c4acda..d185fddf70cf142aab145ec2e7013eef2fd66b44 100644 (file)
@@ -1144,3 +1144,14 @@ process_authorized_user_ids() {
 
     update_authorized_keys "${userIDs[@]}"
 }
+
+# takes a gpg key or keys on stdin, and outputs a list of
+# fingerprints, one per line:
+list_primary_fingerprints() {
+    local file="$1"
+    local fake=$(msmktempdir)
+    GNUPGHOME="$fake" gpg --no-tty --quiet --import
+    GNUPGHOME="$fake" gpg --with-colons --fingerprint --list-keys | \
+       awk -F: '/^fpr:/{ print $10 }'
+    rm -rf "$fake"
+}