summaryrefslogtreecommitdiff
path: root/apt-pkg
diff options
context:
space:
mode:
authorDavid Kalnischkies <kalnischkies@gmail.com>2011-07-14 21:06:09 +0200
committerDavid Kalnischkies <kalnischkies@gmail.com>2011-07-14 21:06:09 +0200
commit4b42f43bed369817398b6c8d538f08e5bf6dff76 (patch)
tree9127cb9461a2de987748600c08682f7051ba12b7 /apt-pkg
parentdbbc549457825d5b6507fdd62bcf323ed3a3fb2a (diff)
* apt-pkg/deb/debmetaindex.cc:
- add trusted=yes option to mark unsigned (local) repository as trusted based on a patch from Ansgar Burchardt, thanks a lot! (Closes: #596498) Note that "apt-get update" still warns about unknown signatures even when [trusted=yes] is given for the source.
Diffstat (limited to 'apt-pkg')
-rw-r--r--apt-pkg/deb/debmetaindex.cc39
-rw-r--r--apt-pkg/deb/debmetaindex.h3
-rw-r--r--apt-pkg/metaindex.h4
3 files changed, 39 insertions, 7 deletions
diff --git a/apt-pkg/deb/debmetaindex.cc b/apt-pkg/deb/debmetaindex.cc
index a91cc34e9..81afb22b6 100644
--- a/apt-pkg/deb/debmetaindex.cc
+++ b/apt-pkg/deb/debmetaindex.cc
@@ -142,11 +142,13 @@ string debReleaseIndex::TranslationIndexURI(const char *Type, const string &Sect
return URI + "dists/" + Dist + "/" + TranslationIndexURISuffix(Type, Section);
}
-debReleaseIndex::debReleaseIndex(string const &URI, string const &Dist) {
- this->URI = URI;
- this->Dist = Dist;
- this->Indexes = NULL;
- this->Type = "deb";
+debReleaseIndex::debReleaseIndex(string const &URI, string const &Dist) :
+ metaIndex(URI, Dist, "deb"), Trusted(CHECK_TRUST)
+{}
+
+debReleaseIndex::debReleaseIndex(string const &URI, string const &Dist, bool const Trusted) :
+ metaIndex(URI, Dist, "deb") {
+ SetTrusted(Trusted);
}
debReleaseIndex::~debReleaseIndex() {
@@ -252,8 +254,22 @@ bool debReleaseIndex::GetIndexes(pkgAcquire *Owner, bool const &GetAll) const
return true;
}
+void debReleaseIndex::SetTrusted(bool const Trusted)
+{
+ if (Trusted == true)
+ this->Trusted = ALWAYS_TRUSTED;
+ else
+ this->Trusted = NEVER_TRUSTED;
+}
+
bool debReleaseIndex::IsTrusted() const
{
+ if (Trusted == ALWAYS_TRUSTED)
+ return true;
+ else if (Trusted == NEVER_TRUSTED)
+ return false;
+
+
if(_config->FindB("APT::Authentication::TrustCDROM", false))
if(URI.substr(0,strlen("cdrom:")) == "cdrom:")
return true;
@@ -349,6 +365,7 @@ class debSLTypeDebian : public pkgSourceList::Type
vector<string> const Archs =
(arch != Options.end()) ? VectorizeString(arch->second, ',') :
APT::Configuration::getArchitectures();
+ map<string, string>::const_iterator const trusted = Options.find("trusted");
for (vector<metaIndex *>::const_iterator I = List.begin();
I != List.end(); I++)
@@ -358,6 +375,9 @@ class debSLTypeDebian : public pkgSourceList::Type
continue;
debReleaseIndex *Deb = (debReleaseIndex *) (*I);
+ if (trusted != Options.end())
+ Deb->SetTrusted(StringToBool(trusted->second, false));
+
/* This check insures that there will be only one Release file
queued for all the Packages files and Sources files it
corresponds to. */
@@ -375,9 +395,14 @@ class debSLTypeDebian : public pkgSourceList::Type
return true;
}
}
+
// No currently created Release file indexes this entry, so we create a new one.
- // XXX determine whether this release is trusted or not
- debReleaseIndex *Deb = new debReleaseIndex(URI, Dist);
+ debReleaseIndex *Deb;
+ if (trusted != Options.end())
+ Deb = new debReleaseIndex(URI, Dist, StringToBool(trusted->second, false));
+ else
+ Deb = new debReleaseIndex(URI, Dist);
+
if (IsSrc == true)
Deb->PushSectionEntry ("source", new debReleaseIndex::debSectionEntry(Section, IsSrc));
else
diff --git a/apt-pkg/deb/debmetaindex.h b/apt-pkg/deb/debmetaindex.h
index 0aaf7f14a..695cfa7cc 100644
--- a/apt-pkg/deb/debmetaindex.h
+++ b/apt-pkg/deb/debmetaindex.h
@@ -22,10 +22,12 @@ class debReleaseIndex : public metaIndex {
/** \brief dpointer placeholder (for later in case we need it) */
void *d;
std::map<string, vector<debSectionEntry const*> > ArchEntries;
+ enum { ALWAYS_TRUSTED, NEVER_TRUSTED, CHECK_TRUST } Trusted;
public:
debReleaseIndex(string const &URI, string const &Dist);
+ debReleaseIndex(string const &URI, string const &Dist, bool const Trusted);
virtual ~debReleaseIndex();
virtual string ArchiveURI(string const &File) const {return URI + File;};
@@ -43,6 +45,7 @@ class debReleaseIndex : public metaIndex {
string TranslationIndexURISuffix(const char *Type, const string &Section) const;
virtual vector <pkgIndexFile *> *GetIndexFiles();
+ void SetTrusted(bool const Trusted);
virtual bool IsTrusted() const;
void PushSectionEntry(vector<string> const &Archs, const debSectionEntry *Entry);
diff --git a/apt-pkg/metaindex.h b/apt-pkg/metaindex.h
index 1d2140799..f60235a5d 100644
--- a/apt-pkg/metaindex.h
+++ b/apt-pkg/metaindex.h
@@ -39,6 +39,10 @@ class metaIndex
virtual vector<pkgIndexFile *> *GetIndexFiles() = 0;
virtual bool IsTrusted() const = 0;
+ metaIndex(string const &URI, string const &Dist, char const * const Type) :
+ Indexes(NULL), Type(Type), URI(URI), Dist(Dist) {
+ }
+
virtual ~metaIndex() {
if (Indexes == 0)
return;