summaryrefslogtreecommitdiff
path: root/lib/libc
diff options
context:
space:
mode:
authorTheo de Raadt <deraadt@cvs.openbsd.org>2015-11-23 18:04:55 +0000
committerTheo de Raadt <deraadt@cvs.openbsd.org>2015-11-23 18:04:55 +0000
commitdc36475f1d7a03255d0416ac2fcc037984502251 (patch)
tree97c0cea5e2af36d478528d6bc0319ee39f3f2bf7 /lib/libc
parent98f409d43d51c9a8dcbd824a5b12089c25bab158 (diff)
Remove support for "lookup yp" in /etc/resolv.conf. This historical
wart is incompatible with pledge, because suddenly a "dns" operation needs "getpw" access to ypbind/ypserv, etc. file + dns access is enough for everyone, sorry if you were using that old SunOS 4.x style mechanism, but it is now gone. ok semarie millert florian
Diffstat (limited to 'lib/libc')
-rw-r--r--lib/libc/asr/asr.c8
-rw-r--r--lib/libc/asr/asr_private.h3
-rw-r--r--lib/libc/asr/getaddrinfo_async.c102
-rw-r--r--lib/libc/asr/gethostnamadr_async.c133
4 files changed, 7 insertions, 239 deletions
diff --git a/lib/libc/asr/asr.c b/lib/libc/asr/asr.c
index f683ff73e8e..589243833a0 100644
--- a/lib/libc/asr/asr.c
+++ b/lib/libc/asr/asr.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: asr.c,v 1.48 2015/10/28 21:38:45 eric Exp $ */
+/* $OpenBSD: asr.c,v 1.49 2015/11/23 18:04:53 deraadt Exp $ */
/*
* Copyright (c) 2010-2012 Eric Faurot <eric@openbsd.org>
*
@@ -560,9 +560,9 @@ pass0(char **tok, int n, struct asr_ctx *ac)
return;
ac->ac_dbcount = 0;
for (i = 1; i < n && ac->ac_dbcount < ASR_MAXDB; i++) {
- if (!strcmp(tok[i], "yp"))
- ac->ac_db[ac->ac_dbcount++] = ASR_DB_YP;
- else if (!strcmp(tok[i], "bind"))
+ if (!strcmp(tok[i], "yp")) {
+ /* silently deprecated */
+ } else if (!strcmp(tok[i], "bind"))
ac->ac_db[ac->ac_dbcount++] = ASR_DB_DNS;
else if (!strcmp(tok[i], "file"))
ac->ac_db[ac->ac_dbcount++] = ASR_DB_FILE;
diff --git a/lib/libc/asr/asr_private.h b/lib/libc/asr/asr_private.h
index f4a357afdf5..0504c8c9e0f 100644
--- a/lib/libc/asr/asr_private.h
+++ b/lib/libc/asr/asr_private.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: asr_private.h,v 1.36 2015/10/28 21:38:45 eric Exp $ */
+/* $OpenBSD: asr_private.h,v 1.37 2015/11/23 18:04:54 deraadt Exp $ */
/*
* Copyright (c) 2012 Eric Faurot <eric@openbsd.org>
*
@@ -119,7 +119,6 @@ enum async_type {
#define ASR_DB_FILE 'f'
#define ASR_DB_DNS 'b'
-#define ASR_DB_YP 'y'
struct asr_ctx {
int ac_refcount;
diff --git a/lib/libc/asr/getaddrinfo_async.c b/lib/libc/asr/getaddrinfo_async.c
index 11e180bfb01..64d3aaf4836 100644
--- a/lib/libc/asr/getaddrinfo_async.c
+++ b/lib/libc/asr/getaddrinfo_async.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: getaddrinfo_async.c,v 1.48 2015/10/08 14:08:44 eric Exp $ */
+/* $OpenBSD: getaddrinfo_async.c,v 1.49 2015/11/23 18:04:54 deraadt Exp $ */
/*
* Copyright (c) 2012 Eric Faurot <eric@openbsd.org>
*
@@ -32,13 +32,6 @@
#include <unistd.h>
#include <limits.h>
-#ifdef YP
-#include <rpc/rpc.h>
-#include <rpcsvc/yp.h>
-#include <rpcsvc/ypclnt.h>
-#include "ypinternal.h"
-#endif
-
#include "asr_private.h"
struct match {
@@ -54,9 +47,6 @@ static int addrinfo_add(struct asr_query *, const struct sockaddr *, const char
static int addrinfo_from_file(struct asr_query *, int, FILE *);
static int addrinfo_from_pkt(struct asr_query *, char *, size_t);
static int addrconfig_setup(struct asr_query *);
-#ifdef YP
-static int addrinfo_from_yp(struct asr_query *, int, char *);
-#endif
static const struct match matches[] = {
{ PF_INET, SOCK_DGRAM, IPPROTO_UDP },
@@ -125,12 +115,6 @@ DEF_WEAK(getaddrinfo_async);
static int
getaddrinfo_async_run(struct asr_query *as, struct asr_result *ar)
{
-#ifdef YP
- static char *domain = NULL;
- char *res;
- int len;
- char *name;
-#endif
char fqdn[MAXDNAME];
const char *str;
struct addrinfo *ai;
@@ -418,38 +402,6 @@ getaddrinfo_async_run(struct asr_query *as, struct asr_result *ar)
fclose(f);
break;
-#ifdef YP
- case ASR_DB_YP:
- if (!domain && _yp_check(&domain) == 0) {
- async_set_state(as, ASR_STATE_NEXT_DB);
- break;
- }
- family = (as->as.ai.hints.ai_family == AF_UNSPEC) ?
- AS_FAMILY(as) : as->as.ai.hints.ai_family;
-
- name = as->as.ai.hostname;
-
- /* XXX
- * ipnodes.byname could also contain IPv4 address
- */
- r = yp_match(domain, (family == AF_INET6) ?
- "ipnodes.byname" : "hosts.byname",
- name, strlen(name), &res, &len);
- if (r == 0) {
- r = addrinfo_from_yp(as, family, res);
- free(res);
- if (r == -1) {
- if (errno == ENOMEM)
- ar->ar_gai_errno = EAI_MEMORY;
- else
- ar->ar_gai_errno = EAI_FAIL;
- async_set_state(as, ASR_STATE_HALT);
- break;
- }
- }
- async_set_state(as, ASR_STATE_NEXT_FAMILY);
- break;
-#endif
default:
async_set_state(as, ASR_STATE_NEXT_DB);
}
@@ -766,55 +718,3 @@ addrconfig_setup(struct asr_query *as)
return (0);
}
-
-#ifdef YP
-static int
-strsplit(char *line, char **tokens, int ntokens)
-{
- int ntok;
- char *cp, **tp;
-
- for (cp = line, tp = tokens, ntok = 0;
- ntok < ntokens && (*tp = strsep(&cp, " \t")) != NULL; )
- if (**tp != '\0') {
- tp++;
- ntok++;
- }
-
- return (ntok);
-}
-
-static int
-addrinfo_from_yp(struct asr_query *as, int family, char *line)
-{
- char *next, *tokens[MAXTOKEN], *c;
- int ntok;
- union {
- struct sockaddr sa;
- struct sockaddr_in sain;
- struct sockaddr_in6 sain6;
- } u;
-
- for (next = line; line; line = next) {
- if ((next = strchr(line, '\n'))) {
- *next = '\0';
- next += 1;
- }
- ntok = strsplit(line, tokens, MAXTOKEN);
- if (ntok < 2)
- continue;
-
- if (_asr_sockaddr_from_str(&u.sa, family, tokens[0]) == -1)
- continue;
-
- if (as->as.ai.hints.ai_flags & (AI_CANONNAME | AI_FQDN))
- c = tokens[1];
- else
- c = NULL;
-
- if (addrinfo_add(as, &u.sa, c))
- return (-1); /* errno set */
- }
- return (0);
-}
-#endif
diff --git a/lib/libc/asr/gethostnamadr_async.c b/lib/libc/asr/gethostnamadr_async.c
index 8bff0a0675a..856d294cb3b 100644
--- a/lib/libc/asr/gethostnamadr_async.c
+++ b/lib/libc/asr/gethostnamadr_async.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: gethostnamadr_async.c,v 1.40 2015/09/20 14:19:21 eric Exp $ */
+/* $OpenBSD: gethostnamadr_async.c,v 1.41 2015/11/23 18:04:54 deraadt Exp $ */
/*
* Copyright (c) 2012 Eric Faurot <eric@openbsd.org>
*
@@ -31,13 +31,6 @@
#include <unistd.h>
#include <limits.h>
-#ifdef YP
-#include <rpc/rpc.h>
-#include <rpcsvc/yp.h>
-#include <rpcsvc/ypclnt.h>
-#include "ypinternal.h"
-#endif
-
#include "asr_private.h"
#define MAXALIASES 35
@@ -60,10 +53,6 @@ static struct hostent_ext *hostent_from_addr(int, const char *, const char *);
static struct hostent_ext *hostent_file_match(FILE *, int, int, const char *,
int);
static struct hostent_ext *hostent_from_packet(int, int, char *, size_t);
-#ifdef YP
-static struct hostent_ext *_yp_gethostnamadr(int, const void *);
-static struct hostent_ext *hostent_from_yp(int, char *);
-#endif
struct asr_query *
gethostbyname_async(const char *name, void *asr)
@@ -283,34 +272,6 @@ gethostnamadr_async_run(struct asr_query *as, struct asr_result *ar)
ar->ar_h_errno = NETDB_SUCCESS;
async_set_state(as, ASR_STATE_HALT);
break;
-#ifdef YP
- case ASR_DB_YP:
- /* IPv4 only */
- if (as->as.hostnamadr.family != AF_INET)
- break;
- if (as->as_type == ASR_GETHOSTBYNAME) {
- data = _asr_hostalias(as->as_ctx,
- as->as.hostnamadr.name, name, sizeof(name));
- if (data == NULL)
- data = as->as.hostnamadr.name;
- }
- else
- data = as->as.hostnamadr.addr;
- h = _yp_gethostnamadr(as->as_type, data);
- if (h == NULL) {
- if (errno) {
- ar->ar_errno = errno;
- ar->ar_h_errno = NETDB_INTERNAL;
- async_set_state(as, ASR_STATE_HALT);
- }
- /* otherwise not found */
- break;
- }
- ar->ar_hostent = &h->h;
- ar->ar_h_errno = NETDB_SUCCESS;
- async_set_state(as, ASR_STATE_HALT);
- break;
-#endif
}
break;
@@ -650,95 +611,3 @@ hostent_add_addr(struct hostent_ext *h, const void *addr, size_t size)
h->pos += size;
return (0);
}
-
-#ifdef YP
-static struct hostent_ext *
-_yp_gethostnamadr(int type, const void *data)
-{
- static char *domain = NULL;
- struct hostent_ext *h = NULL;
- const char *name;
- char buf[HOST_NAME_MAX+1];
- char *res = NULL;
- int r, len;
-
- if (!domain && _yp_check(&domain) == 0) {
- errno = 0; /* ignore yp_bind errors */
- return (NULL);
- }
-
- if (type == ASR_GETHOSTBYNAME) {
- name = data;
- len = strlen(name);
- r = yp_match(domain, "hosts.byname", name, len, &res, &len);
- }
- else {
- if (inet_ntop(AF_INET, data, buf, sizeof buf) == NULL)
- return (NULL);
- len = strlen(buf);
- r = yp_match(domain, "hosts.byaddr", buf, len, &res, &len);
- }
- if (r == 0) {
- h = hostent_from_yp(AF_INET, res);
- } else {
- errno = 0; /* ignore error if not found */
- }
- if (res)
- free(res);
- return (h);
-}
-
-static int
-strsplit(char *line, char **tokens, int ntokens)
-{
- int ntok;
- char *cp, **tp;
-
- for (cp = line, tp = tokens, ntok = 0;
- ntok < ntokens && (*tp = strsep(&cp, " \t")) != NULL; )
- if (**tp != '\0') {
- tp++;
- ntok++;
- }
-
- return (ntok);
-}
-
-static struct hostent_ext *
-hostent_from_yp(int family, char *line)
-{
- struct hostent_ext *h;
- char *next, *tokens[10], addr[IN6ADDRSZ];
- int i, ntok;
-
- if ((h = hostent_alloc(family)) == NULL)
- return (NULL);
-
- for (next = line; line; line = next) {
- if ((next = strchr(line, '\n'))) {
- *next = '\0';
- next += 1;
- }
- ntok = strsplit(line, tokens, 10);
- if (ntok < 2)
- continue;
- if (inet_pton(family, tokens[0], addr) == 1)
- hostent_add_addr(h, addr, family == AF_INET ?
- INADDRSZ : IN6ADDRSZ);
- i = 2;
- if (h->h.h_name == NULL)
- hostent_set_cname(h, tokens[1], 0);
- else if (strcmp(h->h.h_name, tokens[1]))
- i = 1;
- for (; i < ntok; i++)
- hostent_add_alias(h, tokens[i], 0);
- }
-
- if (h->h.h_name == NULL) {
- free(h);
- return (NULL);
- }
-
- return (h);
-}
-#endif