summaryrefslogtreecommitdiffstats
path: root/lib/libc
diff options
context:
space:
mode:
authorderaadt <deraadt@openbsd.org>2015-12-16 16:32:30 +0000
committerderaadt <deraadt@openbsd.org>2015-12-16 16:32:30 +0000
commitc126605face2f870c0ff243ed707ea34b2145d4b (patch)
treefa00a0d86f67abcaccee18781129f4e361c7c5a2 /lib/libc
parentin pledged process, setuid/setgid/sticky bits should be ignored. (diff)
downloadwireguard-openbsd-c126605face2f870c0ff243ed707ea34b2145d4b.tar.xz
wireguard-openbsd-c126605face2f870c0ff243ed707ea34b2145d4b.zip
Remove support for HOSTALIASES from the resolver. This "open and parse
any file indicated by an environment variable" feature inside the resolver is incompatible with what pledge "dns" is trying to be. It is a misguided "feature" added way back in history which almost noone uses, but everyone has to assume the risk from. ok eric florian kettenis
Diffstat (limited to 'lib/libc')
-rw-r--r--lib/libc/asr/asr.c49
-rw-r--r--lib/libc/asr/asr_private.h3
-rw-r--r--lib/libc/asr/getaddrinfo_async.c5
-rw-r--r--lib/libc/asr/gethostnamadr_async.c10
-rw-r--r--lib/libc/asr/res_search_async.c6
-rw-r--r--lib/libc/net/gethostbyname.310
-rw-r--r--lib/libc/net/resolver.311
7 files changed, 13 insertions, 81 deletions
diff --git a/lib/libc/asr/asr.c b/lib/libc/asr/asr.c
index 589243833a0..7095b9200a1 100644
--- a/lib/libc/asr/asr.c
+++ b/lib/libc/asr/asr.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: asr.c,v 1.49 2015/11/23 18:04:53 deraadt Exp $ */
+/* $OpenBSD: asr.c,v 1.50 2015/12/16 16:32:30 deraadt Exp $ */
/*
* Copyright (c) 2010-2012 Eric Faurot <eric@openbsd.org>
*
@@ -36,10 +36,6 @@
#include "asr_private.h"
-#ifndef ASR_OPT_HOSTALIASES
-#define ASR_OPT_HOSTALIASES 1
-#endif
-
#include "thread_private.h"
#define DEFAULT_CONF "lookup file\n"
@@ -839,46 +835,3 @@ _asr_iter_db(struct asr_query *as)
return (0);
}
-
-/*
- * Check if the hostname "name" is a user-defined alias as per hostname(7).
- * If so, copies the result in the buffer "abuf" of size "abufsz" and
- * return "abuf". Otherwise return NULL.
- */
-char *
-_asr_hostalias(struct asr_ctx *ac, const char *name, char *abuf, size_t abufsz)
-{
-#if ASR_OPT_HOSTALIASES
- FILE *fp;
- size_t len;
- char *file, *buf, *tokens[2];
- int ntok;
-
- if (ac->ac_options & RES_NOALIASES ||
- asr_ndots(name) != 0 ||
- issetugid() ||
- (file = getenv("HOSTALIASES")) == NULL ||
- (fp = fopen(file, "re")) == NULL)
- return (NULL);
-
- DPRINT("asr: looking up aliases in \"%s\"\n", file);
-
- while ((buf = fgetln(fp, &len)) != NULL) {
- if (buf[len - 1] == '\n')
- len--;
- buf[len] = '\0';
- if ((ntok = strsplit(buf, tokens, 2)) != 2)
- continue;
- if (!strcasecmp(tokens[0], name)) {
- if (strlcpy(abuf, tokens[1], abufsz) > abufsz)
- continue;
- DPRINT("asr: found alias \"%s\"\n", abuf);
- fclose(fp);
- return (abuf);
- }
- }
-
- fclose(fp);
-#endif
- return (NULL);
-}
diff --git a/lib/libc/asr/asr_private.h b/lib/libc/asr/asr_private.h
index 0504c8c9e0f..76c758f74e2 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.37 2015/11/23 18:04:54 deraadt Exp $ */
+/* $OpenBSD: asr_private.h,v 1.38 2015/12/16 16:32:30 deraadt Exp $ */
/*
* Copyright (c) 2012 Eric Faurot <eric@openbsd.org>
*
@@ -321,7 +321,6 @@ size_t _asr_make_fqdn(const char *, const char *, char *, size_t);
char *_asr_strdname(const char *, char *, size_t);
int _asr_iter_db(struct asr_query *);
int _asr_parse_namedb_line(FILE *, char **, int, char *, size_t);
-char *_asr_hostalias(struct asr_ctx *, const char *, char *, size_t);
/* *_async.c */
struct asr_query *_res_query_async_ctx(const char *, int, int, struct asr_ctx *);
diff --git a/lib/libc/asr/getaddrinfo_async.c b/lib/libc/asr/getaddrinfo_async.c
index 64d3aaf4836..e60d30d3782 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.49 2015/11/23 18:04:54 deraadt Exp $ */
+/* $OpenBSD: getaddrinfo_async.c,v 1.50 2015/12/16 16:32:30 deraadt Exp $ */
/*
* Copyright (c) 2012 Eric Faurot <eric@openbsd.org>
*
@@ -76,7 +76,6 @@ getaddrinfo_async(const char *hostname, const char *servname,
{
struct asr_ctx *ac;
struct asr_query *as;
- char alias[MAXDNAME];
if (hints == NULL || (hints->ai_flags & AI_NUMERICHOST) == 0)
ac = _asr_use_resolver(asr);
@@ -87,8 +86,6 @@ getaddrinfo_async(const char *hostname, const char *servname,
as->as_run = getaddrinfo_async_run;
if (hostname) {
- if (_asr_hostalias(ac, hostname, alias, sizeof(alias)))
- hostname = alias;
if ((as->as.ai.hostname = strdup(hostname)) == NULL)
goto abort; /* errno set */
}
diff --git a/lib/libc/asr/gethostnamadr_async.c b/lib/libc/asr/gethostnamadr_async.c
index 856d294cb3b..a9a7801aab7 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.41 2015/11/23 18:04:54 deraadt Exp $ */
+/* $OpenBSD: gethostnamadr_async.c,v 1.42 2015/12/16 16:32:30 deraadt Exp $ */
/*
* Copyright (c) 2012 Eric Faurot <eric@openbsd.org>
*
@@ -243,12 +243,8 @@ gethostnamadr_async_run(struct asr_query *as, struct asr_result *ar)
if ((f = fopen(_PATH_HOSTS, "re")) == NULL)
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;
- }
+ if (as->as_type == ASR_GETHOSTBYNAME)
+ data = as->as.hostnamadr.name;
else
data = as->as.hostnamadr.addr;
diff --git a/lib/libc/asr/res_search_async.c b/lib/libc/asr/res_search_async.c
index 7cbb423ad76..5a351d636d3 100644
--- a/lib/libc/asr/res_search_async.c
+++ b/lib/libc/asr/res_search_async.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: res_search_async.c,v 1.18 2015/09/20 14:19:21 eric Exp $ */
+/* $OpenBSD: res_search_async.c,v 1.19 2015/12/16 16:32:30 deraadt Exp $ */
/*
* Copyright (c) 2012 Eric Faurot <eric@openbsd.org>
*
@@ -57,14 +57,10 @@ struct asr_query *
_res_search_async_ctx(const char *name, int class, int type, struct asr_ctx *ac)
{
struct asr_query *as;
- char alias[MAXDNAME];
DPRINT("asr: res_search_async_ctx(\"%s\", %i, %i)\n", name, class,
type);
- if (_asr_hostalias(ac, name, alias, sizeof(alias)))
- return _res_query_async_ctx(alias, class, type, ac);
-
if ((as = _asr_async_new(ac, ASR_SEARCH)) == NULL)
goto err; /* errno set */
as->as_run = res_search_async_run;
diff --git a/lib/libc/net/gethostbyname.3 b/lib/libc/net/gethostbyname.3
index 304f3140993..f8c4891c686 100644
--- a/lib/libc/net/gethostbyname.3
+++ b/lib/libc/net/gethostbyname.3
@@ -1,4 +1,4 @@
-.\" $OpenBSD: gethostbyname.3,v 1.27 2014/08/23 07:25:54 jmc Exp $
+.\" $OpenBSD: gethostbyname.3,v 1.28 2015/12/16 16:32:30 deraadt Exp $
.\"
.\" Copyright (c) 1983, 1987, 1991, 1993
.\" The Regents of the University of California. All rights reserved.
@@ -27,7 +27,7 @@
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
.\" SUCH DAMAGE.
.\"
-.Dd $Mdocdate: August 23 2014 $
+.Dd $Mdocdate: December 16 2015 $
.Dt GETHOSTBYNAME 3
.Os
.Sh NAME
@@ -171,12 +171,6 @@ The contents of the error message is the same as that returned by
with argument
.Fa h_errno .
.Sh ENVIRONMENT
-.Bl -tag -width HOSTALIASES
-.It HOSTALIASES
-A file containing local host aliases.
-See
-.Xr hostname 7
-for more information.
.It RES_OPTIONS
A list of options to override the resolver's internal defaults.
See
diff --git a/lib/libc/net/resolver.3 b/lib/libc/net/resolver.3
index 7dae1c7e652..db7400df9b9 100644
--- a/lib/libc/net/resolver.3
+++ b/lib/libc/net/resolver.3
@@ -1,4 +1,4 @@
-.\" $OpenBSD: resolver.3,v 1.31 2015/11/10 23:48:18 jmc Exp $
+.\" $OpenBSD: resolver.3,v 1.32 2015/12/16 16:32:30 deraadt Exp $
.\"
.\" Copyright (c) 1985, 1991, 1993
.\" The Regents of the University of California. All rights reserved.
@@ -27,7 +27,7 @@
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
.\" SUCH DAMAGE.
.\"
-.Dd $Mdocdate: November 10 2015 $
+.Dd $Mdocdate: December 16 2015 $
.Dt RES_INIT 3
.Os
.Sh NAME
@@ -171,12 +171,9 @@ to be equal to the server's address.
Do not check if the query section of the reply packet
is equal to that of the query packet.
.It Dv RES_NOALIASES
-Turn off the
+(In the past, this turned off the legacy
.Ev HOSTALIASES
-feature.
-See
-.Xr hostname 7
-for more information.
+feature).
.It Dv RES_USE_INET6
Enables support for IPv6-only applications.
This causes IPv4 addresses to be returned as an IPv4 mapped address.