X-Git-Url: https://git.saurik.com/apt.git/blobdiff_plain/b53c9cea2902572822bbbece5bac236c1bbf846e..6586d1dbdbbd19b53ce6f348ea3643f42da354eb:/cmdline/apt-helper.cc?ds=sidebyside diff --git a/cmdline/apt-helper.cc b/cmdline/apt-helper.cc index 482e64dd1..dc4efb32b 100644 --- a/cmdline/apt-helper.cc +++ b/cmdline/apt-helper.cc @@ -68,9 +68,6 @@ static bool DoDownloadFile(CommandLine &CmdL) fileind += 3; } - // Disable drop-privs if "_apt" can not write to the target dir - CheckDropPrivsMustBeDisabled(Fetcher); - bool Failed = false; if (AcquireRun(Fetcher, 0, &Failed, NULL) == false || Failed == true) return _error->Error(_("Download Failed")); @@ -84,23 +81,27 @@ static bool DoDownloadFile(CommandLine &CmdL) static bool DoSrvLookup(CommandLine &CmdL) { - if (CmdL.FileSize() < 1) - return _error->Error(_("Must specifc at least one srv record")); - - std::vector srv_records; - for(int i=1; CmdL.FileList[i] != NULL; i++) + if (CmdL.FileSize() <= 1) + return _error->Error("Must specify at least one SRV record"); + + for(size_t i = 1; CmdL.FileList[i] != NULL; ++i) { - if(GetSrvRecords(CmdL.FileList[i], srv_records) == false) - _error->Warning(_("GetSrvRec failed for %s"), CmdL.FileList[i]); - for (std::vector::const_iterator I = srv_records.begin(); - I != srv_records.end(); ++I) + std::vector srv_records; + std::string const name = CmdL.FileList[i]; + c0out << "# Target\tPriority\tWeight\tPort # for " << name << std::endl; + size_t const found = name.find(":"); + if (found != std::string::npos) { - c1out << (*I).target.c_str() << " " - << (*I).priority << " " - << (*I).weight << " " - << (*I).port << " " - << std::endl; + std::string const host = name.substr(0, found); + size_t const port = atoi(name.c_str() + found + 1); + if(GetSrvRecords(host, port, srv_records) == false) + _error->Error(_("GetSrvRec failed for %s"), name.c_str()); } + else if(GetSrvRecords(name, srv_records) == false) + _error->Error(_("GetSrvRec failed for %s"), name.c_str()); + + for (SrvRec const &I : srv_records) + c1out << I.target << "\t" << I.priority << "\t" << I.weight << "\t" << I.port << std::endl; } return true; } @@ -120,6 +121,7 @@ static bool ShowHelp(CommandLine &) "\n" "Commands:\n" " download-file - download the given uri to the target-path\n" + " srv-lookup - lookup a SRV record (e.g. _http._tcp.ftp.debian.org)\n" " auto-detect-proxy - detect proxy using apt.conf\n" "\n" " This APT helper has Super Meep Powers.\n");