summaryrefslogtreecommitdiffstats
path: root/loader/ftp.c
diff options
context:
space:
mode:
authorChris Lumens <clumens@redhat.com>2009-01-06 10:19:17 -0500
committerChris Lumens <clumens@redhat.com>2009-01-06 10:19:17 -0500
commit4a78895e30e5e5a33fc46da6134fa3f3aea7902a (patch)
tree0f194b967b9c4b686bd373cb1fbaa710eba612c3 /loader/ftp.c
parent5299d19ecf85a51d1a9972d59ac151b336d07b56 (diff)
downloadanaconda-4a78895e30e5e5a33fc46da6134fa3f3aea7902a.tar.gz
anaconda-4a78895e30e5e5a33fc46da6134fa3f3aea7902a.tar.xz
anaconda-4a78895e30e5e5a33fc46da6134fa3f3aea7902a.zip
The FTP USER command does not need to be followed by a PASS (#477536).
Diffstat (limited to 'loader/ftp.c')
-rw-r--r--loader/ftp.c21
1 files changed, 13 insertions, 8 deletions
diff --git a/loader/ftp.c b/loader/ftp.c
index aa7a95b6f..8f8a585f9 100644
--- a/loader/ftp.c
+++ b/loader/ftp.c
@@ -74,7 +74,6 @@ extern int h_errno;
#include "net.h"
static int ftpCheckResponse(int sock, char ** str);
-static int ftpCommand(int sock, char * command, ...);
static int getHostAddress(const char * host, void * address, int family);
static int ftpCheckResponse(int sock, char ** str) {
@@ -167,7 +166,7 @@ static int ftpCheckResponse(int sock, char ** str) {
return 0;
}
-int ftpCommand(int sock, char * command, ...) {
+static int ftpCommand(int sock, char **response, char * command, ...) {
va_list ap;
int len;
char * s;
@@ -204,7 +203,7 @@ int ftpCommand(int sock, char * command, ...) {
return FTPERR_SERVER_IO_ERROR;
}
- if ((rc = ftpCheckResponse(sock, NULL)))
+ if ((rc = ftpCheckResponse(sock, response)))
return rc;
return 0;
@@ -261,6 +260,7 @@ int ftpOpen(char *host, int family, char *name, char *password,
struct sockaddr_in6 destPort6;
struct passwd * pw;
int rc = 0;
+ char *userReply;
if (port < 0) port = IPPORT_FTP;
@@ -322,17 +322,22 @@ int ftpOpen(char *host, int family, char *name, char *password,
return rc;
}
- if ((rc = ftpCommand(sock, "USER", name, NULL))) {
+ if ((rc = ftpCommand(sock, &userReply, "USER", name, NULL))) {
close(sock);
return rc;
}
- if ((rc = ftpCommand(sock, "PASS", password, NULL))) {
- close(sock);
- return rc;
+ /* FTP does not require that USER be followed by PASS. Anonymous logins
+ * in particular do not need any password.
+ */
+ if (!strncmp(userReply, "230", 3)) {
+ if ((rc = ftpCommand(sock, NULL, "PASS", password, NULL))) {
+ close(sock);
+ return rc;
+ }
}
- if ((rc = ftpCommand(sock, "TYPE", "I", NULL))) {
+ if ((rc = ftpCommand(sock, NULL, "TYPE", "I", NULL))) {
close(sock);
return rc;
}