|
|
3cbbde |
diff --git a/ftpcodes.h b/ftpcodes.h
|
|
|
3cbbde |
index 93290c0..995788a 100644
|
|
|
3cbbde |
--- a/ftpcodes.h
|
|
|
3cbbde |
+++ b/ftpcodes.h
|
|
|
3cbbde |
@@ -15,7 +15,8 @@
|
|
|
3cbbde |
#define FTP_PBSZOK 200
|
|
|
3cbbde |
#define FTP_PROTOK 200
|
|
|
3cbbde |
#define FTP_OPTSOK 200
|
|
|
3cbbde |
-#define FTP_ALLOOK 202
|
|
|
3cbbde |
+#define FTP_ALLOOK 200
|
|
|
3cbbde |
+#define FTP_ALLOIGN 202
|
|
|
3cbbde |
#define FTP_FEAT 211
|
|
|
3cbbde |
#define FTP_STATOK 211
|
|
|
3cbbde |
#define FTP_SIZEOK 213
|
|
|
3cbbde |
diff --git a/ftpdataio.c b/ftpdataio.c
|
|
|
3cbbde |
index ffb2e23..08b0628 100644
|
|
|
3cbbde |
--- a/ftpdataio.c
|
|
|
3cbbde |
+++ b/ftpdataio.c
|
|
|
3cbbde |
@@ -244,6 +244,10 @@ init_data_sock_params(struct vsf_session* p_sess, int sock_fd)
|
|
|
3cbbde |
/* Start the timeout monitor */
|
|
|
3cbbde |
vsf_sysutil_install_io_handler(handle_io, p_sess);
|
|
|
3cbbde |
start_data_alarm(p_sess);
|
|
|
3cbbde |
+ if(tunable_delete_failed_uploads)
|
|
|
3cbbde |
+ {
|
|
|
3cbbde |
+ vsf_sysutil_rcvtimeo(sock_fd);
|
|
|
3cbbde |
+ }
|
|
|
3cbbde |
}
|
|
|
3cbbde |
|
|
|
3cbbde |
static void
|
|
|
3cbbde |
@@ -617,6 +621,10 @@ do_file_recv(struct vsf_session* p_sess, int file_fd, int is_ascii)
|
|
|
3cbbde |
else if (retval == 0 && !prev_cr)
|
|
|
3cbbde |
{
|
|
|
3cbbde |
/* Transfer done, nifty */
|
|
|
3cbbde |
+ if (tunable_delete_failed_uploads &&
|
|
|
3cbbde |
+ !is_ascii && p_sess->upload_size > 0 &&
|
|
|
3cbbde |
+ p_sess->upload_size != ret_struct.transferred)
|
|
|
3cbbde |
+ ret_struct.retval = -2;
|
|
|
3cbbde |
return ret_struct;
|
|
|
3cbbde |
}
|
|
|
3cbbde |
num_to_write = (unsigned int) retval;
|
|
|
3cbbde |
diff --git a/main.c b/main.c
|
|
|
3cbbde |
index f1e2f69..f039081 100644
|
|
|
3cbbde |
--- a/main.c
|
|
|
3cbbde |
+++ b/main.c
|
|
|
3cbbde |
@@ -44,7 +44,7 @@ main(int argc, const char* argv[])
|
|
|
3cbbde |
/* Login */
|
|
|
3cbbde |
1, 0, INIT_MYSTR, INIT_MYSTR,
|
|
|
3cbbde |
/* Protocol state */
|
|
|
3cbbde |
- 0, 1, INIT_MYSTR, 0, 0,
|
|
|
3cbbde |
+ 0, 0, 1, INIT_MYSTR, 0, 0,
|
|
|
3cbbde |
/* HTTP hacks */
|
|
|
3cbbde |
0, INIT_MYSTR,
|
|
|
3cbbde |
/* Session state */
|
|
|
3cbbde |
diff --git a/postlogin.c b/postlogin.c
|
|
|
3cbbde |
index 8a83164..4ca7f2c 100644
|
|
|
3cbbde |
--- a/postlogin.c
|
|
|
3cbbde |
+++ b/postlogin.c
|
|
|
3cbbde |
@@ -356,7 +356,14 @@ process_post_login(struct vsf_session* p_sess)
|
|
|
3cbbde |
}
|
|
|
3cbbde |
else if (str_equal_text(&p_sess->ftp_cmd_str, "ALLO"))
|
|
|
3cbbde |
{
|
|
|
3cbbde |
- vsf_cmdio_write(p_sess, FTP_ALLOOK, "ALLO command ignored.");
|
|
|
3cbbde |
+ if (tunable_delete_failed_uploads && !p_sess->is_ascii)
|
|
|
3cbbde |
+ {
|
|
|
3cbbde |
+ p_sess->upload_size = (filesize_t)vsf_sysutil_atoi(str_getbuf(&p_sess->ftp_cmd_str)+5);
|
|
|
3cbbde |
+ vsf_cmdio_write(p_sess, FTP_ALLOOK, "The filesize has been allocated.");
|
|
|
3cbbde |
+ }
|
|
|
3cbbde |
+ else {
|
|
|
3cbbde |
+ vsf_cmdio_write(p_sess, FTP_ALLOIGN, "ALLO command ignored.");
|
|
|
3cbbde |
+ }
|
|
|
3cbbde |
}
|
|
|
3cbbde |
else if (str_equal_text(&p_sess->ftp_cmd_str, "REIN"))
|
|
|
3cbbde |
{
|
|
|
3cbbde |
diff --git a/session.h b/session.h
|
|
|
3cbbde |
index 8123ffc..b60e098 100644
|
|
|
3cbbde |
--- a/session.h
|
|
|
3cbbde |
+++ b/session.h
|
|
|
3cbbde |
@@ -41,6 +41,7 @@ struct vsf_session
|
|
|
3cbbde |
struct mystr anon_pass_str;
|
|
|
3cbbde |
|
|
|
3cbbde |
/* Details of the FTP protocol state */
|
|
|
3cbbde |
+ filesize_t upload_size;
|
|
|
3cbbde |
filesize_t restart_pos;
|
|
|
3cbbde |
int is_ascii;
|
|
|
3cbbde |
struct mystr rnfr_filename_str;
|
|
|
3cbbde |
diff --git a/sysutil.c b/sysutil.c
|
|
|
3cbbde |
index af41e32..927174f 100644
|
|
|
3cbbde |
--- a/sysutil.c
|
|
|
3cbbde |
+++ b/sysutil.c
|
|
|
3cbbde |
@@ -681,6 +681,16 @@ vsf_sysutil_activate_keepalive(int fd)
|
|
|
3cbbde |
}
|
|
|
3cbbde |
|
|
|
3cbbde |
void
|
|
|
3cbbde |
+vsf_sysutil_rcvtimeo(int fd)
|
|
|
3cbbde |
+{
|
|
|
3cbbde |
+ struct timeval tv;
|
|
|
3cbbde |
+
|
|
|
3cbbde |
+ tv.tv_sec = tunable_data_connection_timeout;
|
|
|
3cbbde |
+ tv.tv_usec = 0;
|
|
|
3cbbde |
+ setsockopt(fd, SOL_SOCKET, SO_RCVTIMEO, &tv, sizeof(struct timeval));
|
|
|
3cbbde |
+}
|
|
|
3cbbde |
+
|
|
|
3cbbde |
+void
|
|
|
3cbbde |
vsf_sysutil_activate_reuseaddr(int fd)
|
|
|
3cbbde |
{
|
|
|
3cbbde |
int reuseaddr = 1;
|
|
|
3cbbde |
diff --git a/sysutil.h b/sysutil.h
|
|
|
3cbbde |
index 959fdf4..bb55063 100644
|
|
|
3cbbde |
--- a/sysutil.h
|
|
|
3cbbde |
+++ b/sysutil.h
|
|
|
3cbbde |
@@ -265,6 +265,7 @@ void vsf_sysutil_dns_resolve(struct vsf_sysutil_sockaddr** p_sockptr,
|
|
|
3cbbde |
const char* p_name);
|
|
|
3cbbde |
/* Option setting on sockets */
|
|
|
3cbbde |
void vsf_sysutil_activate_keepalive(int fd);
|
|
|
3cbbde |
+void vsf_sysutil_rcvtimeo(int fd);
|
|
|
3cbbde |
void vsf_sysutil_set_iptos_throughput(int fd);
|
|
|
3cbbde |
void vsf_sysutil_activate_reuseaddr(int fd);
|
|
|
3cbbde |
void vsf_sysutil_set_nodelay(int fd);
|