From: Otto Moerbeek Date: Tue, 12 Mar 2024 07:43:00 +0000 (+0100) Subject: Search -lresolv (if applicable) the proper auto* way X-Git-Tag: rec-5.1.0-alpha1~82^2~11 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=4f0abcdce5e9d2378a19ab4f50423747ba5fafa7;p=thirdparty%2Fpdns.git Search -lresolv (if applicable) the proper auto* way --- diff --git a/pdns/recursordist/Makefile.am b/pdns/recursordist/Makefile.am index 56c5465977..762f7a3762 100644 --- a/pdns/recursordist/Makefile.am +++ b/pdns/recursordist/Makefile.am @@ -248,8 +248,7 @@ pdns_recursor_LDADD = \ $(PROBDS_LIBS) \ $(LIBCAP_LIBS) \ $(ARC4RANDOM_LIBS) \ - $(RUST_LIBS) \ - -lresolv + $(RUST_LIBS) pdns_recursor_LDFLAGS = $(AM_LDFLAGS) \ $(LIBCRYPTO_LDFLAGS) $(BOOST_CONTEXT_LDFLAGS) \ @@ -404,8 +403,7 @@ testrunner_LDADD = \ $(PROBDS_LIBS) \ $(LIBCAP_LIBS) \ $(ARC4RANDOM_LIBS) \ - $(RUST_LIBS) \ - -lresolv + $(RUST_LIBS) if NOD_ENABLED testrunner_SOURCES += nod.hh nod.cc \ diff --git a/pdns/recursordist/configure.ac b/pdns/recursordist/configure.ac index 7485daf8f4..a22a6049f8 100644 --- a/pdns/recursordist/configure.ac +++ b/pdns/recursordist/configure.ac @@ -44,6 +44,8 @@ AC_SUBST([LIBDL], [$lt_cv_dlopen_libs]) PDNS_CHECK_OS PDNS_CHECK_NETWORK_LIBS AC_SEARCH_LIBS([res_query], [resolv]) +# macOS uses an alternative name internally +AC_SEARCH_LIBS([res_9_query], [resolv]) PTHREAD_SET_NAME AC_FUNC_STRERROR_R diff --git a/pdns/recursordist/rec-system-resolve.cc b/pdns/recursordist/rec-system-resolve.cc index 6d7327454b..56b9ce7352 100644 --- a/pdns/recursordist/rec-system-resolve.cc +++ b/pdns/recursordist/rec-system-resolve.cc @@ -74,12 +74,12 @@ std::string serverID() cerr << "XXXXXXXXX SID case 1" << endl; return {}; } - MOADNSParser parser(false, reinterpret_cast(buffer.data()), buffer.size()); // NOLINT + MOADNSParser parser(false, reinterpret_cast(buffer.data()), buffer.size()); // NOLINT if (parser.d_header.rcode != RCode::NoError || parser.d_answers.size() != 1) { cerr << "XXXXXXXXX SID case 2" << endl; return {}; } - const auto& answer = parser.d_answers.at(0); + const auto& answer = parser.d_answers.at(0); if (answer.first.d_type == QType::TXT) { if (auto txt = getRR(answer.first); txt != nullptr) { cerr << "XXXXXXXXX SID is " << txt->d_text << endl; @@ -89,7 +89,7 @@ std::string serverID() return txt->d_text; } } - cerr << "XXXXXXXXX SID case 3" << endl; + cerr << "XXXXXXXXX SID case 3" << endl; return {}; } } // anonymous namespace @@ -130,10 +130,10 @@ ComboAddress pdns::RecResolve::lookupAndRegister(const std::string& name, time_t { auto data = d_data.lock(); if (auto iter = data->d_map.find(name); iter != data->d_map.end()) { - if (iter->second.d_ttd < now) { - return iter->second.d_address; - } - // If it's stale, re-resolve below + if (iter->second.d_ttd < now) { + return iter->second.d_address; + } + // If it's stale, re-resolve below } // We keep the lock while resolving, even though this might take a while... auto address = resolve(name); diff --git a/pdns/recursordist/rec-system-resolve.hh b/pdns/recursordist/rec-system-resolve.hh index 3931f790db..f20af5a56f 100644 --- a/pdns/recursordist/rec-system-resolve.hh +++ b/pdns/recursordist/rec-system-resolve.hh @@ -24,6 +24,7 @@ #include "config.h" +#include #include #include @@ -78,6 +79,7 @@ private: void trigger(); std::atomic changes{false}; + private: void refreshLoop(); diff --git a/pdns/recursordist/settings/rust/src/bridge.rs b/pdns/recursordist/settings/rust/src/bridge.rs index d8a004febe..6de3318c2e 100644 --- a/pdns/recursordist/settings/rust/src/bridge.rs +++ b/pdns/recursordist/settings/rust/src/bridge.rs @@ -72,19 +72,19 @@ fn is_port_number(str: &str) -> bool { } pub fn validate_socket_address_or_name(field: &str, val: &String) -> Result<(), ValidationError> { - let sa = SocketAddr::from_str(val); + let sa = validate_socket_address(field, val); if sa.is_err() { - let ip = IpAddr::from_str(val); - if ip.is_err() { - if !hostname_validator::is_valid(val) { - let parts:Vec<&str> = val.split(':').collect(); - if parts.len () != 2 || !hostname_validator::is_valid(parts[0]) || !is_port_number(parts[1]) { - let msg = format!( - "{}: value `{}' is not an IP, IP:port, name or name:port combination", - field, val - ); - return Err(ValidationError { msg }); - } + if !hostname_validator::is_valid(val) { + let parts: Vec<&str> = val.split(':').collect(); + if parts.len() != 2 + || !hostname_validator::is_valid(parts[0]) + || !is_port_number(parts[1]) + { + let msg = format!( + "{}: value `{}' is not an IP, IP:port, name or name:port combination", + field, val + ); + return Err(ValidationError { msg }); } } } @@ -163,9 +163,7 @@ pub fn parse_yaml_string_to_api_zones(str: &str) -> Result Result, serde_yaml::Error> { +pub fn parse_yaml_string_to_allow_notify_for(str: &str) -> Result, serde_yaml::Error> { serde_yaml::from_str(str) } @@ -240,10 +238,7 @@ pub fn validate_auth_zones(field: &str, vec: &Vec) -> Result<(), Valid } #[allow(clippy::ptr_arg)] //# Avoids creating a rust::Slice object on the C++ side. -pub fn validate_forward_zones( - field: &str, - vec: &Vec, -) -> Result<(), ValidationError> { +pub fn validate_forward_zones(field: &str, vec: &Vec) -> Result<(), ValidationError> { validate_vec(field, vec, |field, element| element.validate(field)) } @@ -375,7 +370,9 @@ pub fn map_to_yaml_string(vec: &Vec) -> Result serde_yaml::Value::String("map_to_yaml_string: Unknown type: ".to_owned() + other), + other => serde_yaml::Value::String( + "map_to_yaml_string: Unknown type: ".to_owned() + other, + ), }; if entry.overriding { let tagged_value = Box::new(serde_yaml::value::TaggedValue { @@ -491,7 +488,10 @@ pub fn api_add_forward_zone(path: &str, forwardzone: ForwardZone) -> Result<(), } // This function is called from C++, it needs to acquire the lock -pub fn api_add_forward_zones(path: &str, forwardzones: &mut Vec) -> Result<(), std::io::Error> { +pub fn api_add_forward_zones( + path: &str, + forwardzones: &mut Vec, +) -> Result<(), std::io::Error> { let _lock = LOCK.lock().unwrap(); let mut zones = api_read_zones_locked(path, true)?; zones.forward_zones.append(forwardzones); diff --git a/pdns/recursordist/settings/rust/src/helpers.rs b/pdns/recursordist/settings/rust/src/helpers.rs index 795d8a5855..a49786f616 100644 --- a/pdns/recursordist/settings/rust/src/helpers.rs +++ b/pdns/recursordist/settings/rust/src/helpers.rs @@ -20,8 +20,8 @@ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. */ -use std::{error::Error, fmt}; use crate::ValidationError; +use std::{error::Error, fmt}; /* Helper code for validation */ impl Error for ValidationError {} @@ -64,10 +64,9 @@ pub fn is_default(t: &T) -> bool { pub const OVERRIDE_TAG: &str = "!override"; -pub fn is_overriding(m: &serde_yaml::Mapping, key: &str) -> bool{ +pub fn is_overriding(m: &serde_yaml::Mapping, key: &str) -> bool { if let Some(serde_yaml::Value::Tagged(vvv)) = m.get(key) { return vvv.tag == OVERRIDE_TAG; } false } -