(services_keys): Don't implement lookups with missing protocol using
authordrepper <drepper>
Wed, 31 Mar 2004 00:14:10 +0000 (00:14 +0000)
committerdrepper <drepper>
Wed, 31 Mar 2004 00:14:10 +0000 (00:14 +0000)
getservent loop, just pass NULL.

nss/getent.c

index f43bc63..5738aff 100644 (file)
@@ -638,53 +638,18 @@ services_keys (int number, char *key[])
       struct servent *serv;
       char *proto = strchr (key[i], '/');
 
-      if (proto == NULL)
-       {
-         setservent (0);
-         if (isdigit (key[i][0]))
-           {
-             int port = htons (atol (key[i]));
-             while ((serv = getservent ()) != NULL)
-               if (serv->s_port == port)
-                 {
-                   print_services (serv);
-                   break;
-                 }
-           }
-         else
-           {
-             int j;
-
-             while ((serv = getservent ()) != NULL)
-               if (strcmp (serv->s_name, key[i]) == 0)
-                 {
-                   print_services (serv);
-                   break;
-                 }
-               else
-                 for (j = 0; serv->s_aliases[j]; ++j)
-                   if (strcmp (serv->s_aliases[j], key[i]) == 0)
-                     {
-                       print_services (serv);
-                       break;
-                     }
-           }
-         endservent ();
-       }
-      else
-       {
-         *proto++ = '\0';
+      if (proto != NULL)
+       *proto++ = '\0';
 
-         if (isdigit (key[i][0]))
-           serv = getservbyport (htons (atol (key[i])), proto);
-         else
-           serv = getservbyname (key[i], proto);
+      if (isdigit (key[i][0]))
+       serv = getservbyport (htons (atol (key[i])), proto);
+      else
+       serv = getservbyname (key[i], proto);
 
-         if (serv == NULL)
-           result = 2;
-         else
-           print_services (serv);
-       }
+      if (serv == NULL)
+       result = 2;
+      else
+       print_services (serv);
     }
 
   return result;