From 6a4958d3134a3a61c036bc9ccaccc393c2bb99f2 Mon Sep 17 00:00:00 2001 From: Julian Andres Klode Date: Mon, 28 Mar 2016 03:34:54 +0200 Subject: Allow lowering trust level of a hash via config Introduces APT::Hashes:: with entries Untrusted and Weak which can be set to true to cause the hash to be treated as untrusted and/or weak. --- apt-pkg/contrib/hashes.cc | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) (limited to 'apt-pkg/contrib/hashes.cc') diff --git a/apt-pkg/contrib/hashes.cc b/apt-pkg/contrib/hashes.cc index f2b91501e..755ad2035 100644 --- a/apt-pkg/contrib/hashes.cc +++ b/apt-pkg/contrib/hashes.cc @@ -129,12 +129,21 @@ APT_PURE bool HashString::empty() const /*{{{*/ return (Type.empty() || Hash.empty()); } /*}}}*/ + +APT_PURE static bool IsConfigured(const char *name, const char *what) +{ + std::string option; + strprintf(option, "APT::Hashes::%s::%s", name, what); + return _config->FindB(option, false); +} + APT_PURE bool HashString::usable() const /*{{{*/ { return ( (Type != "Checksum-FileSize") && (Type != "MD5Sum") && - (Type != "SHA1") + (Type != "SHA1") && + !IsConfigured(Type.c_str(), "Untrusted") ); } /*}}}*/ -- cgit v1.2.3