summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEric Faurot <eric@cvs.openbsd.org>2012-07-08 17:01:07 +0000
committerEric Faurot <eric@cvs.openbsd.org>2012-07-08 17:01:07 +0000
commit95e2ff7d8011d60467e23361cec1239b86b9a504 (patch)
tree2cbd1a3e3e4847223556b0e9eeecfb46799f9743
parent576ac457378db6a2f9b51202cd8b136d64844f6d (diff)
implement res_querydomain() required by sendmail
-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)
{