3
3
# caff -- CA - Fire and Forget
4
# $Id: caff 429 2009-06-06 15:47:07Z thijs $
4
# $Id: caff 439 2009-08-30 10:12:07Z thialme-guest $
6
6
# Copyright (c) 2004, 2005, 2006 Peter Palfrader <peter@palfrader.org>
7
7
# Copyright (c) 2005, 2006 Christoph Berg <cb@df7cb.de>
323
323
use GnuPG::Interface;
326
my $REVISION = '$Rev: 429 $';
326
my $REVISION = '$Rev: 439 $';
327
327
my ($REVISION_NUMER) = $REVISION =~ /(\d+)/;
328
328
my $VERSION = "0.0.0.$REVISION_NUMER";
332
# Display an error message on STDERR and then exit.
334
# @param $exitcode exit code status to use to end the program
335
# @param $line error message to display on STDERR
338
my ($exitcode, $line) = @_;
339
print "[ERROR] $line\n";
891
902
return $signed_by_me;
906
# Check the local user keys.
908
# This function checks if the keyids defined through the --local-user
909
# command line option or set in .caffrc are valid and known to be one of the
910
# keyids listed in ./caffrc. The last check ensure we have those keyids
911
# available in the caff's gnupghome directory.
913
# @return an array containing the local user keys\n
914
# (undef) if no key has been specified
916
sub get_local_user_keys()
921
# No user-defined key id has been specified by the user, no need for
923
if (!$CONFIG{'local-user'}) {
927
# Parse the list of keys
928
if (ref($CONFIG{'local-user'})) {
929
@key_list = @{$CONFIG{'local-user'}};
932
@key_list = split /\s*,\s*/, $CONFIG{'local-user'};
935
# Check every key defined by the user...
936
for my $user_key (@key_list) {
938
$user_key =~ s/^0x//i;
939
$user_key = uc($user_key);
941
unless ($user_key =~ m/^([A-F0-9]{8}|[A-F0-9]{16}|[A-F0-9]{40})$/) {
942
mywarn "Local-user $user_key is not a valid keyid.";
946
unless (grep (/$user_key$/, @{$CONFIG{'keyid'}})) {
947
mywarn "Local-user $user_key is not defined as one of your keyid in ./caffrc (it will not be used).";
951
push (@local_user, $user_key);
954
# If no local-user key are valid, there is no need to go further
955
unless (defined $local_user[0]) {
956
myerror (1, "None of the local-user keys seem to be known as a keyid listed in ./caffrc.");
895
963
###################
896
964
# argument handling
1074
1142
$CONFIG{'no-sign'} = ! ask("Continue with signing?", 1);
1077
unless ($CONFIG{'no-sign'}) {
1079
if ($CONFIG{'local-user'}) {
1080
if (ref($CONFIG{'local-user'})) {
1081
@local_user = @{$CONFIG{'local-user'}};
1083
@local_user = split /\s*,\s*/, $CONFIG{'local-user'};
1085
foreach (@local_user) {
1087
unless (/^([A-F0-9]{8}|[A-F0-9]{16}|[A-F0-9]{40})$/i) {
1088
print STDERR "Local-user $_ is not a keyid.\n";
1094
@local_user = (undef);
1145
unless ($CONFIG{'no-sign'})
1147
my @local_user = &get_local_user_keys();
1097
1149
info("Sign the following keys according to your policy, then exit gpg with 'save' after signing each key");
1098
1150
for my $keyid (@keyids_ok) {