From 95e2ff7d8011d60467e23361cec1239b86b9a504 Mon Sep 17 00:00:00 2001 From: Eric Faurot Date: Sun, 8 Jul 2012 17:01:07 +0000 Subject: implement res_querydomain() required by sendmail --- lib/libc/asr/asr_resolver.c | 31 ++++++++++++++++++++++++++++++- 1 file changed, 30 insertions(+), 1 deletion(-) (limited to 'lib/libc') 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 * @@ -18,6 +18,7 @@ #include #include +#include /* for MAXDNAME */ #include #include #include @@ -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) { -- cgit v1.2.3