On Thu, Mar 15, 2012 at 10:41:52PM +0400, lexa wrote: > I have this problem with ftp server on starterkit.dyndns.org .
Ok, please try this patch. -- Alexander.
diff --git a/src/ftpclass.cc b/src/ftpclass.cc index dde498f..8fa438d 100644 --- a/src/ftpclass.cc +++ b/src/ftpclass.cc @@ -301,12 +301,8 @@ bool Ftp::Transient5XX(int act) const if(!is5XX(act)) return false; - if(act==530 && expect->FirstIs(Expect::PASS)) { - if(re_match(all_lines,Query("retry-530",hostname),REG_ICASE)) - return true; - if(!user && re_match(all_lines,Query("retry-530-anonymous",hostname),REG_ICASE)) - return true; - } + if(act==530 && expect->FirstIs(Expect::PASS) && Retry530()) + return true; // retry on these errors (ftp server ought to send 4xx code instead) if(ServerSaid("Broken pipe") || ServerSaid("Too many") @@ -429,28 +425,32 @@ simulate_eof: return; } -void Ftp::LoginCheck(int act) +bool Ftp::Retry530() const { - if(conn->ignore_pass) - return; - if(act==530) // login incorrect or overloaded server + const char *rexp=Query("retry-530",hostname); + if(re_match(all_lines,rexp,REG_ICASE)) { - const char *rexp=Query("retry-530",hostname); + LogNote(9,_("Server reply matched ftp:retry-530, retrying")); + return true; + } + if(!user) + { + rexp=Query("retry-530-anonymous",hostname); if(re_match(all_lines,rexp,REG_ICASE)) { - LogNote(9,_("Server reply matched ftp:retry-530, retrying")); - goto retry; - } - if(!user) - { - rexp=Query("retry-530-anonymous",hostname); - if(re_match(all_lines,rexp,REG_ICASE)) - { - LogNote(9,_("Server reply matched ftp:retry-530-anonymous, retrying")); - goto retry; - } + LogNote(9,_("Server reply matched ftp:retry-530-anonymous, retrying")); + return true; } } + return false; +} + +void Ftp::LoginCheck(int act) +{ + if(conn->ignore_pass) + return; + if(act==530 && Retry530()) // overloaded server? + goto retry; if(is5XX(act)) { SetError(LOGIN_FAILED,all_lines); @@ -499,22 +499,8 @@ void Ftp::NoPassReqCheck(int act) // for USER command if(is3XX(act)) return; - if(act==530) // no such user or overloaded server - { - // Unfortunately, at this point we cannot tell if it is - // really incorrect login or overloaded server, because - // many overloaded servers return hard error 530... - // So try to check the message for `user unknown'. - // NOTE: modern ftp servers don't say `user unknown', they wait for - // PASS and then say `Login incorrect'. - if(strstr(line,"unknown")) // Don't translate!!! - { - LogNote(9,_("Saw `unknown', assume failed login")); - SetError(LOGIN_FAILED,all_lines); - return; - } - goto def_ret; - } + if(act==530 && Retry530()) // overloaded server? + goto retry; if(is5XX(act)) { // proxy interprets USER as user@host, so we check for host name validity @@ -527,7 +513,7 @@ void Ftp::NoPassReqCheck(int act) // for USER command SetError(LOGIN_FAILED,all_lines); return; } -def_ret: +retry: Disconnect(); try_time=now; // count the reconnect-interval from this moment last_connection_failed=true; diff --git a/src/ftpclass.h b/src/ftpclass.h index 3ee6e61..1617603 100644 --- a/src/ftpclass.h +++ b/src/ftpclass.h @@ -276,6 +276,7 @@ class Ftp : public NetAccess void RestCheck(int); void NoFileCheck(int); void TransferCheck(int); + bool Retry530() const; void LoginCheck(int); void NoPassReqCheck(int); void proxy_LoginCheck(int);
_______________________________________________ lftp mailing list lftp@uniyar.ac.ru http://univ.uniyar.ac.ru/mailman/listinfo/lftp