Re: [PATCH] The FTP USER command does not need to be followed by a PASS (#477536)

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Looks good,

Regards,

Hans

On 04/02/2009 04:43 PM, Martin Sivak wrote:
---
  loader2/ftp.c |   21 +++++++++++++--------
  1 files changed, 13 insertions(+), 8 deletions(-)

diff --git a/loader2/ftp.c b/loader2/ftp.c
index 7fe692c..cc89288 100644
--- a/loader2/ftp.c
+++ b/loader2/ftp.c
@@ -72,7 +72,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) {
@@ -165,7 +164,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;
@@ -202,7 +201,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;
@@ -254,6 +253,7 @@ int ftpOpen(char *host, int family, char *name, char *password,
      struct passwd * pw;
      char * buf;
      int rc = 0;
+    char *userReply;

      if (port<  0) port = IPPORT_FTP;

@@ -321,17 +321,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) != 0) {
+        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;
      }

_______________________________________________
Anaconda-devel-list mailing list
Anaconda-devel-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/anaconda-devel-list

[Index of Archives]     [Kickstart]     [Fedora Users]     [Fedora Legacy List]     [Fedora Maintainers]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [Yosemite Photos]     [KDE Users]     [Fedora Tools]
  Powered by Linux