This is the mail archive of the libc-hacker@sources.redhat.com mailing list for the glibc project.

Note that libc-hacker is a closed list. You may look at the archives of this list, but subscription and posting are not open.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[PATCH] Fix NIS


Hi!

getservbyname doesn't work with NIS (but I'm surprised this has not shown
up in many other places) if the NIS server doesn't provide
services.byservicename map, eventhough /etc/default/nss doesn't say
it is available and authoritative:
#SERVICES_AUTHORITATIVE=TRUE
(with SERVICES_AUTHORITATIVE=TRUE and no services.byservicename this
would be expected).
_nss_nis_getservbyname_r in that case tries services.byservicename
map (which fails) and then walks services.byname map with
yp_all.  When the search routine finds the service it is looking for,
yp_all sees data.status == YP_TRUE and result (from clnt_call) RPC_SUCCESS.
The code then does:
      if (res == YPERR_SUCCESS && data.status != YP_NOMORE)
        {
          __set_errno (saved_errno);
          return ypprot_err (data.status);
        }
but since October 2004 ypprot_err no longer handles error values above
YP_NOKEY, so this returns YPERR_YPERR and thus getservbyname results
failure.

Fixed thusly.

2005-03-23  Jakub Jelinek  <jakub@redhat.com>

	* nis/ypclnt.c (yp_2_yperr): Revert 2004-11-30 patch.
	(ypprot_err): Use yp_2_yperr table also for YP_NODOM .. YP_NOMORE.

--- libc/nis/ypclnt.c.jj	2004-12-06 12:40:54.000000000 +0100
+++ libc/nis/ypclnt.c	2005-03-23 15:53:30.657777627 +0100
@@ -1,4 +1,5 @@
-/* Copyright (C) 1996-2001, 2002, 2003, 2004 Free Software Foundation, Inc.
+/* Copyright (C) 1996-2001, 2002, 2003, 2004, 2005
+   Free Software Foundation, Inc.
    This file is part of the GNU C Library.
    Contributed by Thorsten Kukuk <kukuk@suse.de>, 1996.
 
@@ -829,6 +830,11 @@ yperr_string (const int error)
 static const int8_t yp_2_yperr[] =
   {
 #define YP2YPERR(yp, yperr)  [YP_##yp - YP_VERS] = YPERR_##yperr
+    YP2YPERR (TRUE, SUCCESS),
+    YP2YPERR (NOMORE, NOMORE),
+    YP2YPERR (FALSE, YPERR),
+    YP2YPERR (NOMAP, MAP),
+    YP2YPERR (NODOM, DOMAIN),
     YP2YPERR (NOKEY, KEY),
     YP2YPERR (BADOP, YPERR),
     YP2YPERR (BADDB, BADDB),
@@ -839,7 +845,7 @@ static const int8_t yp_2_yperr[] =
 int
 ypprot_err (const int code)
 {
-  if (code < YP_VERS || code > YP_NOKEY)
+  if (code < YP_VERS || code > YP_NOMORE)
     return YPERR_YPERR;
   return yp_2_yperr[code - YP_VERS];
 }

	Jakub


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]