diff options
author | Norbert Preining <preining@logic.at> | 2016-05-05 02:14:49 +0000 |
---|---|---|
committer | Norbert Preining <preining@logic.at> | 2016-05-05 02:14:49 +0000 |
commit | ace9c451be7c23646639d774ac1e858928133c32 (patch) | |
tree | 6a1bc27b6ff33171051782616459982d22a6a687 | |
parent | da1b2d2b56d9d64b11e7a726aa27673af01a6828 (diff) |
tlmgr: add tlmgr key (key management) action
git-svn-id: svn://tug.org/texlive/trunk@40896 c570f23f-e606-0410-a88d-b1316a301751
-rwxr-xr-x | Master/texmf-dist/scripts/texlive/tlmgr.pl | 114 |
1 files changed, 114 insertions, 0 deletions
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 @@ -5630,6 +5634,92 @@ sub texconfig_conf_mimic { } +# Action key +# +# general key management +# +# tlmgr key list +# tlmgr key add <filename> +# tlmgr key delete <keyid> +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. # # set global $location variable. @@ -6998,6 +7088,28 @@ C<--reinstall>, as in (using the C<fontspec> package as the example): =back +=head2 key I<args> + +=over 4 + +=item B<key list> + +=item B<key add I<what>> + +=item B<key remove I<keyid>> + +The action C<key> 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<list> argument lists all keys. + +The C<add> 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<TEXMFSYSCONFIG/tlpkg/gpg/keyring.gpg>. + +The C<delete> 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<key> action. + =head2 Configuration of GnuPG invocation The executable used for GnuPG is searched as follows: If the environment |