Origin: upstream commit beea54019b14ee4534a4079ee76a72128294d762
    Code by Boris Manojlovic <boris@steki.net>, taken from openSUSE,
    submitted by Andreas Stieger <andreas.stieger@gmx.de>, additional
    fixes by Robert Grimm <rob@robgri.de>.
Description: Add IPv6 support to whoami().
Author: Matthias Andree <matthias.andree@gmx.de>
Date:   Sun Sep 25 17:47:38 2011 +0200

Index: leafnode-1.11.8/NEWS
===================================================================
--- leafnode-1.11.8.orig/NEWS	2012-04-15 18:26:16.000000000 +0200
+++ leafnode-1.11.8/NEWS	2012-04-15 18:27:11.018668455 +0200
@@ -11,6 +11,8 @@
   strict-aliasing rules"
 - Fix a file descriptor leak in fetchnews.c's getbody_newno function; reported
   to Debian BTS by Helmut Grohne, fix by Robert Grimm.
+- The whoami() function is now IPv6 enabled. Code contributed to openSUSE by
+  Boris Manojlovic and submitted by Andreas Stieger.
 
 ### CHANGES
 - Leafnode now enables IPv6 support by default. Use --without-ipv6 to disable.
Index: leafnode-1.11.8/miscutil.c
===================================================================
--- leafnode-1.11.8.orig/miscutil.c	2012-04-15 18:26:16.000000000 +0200
+++ leafnode-1.11.8/miscutil.c	2012-04-18 08:51:47.554154236 +0200
@@ -487,7 +487,33 @@
     return 0;
 }
 
+#ifdef HAVE_IPV6
 /* get the fully qualified domain name of this box into fqdn */
+/* IPv6-capable version by Boris Manojlovic <boris@steki.net> */
+static void
+whoami(void)
+{
+    struct addrinfo hints, *res;
+    int debugqual = 0;
+    char *x;
+
+    if ((x = getenv("LN_DEBUG_QUALIFICATION")) != NULL
+	&& *x)
+	debugqual = 1;
+    memset(&hints, 0, sizeof hints);
+    hints.ai_flags = AI_CANONNAME;
+
+    if (!gethostname(fqdn, sizeof(fqdn)) && !getaddrinfo(fqdn, NULL, &hints, &res)) {
+	if (res->ai_canonname != NULL) {
+            xstrlcpy(fqdn,res->ai_canonname, sizeof(fqdn));
+            if (debugqual) syslog(LOG_DEBUG, "canonical hostname: %s", fqdn);
+        }
+        freeaddrinfo(res);
+    }
+}
+#else
+/* get the fully qualified domain name of this box into fqdn */
+/* legacy version, uses legacy (IPv4) gethostby*() interfaces */
 static void
 whoami(void)
 {
@@ -520,6 +546,7 @@
 	endhostent();
     }
 }
+#endif
 
 /*
  * prepend string "newentry" to stringlist "list".
