From 870a2b6d683e58c0584bbd3614a76cf25a055928 Mon Sep 17 00:00:00 2001 From: Julian Andres Klode Date: Mon, 25 May 2015 16:45:05 +0200 Subject: ExecFork: Use /proc/self/fd to determine which files to close This significantly reduces the number of files that have to be closed and seems to be faster, despite the additional reads. On systems where /proc/self/fd is not available, we fallback to the old code that closes all file descriptors >= 3. Closes: #764204 --- apt-pkg/contrib/fileutl.cc | 24 +++++++++++++++++++----- 1 file changed, 19 insertions(+), 5 deletions(-) (limited to 'apt-pkg') diff --git a/apt-pkg/contrib/fileutl.cc b/apt-pkg/contrib/fileutl.cc index 1e6d96fe9..6e34f5d28 100644 --- a/apt-pkg/contrib/fileutl.cc +++ b/apt-pkg/contrib/fileutl.cc @@ -778,12 +778,26 @@ pid_t ExecFork(std::set KeepFDs) signal(SIGCONT,SIG_DFL); signal(SIGTSTP,SIG_DFL); - long ScOpenMax = sysconf(_SC_OPEN_MAX); - // Close all of our FDs - just in case - for (int K = 3; K != ScOpenMax; K++) + DIR *dir = opendir("/proc/self/fd"); + if (dir != NULL) { - if(KeepFDs.find(K) == KeepFDs.end()) - fcntl(K,F_SETFD,FD_CLOEXEC); + struct dirent *ent; + while ((ent = readdir(dir))) + { + int fd = atoi(ent->d_name); + // If fd > 0, it was a fd number and not . or .. + if (fd >= 3 && KeepFDs.find(fd) == KeepFDs.end()) + fcntl(fd,F_SETFD,FD_CLOEXEC); + } + closedir(dir); + } else { + long ScOpenMax = sysconf(_SC_OPEN_MAX); + // Close all of our FDs - just in case + for (int K = 3; K != ScOpenMax; K++) + { + if(KeepFDs.find(K) == KeepFDs.end()) + fcntl(K,F_SETFD,FD_CLOEXEC); + } } } -- cgit v1.2.3 From 3b216cf6b6e082b7de4dfece65601a96d269d529 Mon Sep 17 00:00:00 2001 From: Michael Vogt Date: Fri, 24 Jul 2015 17:34:30 +0200 Subject: updated for the gcc5 transition --- apt-pkg/cacheset.cc | 2 +- apt-pkg/contrib/configuration.h | 1 + apt-pkg/contrib/macros.h | 2 +- apt-pkg/deb/dpkgpm.cc | 11 +++++++++++ apt-pkg/deb/dpkgpm.h | 2 ++ apt-pkg/packagemanager.cc | 3 ++- apt-pkg/packagemanager.h | 8 ++++++++ 7 files changed, 26 insertions(+), 3 deletions(-) (limited to 'apt-pkg') diff --git a/apt-pkg/cacheset.cc b/apt-pkg/cacheset.cc index 2ed6a96da..74837dcb9 100644 --- a/apt-pkg/cacheset.cc +++ b/apt-pkg/cacheset.cc @@ -321,7 +321,7 @@ bool PackageContainerInterface::FromString(PackageContainerInterface * const pci if (FromGroup(pci, Cache, str, helper) == false && FromTask(pci, Cache, str, helper) == false && #if (APT_PKG_MAJOR >= 4 && APT_PKG_MINOR >= 13) - FromFnmatch(pci, Cache, str, helper) == false) + FromFnmatch(pci, Cache, str, helper) == false && #endif FromRegEx(pci, Cache, str, helper) == false) { diff --git a/apt-pkg/contrib/configuration.h b/apt-pkg/contrib/configuration.h index c256139f4..fde9cf851 100644 --- a/apt-pkg/contrib/configuration.h +++ b/apt-pkg/contrib/configuration.h @@ -33,6 +33,7 @@ #include #include #include +#include #ifndef APT_8_CLEANER_HEADERS using std::string; diff --git a/apt-pkg/contrib/macros.h b/apt-pkg/contrib/macros.h index 2d6448e5e..b9ec161af 100644 --- a/apt-pkg/contrib/macros.h +++ b/apt-pkg/contrib/macros.h @@ -138,7 +138,7 @@ // Non-ABI-Breaks should only increase RELEASE number. // See also buildlib/libversion.mak #define APT_PKG_MAJOR 4 -#define APT_PKG_MINOR 12 +#define APT_PKG_MINOR 16 #define APT_PKG_RELEASE 0 #endif diff --git a/apt-pkg/deb/dpkgpm.cc b/apt-pkg/deb/dpkgpm.cc index 82e045fd3..d17734fdc 100644 --- a/apt-pkg/deb/dpkgpm.cc +++ b/apt-pkg/deb/dpkgpm.cc @@ -1068,6 +1068,17 @@ bool pkgDPkgPM::Go(int StatusFd) return GoNoABIBreak(progress); } +#else +bool pkgDPkgPM::Go(int StatusFd) +{ + APT::Progress::PackageManager *progress = NULL; + if (StatusFd == -1) + progress = APT::Progress::PackageManagerProgressFactory(); + else + progress = new APT::Progress::PackageManagerProgressFd(StatusFd); + + return Go(progress); +} #endif void pkgDPkgPM::StartPtyMagic() diff --git a/apt-pkg/deb/dpkgpm.h b/apt-pkg/deb/dpkgpm.h index 2c1805015..e60f5fc3b 100644 --- a/apt-pkg/deb/dpkgpm.h +++ b/apt-pkg/deb/dpkgpm.h @@ -135,6 +135,8 @@ class pkgDPkgPM : public pkgPackageManager #if (APT_PKG_MAJOR >= 4 && APT_PKG_MINOR >= 13) virtual bool Go(APT::Progress::PackageManager *progress); + // compat + virtual bool Go(int StatusFd=-1); #else virtual bool Go(int StatusFd=-1); bool GoNoABIBreak(APT::Progress::PackageManager *progress); diff --git a/apt-pkg/packagemanager.cc b/apt-pkg/packagemanager.cc index 249542c68..4226a3686 100644 --- a/apt-pkg/packagemanager.cc +++ b/apt-pkg/packagemanager.cc @@ -28,7 +28,8 @@ #include #include #include - +#include + #include #include #include diff --git a/apt-pkg/packagemanager.h b/apt-pkg/packagemanager.h index d72790b6e..34b4b529f 100644 --- a/apt-pkg/packagemanager.h +++ b/apt-pkg/packagemanager.h @@ -45,6 +45,12 @@ class pkgSourceList; class pkgOrderList; class pkgRecords; +namespace APT { + namespace Progress { + class PackageManager; + class PackageManagerProgressFd; + } +} class pkgPackageManager : protected pkgCache::Namespace { @@ -93,6 +99,8 @@ class pkgPackageManager : protected pkgCache::Namespace virtual bool Remove(PkgIterator /*Pkg*/,bool /*Purge*/=false) {return false;}; #if (APT_PKG_MAJOR >= 4 && APT_PKG_MINOR >= 13) virtual bool Go(APT::Progress::PackageManager * /*progress*/) {return true;}; + // compat + virtual bool Go(int /*statusFd*/=-1) {return true;}; #else virtual bool Go(int /*statusFd*/=-1) {return true;}; #endif -- cgit v1.2.3 From 8965b2f8e6738463c20f69e76ba888a8d77225e3 Mon Sep 17 00:00:00 2001 From: David Kalnischkies Date: Sat, 9 May 2015 15:37:23 +0200 Subject: stop depending on copy-on-write for std::string In 66c3875df391b1120b43831efcbe88a78569fbfe we workaround/fixed a problem where the code makes the assumption that the compiler uses copy-on-write implementations for std::string. Turns out that for c++11 compatibility gcc >= 5 will stop doing this by default. --- apt-pkg/deb/debindexfile.cc | 26 +++++++++++++------------- apt-pkg/deb/debindexfile.h | 12 ++++++------ 2 files changed, 19 insertions(+), 19 deletions(-) (limited to 'apt-pkg') diff --git a/apt-pkg/deb/debindexfile.cc b/apt-pkg/deb/debindexfile.cc index 5b4289e92..504db919b 100644 --- a/apt-pkg/deb/debindexfile.cc +++ b/apt-pkg/deb/debindexfile.cc @@ -411,8 +411,8 @@ pkgCache::PkgFileIterator debPackagesIndex::FindInCache(pkgCache &Cache) const // TranslationsIndex::debTranslationsIndex - Contructor /*{{{*/ // --------------------------------------------------------------------- /* */ -debTranslationsIndex::debTranslationsIndex(string URI,string Dist,string Section, - char const * const Translation) : +debTranslationsIndex::debTranslationsIndex(std::string URI, std::string Dist, + std::string Section, std::string const &Translation) : pkgIndexFile(true), URI(URI), Dist(Dist), Section(Section), Language(Translation) {} @@ -457,7 +457,7 @@ string debTranslationsIndex::IndexURI(const char *Type) const bool debTranslationsIndex::GetIndexes(pkgAcquire *Owner) const { string const TranslationFile = string("Translation-").append(Language); - new pkgAcqIndexTrans(Owner, IndexURI(Language), + new pkgAcqIndexTrans(Owner, IndexURI(Language.c_str()), Info(TranslationFile.c_str()), TranslationFile); @@ -469,13 +469,13 @@ bool debTranslationsIndex::GetIndexes(pkgAcquire *Owner) const /* This should help the user find the index in the sources.list and in the filesystem for problem solving */ string debTranslationsIndex::Describe(bool Short) const -{ - char S[300]; +{ + std::string S; if (Short == true) - snprintf(S,sizeof(S),"%s",Info(TranslationFile().c_str()).c_str()); + strprintf(S,"%s",Info(TranslationFile().c_str()).c_str()); else - snprintf(S,sizeof(S),"%s (%s)",Info(TranslationFile().c_str()).c_str(), - IndexFile(Language).c_str()); + strprintf(S,"%s (%s)",Info(TranslationFile().c_str()).c_str(), + IndexFile(Language.c_str()).c_str()); return S; } /*}}}*/ @@ -499,7 +499,7 @@ string debTranslationsIndex::Info(const char *Type) const /*}}}*/ bool debTranslationsIndex::HasPackages() const /*{{{*/ { - return FileExists(IndexFile(Language)); + return FileExists(IndexFile(Language.c_str())); } /*}}}*/ // TranslationsIndex::Exists - Check if the index is available /*{{{*/ @@ -507,7 +507,7 @@ bool debTranslationsIndex::HasPackages() const /*{{{*/ /* */ bool debTranslationsIndex::Exists() const { - return FileExists(IndexFile(Language)); + return FileExists(IndexFile(Language.c_str())); } /*}}}*/ // TranslationsIndex::Size - Return the size of the index /*{{{*/ @@ -520,7 +520,7 @@ unsigned long debTranslationsIndex::Size() const /* we need to ignore errors here; if the lists are absent, just return 0 */ _error->PushToStack(); - FileFd f(IndexFile(Language), FileFd::ReadOnly, FileFd::Extension); + FileFd f(IndexFile(Language.c_str()), FileFd::ReadOnly, FileFd::Extension); if (!f.Failed()) size = f.Size(); @@ -537,7 +537,7 @@ unsigned long debTranslationsIndex::Size() const bool debTranslationsIndex::Merge(pkgCacheGenerator &Gen,OpProgress *Prog) const { // Check the translation file, if in use - string TranslationFile = IndexFile(Language); + string TranslationFile = IndexFile(Language.c_str()); if (FileExists(TranslationFile)) { FileFd Trans(TranslationFile,FileFd::ReadOnly, FileFd::Extension); @@ -567,7 +567,7 @@ bool debTranslationsIndex::Merge(pkgCacheGenerator &Gen,OpProgress *Prog) const /* */ pkgCache::PkgFileIterator debTranslationsIndex::FindInCache(pkgCache &Cache) const { - string FileName = IndexFile(Language); + string FileName = IndexFile(Language.c_str()); pkgCache::PkgFileIterator File = Cache.FileBegin(); for (; File.end() == false; ++File) diff --git a/apt-pkg/deb/debindexfile.h b/apt-pkg/deb/debindexfile.h index 017c69a0a..2c674087e 100644 --- a/apt-pkg/deb/debindexfile.h +++ b/apt-pkg/deb/debindexfile.h @@ -100,8 +100,8 @@ class debTranslationsIndex : public pkgIndexFile std::string URI; std::string Dist; std::string Section; - const char * const Language; - + std::string Language; + std::string Info(const char *Type) const; std::string IndexFile(const char *Type) const; std::string IndexURI(const char *Type) const; @@ -109,13 +109,13 @@ class debTranslationsIndex : public pkgIndexFile inline std::string TranslationFile() const {return std::string("Translation-").append(Language);}; public: - + virtual const Type *GetType() const APT_CONST; // Interface for acquire - virtual std::string Describe(bool Short) const; + virtual std::string Describe(bool Short) const; virtual bool GetIndexes(pkgAcquire *Owner) const; - + // Interface for the Cache Generator virtual bool Exists() const; virtual bool HasPackages() const; @@ -123,7 +123,7 @@ class debTranslationsIndex : public pkgIndexFile virtual bool Merge(pkgCacheGenerator &Gen,OpProgress *Prog) const; virtual pkgCache::PkgFileIterator FindInCache(pkgCache &Cache) const; - debTranslationsIndex(std::string URI,std::string Dist,std::string Section, char const * const Language); + debTranslationsIndex(std::string URI,std::string Dist,std::string Section, std::string const &Language); virtual ~debTranslationsIndex() {}; }; -- cgit v1.2.3 From 91cdf3199cb8487eb38a14e2d1d5195ebe51e802 Mon Sep 17 00:00:00 2001 From: David Kalnischkies Date: Sat, 25 Jul 2015 10:52:42 +0200 Subject: bump next-abi check above gcc5-abi bump Some of the 'simpler' abi changes are included in /sid already guarded behind #if's and now that we dumped the ABI fpr gcc5 they trigger. It would probably not hurt to have them trigger and it is an abi break anyway, but there isn't much point to it and it would be really annoying if one of them turns out to be a problem as these changes aren't as well tested as the 'old' abi. It is slightly incorrect to check for abi >= 17 as /experimental with this (and other changes) is abi = 15 currently, but writing the correct check would be just too insane for this dead ends branch. Final /experimental is probably better of increasing APT_PKG_MAJOR anyhow. --- apt-pkg/cacheset.cc | 10 +++++----- apt-pkg/cacheset.h | 4 ++-- apt-pkg/contrib/configuration.cc | 2 +- apt-pkg/contrib/configuration.h | 2 +- apt-pkg/deb/deblistparser.cc | 2 +- apt-pkg/deb/deblistparser.h | 2 +- apt-pkg/deb/debmetaindex.cc | 2 +- apt-pkg/deb/debmetaindex.h | 2 +- apt-pkg/deb/dpkgpm.cc | 4 ++-- apt-pkg/deb/dpkgpm.h | 4 ++-- apt-pkg/metaindex.h | 2 +- apt-pkg/packagemanager.cc | 6 +++--- apt-pkg/packagemanager.h | 6 +++--- apt-pkg/pkgcache.cc | 2 +- apt-pkg/pkgcachegen.h | 2 +- 15 files changed, 26 insertions(+), 26 deletions(-) (limited to 'apt-pkg') diff --git a/apt-pkg/cacheset.cc b/apt-pkg/cacheset.cc index 74837dcb9..760a744f2 100644 --- a/apt-pkg/cacheset.cc +++ b/apt-pkg/cacheset.cc @@ -212,7 +212,7 @@ PackageContainerInterface::FromFnmatch(PackageContainerInterface * const pci, } pci->insert(Pkg); -#if (APT_PKG_MAJOR >= 4 && APT_PKG_MINOR >= 13) +#if (APT_PKG_MAJOR >= 4 && APT_PKG_MINOR >= 17) helper.showFnmatchSelection(Pkg, pattern); #else helper.showRegExSelection(Pkg, pattern); @@ -221,7 +221,7 @@ PackageContainerInterface::FromFnmatch(PackageContainerInterface * const pci, } if (found == false) { -#if (APT_PKG_MAJOR >= 4 && APT_PKG_MINOR >= 13) +#if (APT_PKG_MAJOR >= 4 && APT_PKG_MINOR >= 17) helper.canNotFindFnmatch(pci, Cache, pattern); #else helper.canNotFindRegEx(pci, Cache, pattern); @@ -320,7 +320,7 @@ bool PackageContainerInterface::FromString(PackageContainerInterface * const pci if (FromGroup(pci, Cache, str, helper) == false && FromTask(pci, Cache, str, helper) == false && -#if (APT_PKG_MAJOR >= 4 && APT_PKG_MINOR >= 13) +#if (APT_PKG_MAJOR >= 4 && APT_PKG_MINOR >= 17) FromFnmatch(pci, Cache, str, helper) == false && #endif FromRegEx(pci, Cache, str, helper) == false) @@ -608,7 +608,7 @@ void CacheSetHelper::canNotFindRegEx(PackageContainerInterface * const /*pci*/, if (ShowError == true) _error->Insert(ErrorType, _("Couldn't find any package by regex '%s'"), pattern.c_str()); } -#if (APT_PKG_MAJOR >= 4 && APT_PKG_MINOR >= 13) +#if (APT_PKG_MAJOR >= 4 && APT_PKG_MINOR >= 17) // canNotFindFnmatch - handle the case no package is found by a fnmatch /*{{{*/ void CacheSetHelper::canNotFindFnmatch(PackageContainerInterface * const pci, pkgCacheFile &Cache, std::string pattern) { if (ShowError == true) @@ -674,7 +674,7 @@ APT_CONST void CacheSetHelper::showRegExSelection(pkgCache::PkgIterator const &/ std::string const &/*pattern*/) { } /*}}}*/ -#if (APT_PKG_MAJOR >= 4 && APT_PKG_MINOR >= 13) +#if (APT_PKG_MAJOR >= 4 && APT_PKG_MINOR >= 17) // showFnmatchSelection /*{{{*/ APT_CONST void CacheSetHelper::showFnmatchSelection(pkgCache::PkgIterator const &pkg, std::string const &pattern) { diff --git a/apt-pkg/cacheset.h b/apt-pkg/cacheset.h index b7229bc04..b1302c608 100644 --- a/apt-pkg/cacheset.h +++ b/apt-pkg/cacheset.h @@ -53,7 +53,7 @@ public: /*{{{*/ virtual void showTaskSelection(pkgCache::PkgIterator const &pkg, std::string const &pattern); virtual void showRegExSelection(pkgCache::PkgIterator const &pkg, std::string const &pattern); -#if (APT_PKG_MAJOR >= 4 && APT_PKG_MINOR >= 13) +#if (APT_PKG_MAJOR >= 4 && APT_PKG_MINOR >= 17) virtual void showFnmatchSelection(pkgCache::PkgIterator const &pkg, std::string const &pattern); #endif virtual void showSelectedVersion(pkgCache::PkgIterator const &Pkg, pkgCache::VerIterator const Ver, @@ -61,7 +61,7 @@ public: /*{{{*/ virtual void canNotFindTask(PackageContainerInterface * const pci, pkgCacheFile &Cache, std::string pattern); virtual void canNotFindRegEx(PackageContainerInterface * const pci, pkgCacheFile &Cache, std::string pattern); -#if (APT_PKG_MAJOR >= 4 && APT_PKG_MINOR >= 13) +#if (APT_PKG_MAJOR >= 4 && APT_PKG_MINOR >= 17) virtual void canNotFindFnmatch(PackageContainerInterface * const pci, pkgCacheFile &Cache, std::string pattern); #endif virtual void canNotFindPackage(PackageContainerInterface * const pci, pkgCacheFile &Cache, std::string const &str); diff --git a/apt-pkg/contrib/configuration.cc b/apt-pkg/contrib/configuration.cc index 00f6ad0f9..e0671bcc0 100644 --- a/apt-pkg/contrib/configuration.cc +++ b/apt-pkg/contrib/configuration.cc @@ -253,7 +253,7 @@ string Configuration::FindDir(const char *Name,const char *Default) const // Configuration::FindVector - Find a vector of values /*{{{*/ // --------------------------------------------------------------------- /* Returns a vector of config values under the given item */ -#if (APT_PKG_MAJOR >= 4 && APT_PKG_MINOR < 13) +#if (APT_PKG_MAJOR >= 4 && APT_PKG_MINOR < 17) vector Configuration::FindVector(const char *Name) const { return FindVector(Name, ""); } #endif vector Configuration::FindVector(const char *Name, std::string const &Default) const diff --git a/apt-pkg/contrib/configuration.h b/apt-pkg/contrib/configuration.h index fde9cf851..5273b29bb 100644 --- a/apt-pkg/contrib/configuration.h +++ b/apt-pkg/contrib/configuration.h @@ -85,7 +85,7 @@ class Configuration * \param Default list of values separated by commas */ std::vector FindVector(const char *Name, std::string const &Default) const; std::vector FindVector(std::string const &Name, std::string const &Default) const { return FindVector(Name.c_str(), Default); }; -#if (APT_PKG_MAJOR >= 4 && APT_PKG_MINOR >= 13) +#if (APT_PKG_MAJOR >= 4 && APT_PKG_MINOR >= 17) std::vector FindVector(const char *Name) const { return FindVector(Name, ""); }; #else std::vector FindVector(const char *Name) const; diff --git a/apt-pkg/deb/deblistparser.cc b/apt-pkg/deb/deblistparser.cc index e87e7b5e4..6d4fd9ac1 100644 --- a/apt-pkg/deb/deblistparser.cc +++ b/apt-pkg/deb/deblistparser.cc @@ -964,7 +964,7 @@ unsigned char debListParser::GetPrio(string Str) return Out; } /*}}}*/ -#if (APT_PKG_MAJOR >= 4 && APT_PKG_MINOR >= 13) +#if (APT_PKG_MAJOR >= 4 && APT_PKG_MINOR >= 17) bool debListParser::SameVersion(unsigned short const Hash, /*{{{*/ pkgCache::VerIterator const &Ver) { diff --git a/apt-pkg/deb/deblistparser.h b/apt-pkg/deb/deblistparser.h index 3b6963211..db7afa73c 100644 --- a/apt-pkg/deb/deblistparser.h +++ b/apt-pkg/deb/deblistparser.h @@ -71,7 +71,7 @@ class debListParser : public pkgCacheGenerator::ListParser virtual std::string DescriptionLanguage(); virtual MD5SumValue Description_md5(); virtual unsigned short VersionHash(); -#if (APT_PKG_MAJOR >= 4 && APT_PKG_MINOR >= 13) +#if (APT_PKG_MAJOR >= 4 && APT_PKG_MINOR >= 17) virtual bool SameVersion(unsigned short const Hash, pkgCache::VerIterator const &Ver); #endif virtual bool UsePackage(pkgCache::PkgIterator &Pkg, diff --git a/apt-pkg/deb/debmetaindex.cc b/apt-pkg/deb/debmetaindex.cc index 6fd12add8..7d72a6b2b 100644 --- a/apt-pkg/deb/debmetaindex.cc +++ b/apt-pkg/deb/debmetaindex.cc @@ -78,7 +78,7 @@ string debReleaseIndex::MetaIndexURI(const char *Type) const return Res; } -#if (APT_PKG_MAJOR >= 4 && APT_PKG_MINOR >= 13) +#if (APT_PKG_MAJOR >= 4 && APT_PKG_MINOR >= 17) std::string debReleaseIndex::LocalFileName() const { // see if we have a InRelease file diff --git a/apt-pkg/deb/debmetaindex.h b/apt-pkg/deb/debmetaindex.h index 2286fa8b2..7e9e0d482 100644 --- a/apt-pkg/deb/debmetaindex.h +++ b/apt-pkg/deb/debmetaindex.h @@ -51,7 +51,7 @@ class debReleaseIndex : public metaIndex { std::string MetaIndexFile(const char *Types) const; std::string MetaIndexURI(const char *Type) const; -#if (APT_PKG_MAJOR >= 4 && APT_PKG_MINOR >= 13) +#if (APT_PKG_MAJOR >= 4 && APT_PKG_MINOR >= 17) virtual std::string LocalFileName() const; #endif diff --git a/apt-pkg/deb/dpkgpm.cc b/apt-pkg/deb/dpkgpm.cc index d17734fdc..eca14f626 100644 --- a/apt-pkg/deb/dpkgpm.cc +++ b/apt-pkg/deb/dpkgpm.cc @@ -1057,7 +1057,7 @@ void pkgDPkgPM::BuildPackagesProgressMap() ++PackagesTotal; } /*}}}*/ -#if (APT_PKG_MAJOR >= 4 && APT_PKG_MINOR < 13) +#if (APT_PKG_MAJOR >= 4 && APT_PKG_MINOR < 17) bool pkgDPkgPM::Go(int StatusFd) { APT::Progress::PackageManager *progress = NULL; @@ -1234,7 +1234,7 @@ void pkgDPkgPM::StopPtyMagic() * through to human readable (and i10n-able) * names and calculates a percentage for each step. */ -#if (APT_PKG_MAJOR >= 4 && APT_PKG_MINOR >= 13) +#if (APT_PKG_MAJOR >= 4 && APT_PKG_MINOR >= 17) bool pkgDPkgPM::Go(APT::Progress::PackageManager *progress) #else bool pkgDPkgPM::GoNoABIBreak(APT::Progress::PackageManager *progress) diff --git a/apt-pkg/deb/dpkgpm.h b/apt-pkg/deb/dpkgpm.h index e60f5fc3b..a5e1fe221 100644 --- a/apt-pkg/deb/dpkgpm.h +++ b/apt-pkg/deb/dpkgpm.h @@ -118,7 +118,7 @@ class pkgDPkgPM : public pkgPackageManager void DoTerminalPty(int master); void DoDpkgStatusFd(int statusfd); void ProcessDpkgStatusLine(char *line); -#if (APT_PKG_MAJOR >= 4 && APT_PKG_MINOR < 13) +#if (APT_PKG_MAJOR >= 4 && APT_PKG_MINOR < 17) void DoDpkgStatusFd(int statusfd, int /*unused*/) { DoDpkgStatusFd(statusfd); } @@ -133,7 +133,7 @@ class pkgDPkgPM : public pkgPackageManager virtual bool Configure(PkgIterator Pkg); virtual bool Remove(PkgIterator Pkg,bool Purge = false); -#if (APT_PKG_MAJOR >= 4 && APT_PKG_MINOR >= 13) +#if (APT_PKG_MAJOR >= 4 && APT_PKG_MINOR >= 17) virtual bool Go(APT::Progress::PackageManager *progress); // compat virtual bool Go(int StatusFd=-1); diff --git a/apt-pkg/metaindex.h b/apt-pkg/metaindex.h index ffabaadbf..1393e7c5e 100644 --- a/apt-pkg/metaindex.h +++ b/apt-pkg/metaindex.h @@ -40,7 +40,7 @@ class metaIndex virtual const char* GetType() const {return Type;} // interface to to query it -#if (APT_PKG_MAJOR >= 4 && APT_PKG_MINOR >= 13) +#if (APT_PKG_MAJOR >= 4 && APT_PKG_MINOR >= 17) // returns the path of the local file (or "" if its not available) virtual std::string LocalFileName() const {return "";}; #endif diff --git a/apt-pkg/packagemanager.cc b/apt-pkg/packagemanager.cc index 4226a3686..7e91b4801 100644 --- a/apt-pkg/packagemanager.cc +++ b/apt-pkg/packagemanager.cc @@ -1059,7 +1059,7 @@ pkgPackageManager::OrderResult pkgPackageManager::OrderInstall() // PM::DoInstallPostFork - compat /*{{{*/ // --------------------------------------------------------------------- /*}}}*/ -#if (APT_PKG_MAJOR >= 4 && APT_PKG_MINOR >= 13) +#if (APT_PKG_MAJOR >= 4 && APT_PKG_MINOR >= 17) pkgPackageManager::OrderResult pkgPackageManager::DoInstallPostFork(int statusFd) { @@ -1096,7 +1096,7 @@ pkgPackageManager::DoInstallPostFork(int statusFd) // PM::DoInstall - Does the installation /*{{{*/ // --------------------------------------------------------------------- /* compat */ -#if (APT_PKG_MAJOR >= 4 && APT_PKG_MINOR >= 13) +#if (APT_PKG_MAJOR >= 4 && APT_PKG_MINOR >= 17) pkgPackageManager::OrderResult pkgPackageManager::DoInstall(int statusFd) { @@ -1120,7 +1120,7 @@ pkgPackageManager::OrderResult pkgPackageManager::DoInstall(int statusFd) // --------------------------------------------------------------------- /* This uses the filenames in FileNames and the information in the DepCache to perform the installation of packages.*/ -#if (APT_PKG_MAJOR >= 4 && APT_PKG_MINOR >= 13) +#if (APT_PKG_MAJOR >= 4 && APT_PKG_MINOR >= 17) pkgPackageManager::OrderResult pkgPackageManager::DoInstall(APT::Progress::PackageManager *progress) { diff --git a/apt-pkg/packagemanager.h b/apt-pkg/packagemanager.h index 34b4b529f..ed1d35b15 100644 --- a/apt-pkg/packagemanager.h +++ b/apt-pkg/packagemanager.h @@ -97,7 +97,7 @@ class pkgPackageManager : protected pkgCache::Namespace virtual bool Install(PkgIterator /*Pkg*/,std::string /*File*/) {return false;}; virtual bool Configure(PkgIterator /*Pkg*/) {return false;}; virtual bool Remove(PkgIterator /*Pkg*/,bool /*Purge*/=false) {return false;}; -#if (APT_PKG_MAJOR >= 4 && APT_PKG_MINOR >= 13) +#if (APT_PKG_MAJOR >= 4 && APT_PKG_MINOR >= 17) virtual bool Go(APT::Progress::PackageManager * /*progress*/) {return true;}; // compat virtual bool Go(int /*statusFd*/=-1) {return true;}; @@ -117,7 +117,7 @@ class pkgPackageManager : protected pkgCache::Namespace pkgRecords *Recs); // Do the installation -#if (APT_PKG_MAJOR >= 4 && APT_PKG_MINOR >= 13) +#if (APT_PKG_MAJOR >= 4 && APT_PKG_MINOR >= 17) OrderResult DoInstall(APT::Progress::PackageManager *progress); // compat APT_DEPRECATED OrderResult DoInstall(int statusFd=-1); @@ -131,7 +131,7 @@ class pkgPackageManager : protected pkgCache::Namespace Res = OrderInstall(); return Res; }; -#if (APT_PKG_MAJOR >= 4 && APT_PKG_MINOR >= 13) +#if (APT_PKG_MAJOR >= 4 && APT_PKG_MINOR >= 17) // stuff that needs to be done after the fork OrderResult DoInstallPostFork(APT::Progress::PackageManager *progress); // compat diff --git a/apt-pkg/pkgcache.cc b/apt-pkg/pkgcache.cc index a7b75dae8..05f44cad3 100644 --- a/apt-pkg/pkgcache.cc +++ b/apt-pkg/pkgcache.cc @@ -55,7 +55,7 @@ pkgCache::Header::Header() /* Whenever the structures change the major version should be bumped, whenever the generator changes the minor version should be bumped. */ MajorVersion = 8; -#if (APT_PKG_MAJOR >= 4 && APT_PKG_MINOR >= 13) +#if (APT_PKG_MAJOR >= 4 && APT_PKG_MINOR >= 17) MinorVersion = 2; #else MinorVersion = 1; diff --git a/apt-pkg/pkgcachegen.h b/apt-pkg/pkgcachegen.h index 1e1a71026..1cf90a1e0 100644 --- a/apt-pkg/pkgcachegen.h +++ b/apt-pkg/pkgcachegen.h @@ -169,7 +169,7 @@ class pkgCacheGenerator::ListParser * \param Hash of the currently parsed version * \param Ver to compare with */ -#if (APT_PKG_MAJOR >= 4 && APT_PKG_MINOR >= 13) +#if (APT_PKG_MAJOR >= 4 && APT_PKG_MINOR >= 17) virtual #endif APT_PURE bool SameVersion(unsigned short const Hash, pkgCache::VerIterator const &Ver); -- cgit v1.2.3 From 187bb83dc57c27d04e6706b442ba59976858e6f6 Mon Sep 17 00:00:00 2001 From: David Kalnischkies Date: Thu, 16 Apr 2015 11:01:37 +0200 Subject: hide first pdiff merge failure debug message The siblings of this message are all guarded as debug messages, just this one had it missing and subsequently causes display issues if triggered, which, given that clog is an alias for cerr, end up on stderr and therefore are reported as problems by tools only showing the stderr like our own cron script. [Backport of f4c7a238f4c29ac9b1e1172f103ab7dec5c5807d] Closes: 793444 --- apt-pkg/acquire-item.cc | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'apt-pkg') diff --git a/apt-pkg/acquire-item.cc b/apt-pkg/acquire-item.cc index 0bcafdc5c..3d911a959 100644 --- a/apt-pkg/acquire-item.cc +++ b/apt-pkg/acquire-item.cc @@ -834,7 +834,8 @@ void pkgAcqIndexMergeDiffs::Failed(string Message,pkgAcquire::MethodConfig * /*C // first failure means we should fallback State = StateErrorDiff; - std::clog << "Falling back to normal index file acquire" << std::endl; + if (Debug) + std::clog << "Falling back to normal index file acquire" << std::endl; new pkgAcqIndex(Owner, RealURI, Description,Desc.ShortDesc, ExpectedHash); } -- cgit v1.2.3 From d32010483fed74681bf9035a1c81adbcecbf1146 Mon Sep 17 00:00:00 2001 From: David Kalnischkies Date: Mon, 3 Aug 2015 07:00:33 +0200 Subject: mark again deps of pkgs in APT::Never-MarkAuto-Sections as manual MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit In 50ef3344c3afaaf9943142906b2f976a0337d264 (and similar for other branches), while 'fixing' the edgecase of a package being in multiple sections (e.g. moved from libs to oldlibs in newer releases) I accidently broke the feature itself completely by operating on the package itself and no longer on its dependencies… The behaviour isn't ideal in multiple ways, which we are hopefully able to fix with new ideas as mentioned in the buglog, but until then the functionality of this "hack" should be restored. Reported-By: Raphaël Hertzog Tested-By: Adam Conrad Closes: 793360 LP: 1479207 Thanks: Raphaël Hertzog and Adam Conrad for detailed reports and initial patches --- apt-pkg/depcache.cc | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) (limited to 'apt-pkg') diff --git a/apt-pkg/depcache.cc b/apt-pkg/depcache.cc index 16282df21..14c709c82 100644 --- a/apt-pkg/depcache.cc +++ b/apt-pkg/depcache.cc @@ -1103,7 +1103,12 @@ bool pkgDepCache::MarkInstall(PkgIterator const &Pkg,bool AutoInst, if (DebugMarker == true) std::clog << OutputInDepth(Depth) << "MarkInstall " << Pkg << " FU=" << FromUser << std::endl; - DepIterator Dep = P.InstVerIter(*this).DependsList(); + VerIterator const PV = P.InstVerIter(*this); + if (unlikely(PV.end() == true)) + return false; + bool const PinNeverMarkAutoSection = (PV->Section != 0 && ConfigValueInSubTree("APT::Never-MarkAuto-Sections", PV.Section())); + + DepIterator Dep = PV.DependsList(); for (; Dep.end() != true;) { // Grok or groups @@ -1226,7 +1231,7 @@ bool pkgDepCache::MarkInstall(PkgIterator const &Pkg,bool AutoInst, continue; } // now check if we should consider it a automatic dependency or not - if(InstPkg->CurrentVer == 0 && InstVer->Section != 0 && ConfigValueInSubTree("APT::Never-MarkAuto-Sections", InstVer.Section())) + if(InstPkg->CurrentVer == 0 && PinNeverMarkAutoSection) { if(DebugAutoInstall == true) std::clog << OutputInDepth(Depth) << "Setting NOT as auto-installed (direct " -- cgit v1.2.3 From 130f34b7bc48bb05cc192ca6c66606fd99509b3e Mon Sep 17 00:00:00 2001 From: Julian Andres Klode Date: Fri, 21 Aug 2015 18:00:37 +0200 Subject: Do not parse Status fields from remote sources This could allow an attacker to mark a package as installed in a remote package index, as long as the package was not listed in the dpkg status file. This way, an attacker could force the installation of a package during a dist-upgrade, by providing two packages in an index, an older marked as installed, and a newer - apt would "upgrade" to the newer version. --- apt-pkg/deb/debindexfile.cc | 2 +- apt-pkg/deb/deblistparser.cc | 7 ++++++- apt-pkg/deb/deblistparser.h | 7 +++++++ 3 files changed, 14 insertions(+), 2 deletions(-) (limited to 'apt-pkg') diff --git a/apt-pkg/deb/debindexfile.cc b/apt-pkg/deb/debindexfile.cc index 504db919b..de6371ace 100644 --- a/apt-pkg/deb/debindexfile.cc +++ b/apt-pkg/deb/debindexfile.cc @@ -621,7 +621,7 @@ bool debStatusIndex::Merge(pkgCacheGenerator &Gen,OpProgress *Prog) const FileFd Pkg(File,FileFd::ReadOnly, FileFd::Extension); if (_error->PendingError() == true) return false; - debListParser Parser(&Pkg); + debStatusListParser Parser(&Pkg); if (_error->PendingError() == true) return false; diff --git a/apt-pkg/deb/deblistparser.cc b/apt-pkg/deb/deblistparser.cc index 6d4fd9ac1..336414775 100644 --- a/apt-pkg/deb/deblistparser.cc +++ b/apt-pkg/deb/deblistparser.cc @@ -333,7 +333,7 @@ unsigned short debListParser::VersionHash() return Result; } /*}}}*/ -// ListParser::ParseStatus - Parse the status field /*{{{*/ +// StatusListParser::ParseStatus - Parse the status field /*{{{*/ // --------------------------------------------------------------------- /* Status lines are of the form, Status: want flag status @@ -344,6 +344,11 @@ unsigned short debListParser::VersionHash() */ bool debListParser::ParseStatus(pkgCache::PkgIterator &Pkg, pkgCache::VerIterator &Ver) +{ + return true; +} +bool debStatusListParser::ParseStatus(pkgCache::PkgIterator &Pkg, + pkgCache::VerIterator &Ver) { const char *Start; const char *Stop; diff --git a/apt-pkg/deb/deblistparser.h b/apt-pkg/deb/deblistparser.h index db7afa73c..d479997a3 100644 --- a/apt-pkg/deb/deblistparser.h +++ b/apt-pkg/deb/deblistparser.h @@ -117,4 +117,11 @@ class debTranslationsParser : public debListParser : debListParser(File, Arch) {}; }; +class APT_HIDDEN debStatusListParser : public debListParser +{ + public: + virtual bool ParseStatus(pkgCache::PkgIterator &Pkg,pkgCache::VerIterator &Ver); + debStatusListParser(FileFd *File) + : debListParser(File) {}; +}; #endif -- cgit v1.2.3