/
get_gpg_keys.coretag
46 lines (41 loc) · 1.3 KB
/
get_gpg_keys.coretag
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
# Copyright 2002-2007 Interchange Development Group and others
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version. See the LICENSE file for details.
#
# $Id: get_gpg_keys.coretag,v 1.5 2007-03-30 23:40:54 pajamian Exp $
UserTag get-gpg-keys Order dir
UserTag get-gpg-keys addAttr
UserTag get-gpg-keys Version $Revision: 1.5 $
UserTag get-gpg-keys Routine <<EOR
sub {
my ($dir, $opt) = @_;
my $gpgexe = $Global::Variable->{GPG_PATH} || 'gpg';
my $flags = "--list-keys";
if($dir) {
$dir = filter_value('filesafe', $dir);
$flags .= "--homedir $dir";
}
#::logDebug("gpg_get_keys flags=$flags");
open(GPGIMP, "$gpgexe $flags |")
or die "Can't fork: $!";
my $fmt = $opt->{long} ? "%s=%s (date %s, id %s)" : "%s=%s";
my @out;
while(<GPGIMP>) {
next unless s/^pub\s+//;
my ($id, $date, $text) = split /\s+/, $_, 3;
$id =~ s:.*?/::;
$text = ::errmsg( $fmt, $id, $text, $date, $id );
$text =~ s/</</g;
$text =~ s/>/>/g;
$text =~ s/,/,/g;
push @out, $text;
}
close GPGIMP;
my $joiner = $opt->{joiner} || ",\n";
unshift @out, "=none" if $opt->{none};
return join($joiner, @out);
}
EOR