Blame SOURCES/vsftpd-3.0.2-del-upl.patch

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