diff options
author | Norbert Preining <preining@logic.at> | 2018-04-01 00:48:43 +0000 |
---|---|---|
committer | Norbert Preining <preining@logic.at> | 2018-04-01 00:48:43 +0000 |
commit | 9da8f04dabdeec25b5d75b677ddc6d393a4a9d06 (patch) | |
tree | a3b4783179a631c08d3f3fb17030fd750aaa8541 /Master | |
parent | aeaf0341853a573588be2ada1949278159377a3d (diff) |
start on crypto options rework
git-svn-id: svn://tug.org/texlive/trunk@47210 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Master')
-rwxr-xr-x | Master/texmf-dist/scripts/texlive/tlmgr.pl | 139 |
1 files changed, 96 insertions, 43 deletions
diff --git a/Master/texmf-dist/scripts/texlive/tlmgr.pl b/Master/texmf-dist/scripts/texlive/tlmgr.pl index 638c9b98b20..0e944e8dd77 100755 --- a/Master/texmf-dist/scripts/texlive/tlmgr.pl +++ b/Master/texmf-dist/scripts/texlive/tlmgr.pl @@ -362,6 +362,7 @@ my %globaloptions = ( "print-platform-info" => 1, "usermode|user-mode" => 1, "usertree|user-tree" => "=s", + "verify-repos" => "=s", "verify-downloads" => "!", "require-verification" => "!", "version" => 1, @@ -479,6 +480,52 @@ sub main { $action = "remove"; } + # crypto options rewriting + if ((defined($opts{"verify-downloads"}) || + defined($opts{"require-verification")) && + defined($opts{"verify-repos"})) { + # we cannot have all three, warn and bail out + tldie("The options verify-downloads and require-verification have been\n" . + "superseeded by verify-repos, please use only the later on!\n"); + } + if (defined($opts{"verify-downloads"})) { + if ($opts{"verify-downloads"}) { + # explicit --verify-downloads was given + if ($opts{"require-verification") { + # --require-verification was given + $opts{"verify-repos"} = "all"; + } else { + # either nothing passed or --no-require-verification (default) + # use explit setting to main + $opts{"verify-repos"} = "main"; + } + } else { + # explicit --no-verify-downloads was given + if ($opts"require-verification") { + # --require-verification was given + tldie("You cannot ask for no verification and require it at the same time!\n"); + } else { + $opts{"verify-repos"} = "none"; + } + } + } else { + # nothing related to verify-download was given, so it is by default + # set to true + if ($opts{"require-verification") { + $opts{"verify-repos"} = "all"; + } else { + # dont set anything, as nothing has been passed in + } + } + delete $opts{"require-verification"}; + delete $opts{"verify-downloads"}; + # + # check for correctness of verify-repo argument + if (defined($opts{"verify-repo"}) && + ($opts{"verify-repo"} !~ m/^(none|main|all)$/)) { + tldie("Unknown value for --verify-repo; $opts{verify-repo}\n"); + } + # now $action should be part of %actionoptions, otherwise this is # an error if (defined($action) && $action && !exists $action_specification{$action}) { @@ -6199,7 +6246,7 @@ sub action_shell { # keys which can be set/get and are also settable via global cmdline opts my @valid_bool_keys = qw/debug-translation machine-readable no-execute-actions - require-verification verify-downloads json/; + verify-repos json/; my @valid_string_keys = qw/repository prompt/; my @valid_keys = (@valid_bool_keys, @valid_string_keys); # set auto flush unconditionally in action shell @@ -6518,26 +6565,26 @@ sub handle_gpg_config_settings { # setup gpg if available # by default we setup gpg # default value - my $do_setup_gpg = 1; + my $do_setup_gpg = "main"; # the value is set in the config file - if (defined($config{'verify-downloads'})) { - $do_setup_gpg = $config{'verify-downloads'}; + if (defined($config{'verify-repos'})) { + $do_setup_gpg = $config{'verify-repos'}; } # command line - if (defined($opts{'verify-downloads'})) { - $do_setup_gpg = $opts{'verify-downloads'}; + if (defined($opts{'verify-repos'})) { + $do_setup_gpg = $opts{'verify-repos'}; } # now we know whether we setup gpg or not - if ($do_setup_gpg) { + if ($do_setup_gpg ne "none") { if (TeXLive::TLCrypto::setup_gpg($Master)) { debug("will verify cryptographic signatures\n") } else { my $prefix = "$prg: No gpg found"; # just to shorten the strings - if ($opts{'verify-downloads'}) { + if ($opts{'verify-repos'} eq "all") { # verification was requested on the command line, but did not succeed, die tldie("$prefix, verification explicitly requested on command line, quitting.\n"); } - if ($config{'verify-downloads'}) { + if ($config{'verify-repos'} eq "all") { # verification explicitly requested in config file, but not gpg, die tldie("$prefix, verification explicitly requested in config file, quitting.\n"); } @@ -6549,12 +6596,12 @@ sub handle_gpg_config_settings { } else { # we do not setup gpg: when explicitly requested, be silent, otherwise info my $prefix = "$prg: not setting up gpg"; - if (defined($opts{'verify-downloads'})) { + if (defined($opts{'verify-repos'})) { # log normally is *NOT* logged to a file # tlmgr does by default *NOT* set up a log file (cmd line option) # user requested it, so don't bother with output debug("$prefix, requested on command line\n"); - } elsif (defined($config{'verify-downloads'})) { + } elsif (defined($config{'verify-repos'})) { debug("$prefix, requested in config file\n"); } else { tldie("$prg: how could this happen? gpg setup.\n"); @@ -6978,6 +7025,7 @@ sub load_config_file { $config{"auto-remove"} = 1; $config{"require-verification"} = 0; $config{"persistent-downloads"} = 1; + $config{"verify-repo"} = "auto"; # do NOT set this here, we distinguish between explicitly set in the config file # or implicitly true # $config{"verify-downloads"} = 1; @@ -7046,21 +7094,32 @@ sub load_options_from_config { } } elsif ($key eq "require-verification") { - if ($val eq "0") { - $config{"require-verification"} = 0; - } elsif ($val eq "1") { - $config{"require-verification"} = 1; - } else { - tlwarn("$prg: $fn: Unknown value for require-verification: $val\n"); - } + tlwarn("Configuration file setting \"require-verification\" is being ignored!\n"); + tlwarn("Please update the config file using \"verify-repo\"!\n"); + #if ($val eq "0") { + # $config{"require-verification"} = 0; + #} elsif ($val eq "1") { + # $config{"require-verification"} = 1; + #} else { + # tlwarn("$prg: $fn: Unknown value for require-verification: $val\n"); + #} } elsif ($key eq "verify-downloads") { - if ($val eq "0") { - $config{"verify-downloads"} = 0; - } elsif ($val eq "1") { - $config{"verify-downloads"} = 1; + tlwarn("Configuration file setting \"verify-downloads\" is being ignored!\n"); + tlwarn("Please update the config file using \"verify-repo\"!\n"); + #if ($val eq "0") { + # $config{"verify-downloads"} = 0; + #} elsif ($val eq "1") { + # $config{"verify-downloads"} = 1; + #} else { + # tlwarn("$prg: $fn: Unknown value for verify-downloads: $val\n"); + #} + + } elsif ($key eq "verify-repo") { + if ($val =~ m/^(none|main|all)$/) { + $config{"verify-repo"} = $val; } else { - tlwarn("$prg: $fn: Unknown value for verify-downloads: $val\n"); + tlwarn("$prg: $fn: Unknown value for verify-repo: $val\n"); } } elsif ($key eq "no-checksums") { @@ -7432,16 +7491,6 @@ Change the pinning file location from C<TEXMFLOCAL/tlpkg/pinning.txt> (see L</Pinning> below). Documented only for completeness, as this is only useful in debugging. -=item B<--require-verification> - -=item B<--no-require-verification> - -Verify that all remote repositories to be correctly signed, or quit. -With C<--no-require-verification>, all verification is omitted. By -default, verification is performed (but not required) if GnuPG and the -relevant keys are available. See L<CRYPTOGRAPHIC VERIFICATION> below for -details. - =item B<--usermode> Activates user mode for this run of C<tlmgr>; see L<USER MODE> below. @@ -7450,14 +7499,13 @@ Activates user mode for this run of C<tlmgr>; see L<USER MODE> below. Uses I<dir> for the tree in user mode; see L<USER MODE> below. -=item B<--verify-downloads> - -=item B<--no-verify-downloads> +=item B<--verify-repos=[none|main|all]> -Enables or disables cryptographic verification of all downloaded -database files. A working GnuPG (C<gpg>) binary needs to be present in -the path, otherwise this option has no effect. By default, the main -repository is verified, while any other repositories are not verified. +Defines the level of verification done: If C<none> is passed, no +verification whatsoever is done. If C<main> and a working GnuPG (C<gpg>) +binary is available, all repositories are checked, but only the main +repository is required to be signed. If C<all> then all repositories +need to be signed. See L<CRYPTOGRAPHIC VERIFICATION> below for details. =back @@ -9027,11 +9075,16 @@ main repository be signed, but not any additional repositories. If C<gpg> is not available, signatures are not checked and no verification is carried out, but C<tlmgr> proceeds normally. +The verification can be controlled by the c + + +TODO TODO + The attempted verification can be suppressed entirely by specifying -C<--no-verify-downloads> on the command line, or a line -C<verify-downloads=0> in a C<tlmgr> config file (see L<CONFIGURATION +C<--verify-repos=none> on the command line, or a line +C<verify-repos = none> in a C<tlmgr> config file (see L<CONFIGURATION FILE FOR TLMGR>). On the other hand, you can I<require> successful -verification by specifying C<--require-verification> on the command +verification of all repos by specifying C<--require-verification> on the command line, or C<require-verification=1> in a C<tlmgr> config file; in this case, if verification is not possible, or fails, the program quits. |