summaryrefslogtreecommitdiff
path: root/apt-pkg/contrib
diff options
context:
space:
mode:
authorMichael Vogt <mvo@debian.org>2015-08-18 11:57:35 +0200
committerMichael Vogt <mvo@debian.org>2015-08-18 11:57:35 +0200
commitb53c9cea2902572822bbbece5bac236c1bbf846e (patch)
tree6c6b0524e0971c0623ccbff71383523ee0b2a5cc /apt-pkg/contrib
parent21248c0f00ee71412dbadc6ebf84011cf974346d (diff)
parent2a22cd60f04c4291ea9b9b72e15b6d2ec378b001 (diff)
Merge remote-tracking branch 'upstream/debian/experimental' into feature/srv-records
Diffstat (limited to 'apt-pkg/contrib')
-rw-r--r--apt-pkg/contrib/cdromutl.cc2
-rw-r--r--apt-pkg/contrib/cmndline.cc8
-rw-r--r--apt-pkg/contrib/configuration.cc10
-rw-r--r--apt-pkg/contrib/configuration.h11
-rw-r--r--apt-pkg/contrib/fileutl.cc81
-rw-r--r--apt-pkg/contrib/fileutl.h32
-rw-r--r--apt-pkg/contrib/gpgv.cc19
-rw-r--r--apt-pkg/contrib/gpgv.h5
-rw-r--r--apt-pkg/contrib/hashes.cc52
-rw-r--r--apt-pkg/contrib/hashes.h18
-rw-r--r--apt-pkg/contrib/hashsum_template.h2
-rw-r--r--apt-pkg/contrib/macros.h10
-rw-r--r--apt-pkg/contrib/md5.h2
-rw-r--r--apt-pkg/contrib/progress.h5
-rw-r--r--apt-pkg/contrib/sha1.h2
-rw-r--r--apt-pkg/contrib/sha2.h6
-rw-r--r--apt-pkg/contrib/sptr.h12
-rw-r--r--apt-pkg/contrib/strutl.cc19
-rw-r--r--apt-pkg/contrib/strutl.h1
19 files changed, 197 insertions, 100 deletions
diff --git a/apt-pkg/contrib/cdromutl.cc b/apt-pkg/contrib/cdromutl.cc
index 6eb917457..428ef0161 100644
--- a/apt-pkg/contrib/cdromutl.cc
+++ b/apt-pkg/contrib/cdromutl.cc
@@ -287,9 +287,11 @@ string FindMountPointForDevice(const char *devnode)
fclose(f);
// unescape the \0XXX chars in the path
string mount_point = out[1];
+ free(line);
return DeEscapeString(mount_point);
}
fclose(f);
+ free(line);
}
return string();
diff --git a/apt-pkg/contrib/cmndline.cc b/apt-pkg/contrib/cmndline.cc
index ff8b09ebc..40365237e 100644
--- a/apt-pkg/contrib/cmndline.cc
+++ b/apt-pkg/contrib/cmndline.cc
@@ -124,7 +124,7 @@ bool CommandLine::Parse(int argc,const char **argv)
Args *A;
for (A = ArgList; A->end() == false && A->ShortOpt != *Opt; A++);
if (A->end() == true)
- return _error->Error(_("Command line option '%c' [from %s] is not known."),*Opt,argv[I]);
+ return _error->Error(_("Command line option '%c' [from %s] is not understood in combination with the other options."),*Opt,argv[I]);
if (HandleOpt(I,argc,argv,Opt,A) == false)
return false;
@@ -149,7 +149,7 @@ bool CommandLine::Parse(int argc,const char **argv)
{
Opt = (const char*) memchr(Opt, '-', OptEnd - Opt);
if (Opt == NULL)
- return _error->Error(_("Command line option %s is not understood"),argv[I]);
+ return _error->Error(_("Command line option %s is not understood in combination with the other options"),argv[I]);
Opt++;
for (A = ArgList; A->end() == false &&
@@ -158,7 +158,7 @@ bool CommandLine::Parse(int argc,const char **argv)
// Failed again..
if (A->end() == true && OptEnd - Opt != 1)
- return _error->Error(_("Command line option %s is not understood"),argv[I]);
+ return _error->Error(_("Command line option %s is not understood in combination with the other options"),argv[I]);
// The option could be a single letter option prefixed by a no-..
if (A->end() == true)
@@ -166,7 +166,7 @@ bool CommandLine::Parse(int argc,const char **argv)
for (A = ArgList; A->end() == false && A->ShortOpt != *Opt; A++);
if (A->end() == true)
- return _error->Error(_("Command line option %s is not understood"),argv[I]);
+ return _error->Error(_("Command line option %s is not understood in combination with the other options"),argv[I]);
}
// The option is not boolean
diff --git a/apt-pkg/contrib/configuration.cc b/apt-pkg/contrib/configuration.cc
index 42e35d32a..203de158b 100644
--- a/apt-pkg/contrib/configuration.cc
+++ b/apt-pkg/contrib/configuration.cc
@@ -253,13 +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_ABI < 413
-vector<string> Configuration::FindVector(const char *Name) const
-{
- return FindVector(Name, "");
-}
-#endif
-vector<string> Configuration::FindVector(const char *Name, std::string const &Default) const
+vector<string> Configuration::FindVector(const char *Name, std::string const &Default, bool const Keys) const
{
vector<string> Vec;
const Item *Top = Lookup(Name);
@@ -272,7 +266,7 @@ vector<string> Configuration::FindVector(const char *Name, std::string const &De
Item *I = Top->Child;
while(I != NULL)
{
- Vec.push_back(I->Value);
+ Vec.push_back(Keys ? I->Tag : I->Value);
I = I->Next;
}
if (Vec.empty() == true)
diff --git a/apt-pkg/contrib/configuration.h b/apt-pkg/contrib/configuration.h
index 8d7d51037..eacc26fda 100644
--- a/apt-pkg/contrib/configuration.h
+++ b/apt-pkg/contrib/configuration.h
@@ -84,15 +84,8 @@ class Configuration
*
* \param Name of the parent node
* \param Default list of values separated by commas */
-#if APT_PKG_ABI >= 413
- std::vector<std::string> FindVector(const char *Name, std::string const &Default = "") const;
- std::vector<std::string> FindVector(std::string const &Name, std::string const &Default = "") const { return FindVector(Name.c_str(), Default); };
-#else
- std::vector<std::string> FindVector(const char *Name, std::string const &Default) const;
- std::vector<std::string> FindVector(std::string const &Name, std::string const &Default) const { return FindVector(Name.c_str(), Default); };
- std::vector<std::string> FindVector(const char *Name) const;
- std::vector<std::string> FindVector(std::string const &Name) const { return FindVector(Name.c_str(), ""); };
-#endif
+ std::vector<std::string> FindVector(const char *Name, std::string const &Default = "", bool const Keys = false) const;
+ std::vector<std::string> FindVector(std::string const &Name, std::string const &Default = "", bool const Keys = false) const { return FindVector(Name.c_str(), Default, Keys); };
int FindI(const char *Name,int const &Default = 0) const;
int FindI(std::string const &Name,int const &Default = 0) const {return FindI(Name.c_str(),Default);};
diff --git a/apt-pkg/contrib/fileutl.cc b/apt-pkg/contrib/fileutl.cc
index 8ec868ec0..1be782bac 100644
--- a/apt-pkg/contrib/fileutl.cc
+++ b/apt-pkg/contrib/fileutl.cc
@@ -52,6 +52,7 @@
#include <set>
#include <algorithm>
+#include <memory>
#ifdef HAVE_ZLIB
#include <zlib.h>
@@ -159,7 +160,7 @@ bool CopyFile(FileFd &From,FileFd &To)
return false;
// Buffered copy between fds
- SPtrArray<unsigned char> Buf = new unsigned char[64000];
+ std::unique_ptr<unsigned char[]> Buf(new unsigned char[64000]);
unsigned long long Size = From.Size();
while (Size != 0)
{
@@ -167,8 +168,8 @@ bool CopyFile(FileFd &From,FileFd &To)
if (Size > 64000)
ToRead = 64000;
- if (From.Read(Buf,ToRead) == false ||
- To.Write(Buf,ToRead) == false)
+ if (From.Read(Buf.get(),ToRead) == false ||
+ To.Write(Buf.get(),ToRead) == false)
return false;
Size -= ToRead;
@@ -800,12 +801,26 @@ pid_t ExecFork(std::set<int> 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);
+ }
}
}
@@ -1011,6 +1026,25 @@ class FileFdPrivate { /*{{{*/
~FileFdPrivate() { CloseDown(""); }
};
/*}}}*/
+// FileFd Constructors /*{{{*/
+FileFd::FileFd(std::string FileName,unsigned int const Mode,unsigned long AccessMode) : iFd(-1), Flags(0), d(NULL)
+{
+ Open(FileName,Mode, None, AccessMode);
+}
+FileFd::FileFd(std::string FileName,unsigned int const Mode, CompressMode Compress, unsigned long AccessMode) : iFd(-1), Flags(0), d(NULL)
+{
+ Open(FileName,Mode, Compress, AccessMode);
+}
+FileFd::FileFd() : iFd(-1), Flags(AutoClose), d(NULL) {}
+FileFd::FileFd(int const Fd, unsigned int const Mode, CompressMode Compress) : iFd(-1), Flags(0), d(NULL)
+{
+ OpenDescriptor(Fd, Mode, Compress);
+}
+FileFd::FileFd(int const Fd, bool const AutoClose) : iFd(-1), Flags(0), d(NULL)
+{
+ OpenDescriptor(Fd, ReadWrite, None, AutoClose);
+}
+ /*}}}*/
// FileFd::Open - Open a file /*{{{*/
// ---------------------------------------------------------------------
/* The most commonly used open mode combinations are given with Mode */
@@ -2096,28 +2130,27 @@ std::string GetTempDir() /*{{{*/
return string(tmpdir);
}
/*}}}*/
-FileFd* GetTempFile(std::string const &Prefix, bool ImmediateUnlink) /*{{{*/
+FileFd* GetTempFile(std::string const &Prefix, bool ImmediateUnlink, FileFd * const TmpFd) /*{{{*/
{
char fn[512];
- FileFd *Fd = new FileFd();
+ FileFd * const Fd = TmpFd == NULL ? new FileFd() : TmpFd;
- std::string tempdir = GetTempDir();
- snprintf(fn, sizeof(fn), "%s/%s.XXXXXX",
+ std::string const tempdir = GetTempDir();
+ snprintf(fn, sizeof(fn), "%s/%s.XXXXXX",
tempdir.c_str(), Prefix.c_str());
- int fd = mkstemp(fn);
+ int const fd = mkstemp(fn);
if(ImmediateUnlink)
unlink(fn);
- if (fd < 0)
+ if (fd < 0)
{
_error->Errno("GetTempFile",_("Unable to mkstemp %s"), fn);
return NULL;
}
- if (!Fd->OpenDescriptor(fd, FileFd::WriteOnly, FileFd::None, true))
+ if (!Fd->OpenDescriptor(fd, FileFd::ReadWrite, FileFd::None, true))
{
_error->Errno("GetTempFile",_("Unable to write to %s"),fn);
return NULL;
}
-
return Fd;
}
/*}}}*/
@@ -2219,22 +2252,32 @@ bool DropPrivileges() /*{{{*/
return _error->Error("No user %s, can not drop rights", toUser.c_str());
// Do not change the order here, it might break things
+ // Get rid of all our supplementary groups first
if (setgroups(1, &pw->pw_gid))
return _error->Errno("setgroups", "Failed to setgroups");
+ // Now change the group ids to the new user
+#ifdef HAVE_SETRESGID
+ if (setresgid(pw->pw_gid, pw->pw_gid, pw->pw_gid) != 0)
+ return _error->Errno("setresgid", "Failed to set new group ids");
+#else
if (setegid(pw->pw_gid) != 0)
return _error->Errno("setegid", "Failed to setegid");
if (setgid(pw->pw_gid) != 0)
return _error->Errno("setgid", "Failed to setgid");
+#endif
+ // Change the user ids to the new user
+#ifdef HAVE_SETRESUID
+ if (setresuid(pw->pw_uid, pw->pw_uid, pw->pw_uid) != 0)
+ return _error->Errno("setresuid", "Failed to set new user ids");
+#else
if (setuid(pw->pw_uid) != 0)
return _error->Errno("setuid", "Failed to setuid");
-
- // the seteuid() is probably uneeded (at least thats what the linux
- // man-page says about setuid(2)) but we cargo culted it anyway
if (seteuid(pw->pw_uid) != 0)
return _error->Errno("seteuid", "Failed to seteuid");
+#endif
// Verify that the user has only a single group, and the correct one
gid_t groups[1];
diff --git a/apt-pkg/contrib/fileutl.h b/apt-pkg/contrib/fileutl.h
index 97cb05c56..acfd560ab 100644
--- a/apt-pkg/contrib/fileutl.h
+++ b/apt-pkg/contrib/fileutl.h
@@ -130,28 +130,17 @@ class FileFd
inline bool Eof() {return (Flags & HitEof) == HitEof;};
inline bool IsCompressed() {return (Flags & Compressed) == Compressed;};
inline std::string &Name() {return FileName;};
-
- FileFd(std::string FileName,unsigned int const Mode,unsigned long AccessMode = 0666) : iFd(-1), Flags(0), d(NULL)
- {
- Open(FileName,Mode, None, AccessMode);
- };
- FileFd(std::string FileName,unsigned int const Mode, CompressMode Compress, unsigned long AccessMode = 0666) : iFd(-1), Flags(0), d(NULL)
- {
- Open(FileName,Mode, Compress, AccessMode);
- };
- FileFd() : iFd(-1), Flags(AutoClose), d(NULL) {};
- FileFd(int const Fd, unsigned int const Mode = ReadWrite, CompressMode Compress = None) : iFd(-1), Flags(0), d(NULL)
- {
- OpenDescriptor(Fd, Mode, Compress);
- };
- FileFd(int const Fd, bool const AutoClose) : iFd(-1), Flags(0), d(NULL)
- {
- OpenDescriptor(Fd, ReadWrite, None, AutoClose);
- };
+
+ FileFd(std::string FileName,unsigned int const Mode,unsigned long AccessMode = 0666);
+ FileFd(std::string FileName,unsigned int const Mode, CompressMode Compress, unsigned long AccessMode = 0666);
+ FileFd();
+ FileFd(int const Fd, unsigned int const Mode = ReadWrite, CompressMode Compress = None);
+ FileFd(int const Fd, bool const AutoClose);
virtual ~FileFd();
private:
- FileFdPrivate* d;
+ FileFdPrivate * d;
+ APT_HIDDEN FileFd & operator=(const FileFd &);
APT_HIDDEN bool OpenInternDescriptor(unsigned int const Mode, APT::Configuration::Compressor const &compressor);
// private helpers to set Fail flag and call _error->Error
@@ -170,8 +159,9 @@ time_t GetModificationTime(std::string const &Path);
bool Rename(std::string From, std::string To);
std::string GetTempDir();
-FileFd* GetTempFile(std::string const &Prefix = "",
- bool ImmediateUnlink = true);
+FileFd* GetTempFile(std::string const &Prefix = "",
+ bool ImmediateUnlink = true,
+ FileFd * const TmpFd = NULL);
/** \brief Ensure the existence of the given Path
*
diff --git a/apt-pkg/contrib/gpgv.cc b/apt-pkg/contrib/gpgv.cc
index 9d798cca9..ef84da0d8 100644
--- a/apt-pkg/contrib/gpgv.cc
+++ b/apt-pkg/contrib/gpgv.cc
@@ -16,6 +16,8 @@
#include <sys/wait.h>
#include <unistd.h>
#include <stddef.h>
+
+#include <algorithm>
#include <iostream>
#include <string>
#include <vector>
@@ -42,7 +44,7 @@ static char * GenerateTemporaryFileTemplate(const char *basename) /*{{{*/
of the lifting in regards to merging keyrings. Fun for the whole family.
*/
void ExecGPGV(std::string const &File, std::string const &FileGPG,
- int const &statusfd, int fd[2])
+ int const &statusfd, int fd[2], std::string const &key)
{
#define EINTERNAL 111
std::string const aptkey = _config->FindFile("Dir::Bin::apt-key", "/usr/bin/apt-key");
@@ -55,6 +57,19 @@ void ExecGPGV(std::string const &File, std::string const &FileGPG,
Args.push_back(aptkey.c_str());
Args.push_back("--quiet");
Args.push_back("--readonly");
+ if (key.empty() == false)
+ {
+ if (key[0] == '/')
+ {
+ Args.push_back("--keyring");
+ Args.push_back(key.c_str());
+ }
+ else
+ {
+ Args.push_back("--keyid");
+ Args.push_back(key.c_str());
+ }
+ }
Args.push_back("verify");
char statusfdstr[10];
@@ -296,6 +311,8 @@ bool SplitClearSignedFile(std::string const &InFile, FileFd * const ContentFile,
// all the rest is whitespace, unsigned garbage or additional message blocks we ignore
}
fclose(in);
+ if (buf != NULL)
+ free(buf);
if (found_signature == true)
return _error->Error("Signature in file %s wasn't closed", InFile.c_str());
diff --git a/apt-pkg/contrib/gpgv.h b/apt-pkg/contrib/gpgv.h
index f018893fd..2a4cdad72 100644
--- a/apt-pkg/contrib/gpgv.h
+++ b/apt-pkg/contrib/gpgv.h
@@ -38,9 +38,12 @@ class FileFd;
*
* @param File is the message (unsigned or clear-signed)
* @param FileSig is the signature (detached or clear-signed)
+ * @param statusfd is the fd given to gpgv as --status-fd
+ * @param fd is used as a pipe for the standard output of gpgv
+ * @param key is the specific one to be used instead of using all
*/
void ExecGPGV(std::string const &File, std::string const &FileSig,
- int const &statusfd, int fd[2]) APT_NORETURN;
+ int const &statusfd, int fd[2], std::string const &Key = "") APT_NORETURN;
inline APT_NORETURN void ExecGPGV(std::string const &File, std::string const &FileSig,
int const &statusfd = -1) {
int fd[2];
diff --git a/apt-pkg/contrib/hashes.cc b/apt-pkg/contrib/hashes.cc
index 0fa443b4a..4481321c4 100644
--- a/apt-pkg/contrib/hashes.cc
+++ b/apt-pkg/contrib/hashes.cc
@@ -23,6 +23,7 @@
#include <stddef.h>
#include <algorithm>
#include <unistd.h>
+#include <stdlib.h>
#include <string>
#include <iostream>
/*}}}*/
@@ -178,6 +179,22 @@ HashString const * HashStringList::find(char const * const type) const /*{{{*/
return NULL;
}
/*}}}*/
+unsigned long long HashStringList::FileSize() const /*{{{*/
+{
+ HashString const * const hsf = find("Checksum-FileSize");
+ if (hsf == NULL)
+ return 0;
+ std::string const hv = hsf->HashValue();
+ return strtoull(hv.c_str(), NULL, 10);
+}
+ /*}}}*/
+bool HashStringList::FileSize(unsigned long long const Size) /*{{{*/
+{
+ std::string size;
+ strprintf(size, "%llu", Size);
+ return push_back(HashString("Checksum-FileSize", size));
+}
+ /*}}}*/
bool HashStringList::supported(char const * const type) /*{{{*/
{
for (char const * const * t = HashString::SupportedHashes(); *t != NULL; ++t)
@@ -259,7 +276,19 @@ public:
unsigned long long FileSize;
unsigned int CalcHashes;
- PrivateHashes(unsigned int const CalcHashes) : FileSize(0), CalcHashes(CalcHashes) {}
+ explicit PrivateHashes(unsigned int const CalcHashes) : FileSize(0), CalcHashes(CalcHashes) {}
+ explicit PrivateHashes(HashStringList const &Hashes) : FileSize(0) {
+ unsigned int calcHashes = Hashes.usable() ? 0 : ~0;
+ if (Hashes.find("MD5Sum") != NULL)
+ calcHashes |= Hashes::MD5SUM;
+ if (Hashes.find("SHA1") != NULL)
+ calcHashes |= Hashes::SHA1SUM;
+ if (Hashes.find("SHA256") != NULL)
+ calcHashes |= Hashes::SHA256SUM;
+ if (Hashes.find("SHA512") != NULL)
+ calcHashes |= Hashes::SHA512SUM;
+ CalcHashes = calcHashes;
+ }
};
/*}}}*/
// Hashes::Add* - Add the contents of data or FD /*{{{*/
@@ -351,25 +380,12 @@ APT_IGNORE_DEPRECATED_PUSH
if ((d->CalcHashes & SHA512SUM) == SHA512SUM)
hashes.push_back(HashString("SHA512", SHA512.Result().Value()));
APT_IGNORE_DEPRECATED_POP
- std::string SizeStr;
- strprintf(SizeStr, "%llu", d->FileSize);
- hashes.push_back(HashString("Checksum-FileSize", SizeStr));
+ hashes.FileSize(d->FileSize);
return hashes;
}
APT_IGNORE_DEPRECATED_PUSH
-Hashes::Hashes() { d = new PrivateHashes(~0); }
-Hashes::Hashes(unsigned int const Hashes) { d = new PrivateHashes(Hashes); }
-Hashes::Hashes(HashStringList const &Hashes) {
- unsigned int calcHashes = Hashes.usable() ? 0 : ~0;
- if (Hashes.find("MD5Sum") != NULL)
- calcHashes |= MD5SUM;
- if (Hashes.find("SHA1") != NULL)
- calcHashes |= SHA1SUM;
- if (Hashes.find("SHA256") != NULL)
- calcHashes |= SHA256SUM;
- if (Hashes.find("SHA512") != NULL)
- calcHashes |= SHA512SUM;
- d = new PrivateHashes(calcHashes);
-}
+Hashes::Hashes() : d(new PrivateHashes(~0)) { }
+Hashes::Hashes(unsigned int const Hashes) : d(new PrivateHashes(Hashes)) {}
+Hashes::Hashes(HashStringList const &Hashes) : d(new PrivateHashes(Hashes)) {}
Hashes::~Hashes() { delete d; }
APT_IGNORE_DEPRECATED_POP
diff --git a/apt-pkg/contrib/hashes.h b/apt-pkg/contrib/hashes.h
index ac13c8ace..0e6ff9ef1 100644
--- a/apt-pkg/contrib/hashes.h
+++ b/apt-pkg/contrib/hashes.h
@@ -87,6 +87,22 @@ class HashStringList
*/
HashString const * find(char const * const type) const;
HashString const * find(std::string const &type) const { return find(type.c_str()); }
+
+ /** finds the filesize hash and returns it as number
+ *
+ * @return beware: if the size isn't known we return \b 0 here,
+ * just like we would do for an empty file. If that is a problem
+ * for you have to get the size manually out of the list.
+ */
+ unsigned long long FileSize() const;
+
+ /** sets the filesize hash
+ *
+ * @param Size of the file
+ * @return @see #push_back
+ */
+ bool FileSize(unsigned long long const Size);
+
/** check if the given hash type is supported
*
* @param type to check
@@ -166,7 +182,7 @@ class HashStringList
class PrivateHashes;
class Hashes
{
- PrivateHashes *d;
+ PrivateHashes * const d;
public:
/* those will disappear in the future as it is hard to add new ones this way.
diff --git a/apt-pkg/contrib/hashsum_template.h b/apt-pkg/contrib/hashsum_template.h
index 869dc5cb7..d0ea0971e 100644
--- a/apt-pkg/contrib/hashsum_template.h
+++ b/apt-pkg/contrib/hashsum_template.h
@@ -87,7 +87,7 @@ class HashSumValue
Sum[I] = S[I];
}
- HashSumValue(std::string Str)
+ explicit HashSumValue(std::string const &Str)
{
memset(Sum,0,sizeof(Sum));
Set(Str);
diff --git a/apt-pkg/contrib/macros.h b/apt-pkg/contrib/macros.h
index 2f9c6c269..afa385c75 100644
--- a/apt-pkg/contrib/macros.h
+++ b/apt-pkg/contrib/macros.h
@@ -148,13 +148,19 @@
#define APT_IGNORE_DEPRECATED(XXX) XXX
#endif
+#if __cplusplus >= 201103L
+ #define APT_OVERRIDE override
+#else
+ #define APT_OVERRIDE /* no c++11 standard */
+#endif
+
// These lines are extracted by the makefiles and the buildsystem
// Increasing MAJOR or MINOR results in the need of recompiling all
// reverse-dependencies of libapt-pkg against the new SONAME.
// Non-ABI-Breaks should only increase RELEASE number.
// See also buildlib/libversion.mak
-#define APT_PKG_MAJOR 4
-#define APT_PKG_MINOR 15
+#define APT_PKG_MAJOR 5
+#define APT_PKG_MINOR 0
#define APT_PKG_RELEASE 0
#define APT_PKG_ABI ((APT_PKG_MAJOR * 100) + APT_PKG_MINOR)
diff --git a/apt-pkg/contrib/md5.h b/apt-pkg/contrib/md5.h
index f4992c223..a16ea4d2d 100644
--- a/apt-pkg/contrib/md5.h
+++ b/apt-pkg/contrib/md5.h
@@ -48,7 +48,7 @@ class MD5Summation : public SummationImplementation
public:
- bool Add(const unsigned char *inbuf, unsigned long long inlen);
+ bool Add(const unsigned char *inbuf, unsigned long long inlen) APT_OVERRIDE;
using SummationImplementation::Add;
MD5SumValue Result();
diff --git a/apt-pkg/contrib/progress.h b/apt-pkg/contrib/progress.h
index f7fbc9ccf..427b1bd35 100644
--- a/apt-pkg/contrib/progress.h
+++ b/apt-pkg/contrib/progress.h
@@ -24,6 +24,7 @@
#include <string>
#include <sys/time.h>
+#include <apt-pkg/macros.h>
#ifndef APT_8_CLEANER_HEADERS
using std::string;
@@ -74,12 +75,12 @@ class OpTextProgress : public OpProgress
bool NoUpdate;
bool NoDisplay;
unsigned long LastLen;
- virtual void Update();
+ virtual void Update() APT_OVERRIDE;
void Write(const char *S);
public:
- virtual void Done();
+ virtual void Done() APT_OVERRIDE;
OpTextProgress(bool NoUpdate = false) : NoUpdate(NoUpdate),
NoDisplay(false), LastLen(0) {};
diff --git a/apt-pkg/contrib/sha1.h b/apt-pkg/contrib/sha1.h
index 5770c315a..1c5cb5aa1 100644
--- a/apt-pkg/contrib/sha1.h
+++ b/apt-pkg/contrib/sha1.h
@@ -37,7 +37,7 @@ class SHA1Summation : public SummationImplementation
bool Done;
public:
- bool Add(const unsigned char *inbuf, unsigned long long inlen);
+ bool Add(const unsigned char *inbuf, unsigned long long inlen) APT_OVERRIDE;
using SummationImplementation::Add;
SHA1SumValue Result();
diff --git a/apt-pkg/contrib/sha2.h b/apt-pkg/contrib/sha2.h
index a25ad4d32..8b4bdd439 100644
--- a/apt-pkg/contrib/sha2.h
+++ b/apt-pkg/contrib/sha2.h
@@ -34,7 +34,7 @@ class SHA2SummationBase : public SummationImplementation
protected:
bool Done;
public:
- bool Add(const unsigned char *inbuf, unsigned long long len) = 0;
+ bool Add(const unsigned char *inbuf, unsigned long long len) APT_OVERRIDE = 0;
void Result();
};
@@ -45,7 +45,7 @@ class SHA256Summation : public SHA2SummationBase
unsigned char Sum[32];
public:
- bool Add(const unsigned char *inbuf, unsigned long long len)
+ bool Add(const unsigned char *inbuf, unsigned long long len) APT_OVERRIDE
{
if (Done)
return false;
@@ -78,7 +78,7 @@ class SHA512Summation : public SHA2SummationBase
unsigned char Sum[64];
public:
- bool Add(const unsigned char *inbuf, unsigned long long len)
+ bool Add(const unsigned char *inbuf, unsigned long long len) APT_OVERRIDE
{
if (Done)
return false;
diff --git a/apt-pkg/contrib/sptr.h b/apt-pkg/contrib/sptr.h
index 9df0e44a7..92f4cdec8 100644
--- a/apt-pkg/contrib/sptr.h
+++ b/apt-pkg/contrib/sptr.h
@@ -22,7 +22,7 @@
#define SMART_POINTER_H
template <class T>
-class SPtr
+class APT_DEPRECATED SPtr
{
public:
T *Ptr;
@@ -43,7 +43,7 @@ class SPtr
};
template <class T>
-class SPtrArray
+class APT_DEPRECATED SPtrArray
{
public:
T *Ptr;
@@ -60,7 +60,15 @@ class SPtrArray
inline SPtrArray(T *Ptr) : Ptr(Ptr) {};
inline SPtrArray() : Ptr(0) {};
+#if __GNUC__ >= 4
+ #pragma GCC diagnostic push
+ #pragma GCC diagnostic ignored "-Wunsafe-loop-optimizations"
+ // gcc warns about this, but we can do nothing hereā€¦
+#endif
inline ~SPtrArray() {delete [] Ptr;};
+#if __GNUC__ >= 4
+ #pragma GCC diagnostic pop
+#endif
};
#endif
diff --git a/apt-pkg/contrib/strutl.cc b/apt-pkg/contrib/strutl.cc
index 0db4c57b2..05624f7fb 100644
--- a/apt-pkg/contrib/strutl.cc
+++ b/apt-pkg/contrib/strutl.cc
@@ -1308,7 +1308,7 @@ void ioprintf(ostream &out,const char *format,...)
va_list args;
ssize_t size = 400;
while (true) {
- bool ret = false;
+ bool ret;
va_start(args,format);
ret = iovprintf(out, format, args, size);
va_end(args);
@@ -1322,7 +1322,7 @@ void strprintf(string &out,const char *format,...)
ssize_t size = 400;
std::ostringstream outstr;
while (true) {
- bool ret = false;
+ bool ret;
va_start(args,format);
ret = iovprintf(outstr, format, args, size);
va_end(args);
@@ -1637,8 +1637,6 @@ URI::operator string()
}
/*}}}*/
// URI::SiteOnly - Return the schema and site for the URI /*{{{*/
-// ---------------------------------------------------------------------
-/* */
string URI::SiteOnly(const string &URI)
{
::URI U(URI);
@@ -1648,9 +1646,18 @@ string URI::SiteOnly(const string &URI)
return U;
}
/*}}}*/
+// URI::ArchiveOnly - Return the schema, site and cleaned path for the URI /*{{{*/
+string URI::ArchiveOnly(const string &URI)
+{
+ ::URI U(URI);
+ U.User.clear();
+ U.Password.clear();
+ if (U.Path.empty() == false && U.Path[U.Path.length() - 1] == '/')
+ U.Path.erase(U.Path.length() - 1);
+ return U;
+}
+ /*}}}*/
// URI::NoUserPassword - Return the schema, site and path for the URI /*{{{*/
-// ---------------------------------------------------------------------
-/* */
string URI::NoUserPassword(const string &URI)
{
::URI U(URI);
diff --git a/apt-pkg/contrib/strutl.h b/apt-pkg/contrib/strutl.h
index d64270aaf..01bbfef72 100644
--- a/apt-pkg/contrib/strutl.h
+++ b/apt-pkg/contrib/strutl.h
@@ -167,6 +167,7 @@ class URI
inline void operator =(const std::string &From) {CopyFrom(From);}
inline bool empty() {return Access.empty();};
static std::string SiteOnly(const std::string &URI);
+ static std::string ArchiveOnly(const std::string &URI);
static std::string NoUserPassword(const std::string &URI);
URI(std::string Path) {CopyFrom(Path);}