diff options
Diffstat (limited to 'nss')
-rw-r--r-- | nss/getent.c | 55 |
1 files changed, 10 insertions, 45 deletions
diff --git a/nss/getent.c b/nss/getent.c index f43bc635dc..5738affd53 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; |