// -*- mode: cpp; mode: fold -*-
// Description /*{{{*/
-// $Id: ftp.cc,v 1.30 2003/02/10 07:34:41 doogie Exp $
+// $Id: ftp.cc,v 1.31.2.1 2004/01/16 18:58:50 mdz Exp $
/* ######################################################################
FTP Aquire Method - This is the FTP aquire method for APT.
##################################################################### */
/*}}}*/
// Include Files /*{{{*/
-#include <apti18n.h>
#include <apt-pkg/fileutl.h>
#include <apt-pkg/acquire-method.h>
#include <apt-pkg/error.h>
#include <errno.h>
#include <stdarg.h>
#include <iostream>
+#include <apti18n.h>
// Internet stuff
#include <netinet/in.h>
if (ReadResp(Tag,Msg) == false)
return false;
if (Tag >= 400)
- return _error->Error(_("Server refused our connection and said: %s"),Msg.c_str());
+ return _error->Error(_("The server refused the connection and said: %s"),Msg.c_str());
// Send the user
if (WriteMsg(Tag,Msg,"USER %s",User.c_str()) == false)
if (Tag >= 400)
return _error->Error(_("USER failed, server said: %s"),Msg.c_str());
- // Send the Password
- if (WriteMsg(Tag,Msg,"PASS %s",Pass.c_str()) == false)
- return false;
- if (Tag >= 400)
- return _error->Error(_("PASS failed, server said: %s"),Msg.c_str());
+ if (Tag == 331) { // 331 User name okay, need password.
+ // Send the Password
+ if (WriteMsg(Tag,Msg,"PASS %s",Pass.c_str()) == false)
+ return false;
+ if (Tag >= 400)
+ return _error->Error(_("PASS failed, server said: %s"),Msg.c_str());
+ }
// Enter passive mode
if (_config->Exists("Acquire::FTP::Passive::" + ServerName.Host) == true)
if (ReadResp(Tag,Msg) == false)
return false;
if (Tag >= 400)
- return _error->Error(_("Server refused our connection and said: %s"),Msg.c_str());
+ return _error->Error(_("The server refused the connection and said: %s"),Msg.c_str());
// Perform proxy script execution
Configuration::Item const *Opts = _config->Tree("Acquire::ftp::ProxyLogin");
int Res = write(ServerFd,S + Start,Len);
if (Res <= 0)
{
- _error->Errno("write",_("Write Error"));
+ _error->Errno("write",_("Write error"));
Close();
return false;
}
int main(int argc,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)
// Run the http method
string Path = flNotFile(argv[0]) + "http";
- execl(Path.c_str(),Path.c_str(),0);
+ execl(Path.c_str(),Path.c_str(),(char *)NULL);
cerr << _("Unable to invoke ") << Path << endl;
exit(100);
}