#! /usr/bin/perl use strict; use warnings; use Getopt::Long; use Pod::Usage; use OpenSSL::Query::REST; use HTML::Entities; my %options = (); GetOptions( \%options, 'name|n', # Show name 'email|e', # Show email 'locale|l', # Show locale 'pgp|p', # Show PGP key ID 'activity|a', # Show whether person is active 'title|t=s', # Title of the resulting table 'help|?', # Help 'man', # Full manual ) or pod2usage(2); pod2usage(1) unless $options{title}; pod2usage(1) unless ($options{name} || $options{email} || $options{locale} || $options{activity} || $options{pgp}); pod2usage(1) if $options{help}; pod2usage(-exitval => 0, -verbose => 2) if $options{man}; my $query = OpenSSL::Query->new(); my %data = (); # Indexed by name, value is a hash table of vals foreach my $groupname (@ARGV) { my @members = $query->members_of($groupname); foreach my $ids (@members) { my $name = (grep m|\s|, @$ids)[0]; my $email = (grep m|\@openssl\.org$|, @$ids)[0]; my $locale = $query->find_person_tag($email, 'country'); my $pgpid = $query->find_person_tag($email, 'pgp'); $data{$name} = { email => $email, locale => $locale, pgpid => $pgpid, active => !!($groupname !~ m|-inactive$|), emeritus => !!($groupname =~ m|-emeritus$|) }; } } my @columns = (); push @columns, 'Name' if $options{name}; push @columns, 'Email' if $options{email}; push @columns, 'Locale' if $options{locale}; push @columns, 'PGP Key ID' if $options{pgp}; print "\n"; print " \n"; print join(" \n", map {" \n"} @columns); print " \n"; foreach my $key (sort {mk_sortable($a) cmp mk_sortable($b)} keys %data) { my $pgpurl = $data{$key}->{pgpid} if $options{pgp}; $pgpurl =~ s|\s+||g if $pgpurl; $pgpurl = "https://keys.openpgp.org/search?q=$pgpurl" if $pgpurl; my @columndata = (); push @columndata, join('', $data{$key}->{active} ? "" : "", encode_entities($key), $data{$key}->{active} ? "" : " (I)", $data{$key}->{emeritus} ? " (OMC Emeritus)" : "") if $options{name}; push @columndata, "$data{$key}->{email}" if $options{email}; push @columndata, $data{$key}->{locale} if $options{locale}; push @columndata, $data{$key}->{pgpid} ? "$data{$key}->{pgpid}" : ' ' if $options{pgp}; print " \n"; print join(" \n", map {" \n"} @columndata); print " \n"; } print "
  $_
  $_
\n"; sub mk_sortable { my $name = shift; # Peel off any title $name =~ s/(Dr|Mr|Mrs|Miss)\.?\s+//; # Split into first+middle name and last names and flip them over with # a comma between. # We work with the assumption that the middle name, if included, is # given as a single letter followed by a possible period. $name = ($name =~ m|^(\S+(?:\s\S\.?)?)\s+(.*)$|, "$2, $1"); return $name; }