libcasper: provide compatibility with the old version of service

Some external tools like tcpdump(1) have upstream the changes with old limits
name. Because of that provide compatibility with the old names.

Reported by:	emaste
This commit is contained in:
Mariusz Zaborski 2018-11-19 17:22:52 +00:00
parent 541a117532
commit 2863fd2f27
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=340638

View File

@ -474,7 +474,8 @@ dns_gethostbyname(const nvlist_t *limits, const nvlist_t *nvlin,
struct hostent *hp;
int family;
if (!dns_allowed_type(limits, "NAME2ADDR"))
if (!dns_allowed_type(limits, "NAME2ADDR") &&
!dns_allowed_type(limits, "NAME"))
return (NO_RECOVERY);
family = (int)nvlist_get_number(nvlin, "family");
@ -498,7 +499,8 @@ dns_gethostbyaddr(const nvlist_t *limits, const nvlist_t *nvlin,
size_t addrsize;
int family;
if (!dns_allowed_type(limits, "ADDR2NAME"))
if (!dns_allowed_type(limits, "ADDR2NAME") &&
!dns_allowed_type(limits, "ADDR"))
return (NO_RECOVERY);
family = (int)nvlist_get_number(nvlin, "family");
@ -524,7 +526,8 @@ dns_getnameinfo(const nvlist_t *limits, const nvlist_t *nvlin, nvlist_t *nvlout)
socklen_t salen;
int error, flags;
if (!dns_allowed_type(limits, "ADDR2NAME"))
if (!dns_allowed_type(limits, "ADDR2NAME") &&
!dns_allowed_type(limits, "ADDR"))
return (NO_RECOVERY);
error = 0;
@ -617,7 +620,8 @@ dns_getaddrinfo(const nvlist_t *limits, const nvlist_t *nvlin, nvlist_t *nvlout)
unsigned int ii;
int error, family, n;
if (!dns_allowed_type(limits, "NAME2ADDR"))
if (!dns_allowed_type(limits, "NAME2ADDR") &&
!dns_allowed_type(limits, "NAME"))
return (NO_RECOVERY);
hostname = dnvlist_get_string(nvlin, "hostname", NULL);
@ -703,7 +707,9 @@ dns_limit(const nvlist_t *oldlimits, const nvlist_t *newlimits)
return (EINVAL);
type = nvlist_get_string(newlimits, name);
if (strcmp(type, "ADDR2NAME") != 0 &&
strcmp(type, "NAME2ADDR") != 0) {
strcmp(type, "NAME2ADDR") != 0 &&
strcmp(type, "ADDR") != 0 &&
strcmp(type, "NAME") != 0) {
return (EINVAL);
}
if (!dns_allowed_type(oldlimits, type))