Blame SOURCES/glibc-rh718057.patch

b40826
2011-07-01  Andreas Schwab  <schwab@redhat.com>
b40826
b40826
	* nis/nss_compat/compat-pwd.c (getpwent_next_nss_netgr): Query NIS
b40826
	domain only when needed.
b40826
b40826
Index: glibc-2.12-2-gc4ccff1/nis/nss_compat/compat-pwd.c
b40826
===================================================================
b40826
--- glibc-2.12-2-gc4ccff1.orig/nis/nss_compat/compat-pwd.c
b40826
+++ glibc-2.12-2-gc4ccff1/nis/nss_compat/compat-pwd.c
b40826
@@ -360,7 +360,7 @@ getpwent_next_nss_netgr (const char *nam
b40826
 			 char *group, char *buffer, size_t buflen,
b40826
 			 int *errnop)
b40826
 {
b40826
-  char *curdomain, *host, *user, *domain, *p2;
b40826
+  char *curdomain = NULL, *host, *user, *domain, *p2;
b40826
   int status;
b40826
   size_t p2len;
b40826
 
b40826
@@ -369,15 +369,7 @@ getpwent_next_nss_netgr (const char *nam
b40826
   if (!nss_getpwnam_r)
b40826
     return NSS_STATUS_UNAVAIL;
b40826
 
b40826
-  if (yp_get_default_domain (&curdomain) != YPERR_SUCCESS)
b40826
-    {
b40826
-      ent->netgroup = false;
b40826
-      ent->first = false;
b40826
-      give_pwd_free (&ent->pwd);
b40826
-      return NSS_STATUS_UNAVAIL;
b40826
-    }
b40826
-
b40826
-  if (ent->first == true)
b40826
+  if (ent->first)
b40826
     {
b40826
       memset (&ent->netgrdata, 0, sizeof (struct __netgrent));
b40826
       __internal_setnetgrent (group, &ent->netgrdata);
b40826
@@ -403,8 +395,19 @@ getpwent_next_nss_netgr (const char *nam
b40826
       if (user == NULL || user[0] == '-')
b40826
 	continue;
b40826
 
b40826
-      if (domain != NULL && strcmp (curdomain, domain) != 0)
b40826
-	continue;
b40826
+      if (domain != NULL)
b40826
+	{
b40826
+	  if (curdomain == NULL
b40826
+	      && yp_get_default_domain (&curdomain) != YPERR_SUCCESS)
b40826
+	    {
b40826
+	      __internal_endnetgrent (&ent->netgrdata);
b40826
+	      ent->netgroup = false;
b40826
+	      give_pwd_free (&ent->pwd);
b40826
+	      return NSS_STATUS_UNAVAIL;
b40826
+	    }
b40826
+	  if (strcmp (curdomain, domain) != 0)
b40826
+	    continue;
b40826
+	}
b40826
 
b40826
       /* If name != NULL, we are called from getpwnam.  */
b40826
       if (name != NULL)
b40826
Index: glibc-2.12-2-gc4ccff1/nis/nss_compat/compat-spwd.c
b40826
===================================================================
b40826
--- glibc-2.12-2-gc4ccff1.orig/nis/nss_compat/compat-spwd.c
b40826
+++ glibc-2.12-2-gc4ccff1/nis/nss_compat/compat-spwd.c
b40826
@@ -317,7 +317,7 @@ getspent_next_nss_netgr (const char *nam
b40826
 			 char *group, char *buffer, size_t buflen,
b40826
 			 int *errnop)
b40826
 {
b40826
-  char *curdomain, *host, *user, *domain, *p2;
b40826
+  char *curdomain = NULL, *host, *user, *domain, *p2;
b40826
   size_t p2len;
b40826
 
b40826
   if (!nss_getspnam_r)
b40826
@@ -327,15 +327,7 @@ getspent_next_nss_netgr (const char *nam
b40826
   if (ent->setent_status != NSS_STATUS_SUCCESS)
b40826
     return ent->setent_status;
b40826
 
b40826
-  if (yp_get_default_domain (&curdomain) != YPERR_SUCCESS)
b40826
-    {
b40826
-      ent->netgroup = false;
b40826
-      ent->first = false;
b40826
-      give_spwd_free (&ent->pwd);
b40826
-      return NSS_STATUS_UNAVAIL;
b40826
-    }
b40826
-
b40826
-  if (ent->first == true)
b40826
+  if (ent->first)
b40826
     {
b40826
       memset (&ent->netgrdata, 0, sizeof (struct __netgrent));
b40826
       __internal_setnetgrent (group, &ent->netgrdata);
b40826
@@ -362,8 +354,19 @@ getspent_next_nss_netgr (const char *nam
b40826
       if (user == NULL || user[0] == '-')
b40826
 	continue;
b40826
 
b40826
-      if (domain != NULL && strcmp (curdomain, domain) != 0)
b40826
-	continue;
b40826
+      if (domain != NULL)
b40826
+	{
b40826
+	  if (curdomain == NULL
b40826
+	      && yp_get_default_domain (&curdomain) != YPERR_SUCCESS)
b40826
+	    {
b40826
+	      __internal_endnetgrent (&ent->netgrdata);
b40826
+	      ent->netgroup = false;
b40826
+	      give_spwd_free (&ent->pwd);
b40826
+	      return NSS_STATUS_UNAVAIL;
b40826
+	    }
b40826
+	  if (strcmp (curdomain, domain) != 0)
b40826
+	    continue;
b40826
+	}
b40826
 
b40826
       /* If name != NULL, we are called from getpwnam */
b40826
       if (name != NULL)