File terminate-peers-on-quit.patch of Package vsftpd

 
Index: vsftpd-3.0.5/postlogin.c
===================================================================
--- vsftpd-3.0.5.orig/postlogin.c
+++ vsftpd-3.0.5/postlogin.c
@@ -184,6 +184,10 @@ process_post_login(struct vsf_session* p
     }
     else if (str_equal_text(&p_sess->ftp_cmd_str, "QUIT"))
     {
+      if (!tunable_one_process_model)
+      {
+        vsf_two_process_quit(p_sess);
+      }
       vsf_cmdio_write_exit(p_sess, FTP_GOODBYE, "Goodbye.", 0);
     }
     else if (str_equal_text(&p_sess->ftp_cmd_str, "PWD") ||
Index: vsftpd-3.0.5/postprivparent.c
===================================================================
--- vsftpd-3.0.5.orig/postprivparent.c
+++ vsftpd-3.0.5/postprivparent.c
@@ -73,6 +73,10 @@ process_post_login_req(struct vsf_sessio
   {
     cmd_process_pasv_accept(p_sess);
   }
+  else if (cmd == PRIV_SOCK_QUIT)
+  {
+    vsf_sysutil_exit(0);
+  }
   else
   {
     die("bad request in process_post_login_req");
Index: vsftpd-3.0.5/privsock.h
===================================================================
--- vsftpd-3.0.5.orig/privsock.h
+++ vsftpd-3.0.5/privsock.h
@@ -169,6 +169,7 @@ int priv_sock_get_int(int fd);
 #define PRIV_SOCK_PASV_ACTIVE       11
 #define PRIV_SOCK_PASV_LISTEN       12
 #define PRIV_SOCK_PASV_ACCEPT       13
+#define PRIV_SOCK_QUIT              127
 
 #define PRIV_SOCK_RESULT_OK         1
 #define PRIV_SOCK_RESULT_BAD        2
Index: vsftpd-3.0.5/twoprocess.c
===================================================================
--- vsftpd-3.0.5.orig/twoprocess.c
+++ vsftpd-3.0.5/twoprocess.c
@@ -267,6 +267,12 @@ vsf_two_process_pasv_active(struct vsf_s
   return priv_sock_get_int(p_sess->child_fd);
 }
 
+void
+vsf_two_process_quit(struct vsf_session* p_sess)
+{
+  priv_sock_send_cmd(p_sess->child_fd, PRIV_SOCK_QUIT);
+}
+
 unsigned short
 vsf_two_process_listen(struct vsf_session* p_sess)
 {
Index: vsftpd-3.0.5/twoprocess.h
===================================================================
--- vsftpd-3.0.5.orig/twoprocess.h
+++ vsftpd-3.0.5/twoprocess.h
@@ -51,6 +51,14 @@ void vsf_two_process_pasv_cleanup(struct
  */
 int vsf_two_process_pasv_active(struct vsf_session* p_sess);
 
+/* vsf_two_process_quit()
+ * PURPOSE
+ * Terminate privileged side.
+ * PARAMETERS
+ * p_sess       - the current session object
+ */
+void vsf_two_process_quit(struct vsf_session* p_sess);
+
 /* vsf_two_process_listen()
  * PURPOSE
  * Start listening for an incoming connection on the passive socket in the
Index: vsftpd-3.0.5/ftpcmdio.c
===================================================================
--- vsftpd-3.0.5.orig/ftpcmdio.c
+++ vsftpd-3.0.5/ftpcmdio.c
@@ -19,6 +19,7 @@
 #include "logging.h"
 #include "session.h"
 #include "readwrite.h"
+#include "privsock.h"
 
 /* Internal functions */
 static int control_getline(struct mystr* p_str, struct vsf_session* p_sess);
@@ -87,6 +88,10 @@ vsf_cmdio_write_exit(struct vsf_session*
   vsf_sysutil_shutdown_read_failok(VSFTP_COMMAND_FD);
   vsf_cmdio_write(p_sess, status, p_text);
   vsf_sysutil_shutdown_failok(VSFTP_COMMAND_FD);
+  if (p_sess->data_use_ssl && p_sess->ssl_slave_active)
+  {
+    priv_sock_send_cmd(p_sess->ssl_consumer_fd, PRIV_SOCK_QUIT);
+  }
   vsf_sysutil_exit(exit_val);
 }
 
Index: vsftpd-3.0.5/sslslave.c
===================================================================
--- vsftpd-3.0.5.orig/sslslave.c
+++ vsftpd-3.0.5/sslslave.c
@@ -43,6 +43,10 @@ ssl_slave(struct vsf_session* p_sess)
         priv_sock_send_str(p_sess->ssl_slave_fd, &p_sess->ftp_cmd_str);
       }
     }
+    else if (cmd == PRIV_SOCK_QUIT)
+    {
+      vsf_sysutil_exit(0);
+    }
     else if (cmd == PRIV_SOCK_WRITE_USER_RESP)
     {
       priv_sock_get_str(p_sess->ssl_slave_fd, &p_sess->ftp_cmd_str);
openSUSE Build Service is sponsored by