summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichael Vogt <michael.vogt@ubuntu.com>2011-07-15 09:42:37 +0200
committerMichael Vogt <michael.vogt@ubuntu.com>2011-07-15 09:42:37 +0200
commit35555c1826da5df9f2c06a74f2e91be843ad8142 (patch)
tree9127cb9461a2de987748600c08682f7051ba12b7
parentcec8c646c79e40d928464b08a6f2e3ea62bb1611 (diff)
parent4b42f43bed369817398b6c8d538f08e5bf6dff76 (diff)
merged from donkult
-rw-r--r--apt-pkg/acquire-item.cc30
-rw-r--r--apt-pkg/acquire-item.h22
-rw-r--r--apt-pkg/acquire-method.h4
-rw-r--r--apt-pkg/acquire-worker.cc4
-rw-r--r--apt-pkg/acquire-worker.h6
-rw-r--r--apt-pkg/acquire.cc19
-rw-r--r--apt-pkg/acquire.h25
-rw-r--r--apt-pkg/contrib/hashes.cc38
-rw-r--r--apt-pkg/contrib/hashes.h5
-rw-r--r--apt-pkg/contrib/hashsum.cc27
-rw-r--r--apt-pkg/contrib/hashsum_template.h20
-rw-r--r--apt-pkg/contrib/md5.cc23
-rw-r--r--apt-pkg/contrib/md5.h16
-rw-r--r--apt-pkg/contrib/sha1.cc23
-rw-r--r--apt-pkg/contrib/sha1.h11
-rw-r--r--apt-pkg/contrib/sha2.cc43
-rw-r--r--apt-pkg/contrib/sha2.h27
-rw-r--r--apt-pkg/contrib/sha2_internal.cc16
-rw-r--r--apt-pkg/deb/debmetaindex.cc39
-rw-r--r--apt-pkg/deb/debmetaindex.h3
-rw-r--r--apt-pkg/makefile2
-rw-r--r--apt-pkg/metaindex.h4
-rw-r--r--apt-pkg/pkgcache.h4
-rw-r--r--cmdline/acqprogress.cc2
-rw-r--r--cmdline/apt-get.cc8
-rw-r--r--debian/changelog29
-rw-r--r--doc/apt-get.8.xml5
-rw-r--r--doc/sources.list.5.xml23
-rw-r--r--ftparchive/writer.cc34
-rw-r--r--test/hash.cc82
-rwxr-xr-xtest/integration/test-bug-596498-trusted-unsigned-repo47
-rw-r--r--test/libapt/hashsums_test.cc141
-rw-r--r--test/libapt/makefile6
-rwxr-xr-xtest/libapt/run-tests7
34 files changed, 463 insertions, 332 deletions
diff --git a/apt-pkg/acquire-item.cc b/apt-pkg/acquire-item.cc
index d790bd898..a6698b367 100644
--- a/apt-pkg/acquire-item.cc
+++ b/apt-pkg/acquire-item.cc
@@ -94,7 +94,7 @@ void pkgAcquire::Item::Failed(string Message,pkgAcquire::MethodConfig *Cnf)
// ---------------------------------------------------------------------
/* Stash status and the file size. Note that setting Complete means
sub-phases of the acquire process such as decompresion are operating */
-void pkgAcquire::Item::Start(string /*Message*/,unsigned long Size)
+void pkgAcquire::Item::Start(string /*Message*/,unsigned long long Size)
{
Status = StatFetching;
if (FileSize == 0 && Complete == false)
@@ -104,7 +104,7 @@ void pkgAcquire::Item::Start(string /*Message*/,unsigned long Size)
// Acquire::Item::Done - Item downloaded OK /*{{{*/
// ---------------------------------------------------------------------
/* */
-void pkgAcquire::Item::Done(string Message,unsigned long Size,string Hash,
+void pkgAcquire::Item::Done(string Message,unsigned long long Size,string Hash,
pkgAcquire::MethodConfig *Cnf)
{
// We just downloaded something..
@@ -245,7 +245,7 @@ void pkgAcqSubIndex::Failed(string Message,pkgAcquire::MethodConfig *Cnf) /*{{{*
}
}
/*}}}*/
-void pkgAcqSubIndex::Done(string Message,unsigned long Size,string Md5Hash, /*{{{*/
+void pkgAcqSubIndex::Done(string Message,unsigned long long Size,string Md5Hash, /*{{{*/
pkgAcquire::MethodConfig *Cnf)
{
if(Debug)
@@ -544,7 +544,7 @@ void pkgAcqDiffIndex::Failed(string Message,pkgAcquire::MethodConfig *Cnf) /*{{{
Dequeue();
}
/*}}}*/
-void pkgAcqDiffIndex::Done(string Message,unsigned long Size,string Md5Hash, /*{{{*/
+void pkgAcqDiffIndex::Done(string Message,unsigned long long Size,string Md5Hash, /*{{{*/
pkgAcquire::MethodConfig *Cnf)
{
if(Debug)
@@ -710,7 +710,7 @@ bool pkgAcqIndexDiffs::QueueNextDiff() /*{{{*/
return true;
}
/*}}}*/
-void pkgAcqIndexDiffs::Done(string Message,unsigned long Size,string Md5Hash, /*{{{*/
+void pkgAcqIndexDiffs::Done(string Message,unsigned long long Size,string Md5Hash, /*{{{*/
pkgAcquire::MethodConfig *Cnf)
{
if(Debug)
@@ -881,7 +881,7 @@ void pkgAcqIndex::Failed(string Message,pkgAcquire::MethodConfig *Cnf) /*{{{*/
to the uncompressed version of the file. If this is so the file
is copied into the partial directory. In all other cases the file
is decompressed with a gzip uri. */
-void pkgAcqIndex::Done(string Message,unsigned long Size,string Hash,
+void pkgAcqIndex::Done(string Message,unsigned long long Size,string Hash,
pkgAcquire::MethodConfig *Cfg)
{
Item::Done(Message,Size,Hash,Cfg);
@@ -1123,7 +1123,7 @@ string pkgAcqMetaSig::Custom600Headers()
return "\nIndex-File: true\nLast-Modified: " + TimeRFC1123(Buf.st_mtime);
}
-void pkgAcqMetaSig::Done(string Message,unsigned long Size,string MD5,
+void pkgAcqMetaSig::Done(string Message,unsigned long long Size,string MD5,
pkgAcquire::MethodConfig *Cfg)
{
Item::Done(Message,Size,MD5,Cfg);
@@ -1232,7 +1232,7 @@ string pkgAcqMetaIndex::Custom600Headers()
return "\nIndex-File: true\nLast-Modified: " + TimeRFC1123(Buf.st_mtime);
}
/*}}}*/
-void pkgAcqMetaIndex::Done(string Message,unsigned long Size,string Hash, /*{{{*/
+void pkgAcqMetaIndex::Done(string Message,unsigned long long Size,string Hash, /*{{{*/
pkgAcquire::MethodConfig *Cfg)
{
Item::Done(Message,Size,Hash,Cfg);
@@ -1768,7 +1768,7 @@ bool pkgAcqArchive::QueueNext()
if (stat(FinalFile.c_str(),&Buf) == 0)
{
// Make sure the size matches
- if ((unsigned)Buf.st_size == Version->Size)
+ if ((unsigned long long)Buf.st_size == Version->Size)
{
Complete = true;
Local = true;
@@ -1787,7 +1787,7 @@ bool pkgAcqArchive::QueueNext()
if (stat(FinalFile.c_str(),&Buf) == 0)
{
// Make sure the size matches
- if ((unsigned)Buf.st_size == Version->Size)
+ if ((unsigned long long)Buf.st_size == Version->Size)
{
Complete = true;
Local = true;
@@ -1807,7 +1807,7 @@ bool pkgAcqArchive::QueueNext()
if (stat(DestFile.c_str(),&Buf) == 0)
{
// Hmm, the partial file is too big, erase it
- if ((unsigned)Buf.st_size > Version->Size)
+ if ((unsigned long long)Buf.st_size > Version->Size)
unlink(DestFile.c_str());
else
PartialSize = Buf.st_size;
@@ -1830,7 +1830,7 @@ bool pkgAcqArchive::QueueNext()
// AcqArchive::Done - Finished fetching /*{{{*/
// ---------------------------------------------------------------------
/* */
-void pkgAcqArchive::Done(string Message,unsigned long Size,string CalcHash,
+void pkgAcqArchive::Done(string Message,unsigned long long Size,string CalcHash,
pkgAcquire::MethodConfig *Cfg)
{
Item::Done(Message,Size,CalcHash,Cfg);
@@ -1941,7 +1941,7 @@ void pkgAcqArchive::Finished()
// ---------------------------------------------------------------------
/* The file is added to the queue */
pkgAcqFile::pkgAcqFile(pkgAcquire *Owner,string URI,string Hash,
- unsigned long Size,string Dsc,string ShortDesc,
+ unsigned long long Size,string Dsc,string ShortDesc,
const string &DestDir, const string &DestFilename,
bool IsIndexFile) :
Item(Owner), ExpectedHash(Hash), IsIndexFile(IsIndexFile)
@@ -1969,7 +1969,7 @@ pkgAcqFile::pkgAcqFile(pkgAcquire *Owner,string URI,string Hash,
if (stat(DestFile.c_str(),&Buf) == 0)
{
// Hmm, the partial file is too big, erase it
- if ((unsigned)Buf.st_size > Size)
+ if ((unsigned long long)Buf.st_size > Size)
unlink(DestFile.c_str());
else
PartialSize = Buf.st_size;
@@ -1981,7 +1981,7 @@ pkgAcqFile::pkgAcqFile(pkgAcquire *Owner,string URI,string Hash,
// AcqFile::Done - Item downloaded OK /*{{{*/
// ---------------------------------------------------------------------
/* */
-void pkgAcqFile::Done(string Message,unsigned long Size,string CalcHash,
+void pkgAcqFile::Done(string Message,unsigned long long Size,string CalcHash,
pkgAcquire::MethodConfig *Cnf)
{
Item::Done(Message,Size,CalcHash,Cnf);
diff --git a/apt-pkg/acquire-item.h b/apt-pkg/acquire-item.h
index f763577ee..e6916a834 100644
--- a/apt-pkg/acquire-item.h
+++ b/apt-pkg/acquire-item.h
@@ -194,7 +194,7 @@ class pkgAcquire::Item : public WeakPointable
*
* \sa pkgAcqMethod
*/
- virtual void Done(string Message,unsigned long Size,string Hash,
+ virtual void Done(string Message,unsigned long long Size,string Hash,
pkgAcquire::MethodConfig *Cnf);
/** \brief Invoked when the worker starts to fetch this object.
@@ -206,7 +206,7 @@ class pkgAcquire::Item : public WeakPointable
*
* \sa pkgAcqMethod
*/
- virtual void Start(string Message,unsigned long Size);
+ virtual void Start(string Message,unsigned long long Size);
/** \brief Custom headers to be sent to the fetch process.
*
@@ -309,7 +309,7 @@ class pkgAcqSubIndex : public pkgAcquire::Item
public:
// Specialized action members
virtual void Failed(string Message,pkgAcquire::MethodConfig *Cnf);
- virtual void Done(string Message,unsigned long Size,string Md5Hash,
+ virtual void Done(string Message,unsigned long long Size,string Md5Hash,
pkgAcquire::MethodConfig *Cnf);
virtual string DescURI() {return Desc.URI;};
virtual string Custom600Headers();
@@ -372,7 +372,7 @@ class pkgAcqDiffIndex : public pkgAcquire::Item
public:
// Specialized action members
virtual void Failed(string Message,pkgAcquire::MethodConfig *Cnf);
- virtual void Done(string Message,unsigned long Size,string Md5Hash,
+ virtual void Done(string Message,unsigned long long Size,string Md5Hash,
pkgAcquire::MethodConfig *Cnf);
virtual string DescURI() {return RealURI + "Index";};
virtual string Custom600Headers();
@@ -508,7 +508,7 @@ class pkgAcqIndexDiffs : public pkgAcquire::Item
*/
virtual void Failed(string Message,pkgAcquire::MethodConfig *Cnf);
- virtual void Done(string Message,unsigned long Size,string Md5Hash,
+ virtual void Done(string Message,unsigned long long Size,string Md5Hash,
pkgAcquire::MethodConfig *Cnf);
virtual string DescURI() {return RealURI + "Index";};
@@ -581,7 +581,7 @@ class pkgAcqIndex : public pkgAcquire::Item
// Specialized action members
virtual void Failed(string Message,pkgAcquire::MethodConfig *Cnf);
- virtual void Done(string Message,unsigned long Size,string Md5Hash,
+ virtual void Done(string Message,unsigned long long Size,string Md5Hash,
pkgAcquire::MethodConfig *Cnf);
virtual string Custom600Headers();
virtual string DescURI() {return Desc.URI;};
@@ -723,7 +723,7 @@ class pkgAcqMetaSig : public pkgAcquire::Item
// Specialized action members
virtual void Failed(string Message,pkgAcquire::MethodConfig *Cnf);
- virtual void Done(string Message,unsigned long Size,string Md5Hash,
+ virtual void Done(string Message,unsigned long long Size,string Md5Hash,
pkgAcquire::MethodConfig *Cnf);
virtual string Custom600Headers();
virtual string DescURI() {return RealURI; };
@@ -818,7 +818,7 @@ class pkgAcqMetaIndex : public pkgAcquire::Item
// Specialized action members
virtual void Failed(string Message,pkgAcquire::MethodConfig *Cnf);
- virtual void Done(string Message,unsigned long Size, string Hash,
+ virtual void Done(string Message,unsigned long long Size, string Hash,
pkgAcquire::MethodConfig *Cnf);
virtual string Custom600Headers();
virtual string DescURI() {return RealURI; };
@@ -918,7 +918,7 @@ class pkgAcqArchive : public pkgAcquire::Item
public:
virtual void Failed(string Message,pkgAcquire::MethodConfig *Cnf);
- virtual void Done(string Message,unsigned long Size,string Hash,
+ virtual void Done(string Message,unsigned long long Size,string Hash,
pkgAcquire::MethodConfig *Cnf);
virtual string DescURI() {return Desc.URI;};
virtual string ShortDesc() {return Desc.ShortDesc;};
@@ -975,7 +975,7 @@ class pkgAcqFile : public pkgAcquire::Item
// Specialized action members
virtual void Failed(string Message,pkgAcquire::MethodConfig *Cnf);
- virtual void Done(string Message,unsigned long Size,string CalcHash,
+ virtual void Done(string Message,unsigned long long Size,string CalcHash,
pkgAcquire::MethodConfig *Cnf);
virtual string DescURI() {return Desc.URI;};
virtual string HashSum() {return ExpectedHash.toStr(); };
@@ -1012,7 +1012,7 @@ class pkgAcqFile : public pkgAcquire::Item
* is the absolute name to which the file should be downloaded.
*/
- pkgAcqFile(pkgAcquire *Owner, string URI, string Hash, unsigned long Size,
+ pkgAcqFile(pkgAcquire *Owner, string URI, string Hash, unsigned long long Size,
string Desc, string ShortDesc,
const string &DestDir="", const string &DestFilename="",
bool IsIndexFile=false);
diff --git a/apt-pkg/acquire-method.h b/apt-pkg/acquire-method.h
index 2d0fa4590..6551170c4 100644
--- a/apt-pkg/acquire-method.h
+++ b/apt-pkg/acquire-method.h
@@ -51,8 +51,8 @@ class pkgAcqMethod
time_t LastModified;
bool IMSHit;
string Filename;
- unsigned long Size;
- unsigned long ResumePoint;
+ unsigned long long Size;
+ unsigned long long ResumePoint;
void TakeHashes(Hashes &Hash);
FetchResult();
diff --git a/apt-pkg/acquire-worker.cc b/apt-pkg/acquire-worker.cc
index 75e03232a..3e1fd98db 100644
--- a/apt-pkg/acquire-worker.cc
+++ b/apt-pkg/acquire-worker.cc
@@ -287,9 +287,9 @@ bool pkgAcquire::Worker::RunMessages()
Log->Pulse(Owner->GetOwner());
OwnerQ->ItemDone(Itm);
- unsigned long const ServerSize = atol(LookupTag(Message,"Size","0").c_str());
+ unsigned long long const ServerSize = atoll(LookupTag(Message,"Size","0").c_str());
if (TotalSize != 0 && ServerSize != TotalSize)
- _error->Warning("Size of file %s is not what the server reported %s %lu",
+ _error->Warning("Size of file %s is not what the server reported %s %llu",
Owner->DestFile.c_str(), LookupTag(Message,"Size","0").c_str(),TotalSize);
// see if there is a hash to verify
diff --git a/apt-pkg/acquire-worker.h b/apt-pkg/acquire-worker.h
index 62545829a..ce19091e4 100644
--- a/apt-pkg/acquire-worker.h
+++ b/apt-pkg/acquire-worker.h
@@ -247,17 +247,17 @@ class pkgAcquire::Worker : public WeakPointable
/** \brief How many bytes of the file have been downloaded. Zero
* if the current progress of the file cannot be determined.
*/
- unsigned long CurrentSize;
+ unsigned long long CurrentSize;
/** \brief The total number of bytes to be downloaded. Zero if the
* total size of the final is unknown.
*/
- unsigned long TotalSize;
+ unsigned long long TotalSize;
/** \brief How much of the file was already downloaded prior to
* starting this worker.
*/
- unsigned long ResumePoint;
+ unsigned long long ResumePoint;
/** \brief Tell the subprocess to download the given item.
*
diff --git a/apt-pkg/acquire.cc b/apt-pkg/acquire.cc
index 9478cdfb4..2064abc50 100644
--- a/apt-pkg/acquire.cc
+++ b/apt-pkg/acquire.cc
@@ -37,9 +37,9 @@ using namespace std;
// Acquire::pkgAcquire - Constructor /*{{{*/
// ---------------------------------------------------------------------
/* We grab some runtime state from the configuration space */
-pkgAcquire::pkgAcquire() : Queues(0), Workers(0), Configs(0), Log(NULL), ToFetch(0),
+pkgAcquire::pkgAcquire() : LockFD(-1), Queues(0), Workers(0), Configs(0), Log(NULL), ToFetch(0),
Debug(_config->FindB("Debug::pkgAcquire",false)),
- Running(false), LockFD(-1)
+ Running(false)
{
string const Mode = _config->Find("Acquire::Queue-Mode","host");
if (strcasecmp(Mode.c_str(),"host") == 0)
@@ -47,10 +47,10 @@ pkgAcquire::pkgAcquire() : Queues(0), Workers(0), Configs(0), Log(NULL), ToFetch
if (strcasecmp(Mode.c_str(),"access") == 0)
QueueMode = QueueAccess;
}
-pkgAcquire::pkgAcquire(pkgAcquireStatus *Progress) : Queues(0), Workers(0),
+pkgAcquire::pkgAcquire(pkgAcquireStatus *Progress) : LockFD(-1), Queues(0), Workers(0),
Configs(0), Log(Progress), ToFetch(0),
Debug(_config->FindB("Debug::pkgAcquire",false)),
- Running(false), LockFD(-1)
+ Running(false)
{
string const Mode = _config->Find("Acquire::Queue-Mode","host");
if (strcasecmp(Mode.c_str(),"host") == 0)
@@ -799,7 +799,7 @@ bool pkgAcquireStatus::Pulse(pkgAcquire *Owner)
}
// Compute the current completion
- unsigned long ResumeSize = 0;
+ unsigned long long ResumeSize = 0;
for (pkgAcquire::Worker *I = Owner->WorkersBegin(); I != 0;
I = Owner->WorkerStep(I))
if (I->CurrentItem != 0 && I->CurrentItem->Owner->Complete == false)
@@ -838,7 +838,7 @@ bool pkgAcquireStatus::Pulse(pkgAcquire *Owner)
else
CurrentCPS = ((CurrentBytes - ResumeSize) - LastBytes)/Delta;
LastBytes = CurrentBytes - ResumeSize;
- ElapsedTime = (unsigned long)Delta;
+ ElapsedTime = (unsigned long long)Delta;
Time = NewTime;
}
@@ -849,8 +849,7 @@ bool pkgAcquireStatus::Pulse(pkgAcquire *Owner)
char msg[200];
long i = CurrentItems < TotalItems ? CurrentItems + 1 : CurrentItems;
- unsigned long ETA =
- (unsigned long)((TotalBytes - CurrentBytes) / CurrentCPS);
+ unsigned long long const ETA = (TotalBytes - CurrentBytes) / CurrentCPS;
// only show the ETA if it makes sense
if (ETA > 0 && ETA < 172800 /* two days */ )
@@ -906,13 +905,13 @@ void pkgAcquireStatus::Stop()
else
CurrentCPS = FetchedBytes/Delta;
LastBytes = CurrentBytes;
- ElapsedTime = (unsigned int)Delta;
+ ElapsedTime = (unsigned long long)Delta;
}
/*}}}*/
// AcquireStatus::Fetched - Called when a byte set has been fetched /*{{{*/
// ---------------------------------------------------------------------
/* This is used to get accurate final transfer rate reporting. */
-void pkgAcquireStatus::Fetched(unsigned long Size,unsigned long Resume)
+void pkgAcquireStatus::Fetched(unsigned long long Size,unsigned long long Resume)
{
FetchedBytes += Size - Resume;
}
diff --git a/apt-pkg/acquire.h b/apt-pkg/acquire.h
index 7db7a9958..c9eaa67d1 100644
--- a/apt-pkg/acquire.h
+++ b/apt-pkg/acquire.h
@@ -148,12 +148,7 @@ class pkgAcquire
/** \brief The progress indicator for this download. */
pkgAcquireStatus *Log;
- /** \brief The total size of the files which are to be fetched.
- *
- * This is not necessarily the total number of bytes to download
- * when, e.g., download resumption and list updates via patches
- * are taken into account.
- */
+ /** \brief The number of files which are to be fetched. */
unsigned long ToFetch;
// Configurable parameters for the scheduler
@@ -484,7 +479,7 @@ class pkgAcquire::Queue
*
* \todo Unimplemented. Implement it or remove?
*/
- bool ItemStart(QItem *Itm,unsigned long Size);
+ bool ItemStart(QItem *Itm,unsigned long long Size);
/** \brief Remove the given item from this queue and set its state
* to pkgAcquire::Item::StatDone.
@@ -655,8 +650,6 @@ struct pkgAcquire::MethodConfig
/** \brief A monitor object for downloads controlled by the pkgAcquire class. {{{
*
* \todo Why protected members?
- *
- * \todo Should the double members be uint64_t?
*/
class pkgAcquireStatus
{
@@ -674,34 +667,34 @@ class pkgAcquireStatus
/** \brief The number of bytes fetched as of the previous call to
* pkgAcquireStatus::Pulse, including local items.
*/
- double LastBytes;
+ unsigned long long LastBytes;
/** \brief The current rate of download as of the most recent call
* to pkgAcquireStatus::Pulse, in bytes per second.
*/
- double CurrentCPS;
+ unsigned long long CurrentCPS;
/** \brief The number of bytes fetched as of the most recent call
* to pkgAcquireStatus::Pulse, including local items.
*/
- double CurrentBytes;
+ unsigned long long CurrentBytes;
/** \brief The total number of bytes that need to be fetched.
*
* \warning This member is inaccurate, as new items might be
* enqueued while the download is in progress!
*/
- double TotalBytes;
+ unsigned long long TotalBytes;
/** \brief The total number of bytes accounted for by items that
* were successfully fetched.
*/
- double FetchedBytes;
+ unsigned long long FetchedBytes;
/** \brief The amount of time that has elapsed since the download
* started.
*/
- unsigned long ElapsedTime;
+ unsigned long long ElapsedTime;
/** \brief The total number of items that need to be fetched.
*
@@ -734,7 +727,7 @@ class pkgAcquireStatus
*
* \param ResumePoint How much of the file was already fetched.
*/
- virtual void Fetched(unsigned long Size,unsigned long ResumePoint);
+ virtual void Fetched(unsigned long long Size,unsigned long long ResumePoint);
/** \brief Invoked when the user should be prompted to change the
* inserted removable media.
diff --git a/apt-pkg/contrib/hashes.cc b/apt-pkg/contrib/hashes.cc
index 66ae33146..4407574fa 100644
--- a/apt-pkg/contrib/hashes.cc
+++ b/apt-pkg/contrib/hashes.cc
@@ -53,31 +53,30 @@ HashString::HashString(string StringedHash) /*{{{*/
/*}}}*/
bool HashString::VerifyFile(string filename) const /*{{{*/
{
- FileFd fd;
- MD5Summation MD5;
- SHA1Summation SHA1;
- SHA256Summation SHA256;
- SHA256Summation SHA512;
string fileHash;
FileFd Fd(filename, FileFd::ReadOnly);
- if(Type == "MD5Sum")
+ if(Type == "MD5Sum")
{
+ MD5Summation MD5;
MD5.AddFD(Fd.Fd(), Fd.Size());
fileHash = (string)MD5.Result();
- }
+ }
else if (Type == "SHA1")
{
+ SHA1Summation SHA1;
SHA1.AddFD(Fd.Fd(), Fd.Size());
fileHash = (string)SHA1.Result();
- }
- else if (Type == "SHA256")
+ }
+ else if (Type == "SHA256")
{
+ SHA256Summation SHA256;
SHA256.AddFD(Fd.Fd(), Fd.Size());
fileHash = (string)SHA256.Result();
}
- else if (Type == "SHA512")
+ else if (Type == "SHA512")
{
+ SHA512Summation SHA512;
SHA512.AddFD(Fd.Fd(), Fd.Size());
fileHash = (string)SHA512.Result();
}
@@ -107,7 +106,8 @@ string HashString::toStr() const
// Hashes::AddFD - Add the contents of the FD /*{{{*/
// ---------------------------------------------------------------------
/* */
-bool Hashes::AddFD(int Fd,unsigned long Size)
+bool Hashes::AddFD(int const Fd,unsigned long Size, bool const addMD5,
+ bool const addSHA1, bool const addSHA256, bool const addSHA512)
{
unsigned char Buf[64*64];
int Res = 0;
@@ -118,14 +118,18 @@ bool Hashes::AddFD(int Fd,unsigned long Size)
if (!ToEOF) n = min(Size,(unsigned long)n);
Res = read(Fd,Buf,n);
if (Res < 0 || (!ToEOF && (unsigned) Res != n)) // error, or short read
- return false;
+ return false;
if (ToEOF && Res == 0) // EOF
- break;
+ break;
Size -= Res;
- MD5.Add(Buf,Res);
- SHA1.Add(Buf,Res);
- SHA256.Add(Buf,Res);
- SHA512.Add(Buf,Res);
+ if (addMD5 == true)
+ MD5.Add(Buf,Res);
+ if (addSHA1 == true)
+ SHA1.Add(Buf,Res);
+ if (addSHA256 == true)
+ SHA256.Add(Buf,Res);
+ if (addSHA512 == true)
+ SHA512.Add(Buf,Res);
}
return true;
}
diff --git a/apt-pkg/contrib/hashes.h b/apt-pkg/contrib/hashes.h
index 4b6a08b1f..e702fcca2 100644
--- a/apt-pkg/contrib/hashes.h
+++ b/apt-pkg/contrib/hashes.h
@@ -67,7 +67,10 @@ class Hashes
return MD5.Add(Data,Size) && SHA1.Add(Data,Size) && SHA256.Add(Data,Size) && SHA512.Add(Data,Size);
};
inline bool Add(const char *Data) {return Add((unsigned char *)Data,strlen(Data));};
- bool AddFD(int Fd,unsigned long Size);
+ inline bool AddFD(int const Fd,unsigned long Size = 0)
+ { return AddFD(Fd, Size, true, true, true, true); };
+ bool AddFD(int const Fd, unsigned long Size, bool const addMD5,
+ bool const addSHA1, bool const addSHA256, bool const addSHA512);
inline bool Add(const unsigned char *Beg,const unsigned char *End)
{return Add(Beg,End-Beg);};
};
diff --git a/apt-pkg/contrib/hashsum.cc b/apt-pkg/contrib/hashsum.cc
new file mode 100644
index 000000000..728747d7a
--- /dev/null
+++ b/apt-pkg/contrib/hashsum.cc
@@ -0,0 +1,27 @@
+// Cryptographic API Base
+
+#include <unistd.h>
+#include "hashsum_template.h"
+
+// Summation::AddFD - Add content of file into the checksum /*{{{*/
+// ---------------------------------------------------------------------
+/* */
+bool SummationImplementation::AddFD(int const Fd, unsigned long Size) {
+ unsigned char Buf[64 * 64];
+ int Res = 0;
+ int ToEOF = (Size == 0);
+ while (Size != 0 || ToEOF)
+ {
+ unsigned n = sizeof(Buf);
+ if (!ToEOF) n = min(Size,(unsigned long)n);
+ Res = read(Fd, Buf, n);
+ if (Res < 0 || (!ToEOF && (unsigned) Res != n)) // error, or short read
+ return false;
+ if (ToEOF && Res == 0) // EOF
+ break;
+ Size -= Res;
+ Add(Buf,Res);
+ }
+ return true;
+}
+ /*}}}*/
diff --git a/apt-pkg/contrib/hashsum_template.h b/apt-pkg/contrib/hashsum_template.h
index 7667baf92..85d94c2af 100644
--- a/apt-pkg/contrib/hashsum_template.h
+++ b/apt-pkg/contrib/hashsum_template.h
@@ -84,4 +84,24 @@ class HashSumValue
}
};
+class SummationImplementation
+{
+ public:
+ virtual bool Add(const unsigned char *inbuf, unsigned long inlen) = 0;
+ inline bool Add(const char *inbuf, unsigned long const inlen)
+ { return Add((unsigned char *)inbuf, inlen); };
+
+ inline bool Add(const unsigned char *Data)
+ { return Add(Data, strlen((const char *)Data)); };
+ inline bool Add(const char *Data)
+ { return Add((const unsigned char *)Data, strlen((const char *)Data)); };
+
+ inline bool Add(const unsigned char *Beg, const unsigned char *End)
+ { return Add(Beg, End - Beg); };
+ inline bool Add(const char *Beg, const char *End)
+ { return Add((const unsigned char *)Beg, End - Beg); };
+
+ bool AddFD(int Fd, unsigned long Size = 0);
+};
+
#endif
diff --git a/apt-pkg/contrib/md5.cc b/apt-pkg/contrib/md5.cc
index 6820d3951..65e20e9bb 100644
--- a/apt-pkg/contrib/md5.cc
+++ b/apt-pkg/contrib/md5.cc
@@ -231,29 +231,6 @@ bool MD5Summation::Add(const unsigned char *data,unsigned long len)
return true;
}
/*}}}*/
-// MD5Summation::AddFD - Add the contents of a FD to the hash /*{{{*/
-// ---------------------------------------------------------------------
-/* */
-bool MD5Summation::AddFD(int Fd,unsigned long Size)
-{
- unsigned char Buf[64*64];
- int Res = 0;
- int ToEOF = (Size == 0);
- while (Size != 0 || ToEOF)
- {
- unsigned n = sizeof(Buf);
- if (!ToEOF) n = min(Size,(unsigned long)n);
- Res = read(Fd,Buf,n);
- if (Res < 0 || (!ToEOF && (unsigned) Res != n)) // error, or short read
- return false;
- if (ToEOF && Res == 0) // EOF
- break;
- Size -= Res;
- Add(Buf,Res);
- }
- return true;
-}
- /*}}}*/
// MD5Summation::Result - Returns the value of the sum /*{{{*/
// ---------------------------------------------------------------------
/* Because this must add in the last bytes of the series it prevents anyone
diff --git a/apt-pkg/contrib/md5.h b/apt-pkg/contrib/md5.h
index 9cc88cfbe..e76428325 100644
--- a/apt-pkg/contrib/md5.h
+++ b/apt-pkg/contrib/md5.h
@@ -34,26 +34,22 @@ using std::min;
#include "hashsum_template.h"
-class MD5Summation;
-
typedef HashSumValue<128> MD5SumValue;
-class MD5Summation
+class MD5Summation : public SummationImplementation
{
uint32_t Buf[4];
unsigned char Bytes[2*4];
unsigned char In[16*4];
bool Done;
-
+
public:
- bool Add(const unsigned char *Data,unsigned long Size);
- inline bool Add(const char *Data) {return Add((unsigned char *)Data,strlen(Data));};
- bool AddFD(int Fd,unsigned long Size);
- inline bool Add(const unsigned char *Beg,const unsigned char *End)
- {return Add(Beg,End-Beg);};
+ bool Add(const unsigned char *inbuf, unsigned long inlen);
+ using SummationImplementation::Add;
+
MD5SumValue Result();
-
+
MD5Summation();
};
diff --git a/apt-pkg/contrib/sha1.cc b/apt-pkg/contrib/sha1.cc
index 9a6725ef3..4b0552102 100644
--- a/apt-pkg/contrib/sha1.cc
+++ b/apt-pkg/contrib/sha1.cc
@@ -273,26 +273,3 @@ bool SHA1Summation::Add(const unsigned char *data,unsigned long len)
return true;
}
/*}}}*/
-// SHA1Summation::AddFD - Add content of file into the checksum /*{{{*/
-// ---------------------------------------------------------------------
-/* */
-bool SHA1Summation::AddFD(int Fd,unsigned long Size)
-{
- unsigned char Buf[64 * 64];
- int Res = 0;
- int ToEOF = (Size == 0);
- while (Size != 0 || ToEOF)
- {
- unsigned n = sizeof(Buf);
- if (!ToEOF) n = min(Size,(unsigned long)n);
- Res = read(Fd,Buf,n);
- if (Res < 0 || (!ToEOF && (unsigned) Res != n)) // error, or short read
- return false;
- if (ToEOF && Res == 0) // EOF
- break;
- Size -= Res;
- Add(Buf,Res);
- }
- return true;
-}
- /*}}}*/
diff --git a/apt-pkg/contrib/sha1.h b/apt-pkg/contrib/sha1.h
index e7683fa7b..2701fc67e 100644
--- a/apt-pkg/contrib/sha1.h
+++ b/apt-pkg/contrib/sha1.h
@@ -23,11 +23,9 @@ using std::min;
#include "hashsum_template.h"
-class SHA1Summation;
-
typedef HashSumValue<160> SHA1SumValue;
-class SHA1Summation
+class SHA1Summation : public SummationImplementation
{
/* assumes 64-bit alignment just in case */
unsigned char Buffer[64] __attribute__((aligned(8)));
@@ -36,12 +34,9 @@ class SHA1Summation
bool Done;
public:
+ bool Add(const unsigned char *inbuf, unsigned long inlen);
+ using SummationImplementation::Add;
- bool Add(const unsigned char *inbuf,unsigned long inlen);
- inline bool Add(const char *Data) {return Add((unsigned char *)Data,strlen(Data));};
- bool AddFD(int Fd,unsigned long Size);
- inline bool Add(const unsigned char *Beg,const unsigned char *End)
- {return Add(Beg,End-Beg);};
SHA1SumValue Result();
SHA1Summation();
diff --git a/apt-pkg/contrib/sha2.cc b/apt-pkg/contrib/sha2.cc
deleted file mode 100644
index 4604d3167..000000000
--- a/apt-pkg/contrib/sha2.cc
+++ /dev/null
@@ -1,43 +0,0 @@
-/*
- * Cryptographic API. {{{
- *
- * SHA-512, as specified in
- * http://csrc.nist.gov/cryptval/shs/sha256-384-512.pdf
- *
- * This program is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License as published by the Free
- * Software Foundation; either version 2 of the License, or (at your option)
- * any later version.
- *
- */ /*}}}*/
-
-#ifdef __GNUG__
-#pragma implementation "apt-pkg/sha2.h"
-#endif
-
-#include <apt-pkg/sha2.h>
-#include <apt-pkg/strutl.h>
-
-// SHA2Summation::AddFD - Add content of file into the checksum /*{{{*/
-// ---------------------------------------------------------------------
-/* */
-bool SHA2SummationBase::AddFD(int Fd,unsigned long Size){
- unsigned char Buf[64 * 64];
- int Res = 0;
- int ToEOF = (Size == 0);
- while (Size != 0 || ToEOF)
- {
- unsigned n = sizeof(Buf);
- if (!ToEOF) n = min(Size,(unsigned long)n);
- Res = read(Fd,Buf,n);
- if (Res < 0 || (!ToEOF && (unsigned) Res != n)) // error, or short read
- return false;
- if (ToEOF && Res == 0) // EOF
- break;
- Size -= Res;
- Add(Buf,Res);
- }
- return true;
-}
- /*}}}*/
-
diff --git a/apt-pkg/contrib/sha2.h b/apt-pkg/contrib/sha2.h
index bd5472527..386225889 100644
--- a/apt-pkg/contrib/sha2.h
+++ b/apt-pkg/contrib/sha2.h
@@ -22,31 +22,16 @@
#include "sha2_internal.h"
#include "hashsum_template.h"
-using std::string;
-using std::min;
-
-class SHA512Summation;
-class SHA256Summation;
-
typedef HashSumValue<512> SHA512SumValue;
typedef HashSumValue<256> SHA256SumValue;
-class SHA2SummationBase
+class SHA2SummationBase : public SummationImplementation
{
protected:
bool Done;
public:
- virtual bool Add(const unsigned char *inbuf,unsigned long inlen) = 0;
- virtual bool AddFD(int Fd,unsigned long Size);
+ bool Add(const unsigned char *inbuf, unsigned long len) = 0;
- inline bool Add(const char *Data)
- {
- return Add((unsigned char *)Data,strlen(Data));
- };
- inline bool Add(const unsigned char *Beg,const unsigned char *End)
- {
- return Add(Beg,End-Beg);
- };
void Result();
};
@@ -56,13 +41,15 @@ class SHA256Summation : public SHA2SummationBase
unsigned char Sum[32];
public:
- virtual bool Add(const unsigned char *inbuf, unsigned long len)
+ bool Add(const unsigned char *inbuf, unsigned long len)
{
if (Done)
return false;
SHA256_Update(&ctx, inbuf, len);
return true;
};
+ using SummationImplementation::Add;
+
SHA256SumValue Result()
{
if (!Done) {
@@ -86,13 +73,15 @@ class SHA512Summation : public SHA2SummationBase
unsigned char Sum[64];
public:
- virtual bool Add(const unsigned char *inbuf, unsigned long len)
+ bool Add(const unsigned char *inbuf, unsigned long len)
{
if (Done)
return false;
SHA512_Update(&ctx, inbuf, len);
return true;
};
+ using SummationImplementation::Add;
+
SHA512SumValue Result()
{
if (!Done) {
diff --git a/apt-pkg/contrib/sha2_internal.cc b/apt-pkg/contrib/sha2_internal.cc
index 10b82dec4..565db2f91 100644
--- a/apt-pkg/contrib/sha2_internal.cc
+++ b/apt-pkg/contrib/sha2_internal.cc
@@ -219,9 +219,9 @@ typedef u_int64_t sha2_word64; /* Exactly 8 bytes */
* library -- they are intended for private internal visibility/use
* only.
*/
-void SHA512_Last(SHA512_CTX*);
-void SHA256_Transform(SHA256_CTX*, const sha2_word32*);
-void SHA512_Transform(SHA512_CTX*, const sha2_word64*);
+static void SHA512_Last(SHA512_CTX*);
+static void SHA256_Transform(SHA256_CTX*, const sha2_word32*);
+static void SHA512_Transform(SHA512_CTX*, const sha2_word64*);
/*** SHA-XYZ INITIAL HASH VALUES AND CONSTANTS ************************/
@@ -379,7 +379,7 @@ void SHA256_Init(SHA256_CTX* context) {
(h) = T1 + Sigma0_256(a) + Maj((a), (b), (c)); \
j++
-void SHA256_Transform(SHA256_CTX* context, const sha2_word32* data) {
+static void SHA256_Transform(SHA256_CTX* context, const sha2_word32* data) {
sha2_word32 a, b, c, d, e, f, g, h, s0, s1;
sha2_word32 T1, *W256;
int j;
@@ -437,7 +437,7 @@ void SHA256_Transform(SHA256_CTX* context, const sha2_word32* data) {
#else /* SHA2_UNROLL_TRANSFORM */
-void SHA256_Transform(SHA256_CTX* context, const sha2_word32* data) {
+static void SHA256_Transform(SHA256_CTX* context, const sha2_word32* data) {
sha2_word32 a, b, c, d, e, f, g, h, s0, s1;
sha2_word32 T1, T2, *W256;
int j;
@@ -706,7 +706,7 @@ void SHA512_Init(SHA512_CTX* context) {
(h) = T1 + Sigma0_512(a) + Maj((a), (b), (c)); \
j++
-void SHA512_Transform(SHA512_CTX* context, const sha2_word64* data) {
+static void SHA512_Transform(SHA512_CTX* context, const sha2_word64* data) {
sha2_word64 a, b, c, d, e, f, g, h, s0, s1;
sha2_word64 T1, *W512 = (sha2_word64*)context->buffer;
int j;
@@ -761,7 +761,7 @@ void SHA512_Transform(SHA512_CTX* context, const sha2_word64* data) {
#else /* SHA2_UNROLL_TRANSFORM */
-void SHA512_Transform(SHA512_CTX* context, const sha2_word64* data) {
+static void SHA512_Transform(SHA512_CTX* context, const sha2_word64* data) {
sha2_word64 a, b, c, d, e, f, g, h, s0, s1;
sha2_word64 T1, T2, *W512 = (sha2_word64*)context->buffer;
int j;
@@ -887,7 +887,7 @@ void SHA512_Update(SHA512_CTX* context, const sha2_byte *data, size_t len) {
usedspace = freespace = 0;
}
-void SHA512_Last(SHA512_CTX* context) {
+static void SHA512_Last(SHA512_CTX* context) {
unsigned int usedspace;
usedspace = (context->bitcount[0] >> 3) % SHA512_BLOCK_LENGTH;
diff --git a/apt-pkg/deb/debmetaindex.cc b/apt-pkg/deb/debmetaindex.cc
index a91cc34e9..81afb22b6 100644
--- a/apt-pkg/deb/debmetaindex.cc
+++ b/apt-pkg/deb/debmetaindex.cc
@@ -142,11 +142,13 @@ string debReleaseIndex::TranslationIndexURI(const char *Type, const string &Sect
return URI + "dists/" + Dist + "/" + TranslationIndexURISuffix(Type, Section);
}
-debReleaseIndex::debReleaseIndex(string const &URI, string const &Dist) {
- this->URI = URI;
- this->Dist = Dist;
- this->Indexes = NULL;
- this->Type = "deb";
+debReleaseIndex::debReleaseIndex(string const &URI, string const &Dist) :
+ metaIndex(URI, Dist, "deb"), Trusted(CHECK_TRUST)
+{}
+
+debReleaseIndex::debReleaseIndex(string const &URI, string const &Dist, bool const Trusted) :
+ metaIndex(URI, Dist, "deb") {
+ SetTrusted(Trusted);
}
debReleaseIndex::~debReleaseIndex() {
@@ -252,8 +254,22 @@ bool debReleaseIndex::GetIndexes(pkgAcquire *Owner, bool const &GetAll) const
return true;
}
+void debReleaseIndex::SetTrusted(bool const Trusted)
+{
+ if (Trusted == true)
+ this->Trusted = ALWAYS_TRUSTED;
+ else
+ this->Trusted = NEVER_TRUSTED;
+}
+
bool debReleaseIndex::IsTrusted() const
{
+ if (Trusted == ALWAYS_TRUSTED)
+ return true;
+ else if (Trusted == NEVER_TRUSTED)
+ return false;
+
+
if(_config->FindB("APT::Authentication::TrustCDROM", false))
if(URI.substr(0,strlen("cdrom:")) == "cdrom:")
return true;
@@ -349,6 +365,7 @@ class debSLTypeDebian : public pkgSourceList::Type
vector<string> const Archs =
(arch != Options.end()) ? VectorizeString(arch->second, ',') :
APT::Configuration::getArchitectures();
+ map<string, string>::const_iterator const trusted = Options.find("trusted");
for (vector<metaIndex *>::const_iterator I = List.begin();
I != List.end(); I++)
@@ -358,6 +375,9 @@ class debSLTypeDebian : public pkgSourceList::Type
continue;
debReleaseIndex *Deb = (debReleaseIndex *) (*I);
+ if (trusted != Options.end())
+ Deb->SetTrusted(StringToBool(trusted->second, false));
+
/* This check insures that there will be only one Release file
queued for all the Packages files and Sources files it
corresponds to. */
@@ -375,9 +395,14 @@ class debSLTypeDebian : public pkgSourceList::Type
return true;
}
}
+
// No currently created Release file indexes this entry, so we create a new one.
- // XXX determine whether this release is trusted or not
- debReleaseIndex *Deb = new debReleaseIndex(URI, Dist);
+ debReleaseIndex *Deb;
+ if (trusted != Options.end())
+ Deb = new debReleaseIndex(URI, Dist, StringToBool(trusted->second, false));
+ else
+ Deb = new debReleaseIndex(URI, Dist);
+
if (IsSrc == true)
Deb->PushSectionEntry ("source", new debReleaseIndex::debSectionEntry(Section, IsSrc));
else
diff --git a/apt-pkg/deb/debmetaindex.h b/apt-pkg/deb/debmetaindex.h
index 0aaf7f14a..695cfa7cc 100644
--- a/apt-pkg/deb/debmetaindex.h
+++ b/apt-pkg/deb/debmetaindex.h
@@ -22,10 +22,12 @@ class debReleaseIndex : public metaIndex {
/** \brief dpointer placeholder (for later in case we need it) */
void *d;
std::map<string, vector<debSectionEntry const*> > ArchEntries;
+ enum { ALWAYS_TRUSTED, NEVER_TRUSTED, CHECK_TRUST } Trusted;
public:
debReleaseIndex(string const &URI, string const &Dist);
+ debReleaseIndex(string const &URI, string const &Dist, bool const Trusted);
virtual ~debReleaseIndex();
virtual string ArchiveURI(string const &File) const {return URI + File;};
@@ -43,6 +45,7 @@ class debReleaseIndex : public metaIndex {
string TranslationIndexURISuffix(const char *Type, const string &Section) const;
virtual vector <pkgIndexFile *> *GetIndexFiles();
+ void SetTrusted(bool const Trusted);
virtual bool IsTrusted() const;
void PushSectionEntry(vector<string> const &Archs, const debSectionEntry *Entry);
diff --git a/apt-pkg/makefile b/apt-pkg/makefile
index b11e35250..69d6cbffd 100644
--- a/apt-pkg/makefile
+++ b/apt-pkg/makefile
@@ -20,7 +20,7 @@ APT_DOMAIN:=libapt-pkg$(LIBAPTPKG_MAJOR)
# Source code for the contributed non-core things
SOURCE = contrib/mmap.cc contrib/error.cc contrib/strutl.cc \
contrib/configuration.cc contrib/progress.cc contrib/cmndline.cc \
- contrib/md5.cc contrib/sha1.cc contrib/sha2.cc \
+ contrib/hashsum.cc contrib/md5.cc contrib/sha1.cc \
contrib/sha2_internal.cc\
contrib/hashes.cc \
contrib/cdromutl.cc contrib/crc-16.cc contrib/netrc.cc \
diff --git a/apt-pkg/metaindex.h b/apt-pkg/metaindex.h
index 1d2140799..f60235a5d 100644
--- a/apt-pkg/metaindex.h
+++ b/apt-pkg/metaindex.h
@@ -39,6 +39,10 @@ class metaIndex
virtual vector<pkgIndexFile *> *GetIndexFiles() = 0;
virtual bool IsTrusted() const = 0;
+ metaIndex(string const &URI, string const &Dist, char const * const Type) :
+ Indexes(NULL), Type(Type), URI(URI), Dist(Dist) {
+ }
+
virtual ~metaIndex() {
if (Indexes == 0)
return;
diff --git a/apt-pkg/pkgcache.h b/apt-pkg/pkgcache.h
index 280f37bca..9a9f79420 100644
--- a/apt-pkg/pkgcache.h
+++ b/apt-pkg/pkgcache.h
@@ -506,7 +506,9 @@ struct pkgCache::Version
All = (1<<0), /*!< will cause that Ver.Arch() will report "all" */
Foreign = (1<<1), /*!< can satisfy dependencies in another architecture */
Same = (1<<2), /*!< can be co-installed with itself from other architectures */
- Allowed = (1<<3) /*!< other packages are allowed to depend on thispkg:any */ };
+ Allowed = (1<<3), /*!< other packages are allowed to depend on thispkg:any */
+ AllForeign = All | Foreign,
+ AllAllowed = All | Allowed };
/** \brief stores the MultiArch capabilities of this version
Flags used are defined in pkgCache::Version::VerMultiArch
diff --git a/cmdline/acqprogress.cc b/cmdline/acqprogress.cc
index ba334ce05..d2db949ea 100644
--- a/cmdline/acqprogress.cc
+++ b/cmdline/acqprogress.cc
@@ -200,7 +200,7 @@ bool AcqTextStatus::Pulse(pkgAcquire *Owner)
// Add the current progress
if (Mode == Long)
- snprintf(S,End-S," %lu",I->CurrentSize);
+ snprintf(S,End-S," %llu",I->CurrentSize);
else
{
if (Mode == Medium || I->TotalSize == 0)
diff --git a/cmdline/apt-get.cc b/cmdline/apt-get.cc
index 66ebd30b8..94e078cb3 100644
--- a/cmdline/apt-get.cc
+++ b/cmdline/apt-get.cc
@@ -135,6 +135,11 @@ bool YnPrompt(bool Default=true)
c1out << _("Y") << endl;
return true;
}
+ else if (_config->FindB("APT::Get::Assume-No",false) == true)
+ {
+ c1out << _("N") << endl;
+ return false;
+ }
char response[1024] = "";
cin.getline(response, sizeof(response));
@@ -3245,7 +3250,8 @@ int main(int argc,const char *argv[]) /*{{{*/
{'s',"dry-run","APT::Get::Simulate",0},
{'s',"no-act","APT::Get::Simulate",0},
{'y',"yes","APT::Get::Assume-Yes",0},
- {'y',"assume-yes","APT::Get::Assume-Yes",0},
+ {'y',"assume-yes","APT::Get::Assume-Yes",0},
+ {0,"assume-no","APT::Get::Assume-No",0},
{'f',"fix-broken","APT::Get::Fix-Broken",0},
{'u',"show-upgraded","APT::Get::Show-Upgraded",0},
{'m',"ignore-missing","APT::Get::Fix-Missing",0},
diff --git a/debian/changelog b/debian/changelog
index 478d6e1e2..d226d91c4 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -1,10 +1,26 @@
apt (0.8.16~exp3) UNRELEASEDexperimental; urgency=low
+ [ David Kalnischkies ]
+ * apt-pkg/pkgcache.h:
+ - readd All{Foreign,Allowed} as suggested by Julian to
+ remain strictly API compatible
+ * apt-pkg/acquire*.{cc,h}:
+ - try even harder to support really big files in the fetcher by
+ converting (hopefully) everything to 'long long' (Closes: #632271)
+ * ftparchive/writer.cc:
+ - generate all checksums in one run over the file for Release
+ * cmdline/apt-get.cc:
+ - add an --assume-no option for testing to say 'no' to everything
+ * apt-pkg/deb/debmetaindex.cc:
+ - add trusted=yes option to mark unsigned (local) repository as trusted
+ based on a patch from Ansgar Burchardt, thanks a lot! (Closes: #596498)
+
+ [ Michael Vogt ]
* merge fixes from the debian/unstable upload
* merge lp:~mvo/apt/sha512-template to get fixes for the
sha1/md5 verifiation (closes: #632520)
- -- Michael Vogt <michael.vogt@ubuntu.com> Thu, 30 Jun 2011 09:19:27 +0100
+ -- David Kalnischkies <kalnischkies@gmail.com> Thu, 14 Jul 2011 20:56:45 +0200
apt (0.8.16~exp2) experimental; urgency=low
@@ -46,6 +62,17 @@ apt (0.8.16~exp1) experimental; urgency=low
-- Michael Vogt <mvo@debian.org> Wed, 29 Jun 2011 12:40:31 +0200
+apt (0.8.15.2) unstable; urgency=low
+
+ [ David Kalnischkies ]
+ * apt-pkg/pkgcachegen.cc:
+ - fallback to memory if file is not writeable even if access()
+ told us the opposite before (e.g. in fakeroot 1.16) (Closes: #630591)
+ * doc/sources.list.5.xml:
+ - document available [options] for sources.list entries (Closes: 632441)
+
+ -- David Kalnischkies <kalnischkies@gmail.com> Tue, 05 Jul 2011 15:12:21 +0200
+
apt (0.8.15.1) unstable; urgency=low
[ David Kalnischkies ]
diff --git a/doc/apt-get.8.xml b/doc/apt-get.8.xml
index 11b53e5e7..23e682fd9 100644
--- a/doc/apt-get.8.xml
+++ b/doc/apt-get.8.xml
@@ -422,6 +422,11 @@
Configuration Item: <literal>APT::Get::Assume-Yes</literal>.</para></listitem>
</varlistentry>
+ <varlistentry><term><option>--assume-no</option></term>
+ <listitem><para>Automatic "no" to all prompts.
+ Configuration Item: <literal>APT::Get::Assume-No</literal>.</para></listitem>
+ </varlistentry>
+
<varlistentry><term><option>-u</option></term><term><option>--show-upgraded</option></term>
<listitem><para>Show upgraded packages; Print out a list of all packages that are to be
upgraded.
diff --git a/doc/sources.list.5.xml b/doc/sources.list.5.xml
index 837f07683..bf8356348 100644
--- a/doc/sources.list.5.xml
+++ b/doc/sources.list.5.xml
@@ -78,7 +78,7 @@
<para>The format for a <filename>sources.list</filename> entry using the
<literal>deb</literal> and <literal>deb-src</literal> types is:</para>
- <literallayout>deb uri distribution [component1] [component2] [...]</literallayout>
+ <literallayout>deb [ options ] uri distribution [component1] [component2] [...]</literallayout>
<para>The URI for the <literal>deb</literal> type must specify the base of the
Debian distribution, from which APT will find the information it needs.
@@ -109,6 +109,22 @@
simultaneous anonymous users. APT also parallelizes connections to
different hosts to more effectively deal with sites with low bandwidth.</para>
+ <para><literal>options</literal> is always optional and needs to be surounded by
+ square brackets. It can consist of multiple settings in the form
+ <literal><replaceable>setting</replaceable>=<replaceable>value</replaceable></literal>.
+ Multiple settings are separated by spaces. The following settings are supported by APT,
+ note through that unsupported settings will be ignored silently:
+ <itemizedlist><listitem><para><literal>arch=<replaceable>arch1</replaceable>,<replaceable>arch2</replaceable>,…</literal>
+ can be used to specify for which architectures packages information should
+ be downloaded. If this option is not set all architectures defined by the
+ <literal>APT::Architectures</literal> option will be downloaded.</para></listitem>
+ <listitem><para><literal>trusted=yes</literal> can be set to indicate that packages
+ from this source are always authenificated even if the <filename>Release</filename> file
+ is not signed or the signature can't be checked. This disables parts of &apt-secure;
+ and should therefore only be used in a local and trusted context. <literal>trusted=no</literal>
+ is the opposite which handles even correctly authenificated sources as not authenificated.</para></listitem>
+ </itemizedlist></para>
+
<para>It is important to list sources in order of preference, with the most
preferred source listed first. Typically this will result in sorting
by speed from fastest to slowest (CD-ROM followed by hosts on a local
@@ -206,6 +222,11 @@ deb http://security.debian.org/ &stable-codename;/updates main contrib non-free
<para>Source line for the above</para>
<literallayout>deb-src file:/home/jason/debian unstable main contrib non-free</literallayout>
+ <para>The first line gets package information for the architectures in <literal>APT::Architectures</literal>
+ while the second always retrieves <literal>amd64</literal> and <literal>armel</literal>.</para>
+ <literallayout>deb http://ftp.debian.org/debian &stable-codename; main
+deb [ arch=amd64,armel ] http://ftp.debian.org/debian &stable-codename; main</literallayout>
+
<para>Uses HTTP to access the archive at archive.debian.org, and uses only
the hamm/main area.</para>
<literallayout>deb http://archive.debian.org/debian-archive hamm main</literallayout>
diff --git a/ftparchive/writer.cc b/ftparchive/writer.cc
index c43e8f4b4..60db8b990 100644
--- a/ftparchive/writer.cc
+++ b/ftparchive/writer.cc
@@ -19,8 +19,7 @@
#include <apt-pkg/configuration.h>
#include <apt-pkg/aptconfiguration.h>
#include <apt-pkg/md5.h>
-#include <apt-pkg/sha1.h>
-#include <apt-pkg/sha2.h>
+#include <apt-pkg/hashes.h>
#include <apt-pkg/deblistparser.h>
#include <sys/types.h>
@@ -1040,35 +1039,18 @@ bool ReleaseWriter::DoPackage(string FileName)
CheckSums[NewFileName].size = fd.Size();
+ Hashes hs;
+ hs.AddFD(fd.Fd(), 0, DoMD5, DoSHA1, DoSHA256, DoSHA512);
if (DoMD5 == true)
- {
- MD5Summation MD5;
- MD5.AddFD(fd.Fd(), fd.Size());
- CheckSums[NewFileName].MD5 = MD5.Result();
- fd.Seek(0);
- }
+ CheckSums[NewFileName].MD5 = hs.MD5.Result();
if (DoSHA1 == true)
- {
- SHA1Summation SHA1;
- SHA1.AddFD(fd.Fd(), fd.Size());
- CheckSums[NewFileName].SHA1 = SHA1.Result();
- fd.Seek(0);
- }
+ CheckSums[NewFileName].SHA1 = hs.SHA1.Result();
if (DoSHA256 == true)
- {
- SHA256Summation SHA256;
- SHA256.AddFD(fd.Fd(), fd.Size());
- CheckSums[NewFileName].SHA256 = SHA256.Result();
- }
-
+ CheckSums[NewFileName].SHA256 = hs.SHA256.Result();
if (DoSHA512 == true)
- {
- SHA512Summation SHA512;
- SHA512.AddFD(fd.Fd(), fd.Size());
- CheckSums[NewFileName].SHA512 = SHA512.Result();
- }
+ CheckSums[NewFileName].SHA512 = hs.SHA512.Result();
fd.Close();
-
+
return true;
}
diff --git a/test/hash.cc b/test/hash.cc
deleted file mode 100644
index 88f09fca0..000000000
--- a/test/hash.cc
+++ /dev/null
@@ -1,82 +0,0 @@
-#include <apt-pkg/md5.h>
-#include <apt-pkg/sha1.h>
-#include <apt-pkg/sha2.h>
-#include <apt-pkg/strutl.h>
-#include <iostream>
-
-using namespace std;
-
-template <class T> void Test(const char *In,const char *Out)
-{
- T Sum;
- Sum.Add(In);
-
- cout << "expected: '" << Out << "'" << endl;
- cout << "got : '" << Sum.Result().Value() << "'" << endl;
- cout << "got : '" << Sum.Result().Value() << "'" << endl;
- cout << "got : '" << Sum.Result().Value() << "'" << endl;
- if (stringcasecmp(Sum.Result().Value(), Out) != 0) {
- cout << "FAIL" << endl << endl;
- abort();
- } else {
- cout << "PASS" << endl << endl;
- }
-}
-
-template <class T> void TestMill(const char *Out)
-{
- T Sum;
-
- const unsigned char As[] = "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa";
- unsigned Count = 1000000;
- for (; Count != 0;)
- {
- if (Count >= 64)
- {
- Sum.Add(As,64);
- Count -= 64;
- }
- else
- {
- Sum.Add(As,Count);
- Count = 0;
- }
- }
-
- if (stringcasecmp(Sum.Result().Value(), Out) != 0)
- abort();
-}
-
-int main()
-{
- // From FIPS PUB 180-1
- Test<SHA1Summation>("abc","A9993E364706816ABA3E25717850C26C9CD0D89D");
- Test<SHA1Summation>("abcdbcdecdefdefgefghfghighijhijkijkljklmklmnlmnomnopnopq",
- "84983E441C3BD26EBAAE4AA1F95129E5E54670F1");
- TestMill<SHA1Summation>("34AA973CD4C4DAA4F61EEB2BDBAD27316534016F");
-
- // MD5 tests from RFC 1321
- Test<MD5Summation>("","d41d8cd98f00b204e9800998ecf8427e");
- Test<MD5Summation>("a","0cc175b9c0f1b6a831c399e269772661");
- Test<MD5Summation>("abc","900150983cd24fb0d6963f7d28e17f72");
- Test<MD5Summation>("message digest","f96b697d7cb7938d525a2f31aaf161d0");
- Test<MD5Summation>("abcdefghijklmnopqrstuvwxyz","c3fcd3d76192e4007dfb496cca67e13b");
- Test<MD5Summation>("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789",
- "d174ab98d277d9f5a5611c2c9f419d9f");
- Test<MD5Summation>("12345678901234567890123456789012345678901234567890123456789012345678901234567890",
- "57edf4a22be3c955ac49da2e2107b67a");
-
- // SHA-256, From FIPS 180-2
- Test<SHA256Summation>("abcdbcdecdefdefgefghfghighijhijkijkljklmklmnlmnomnopnopq",
- "248d6a61d20638b8e5c026930c3e6039a33ce45964ff2167f6ecedd419db06c1");
-
- // SHA-512, From
- Test<SHA512Summation>(
- "abc",
- "ddaf35a193617abacc417349ae20413112e6fa4e89a97ea20a9eeee64b55d39a"
- "2192992a274fc1a836ba3c23a3feebbd454d4423643ce80e2a9ac94fa54ca49f");
-
- return 0;
-}
-
-
diff --git a/test/integration/test-bug-596498-trusted-unsigned-repo b/test/integration/test-bug-596498-trusted-unsigned-repo
new file mode 100755
index 000000000..6ebc4a3bb
--- /dev/null
+++ b/test/integration/test-bug-596498-trusted-unsigned-repo
@@ -0,0 +1,47 @@
+#!/bin/sh
+set -e
+
+TESTDIR=$(readlink -f $(dirname $0))
+. $TESTDIR/framework
+setupenvironment
+configarchitecture 'i386'
+
+buildsimplenativepackage 'cool' 'i386' '1.0' 'unstable'
+
+setupaptarchive
+
+aptgetupdate() {
+ rm -rf rootdir/var/lib/apt/ rootdir/var/cache/apt/*.bin
+ aptget update -qq
+}
+
+PKGTEXT="$(aptget install cool --assume-no -d | head -n 7)"
+DEBFILE='rootdir/etc/apt/sources.list.d/apt-test-unstable-deb.list'
+
+testequal "$PKGTEXT
+Download complete and in download only mode" aptget install cool --assume-no -d
+
+sed -i -e 's#deb#deb [trusted=no]#' $DEBFILE
+aptgetupdate
+
+testequal "$PKGTEXT
+WARNING: The following packages cannot be authenticated!
+ cool
+Install these packages without verification [y/N]? N
+E: Some packages could not be authenticated" aptget install cool --assume-no -d
+
+find aptarchive/ \( -name 'Release.gpg' -o -name 'InRelease' \) -delete
+sed -i -e 's#deb \[trusted=no\]#deb#' $DEBFILE
+aptgetupdate
+
+testequal "$PKGTEXT
+WARNING: The following packages cannot be authenticated!
+ cool
+Install these packages without verification [y/N]? N
+E: Some packages could not be authenticated" aptget install cool --assume-no -d
+
+sed -i -e 's#deb#deb [trusted=yes]#' $DEBFILE
+aptgetupdate
+
+testequal "$PKGTEXT
+Download complete and in download only mode" aptget install cool --assume-no -d
diff --git a/test/libapt/hashsums_test.cc b/test/libapt/hashsums_test.cc
new file mode 100644
index 000000000..ff1536718
--- /dev/null
+++ b/test/libapt/hashsums_test.cc
@@ -0,0 +1,141 @@
+#include <apt-pkg/md5.h>
+#include <apt-pkg/sha1.h>
+#include <apt-pkg/sha2.h>
+#include <apt-pkg/strutl.h>
+#include <apt-pkg/hashes.h>
+#include <iostream>
+
+#include <stdio.h>
+
+#include "assert.h"
+
+template <class T> void Test(const char *In,const char *Out)
+{
+ T Sum;
+ Sum.Add(In);
+ equals(Sum.Result().Value(), Out);
+}
+
+template <class T> void TestMill(const char *Out)
+{
+ T Sum;
+
+ const unsigned char As[] = "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa";
+ unsigned Count = 1000000;
+ for (; Count != 0;)
+ {
+ if (Count >= 64)
+ {
+ Sum.Add(As,64);
+ Count -= 64;
+ }
+ else
+ {
+ Sum.Add(As,Count);
+ Count = 0;
+ }
+ }
+
+ if (stringcasecmp(Sum.Result().Value(), Out) != 0)
+ abort();
+}
+
+int main(int argc, char** argv)
+{
+ // From FIPS PUB 180-1
+ Test<SHA1Summation>("","da39a3ee5e6b4b0d3255bfef95601890afd80709");
+ Test<SHA1Summation>("abc","a9993e364706816aba3e25717850c26c9cd0d89d");
+ Test<SHA1Summation>("abcdbcdecdefdefgefghfghighijhijkijkljklmklmnlmnomnopnopq",
+ "84983e441c3bd26ebaae4aa1f95129e5e54670f1");
+ TestMill<SHA1Summation>("34aa973cd4c4daa4f61eeb2bdbad27316534016f");
+
+ // MD5 tests from RFC 1321
+ Test<MD5Summation>("","d41d8cd98f00b204e9800998ecf8427e");
+ Test<MD5Summation>("a","0cc175b9c0f1b6a831c399e269772661");
+ Test<MD5Summation>("abc","900150983cd24fb0d6963f7d28e17f72");
+ Test<MD5Summation>("message digest","f96b697d7cb7938d525a2f31aaf161d0");
+ Test<MD5Summation>("abcdefghijklmnopqrstuvwxyz","c3fcd3d76192e4007dfb496cca67e13b");
+ Test<MD5Summation>("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789",
+ "d174ab98d277d9f5a5611c2c9f419d9f");
+ Test<MD5Summation>("12345678901234567890123456789012345678901234567890123456789012345678901234567890",
+ "57edf4a22be3c955ac49da2e2107b67a");
+
+ // SHA-256, From FIPS 180-2
+ Test<SHA256Summation>("", "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855");
+ Test<SHA256Summation>("abcdbcdecdefdefgefghfghighijhijkijkljklmklmnlmnomnopnopq",
+ "248d6a61d20638b8e5c026930c3e6039a33ce45964ff2167f6ecedd419db06c1");
+
+ // SHA-512
+ Test<SHA512Summation>("",
+ "cf83e1357eefb8bdf1542850d66d8007d620e4050b5715dc83f4a921d36ce9ce"
+ "47d0d13c5d85f2b0ff8318d2877eec2f63b931bd47417a81a538327af927da3e");
+ Test<SHA512Summation>(
+ "abc",
+ "ddaf35a193617abacc417349ae20413112e6fa4e89a97ea20a9eeee64b55d39a"
+ "2192992a274fc1a836ba3c23a3feebbd454d4423643ce80e2a9ac94fa54ca49f");
+
+
+ Test<MD5Summation>("The quick brown fox jumps over the lazy dog", "9e107d9d372bb6826bd81d3542a419d6");
+ Test<MD5Summation>("The quick brown fox jumps over the lazy dog.", "e4d909c290d0fb1ca068ffaddf22cbd0");
+ Test<SHA1Summation>("The quick brown fox jumps over the lazy dog", "2fd4e1c67a2d28fced849ee1bb76e7391b93eb12");
+ Test<SHA1Summation>("The quick brown fox jumps over the lazy cog", "de9f2c7fd25e1b3afad3e85a0bd17d9b100db4b3");
+ Test<SHA256Summation>("The quick brown fox jumps over the lazy dog", "d7a8fbb307d7809469ca9abcb0082e4f8d5651e46d3cdb762d02d0bf37c9e592");
+ Test<SHA256Summation>("The quick brown fox jumps over the lazy dog.", "ef537f25c895bfa782526529a9b63d97aa631564d5d789c2b765448c8635fb6c");
+ Test<SHA512Summation>("The quick brown fox jumps over the lazy dog", "07e547d9586f6a73f73fbac0435ed76951218fb7d0c8d788a309d785436bbb64"
+ "2e93a252a954f23912547d1e8a3b5ed6e1bfd7097821233fa0538f3db854fee6");
+ Test<SHA512Summation>("The quick brown fox jumps over the lazy dog.", "91ea1245f20d46ae9a037a989f54f1f790f0a47607eeb8a14d12890cea77a1bb"
+ "c6c7ed9cf205e67b7f2b8fd4c7dfd3a7a8617e45f3c463d481c7e586c39ac1ed");
+
+ FILE* fd = fopen(argv[1], "r");
+ if (fd == NULL) {
+ std::cerr << "Can't open file for 1. testing: " << argv[1] << std::endl;
+ return 1;
+ }
+ {
+ Hashes hashes;
+ hashes.AddFD(fileno(fd));
+ equals(argv[2], hashes.MD5.Result().Value());
+ equals(argv[3], hashes.SHA1.Result().Value());
+ equals(argv[4], hashes.SHA256.Result().Value());
+ equals(argv[5], hashes.SHA512.Result().Value());
+ }
+ fseek(fd, 0L, SEEK_END);
+ unsigned long sz = ftell(fd);
+ fseek(fd, 0L, SEEK_SET);
+ {
+ Hashes hashes;
+ hashes.AddFD(fileno(fd), sz);
+ equals(argv[2], hashes.MD5.Result().Value());
+ equals(argv[3], hashes.SHA1.Result().Value());
+ equals(argv[4], hashes.SHA256.Result().Value());
+ equals(argv[5], hashes.SHA512.Result().Value());
+ }
+ fseek(fd, 0L, SEEK_SET);
+ {
+ MD5Summation md5;
+ md5.AddFD(fileno(fd));
+ equals(argv[2], md5.Result().Value());
+ }
+ fseek(fd, 0L, SEEK_SET);
+ {
+ SHA1Summation sha1;
+ sha1.AddFD(fileno(fd));
+ equals(argv[3], sha1.Result().Value());
+ }
+ fseek(fd, 0L, SEEK_SET);
+ {
+ SHA256Summation sha2;
+ sha2.AddFD(fileno(fd));
+ equals(argv[4], sha2.Result().Value());
+ }
+ fseek(fd, 0L, SEEK_SET);
+ {
+ SHA512Summation sha2;
+ sha2.AddFD(fileno(fd));
+ equals(argv[5], sha2.Result().Value());
+ }
+ fclose(fd);
+ return 0;
+}
+
+
diff --git a/test/libapt/makefile b/test/libapt/makefile
index 50058262e..1d36f0c7c 100644
--- a/test/libapt/makefile
+++ b/test/libapt/makefile
@@ -46,3 +46,9 @@ PROGRAM = GlobalError${BASENAME}
SLIBS = -lapt-pkg
SOURCE = globalerror_test.cc
include $(PROGRAM_H)
+
+# test the different Hashsum classes
+PROGRAM = HashSums${BASENAME}
+SLIBS = -lapt-pkg
+SOURCE = hashsums_test.cc
+include $(PROGRAM_H)
diff --git a/test/libapt/run-tests b/test/libapt/run-tests
index 4b71c2097..0eea6d4f8 100755
--- a/test/libapt/run-tests
+++ b/test/libapt/run-tests
@@ -53,6 +53,13 @@ do
"${tmppath}/ftp.de.debian.org_debian_dists_sid_main_i18n_Translation-pt" \
"${tmppath}/ftp.de.debian.org_debian_dists_sid_main_i18n_Translation-se~" \
"${tmppath}/ftp.de.debian.org_debian_dists_sid_main_i18n_Translation-st.bak"
+ elif [ $name = "HashSums${EXT}" ]; then
+ TMP="$(mktemp)"
+ dmesg > $TMP
+ echo -n "Testing with \033[1;35m${name}\033[0m ... "
+ LD_LIBRARY_PATH=${LDPATH} ${testapp} $TMP $(md5sum $TMP | cut -d' ' -f 1) $(sha1sum $TMP | cut -d' ' -f 1) $(sha256sum $TMP | cut -d' ' -f 1) $(sha512sum $TMP | cut -d' ' -f 1) && echo "\033[1;32mOKAY\033[0m" || echo "\033[1;31mFAILED\033[0m"
+ rm $TMP
+ continue
fi
echo -n "Testing with \033[1;35m${name}\033[0m ... "