mirror of git://sourceware.org/git/glibc.git
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.
This commit is contained in:
parent
e0dbb48105
commit
a70e964ee0
15
ChangeLog
15
ChangeLog
|
|
@ -1,5 +1,20 @@
|
||||||
|
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.
|
||||||
|
|
||||||
2004-03-30 Ulrich Drepper <drepper@redhat.com>
|
2004-03-30 Ulrich Drepper <drepper@redhat.com>
|
||||||
|
|
||||||
|
* nss/getent.c (services_keys): Don't implement lookups with
|
||||||
|
missing protocol using getservent loop, just pass NULL.
|
||||||
|
|
||||||
* sysdeps/unix/sysv/linux/i386/setgroups.c (setgroups): Avoid
|
* sysdeps/unix/sysv/linux/i386/setgroups.c (setgroups): Avoid
|
||||||
comparison with limit if we can rely on the syscall being available.
|
comparison with limit if we can rely on the syscall being available.
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -279,18 +279,21 @@ _nss_nis_getservbyname_r (const char *name, const char *protocol,
|
||||||
return NSS_STATUS_UNAVAIL;
|
return NSS_STATUS_UNAVAIL;
|
||||||
|
|
||||||
/* If the protocol is given, we could try if our NIS server knows
|
/* If the protocol is given, we could try if our NIS server knows
|
||||||
about services.byservicename map. If yes, we only need one query */
|
about services.byservicename map. If yes, we only need one query.
|
||||||
if (protocol != NULL)
|
If the protocol is not given, try first name/tcp, then name/udp
|
||||||
|
and then fallback to sequential scanning of services.byname map. */
|
||||||
|
const char *proto = protocol != NULL ? protocol : "tcp";
|
||||||
|
do
|
||||||
{
|
{
|
||||||
char key[strlen (name) + strlen (protocol) + 2];
|
char key[strlen (name) + strlen (proto) + 2];
|
||||||
char *cp, *result;
|
char *cp, *result;
|
||||||
size_t keylen, len;
|
size_t keylen, len;
|
||||||
int int_len;
|
int int_len;
|
||||||
|
|
||||||
/* key is: "name/protocol" */
|
/* key is: "name/proto" */
|
||||||
cp = stpcpy (key, name);
|
cp = stpcpy (key, name);
|
||||||
*cp++ = '/';
|
*cp++ = '/';
|
||||||
stpcpy (cp, protocol);
|
stpcpy (cp, proto);
|
||||||
keylen = strlen (key);
|
keylen = strlen (key);
|
||||||
status = yperr2nss (yp_match (domain, "services.byservicename", key,
|
status = yperr2nss (yp_match (domain, "services.byservicename", key,
|
||||||
keylen, &result, &int_len));
|
keylen, &result, &int_len));
|
||||||
|
|
@ -329,6 +332,7 @@ _nss_nis_getservbyname_r (const char *name, const char *protocol,
|
||||||
return NSS_STATUS_SUCCESS;
|
return NSS_STATUS_SUCCESS;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
while (protocol == NULL && (proto[0] == 't' ? (proto = "udp") : NULL));
|
||||||
|
|
||||||
struct ypall_callback ypcb;
|
struct ypall_callback ypcb;
|
||||||
struct search_t req;
|
struct search_t req;
|
||||||
|
|
@ -343,7 +347,7 @@ _nss_nis_getservbyname_r (const char *name, const char *protocol,
|
||||||
req.buflen = buflen;
|
req.buflen = buflen;
|
||||||
req.errnop = errnop;
|
req.errnop = errnop;
|
||||||
req.status = NSS_STATUS_NOTFOUND;
|
req.status = NSS_STATUS_NOTFOUND;
|
||||||
status = yperr2nss (yp_all (domain, "services.byservicename", &ypcb));
|
status = yperr2nss (yp_all (domain, "services.byname", &ypcb));
|
||||||
|
|
||||||
if (status != NSS_STATUS_SUCCESS)
|
if (status != NSS_STATUS_SUCCESS)
|
||||||
return status;
|
return status;
|
||||||
|
|
@ -362,16 +366,19 @@ _nss_nis_getservbyport_r (int port, const char *protocol,
|
||||||
if (yp_get_default_domain (&domain))
|
if (yp_get_default_domain (&domain))
|
||||||
return NSS_STATUS_UNAVAIL;
|
return NSS_STATUS_UNAVAIL;
|
||||||
|
|
||||||
/* If the protocol is given, we only need one query */
|
/* If the protocol is given, we only need one query.
|
||||||
if (protocol != NULL)
|
Otherwise try first port/tcp, then port/udp and then fallback
|
||||||
|
to sequential scanning of services.byname. */
|
||||||
|
const char *proto = protocol != NULL ? protocol : "tcp";
|
||||||
|
do
|
||||||
{
|
{
|
||||||
char key[100 + strlen (protocol) + 2];
|
char key[sizeof (int) * 3 + strlen (proto) + 2];
|
||||||
char *result;
|
char *result;
|
||||||
size_t keylen, len;
|
size_t keylen, len;
|
||||||
int int_len;
|
int int_len;
|
||||||
|
|
||||||
/* key is: "port/protocol" */
|
/* key is: "port/proto" */
|
||||||
keylen = snprintf (key, sizeof (key), "%d/%s", port, protocol);
|
keylen = snprintf (key, sizeof (key), "%d/%s", ntohs (port), proto);
|
||||||
status = yperr2nss (yp_match (domain, "services.byname", key,
|
status = yperr2nss (yp_match (domain, "services.byname", key,
|
||||||
keylen, &result, &int_len));
|
keylen, &result, &int_len));
|
||||||
len = int_len;
|
len = int_len;
|
||||||
|
|
@ -409,6 +416,7 @@ _nss_nis_getservbyport_r (int port, const char *protocol,
|
||||||
return NSS_STATUS_SUCCESS;
|
return NSS_STATUS_SUCCESS;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
while (protocol == NULL && (proto[0] == 't' ? (proto = "udp") : NULL));
|
||||||
|
|
||||||
if (port == -1)
|
if (port == -1)
|
||||||
return NSS_STATUS_NOTFOUND;
|
return NSS_STATUS_NOTFOUND;
|
||||||
|
|
|
||||||
53
nss/getent.c
53
nss/getent.c
|
|
@ -638,53 +638,18 @@ services_keys (int number, char *key[])
|
||||||
struct servent *serv;
|
struct servent *serv;
|
||||||
char *proto = strchr (key[i], '/');
|
char *proto = strchr (key[i], '/');
|
||||||
|
|
||||||
if (proto == NULL)
|
if (proto != NULL)
|
||||||
{
|
*proto++ = '\0';
|
||||||
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 (isdigit (key[i][0]))
|
||||||
if (strcmp (serv->s_name, key[i]) == 0)
|
serv = getservbyport (htons (atol (key[i])), proto);
|
||||||
{
|
|
||||||
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
|
else
|
||||||
{
|
serv = getservbyname (key[i], proto);
|
||||||
*proto++ = '\0';
|
|
||||||
|
|
||||||
if (isdigit (key[i][0]))
|
if (serv == NULL)
|
||||||
serv = getservbyport (htons (atol (key[i])), proto);
|
result = 2;
|
||||||
else
|
else
|
||||||
serv = getservbyname (key[i], proto);
|
print_services (serv);
|
||||||
|
|
||||||
if (serv == NULL)
|
|
||||||
result = 2;
|
|
||||||
else
|
|
||||||
print_services (serv);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue