Browse Source

* apt-pkg/acquire*.cc:

- handle redirections in the worker with the right method instead of
    in the method the redirection occured in (Closes: #668111)
* methods/http.cc:
  - forbid redirects to change protocol
debian/1.8.y
Raphael Geissert 10 years ago
committed by David Kalnischkies
parent
commit
5674f6b316
  1. 18
      apt-pkg/acquire-method.cc
  2. 15
      apt-pkg/acquire-worker.cc
  3. 39
      apt-pkg/acquire.cc
  4. 7
      debian/changelog
  5. 5
      methods/http.cc

18
apt-pkg/acquire-method.cc

@ -412,26 +412,14 @@ void pkgAcqMethod::Status(const char *Format,...)
/*}}}*/
// AcqMethod::Redirect - Send a redirect message /*{{{*/
// ---------------------------------------------------------------------
/* This method sends the redirect message and also manipulates the queue
to keep the pipeline synchronized. */
/* This method sends the redirect message and dequeues the item as
* the worker will enqueue again later on to the right queue */
void pkgAcqMethod::Redirect(const string &NewURI)
{
std::cout << "103 Redirect\nURI: " << Queue->Uri << "\n"
<< "New-URI: " << NewURI << "\n"
<< "\n" << std::flush;
// Change the URI for the request.
Queue->Uri = NewURI;
/* To keep the pipeline synchronized, move the current request to
the end of the queue, past the end of the current pipeline. */
FetchItem *I;
for (I = Queue; I->Next != 0; I = I->Next) ;
I->Next = Queue;
Queue = Queue->Next;
I->Next->Next = 0;
if (QueueBack == 0)
QueueBack = I->Next;
Dequeue();
}
/*}}}*/
// AcqMethod::FetchResult::FetchResult - Constructor /*{{{*/

15
apt-pkg/acquire-worker.cc

@ -244,6 +244,21 @@ bool pkgAcquire::Worker::RunMessages()
string NewURI = LookupTag(Message,"New-URI",URI.c_str());
Itm->URI = NewURI;
ItemDone();
pkgAcquire::Item *Owner = Itm->Owner;
pkgAcquire::ItemDesc Desc = *Itm;
// Change the status so that it can be dequeued
Owner->Status = pkgAcquire::Item::StatIdle;
// Mark the item as done (taking care of all queues)
// and then put it in the main queue again
OwnerQ->ItemDone(Itm);
OwnerQ->Owner->Enqueue(Desc);
if (Log != 0)
Log->Done(Desc);
break;
}

39
apt-pkg/acquire.cc

@ -244,11 +244,19 @@ void pkgAcquire::Dequeue(Item *Itm)
{
Queue *I = Queues;
bool Res = false;
for (; I != 0; I = I->Next)
Res |= I->Dequeue(Itm);
if (Debug == true)
clog << "Dequeuing " << Itm->DestFile << endl;
for (; I != 0; I = I->Next)
{
if (I->Dequeue(Itm))
{
Res = true;
if (Debug == true)
clog << "Dequeued from " << I->Name << endl;
}
}
if (Res == true)
ToFetch--;
}
@ -269,9 +277,30 @@ string pkgAcquire::QueueName(string Uri,MethodConfig const *&Config)
/* Single-Instance methods get exactly one queue per URI. This is
also used for the Access queue method */
if (Config->SingleInstance == true || QueueMode == QueueAccess)
return U.Access;
return U.Access;
string AccessSchema = U.Access + ':',
FullQueueName = AccessSchema + U.Host;
unsigned int Instances = 0, SchemaLength = AccessSchema.length();
Queue *I = Queues;
for (; I != 0; I = I->Next) {
// if the queue already exists, re-use it
if (I->Name == FullQueueName)
return FullQueueName;
if (I->Name.compare(0, SchemaLength, AccessSchema) == 0)
Instances++;
}
if (Debug) {
clog << "Found " << Instances << " instances of " << U.Access << endl;
}
if (Instances >= (unsigned int)_config->FindI("Acquire::QueueHost::Limit",10))
return U.Access;
return U.Access + ':' + U.Host;
return FullQueueName;
}
/*}}}*/
// Acquire::GetConfig - Fetch the configuration information /*{{{*/

7
debian/changelog

@ -18,6 +18,13 @@ apt (0.9.4) UNRELEASED; urgency=low
* apt-pkg/acquire-methods.cc:
- factor out into private Dequeue() to fix access to deleted pointer
[ Raphael Geissert ]
* apt-pkg/acquire*.cc:
- handle redirections in the worker with the right method instead of
in the method the redirection occured in (Closes: #668111)
* methods/http.cc:
- forbid redirects to change protocol
-- David Kalnischkies <kalnischkies@gmail.com> Fri, 11 May 2012 23:26:59 +0200
apt (0.9.3) unstable; urgency=low

5
methods/http.cc

@ -985,7 +985,10 @@ HttpMethod::DealWithHeaders(FetchResult &Res,ServerState *Srv)
else
{
NextURI = DeQuoteString(Srv->Location);
return TRY_AGAIN_OR_REDIRECT;
URI tmpURI = NextURI;
// Do not allow a redirection to switch protocol
if (tmpURI.Access == "http")
return TRY_AGAIN_OR_REDIRECT;
}
/* else pass through for error message */
}

Loading…
Cancel
Save