aboutsummaryrefslogtreecommitdiff
path: root/nss
diff options
context:
space:
mode:
authorUlrich Drepper <drepper@redhat.com>2004-03-31 00:16:53 +0000
committerUlrich Drepper <drepper@redhat.com>2004-03-31 00:16:53 +0000
commita70e964ee0ec3827b4d24ed3fbff1b614b1a0269 (patch)
tree9483b75961175d2d5f7509d95519b931514a91b8 /nss
parente0dbb4810552c091065080cb61d631354040f826 (diff)
downloadglibc-a70e964ee0ec3827b4d24ed3fbff1b614b1a0269.zip
glibc-a70e964ee0ec3827b4d24ed3fbff1b614b1a0269.tar.gz
glibc-a70e964ee0ec3827b4d24ed3fbff1b614b1a0269.tar.bz2
Update.
2004-03-30 Jakub Jelinek <jakub@redhat.com> * nis/nss_nis/nis-service.c (_nss_nis_getservbyname_r): If protocol == NULL, try name/tcp and name/udp first before falling back into the sequential scanning. Use services.byname database for sequential scanning. (_nss_nis_getservbyport_r): Likewise. Just allocate sizeof (int) * 3 chars for integer. * nis/nss_nis/nis-service.c (_nss_nis_getservbyport_r): Convert proto to host by order for snprintf. * nss/getent.c (services_keys): Don't implement lookups with missing protocol using getservent loop, just pass NULL.
Diffstat (limited to 'nss')
-rw-r--r--nss/getent.c55
1 files changed, 10 insertions, 45 deletions
diff --git a/nss/getent.c b/nss/getent.c
index f43bc63..5738aff 100644
--- a/nss/getent.c
+++ b/nss/getent.c
@@ -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;