summaryrefslogtreecommitdiff
path: root/packages/glibc/glibc-2.3.2/nss_compat-shadow.patch
blob: 1fc774aadbe36ccc753c77152235adf59a681712 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
--- nis/nss_compat/compat-spwd.c
+++ nis/nss_compat/compat-spwd.c	2003/09/01 15:14:14
@@ -435,7 +435,7 @@
   copy_spwd_changes (result, &pwd, p, plen);
   give_spwd_free (&pwd);
   /* We found the entry.  */
-  return NSS_STATUS_RETURN;
+  return NSS_STATUS_SUCCESS;
 }
 
 static enum nss_status
@@ -539,13 +539,16 @@
       if (result->sp_namp[0] == '+' && result->sp_namp[1] != '\0'
 	  && result->sp_namp[1] != '@')
 	{
+          size_t len = strlen (result->sp_namp);
+          char buf[len];
 	  enum nss_status status;
 
 	  /* Store the User in the blacklist for the "+" at the end of
 	     /etc/passwd */
-	  blacklist_store_name (&result->sp_namp[1], ent);
+          memcpy (buf, &result->sp_namp[1], len);
 	  status = getspnam_plususer (&result->sp_namp[1], result, ent,
 				      buffer, buflen, errnop);
+	  blacklist_store_name (buf, ent);
 
 	  if (status == NSS_STATUS_SUCCESS)	/* We found the entry. */
 	    break;
@@ -653,6 +656,9 @@
 	      return NSS_STATUS_TRYAGAIN;
 	    }
 
+          /* Terminate the line for any case.  */
+          buffer[buflen - 1] = '\0';
+
 	  /* Skip leading blanks.  */
 	  while (isspace (*p))
 	    ++p;
@@ -686,21 +692,8 @@
       if (result->sp_namp[0] == '-' && result->sp_namp[1] == '@'
 	  && result->sp_namp[2] != '\0')
 	{
-	  /* XXX Do not use fixed length buffers.  */
-	  char buf2[1024];
-	  char *user, *host, *domain;
-	  struct __netgrent netgrdata;
-
-	  bzero (&netgrdata, sizeof (struct __netgrent));
-	  __internal_setnetgrent (&result->sp_namp[2], &netgrdata);
-	  while (__internal_getnetgrent_r (&host, &user, &domain, &netgrdata,
-					   buf2, sizeof (buf2), errnop))
-	    {
-	      if (user != NULL && user[0] != '-')
-		if (strcmp (user, name) == 0)
-		  return NSS_STATUS_NOTFOUND;
-	    }
-	  __internal_endnetgrent (&netgrdata);
+	  if (innetgr (&result->sp_namp[2], NULL, name, NULL))
+            return NSS_STATUS_NOTFOUND;
 	  continue;
 	}
 
@@ -708,25 +701,18 @@
       if (result->sp_namp[0] == '+' && result->sp_namp[1] == '@'
 	  && result->sp_namp[2] != '\0')
 	{
-	  char *buf = strdupa (&result->sp_namp[2]);
-	  int status;
+          enum nss_status status;
 
-	  ent->netgroup = TRUE;
-	  ent->first = TRUE;
-	  copy_spwd_changes (&ent->pwd, result, NULL, 0);
+          if (innetgr (&result->sp_namp[2], NULL, name, NULL))
+            {
+              status = getspnam_plususer (name, result, ent, buffer,
+                                          buflen, errnop);
 
-	  do
-	    {
-	      status = getspent_next_nss_netgr (name, result, ent, buf,
-						buffer, buflen, errnop);
-	      if (status == NSS_STATUS_RETURN)
-		continue;
+              if (status == NSS_STATUS_RETURN)
+                continue;
 
-	      if (status == NSS_STATUS_SUCCESS
-		  && strcmp (result->sp_namp, name) == 0)
-		return NSS_STATUS_SUCCESS;
-	    }
-	  while (status == NSS_STATUS_SUCCESS);
+              return status;
+            }
 	  continue;
 	}
 
@@ -767,10 +753,12 @@
 	  status = getspnam_plususer (name, result, ent,
 				      buffer, buflen, errnop);
 
-	  if (status == NSS_STATUS_RETURN)	/* We couldn't parse the entry */
-	    return NSS_STATUS_NOTFOUND;
-	  else
-	    return status;
+          if (status == NSS_STATUS_SUCCESS)     /* We found the entry. */
+            break;
+          else if (status == NSS_STATUS_RETURN) /* We couldn't parse the entry */
+            return NSS_STATUS_NOTFOUND;
+          else
+            return status;
 	}
     }
   return NSS_STATUS_SUCCESS;
@@ -796,10 +784,8 @@
 
   result = internal_setspent (&ent, 0);
 
-  if (result != NSS_STATUS_SUCCESS)
-    return result;
-
-  result = internal_getspnam_r (name, pwd, &ent, buffer, buflen, errnop);
+  if (result == NSS_STATUS_SUCCESS)
+    result = internal_getspnam_r (name, pwd, &ent, buffer, buflen, errnop);
 
   internal_endspent (&ent);