Radish alpha
H
rad:z3QDZAW2FAfuLvihrhiyDC9fAD8G9
HardenedBSD Package Manager
Radicle
Git
Fix setting nameservers
Baptiste Daroussin committed 9 years ago
commit 6822849253c3f6e8f4eb90ad55c1c9eae86a8e69
parent a3a2a28
4 files changed +22 -8
modified configure.ac
@@ -164,7 +164,7 @@ AC_CHECK_FUNCS_ONCE([strnstr])
AC_CHECK_FUNCS_ONCE([funopen])
AC_CHECK_FUNCS_ONCE([fopencookie])
AC_CHECK_FUNCS_ONCE([sysctlbyname])
-
AC_CHECK_FUNCS_ONCE([res_setservers])
+
AC_CHECK_FUNCS_ONCE([__res_setservers])
AC_CHECK_DECLS(
	[[fstatat], [openat], [unlinkat], [readlinkat], [faccessat]],
	[], [], [
modified libpkg/dns_utils.c
@@ -271,7 +271,7 @@ dns_getsrvinfo(const char *zone)

int
set_nameserver(const char *nsname) {
-
#ifndef HAVE_RES_SETSERVERS
+
#ifndef HAVE___RES_SETSERVERS
	return (-1);
#else
	struct __res_state res;
@@ -283,6 +283,7 @@ set_nameserver(const char *nsname) {

	memset(u, 0, sizeof(u));
	memset(&hint, 0, sizeof(hint));
+
	memset(&res, 0, sizeof(res));
	hint.ai_socktype = SOCK_DGRAM;

	if (res_ninit(&res) == -1)
modified libpkg/pkg_config.c
@@ -1170,12 +1170,8 @@ pkg_ini(const char *path, const char *reposdir, pkg_init_flags flags)

	/* bypass resolv.conf with specified NAMESERVER if any */
	nsname = pkg_object_string(pkg_config_get("NAMESERVER"));
-
	if (nsname != NULL) {
-
		if (set_nameserver(ucl_object_tostring_forced(o)) != 0) {
-
			pkg_emit_error("Unable to set nameserver");
-
			return (EPKG_FATAL);
-
		}
-
	}
+
	if (nsname != NULL && set_nameserver(nsname) != 0)
+
			pkg_emit_error("Unable to set nameserver, ignoring");

	return (EPKG_OK);
}
modified tests/frontend/config.sh
@@ -4,6 +4,7 @@
tests_init \
	inline_repo \
	empty_conf \
+
	nameserver

inline_repo_body() {
	cat > pkgconfiguration << EOF
@@ -46,3 +47,19 @@ EOF
		-s exit:0 \
		pkg -C pkg.conf info test
}
+

+
nameserver_body()
+
{
+
	atf_check \
+
		-o inline:"\n" \
+
		pkg -C /dev/null config nameserver
+

+
	atf_check \
+
		-o inline:"192.168.1.1\n" \
+
		pkg -o NAMESERVER="192.168.1.1" -C /dev/null config nameserver
+

+
	atf_check \
+
		-o inline:"plop\n" \
+
		-e inline:"pkg: Unable to set nameserver, ignoring\n" \
+
		pkg -o NAMESERVER="plop" -C /dev/null config nameserver
+
}