From ace9c451be7c23646639d774ac1e858928133c32 Mon Sep 17 00:00:00 2001 From: Norbert Preining Date: Thu, 5 May 2016 02:14:49 +0000 Subject: tlmgr: add tlmgr key (key management) action git-svn-id: svn://tug.org/texlive/trunk@40896 c570f23f-e606-0410-a88d-b1316a301751 --- Master/texmf-dist/scripts/texlive/tlmgr.pl | 114 +++++++++++++++++++++++++++++ 1 file changed, 114 insertions(+) (limited to 'Master/texmf-dist') diff --git a/Master/texmf-dist/scripts/texlive/tlmgr.pl b/Master/texmf-dist/scripts/texlive/tlmgr.pl index be6c9251153..2162a198120 100755 --- a/Master/texmf-dist/scripts/texlive/tlmgr.pl +++ b/Master/texmf-dist/scripts/texlive/tlmgr.pl @@ -214,6 +214,10 @@ my %action_specification = ( "run-post" => 1, "function" => \&action_install }, + "key" => { + "run-post" => 0, + "function" => \&action_key + }, "option" => { "run-post" => 1, "function" => \&action_option @@ -5629,6 +5633,92 @@ sub texconfig_conf_mimic { } } + +# Action key +# +# general key management +# +# tlmgr key list +# tlmgr key add +# tlmgr key delete +sub action_key { + my $arg = shift @ARGV; + + $arg = lc($arg); + + + if (!defined($arg)) { + tlwarn("missing arguments to action `key'\n"); + return $F_ERROR; + + } elsif ($arg =~ /^(add|delete|list)$/) { + handle_gpg_config_settings(); + if (!$::gpg) { + tlwarn("gnupg is not found or setup, cannot continue with action `key'\n"); + return $F_ERROR; + } + chomp (my $TEXMFSYSCONFIG = `kpsewhich -var-value=TEXMFSYSCONFIG`); + my $local_keyring = "$TEXMFSYSCONFIG/tlpkg/gpg/keyring.gpg"; + if ($arg eq 'list') { + debug("running $::gpg --list-keys\n"); + system("$::gpg --list-keys"); + return $F_OK; + } elsif ($arg eq 'delete') { + my $what = shift @ARGV; + if (!$what) { + tlwarn("missing argument to `key add'\n"); + return $F_ERROR; + } + # we need to make sure that $local_keyring is existent! + if (! -r $local_keyring) { + tlwarn("no local keyring available, cannot delete anything!\n"); + return $F_ERROR; + } + debug("running: $::gpg --primary-keyring \"$local_keyring\" --delete-key $what\n"); + my ($out, $ret) = + TeXLive::TLUtils::run_cmd("$::gpg --primary-keyring \"$local_keyring\" --delete-key \"$what\" 2>&1"); + if ($ret == 0) { + info("key successfully removed\n"); + return $F_OK; + } else { + tlwarn("key removal failed, output:\n$out\n"); + return $F_ERROR; + } + + } elsif ($arg eq 'add') { + my $what = shift @ARGV; + if (!$what) { + tlwarn("missing argument to `key add'\n"); + return $F_ERROR; + } + # we need to make sure that $local_keyring is existent! + if (! -r $local_keyring) { + TeXLive::TLUtils::mkdirhier("$TEXMFSYSCONFIG/tlpkg/gpg"); + open(FOO, ">$local_keyring") || die("Cannot create $local_keyring: $!"); + close(FOO); + } + debug("running: $::gpg --primary-keyring \"$local_keyring\" --import $what\n"); + my ($out, $ret) = + TeXLive::TLUtils::run_cmd("$::gpg --primary-keyring \"$local_keyring\" --import \"$what\" 2>&1"); + if ($ret == 0) { + info("key successfully imported\n"); + return $F_OK; + } else { + tlwarn("key import failed, output:\n$out\n"); + return $F_ERROR; + } + } else { + tldie("should not be reached: tlmgr key $arg\n"); + } + + } else { + tlwarn("unknown directive `$arg' to action `key'\n"); + return $F_ERROR; + } + return $F_OK; +} + + # Subroutines galore. # @@ -6998,6 +7088,28 @@ C<--reinstall>, as in (using the C package as the example): =back +=head2 key I + +=over 4 + +=item B + +=item B> + +=item B> + +The action C allows listing, adding and removing additional keys +to the set of trusted keys, that is those that are used to verify the +TeX Live databases. + +With the C argument lists all keys. + +The C argument requires another argument, either a filename or +C<-> for stdin, from which the key is added. The key is added to the +local keyring C. + +The C argument requires a key id and removes the requested id +from the local keyring. =head2 option @@ -7709,6 +7821,8 @@ is signed by Karl Berry's key 0x9DEB46C0 and Norbert Preining's key 0x6CACA448. All of these keys are obtainable from the standard key servers. +Additional trusted keys can be added using the C action. + =head2 Configuration of GnuPG invocation The executable used for GnuPG is searched as follows: If the environment -- cgit v1.2.3