Blame SOURCES/0003-Make-the-max-number-of-bind-retries-tunable.patch

d83721
From be7c2d639127dd8af0139caf94f8c29f431d3753 Mon Sep 17 00:00:00 2001
d83721
From: =?UTF-8?q?Ond=C5=99ej=20Lyson=C4=9Bk?= <olysonek@redhat.com>
d83721
Date: Mon, 18 Jun 2018 10:13:48 +0200
d83721
Subject: [PATCH 3/3] Make the max number of bind retries tunable
d83721
d83721
Resolves: rhbz#1318198
d83721
---
d83721
 parseconf.c   | 1 +
d83721
 privops.c     | 8 ++++++--
d83721
 tunables.c    | 2 ++
d83721
 tunables.h    | 1 +
d83721
 vsftpd.conf.5 | 5 +++++
d83721
 5 files changed, 15 insertions(+), 2 deletions(-)
d83721
d83721
diff --git a/parseconf.c b/parseconf.c
d83721
index aeb401a..3cfe7da 100644
d83721
--- a/parseconf.c
d83721
+++ b/parseconf.c
d83721
@@ -143,6 +143,7 @@ parseconf_uint_array[] =
d83721
   { "delay_successful_login", &tunable_delay_successful_login },
d83721
   { "max_login_fails", &tunable_max_login_fails },
d83721
   { "chown_upload_mode", &tunable_chown_upload_mode },
d83721
+  { "bind_retries", &tunable_bind_retries },
d83721
   { 0, 0 }
d83721
 };
d83721
 
d83721
diff --git a/privops.c b/privops.c
d83721
index 010d28d..83b25c7 100644
d83721
--- a/privops.c
d83721
+++ b/privops.c
d83721
@@ -120,8 +120,8 @@ unsigned short
d83721
 vsf_privop_pasv_listen(struct vsf_session* p_sess)
d83721
 {
d83721
   static struct vsf_sysutil_sockaddr* s_p_sockaddr;
d83721
-  int bind_retries = 10;
d83721
-  unsigned short the_port;
d83721
+  int bind_retries = tunable_bind_retries + 1;
d83721
+  unsigned short the_port = 0;
d83721
   /* IPPORT_RESERVED */
d83721
   unsigned short min_port = 1024;
d83721
   unsigned short max_port = 65535;
d83721
@@ -131,6 +131,10 @@ vsf_privop_pasv_listen(struct vsf_session* p_sess)
d83721
     die("listed fd already active");
d83721
   }
d83721
 
d83721
+  if (bind_retries < 2)
d83721
+  {
d83721
+    bind_retries = 2;
d83721
+  }
d83721
   if (tunable_pasv_min_port > min_port && tunable_pasv_min_port <= max_port)
d83721
   {
d83721
     min_port = (unsigned short) tunable_pasv_min_port;
d83721
diff --git a/tunables.c b/tunables.c
d83721
index 63de8e6..a7ce9c8 100644
d83721
--- a/tunables.c
d83721
+++ b/tunables.c
d83721
@@ -115,6 +115,7 @@ unsigned int tunable_delay_failed_login;
d83721
 unsigned int tunable_delay_successful_login;
d83721
 unsigned int tunable_max_login_fails;
d83721
 unsigned int tunable_chown_upload_mode;
d83721
+unsigned int tunable_bind_retries;
d83721
 
d83721
 const char* tunable_secure_chroot_dir;
d83721
 const char* tunable_ftp_username;
d83721
@@ -268,6 +269,7 @@ tunables_load_defaults()
d83721
   tunable_max_login_fails = 3;
d83721
   /* -rw------- */
d83721
   tunable_chown_upload_mode = 0600;
d83721
+  tunable_bind_retries = 9;
d83721
 
d83721
   install_str_setting("/usr/share/empty", &tunable_secure_chroot_dir);
d83721
   install_str_setting("ftp", &tunable_ftp_username);
d83721
diff --git a/tunables.h b/tunables.h
d83721
index 8a4b8b2..029d645 100644
d83721
--- a/tunables.h
d83721
+++ b/tunables.h
d83721
@@ -120,6 +120,7 @@ extern unsigned int tunable_delay_failed_login;
d83721
 extern unsigned int tunable_delay_successful_login;
d83721
 extern unsigned int tunable_max_login_fails;
d83721
 extern unsigned int tunable_chown_upload_mode;
d83721
+extern unsigned int tunable_bind_retries;
d83721
 
d83721
 /* String defines */
d83721
 extern const char* tunable_secure_chroot_dir;
d83721
diff --git a/vsftpd.conf.5 b/vsftpd.conf.5
d83721
index f246906..ce3fba3 100644
d83721
--- a/vsftpd.conf.5
d83721
+++ b/vsftpd.conf.5
d83721
@@ -760,6 +760,11 @@ value will be treated as a base 10 integer!
d83721
 
d83721
 Default: 077
d83721
 .TP
d83721
+.B bind_retries
d83721
+Maximum number of attempts to find a free listening port in passive mode.
d83721
+
d83721
+Default: 9
d83721
+.TP
d83721
 .B chown_upload_mode
d83721
 The file mode to force for chown()ed anonymous uploads. (Added in v2.0.6).
d83721
 
d83721
-- 
d83721
2.14.4
d83721