#include <arpa/inet.h>
#include <string.h>
#include <stdlib.h>
+#include <errno.h>
#include <stdio.h>
#include <ctype.h>
#include <rpc/types.h>
if (!xdr_int(&outxdr, (int32_t *)&na))
{
xdr_destroy(&outxdr);
+ errno = EIO;
return EAI_SYSTEM;
}
if (encode_kv(&outxdr, "name", nodename) != 0)
{
xdr_destroy(&outxdr);
+ errno = EIO;
return EAI_SYSTEM;
}
}
if (encode_kv(&outxdr, "service", servname) != 0)
{
xdr_destroy(&outxdr);
+ errno = EIO;
return EAI_SYSTEM;
}
}
if (encode_kv(&outxdr, "protocol", str) != 0)
{
xdr_destroy(&outxdr);
+ errno = EIO;
return EAI_SYSTEM;
}
}
if (encode_kv(&outxdr, "socktype", str) != 0)
{
xdr_destroy(&outxdr);
+ errno = EIO;
return EAI_SYSTEM;
}
}
if (encode_kv(&outxdr, "family", str) != 0)
{
xdr_destroy(&outxdr);
+ errno = EIO;
return EAI_SYSTEM;
}
}
if (encode_kv(&outxdr, "canonname", "1") != 0)
{
xdr_destroy(&outxdr);
+ errno = EIO;
return EAI_SYSTEM;
}
}
if (encode_kv(&outxdr, "passive", "1") != 0)
{
xdr_destroy(&outxdr);
+ errno = EIO;
return EAI_SYSTEM;
}
}
if (encode_kv(&outxdr, "parallel", "1") != 0)
{
xdr_destroy(&outxdr);
+ errno = EIO;
return EAI_SYSTEM;
}
}
if (encode_kv(&outxdr, "numerichost", "1") != 0)
{
xdr_destroy(&outxdr);
+ errno = EIO;
return EAI_SYSTEM;
}
}
if (gai_proc < 0)
{
status = _lookup_link(server_port, "getaddrinfo", &gai_proc);
- if (status != KERN_SUCCESS) return EAI_SYSTEM;
+ if (status != KERN_SUCCESS)
+ {
+ errno = ECONNREFUSED;
+ return EAI_SYSTEM;
+ }
}
qlen = LU_QBUF_SIZE;
+
+ /* gai_make_query sets errno if it fails */
i = gai_make_query(nodename, servname, hints, qbuf, &qlen);
if (i != 0) return EAI_SYSTEM;
if (!xdr_int(&inxdr, (int32_t *)&n))
{
xdr_destroy(&inxdr);
+ errno = EIO;
return EAI_SYSTEM;
}
server_port = MACH_PORT_NULL;
if (_lu_running()) server_port = _lookupd_port(0);
- if (server_port == MACH_PORT_NULL) return EAI_SYSTEM;
+ if (server_port == MACH_PORT_NULL)
+ {
+ errno = ECONNREFUSED;
+ return EAI_SYSTEM;
+ }
if (gai_proc < 0)
{
status = _lookup_link(server_port, "getaddrinfo", &gai_proc);
- if (status != KERN_SUCCESS) return EAI_SYSTEM;
+ if (status != KERN_SUCCESS)
+ {
+ errno = ECONNREFUSED;
+ return EAI_SYSTEM;
+ }
}
qlen = LU_QBUF_SIZE;
+
+ /* gai_make_query sets errno if it fails */
i = gai_make_query(nodename, servname, hints, qbuf, &qlen);
if (i != 0) return EAI_SYSTEM;
qlen /= BYTES_PER_XDR_UNIT;
- return lu_async_start(p, gai_proc, qbuf, qlen, (void *)callback, context);
+ status = lu_async_start(p, gai_proc, qbuf, qlen, (void *)callback, context);
+ if (status != 0)
+ {
+ errno = ECONNREFUSED;
+ return EAI_SYSTEM;
+ }
+
+ return 0;
}
int32_t
if (!xdr_int(&xdr, (int32_t *)&n))
{
xdr_destroy(&xdr);
+ errno = EIO;
return EAI_SYSTEM;
}
int32_t i, j, nkeys, nvals, status;
char *key, **vals;
- if ((host == NULL) || (serv == NULL)) return EAI_SYSTEM;
+ if ((host == NULL) || (serv == NULL))
+ {
+ errno = EINVAL;
+ return EAI_SYSTEM;
+ }
- if (!xdr_int(inxdr, &nkeys)) return EAI_SYSTEM;
+ if (!xdr_int(inxdr, &nkeys))
+ {
+ errno = EIO;
+ return EAI_SYSTEM;
+ }
*host = NULL;
*serv = NULL;
nvals = 0;
status = _lu_xdr_attribute(inxdr, &key, &vals, (uint32_t *)&nvals);
- if (status < 0) return EAI_SYSTEM;
+ if (status < 0)
+ {
+ errno = EIO;
+ return EAI_SYSTEM;
+ }
if (nvals == 0)
{
if (!xdr_int(&outxdr, (int32_t *)&na))
{
xdr_destroy(&outxdr);
+ errno = EIO;
return EAI_SYSTEM;
}
if (encode_kv(&outxdr, key, str) != 0)
{
xdr_destroy(&outxdr);
+ errno = EIO;
return EAI_SYSTEM;
}
}
if (encode_kv(&outxdr, "port", str) != 0)
{
xdr_destroy(&outxdr);
+ errno = EIO;
return EAI_SYSTEM;
}
}
if (encode_kv(&outxdr, "protocol", "udp") != 0)
{
xdr_destroy(&outxdr);
+ errno = EIO;
return EAI_SYSTEM;
}
}
if (encode_kv(&outxdr, "fqdn", "0") != 0)
{
xdr_destroy(&outxdr);
+ errno = EIO;
return EAI_SYSTEM;
}
}
if (encode_kv(&outxdr, "numerichost", "1") != 0)
{
xdr_destroy(&outxdr);
+ errno = EIO;
return EAI_SYSTEM;
}
}
if (encode_kv(&outxdr, "numericserv", "1") != 0)
{
xdr_destroy(&outxdr);
+ errno = EIO;
return EAI_SYSTEM;
}
}
if (encode_kv(&outxdr, "name_required", "1") != 0)
{
xdr_destroy(&outxdr);
+ errno = EIO;
return EAI_SYSTEM;
}
}
*/
server_port = MACH_PORT_NULL;
if (_lu_running()) server_port = _lookupd_port(0);
- if (server_port == MACH_PORT_NULL) return EAI_SYSTEM;
+ if (server_port == MACH_PORT_NULL)
+ {
+ errno = ECONNREFUSED;
+ return EAI_SYSTEM;
+ }
if (gni_proc < 0)
{
status = _lookup_link(server_port, "getnameinfo", &gni_proc);
- if (status != KERN_SUCCESS) return EAI_SYSTEM;
+ if (status != KERN_SUCCESS)
+ {
+ errno = ECONNREFUSED;
+ return EAI_SYSTEM;
+ }
}
qlen = LU_QBUF_SIZE;
if (!xdr_int(&inxdr, (int32_t *)&n))
{
xdr_destroy(&inxdr);
+ errno = EIO;
return EAI_SYSTEM;
}
server_port = MACH_PORT_NULL;
if (_lu_running()) server_port = _lookupd_port(0);
- if (server_port == MACH_PORT_NULL) return EAI_SYSTEM;
+ if (server_port == MACH_PORT_NULL)
+ {
+ errno = ECONNREFUSED;
+ return EAI_SYSTEM;
+ }
if (gni_proc < 0)
{
status = _lookup_link(server_port, "getnameinfo", &gni_proc);
- if (status != KERN_SUCCESS) return EAI_SYSTEM;
+ if (status != KERN_SUCCESS)
+ {
+ errno = ECONNREFUSED;
+ return EAI_SYSTEM;
+ }
}
qlen = LU_QBUF_SIZE;
qlen /= BYTES_PER_XDR_UNIT;
- return lu_async_start(p, gni_proc, qbuf, qlen, (void *)callback, context);
+ status = lu_async_start(p, gni_proc, qbuf, qlen, (void *)callback, context);
+ if (status != 0)
+ {
+ errno = ECONNREFUSED;
+ return EAI_SYSTEM;
+ }
+
+ return 0;
}
int32_t
if (!xdr_int(&xdr, (int32_t *)&n))
{
xdr_destroy(&xdr);
+ errno = EIO;
return EAI_SYSTEM;
}
char area_machname[MAX_MACHINE_NAME+1];
int area_gids[NGROUPS];
} *area;
- u_int auth_len;
- int str_len, gid_len;
+ u_int auth_len, str_len, gid_len;
register int i;
area = (struct area *) rqst->rq_clntcred;
stat = AUTH_BADCRED;
goto done;
}
- bcopy((caddr_t)buf, aup->aup_machname, (u_int)str_len);
+ bcopy((caddr_t)buf, aup->aup_machname, str_len);
aup->aup_machname[str_len] = 0;
str_len = RNDUP(str_len);
buf += str_len / sizeof (long);
* timestamp, hostname len (0), uid, gid, and gids len (0).
*/
if ((5 + gid_len) * BYTES_PER_XDR_UNIT + str_len > auth_len) {
- (void) printf("bad auth_len gid %d str %d auth %d\n",
- gid_len, str_len, auth_len);
+ /* LIBRARY CODE SHOULD NOT PRINT
+ (void) printf("bad auth_len gid %d str %d auth %d\n", gid_len, str_len, auth_len);
+ */
stat = AUTH_BADCRED;
goto done;
}