From: Apple Date: Thu, 2 Apr 2020 23:40:12 +0000 (+0000) Subject: mDNSResponder-1096.60.2.tar.gz X-Git-Tag: macos-10152^0 X-Git-Url: https://git.saurik.com/apple/mdnsresponder.git/commitdiff_plain/660496427b82c4c24076024cf9e753fb27530ce9 mDNSResponder-1096.60.2.tar.gz --- diff --git a/Clients/dnssdutil/TestUtils.h b/Clients/dnssdutil/TestUtils.h new file mode 100644 index 0000000..c263164 --- /dev/null +++ b/Clients/dnssdutil/TestUtils.h @@ -0,0 +1,26 @@ +// +// TestUtils.h +// mDNSResponder +// +// Copyright (c) 2019 Apple Inc. All rights reserved. +// + +#ifndef __TestUtils_h +#define __TestUtils_h + +#include +#include + +#ifdef __cplusplus +extern "C" { +#endif + +#define DNSSDUTIL_XCTEST "DNSSDUTIL_XCTEST" + +Boolean TestUtilsRunXCTestNamed(const char * classname); + +#ifdef __cplusplus +} +#endif + +#endif // __TestUtils_h diff --git a/Clients/dnssdutil/TestUtils.m b/Clients/dnssdutil/TestUtils.m new file mode 100644 index 0000000..00b3c4c --- /dev/null +++ b/Clients/dnssdutil/TestUtils.m @@ -0,0 +1,65 @@ +// +// TestUtils.m +// mDNSResponder +// +// Copyright (c) 2019 Apple Inc. All rights reserved. +// + +#import "TestUtils.h" + +#import +#import +#import + +#if TARGET_OS_OSX +#define XCTest_Framework_Runtime_Path "/AppleInternal/Developer/Library/Frameworks/XCTest.framework" +#else +#define XCTest_Framework_Runtime_Path "/Developer/Library/Frameworks/XCTest.framework" +#endif + +//=========================================================================================================================== +// XCTest Utils +//=========================================================================================================================== +static NSBundle * LoadXCTestFramework() +{ + NSBundle * result = nil; + Boolean loaded = (NSClassFromString(@"XCTestSuite") != nil); + + if(!result) { + result = [NSBundle bundleWithPath: @ XCTest_Framework_Runtime_Path]; + [result load]; + loaded = (NSClassFromString(@"XCTestSuite") != nil); + if( !loaded ) { + FPrintF( stdout, "Failed to load XCTest framework from: %s\n", XCTest_Framework_Runtime_Path ); + } + } + + return( result ); +} + +//=========================================================================================================================== +// Main Test Running +//=========================================================================================================================== + +Boolean TestUtilsRunXCTestNamed(const char * classname) +{ + Boolean result = false; + NSBundle * xctestFramework = LoadXCTestFramework(); + + if(xctestFramework) { + NSString * name = [NSString stringWithUTF8String: classname]; + NSBundle * testBundle = [NSBundle bundleWithPath: @"/AppleInternal/XCTests/com.apple.mDNSResponder/Tests.xctest"]; + [testBundle load]; + + XCTestSuite * compiledSuite = [NSClassFromString(@"XCTestSuite") testSuiteForTestCaseWithName: name]; + if(compiledSuite.tests.count) { + [compiledSuite runTest]; + XCTestRun *testRun = compiledSuite.testRun; + result = (testRun.hasSucceeded != NO); + } else { + FPrintF( stdout, "Test class %s not found\n", classname ); + } + } + + return( result ); +} diff --git a/Clients/dnssdutil/dnssdutil-entitlements.plist b/Clients/dnssdutil/dnssdutil-entitlements.plist index 8be5704..47eba96 100644 --- a/Clients/dnssdutil/dnssdutil-entitlements.plist +++ b/Clients/dnssdutil/dnssdutil-entitlements.plist @@ -16,5 +16,9 @@ preferences.plist + com.apple.private.nehelper.privileged + + com.apple.networkd_privileged + diff --git a/Clients/dnssdutil/dnssdutil.c b/Clients/dnssdutil/dnssdutil.c index 5ab8596..9852be0 100644 --- a/Clients/dnssdutil/dnssdutil.c +++ b/Clients/dnssdutil/dnssdutil.c @@ -44,6 +44,7 @@ #if( MDNSRESPONDER_PROJECT ) #include #include "mdns_private.h" + #include "TestUtils.h" #endif //=========================================================================================================================== @@ -1777,6 +1778,18 @@ static CLIOption kExpensiveConstrainedTestOpts[] = CLI_OPTION_END() }; +#if( MDNSRESPONDER_PROJECT ) +static void XCTestCmd( void ); + +static const char * gXCTest_Classname = NULL; + +static CLIOption kXCTestOpts[] = +{ + StringOption( 'c', "class", &gXCTest_Classname, "classname", "The classname of the XCTest to run (from /AppleInternal/XCTests/com.apple.mDNSResponder/Tests.xctest)", true ), + CLI_OPTION_END() +}; +#endif + static CLIOption kTestOpts[] = { Command( "gaiperf", GAIPerfCmd, kGAIPerfOpts, "Runs DNSServiceGetAddrInfo() performance tests.", false ), @@ -1785,7 +1798,10 @@ static CLIOption kTestOpts[] = Command( "probeconflicts", ProbeConflictTestCmd, kProbeConflictTestOpts, "Tests various probing conflict scenarios.", false ), Command( "registration", RegistrationTestCmd, kRegistrationTestOpts, "Tests service registrations.", false ), Command( "expensive_constrained_updates", ExpensiveConstrainedTestCmd, kExpensiveConstrainedTestOpts, "Tests if the mDNSResponder can handle expensive and constrained property change correctly", false), - CLI_OPTION_END() +#if( MDNSRESPONDER_PROJECT ) + Command( "xctest", XCTestCmd, kXCTestOpts, "Run a XCTest from /AppleInternal/XCTests/com.apple.mDNSResponder/Tests.xctest.", true ), +#endif + CLI_OPTION_END() }; //=========================================================================================================================== @@ -18190,6 +18206,21 @@ static void _DNSProxyCmdSignalHandler( void *inContext ) exit( 0 ); } +//=========================================================================================================================== +// XCTestCmd +//=========================================================================================================================== + +static void XCTestCmd( void ) +{ + int result = 0; + setenv(DNSSDUTIL_XCTEST, DNSSDUTIL_XCTEST, 0); + if(!TestUtilsRunXCTestNamed(gXCTest_Classname)) { + result = 1; + } + unsetenv(DNSSDUTIL_XCTEST); + exit( result ); +} + #endif // MDNSRESPONDER_PROJECT //=========================================================================================================================== diff --git a/Makefile b/Makefile index 88f9942..f2d7645 100644 --- a/Makefile +++ b/Makefile @@ -17,7 +17,7 @@ include $(MAKEFILEPATH)/pb_makefiles/platform.make -MVERS = "mDNSResponder-1096.40.7" +MVERS = "mDNSResponder-1096.60.2" VER = ifneq ($(strip $(GCC_VERSION)),) diff --git a/mDNSMacOSX/Bonjour Safari Extension/CNServiceBrowserView.m b/mDNSMacOSX/Bonjour Safari Extension/CNServiceBrowserView.m index 3adc624..452caf8 100644 --- a/mDNSMacOSX/Bonjour Safari Extension/CNServiceBrowserView.m +++ b/mDNSMacOSX/Bonjour Safari Extension/CNServiceBrowserView.m @@ -578,7 +578,7 @@ static void resolveReply( DNSServiceRef sdRef, const u_char * valuePtr = TXTRecordGetValuePtr( txtLen, txtRecord, "path", &valueLen ); urlComponents.path = (__bridge_transfer NSString *)CFStringCreateWithBytes( kCFAllocatorDefault, valuePtr, valueLen, kCFStringEncodingUTF8, false ); } - if( port ) urlComponents.port = [NSNumber numberWithShort: NTOHS( port )]; + if( port ) urlComponents.port = [NSNumber numberWithUnsignedShort: ntohs( port )]; record[_CNInstanceKey_resolveUrl] = urlComponents.URL; } } diff --git a/mDNSMacOSX/Tests/Unit Tests/PathEvaluationTest.m b/mDNSMacOSX/Tests/Unit Tests/PathEvaluationTest.m new file mode 100644 index 0000000..0371086 --- /dev/null +++ b/mDNSMacOSX/Tests/Unit Tests/PathEvaluationTest.m @@ -0,0 +1,86 @@ +/* + * Copyright (c) 2019 Apple Inc. All rights reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include "unittest_common.h" +#import + +#import + +@interface PathEvaluationTest : XCTestCase +{ +} +@end + +@implementation PathEvaluationTest + +- (void)setUp +{ + mDNSPlatformMemZero(&mDNSStorage, sizeof(mDNS)); + init_mdns_environment(mDNStrue); +} + +- (void)tearDown +{ +} + +- (void)testPathDeny +{ + if(!getenv("DNSSDUTIL_XCTEST")) return; // Don't run without this environment variable + mDNSBool isBlocked; + DNSQuestion q; + mDNSInterfaceID routableIndex; + + mDNSPlatformMemZero(&q, sizeof(DNSQuestion)); + q.TargetQID.NotAnInteger = 1; + q.pid = getpid(); + q.InterfaceID = if_nametoindex( "pdp_ip0" ); + fprintf(stdout, "%s %s with cellular index %d named pdp_ip0\n", q.InterfaceID ? "Starting" : "Exiting (no cellular interface)", __FUNCTION__, q.InterfaceID); + if (!q.InterfaceID) return; + + routableIndex = IndexForInterfaceByName_ut( "pdp_ip0" ); + fprintf(stdout, "Testing blocked by (%s)\n", routableIndex ? "policy" : "no route"); + + mDNSPlatformGetDNSRoutePolicy(&q, &isBlocked); + XCTAssertFalse(isBlocked); + + // Now block it + NSMutableArray *routeRules = [NSMutableArray array]; + NEPolicyRouteRule *routeRule = [NEPolicyRouteRule routeRuleWithAction:NEPolicyRouteRuleActionDeny forType:NEPolicyRouteRuleTypeCellular]; + [routeRules addObject:routeRule]; + routeRule = [NEPolicyRouteRule routeRuleWithAction:NEPolicyRouteRuleActionDeny forType:NEPolicyRouteRuleTypeWiFi]; + [routeRules addObject:routeRule]; + routeRule = [NEPolicyRouteRule routeRuleWithAction:NEPolicyRouteRuleActionDeny forType:NEPolicyRouteRuleTypeWired]; + [routeRules addObject:routeRule]; + + NEPolicyResult *result = [NEPolicyResult routeRules:routeRules]; + NEPolicy *policy = [[NEPolicy alloc] initWithOrder:1 result:result conditions:@[ [NEPolicyCondition effectivePID:q.pid], [NEPolicyCondition allInterfaces] ]]; + + NEPolicySession *policySession = [[NEPolicySession alloc] init]; + XCTAssertNotNil(policySession, "Check entitlemnts"); + [policySession addPolicy:policy]; + [policySession apply]; + + mDNSPlatformGetDNSRoutePolicy(&q, &isBlocked); + // Either if these asserts indicate a regression in mDNSPlatformGetDNSRoutePolicy + if (routableIndex) XCTAssertTrue(isBlocked, "blocked by (policy) test failure"); + else XCTAssertFalse(isBlocked, "blocked by (no route) test failure"); + + [policySession removeAllPolicies]; + [policySession apply]; + fprintf(stdout, "Completed %s\n", __FUNCTION__); +} + +@end diff --git a/mDNSMacOSX/Tests/mDNSResponder.plist b/mDNSMacOSX/Tests/mDNSResponder.plist index 7c6d648..5007abf 100644 --- a/mDNSMacOSX/Tests/mDNSResponder.plist +++ b/mDNSMacOSX/Tests/mDNSResponder.plist @@ -1170,33 +1170,6 @@ mDNSResponder - - TestName - XCTests - Description - mDNSResponder XCTests - WorkingDirectory - /AppleInternal/XCTests/com.apple.mDNSResponder/ - AsRoot - - RequiresWiFi - - Timeout - 20 - ShowSubtestResults - - Command - - BATS_XCTEST_CMD - -NSTreatUnknownArgumentsAsOpen - NO - -ApplePersistenceIgnoreState - YES - -XCTest - Self - Tests.xctest - - TestName Fix Verification #1 @@ -1238,6 +1211,55 @@ mDNSResponder + + TestName + XCTests + Description + mDNSResponder XCTests + WorkingDirectory + /AppleInternal/XCTests/com.apple.mDNSResponder/ + AsRoot + + RequiresWiFi + + Timeout + 20 + ShowSubtestResults + + Command + + BATS_XCTEST_CMD + -NSTreatUnknownArgumentsAsOpen + NO + -ApplePersistenceIgnoreState + YES + -XCTest + Self + Tests.xctest + + + + TestName + PathEvaluationTest + Description + PathEvaluationTest from Tests.xctest + AsRoot + + RequiresWiFi + + Timeout + 5 + IgnoreOutput + + Command + + /usr/local/bin/dnssdutil + test + xctest + -c + PathEvaluationTest + + diff --git a/mDNSMacOSX/mDNSResponder.xcodeproj/project.pbxproj b/mDNSMacOSX/mDNSResponder.xcodeproj/project.pbxproj index 8423ab6..5f23f0b 100644 --- a/mDNSMacOSX/mDNSResponder.xcodeproj/project.pbxproj +++ b/mDNSMacOSX/mDNSResponder.xcodeproj/project.pbxproj @@ -276,6 +276,8 @@ B7706AAF1DBA9C1800593FD5 /* CNDomainBrowserPathUtils.m in Sources */ = {isa = PBXBuildFile; fileRef = B799209E1DA6BA8E00C6E02B /* CNDomainBrowserPathUtils.m */; }; B778EE4D1D51113800C814A2 /* HostnameController.m in Sources */ = {isa = PBXBuildFile; fileRef = B778EE4B1D51113800C814A2 /* HostnameController.m */; }; B778EE501D51287100C814A2 /* BonjourSettingsController.m in Sources */ = {isa = PBXBuildFile; fileRef = B778EE4F1D51287100C814A2 /* BonjourSettingsController.m */; }; + B77CAFCE234EADE5006706B4 /* PathEvaluationTest.m in Sources */ = {isa = PBXBuildFile; fileRef = B77CAFCD234EADE5006706B4 /* PathEvaluationTest.m */; }; + B77CAFD0234EAE72006706B4 /* NetworkExtension.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = B77CAFCF234EAE72006706B4 /* NetworkExtension.framework */; }; B78A9C30223941A900BFB0C6 /* DNSServiceDiscoveryPref.xib in Resources */ = {isa = PBXBuildFile; fileRef = B78A9C2E223941A900BFB0C6 /* DNSServiceDiscoveryPref.xib */; }; B79568351D53F693005E3BED /* DomainBrowser.h in Headers */ = {isa = PBXBuildFile; fileRef = B74EC12B1D494C7200A1D155 /* DomainBrowser.h */; settings = {ATTRIBUTES = (Public, ); }; }; B79568361D53F69B005E3BED /* CNDomainBrowserView.h in Headers */ = {isa = PBXBuildFile; fileRef = B7D6CA681D1076C6005E24CF /* CNDomainBrowserView.h */; settings = {ATTRIBUTES = (Public, ); }; }; @@ -332,6 +334,8 @@ B7EEF7EA212613260093828F /* uds_daemon.c in Sources */ = {isa = PBXBuildFile; fileRef = F525E72804AA167501F1CF4D /* uds_daemon.c */; }; B7EEF7EC212613D10093828F /* dnsproxy.c in Sources */ = {isa = PBXBuildFile; fileRef = 218E8E4F156D8C0300720DA0 /* dnsproxy.c */; }; B7EEF7ED212613D50093828F /* DNSProxySupport.c in Sources */ = {isa = PBXBuildFile; fileRef = 21DED43415702C0F0060B6B9 /* DNSProxySupport.c */; }; + B7F1FEDE234F89C50081159C /* TestUtils.h in Headers */ = {isa = PBXBuildFile; fileRef = B7F1FEDC234F89C50081159C /* TestUtils.h */; }; + B7F1FEDF234F89C50081159C /* TestUtils.m in Sources */ = {isa = PBXBuildFile; fileRef = B7F1FEDD234F89C50081159C /* TestUtils.m */; }; BD03E88D1AD31278005E8A81 /* SymptomReporter.c in Sources */ = {isa = PBXBuildFile; fileRef = BD03E88C1AD31278005E8A81 /* SymptomReporter.c */; }; BD11267121DB1B25006115E6 /* dnssd_server.h in Headers */ = {isa = PBXBuildFile; fileRef = BD11267021DB1AFE006115E6 /* dnssd_server.h */; }; BD11267221DB1B29006115E6 /* dnssd_xpc.h in Headers */ = {isa = PBXBuildFile; fileRef = BD11266D21DB1AFE006115E6 /* dnssd_xpc.h */; }; @@ -1029,6 +1033,8 @@ B778EE4B1D51113800C814A2 /* HostnameController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = HostnameController.m; path = ../SettingsBundle/HostnameController.m; sourceTree = ""; }; B778EE4E1D51287100C814A2 /* BonjourSettingsController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = BonjourSettingsController.h; path = ../SettingsBundle/BonjourSettingsController.h; sourceTree = ""; }; B778EE4F1D51287100C814A2 /* BonjourSettingsController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = BonjourSettingsController.m; path = ../SettingsBundle/BonjourSettingsController.m; sourceTree = ""; }; + B77CAFCD234EADE5006706B4 /* PathEvaluationTest.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = PathEvaluationTest.m; sourceTree = ""; }; + B77CAFCF234EAE72006706B4 /* NetworkExtension.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = NetworkExtension.framework; path = System/Library/Frameworks/NetworkExtension.framework; sourceTree = SDKROOT; }; B78A9C2F223941A900BFB0C6 /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.xib; name = Base; path = Base.lproj/DNSServiceDiscoveryPref.xib; sourceTree = ""; }; B78A9C322239485E00BFB0C6 /* en */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = en; path = en.lproj/InfoPlist.strings; sourceTree = ""; }; B799209D1DA6BA8E00C6E02B /* CNDomainBrowserPathUtils.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CNDomainBrowserPathUtils.h; sourceTree = ""; }; @@ -1080,6 +1086,9 @@ B7D6CA691D1076C6005E24CF /* CNDomainBrowserView.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = CNDomainBrowserView.m; sourceTree = ""; }; B7D6CA701D1076F3005E24CF /* DomainBrowser.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = DomainBrowser.framework; sourceTree = BUILT_PRODUCTS_DIR; }; B7E06CDF2329AA7B0021401F /* LocalOnlyWithInterfacesTest.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = LocalOnlyWithInterfacesTest.m; sourceTree = ""; }; + B7F1FEDC234F89C50081159C /* TestUtils.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = TestUtils.h; sourceTree = ""; }; + B7F1FEDD234F89C50081159C /* TestUtils.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = TestUtils.m; sourceTree = ""; }; + B7F1FEEA234FAF0F0081159C /* dnssdutil-entitlements.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = "dnssdutil-entitlements.plist"; sourceTree = ""; }; BD03E88C1AD31278005E8A81 /* SymptomReporter.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = SymptomReporter.c; sourceTree = ""; }; BD11266D21DB1AFE006115E6 /* dnssd_xpc.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = dnssd_xpc.h; sourceTree = ""; }; BD11266E21DB1AFE006115E6 /* dnssd_xpc.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = dnssd_xpc.c; sourceTree = ""; }; @@ -1304,6 +1313,7 @@ B7A861A2212B408D00E81CC3 /* Security.framework in Frameworks */, B7EEF7C4212603B20093828F /* SystemConfiguration.framework in Frameworks */, B7A861A9212B411600E81CC3 /* Network.framework in Frameworks */, + B77CAFD0234EAE72006706B4 /* NetworkExtension.framework in Frameworks */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -1741,6 +1751,7 @@ B74BF92D2322E97400E35354 /* SuspiciousReplyTest.m */, B74BF930232701F600E35354 /* CacheOrderTest.m */, B7E06CDF2329AA7B0021401F /* LocalOnlyWithInterfacesTest.m */, + B77CAFCD234EADE5006706B4 /* PathEvaluationTest.m */, ); path = "Unit Tests"; sourceTree = ""; @@ -1904,8 +1915,11 @@ BD97754A221D643500F68FFC /* dnssdutil */ = { isa = PBXGroup; children = ( + B7F1FEEA234FAF0F0081159C /* dnssdutil-entitlements.plist */, BD97754D221D64BF00F68FFC /* DNSMessage.c */, BD97754E221D64BF00F68FFC /* DNSMessage.h */, + B7F1FEDC234F89C50081159C /* TestUtils.h */, + B7F1FEDD234F89C50081159C /* TestUtils.m */, BD97754B221D643500F68FFC /* dnssdutil.c */, ); name = dnssdutil; @@ -1915,6 +1929,7 @@ BD9BA7561EAF929C00658CCF /* Frameworks */ = { isa = PBXGroup; children = ( + B77CAFCF234EAE72006706B4 /* NetworkExtension.framework */, BDA82B8922BF8A7000A31CBE /* libdns_services.tbd */, D448F7AD222DCC0A0069E1D2 /* CoreFoundation.framework */, D448F7AB222DCB5B0069E1D2 /* libarchive.tbd */, @@ -2122,6 +2137,7 @@ files = ( BD977550221D64BF00F68FFC /* DNSMessage.h in Headers */, D4A9F60521FA797F0079D0C6 /* dns_sd_private.h in Headers */, + B7F1FEDE234F89C50081159C /* TestUtils.h in Headers */, BD2A15B9225ED30C00BEA50A /* mdns_private.h in Headers */, ); runOnlyForDeploymentPostprocessing = 0; @@ -3223,6 +3239,7 @@ D40123922272B7A7006C9BBE /* mdns.c in Sources */, B7EEF7CA2126046A0093828F /* uDNS.c in Sources */, D4F2BB2822CD21CB00234A38 /* posix_utilities.c in Sources */, + B77CAFCE234EADE5006706B4 /* PathEvaluationTest.m in Sources */, B7EEF7D82126076F0093828F /* dnssec.c in Sources */, B7EEF7E021260A1F0093828F /* helper-stubs.c in Sources */, B79FA14B211CE8CA00B7861E /* DNSCommon.c in Sources */, @@ -3276,6 +3293,7 @@ BD97754F221D64BF00F68FFC /* DNSMessage.c in Sources */, BD2A15BA225ED31C00BEA50A /* mdns.c in Sources */, BD2A15BB225ED33C00BEA50A /* mdns_object.m in Sources */, + B7F1FEDF234F89C50081159C /* TestUtils.m in Sources */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -4977,7 +4995,7 @@ ); INFOPLIST_FILE = "Tests/Unit Tests/Info.plist"; INSTALL_PATH = /AppleInternal/XCTests/com.apple.mDNSResponder/; - LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/../Frameworks @loader_path/../Frameworks"; + LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/../Frameworks @loader_path/../Frameworks /AppleInternal/Developer/Library/Frameworks"; MTL_FAST_MATH = YES; OTHER_CFLAGS = ( "-DUSE_SYSTEMCONFIGURATION_PRIVATE_HEADERS", @@ -4990,6 +5008,8 @@ WebFilterDNS, "-weak_framework", DeviceToDeviceManager, + "-weak_framework", + XCTest, ); "OTHER_LDFLAGS[sdk=iphoneos*]" = ( "-weak_framework", @@ -5059,7 +5079,7 @@ ); INFOPLIST_FILE = "Tests/Unit Tests/Info.plist"; INSTALL_PATH = /AppleInternal/XCTests/com.apple.mDNSResponder/; - LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/../Frameworks @loader_path/../Frameworks"; + LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/../Frameworks @loader_path/../Frameworks /AppleInternal/Developer/Library/Frameworks"; MTL_FAST_MATH = YES; ONLY_ACTIVE_ARCH = YES; OTHER_CFLAGS = ( @@ -5072,6 +5092,8 @@ WebFilterDNS, "-weak_framework", DeviceToDeviceManager, + "-weak_framework", + XCTest, ); "OTHER_LDFLAGS[sdk=iphoneos*]" = ( "-weak_framework", @@ -5490,6 +5512,7 @@ HEADER_SEARCH_PATHS = "$(SDKROOT)${SYSTEM_LIBRARY_DIR}/Frameworks/System.framework/PrivateHeaders"; INSTALL_PATH = /usr/local/bin; PRODUCT_NAME = "$(TARGET_NAME)"; + SYSTEM_FRAMEWORK_SEARCH_PATHS = "$(inherited) $(SDKROOT)/System/Library/PrivateFrameworks $(PLATFORM_DIR)/Developer/Library/Frameworks $(PLATFORM_DIR)/Developer/AppleInternal/Library/Frameworks"; WARNING_CFLAGS = ( "-Wall", "-Warc-repeated-use-of-weak", @@ -5584,6 +5607,7 @@ HEADER_SEARCH_PATHS = "$(SDKROOT)${SYSTEM_LIBRARY_DIR}/Frameworks/System.framework/PrivateHeaders"; INSTALL_PATH = /usr/local/bin; PRODUCT_NAME = "$(TARGET_NAME)"; + SYSTEM_FRAMEWORK_SEARCH_PATHS = "$(inherited) $(SDKROOT)/System/Library/PrivateFrameworks $(PLATFORM_DIR)/Developer/Library/Frameworks $(PLATFORM_DIR)/Developer/AppleInternal/Library/Frameworks"; WARNING_CFLAGS = ( "-Wall", "-Warc-repeated-use-of-weak", diff --git a/mDNSMacOSX/uDNSPathEvalulation.c b/mDNSMacOSX/uDNSPathEvalulation.c index c78e3ca..9923446 100644 --- a/mDNSMacOSX/uDNSPathEvalulation.c +++ b/mDNSMacOSX/uDNSPathEvalulation.c @@ -155,7 +155,7 @@ mDNSexport void mDNSPlatformGetDNSRoutePolicy(DNSQuestion *q, mDNSBool *isBlocke } } - if (isUUIDSet && path && (nw_path_get_status(path) == nw_path_status_unsatisfied) && (nw_path_get_reason(path) == nw_path_reason_policy_drop)) + if (isUUIDSet && path && (nw_path_get_status(path) == nw_path_status_unsatisfied) && (nw_path_get_reason(path) != nw_path_reason_no_route)) *isBlocked = mDNStrue; else *isBlocked = mDNSfalse; diff --git a/mDNSShared/dns_sd.h b/mDNSShared/dns_sd.h index f208d28..d44a949 100644 --- a/mDNSShared/dns_sd.h +++ b/mDNSShared/dns_sd.h @@ -66,7 +66,7 @@ */ #ifndef _DNS_SD_H -#define _DNS_SD_H 10964007 +#define _DNS_SD_H 10966002 #ifdef __cplusplus extern "C" { diff --git a/unittests/mdns_macosx_ut.c b/unittests/mdns_macosx_ut.c index 163ccc4..18b7611 100644 --- a/unittests/mdns_macosx_ut.c +++ b/unittests/mdns_macosx_ut.c @@ -1,5 +1,6 @@ #include "DNSCommon.h" // Defines general DNS utility routines #include "unittest_common.h" +#include "mDNSMacOSX.h" // To match *either* a v4 or v6 instance of this interface mDNSlocal mDNSInterfaceID SearchForInterfaceByAddr(mDNSAddr* addr) @@ -70,3 +71,9 @@ mDNSexport void mDNSDomainLabelFromCFString_ut(CFStringRef cfs, domainlabel *con { mDNSDomainLabelFromCFString(cfs, namelabel); } + +mDNSexport mDNSu32 IndexForInterfaceByName_ut(const char *ifname) +{ + NetworkInterfaceInfoOSX * i = SearchForInterfaceByName(ifname, AF_UNSPEC); + return (i ? i->scope_id : 0); +} diff --git a/unittests/unittest_common.h b/unittests/unittest_common.h index 3ab4b4f..5755a75 100644 --- a/unittests/unittest_common.h +++ b/unittests/unittest_common.h @@ -60,5 +60,6 @@ extern mStatus verify_cache_addr_order_for_domain_ut(mDNS *const m, mDNSu8* oct // HelperFunctionTest extern void mDNSDomainLabelFromCFString_ut(CFStringRef cfs, domainlabel *const namelabel); +mDNSexport mDNSu32 IndexForInterfaceByName_ut(const char *ifname); #endif /* UNITTEST_COMMON_H */