#include <config.h>
#include <apt-pkg/fileutl.h>
-#include <apt-pkg/acquire-method.h>
#include <apt-pkg/error.h>
#include <apt-pkg/hashes.h>
#include <apt-pkg/netrc.h>
// Unsupported function
string::size_type Pos = Msg.find('(');
- if (Tag >= 400 || Pos == string::npos)
+ if (Tag >= 400)
+ return true;
+
+ //wu-2.6.2(1) ftp server, returns
+ //227 Entering Passive Mode 193,219,28,140,150,111
+ //without parentheses, let's try to cope with it.
+ //wget(1) and ftp(1) can.
+ if (Pos == string::npos)
+ Pos = Msg.rfind(' ');
+ else
+ ++Pos;
+
+ // Still unsupported function
+ if (Pos == string::npos)
return true;
// Scan it
unsigned a0,a1,a2,a3,p0,p1;
- if (sscanf(Msg.c_str() + Pos,"(%u,%u,%u,%u,%u,%u)",&a0,&a1,&a2,&a3,&p0,&p1) != 6)
+ if (sscanf(Msg.c_str() + Pos,"%u,%u,%u,%u,%u,%u",&a0,&a1,&a2,&a3,&p0,&p1) != 6)
return true;
/* Some evil servers return 0 to mean their addr. We can actually speak
}
// Bind and listen
- if (bind(DataListenFd,BindAddr->ai_addr,BindAddr->ai_addrlen) < 0)
+ if (::bind(DataListenFd,BindAddr->ai_addr,BindAddr->ai_addrlen) < 0)
{
freeaddrinfo(BindAddr);
return _error->Errno("bind",_("Could not bind a socket"));
// FtpMethod::FtpMethod - Constructor /*{{{*/
// ---------------------------------------------------------------------
/* */
-FtpMethod::FtpMethod() : pkgAcqMethod("1.0",SendConfig)
+FtpMethod::FtpMethod() : aptMethod("ftp","1.0",SendConfig)
{
signal(SIGTERM,SigTerm);
signal(SIGINT,SigTerm);
/* We stash the desired pipeline depth */
bool FtpMethod::Configuration(string Message)
{
- if (pkgAcqMethod::Configuration(Message) == false)
+ if (aptMethod::Configuration(Message) == false)
return false;
-
- TimeOut = _config->FindI("Acquire::Ftp::Timeout",TimeOut);
- // no more active ftp, sorry
- DropPrivsOrDie();
+ TimeOut = _config->FindI("Acquire::Ftp::Timeout",TimeOut);
return true;
}
URIStart(Res);
FailFile = Itm->DestFile;
- FailFile.c_str(); // Make sure we dont do a malloc in the signal handler
+ FailFile.c_str(); // Make sure we don't do a malloc in the signal handler
FailFd = Fd.Fd();
bool Missing;
// If the file is missing we hard fail and delete the destfile
// otherwise transient fail
if (Missing == true) {
- unlink(FailFile.c_str());
+ RemoveFile("ftp", FailFile);
return false;
}
Fail(true);
/*}}}*/
int main(int, const char *argv[])
-{
- setlocale(LC_ALL, "");
-
+{
/* See if we should be come the http client - we do this for http
proxy urls */
if (getenv("ftp_proxy") != 0)
exit(100);
}
}
-
- FtpMethod Mth;
-
- return Mth.Run();
+ return FtpMethod().Run();
}