]> git.saurik.com Git - apt.git/blobdiff - apt-pkg/edsp.cc
Fix buffer overflow in debListParser::VersionHash()
[apt.git] / apt-pkg / edsp.cc
index f2d728933db3aee3cb54f688ef12b08dc2f14c1c..49873f2438ddcbd8652567ebade9fae35df58d65 100644 (file)
@@ -1074,6 +1074,20 @@ bool EDSP::ResolveExternal(const char* const solver, pkgDepCache &Cache,
 bool EIPP::OrderInstall(char const * const solver, pkgPackageManager * const PM,       /*{{{*/
                         unsigned int const flags, OpProgress * const Progress)
 {
+   if (strcmp(solver, "internal") == 0)
+   {
+      auto const dumpfile = _config->FindFile("Dir::Log::Planer");
+      if (dumpfile.empty())
+        return false;
+      auto const dumpdir = flNotFile(dumpfile);
+      FileFd output;
+      if (CreateAPTDirectoryIfNeeded(dumpdir, dumpdir) == false ||
+           output.Open(dumpfile, FileFd::WriteOnly | FileFd::Exclusive | FileFd::Create, FileFd::Extension, 0644) == false)
+        return _error->WarningE("EIPP::OrderInstall", _("Could not open file '%s'"), dumpfile.c_str());
+      bool Okay = EIPP::WriteRequest(PM->Cache, output, flags, nullptr);
+      return Okay && EIPP::WriteScenario(PM->Cache, output, nullptr);
+   }
+
    int solver_in, solver_out;
    pid_t const solver_pid = ExecuteExternal("planer", solver, "Dir::Bin::Planers", &solver_in, &solver_out);
    if (solver_pid == 0)
@@ -1081,7 +1095,7 @@ bool EIPP::OrderInstall(char const * const solver, pkgPackageManager * const PM,
 
    FileFd output;
    if (output.OpenDescriptor(solver_in, FileFd::WriteOnly | FileFd::BufferedWrite, true) == false)
-      return _error->Errno("OrderInstall", "Opening planer %s stdin on fd %d for writing failed", solver, solver_in);
+      return _error->Errno("EIPP::OrderInstall", "Opening planer %s stdin on fd %d for writing failed", solver, solver_in);
 
    bool Okay = output.Failed() == false;
    if (Progress != NULL)
@@ -1112,7 +1126,6 @@ bool EIPP::WriteRequest(pkgDepCache &Cache, FileFd &output,               /*{{{*/
                        unsigned int const flags,
                        OpProgress * const Progress)
 {
-   (void)(flags);
    if (Progress != NULL)
       Progress->SubProgress(Cache.Head().PackageCount, _("Send request to planer"));
    unsigned long p = 0;
@@ -1152,6 +1165,12 @@ bool EIPP::WriteRequest(pkgDepCache &Cache, FileFd &output,              /*{{{*/
    if (reinst.empty() == false)
       WriteOkay(Okay, output, "ReInstall:", reinst, "\n");
    WriteOkay(Okay, output, "Planer: ", _config->Find("APT::Planer", "internal"), "\n");
+   if ((flags & Request::IMMEDIATE_CONFIGURATION_ALL) != 0)
+      WriteOkay(Okay, output, "Immediate-Configuration: yes\n");
+   else if ((flags & Request::NO_IMMEDIATE_CONFIGURATION) != 0)
+      WriteOkay(Okay, output, "Immediate-Configuration: no\n");
+   else if ((flags & Request::ALLOW_TEMPORARY_REMOVE_OF_ESSENTIALS) != 0)
+      WriteOkay(Okay, output, "Allow-Temporary-Remove-of-Essentials: yes\n");
    return WriteOkay(Okay, output, "\n");
 }
                                                                        /*}}}*/
@@ -1218,6 +1237,35 @@ bool EIPP::WriteScenario(pkgDepCache &Cache, FileFd &output, OpProgress * const
               pkgset[PV->ID] = true;
         }
         pkgset[P->ID] = true;
+        if (strcmp(P.Arch(), "any") == 0)
+        {
+           APT::StringView const pkgname(P.Name());
+           auto const idxColon = pkgname.find(':');
+           if (idxColon != APT::StringView::npos)
+           {
+              pkgCache::PkgIterator PA;
+              if (pkgname.substr(idxColon + 1) == "any")
+              {
+                 auto const GA = Cache.FindGrp(pkgname.substr(0, idxColon).to_string());
+                 for (auto PA = GA.PackageList(); PA.end() == false; PA = GA.NextPkg(PA))
+                 {
+                    pkgset[PA->ID] = true;
+                 }
+              }
+              else
+              {
+                 auto const PA = Cache.FindPkg(pkgname.to_string());
+                 if (PA.end() == false)
+                    pkgset[PA->ID] = true;
+              }
+           }
+        }
+        else
+        {
+           auto const PA = Cache.FindPkg(P.FullName(false), "any");
+           if (PA.end() == false)
+              pkgset[PA->ID] = true;
+        }
       }
    };
    for (pkgCache::PkgIterator Pkg = Cache.PkgBegin(); Pkg.end() == false; ++Pkg)
@@ -1280,8 +1328,8 @@ bool EIPP::ReadResponse(int const input, pkgPackageManager * const PM, OpProgres
         std::cerr << "The following information might help you to understand what is wrong:" << std::endl;
         std::cerr << msg << std::endl << std::endl;
         return false;
-      } else if (section.Exists("Install") == true)
-        type = "Install";
+      } else if (section.Exists("Unpack") == true)
+        type = "Unpack";
       else if (section.Exists("Configure") == true)
         type = "Configure";
       else if (section.Exists("Remove") == true)
@@ -1306,7 +1354,7 @@ bool EIPP::ReadResponse(int const input, pkgPackageManager * const PM, OpProgres
 
       pkgCache::VerIterator Ver(PM->Cache.GetCache(), PM->Cache.GetCache().VerP + VerIdx[id]);
       auto const Pkg = Ver.ParentPkg();
-      if (strcmp(type, "Install") == 0)
+      if (strcmp(type, "Unpack") == 0)
         PM->Install(Pkg, PM->FileNames[Pkg->ID]);
       else if (strcmp(type, "Configure") == 0)
         PM->Configure(Pkg);
@@ -1350,6 +1398,15 @@ bool EIPP::ReadRequest(int const input, std::list<std::pair<std::string,PKG_ACTI
            _config->Set("APT::Architectures", SubstVar(line, " ", ","));
         else if (LineStartsWithAndStrip(line, "Planer:"))
            ; // purely informational line
+        else if (LineStartsWithAndStrip(line, "Immediate-Configuration:"))
+        {
+           if (localStringToBool(line, true))
+              flags |= Request::IMMEDIATE_CONFIGURATION_ALL;
+           else
+              flags |= Request::NO_IMMEDIATE_CONFIGURATION;
+        }
+        else if (ReadFlag(flags, line, "Allow-Temporary-Remove-of-Essentials:", Request::ALLOW_TEMPORARY_REMOVE_OF_ESSENTIALS))
+           ;
         else
            _error->Warning("Unknown line in EIPP Request stanza: %s", line.c_str());