summaryrefslogtreecommitdiff
path: root/security/gpg2dot/files
diff options
context:
space:
mode:
authoratatat <atatat>2004-01-21 04:04:55 +0000
committeratatat <atatat>2004-01-21 04:04:55 +0000
commit8b27adecc497d7cf3f4bb328d2a9b9fd620b7277 (patch)
tree2d0ad288cebcb1eb351fad0420f9085a2848dc83 /security/gpg2dot/files
parenta8f99e8a2362a25cbe04d3c3804f68dbb098975c (diff)
downloadpkgsrc-8b27adecc497d7cf3f4bb328d2a9b9fd620b7277.tar.gz
This simple perl script takes the output of gpg --list-keys --verbose,
which lists all the keys in your public key ring, along with all their signatures, and converts it to a di-graph in "dot" language form. The graphviz package can turn the description into a graph you can look at to see who has signed whose key, or how far it is from your key to someone in Reykjavik, etc.
Diffstat (limited to 'security/gpg2dot/files')
-rw-r--r--security/gpg2dot/files/gpg2dot.pl77
1 files changed, 77 insertions, 0 deletions
diff --git a/security/gpg2dot/files/gpg2dot.pl b/security/gpg2dot/files/gpg2dot.pl
new file mode 100644
index 00000000000..6cd62881c52
--- /dev/null
+++ b/security/gpg2dot/files/gpg2dot.pl
@@ -0,0 +1,77 @@
+#!@PREFIX@/bin/perl
+
+# ----------------------------------------------------------------------------
+# "THE BEER-WARE LICENSE" (Revision 42):
+# <atatat@NetBSD.ORG> wrote this file. As long as you retain this notice you
+# can do whatever you want with this stuff. If we meet some day, and you think
+# this stuff is worth it, you can buy me a beer in return.
+#
+# Andrew Brown
+# ----------------------------------------------------------------------------
+
+$date = localtime();
+
+$sg = "";
+open(GPG, "gpg --list-keys --verbose 2>/dev/null |");
+while (<GPG>) {
+ chomp;
+ if (/^(pub) +(\S+)\s+(\S+)\s+(.+\S)/ ||
+ /^(uid) +\s+(.+\S)/) {
+ if ($1 eq "pub") {
+ ($lkeyid, $date, $kuid) = ($2, $3, $4);
+ }
+ else {
+ ($kuid) = ($2);
+ }
+ $kuid =~ s/\"/\\\"/g;
+ ($keyid = $lkeyid) =~ s:.*/::;
+ next if ($kuid !~ /netbsd.org/i);
+ $kuid{$keyid} = $kuid;
+ $label{$keyid} = "$lkeyid - $date\\n$kuid";
+ }
+ elsif (/^sig (.{7}) (\S+)\s+(\S+)\s+(.+\S)/) {
+ ($skeyid, $date, $suid) = ($2, $3, $4);
+ next if ($kuid !~ /netbsd.org/i ||
+ $suid =~ /id not found/ ||
+ $skeyid eq $keyid);
+ push(@isigs, "$keyid $skeyid $date $suid");
+ }
+}
+
+foreach (@isigs) {
+ ($keyid, $skeyid, $date, $suid) = split(/ /, $_, 4);
+ next if (!$kuid{$keyid} || !$kuid{$skeyid});
+ push(@sigs, sprintf("\"%s\" -> \"%s\";\t// %s -> %s\n",
+ $skeyid, $keyid, $kuid{$skeyid}, $kuid{$keyid}));
+ $signer{$skeyid} = "yes";
+ $signed{$keyid} = "yes";
+}
+
+foreach (keys %label) {
+ next if (!$signer{$_} && !$signed{$_});
+ push(@keys, sprintf("\"%s\" [label=\"%s\"];\n",
+ $_, $label{$_}));
+}
+
+@sigs = uniq(sort(@sigs));
+
+$" = "";
+print(<<"EOF")
+digraph "gpg" {
+label = "gpg signature graph, $date";
+
+@keys
+@sigs
+}
+EOF
+ ;
+
+sub uniq {
+ my (@i) = @_;
+ my (@o);
+ push(@o, shift(@i));
+ foreach (@i) {
+ push(@o, $_) if ($o[-1] ne $_);
+ }
+ @o;
+}