ud-fingerserv: fix logging when using ipv6 and inetd
authorJulien Cristau <jcristau@debian.org>
Tue, 12 Nov 2019 20:58:35 +0000 (21:58 +0100)
committerJulien Cristau <jcristau@debian.org>
Tue, 12 Nov 2019 20:58:57 +0000 (21:58 +0100)
This removes the reverse name resolution because I don't think it's useful.

debian/changelog
ud-fingerserv

index 916ef10..cf1e4a5 100644 (file)
@@ -25,6 +25,7 @@ userdir-ldap (0.3.97) UNRELEASED; urgency=medium
   * ud-mailgate: use subprocess.Popen instead of os.popen.
   * ud-host: use subprocess.Popen instead of os.popen.
   * Use ldap.initialize instead of ldap.open for compatibility with python-ldap 3.2.0.
+  * ud-fingerserv: fix logging when using ipv6 and inetd
 
  -- Peter Palfrader <weasel@debian.org>  Sat, 06 Apr 2019 22:04:34 +0200
 
index fcdd57a..14444a7 100755 (executable)
@@ -10,6 +10,7 @@ use lib '/var/www/userdir-ldap/';
 use strict vars;
 use IO::Handle;
 use IO::Socket;
+use Socket qw(:addrinfo);
 use POSIX qw(:sys_wait_h);
 use Getopt::Std;
 use Util;
@@ -102,8 +103,8 @@ if (!$use_inetd) {
   &log("inetd mode");
   my $sockaddr = getpeername(STDIN);
   if ($sockaddr) {
-    my ($port, $addr) = unpack_sockaddr_in(getpeername(STDIN));
-    &log(sprintf("[Connect from %s (%s)]", gethostbyaddr($addr, AF_INET), inet_ntoa($addr)));
+    my ($err, $hostname, $servicename) = getnameinfo($sockaddr, NI_NUMERICHOST|NI_NUMERICSERV);
+    &log(sprintf("[Connect from %s:%s]", $hostname, $servicename));
   } else {
     &log("[Connect via terminal]");
   }