diff -up vsftpd-2.1.0/sysdeputil.c.pam_hostname vsftpd-2.1.0/sysdeputil.c --- vsftpd-2.1.0/sysdeputil.c.pam_hostname 2008-12-17 22:40:56.000000000 +0100 +++ vsftpd-2.1.0/sysdeputil.c 2009-01-15 15:38:14.000000000 +0100 @@ -16,6 +16,10 @@ #include "tunables.h" #include "builddefs.h" +/* For gethostbyaddr, inet_addr */ +#include +#include + /* For Linux, this adds nothing :-) */ #include "port/porting_junk.h" @@ -296,6 +300,10 @@ vsf_sysdep_check_auth(const struct mystr const struct mystr* p_remote_host) { int retval; +#ifdef PAM_RHOST + struct sockaddr_in sin; + struct hostent *host; +#endif struct pam_conv the_conv = { &pam_conv_func, @@ -314,7 +322,12 @@ vsf_sysdep_check_auth(const struct mystr return 0; } #ifdef PAM_RHOST - retval = pam_set_item(s_pamh, PAM_RHOST, str_getbuf(p_remote_host)); + sin.sin_addr.s_addr = inet_addr(str_getbuf(p_remote_host)); + host = gethostbyaddr((char*)&sin.sin_addr.s_addr,sizeof(struct in_addr),AF_INET); + if (host != (struct hostent*)0) + retval = pam_set_item(s_pamh, PAM_RHOST, host->h_name); + else + retval = pam_set_item(s_pamh, PAM_RHOST, str_getbuf(p_remote_host)); if (retval != PAM_SUCCESS) { (void) pam_end(s_pamh, retval); @@ -516,7 +529,7 @@ vsf_sysdep_has_capabilities(void) } return s_runtime_has_caps; } - + #ifndef VSF_SYSDEP_HAVE_LIBCAP static int do_checkcap(void) @@ -1038,7 +1051,7 @@ vsf_sysutil_recv_fd(const int sock_fd) msg.msg_flags = 0; /* In case something goes wrong, set the fd to -1 before the syscall */ p_fd = (int*)CMSG_DATA(CMSG_FIRSTHDR(&msg)); - *p_fd = -1; + *p_fd = -1; retval = recvmsg(sock_fd, &msg, 0); if (retval != 1) {