]> git.saurik.com Git - apt.git/blobdiff - apt-pkg/acquire-method.cc
apt-key: change to / before find to satisfy its CWD needs
[apt.git] / apt-pkg / acquire-method.cc
index e4a937d1dd6de8b363998a43b24abaf48e3a2a0a..82f4b626d08486fe32091105a3fda3470975de7d 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               /*{{{*/
 // ---------------------------------------------------------------------
@@ -130,13 +145,13 @@ void pkgAcqMethod::URIStart(FetchResult &Res)
    std::cout << "200 URI Start\n"
             << "URI: " << Queue->Uri << "\n";
    if (Res.Size != 0)
-      std::cout << "Size: " << Res.Size << "\n";
+      std::cout << "Size: " << std::to_string(Res.Size) << "\n";
 
    if (Res.LastModified != 0)
       std::cout << "Last-Modified: " << TimeRFC1123(Res.LastModified) << "\n";
 
    if (Res.ResumePoint != 0)
-      std::cout << "Resume-Point: " << Res.ResumePoint << "\n";
+      std::cout << "Resume-Point: " << std::to_string(Res.ResumePoint) << "\n";
 
    if (UsedMirror.empty() == false)
       std::cout << "UsedMirror: " << UsedMirror << "\n";
@@ -169,7 +184,7 @@ void pkgAcqMethod::URIDone(FetchResult &Res, FetchResult *Alt)
       std::cout << "Filename: " << Res.Filename << "\n";
 
    if (Res.Size != 0)
-      std::cout << "Size: " << Res.Size << "\n";
+      std::cout << "Size: " << std::to_string(Res.Size) << "\n";
 
    if (Res.LastModified != 0)
       std::cout << "Last-Modified: " << TimeRFC1123(Res.LastModified) << "\n";
@@ -187,7 +202,7 @@ void pkgAcqMethod::URIDone(FetchResult &Res, FetchResult *Alt)
    }
 
    if (Res.ResumePoint != 0)
-      std::cout << "Resume-Point: " << Res.ResumePoint << "\n";
+      std::cout << "Resume-Point: " << std::to_string(Res.ResumePoint) << "\n";
 
    if (Res.IMSHit == true)
       std::cout << "IMS-Hit: true\n";
@@ -198,7 +213,7 @@ void pkgAcqMethod::URIDone(FetchResult &Res, FetchResult *Alt)
         std::cout << "Alt-Filename: " << Alt->Filename << "\n";
 
       if (Alt->Size != 0)
-        std::cout << "Alt-Size: " << Alt->Size << "\n";
+        std::cout << "Alt-Size: " << std::to_string(Alt->Size) << "\n";
 
       if (Alt->LastModified != 0)
         std::cout << "Alt-Last-Modified: " << TimeRFC1123(Alt->LastModified) << "\n";
@@ -360,6 +375,11 @@ int pkgAcqMethod::Run(bool Single)
               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
@@ -368,14 +388,14 @@ int pkgAcqMethod::Run(bool Single)
            *I = Tmp;
            if (QueueBack == 0)
               QueueBack = Tmp;
-           
+
            // Notify that this item is to be fetched.
-           if (Fetch(Tmp) == false)
+           if (URIAcquire(Message, Tmp) == false)
               Fail();
-           
-           break;                                           
-        }   
-      }      
+
+           break;
+        }
+      }
    }
 
    Exit();
@@ -383,8 +403,6 @@ int pkgAcqMethod::Run(bool Single)
 }
                                                                        /*}}}*/
 // AcqMethod::PrintStatus - privately really send a log/status message /*{{{*/
-// ---------------------------------------------------------------------
-/* */
 void pkgAcqMethod::PrintStatus(char const * const header, const char* Format,
                               va_list &args) const
 {
@@ -439,7 +457,7 @@ void pkgAcqMethod::Redirect(const string &NewURI)
 // ---------------------------------------------------------------------
 /* */
 pkgAcqMethod::FetchResult::FetchResult() : LastModified(0),
-                                   IMSHit(false), Size(0), ResumePoint(0)
+                                   IMSHit(false), Size(0), ResumePoint(0), d(NULL)
 {
 }
                                                                        /*}}}*/
@@ -460,3 +478,12 @@ void pkgAcqMethod::Dequeue() {                                             /*{{{*/
    delete Tmp;
 }
                                                                        /*}}}*/
+pkgAcqMethod::~pkgAcqMethod() {}
+
+pkgAcqMethod::FetchItem::FetchItem() :
+   Next(nullptr), DestFileFd(-1), LastModified(0), IndexFile(false),
+   FailIgnore(false), MaximumSize(0), d(nullptr)
+{}
+pkgAcqMethod::FetchItem::~FetchItem() {}
+
+pkgAcqMethod::FetchResult::~FetchResult() {}