Blame SOURCES/glibc-rh718057.patch

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