3cbbde
diff -up vsftpd-3.0.2/parseconf.c.lookup vsftpd-3.0.2/parseconf.c
3cbbde
--- vsftpd-3.0.2/parseconf.c.lookup	2014-04-17 10:01:50.862951491 +0200
3cbbde
+++ vsftpd-3.0.2/parseconf.c	2014-04-17 10:02:42.343955443 +0200
3cbbde
@@ -91,6 +91,7 @@ parseconf_bool_array[] =
3cbbde
   { "mdtm_write", &tunable_mdtm_write },
3cbbde
   { "lock_upload_files", &tunable_lock_upload_files },
3cbbde
   { "pasv_addr_resolve", &tunable_pasv_addr_resolve },
3cbbde
+  { "reverse_lookup_enable", &tunable_reverse_lookup_enable },
3cbbde
   { "userlist_log", &tunable_userlist_log },
3cbbde
   { "debug_ssl", &tunable_debug_ssl },
3cbbde
   { "require_cert", &tunable_require_cert },
3cbbde
diff -up vsftpd-3.0.2/sysdeputil.c.lookup vsftpd-3.0.2/sysdeputil.c
3cbbde
--- vsftpd-3.0.2/sysdeputil.c.lookup	2014-04-17 09:57:02.111933144 +0200
3cbbde
+++ vsftpd-3.0.2/sysdeputil.c	2014-04-17 10:01:31.069950498 +0200
3cbbde
@@ -354,12 +354,16 @@ vsf_sysdep_check_auth(struct mystr* p_us
3cbbde
     return 0;
3cbbde
   }
3cbbde
 #ifdef PAM_RHOST
3cbbde
-  sin.sin_addr.s_addr = inet_addr(str_getbuf(p_remote_host));
3cbbde
-  host = gethostbyaddr((char*)&sin.sin_addr.s_addr,sizeof(struct in_addr),AF_INET);
3cbbde
-  if (host != (struct hostent*)0)
3cbbde
-    retval = pam_set_item(s_pamh, PAM_RHOST, host->h_name);
3cbbde
-  else
3cbbde
+  if (tunable_reverse_lookup_enable) {
3cbbde
+    sin.sin_addr.s_addr = inet_addr(str_getbuf(p_remote_host));
3cbbde
+    host = gethostbyaddr((char*)&sin.sin_addr.s_addr,sizeof(struct in_addr),AF_INET);
3cbbde
+    if (host != (struct hostent*)0)
3cbbde
+      retval = pam_set_item(s_pamh, PAM_RHOST, host->h_name);
3cbbde
+    else
3cbbde
+      retval = pam_set_item(s_pamh, PAM_RHOST, str_getbuf(p_remote_host));
3cbbde
+  } else {
3cbbde
     retval = pam_set_item(s_pamh, PAM_RHOST, str_getbuf(p_remote_host));
3cbbde
+  }
3cbbde
   if (retval != PAM_SUCCESS)
3cbbde
   {
3cbbde
     (void) pam_end(s_pamh, retval);
3cbbde
diff -up vsftpd-3.0.2/tunables.c.lookup vsftpd-3.0.2/tunables.c
3cbbde
--- vsftpd-3.0.2/tunables.c.lookup	2014-04-17 10:03:22.766958324 +0200
3cbbde
+++ vsftpd-3.0.2/tunables.c	2014-04-17 10:04:52.004964675 +0200
3cbbde
@@ -72,6 +72,7 @@ int tunable_force_anon_data_ssl;
3cbbde
 int tunable_mdtm_write;
3cbbde
 int tunable_lock_upload_files;
3cbbde
 int tunable_pasv_addr_resolve;
3cbbde
+int tunable_reverse_lookup_enable;
3cbbde
 int tunable_userlist_log;
3cbbde
 int tunable_debug_ssl;
3cbbde
 int tunable_require_cert;
3cbbde
@@ -213,6 +214,7 @@ tunables_load_defaults()
3cbbde
   tunable_mdtm_write = 1;
3cbbde
   tunable_lock_upload_files = 1;
3cbbde
   tunable_pasv_addr_resolve = 0;
3cbbde
+  tunable_reverse_lookup_enable = 1;
3cbbde
   tunable_userlist_log = 0;
3cbbde
   tunable_debug_ssl = 0;
3cbbde
   tunable_require_cert = 0;
3cbbde
diff -up vsftpd-3.0.2/tunables.h.lookup vsftpd-3.0.2/tunables.h
3cbbde
--- vsftpd-3.0.2/tunables.h.lookup	2014-04-17 10:03:27.405958676 +0200
3cbbde
+++ vsftpd-3.0.2/tunables.h	2014-04-17 10:04:22.763963824 +0200
3cbbde
@@ -73,6 +73,7 @@ extern int tunable_force_anon_data_ssl;
3cbbde
 extern int tunable_mdtm_write;                /* Allow MDTM to set timestamps */
3cbbde
 extern int tunable_lock_upload_files;         /* Lock uploading files */
3cbbde
 extern int tunable_pasv_addr_resolve;         /* DNS resolve pasv_addr */
3cbbde
+extern int tunable_reverse_lookup_enable;     /* Get hostname before pam auth */
3cbbde
 extern int tunable_userlist_log;              /* Log every failed login attempt */
3cbbde
 extern int tunable_debug_ssl;                 /* Verbose SSL logging */
3cbbde
 extern int tunable_require_cert;              /* SSL client cert required */
3cbbde
diff -up vsftpd-3.0.2/vsftpd.conf.5.lookup vsftpd-3.0.2/vsftpd.conf.5
3cbbde
--- vsftpd-3.0.2/vsftpd.conf.5.lookup	2014-04-17 10:05:30.956969003 +0200
3cbbde
+++ vsftpd-3.0.2/vsftpd.conf.5	2014-04-17 10:06:36.586971828 +0200
3cbbde
@@ -425,6 +425,15 @@ http://scarybeastsecurity.blogspot.com/2
3cbbde
 
3cbbde
 Default: YES
3cbbde
 .TP
3cbbde
+.B reverse_lookup_enable
3cbbde
+Set to YES if you want vsftpd to transform the ip address into the hostname,
3cbbde
+before pam authentication. This is useful if you use pam_access including the
3cbbde
+hostname. If you want vsftpd to run on the environment where the reverse lookup
3cbbde
+for some hostname is available and the name server doesn't respond for a while,
3cbbde
+you should set this to NO to avoid a performance issue.
3cbbde
+
3cbbde
+Default: YES
3cbbde
+.TP
3cbbde
 .B run_as_launching_user
3cbbde
 Set to YES if you want vsftpd to run as the user which launched vsftpd. This is
3cbbde
 useful where root access is not available. MASSIVE WARNING! Do NOT enable this