Blame SOURCES/vsftpd-3.0.2-reverse-lookup.patch

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