aboutsummaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorDaniel Stenberg <daniel@haxx.se>2001-03-29 08:16:55 +0000
committerDaniel Stenberg <daniel@haxx.se>2001-03-29 08:16:55 +0000
commitb1328430c9f73bededc274ce8bac5aa8f36f7afe (patch)
treea9e966651abf4f5b3d751fc7cfe99754b0f2ce2b /lib
parent34efa74a5943df3f94db1f1d852082f35922f953 (diff)
ftps:// support added
Diffstat (limited to 'lib')
-rw-r--r--lib/ftp.c24
-rw-r--r--lib/url.c21
-rw-r--r--lib/urldata.h6
3 files changed, 33 insertions, 18 deletions
diff --git a/lib/ftp.c b/lib/ftp.c
index 228ae0ea5..53f8df14e 100644
--- a/lib/ftp.c
+++ b/lib/ftp.c
@@ -78,6 +78,7 @@
#endif
#include "strequal.h"
+#include "ssluse.h"
#define _MPRINTF_REPLACE /* use our functions only */
#include <curl/mprintf.h>
@@ -316,6 +317,14 @@ CURLcode Curl_ftp_connect(struct connectdata *conn)
return result;
}
+ if(conn->protocol & PROT_FTPS) {
+ /* FTPS is simply ftp with SSL for the control channel */
+ /* now, perform the SSL initialization for this socket */
+ if(Curl_SSLConnect(conn))
+ return CURLE_SSL_CONNECT_ERROR;
+ }
+
+
/* The first thing we do is wait for the "220*" line: */
nread = Curl_GetFTPResponse(conn->firstsocket, buf, conn, &ftpcode);
if(nread < 0)
@@ -337,8 +346,6 @@ CURLcode Curl_ftp_connect(struct connectdata *conn)
set a valid level */
sec_request_prot(conn, data->krb4_level);
- data->cmdchannel = fdopen(conn->firstsocket, "w");
-
if(sec_login(conn) != 0)
infof(data, "Logging in with password in cleartext!\n");
else
@@ -1702,16 +1709,9 @@ size_t Curl_ftpsendf(int fd, struct connectdata *conn, char *fmt, ...)
strcat(s, "\r\n"); /* append a trailing CRLF */
-#ifdef KRB4
- if(conn->sec_complete && conn->data->cmdchannel) {
- bytes_written = sec_fprintf(conn, conn->data->cmdchannel, s);
- fflush(conn->data->cmdchannel);
- }
- else
-#endif /* KRB4 */
- {
- bytes_written = swrite(fd, s, strlen(s));
- }
+ bytes_written=0;
+ Curl_write(conn, fd, s, strlen(s), &bytes_written);
+
return(bytes_written);
}
diff --git a/lib/url.c b/lib/url.c
index d7f1f004f..2840d32e5 100644
--- a/lib/url.c
+++ b/lib/url.c
@@ -1399,6 +1399,8 @@ static CURLcode Connect(struct UrlData *data,
#ifdef USE_SSLEAY
else if(strnequal(conn->gname, "HTTPS", 5))
strcpy(conn->protostr, "https");
+ else if(strnequal(conn->gname, "FTPS", 4))
+ strcpy(conn->protostr, "ftps");
#endif /* USE_SSLEAY */
else if(strnequal(conn->gname, "TELNET", 6))
strcpy(conn->protostr, "telnet");
@@ -1668,8 +1670,19 @@ static CURLcode Connect(struct UrlData *data,
conn->curl_done = Curl_http_done;
conn->curl_close = Curl_http_close;
}
- else if(strequal(conn->protostr, "FTP")) {
+ else if(strequal(conn->protostr, "FTP") ||
+ strequal(conn->protostr, "FTPS")) {
char *type;
+
+ if(strequal(conn->protostr, "FTPS")) {
+#ifdef USE_SSLEAY
+ conn->protocol |= PROT_FTPS;
+#else
+ failf(data, "libcurl was built with SSL disabled, ftps: not supported!");
+ return CURLE_UNSUPPORTED_PROTOCOL;
+#endif /* !USE_SSLEAY */
+ }
+
conn->port = (data->use_port && allow_port)?data->use_port:PORT_FTP;
conn->remote_port = PORT_FTP;
conn->protocol |= PROT_FTP;
@@ -1678,6 +1691,12 @@ static CURLcode Connect(struct UrlData *data,
!data->bits.tunnel_thru_httpproxy) {
/* Unless we have asked to tunnel ftp operations through the proxy, we
switch and use HTTP operations only */
+ if(conn->protocol & PROT_FTPS) {
+ /* FTPS is a hacked protocol and does not work through your
+ ordinary http proxy! */
+ failf(data, "ftps does not work through http proxy!");
+ return CURLE_UNSUPPORTED_PROTOCOL;
+ }
conn->curl_do = Curl_http;
conn->curl_done = Curl_http_done;
conn->curl_close = Curl_http_close;
diff --git a/lib/urldata.h b/lib/urldata.h
index 07e8953ee..aef8435c4 100644
--- a/lib/urldata.h
+++ b/lib/urldata.h
@@ -207,6 +207,7 @@ struct connectdata {
#define PROT_DICT (1<<6)
#define PROT_LDAP (1<<7)
#define PROT_FILE (1<<8)
+#define PROT_FTPS (1<<9)
#ifdef ENABLE_IPV6
struct addrinfo *hp; /* host info pointer list */
@@ -293,7 +294,6 @@ struct connectdata {
document headers */
#ifdef KRB4
-
enum protection_level command_prot;
enum protection_level data_prot;
enum protection_level request_data_prot;
@@ -553,10 +553,6 @@ struct UrlData {
char proxypasswd[MAX_CURL_PASSWORD_LENGTH];
char *krb4_level; /* what security level */
-#ifdef KRB4
- FILE *cmdchannel;
-#endif
-
struct timeval keeps_speed; /* this should be request-specific */
/* 'connects' will be an allocated array with pointers. If the pointer is