Blame SOURCES/0019-Introduce-reverse_lookup_enable-option.patch

bd689f
From 721de88621100f6ed33f1602415bc249f3ed3219 Mon Sep 17 00:00:00 2001
bd689f
From: Martin Sehnoutka <msehnout@redhat.com>
bd689f
Date: Thu, 17 Nov 2016 10:22:32 +0100
bd689f
Subject: [PATCH 19/59] Introduce reverse_lookup_enable option.
bd689f
bd689f
vsftpd can transform IP address into hostname before
bd689f
PAM authentication. You can disable it to prevent
bd689f
performance issues.
bd689f
---
bd689f
 parseconf.c   |  1 +
bd689f
 sysdeputil.c  | 14 +++++++++-----
bd689f
 tunables.c    |  2 ++
bd689f
 tunables.h    |  1 +
bd689f
 vsftpd.conf.5 |  9 +++++++++
bd689f
 5 files changed, 22 insertions(+), 5 deletions(-)
bd689f
bd689f
diff --git a/parseconf.c b/parseconf.c
bd689f
index 30df598..3e0dba4 100644
bd689f
--- a/parseconf.c
bd689f
+++ b/parseconf.c
bd689f
@@ -91,6 +91,7 @@ parseconf_bool_array[] =
bd689f
   { "mdtm_write", &tunable_mdtm_write },
bd689f
   { "lock_upload_files", &tunable_lock_upload_files },
bd689f
   { "pasv_addr_resolve", &tunable_pasv_addr_resolve },
bd689f
+  { "reverse_lookup_enable", &tunable_reverse_lookup_enable },
bd689f
   { "userlist_log", &tunable_userlist_log },
bd689f
   { "debug_ssl", &tunable_debug_ssl },
bd689f
   { "require_cert", &tunable_require_cert },
bd689f
diff --git a/sysdeputil.c b/sysdeputil.c
bd689f
index 3bbabaa..2063c87 100644
bd689f
--- a/sysdeputil.c
bd689f
+++ b/sysdeputil.c
bd689f
@@ -354,12 +354,16 @@ vsf_sysdep_check_auth(struct mystr* p_user_str,
bd689f
     return 0;
bd689f
   }
bd689f
 #ifdef PAM_RHOST
bd689f
-  sin.sin_addr.s_addr = inet_addr(str_getbuf(p_remote_host));
bd689f
-  host = gethostbyaddr((char*)&sin.sin_addr.s_addr,sizeof(struct in_addr),AF_INET);
bd689f
-  if (host != (struct hostent*)0)
bd689f
-    retval = pam_set_item(s_pamh, PAM_RHOST, host->h_name);
bd689f
-  else
bd689f
+  if (tunable_reverse_lookup_enable) {
bd689f
+    sin.sin_addr.s_addr = inet_addr(str_getbuf(p_remote_host));
bd689f
+    host = gethostbyaddr((char*)&sin.sin_addr.s_addr,sizeof(struct in_addr),AF_INET);
bd689f
+    if (host != (struct hostent*)0)
bd689f
+      retval = pam_set_item(s_pamh, PAM_RHOST, host->h_name);
bd689f
+    else
bd689f
+      retval = pam_set_item(s_pamh, PAM_RHOST, str_getbuf(p_remote_host));
bd689f
+  } else {
bd689f
     retval = pam_set_item(s_pamh, PAM_RHOST, str_getbuf(p_remote_host));
bd689f
+  }
bd689f
   if (retval != PAM_SUCCESS)
bd689f
   {
bd689f
     (void) pam_end(s_pamh, retval);
bd689f
diff --git a/tunables.c b/tunables.c
bd689f
index b30fca1..c737465 100644
bd689f
--- a/tunables.c
bd689f
+++ b/tunables.c
bd689f
@@ -72,6 +72,7 @@ int tunable_force_anon_data_ssl;
bd689f
 int tunable_mdtm_write;
bd689f
 int tunable_lock_upload_files;
bd689f
 int tunable_pasv_addr_resolve;
bd689f
+int tunable_reverse_lookup_enable;
bd689f
 int tunable_userlist_log;
bd689f
 int tunable_debug_ssl;
bd689f
 int tunable_require_cert;
bd689f
@@ -213,6 +214,7 @@ tunables_load_defaults()
bd689f
   tunable_mdtm_write = 1;
bd689f
   tunable_lock_upload_files = 1;
bd689f
   tunable_pasv_addr_resolve = 0;
bd689f
+  tunable_reverse_lookup_enable = 1;
bd689f
   tunable_userlist_log = 0;
bd689f
   tunable_debug_ssl = 0;
bd689f
   tunable_require_cert = 0;
bd689f
diff --git a/tunables.h b/tunables.h
bd689f
index e44d64c..9553038 100644
bd689f
--- a/tunables.h
bd689f
+++ b/tunables.h
bd689f
@@ -73,6 +73,7 @@ extern int tunable_force_anon_data_ssl;       /* Require anon data uses SSL */
bd689f
 extern int tunable_mdtm_write;                /* Allow MDTM to set timestamps */
bd689f
 extern int tunable_lock_upload_files;         /* Lock uploading files */
bd689f
 extern int tunable_pasv_addr_resolve;         /* DNS resolve pasv_addr */
bd689f
+extern int tunable_reverse_lookup_enable;     /* Get hostname before pam auth */
bd689f
 extern int tunable_userlist_log;              /* Log every failed login attempt */
bd689f
 extern int tunable_debug_ssl;                 /* Verbose SSL logging */
bd689f
 extern int tunable_require_cert;              /* SSL client cert required */
bd689f
diff --git a/vsftpd.conf.5 b/vsftpd.conf.5
bd689f
index 72bb86f..fb6324e 100644
bd689f
--- a/vsftpd.conf.5
bd689f
+++ b/vsftpd.conf.5
bd689f
@@ -423,6 +423,15 @@ so you may want to disable it. For a discussion of the consequences, see
bd689f
 http://scarybeastsecurity.blogspot.com/2009/02/vsftpd-210-released.html
bd689f
 (Added in v2.1.0).
bd689f
 
bd689f
+Default: YES
bd689f
+.TP
bd689f
+.B reverse_lookup_enable
bd689f
+Set to YES if you want vsftpd to transform the ip address into the hostname,
bd689f
+before pam authentication. This is useful if you use pam_access including the
bd689f
+hostname. If you want vsftpd to run on the environment where the reverse lookup
bd689f
+for some hostname is available and the name server doesn't respond for a while,
bd689f
+you should set this to NO to avoid a performance issue.
bd689f
+
bd689f
 Default: YES
bd689f
 .TP
bd689f
 .B run_as_launching_user
bd689f
-- 
bd689f
2.14.4
bd689f