]> git.ipfire.org Git - thirdparty/glibc.git/blobdiff - nis/nis_ping.c
nss_nis, nss_nisplus: Remove RES_USE_INET6 handling
[thirdparty/glibc.git] / nis / nis_ping.c
index 1397cb9c98c052658e9585108dc716e0add45755..1d388d8151620577063c1827af4b9e98e5f6a04e 100644 (file)
@@ -1,32 +1,35 @@
-/* Copyright (c) 1997 Free Software Foundation, Inc.
+/* Copyright (c) 1997-2019 Free Software Foundation, Inc.
    This file is part of the GNU C Library.
-   Contributed by Thorsten Kukuk <kukuk@vt.uni-paderborn.de>, 1997.
+   Contributed by Thorsten Kukuk <kukuk@suse.de>, 1997.
 
    The GNU C Library is free software; you can redistribute it and/or
-   modify it under the terms of the GNU Library General Public License as
-   published by the Free Software Foundation; either version 2 of the
-   License, or (at your option) any later version.
+   modify it under the terms of the GNU Lesser General Public
+   License as published by the Free Software Foundation; either
+   version 2.1 of the License, or (at your option) any later version.
 
    The GNU C Library is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
-   Library General Public License for more details.
+   Lesser General Public License for more details.
 
-   You should have received a copy of the GNU Library General Public
-   License along with the GNU C Library; see the file COPYING.LIB.  If not,
-   write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
-   Boston, MA 02111-1307, USA. */
+   You should have received a copy of the GNU Lesser General Public
+   License along with the GNU C Library; if not, see
+   <http://www.gnu.org/licenses/>.  */
 
 #include <rpcsvc/nis.h>
+#include <shlib-compat.h>
+
+#include "nis_xdr.h"
 #include "nis_intern.h"
 
 void
-nis_ping (const_nis_name dirname, u_long utime, const nis_object *dirobj)
+nis_ping (const_nis_name dirname, unsigned int utime,
+         const nis_object *dirobj)
 {
   nis_result *res = NULL;
   nis_object *obj;
   ping_args args;
-  u_int i;
+  unsigned int i;
 
   if (dirname == NULL && dirobj == NULL)
     abort ();
@@ -34,8 +37,11 @@ nis_ping (const_nis_name dirname, u_long utime, const nis_object *dirobj)
   if (dirobj == NULL)
     {
       res = nis_lookup (dirname, MASTER_ONLY);
-      if (res->status != NIS_SUCCESS)
-       return;
+      if (res == NULL || NIS_RES_STATUS (res) != NIS_SUCCESS)
+       {
+         nis_freeresult (res);
+         return;
+       }
       obj = res->objects.objects_val;
     }
   else
@@ -44,8 +50,7 @@ nis_ping (const_nis_name dirname, u_long utime, const nis_object *dirobj)
   /* Check if obj is really a diryectory object */
   if (__type_of (obj) != NIS_DIRECTORY_OBJ)
     {
-      if (res != NULL)
-       nis_freeresult (res);
+      nis_freeresult (res);
       return;
     }
 
@@ -55,11 +60,12 @@ nis_ping (const_nis_name dirname, u_long utime, const nis_object *dirobj)
     args.dir = (char *) dirname;
   args.stamp = utime;
 
-  for (i = 0; i < obj->DI_data.do_servers.do_servers_len; ++i)
+  /* Send the ping only to replicas */
+  for (i = 1; i < obj->DI_data.do_servers.do_servers_len; ++i)
     __do_niscall2 (&obj->DI_data.do_servers.do_servers_val[i], 1,
-                  NIS_PING, (xdrproc_t) xdr_ping_args,
+                  NIS_PING, (xdrproc_t) _xdr_ping_args,
                   (caddr_t) &args, (xdrproc_t) xdr_void,
                   (caddr_t) NULL, 0, NULL);
-  if (res)
-    nis_freeresult (res);
+  nis_freeresult (res);
 }
+libnsl_hidden_nolink_def (nis_ping, GLIBC_2_1)