From e718825a4874f654bfc11a8c888d3dbeed154919 Mon Sep 17 00:00:00 2001
From: Julien Chaffraix <julien.chaffraix@gmail.com>
Date: Sun, 26 Sep 2010 19:16:38 -0700
Subject: [PATCH 5/7] security.c: We should always register the socket handler.

Following a change in the way socket handler are registered, the custom
recv and send method were conditionaly registered.
We need to register them everytime to handle the ftp security
extensions.

Re-added the clear text handling in sec_recv.
---
 lib/security.c |   14 ++++++++------
 1 files changed, 8 insertions(+), 6 deletions(-)

diff --git a/lib/security.c b/lib/security.c
index 9e74eb2..5becb0c 100644
--- a/lib/security.c
+++ b/lib/security.c
@@ -245,6 +245,10 @@ static ssize_t sec_recv(struct connectdata *conn, int sockindex,
 
   *err = CURLE_OK;
 
+  /* Handle clear text response. */
+  if(conn->sec_complete == 0 || conn->data_prot == prot_clear)
+      return read(fd, buffer, len);
+
   if(conn->in_buffer.eof_flag) {
     conn->in_buffer.eof_flag = 0;
     return 0;
@@ -550,12 +554,10 @@ static CURLcode choose_mech(struct connectdata *conn)
 
     conn->mech = *mech;
     conn->sec_complete = 1;
-    if (conn->data_prot != prot_clear) {
-      conn->recv[FIRSTSOCKET] = sec_recv;
-      conn->send[FIRSTSOCKET] = sec_send;
-      conn->recv[SECONDARYSOCKET] = sec_recv;
-      conn->send[SECONDARYSOCKET] = sec_send;
-    }
+    conn->recv[FIRSTSOCKET] = sec_recv;
+    conn->send[FIRSTSOCKET] = sec_send;
+    conn->recv[SECONDARYSOCKET] = sec_recv;
+    conn->send[SECONDARYSOCKET] = sec_send;
     conn->command_prot = prot_safe;
     /* Set the requested protection level */
     /* BLOCKING */
-- 
1.7.0.4

