From 081fbea14d12f79c8d91ce4fe1f1004c7bc08656 Mon Sep 17 00:00:00 2001 From: David Kalnischkies Date: Wed, 12 Apr 2017 17:39:06 +0200 Subject: error in update on Release information changes The value of Origin, Label, Codename and co can be used in user configuration from apts own pinning to unattended upgrades. A repository changing this values can therefore have serious effects on the behaviour of apt and other tools using these values. In a first step we will generate error messages for these changes now explaining the need for explicit confirmation and provide config options and commandline flags to accept them. --- doc/apt-get.8.xml | 17 +++++++++++++++++ doc/apt-secure.8.xml | 42 ++++++++++++++++++++++++++++++------------ doc/examples/configure-index | 35 ++++++++++++++++++++++++++++------- 3 files changed, 75 insertions(+), 19 deletions(-) (limited to 'doc') diff --git a/doc/apt-get.8.xml b/doc/apt-get.8.xml index 931a4f313..a38a14e0c 100644 --- a/doc/apt-get.8.xml +++ b/doc/apt-get.8.xml @@ -575,6 +575,23 @@ Configuration Item: Acquire::AllowInsecureRepositories. + + Allow the update command to continue downloading + data from a repository which changed its information of the release + contained in the repository indicating e.g a new major release. + APT will fail at the update command for such repositories until the + change is confirmed to ensure the user is prepared for the change. + See also &apt-secure; for details on the concept and configuration. + + Specialist options + (--allow-releaseinfo-changes-field) + exist to allow changes only for certain fields like origin, + label, codename, suite, + version and defaultpin. See also &apt-preferences;. + + Configuration Item: Acquire::AllowReleaseInfoChanges. + + Show user friendly progress information in the terminal window when packages are installed, upgraded or diff --git a/doc/apt-secure.8.xml b/doc/apt-secure.8.xml index 8ad249d7c..4f5d491f3 100644 --- a/doc/apt-secure.8.xml +++ b/doc/apt-secure.8.xml @@ -13,7 +13,7 @@ &apt-email; &apt-product; - 2016-08-06T00:00:00Z + 2017-04-12T00:00:00Z @@ -50,9 +50,19 @@ that data like packages in the archive can't be modified by people who have no access to the Release file signing key. Starting with version 1.1 APT requires repositories to provide recent authentication - information for unimpeded usage of the repository. + information for unimpeded usage of the repository. Since version 1.5 changes + in the information contained in the Release file about the repository need to be + confirmed before APT continues to apply updates from this repository. + + Note: All APT-based package management front-ends like &apt-get;, &aptitude; + and &synaptic; support this authentication feature, so this manpage uses + APT to refer to them all for simplicity only. + + + + Unsigned Repositories If an archive has an unsigned Release file or no Release file at all current APT versions will refuse to download data from them by default @@ -83,16 +93,9 @@ to true or for Individual repositories with the &sources-list; option allow-downgrade-to-insecure=yes. - - - Note: All APT-based package management front-ends like &apt-get;, &aptitude; - and &synaptic; support this authentication feature, so this manpage uses - APT to refer to them all for simplicity only. - - Trusted Repositories - + Signed Repositories The chain of trust from an APT archive to the end user is made up of several steps. apt-secure is the last step in @@ -162,7 +165,22 @@ this mechanism can complement a per-package signature. - User Configuration +Information changes + + A Release file contains beside the checksums for the files in the repository + also general information about the repository like the origin, codename or + version number of the release. + + This information is shown in various places so a repository owner should always + ensure correctness. Further more user configuration like &apt-preferences; + can depend and make use of this information. Since version 1.5 the user must + therefore explicitly confirm changes to signal that the user is sufficently + prepared e.g. for the new major release of the distribution shipped in the + repository (as e.g. indicated by the codename). + + + +User Configuration apt-key is the program that manages the list of keys used by APT to trust repositories. It can be used to add or remove keys as well @@ -183,7 +201,7 @@ -Archive Configuration +Repository Configuration If you want to provide archive signatures in an archive under your maintenance you have to: diff --git a/doc/examples/configure-index b/doc/examples/configure-index index a48d4cb99..8adef26a9 100644 --- a/doc/examples/configure-index +++ b/doc/examples/configure-index @@ -29,10 +29,20 @@ and the syntax of configuration files and commandline options! */ -quiet ""; -quiet::NoUpdate ""; // never update progress information - included in -q=1 -quiet::NoProgress ""; // disables the 0% → 100% progress on cache generation and stuff -quiet::NoStatistic ""; // no "42 kB downloaded" stats in update +quiet "" { + NoUpdate ""; // never update progress information - included in -q=1 + NoProgress ""; // disables the 0% → 100% progress on cache generation and stuff + NoStatistic ""; // no "42 kB downloaded" stats in update + ReleaseInfoChange "" // don't even print the notices if the info change is allowed + { + Origin ""; + Label ""; + Version ""; + Codename ""; + Suite ""; + DefaultPin ""; + }; +}; // Options for APT in general APT @@ -221,6 +231,20 @@ Acquire SameMirrorForAllIndexes ""; // use the mirror serving the Release file for Packages & co + AllowInsecureRepositories ""; + AllowWeakRepositories ""; + AllowDowngradeToInsecureRepositories ""; + // allow repositories to change information potentally breaking user config like pinning + AllowReleaseInfoChange "" + { + Origin ""; + Label ""; + Version ""; // allowed by default + Codename ""; + Suite ""; + DefaultPin ""; + }; + // HTTP method configuration http { @@ -686,9 +710,6 @@ acquire::cdrom::mount ""; acquire::maxreleasefilesize ""; acquire::queuehost::limit ""; acquire::max-pipeline-depth ""; -acquire::allowinsecurerepositories ""; -acquire::allowweakrepositories ""; -acquire::allowdowngradetoinsecurerepositories ""; acquire::progress::diffpercent ""; acquire::gzipindexes ""; acquire::indextargets::randomized ""; -- cgit v1.2.3-70-g09d2 From 24b5bc4e41ed527799a9fa01dec9c29294d0a3f2 Mon Sep 17 00:00:00 2001 From: David Kalnischkies Date: Sun, 28 May 2017 17:44:11 +0200 Subject: ask for releaseinfo change interactively in apt If we have a user sitting around we can let 'apt' ask the user for a confirmation rather than print errors at the end and require the user to figure out which commandline flags are needed to confirm the changes non-interactively. --- apt-private/acqprogress.cc | 22 +++++++++++++++++++++- apt-private/acqprogress.h | 3 ++- apt-private/private-cmndline.cc | 1 + apt-private/private-output.cc | 26 +++++++++++++++----------- apt-private/private-output.h | 1 + doc/examples/configure-index | 2 ++ 6 files changed, 42 insertions(+), 13 deletions(-) (limited to 'doc') diff --git a/apt-private/acqprogress.cc b/apt-private/acqprogress.cc index e4bfbd4e5..1f053cb9f 100644 --- a/apt-private/acqprogress.cc +++ b/apt-private/acqprogress.cc @@ -17,6 +17,7 @@ #include #include +#include #include #include @@ -32,7 +33,7 @@ // --------------------------------------------------------------------- /* */ AcqTextStatus::AcqTextStatus(std::ostream &out, unsigned int &ScreenWidth,unsigned int const Quiet) : - pkgAcquireStatus(), out(out), ScreenWidth(ScreenWidth), LastLineLength(0), ID(0), Quiet(Quiet) + pkgAcquireStatus2(), out(out), ScreenWidth(ScreenWidth), LastLineLength(0), ID(0), Quiet(Quiet) { // testcases use it to disable pulses without disabling other user messages if (Quiet == 0 && _config->FindB("quiet::NoUpdate", false) == true) @@ -330,6 +331,25 @@ bool AcqTextStatus::MediaChange(std::string Media, std::string Drive) return bStatus; } /*}}}*/ +bool AcqTextStatus::ReleaseInfoChanges(metaIndex const * const L, metaIndex const * const N, std::vector &&Changes)/*{{{*/ +{ + if (Quiet >= 2 || isatty(STDOUT_FILENO) != 1 || isatty(STDIN_FILENO) != 1 || + _config->FindB("APT::Get::Update::InteractiveReleaseInfoChanges", false) == false) + return pkgAcquireStatus2::ReleaseInfoChanges(nullptr, nullptr, std::move(Changes)); + + _error->PushToStack(); + auto const confirmed = pkgAcquireStatus2::ReleaseInfoChanges(L, N, std::move(Changes)); + if (confirmed == true) + { + _error->MergeWithStack(); + return true; + } + clearLastLine(); + _error->DumpErrors(out, GlobalError::NOTICE, false); + _error->RevertToStack(); + return YnPrompt(_("Do you want to accept these changes and continue updating from this repository?"), false, false, out, out); +} + /*}}}*/ void AcqTextStatus::clearLastLine() { /*{{{*/ if (Quiet > 0 || LastLineLength == 0) return; diff --git a/apt-private/acqprogress.h b/apt-private/acqprogress.h index 6b6d555b1..196995ac4 100644 --- a/apt-private/acqprogress.h +++ b/apt-private/acqprogress.h @@ -15,7 +15,7 @@ #include #include -class APT_PUBLIC AcqTextStatus : public pkgAcquireStatus +class APT_PUBLIC AcqTextStatus : public pkgAcquireStatus2 { std::ostream &out; unsigned int &ScreenWidth; @@ -28,6 +28,7 @@ class APT_PUBLIC AcqTextStatus : public pkgAcquireStatus public: + virtual bool ReleaseInfoChanges(metaIndex const * const LastRelease, metaIndex const * const CurrentRelease, std::vector &&Changes) APT_OVERRIDE; virtual bool MediaChange(std::string Media,std::string Drive) APT_OVERRIDE; virtual void IMSHit(pkgAcquire::ItemDesc &Itm) APT_OVERRIDE; virtual void Fetch(pkgAcquire::ItemDesc &Itm) APT_OVERRIDE; diff --git a/apt-private/private-cmndline.cc b/apt-private/private-cmndline.cc index b035d99f0..6b84324de 100644 --- a/apt-private/private-cmndline.cc +++ b/apt-private/private-cmndline.cc @@ -469,6 +469,7 @@ static void BinarySpecificConfiguration(char const * const Binary) /*{{{*/ _config->CndSet("Binary::apt::APT::Cmd::Show-Update-Stats", true); _config->CndSet("Binary::apt::DPkg::Progress-Fancy", true); _config->CndSet("Binary::apt::APT::Keep-Downloaded-Packages", false); + _config->CndSet("Binary::apt::APT::Get::Update::InteractiveReleaseInfoChanges", true); } _config->Set("Binary", binary); diff --git a/apt-private/private-output.cc b/apt-private/private-output.cc index 9c25cda6d..3b8832c21 100644 --- a/apt-private/private-output.cc +++ b/apt-private/private-output.cc @@ -650,20 +650,20 @@ void Stats(ostream &out,pkgDepCache &Dep) // YnPrompt - Yes No Prompt. /*{{{*/ // --------------------------------------------------------------------- /* Returns true on a Yes.*/ -bool YnPrompt(char const * const Question, bool Default) +bool YnPrompt(char const * const Question, bool const Default, bool const ShowGlobalErrors, std::ostream &c1o, std::ostream &c2o) { auto const AssumeYes = _config->FindB("APT::Get::Assume-Yes",false); auto const AssumeNo = _config->FindB("APT::Get::Assume-No",false); // if we ask interactively, show warnings/notices before the question - if (AssumeYes == false && AssumeNo == false) + if (ShowGlobalErrors == true && AssumeYes == false && AssumeNo == false) { if (_config->FindI("quiet",0) > 0) - _error->DumpErrors(c2out); + _error->DumpErrors(c2o); else - _error->DumpErrors(c2out, GlobalError::DEBUG); + _error->DumpErrors(c2o, GlobalError::DEBUG); } - c2out << Question << std::flush; + c2o << Question << std::flush; /* nl_langinfo does not support LANGUAGE setting, so we unset it here to have the help-message (hopefully) match the expected characters */ @@ -678,13 +678,13 @@ bool YnPrompt(char const * const Question, bool Default) // e.g. "Do you want to continue? [Y/n] " // The user has to answer with an input matching the // YESEXPR/NOEXPR defined in your l10n. - c2out << " " << _("[Y/n]") << " " << std::flush; + c2o << " " << _("[Y/n]") << " " << std::flush; else // TRANSLATOR: Yes/No question help-text: defaulting to N[o] // e.g. "Should this file be removed? [y/N] " // The user has to answer with an input matching the // YESEXPR/NOEXPR defined in your l10n. - c2out << " " << _("[y/N]") << " " << std::flush; + c2o << " " << _("[y/N]") << " " << std::flush; if (language != NULL) { @@ -695,13 +695,13 @@ bool YnPrompt(char const * const Question, bool Default) if (AssumeYes) { // TRANSLATOR: "Yes" answer printed for a yes/no question if --assume-yes is set - c1out << _("Y") << std::endl; + c1o << _("Y") << std::endl; return true; } else if (AssumeNo) { // TRANSLATOR: "No" answer printed for a yes/no question if --assume-no is set - c1out << _("N") << std::endl; + c1o << _("N") << std::endl; return false; } @@ -721,15 +721,19 @@ bool YnPrompt(char const * const Question, bool Default) REG_EXTENDED|REG_ICASE|REG_NOSUB); if (Res != 0) { - char Error[300]; + char Error[300]; regerror(Res,&Pattern,Error,sizeof(Error)); return _error->Error(_("Regex compilation error - %s"),Error); } - + Res = regexec(&Pattern, response, 0, NULL, 0); if (Res == 0) return true; return false; +} +bool YnPrompt(char const * const Question, bool const Default) +{ + return YnPrompt(Question, Default, true, c1out, c2out); } /*}}}*/ // AnalPrompt - Annoying Yes No Prompt. /*{{{*/ diff --git a/apt-private/private-output.h b/apt-private/private-output.h index bb9428d7f..79da3d130 100644 --- a/apt-private/private-output.h +++ b/apt-private/private-output.h @@ -102,6 +102,7 @@ void Stats(std::ostream &out, pkgDepCache &Dep); // prompting bool YnPrompt(char const * const Question, bool Default=true); +bool YnPrompt(char const * const Question, bool const Default, bool const ShowGlobalErrors, std::ostream &c1o, std::ostream &c2o); bool AnalPrompt(std::string const &Question, const char *Text); std::string PrettyFullName(pkgCache::PkgIterator const &Pkg); diff --git a/doc/examples/configure-index b/doc/examples/configure-index index 8adef26a9..155dac84f 100644 --- a/doc/examples/configure-index +++ b/doc/examples/configure-index @@ -106,6 +106,8 @@ APT CallResolver ""; IndexTargets::ReleaseInfo ""; IndexTargets::format ""; + + Update::InteractiveReleaseInfoChanges ""; }; Cache -- cgit v1.2.3-70-g09d2