File yp-tools-workaround-SunOS-bug.diff of Package yp-tools

--- src/ypwhich.c
+++ src/ypwhich.c	2014/10/27 13:10:31
@@ -20,6 +20,8 @@
 #include "config.h"
 #endif
 
+#define _GNU_SOURCE
+
 #ifdef HAVE_GETOPT_H
 #include <getopt.h>
 #else
@@ -28,6 +30,7 @@
 #include <locale.h>
 #include <libintl.h>
 #include <netdb.h>
+#include <stdio.h>
 #include <stdlib.h>
 #include <unistd.h>
 #include <netinet/in.h>
@@ -131,13 +134,23 @@
 
   if (ret != RPC_SUCCESS)
     {
-      fprintf (stderr, "ypwhich: %s\n", yperr_string (YPERR_YPBIND));
+      char *err = NULL;
+
+      if (asprintf (&err, _("ypwhich: can't call ypbind on '%s'"),
+                    inet_ntoa (socka_in->sin_addr)) > 0)
+	{
+	  clnt_perror (client, err);
+	  free (err);
+        }
       clnt_destroy (client);
       return 1;
     }
   else
     {
-      if (yp_r.ypbind_status != YPBIND_SUCC_VAL)
+      if (yp_r.ypbind_status != YPBIND_SUCC_VAL ||
+	  /* that's an ugly hack, but ypbind of Solaris reports for V1 and V2
+	     YPBIND_SUCC_VAL if it is bound to a server with IPv6 address. */
+	  yp_r.ypbind_respbody.ypbind_bindinfo.ypbind_binding_port == 0)
         {
           fprintf (stderr, _("can't yp_bind: Reason: %s\n"),
                    ypbinderr_string (yp_r.ypbind_respbody.ypbind_error));
openSUSE Build Service is sponsored by