Path: blob/main/lib/libcasper/services/cap_dns/tests/dns_test.c
48383 views
/*-1* SPDX-License-Identifier: BSD-2-Clause2*3* Copyright (c) 2013 The FreeBSD Foundation4*5* This software was developed by Pawel Jakub Dawidek under sponsorship from6* the FreeBSD Foundation.7*8* Redistribution and use in source and binary forms, with or without9* modification, are permitted provided that the following conditions10* are met:11* 1. Redistributions of source code must retain the above copyright12* notice, this list of conditions and the following disclaimer.13* 2. Redistributions in binary form must reproduce the above copyright14* notice, this list of conditions and the following disclaimer in the15* documentation and/or other materials provided with the distribution.16*17* THIS SOFTWARE IS PROVIDED BY THE AUTHORS AND CONTRIBUTORS ``AS IS'' AND18* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE19* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE20* ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS OR CONTRIBUTORS BE LIABLE21* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL22* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS23* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)24* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT25* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY26* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF27* SUCH DAMAGE.28*/2930#include <sys/capsicum.h>31#include <sys/nv.h>3233#include <arpa/inet.h>34#include <netinet/in.h>3536#include <assert.h>37#include <err.h>38#include <errno.h>39#include <netdb.h>40#include <stdio.h>41#include <stdlib.h>42#include <string.h>43#include <unistd.h>4445#include <libcasper.h>46#include <casper/cap_dns.h>4748#include <atf-c.h>4950#define GETHOSTBYNAME 0x0151#define GETHOSTBYNAME2_AF_INET 0x0252#define GETHOSTBYNAME2_AF_INET6 0x0453#define GETHOSTBYADDR_AF_INET 0x0854#define GETHOSTBYADDR_AF_INET6 0x1055#define GETADDRINFO_AF_UNSPEC 0x2056#define GETADDRINFO_AF_INET 0x4057#define GETADDRINFO_AF_INET6 0x805859static bool60addrinfo_compare(struct addrinfo *ai0, struct addrinfo *ai1)61{62struct addrinfo *at0, *at1;6364if (ai0 == NULL && ai1 == NULL)65return (true);66if (ai0 == NULL || ai1 == NULL)67return (false);6869at0 = ai0;70at1 = ai1;71while (true) {72if ((at0->ai_flags == at1->ai_flags) &&73(at0->ai_family == at1->ai_family) &&74(at0->ai_socktype == at1->ai_socktype) &&75(at0->ai_protocol == at1->ai_protocol) &&76(at0->ai_addrlen == at1->ai_addrlen) &&77(memcmp(at0->ai_addr, at1->ai_addr,78at0->ai_addrlen) == 0)) {79if (at0->ai_canonname != NULL &&80at1->ai_canonname != NULL) {81if (strcmp(at0->ai_canonname,82at1->ai_canonname) != 0) {83return (false);84}85}8687if (at0->ai_canonname == NULL &&88at1->ai_canonname != NULL) {89return (false);90}91if (at0->ai_canonname != NULL &&92at1->ai_canonname == NULL) {93return (false);94}9596if (at0->ai_next == NULL && at1->ai_next == NULL)97return (true);98if (at0->ai_next == NULL || at1->ai_next == NULL)99return (false);100101at0 = at0->ai_next;102at1 = at1->ai_next;103} else {104return (false);105}106}107108/* NOTREACHED */109fprintf(stderr, "Dead code reached in addrinfo_compare()\n");110exit(1);111}112113static bool114hostent_aliases_compare(char **aliases0, char **aliases1)115{116int i0, i1;117118if (aliases0 == NULL && aliases1 == NULL)119return (true);120if (aliases0 == NULL || aliases1 == NULL)121return (false);122123for (i0 = 0; aliases0[i0] != NULL; i0++) {124for (i1 = 0; aliases1[i1] != NULL; i1++) {125if (strcmp(aliases0[i0], aliases1[i1]) == 0)126break;127}128if (aliases1[i1] == NULL)129return (false);130}131132return (true);133}134135static bool136hostent_addr_list_compare(char **addr_list0, char **addr_list1, int length)137{138int i0, i1;139140if (addr_list0 == NULL && addr_list1 == NULL)141return (true);142if (addr_list0 == NULL || addr_list1 == NULL)143return (false);144145for (i0 = 0; addr_list0[i0] != NULL; i0++) {146for (i1 = 0; addr_list1[i1] != NULL; i1++) {147if (memcmp(addr_list0[i0], addr_list1[i1], length) == 0)148break;149}150if (addr_list1[i1] == NULL)151return (false);152}153154return (true);155}156157static bool158hostent_compare(const struct hostent *hp0, const struct hostent *hp1)159{160161if (hp0 == NULL && hp1 != NULL)162return (true);163164if (hp0 == NULL || hp1 == NULL)165return (false);166167if (hp0->h_name != NULL || hp1->h_name != NULL) {168if (hp0->h_name == NULL || hp1->h_name == NULL)169return (false);170if (strcmp(hp0->h_name, hp1->h_name) != 0)171return (false);172}173174if (!hostent_aliases_compare(hp0->h_aliases, hp1->h_aliases))175return (false);176if (!hostent_aliases_compare(hp1->h_aliases, hp0->h_aliases))177return (false);178179if (hp0->h_addrtype != hp1->h_addrtype)180return (false);181182if (hp0->h_length != hp1->h_length)183return (false);184185if (!hostent_addr_list_compare(hp0->h_addr_list, hp1->h_addr_list,186hp0->h_length)) {187return (false);188}189if (!hostent_addr_list_compare(hp1->h_addr_list, hp0->h_addr_list,190hp0->h_length)) {191return (false);192}193194return (true);195}196197static void198runtest(cap_channel_t *capdns, unsigned int expected)199{200unsigned int result;201struct addrinfo *ais, *aic, hints, *hintsp;202struct hostent *hps, *hpc;203struct in_addr ip4;204struct in6_addr ip6;205int caperr, syserr;206207result = 0;208209hps = gethostbyname("example.com");210if (hps == NULL) {211fprintf(stderr, "Unable to resolve %s IPv4.\n", "example.com");212} else {213hpc = cap_gethostbyname(capdns, "example.com");214if (hostent_compare(hps, hpc))215result |= GETHOSTBYNAME;216}217218hps = gethostbyname2("example.com", AF_INET);219if (hps == NULL) {220fprintf(stderr, "Unable to resolve %s IPv4.\n", "example.com");221} else {222hpc = cap_gethostbyname2(capdns, "example.com", AF_INET);223if (hostent_compare(hps, hpc))224result |= GETHOSTBYNAME2_AF_INET;225}226227hps = gethostbyname2("example.com", AF_INET6);228if (hps == NULL) {229fprintf(stderr, "Unable to resolve %s IPv6.\n", "example.com");230} else {231hpc = cap_gethostbyname2(capdns, "example.com", AF_INET6);232if (hostent_compare(hps, hpc))233result |= GETHOSTBYNAME2_AF_INET6;234}235236hints.ai_flags = 0;237hints.ai_family = AF_UNSPEC;238hints.ai_socktype = 0;239hints.ai_protocol = 0;240hints.ai_addrlen = 0;241hints.ai_addr = NULL;242hints.ai_canonname = NULL;243hints.ai_next = NULL;244245hintsp = &hints;246247syserr = getaddrinfo("freebsd.org", "25", hintsp, &ais);248if (syserr != 0) {249fprintf(stderr,250"Unable to issue [system] getaddrinfo() for AF_UNSPEC: %s\n",251gai_strerror(syserr));252} else {253caperr = cap_getaddrinfo(capdns, "freebsd.org", "25", hintsp,254&aic);255if (caperr == 0) {256if (addrinfo_compare(ais, aic))257result |= GETADDRINFO_AF_UNSPEC;258freeaddrinfo(ais);259freeaddrinfo(aic);260}261}262263hints.ai_family = AF_INET;264syserr = getaddrinfo("freebsd.org", "25", hintsp, &ais);265if (syserr != 0) {266fprintf(stderr,267"Unable to issue [system] getaddrinfo() for AF_UNSPEC: %s\n",268gai_strerror(syserr));269} else {270caperr = cap_getaddrinfo(capdns, "freebsd.org", "25", hintsp,271&aic);272if (caperr == 0) {273if (addrinfo_compare(ais, aic))274result |= GETADDRINFO_AF_INET;275freeaddrinfo(ais);276freeaddrinfo(aic);277}278}279280hints.ai_family = AF_INET6;281syserr = getaddrinfo("freebsd.org", "25", hintsp, &ais);282if (syserr != 0) {283fprintf(stderr,284"Unable to issue [system] getaddrinfo() for AF_UNSPEC: %s\n",285gai_strerror(syserr));286} else {287caperr = cap_getaddrinfo(capdns, "freebsd.org", "25", hintsp,288&aic);289if (caperr == 0) {290if (addrinfo_compare(ais, aic))291result |= GETADDRINFO_AF_INET6;292freeaddrinfo(ais);293freeaddrinfo(aic);294}295}296297/* XXX: hardcoded addresses for "google-public-dns-a.google.com". */298#define GOOGLE_DNS_IPV4 "8.8.8.8"299#define GOOGLE_DNS_IPV6 "2001:4860:4860::8888"300301inet_pton(AF_INET, GOOGLE_DNS_IPV4, &ip4);302hps = gethostbyaddr(&ip4, sizeof(ip4), AF_INET);303if (hps == NULL) {304fprintf(stderr, "Unable to resolve %s.\n", GOOGLE_DNS_IPV4);305} else {306hpc = cap_gethostbyaddr(capdns, &ip4, sizeof(ip4), AF_INET);307if (hostent_compare(hps, hpc))308result |= GETHOSTBYADDR_AF_INET;309}310311inet_pton(AF_INET6, GOOGLE_DNS_IPV6, &ip6);312hps = gethostbyaddr(&ip6, sizeof(ip6), AF_INET6);313if (hps == NULL) {314fprintf(stderr, "Unable to resolve %s.\n", GOOGLE_DNS_IPV6);315} else {316hpc = cap_gethostbyaddr(capdns, &ip6, sizeof(ip6), AF_INET6);317if (hostent_compare(hps, hpc)) {318caperr = h_errno;319result |= GETHOSTBYADDR_AF_INET6;320}321}322323ATF_REQUIRE_MSG(result == expected,324"expected 0x%x, got 0x%x", expected, result);325}326327static cap_channel_t *328cap_dns_init(void)329{330cap_channel_t *capcas, *capdns;331332capcas = cap_init();333ATF_REQUIRE(capcas != NULL);334335capdns = cap_service_open(capcas, "system.dns");336ATF_REQUIRE(capdns != NULL);337338cap_close(capcas);339340return (capdns);341}342343ATF_TC(dns_no_limits);344ATF_TC_HEAD(dns_no_limits, tc)345{346atf_tc_set_md_var(tc, "require.config", "allow_network_access");347}348ATF_TC_BODY(dns_no_limits, tc)349{350cap_channel_t *capdns;351352capdns = cap_dns_init();353354runtest(capdns,355(GETHOSTBYNAME | GETHOSTBYNAME2_AF_INET | GETHOSTBYNAME2_AF_INET6 |356GETHOSTBYADDR_AF_INET | GETHOSTBYADDR_AF_INET6 |357GETADDRINFO_AF_UNSPEC | GETADDRINFO_AF_INET |358GETADDRINFO_AF_INET6));359360cap_close(capdns);361}362363ATF_TC(dns_all_limits);364ATF_TC_HEAD(dns_all_limits, tc)365{366atf_tc_set_md_var(tc, "require.config", "allow_network_access");367}368ATF_TC_BODY(dns_all_limits, tc)369{370cap_channel_t *capdns;371const char *types[2];372int families[2];373374capdns = cap_dns_init();375376types[0] = "NAME2ADDR";377types[1] = "ADDR2NAME";378ATF_REQUIRE(cap_dns_type_limit(capdns, types, 2) == 0);379families[0] = AF_INET;380families[1] = AF_INET6;381ATF_REQUIRE(cap_dns_family_limit(capdns, families, 2) == 0);382ATF_REQUIRE_ERRNO(ENOTCAPABLE,383cap_dns_family_limit(capdns, NULL, 0) == -1);384ATF_REQUIRE_ERRNO(ENOTCAPABLE,385cap_dns_type_limit(capdns, NULL, 0) == -1);386387runtest(capdns,388(GETHOSTBYNAME | GETHOSTBYNAME2_AF_INET | GETHOSTBYNAME2_AF_INET6 |389GETHOSTBYADDR_AF_INET | GETHOSTBYADDR_AF_INET6 |390GETADDRINFO_AF_INET | GETADDRINFO_AF_INET6));391392cap_close(capdns);393}394395ATF_TC(dns_name_limit);396ATF_TC_HEAD(dns_name_limit, tc)397{398atf_tc_set_md_var(tc, "require.config", "allow_network_access");399}400ATF_TC_BODY(dns_name_limit, tc)401{402cap_channel_t *capdns;403const char *types[2];404int families[2];405406capdns = cap_dns_init();407408types[0] = "NAME2ADDR";409ATF_REQUIRE(cap_dns_type_limit(capdns, types, 1) == 0);410types[1] = "ADDR2NAME";411ATF_REQUIRE_ERRNO(ENOTCAPABLE,412cap_dns_type_limit(capdns, types, 2) == -1);413types[0] = "ADDR2NAME";414ATF_REQUIRE_ERRNO(ENOTCAPABLE,415cap_dns_type_limit(capdns, types, 1) == -1);416families[0] = AF_INET;417families[1] = AF_INET6;418ATF_REQUIRE(cap_dns_family_limit(capdns, families, 2) == 0);419420runtest(capdns,421(GETHOSTBYNAME | GETHOSTBYNAME2_AF_INET | GETHOSTBYNAME2_AF_INET6 |422GETADDRINFO_AF_INET | GETADDRINFO_AF_INET6));423424cap_close(capdns);425}426427ATF_TC(dns_addr_limit);428ATF_TC_HEAD(dns_addr_limit, tc)429{430atf_tc_set_md_var(tc, "require.config", "allow_network_access");431}432ATF_TC_BODY(dns_addr_limit, tc)433{434cap_channel_t *capdns;435const char *types[2];436int families[2];437438capdns = cap_dns_init();439440types[0] = "ADDR2NAME";441ATF_REQUIRE(cap_dns_type_limit(capdns, types, 1) == 0);442types[1] = "NAME2ADDR";443ATF_REQUIRE_ERRNO(ENOTCAPABLE,444cap_dns_type_limit(capdns, types, 2) == -1);445types[0] = "NAME2ADDR";446ATF_REQUIRE_ERRNO(ENOTCAPABLE,447cap_dns_type_limit(capdns, types, 1) == -1);448families[0] = AF_INET;449families[1] = AF_INET6;450ATF_REQUIRE(cap_dns_family_limit(capdns, families, 2) == 0);451452runtest(capdns,453(GETHOSTBYADDR_AF_INET | GETHOSTBYADDR_AF_INET6));454455cap_close(capdns);456}457458ATF_TC(dns_inet_limit);459ATF_TC_HEAD(dns_inet_limit, tc)460{461atf_tc_set_md_var(tc, "require.config", "allow_network_access");462}463ATF_TC_BODY(dns_inet_limit, tc)464{465cap_channel_t *capdns;466const char *types[2];467int families[2];468469capdns = cap_dns_init();470471types[0] = "NAME2ADDR";472types[1] = "ADDR2NAME";473ATF_REQUIRE(cap_dns_type_limit(capdns, types, 2) == 0);474families[0] = AF_INET;475ATF_REQUIRE(cap_dns_family_limit(capdns, families, 1) == 0);476families[1] = AF_INET6;477ATF_REQUIRE_ERRNO(ENOTCAPABLE,478cap_dns_family_limit(capdns, families, 2) == -1);479families[0] = AF_INET6;480ATF_REQUIRE_ERRNO(ENOTCAPABLE,481cap_dns_family_limit(capdns, families, 1) == -1);482483runtest(capdns,484(GETHOSTBYNAME | GETHOSTBYNAME2_AF_INET | GETHOSTBYADDR_AF_INET |485GETADDRINFO_AF_INET));486487cap_close(capdns);488}489490ATF_TC(dns_inet6_limit);491ATF_TC_HEAD(dns_inet6_limit, tc)492{493atf_tc_set_md_var(tc, "require.config", "allow_network_access");494}495ATF_TC_BODY(dns_inet6_limit, tc)496{497cap_channel_t *capdns;498const char *types[2];499int families[2];500501capdns = cap_dns_init();502503types[0] = "NAME2ADDR";504types[1] = "ADDR2NAME";505ATF_REQUIRE(cap_dns_type_limit(capdns, types, 2) == 0);506families[0] = AF_INET6;507ATF_REQUIRE(cap_dns_family_limit(capdns, families, 1) == 0);508families[1] = AF_INET;509ATF_REQUIRE_ERRNO(ENOTCAPABLE,510cap_dns_family_limit(capdns, families, 2) == -1);511families[0] = AF_INET;512ATF_REQUIRE_ERRNO(ENOTCAPABLE,513cap_dns_family_limit(capdns, families, 1) == -1);514515runtest(capdns,516(GETHOSTBYNAME2_AF_INET6 | GETHOSTBYADDR_AF_INET6 |517GETADDRINFO_AF_INET6));518519cap_close(capdns);520}521522ATF_TC(dns_name_inet_limit);523ATF_TC_HEAD(dns_name_inet_limit, tc)524{525atf_tc_set_md_var(tc, "require.config", "allow_network_access");526}527ATF_TC_BODY(dns_name_inet_limit, tc)528{529cap_channel_t *capdns;530const char *types[2];531int families[2];532533capdns = cap_dns_init();534535types[0] = "NAME2ADDR";536types[1] = "ADDR2NAME";537ATF_REQUIRE(cap_dns_type_limit(capdns, types, 2) == 0);538families[0] = AF_INET;539families[1] = AF_INET6;540ATF_REQUIRE(cap_dns_family_limit(capdns, families, 2) == 0);541types[0] = "NAME2ADDR";542ATF_REQUIRE(cap_dns_type_limit(capdns, types, 1) == 0);543types[1] = "ADDR2NAME";544ATF_REQUIRE_ERRNO(ENOTCAPABLE,545cap_dns_type_limit(capdns, types, 2) == -1);546types[0] = "ADDR2NAME";547ATF_REQUIRE_ERRNO(ENOTCAPABLE,548cap_dns_type_limit(capdns, types, 1) == -1);549families[0] = AF_INET;550ATF_REQUIRE(cap_dns_family_limit(capdns, families, 1) == 0);551families[1] = AF_INET6;552ATF_REQUIRE_ERRNO(ENOTCAPABLE,553cap_dns_family_limit(capdns, families, 2) == -1);554families[0] = AF_INET6;555ATF_REQUIRE_ERRNO(ENOTCAPABLE,556cap_dns_family_limit(capdns, families, 1) == -1);557558runtest(capdns,559(GETHOSTBYNAME | GETHOSTBYNAME2_AF_INET | GETADDRINFO_AF_INET));560561cap_close(capdns);562}563564ATF_TC(dns_name_inet6_limit);565ATF_TC_HEAD(dns_name_inet6_limit, tc)566{567atf_tc_set_md_var(tc, "require.config", "allow_network_access");568}569ATF_TC_BODY(dns_name_inet6_limit, tc)570{571cap_channel_t *capdns;572const char *types[2];573int families[2];574575capdns = cap_dns_init();576577types[0] = "NAME2ADDR";578types[1] = "ADDR2NAME";579ATF_REQUIRE(cap_dns_type_limit(capdns, types, 2) == 0);580families[0] = AF_INET6;581families[1] = AF_INET;582ATF_REQUIRE(cap_dns_family_limit(capdns, families, 2) == 0);583types[0] = "NAME2ADDR";584ATF_REQUIRE(cap_dns_type_limit(capdns, types, 1) == 0);585types[1] = "ADDR2NAME";586ATF_REQUIRE_ERRNO(ENOTCAPABLE,587cap_dns_type_limit(capdns, types, 2) == -1);588types[0] = "ADDR2NAME";589ATF_REQUIRE_ERRNO(ENOTCAPABLE,590cap_dns_type_limit(capdns, types, 1) == -1);591families[0] = AF_INET6;592ATF_REQUIRE(cap_dns_family_limit(capdns, families, 1) == 0);593families[1] = AF_INET;594ATF_REQUIRE_ERRNO(ENOTCAPABLE,595cap_dns_family_limit(capdns, families, 2) == -1);596families[0] = AF_INET;597ATF_REQUIRE_ERRNO(ENOTCAPABLE,598cap_dns_family_limit(capdns, families, 1) == -1);599600runtest(capdns,601(GETHOSTBYNAME2_AF_INET6 | GETADDRINFO_AF_INET6));602603cap_close(capdns);604}605606ATF_TC(dns_addr_inet_limit);607ATF_TC_HEAD(dns_addr_inet_limit, tc)608{609atf_tc_set_md_var(tc, "require.config", "allow_network_access");610}611ATF_TC_BODY(dns_addr_inet_limit, tc)612{613cap_channel_t *capdns;614const char *types[2];615int families[2];616617capdns = cap_dns_init();618619types[0] = "NAME2ADDR";620types[1] = "ADDR2NAME";621ATF_REQUIRE(cap_dns_type_limit(capdns, types, 2) == 0);622families[0] = AF_INET;623families[1] = AF_INET6;624ATF_REQUIRE(cap_dns_family_limit(capdns, families, 2) == 0);625types[0] = "ADDR2NAME";626ATF_REQUIRE(cap_dns_type_limit(capdns, types, 1) == 0);627types[1] = "NAME2ADDR";628ATF_REQUIRE_ERRNO(ENOTCAPABLE,629cap_dns_type_limit(capdns, types, 2) == -1);630types[0] = "NAME2ADDR";631ATF_REQUIRE_ERRNO(ENOTCAPABLE,632cap_dns_type_limit(capdns, types, 1) == -1);633families[0] = AF_INET;634ATF_REQUIRE(cap_dns_family_limit(capdns, families, 1) == 0);635families[1] = AF_INET6;636ATF_REQUIRE_ERRNO(ENOTCAPABLE,637cap_dns_family_limit(capdns, families, 2) == -1);638families[0] = AF_INET6;639ATF_REQUIRE_ERRNO(ENOTCAPABLE,640cap_dns_family_limit(capdns, families, 1) == -1);641642runtest(capdns, GETHOSTBYADDR_AF_INET);643644cap_close(capdns);645}646647ATF_TC(dns_addr_inet6_limit);648ATF_TC_HEAD(dns_addr_inet6_limit, tc)649{650atf_tc_set_md_var(tc, "require.config", "allow_network_access");651}652ATF_TC_BODY(dns_addr_inet6_limit, tc)653{654cap_channel_t *capdns;655const char *types[2];656int families[2];657658capdns = cap_dns_init();659660types[0] = "NAME2ADDR";661types[1] = "ADDR2NAME";662ATF_REQUIRE(cap_dns_type_limit(capdns, types, 2) == 0);663families[0] = AF_INET6;664families[1] = AF_INET;665ATF_REQUIRE(cap_dns_family_limit(capdns, families, 2) == 0);666types[0] = "ADDR2NAME";667ATF_REQUIRE(cap_dns_type_limit(capdns, types, 1) == 0);668types[1] = "NAME2ADDR";669ATF_REQUIRE_ERRNO(ENOTCAPABLE,670cap_dns_type_limit(capdns, types, 2) == -1);671types[0] = "NAME2ADDR";672ATF_REQUIRE_ERRNO(ENOTCAPABLE,673cap_dns_type_limit(capdns, types, 1) == -1);674families[0] = AF_INET6;675ATF_REQUIRE(cap_dns_family_limit(capdns, families, 1) == 0);676families[1] = AF_INET;677ATF_REQUIRE_ERRNO(ENOTCAPABLE,678cap_dns_family_limit(capdns, families, 2) == -1);679families[0] = AF_INET;680ATF_REQUIRE_ERRNO(ENOTCAPABLE,681cap_dns_family_limit(capdns, families, 1) == -1);682683runtest(capdns, GETHOSTBYADDR_AF_INET6);684685cap_close(capdns);686}687688ATF_TP_ADD_TCS(tp)689{690ATF_TP_ADD_TC(tp, dns_no_limits);691ATF_TP_ADD_TC(tp, dns_all_limits);692ATF_TP_ADD_TC(tp, dns_name_limit);693ATF_TP_ADD_TC(tp, dns_addr_limit);694ATF_TP_ADD_TC(tp, dns_inet_limit);695ATF_TP_ADD_TC(tp, dns_inet6_limit);696ATF_TP_ADD_TC(tp, dns_name_inet_limit);697ATF_TP_ADD_TC(tp, dns_name_inet6_limit);698ATF_TP_ADD_TC(tp, dns_addr_inet_limit);699ATF_TP_ADD_TC(tp, dns_addr_inet6_limit);700701return atf_no_error();702}703704705