]> git.saurik.com Git - apt.git/blobdiff - apt-pkg/acquire-method.cc
rework hashsum verification in the acquire system
[apt.git] / apt-pkg / acquire-method.cc
index 58d214068ec3d1d86cfb21c2e470a2d4715ad158..b77096efd652b319676dbfec109a5e64f3e1752f 100644 (file)
@@ -102,7 +102,10 @@ void pkgAcqMethod::Fail(string Err,bool Transient)
    if (Queue != 0)
    {
       std::cout << "400 URI Failure\nURI: " << Queue->Uri << "\n"
-               << "Message: " << Err << " " << IP << "\n";
+               << "Message: " << Err;
+      if (IP.empty() == false && _config->FindB("Acquire::Failure::ShowIP", true) == true)
+        std::cout << " " << IP;
+      std::cout << "\n";
       Dequeue();
    }
    else
@@ -118,6 +121,18 @@ void pkgAcqMethod::Fail(string Err,bool Transient)
 
    std::cout << "\n" << std::flush;
 }
+                                                                       /*}}}*/
+// AcqMethod::DropPrivsOrDie - Drop privileges or die          /*{{{*/
+// ---------------------------------------------------------------------
+/* */
+void pkgAcqMethod::DropPrivsOrDie()
+{
+   if (!DropPrivileges()) {
+      Fail(false);
+      exit(112);       /* call the european emergency number */
+   }
+}
+
                                                                        /*}}}*/
 // AcqMethod::URIStart - Indicate a download is starting               /*{{{*/
 // ---------------------------------------------------------------------
@@ -351,6 +366,20 @@ int pkgAcqMethod::Run(bool Single)
               Tmp->LastModified = 0;
            Tmp->IndexFile = StringToBool(LookupTag(Message,"Index-File"),false);
            Tmp->FailIgnore = StringToBool(LookupTag(Message,"Fail-Ignore"),false);
+           Tmp->ExpectedHashes = HashStringList();
+           for (char const * const * t = HashString::SupportedHashes(); *t != NULL; ++t)
+           {
+              std::string tag = "Expected-";
+              tag.append(*t);
+              std::string const hash = LookupTag(Message, tag.c_str());
+              if (hash.empty() == false)
+                 Tmp->ExpectedHashes.push_back(HashString(*t, hash));
+           }
+            char *End;
+           if (Tmp->ExpectedHashes.FileSize() > 0)
+              Tmp->MaximumSize = Tmp->ExpectedHashes.FileSize();
+           else
+              Tmp->MaximumSize = strtoll(LookupTag(Message, "Maximum-Size", "0").c_str(), &End, 10);
            Tmp->Next = 0;
            
            // Append it to the list
@@ -451,3 +480,5 @@ void pkgAcqMethod::Dequeue() {                                              /*{{{*/
    delete Tmp;
 }
                                                                        /*}}}*/
+
+pkgAcqMethod::~pkgAcqMethod() {}