summaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authoreric <eric@openbsd.org>2012-07-08 17:01:06 +0000
committereric <eric@openbsd.org>2012-07-08 17:01:06 +0000
commita25ce9b23177e3f87d0195358bb4c53b8f427fc3 (patch)
tree41144966a746cef58dec233d98715ca849c6b2aa /lib
parentimplement -Tman .An (diff)
downloadwireguard-openbsd-a25ce9b23177e3f87d0195358bb4c53b8f427fc3.tar.xz
wireguard-openbsd-a25ce9b23177e3f87d0195358bb4c53b8f427fc3.zip
implement res_querydomain() required by sendmail
Diffstat (limited to 'lib')
-rw-r--r--lib/libc/asr/asr_resolver.c31
1 files changed, 30 insertions, 1 deletions
diff --git a/lib/libc/asr/asr_resolver.c b/lib/libc/asr/asr_resolver.c
index 077b52e0e10..6d49dd31ab1 100644
--- a/lib/libc/asr/asr_resolver.c
+++ b/lib/libc/asr/asr_resolver.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: asr_resolver.c,v 1.2 2012/07/08 13:12:46 eric Exp $ */
+/* $OpenBSD: asr_resolver.c,v 1.3 2012/07/08 17:01:06 eric Exp $ */
/*
* Copyright (c) 2012 Eric Faurot <eric@openbsd.org>
*
@@ -18,6 +18,7 @@
#include <sys/types.h>
#include <netinet/in.h>
+#include <arpa/nameser.h> /* for MAXDNAME */
#include <errno.h>
#include <resolv.h>
#include <string.h>
@@ -111,6 +112,34 @@ res_query(const char *name, int class, int type, u_char *ans, int anslen)
return (ar.ar_datalen);
}
+/* This function is not documented, but used by sendmail. */
+int
+res_querydomain(const char *name,
+ const char *domain,
+ int class,
+ int type,
+ u_char *answer,
+ int anslen)
+{
+ char fqdn[MAXDNAME], ndom[MAXDNAME];
+ size_t n;
+
+ /* we really want domain to end with a dot for now */
+ if (domain && (n = strlen(domain)) == 0 || domain[n - 1 ] != '.') {
+ domain = ndom;
+ strlcpy(ndom, domain, sizeof ndom);
+ strlcat(ndom, ".", sizeof ndom);
+ }
+
+ if (asr_make_fqdn(name, domain, fqdn, sizeof fqdn) == 0) {
+ h_errno = NO_RECOVERY;
+ errno = EINVAL;
+ return (-1);
+ }
+
+ return (res_query(fqdn, class, type, answer, anslen));
+}
+
int
res_search(const char *name, int class, int type, u_char *ans, int anslen)
{