Blame SOURCES/vsftpd-2.1.0-pam_hostname.patch

bd78b8
diff -up vsftpd-2.2.0/sysdeputil.c.pam_hostname vsftpd-2.2.0/sysdeputil.c
bd78b8
--- vsftpd-2.2.0/sysdeputil.c.pam_hostname	2009-08-08 03:51:10.000000000 +0200
bd78b8
+++ vsftpd-2.2.0/sysdeputil.c	2009-08-24 12:24:07.220623773 +0200
bd78b8
@@ -16,6 +16,10 @@
bd78b8
 #include "tunables.h"
bd78b8
 #include "builddefs.h"
bd78b8
 
bd78b8
+/* For gethostbyaddr, inet_addr */
bd78b8
+#include <netdb.h>
bd78b8
+#include <arpa/inet.h>
bd78b8
+
bd78b8
 /* For Linux, this adds nothing :-) */
bd78b8
 #include "port/porting_junk.h"
bd78b8
 
bd78b8
@@ -325,6 +329,10 @@ vsf_sysdep_check_auth(struct mystr* p_us
bd78b8
                       const struct mystr* p_remote_host)
bd78b8
 {
bd78b8
   int retval = -1;
bd78b8
+#ifdef PAM_RHOST
bd78b8
+  struct sockaddr_in sin;
bd78b8
+  struct hostent *host;
bd78b8
+#endif
bd78b8
   pam_item_t item;
bd78b8
   const char* pam_user_name = 0;
bd78b8
   struct pam_conv the_conv =
bd78b8
@@ -345,7 +353,12 @@ vsf_sysdep_check_auth(struct mystr* p_us
bd78b8
     return 0;
bd78b8
   }
bd78b8
 #ifdef PAM_RHOST
bd78b8
-  retval = pam_set_item(s_pamh, PAM_RHOST, str_getbuf(p_remote_host));
bd78b8
+  sin.sin_addr.s_addr = inet_addr(str_getbuf(p_remote_host));
bd78b8
+  host = gethostbyaddr((char*)&sin.sin_addr.s_addr,sizeof(struct in_addr),AF_INET);
bd78b8
+  if (host != (struct hostent*)0)
bd78b8
+    retval = pam_set_item(s_pamh, PAM_RHOST, host->h_name);
bd78b8
+  else
bd78b8
+    retval = pam_set_item(s_pamh, PAM_RHOST, str_getbuf(p_remote_host));
bd78b8
   if (retval != PAM_SUCCESS)
bd78b8
   {
bd78b8
     (void) pam_end(s_pamh, retval);
bd78b8
@@ -558,7 +571,7 @@ vsf_sysdep_has_capabilities(void)
bd78b8
   }
bd78b8
   return s_runtime_has_caps;
bd78b8
 }
bd78b8
-  
bd78b8
+
bd78b8
   #ifndef VSF_SYSDEP_HAVE_LIBCAP
bd78b8
 static int
bd78b8
 do_checkcap(void)
bd78b8
@@ -1080,7 +1093,7 @@ vsf_sysutil_recv_fd(const int sock_fd)
bd78b8
   msg.msg_flags = 0;
bd78b8
   /* In case something goes wrong, set the fd to -1 before the syscall */
bd78b8
   p_fd = (int*)CMSG_DATA(CMSG_FIRSTHDR(&msg));
bd78b8
-  *p_fd = -1;  
bd78b8
+  *p_fd = -1;
bd78b8
   retval = recvmsg(sock_fd, &msg, 0);
bd78b8
   if (retval != 1)
bd78b8
   {