From 1ef45fa40afc16a8d224b7438ecefbd7c8b4fbfe Mon Sep 17 00:00:00 2001 From: Apple Date: Tue, 26 Sep 2017 16:52:47 +0000 Subject: [PATCH] configd-963.tar.gz --- IPMonitorControl/IPMonitorControl.c | 18 +- IPMonitorControl/IPMonitorControlServer.c | 6 +- .../IPMonitor/Info-EmbeddedSimulator.plist | 4 +- Plugins/IPMonitor/Info.plist | 4 +- .../Simulator/com.apple.networking.IPMonitor | 1 - Plugins/IPMonitor/configAgent.m | 8 +- Plugins/IPMonitor/controller.m | 88 +- Plugins/IPMonitor/dns-configuration.c | 177 ++- Plugins/IPMonitor/ip_plugin.c | 624 ++++---- Plugins/IPMonitor/ip_plugin.h | 16 +- Plugins/IPMonitor/nat64-configuration.c | 288 ++++ Plugins/IPMonitor/nat64-configuration.h | 50 + Plugins/IPMonitor/proxy-configuration.c | 10 +- Plugins/IPMonitor/set-hostname.c | 7 +- Plugins/IPMonitor/smb-configuration.c | 34 +- Plugins/InterfaceNamer/Info.plist | 4 +- Plugins/InterfaceNamer/ifnamer.c | 28 +- Plugins/KernelEventMonitor/Info.plist | 4 +- Plugins/KernelEventMonitor/ev_dlil.c | 20 +- Plugins/KernelEventMonitor/ev_extra.m | 8 +- Plugins/KernelEventMonitor/ev_ipv4.c | 10 +- Plugins/KernelEventMonitor/ev_ipv6.c | 47 +- Plugins/KernelEventMonitor/ev_ipv6.h | 11 +- Plugins/KernelEventMonitor/eventmon.c | 61 +- Plugins/LinkConfiguration/Info.plist | 4 +- Plugins/LinkConfiguration/linkconfig.c | 17 +- Plugins/PreferencesMonitor/Info.plist | 4 +- Plugins/PreferencesMonitor/prefsmon.c | 18 +- Plugins/QoSMarking/Info.plist | 8 +- Plugins/QoSMarking/qos-marking.m | 65 +- Plugins/SimulatorSupport/Info.plist | 4 +- Plugins/SimulatorSupport/simulator_support.c | 4 +- Plugins/common/IPMonitorControlPrefs.c | 9 +- Plugins/common/IPMonitorControlPrefs.h | 8 +- Plugins/common/InterfaceNamerControlPrefs.c | 2 - Plugins/common/cache.c | 5 +- SCMonitor/English.lproj/Localizable.strings | Bin 1608 -> 1604 bytes SCMonitor/Info.plist | 2 +- SCMonitor/monitor.c | 14 +- SystemConfiguration.fproj/BondConfiguration.c | 14 +- .../BridgeConfiguration.c | 37 +- SystemConfiguration.fproj/DHCP.c | 4 +- .../DHCPClientPreferences.h | 4 +- .../English.lproj/NetworkInterface.strings | Bin 6510 -> 6634 bytes SystemConfiguration.fproj/Info-Embedded.plist | 6 +- SystemConfiguration.fproj/Info.plist | 6 +- SystemConfiguration.fproj/LinkConfiguration.c | 14 +- SystemConfiguration.fproj/SCD.c | 536 +------ SystemConfiguration.fproj/SCD.h | 4 +- SystemConfiguration.fproj/SCDAdd.c | 6 +- SystemConfiguration.fproj/SCDGet.c | 6 +- SystemConfiguration.fproj/SCDHostName.c | 4 +- SystemConfiguration.fproj/SCDList.c | 4 +- SystemConfiguration.fproj/SCDNotifierAdd.c | 4 +- SystemConfiguration.fproj/SCDNotifierCancel.c | 8 +- .../SCDNotifierGetChanges.c | 4 +- .../SCDNotifierInformViaCallback.c | 15 +- .../SCDNotifierInformViaFD.c | 8 +- .../SCDNotifierInformViaSignal.c | 4 +- SystemConfiguration.fproj/SCDNotifierRemove.c | 4 +- .../SCDNotifierSetKeys.c | 4 +- SystemConfiguration.fproj/SCDNotifierWait.c | 6 +- SystemConfiguration.fproj/SCDNotify.c | 4 +- SystemConfiguration.fproj/SCDOpen.c | 24 +- SystemConfiguration.fproj/SCDPlugin.c | 8 +- SystemConfiguration.fproj/SCDPrivate.c | 304 ++-- SystemConfiguration.fproj/SCDRemove.c | 4 +- SystemConfiguration.fproj/SCDSet.c | 6 +- SystemConfiguration.fproj/SCDSnapshot.c | 4 +- .../SCDynamicStoreInternal.h | 6 +- SystemConfiguration.fproj/SCLocation.c | 3 +- .../SCNetworkConfigurationInternal.h | 18 +- .../SCNetworkConfigurationPrivate.h | 92 +- .../SCNetworkConnection.c | 47 +- .../SCNetworkConnectionPrivate.c | 33 +- .../SCNetworkInterface.c | 225 +-- .../SCNetworkMigration.c | 143 +- SystemConfiguration.fproj/SCNetworkProtocol.c | 51 +- .../SCNetworkReachability.c | 21 +- .../SCNetworkReachabilityInternal.h | 75 +- .../SCNetworkReachabilityLogging.h | 149 ++ SystemConfiguration.fproj/SCNetworkService.c | 14 +- SystemConfiguration.fproj/SCNetworkSet.c | 37 + .../SCNetworkSignature.c | 8 +- .../SCNetworkSignature.h | 8 +- SystemConfiguration.fproj/SCP.c | 8 +- SystemConfiguration.fproj/SCPCommit.c | 27 +- SystemConfiguration.fproj/SCPLock.c | 4 +- SystemConfiguration.fproj/SCPOpen.c | 43 +- .../SCPreferencesKeychainPrivate.c | 28 +- .../SCPreferencesPrivate.h | 18 +- SystemConfiguration.fproj/SCPrivate.h | 195 +-- .../SCSchemaDefinitions.c | 2 + .../SCSchemaDefinitions.h | 3 +- .../SCSchemaDefinitionsPrivate.h | 22 +- SystemConfiguration.fproj/VPNConfiguration.c | 2 +- SystemConfiguration.fproj/VPNFlow.h | 2 +- SystemConfiguration.fproj/VPNPrivate.c | 2 +- SystemConfiguration.fproj/VPNService.c | 87 +- SystemConfiguration.fproj/genSCPreferences.c | 38 +- .../helper/SCHelper_server.c | 80 +- .../helper/com.apple.SCHelper-embedded.plist | 2 +- .../helper/com.apple.SCHelper.plist | 2 +- SystemConfiguration.fproj/scprefs_observer.c | 9 +- SystemConfiguration.fproj/scprefs_observer.h | 4 +- config-agent-info/config_agent_info.c | 3 +- configd.tproj/_SCD.c | 4 +- configd.tproj/_configadd.c | 6 +- configd.tproj/_confignotify.c | 4 +- configd.tproj/_configopen.c | 3 +- configd.tproj/_configremove.c | 4 +- configd.tproj/_configset.c | 11 +- configd.tproj/_configunlock.c | 3 +- configd.tproj/_snapshot.c | 3 +- configd.tproj/configd.m | 8 +- configd.tproj/configd_server.c | 8 +- configd.tproj/entitlements-ios.plist | 4 +- configd.tproj/plugin_support.c | 38 +- configd.tproj/session.c | 12 +- configd.tproj/session.h | 3 +- configd.xcodeproj/project.pbxproj | 1294 ++++++++++++++--- dnsinfo/dnsinfo.h | 7 +- dnsinfo/dnsinfo_copy.c | 70 +- dnsinfo/dnsinfo_create.c | 18 +- dnsinfo/dnsinfo_create.h | 11 +- dnsinfo/dnsinfo_flatfile.c | 70 +- dnsinfo/dnsinfo_internal.h | 286 ++-- dnsinfo/dnsinfo_logging.h | 245 ++++ dnsinfo/dnsinfo_private.h | 49 +- dnsinfo/dnsinfo_server.c | 69 +- get-mobility-info | 23 +- get-network-info | 138 +- logging/liblog_SystemConfiguration.m | 190 +++ nwi/network_information.c | 11 +- nwi/network_information.h | 5 +- nwi/network_information_server.c | 70 +- nwi/network_state_information_logging.h | 396 +++++ nwi/network_state_information_priv.c | 110 +- nwi/network_state_information_priv.h | 38 +- sctest/SCTestConfigAgents.m | 16 +- sctest/SCTestDynamicStore.m | 4 +- sctest/SCTestOptions.h | 2 +- sctest/SCTestPreferences.m | 151 +- sctest/SCTestReachability.m | 6 +- sctest/genSCTestOptions.c | 4 +- scutil.tproj/cache.c | 13 +- scutil.tproj/commands.c | 11 +- scutil.tproj/dictionary.c | 7 +- scutil.tproj/nc.c | 7 +- scutil.tproj/net.c | 30 +- scutil.tproj/net_interface.c | 48 +- scutil.tproj/net_protocol.c | 86 +- scutil.tproj/net_protocol.h | 4 +- scutil.tproj/net_service.c | 16 +- scutil.tproj/net_set.c | 40 +- scutil.tproj/notifications.c | 19 +- scutil.tproj/prefs.c | 46 +- scutil.tproj/scutil.c | 11 +- scutil.tproj/session.c | 7 +- scutil.tproj/tests.c | 243 +--- update-sanitizer-dylib-references | 108 ++ 161 files changed, 5610 insertions(+), 2739 deletions(-) delete mode 100644 Plugins/IPMonitor/Simulator/com.apple.networking.IPMonitor create mode 100644 Plugins/IPMonitor/nat64-configuration.c create mode 100644 Plugins/IPMonitor/nat64-configuration.h create mode 100644 SystemConfiguration.fproj/SCNetworkReachabilityLogging.h create mode 100644 dnsinfo/dnsinfo_logging.h create mode 100644 logging/liblog_SystemConfiguration.m create mode 100644 nwi/network_state_information_logging.h create mode 100755 update-sanitizer-dylib-references diff --git a/IPMonitorControl/IPMonitorControl.c b/IPMonitorControl/IPMonitorControl.c index ed8d861..8336eb0 100644 --- a/IPMonitorControl/IPMonitorControl.c +++ b/IPMonitorControl/IPMonitorControl.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013-2016 Apple Inc. All rights reserved. + * Copyright (c) 2013-2017 Apple Inc. All rights reserved. * * @APPLE_LICENSE_HEADER_START@ * @@ -60,7 +60,9 @@ struct IPMonitorControl { CFRuntimeBase cf_base; +#ifdef VERBOSE_ACTIVITY_LOGGING os_activity_t activity; +#endif // VERBOSE_ACTIVITY_LOGGING dispatch_queue_t queue; xpc_connection_t connection; CFMutableDictionaryRef assertions; /* ifname = rank */ @@ -102,9 +104,11 @@ __IPMonitorControlDeallocate(CFTypeRef cf) if (control->connection != NULL) { xpc_release(control->connection); } +#ifdef VERBOSE_ACTIVITY_LOGGING if (control->activity != NULL) { os_release(control->activity); } +#endif // VERBOSE_ACTIVITY_LOGGING if (control->queue != NULL) { xpc_release(control->queue); } @@ -293,9 +297,11 @@ IPMonitorControlCreate(void) os_release(activity); }; xpc_connection_set_event_handler(connection, handler); - control->activity = os_activity_create("accessing IPMonitor [rank] controls", - OS_ACTIVITY_CURRENT, - OS_ACTIVITY_FLAG_DEFAULT); +#ifdef VERBOSE_ACTIVITY_LOGGING + control->activity = os_activity_create("accessing IPMonitor [rank] controls", + OS_ACTIVITY_CURRENT, + OS_ACTIVITY_FLAG_DEFAULT); +#endif // VERBOSE_ACTIVITY_LOGGING control->connection = connection; control->queue = queue; xpc_connection_resume(connection); @@ -316,7 +322,9 @@ IPMonitorControlSetInterfacePrimaryRank(IPMonitorControlRef control, return (FALSE); } +#ifdef VERBOSE_ACTIVITY_LOGGING os_activity_scope(control->activity); +#endif // VERBOSE_ACTIVITY_LOGGING request = xpc_dictionary_create(NULL, NULL, 0); xpc_dictionary_set_uint64(request, @@ -381,7 +389,9 @@ IPMonitorControlGetInterfacePrimaryRank(IPMonitorControlRef control, return rank; } +#ifdef VERBOSE_ACTIVITY_LOGGING os_activity_scope(control->activity); +#endif // VERBOSE_ACTIVITY_LOGGING request = xpc_dictionary_create(NULL, NULL, 0); xpc_dictionary_set_uint64(request, diff --git a/IPMonitorControl/IPMonitorControlServer.c b/IPMonitorControl/IPMonitorControlServer.c index b3a9fb6..b4563fc 100644 --- a/IPMonitorControl/IPMonitorControlServer.c +++ b/IPMonitorControl/IPMonitorControlServer.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013-2016 Apple Inc. All rights reserved. + * Copyright (c) 2013-2017 Apple Inc. All rights reserved. * * @APPLE_LICENSE_HEADER_START@ * @@ -168,6 +168,8 @@ GenerateNotification(void) STATIC void AddChangedInterface(const void * key, const void * value, void * context) { +#pragma unused(value) +#pragma unused(context) InterfaceChangedListAddInterface((CFStringRef)key); return; } @@ -311,6 +313,7 @@ IPMonitorControlServerHandleSetInterfaceRank(xpc_connection_t connection, xpc_object_t request, xpc_object_t reply) { +#pragma unused(reply) const char * ifname; SCNetworkServicePrimaryRank rank; ControlSessionRef session; @@ -505,6 +508,7 @@ PRIVATE_EXTERN Boolean IPMonitorControlServerStart(CFRunLoopRef runloop, CFRunLoopSourceRef rls, Boolean * verbose) { +#pragma unused(verbose) dispatch_queue_t q; xpc_connection_t connection; diff --git a/Plugins/IPMonitor/Info-EmbeddedSimulator.plist b/Plugins/IPMonitor/Info-EmbeddedSimulator.plist index 411ec7d..4065076 100644 --- a/Plugins/IPMonitor/Info-EmbeddedSimulator.plist +++ b/Plugins/IPMonitor/Info-EmbeddedSimulator.plist @@ -19,11 +19,11 @@ CFBundlePackageType BNDL CFBundleShortVersionString - 1.14 + 1.17 CFBundleSignature ???? CFBundleVersion - 1.14 + 1.17 MachServices com.apple.SystemConfiguration.DNSConfiguration_sim diff --git a/Plugins/IPMonitor/Info.plist b/Plugins/IPMonitor/Info.plist index 0907a58..6c63c55 100644 --- a/Plugins/IPMonitor/Info.plist +++ b/Plugins/IPMonitor/Info.plist @@ -19,11 +19,11 @@ CFBundlePackageType BNDL CFBundleShortVersionString - 1.14 + 1.17 CFBundleSignature ???? CFBundleVersion - 1.14 + 1.17 MachServices com.apple.SystemConfiguration.DNSConfiguration diff --git a/Plugins/IPMonitor/Simulator/com.apple.networking.IPMonitor b/Plugins/IPMonitor/Simulator/com.apple.networking.IPMonitor deleted file mode 100644 index 8f9f9c5..0000000 --- a/Plugins/IPMonitor/Simulator/com.apple.networking.IPMonitor +++ /dev/null @@ -1 +0,0 @@ -? [= LoggerID com.apple.networking.IPMonitor] file $ENV(SIMULATOR_LOG_ROOT)/com.apple.networking.IPMonitor.log crashlog rotate=local file_max=1M compress format=$((Time)(local.6))\ $Host\ $(Sender)[$(PID)]\ <$((Level)(str))>:\ $(Message) \ No newline at end of file diff --git a/Plugins/IPMonitor/configAgent.m b/Plugins/IPMonitor/configAgent.m index 502859f..8b57188 100644 --- a/Plugins/IPMonitor/configAgent.m +++ b/Plugins/IPMonitor/configAgent.m @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015, 2016 Apple Inc. All rights reserved. + * Copyright (c) 2015-2017 Apple Inc. All rights reserved. * * @APPLE_LICENSE_HEADER_START@ * @@ -54,8 +54,9 @@ return @kConfigAgentTypeGeneric; } -+ (instancetype)agentFromData:(__unused NSData *)data ++ (instancetype)agentFromData:(NSData *)data { +#pragma unused(data) return nil; } @@ -144,6 +145,7 @@ - (BOOL)startAgentWithOptions:(NSDictionary *)options { +#pragma unused(options) BOOL ok = NO; if (!self.active) { self.active = YES; @@ -188,4 +190,4 @@ return [[NSUUID alloc] initWithUUIDBytes:hashValue]; } -@end \ No newline at end of file +@end diff --git a/Plugins/IPMonitor/controller.m b/Plugins/IPMonitor/controller.m index 2a7e06f..78f5573 100644 --- a/Plugins/IPMonitor/controller.m +++ b/Plugins/IPMonitor/controller.m @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015, 2016 Apple Inc. All rights reserved. + * Copyright (c) 2015-2017 Apple Inc. All rights reserved. * * @APPLE_LICENSE_HEADER_START@ * @@ -23,6 +23,7 @@ #import "controller.h" #import +#import "ip_plugin.h" #define numberToNSNumber(x) [NSNumber numberWithUnsignedInteger:x] @@ -174,56 +175,7 @@ typedef struct resolverList { - (NEPolicySession *)createPolicySession { - NEPolicySession *session = nil; -#if !TARGET_OS_IPHONE - /* On OS X, since we cannot have entitlements, we open a kernel control - * socket and use it to create a policy session - */ - - /* Create kernel control socket */ - int sock = -1; - struct ctl_info kernctl_info; - struct sockaddr_ctl kernctl_addr; - const char *controlName = NECP_CONTROL_NAME; - - if ((sock = socket(PF_SYSTEM, SOCK_DGRAM, SYSPROTO_CONTROL)) < 0) - { - SC_log(LOG_NOTICE, "Cannot create kernel control socket (errno = %d)\n", errno); - return nil; - } - - bzero(&kernctl_info, sizeof(kernctl_info)); - strlcpy(kernctl_info.ctl_name, controlName, sizeof(kernctl_info.ctl_name)); - if (ioctl(sock, CTLIOCGINFO, &kernctl_info)) - { - SC_log(LOG_NOTICE, "ioctl failed on kernel control socket (errno = %d)\n", errno); - close(sock); - return nil; - } - - bzero(&kernctl_addr, sizeof(kernctl_addr)); - kernctl_addr.sc_len = sizeof(kernctl_addr); - kernctl_addr.sc_family = AF_SYSTEM; - kernctl_addr.ss_sysaddr = AF_SYS_CONTROL; - kernctl_addr.sc_id = kernctl_info.ctl_id; - kernctl_addr.sc_unit = 0; - if (connect(sock, (struct sockaddr *)&kernctl_addr, sizeof(kernctl_addr))) - { - SC_log(LOG_NOTICE, "connect failed on kernel control socket (errno = %d)\n", errno); - close(sock); - return nil; - } - - /* Create policy session */ - session = [[NEPolicySession alloc] initWithSocket:sock]; - if (session == nil) { - close(sock); - } -#else //!TARGET_OS_IPHONE - session = [[NEPolicySession alloc] init]; -#endif //!TARGET_OS_IPHONE - - return session; + return [[NEPolicySession alloc] init]; } - (BOOL)isControllerReady @@ -816,9 +768,9 @@ typedef struct resolverList { resolver_list_t *resolvers = NULL; if ((dns_config->n_resolver > 0) && (dns_config->resolver != NULL)) { - int a = 0; - int b = 0; - int c = 0; + uint32_t a = 0; + uint32_t b = 0; + uint32_t c = 0; resolvers = calloc(1, sizeof(resolver_list_t)); for (int i = 0; i < dns_config->n_resolver; i++) { @@ -1208,7 +1160,7 @@ typedef struct resolverList { // For default resolvers, their name will be '_defaultDNS', '_defaultDNS #2' so on... if (resolvers->n_default_resolvers > 0 && resolvers->default_resolvers != NULL) { - for (int i = 0; i < resolvers->n_default_resolvers; i++) { + for (uint32_t i = 0; i < resolvers->n_default_resolvers; i++) { dns_resolver_t *default_resolver = resolvers->default_resolvers[i]; NSData * data; id dnsAgent; @@ -1252,7 +1204,7 @@ typedef struct resolverList { agentSubType:kAgentSubTypeMulticast]; if (resolvers->n_multicast_resolvers > 0 && resolvers->multicast_resolvers != NULL) { - for (int i = 0; i < resolvers->n_multicast_resolvers; i++) { + for (uint32_t i = 0; i < resolvers->n_multicast_resolvers; i++) { dns_resolver_t * multicast_resolver = resolvers->multicast_resolvers[i]; id dnsAgent; NSString * resolverName; @@ -1296,7 +1248,7 @@ typedef struct resolverList { agentSubType:kAgentSubTypePrivate]; if (resolvers->n_private_resolvers > 0 && resolvers->private_resolvers != NULL) { - for (int i = 0; i < resolvers->n_private_resolvers; i++) { + for (uint32_t i = 0; i < resolvers->n_private_resolvers; i++) { dns_resolver_t * private_resolver = resolvers->private_resolvers[i]; id dnsAgent; NSString * resolverName; @@ -1337,7 +1289,7 @@ typedef struct resolverList { [self freeResolverList:resolvers]; } -- (void)processScopedDNSResolvers:(dns_config_t *)dns_config; +- (void)processScopedDNSResolvers:(dns_config_t *)dns_config { NSMutableArray * old_intf_list; old_intf_list = [self getAgentList:self.floatingDNSAgentList @@ -1350,13 +1302,13 @@ typedef struct resolverList { NSData * data; id dnsAgent; NSUInteger idx; - char * if_name; + const char * if_name; NSString * ns_if_name; NSString * ns_if_name_with_prefix; dns_resolver_t * resolver; resolver = dns_config->scoped_resolver[i]; - if_name = if_indextoname(resolver->if_index, buf); + if_name = my_if_indextoname(resolver->if_index, buf); if (if_name) { ns_if_name = @(if_name); ns_if_name_with_prefix = [NSString stringWithFormat:@"%s%@", prefixForInterfaceName, ns_if_name]; @@ -1395,7 +1347,7 @@ typedef struct resolverList { [self deleteAgentList:self.floatingDNSAgentList list:old_intf_list]; } -- (void)processServiceSpecificDNSResolvers:(dns_config_t *)dns_config; +- (void)processServiceSpecificDNSResolvers:(dns_config_t *)dns_config { NSMutableArray * old_service_list; old_service_list = [self getAgentList:self.floatingDNSAgentList @@ -1949,7 +1901,7 @@ done: /* Add a policy if there is a valid type. If POLICY_TYPE_NO_POLICY, then ignore policies. * POLICY_TYPE_NO_POLICY will be set for service-specific agents, in which case we rely on * service owners to install custom policies to point at the agents. */ - if (policyType >= NEPolicyResultTypeNone) { + if (policyType >= NEPolicyConditionTypeNone) { BOOL useControlPolicySession = NO; if (subtype == kAgentSubTypeGlobal) { /* Policies for a Global scoped agents are at "control" level */ @@ -2125,8 +2077,16 @@ done: if ([globalProxyAgentList count] == 0 && [globalDNSAgentList count] == 0) { - [self.controlPolicySession removeAllPolicies]; - [self.controlPolicySession apply]; + ok = [self.controlPolicySession removeAllPolicies]; + if (!ok) { + SC_log(LOG_ERR, "Could not remove policies for agent %@", [agent getAgentName]); + } + + ok = [self.controlPolicySession apply]; + if (!ok) { + SC_log(LOG_ERR, "Could not apply policy change for agent %@", [agent getAgentName]); + } + self.controlPolicySession = nil; SC_log(LOG_NOTICE, "Closed control policy session"); } diff --git a/Plugins/IPMonitor/dns-configuration.c b/Plugins/IPMonitor/dns-configuration.c index cb92244..b958f11 100644 --- a/Plugins/IPMonitor/dns-configuration.c +++ b/Plugins/IPMonitor/dns-configuration.c @@ -56,9 +56,10 @@ extern uint32_t notify_monitor_file(int token, const char *name, int flags); #include "dns-configuration.h" #include -#include "dnsinfo_private.h" -#include "dnsinfo_internal.h" #include "dnsinfo_create.h" +#include "dnsinfo_internal.h" +#include "dnsinfo_logging.h" +#include "dnsinfo_private.h" #include "dnsinfo_server.h" #include @@ -113,6 +114,7 @@ dns_resolver_flags_service(CFDictionaryRef service, uint32_t resolver_flags) static void add_dns_resolver_flags(const void *key, const void *value, void *context) { +#pragma unused(key) CFDictionaryRef service = (CFDictionaryRef)value; // CFStringRef serviceID = (CFStringRef)key; uint32_t *resolver_flags = (uint32_t *)context; @@ -616,6 +618,7 @@ add_private_resolvers(CFMutableArrayRef resolvers, CFArrayRef privateResolvers) static CFComparisonResult compareBySearchOrder(const void *val1, const void *val2, void *context) { +#pragma unused(context) CFDictionaryRef dns1 = (CFDictionaryRef)val1; CFDictionaryRef dns2 = (CFDictionaryRef)val2; CFNumberRef num1; @@ -664,10 +667,10 @@ extract_search_domains(CFMutableDictionaryRef defaultDomain, CFArrayRef suppleme uint32_t defaultOrder = DEFAULT_SEARCH_ORDER; CFArrayRef defaultSearchDomains = NULL; CFIndex defaultSearchIndex = 0; - CFIndex i; CFMutableArrayRef mySearchDomains; CFMutableArrayRef mySupplemental = NULL; CFIndex n_supplemental; + CFStringRef trimmedDomainName; mySearchDomains = CFArrayCreateMutable(NULL, 0, &kCFTypeArrayCallBacks); @@ -689,7 +692,7 @@ extract_search_domains(CFMutableDictionaryRef defaultDomain, CFArrayRef suppleme CFIndex n_search; n_search = CFArrayGetCount(defaultSearchDomains); - for (i = 0; i < n_search; i++) { + for (int i = 0; i < n_search; i++) { CFStringRef search; search = CFArrayGetValueAtIndex(defaultSearchDomains, i); @@ -700,18 +703,28 @@ extract_search_domains(CFMutableDictionaryRef defaultDomain, CFArrayRef suppleme } } } else { - defaultDomainName = _SC_trimDomain(defaultDomainName); - if (defaultDomainName != NULL) { + trimmedDomainName = _SC_trimDomain(defaultDomainName); +#ifdef PERFORM_DOMAIN_EXPANSION + /* + * With BIND 4.8.3 (and earlier) resolvers, the default search list included + * the default domain and each of its parent domains with two or more labels. + */ + if ((trimmedDomainName != NULL) && + CFStringHasSuffix(defaultDomainName, CFSTR("."))) { + // if "domain" name is fully qualified + CFArrayAppendValue(mySearchDomains, trimmedDomainName); + CFRelease(trimmedDomainName); + } else if (trimmedDomainName != NULL) { char *domain; int domain_parts = 1; char *dp; const int ndots = 1; - domain = _SC_cfstring_to_cstring(defaultDomainName, + domain = _SC_cfstring_to_cstring(trimmedDomainName, NULL, 0, kCFStringEncodingUTF8); - CFRelease(defaultDomainName); + CFRelease(trimmedDomainName); // count domain parts for (dp = domain; *dp != '\0'; dp++) { @@ -721,7 +734,6 @@ extract_search_domains(CFMutableDictionaryRef defaultDomain, CFArrayRef suppleme } // move "domain" to "search" list (and expand as needed) - i = LOCALDOMAINPARTS; dp = domain; do { CFStringRef search; @@ -738,9 +750,19 @@ extract_search_domains(CFMutableDictionaryRef defaultDomain, CFArrayRef suppleme } dp = strchr(dp, '.') + 1; - } while (++i <= (domain_parts - ndots)); + } while (domain_parts-- > 2); CFAllocatorDeallocate(NULL, domain); } +#else // PERFORM_DOMAIN_EXPANSION + /* + * With BIND 4.9.3 (and later) resolvers, the default search list included + * just the default domain. + */ + if (trimmedDomainName != NULL) { + CFArrayAppendValue(mySearchDomains, trimmedDomainName); + CFRelease(trimmedDomainName); + } +#endif // PERFORM_DOMAIN_EXPANSION } // add any supplemental "domain" names to the search list @@ -753,7 +775,7 @@ extract_search_domains(CFMutableDictionaryRef defaultDomain, CFArrayRef suppleme NULL); supplemental = mySupplemental; } - for (i = 0; i < n_supplemental; i++) { + for (int i = 0; i < n_supplemental; i++) { CFDictionaryRef dns; CFIndex domainIndex; int noSearch; @@ -1025,6 +1047,7 @@ add_service_specific_resolvers(CFMutableArrayRef resolvers, CFDictionaryRef serv uint32_t newFlags = 0; CFDictionaryRef service = vals[i]; CFStringRef serviceID = keys[i]; + CFArrayRef searchDomains; dns = CFDictionaryGetValue(service, kSCEntNetDNS); if (!isA_CFDictionary(dns)) { @@ -1046,33 +1069,45 @@ add_service_specific_resolvers(CFMutableArrayRef resolvers, CFDictionaryRef serv newDNS = CFDictionaryCreateMutableCopy(NULL, 0, dns); + // add "Request A/AAAA query" flag(s) + newFlags |= DNS_RESOLVER_FLAGS_REQUEST_ALL_RECORDS; + + // set search list + searchDomains = extract_search_domains(newDNS, NULL); + if (searchDomains != NULL) { + CFDictionarySetValue(newDNS, kSCPropNetDNSSearchDomains, searchDomains); + CFRelease(searchDomains); + searchDomains = NULL; + } + + CFDictionaryRemoveValue(newDNS, kSCPropNetDNSSupplementalMatchDomains); + CFDictionaryRemoveValue(newDNS, kSCPropNetDNSSupplementalMatchOrders); + if (CFDictionaryContainsKey(newDNS, kSCPropInterfaceName)) { - CFArrayRef searchDomains; + CFMutableDictionaryRef interfaceScopedDNS; + uint32_t interfaceScopedFlags; - // set "scoped" configuration flag - newFlags |= DNS_RESOLVER_FLAGS_SCOPED; + // The dictionary has an interface, so add a interface-scoped resolver CFDictionarySetValue(newDNS, DNS_CONFIGURATION_SCOPED_QUERY_KEY, kCFBooleanTrue); - CFDictionaryRemoveValue(newDNS, kSCPropNetDNSServiceIdentifier); - // set search list - searchDomains = extract_search_domains(newDNS, NULL); - if (searchDomains != NULL) { - CFDictionarySetValue(newDNS, kSCPropNetDNSSearchDomains, searchDomains); - CFRelease(searchDomains); - } - } else { - // set "service specific" configuration flag - newFlags |= DNS_RESOLVER_FLAGS_SERVICE_SPECIFIC; - } + interfaceScopedDNS = CFDictionaryCreateMutableCopy(NULL, 0, newDNS); + interfaceScopedFlags = newFlags; - // add "Request A/AAAA query" flag(s) - newFlags |= DNS_RESOLVER_FLAGS_REQUEST_ALL_RECORDS; + // set "scoped" configuration flag + interfaceScopedFlags |= DNS_RESOLVER_FLAGS_SCOPED; + merge_configuration_flags(interfaceScopedDNS, interfaceScopedFlags); - merge_configuration_flags(newDNS, newFlags); + CFDictionaryRemoveValue(interfaceScopedDNS, kSCPropNetDNSServiceIdentifier); - CFDictionaryRemoveValue(newDNS, kSCPropNetDNSSupplementalMatchDomains); - CFDictionaryRemoveValue(newDNS, kSCPropNetDNSSupplementalMatchOrders); + add_resolver_signature(interfaceScopedDNS, "Service", serviceID, 0); + add_resolver(resolvers, interfaceScopedDNS); + CFRelease(interfaceScopedDNS); + } + + // set "service specific" configuration flag + newFlags |= DNS_RESOLVER_FLAGS_SERVICE_SPECIFIC; + merge_configuration_flags(newDNS, newFlags); add_resolver_signature(newDNS, "Service", serviceID, 0); add_resolver(resolvers, newDNS); @@ -1182,17 +1217,20 @@ create_resolver(CFDictionaryRef dns) int if_index; if (CFNumberGetValue(num, kCFNumberIntType, &if_index)) { - char if_name[IFNAMSIZ]; - - _dns_resolver_set_if_index(&_resolver, if_index); - - if ((if_index != 0) && - (my_if_indextoname(if_index, if_name) != NULL)) { - targetInterface = CFStringCreateWithCString(NULL, - if_name, - kCFStringEncodingASCII); - targetInterfaceIndex = if_index; + char buf[IFNAMSIZ]; + const char *if_name = NULL; + + if (if_index != 0) { + if_name = my_if_indextoname(if_index, buf); + if (if_name != NULL) { + targetInterface = CFStringCreateWithCString(NULL, + if_name, + kCFStringEncodingASCII); + targetInterfaceIndex = if_index; + } } + + _dns_resolver_set_if_index(&_resolver, if_index, if_name); } } @@ -1518,7 +1556,7 @@ dns_configuration_set(CFDictionaryRef defaultResolver, CFArrayRef multicastResolvers, CFArrayRef privateResolvers) { - dns_create_config_t _config; + dns_create_config_t dns_create_config; Boolean changed = FALSE; CFIndex i; CFMutableDictionaryRef myDefault; @@ -1620,7 +1658,7 @@ dns_configuration_set(CFDictionaryRef defaultResolver, /* * if no default and no supplemental/scoped resolvers */ - _config = NULL; + dns_create_config = NULL; } else { uint32_t default_resolver_flags = 0; Boolean have_default_flags = FALSE; @@ -1628,7 +1666,7 @@ dns_configuration_set(CFDictionaryRef defaultResolver, /* * if default and/or supplemental/scoped resolvers are defined */ - _config = _dns_configuration_create(); + dns_create_config = _dns_configuration_create(); for (i = 0; i < n_resolvers; i++) { Boolean merge_default_flags; @@ -1654,7 +1692,7 @@ dns_configuration_set(CFDictionaryRef defaultResolver, } _resolver = create_resolver(resolver); - _dns_configuration_add_resolver(&_config, _resolver); + _dns_configuration_add_resolver(&dns_create_config, _resolver); _dns_resolver_free(&_resolver); if (merge_default_flags) { @@ -1666,40 +1704,43 @@ dns_configuration_set(CFDictionaryRef defaultResolver, // add flatfile resolvers _dnsinfo_flatfile_set_flags(default_resolver_flags); - _dnsinfo_flatfile_add_resolvers(&_config); + _dnsinfo_flatfile_add_resolvers(&dns_create_config); #endif // !TARGET_OS_IPHONE } // check if the configuration changed - _dns_configuration_signature(&_config, signature, sizeof(signature)); + _dns_configuration_signature(&dns_create_config, signature, sizeof(signature)); if (bcmp(signature, signature_last, sizeof(signature)) != 0) { // save [new] signature bcopy(signature, signature_last, sizeof(signature)); my_log(LOG_INFO, "Updating DNS configuration"); - if (_config != NULL) { - uint8_t *buf; - dns_config_t *config; - _dns_config_buf_t *config_buf; - uint32_t n_config; - uint32_t n_padding; - - config_buf = (_dns_config_buf_t *)_config; - n_config = sizeof(_dns_config_buf_t) + ntohl(config_buf->n_attribute); - n_padding = ntohl(config_buf->n_padding); - buf = malloc(n_config + n_padding); - bcopy((void *)config_buf, buf, n_config); - bzero(&buf[n_config], n_padding); - /* ALIGN: cast okay since _dns_config_buf_t is int aligned */ - config = _dns_configuration_expand_config((_dns_config_buf_t *)(void *)buf); - _dns_configuration_log(config, TRUE); - free(buf); + if (dns_create_config != NULL) { + dns_config_t *dns_config = NULL; + _dns_config_buf_t *dns_config_buf; + size_t n; + + n = sizeof(_dns_config_buf_t); + n += ntohl(((_dns_config_buf_t *)dns_create_config)->n_attribute); + dns_config_buf = _dns_configuration_buffer_create((void *)dns_create_config, n); + if (dns_config_buf != NULL) { + dns_config = _dns_configuration_buffer_expand(dns_config_buf); + if (dns_config == NULL) { + // if we were unable to expand the configuration + _dns_configuration_buffer_free(&dns_config_buf); + } + } + + if (dns_config != NULL) { + _dns_configuration_log(dns_config, TRUE, NULL); + free(dns_config); + } } else { my_log(LOG_INFO, "*** No DNS configuration"); } #ifndef MAIN // save [new] configuration - if (!_dns_configuration_store(&_config)) { + if (!_dns_configuration_store(&dns_create_config)) { my_log(LOG_ERR, "could not store configuration"); } #endif // MAIN @@ -1707,7 +1748,9 @@ dns_configuration_set(CFDictionaryRef defaultResolver, changed = TRUE; } - if (_config != NULL) _dns_configuration_free(&_config); + if (dns_create_config != NULL) { + _dns_configuration_free(&dns_create_config); + } CFRelease(resolvers); return changed; @@ -1721,6 +1764,10 @@ static SCDynamicStoreCallBack dns_configuration_callout; static void dns_configuration_changed(CFMachPortRef port, void *msg, CFIndex size, void *info) { +#pragma unused(port) +#pragma unused(msg) +#pragma unused(size) +#pragma unused(info) os_activity_t activity; static const CFStringRef key = CFSTR(_PATH_RESOLVER_DIR); CFArrayRef keys; diff --git a/Plugins/IPMonitor/ip_plugin.c b/Plugins/IPMonitor/ip_plugin.c index 413217f..eeec2c2 100644 --- a/Plugins/IPMonitor/ip_plugin.c +++ b/Plugins/IPMonitor/ip_plugin.c @@ -95,6 +95,8 @@ #include #include +#include "ip_plugin.h" + #include #include #include @@ -112,14 +114,19 @@ #include #include "network_state_information_priv.h" +#include "network_state_information_logging.h" #include "network_information_server.h" #include -#include "ip_plugin.h" #if !TARGET_OS_SIMULATOR #include "set-hostname.h" #endif /* !TARGET_OS_SIMULATOR */ #include "dns-configuration.h" + +#if !TARGET_OS_SIMULATOR +#include "nat64-configuration.h" +#endif /* !TARGET_OS_SIMULATOR */ + #include "proxy-configuration.h" #if !TARGET_OS_SIMULATOR @@ -150,6 +157,8 @@ enum { typedef unsigned int IFIndex; +static dispatch_queue_t __network_change_queue(); + #pragma mark - #pragma mark Logging @@ -178,54 +187,80 @@ __log_IPMonitor() static struct if_nameindex * S_if_nameindex_cache; +static dispatch_queue_t +__my_if_nametoindex_queue() +{ + static dispatch_once_t once; + static dispatch_queue_t q; + + dispatch_once(&once, ^{ + q = dispatch_queue_create("my_if_nametoindex queue", NULL); + }); + + return q; +} + __private_extern__ IFIndex my_if_nametoindex(const char * ifname) { - IFIndex idx = 0; - struct if_nameindex * scan; + __block IFIndex idx = 0; - if (S_if_nameindex_cache == NULL) { - return (if_nametoindex(ifname)); - } - for (scan = S_if_nameindex_cache; - scan->if_index != 0 && scan->if_name != NULL; - scan++) { - if (strcmp(scan->if_name, ifname) == 0) { - idx = scan->if_index; - break; + dispatch_sync(__my_if_nametoindex_queue(), ^{ + struct if_nameindex * scan; + + if (S_if_nameindex_cache == NULL) { + idx = if_nametoindex(ifname); + return; } - } + for (scan = S_if_nameindex_cache; + scan->if_index != 0 && scan->if_name != NULL; + scan++) { + if (strcmp(scan->if_name, ifname) == 0) { + idx = scan->if_index; + break; + } + } + }); + return (idx); } __private_extern__ const char * my_if_indextoname(IFIndex idx, char if_name[IFNAMSIZ]) { - const char * name = NULL; - struct if_nameindex * scan; + __block const char * name = NULL; - if (S_if_nameindex_cache == NULL) { - return (if_indextoname(idx, if_name)); - } - for (scan = S_if_nameindex_cache; - scan->if_index != 0 && scan->if_name != NULL; - scan++) { - if (scan->if_index == idx) { - name = if_name; - strlcpy(if_name, scan->if_name, IFNAMSIZ); - break; + dispatch_sync(__my_if_nametoindex_queue(), ^{ + struct if_nameindex * scan; + + if (S_if_nameindex_cache == NULL) { + name = if_indextoname(idx, if_name); + return; } - } + for (scan = S_if_nameindex_cache; + scan->if_index != 0 && scan->if_name != NULL; + scan++) { + if (scan->if_index == idx) { + name = if_name; + strlcpy(if_name, scan->if_name, IFNAMSIZ); + break; + } + } + }); + return (name); } static void my_if_freenameindex(void) { - if (S_if_nameindex_cache != NULL) { - if_freenameindex(S_if_nameindex_cache); - S_if_nameindex_cache = NULL; - } + dispatch_sync(__my_if_nametoindex_queue(), ^{ + if (S_if_nameindex_cache != NULL) { + if_freenameindex(S_if_nameindex_cache); + S_if_nameindex_cache = NULL; + } + }); + return; } @@ -233,7 +268,10 @@ static void my_if_nameindex(void) { my_if_freenameindex(); - S_if_nameindex_cache = if_nameindex(); + dispatch_sync(__my_if_nametoindex_queue(), ^{ + S_if_nameindex_cache = if_nameindex(); + }); + return; } @@ -359,8 +397,6 @@ lo0_ifindex(void) #define IP_CH(ip) ((u_char *)(ip)) #define IP_LIST(ip) IP_CH(ip)[0],IP_CH(ip)[1],IP_CH(ip)[2],IP_CH(ip)[3] -static SCLoggerRef S_IPMonitor_logger; - static Boolean S_bundle_logging_verbose; /* @@ -487,28 +523,8 @@ ElectionResultsComputeSize(unsigned int n) } /* - * Type: Rank - * Purpose: - * A 32-bit value to encode the relative rank of a service. - * - * The top 8 bits are used to hold the rank assertion (first, default, last, - * never, scoped); - * - * The bottom 24 bits are used to store the service index (i.e. the - * position within the service order array). + * Rank support */ -#define RANK_ASSERTION_MAKE(r) ((Rank)(r) << 24) -#define kRankAssertionFirst RANK_ASSERTION_MAKE(0) -#define kRankAssertionDefault RANK_ASSERTION_MAKE(1) -#define kRankAssertionLast RANK_ASSERTION_MAKE(2) -#define kRankAssertionNever RANK_ASSERTION_MAKE(3) -#define kRankAssertionScoped RANK_ASSERTION_MAKE(4) -#define kRankAssertionMask RANK_ASSERTION_MAKE(0xff) -#define RANK_ASSERTION_MASK(r) ((Rank)(r) & kRankAssertionMask) -#define RANK_ASSERTION_GET(r) ((Rank)(r) >> 24) -#define RANK_INDEX_MAKE(r) ((Rank)(r)) -#define kRankIndexMask RANK_INDEX_MAKE(0xffffff) -#define RANK_INDEX_MASK(r) ((Rank)(r) & kRankIndexMask) static __inline__ Rank RankMake(uint32_t service_index, Rank primary_rank) @@ -543,7 +559,6 @@ InterfaceRankGetRankAssertion(CFNumberRef rank_cf, Boolean * ret_is_set) static Rank PrimaryRankGetRankAssertion(CFStringRef rank_str, Boolean * is_set) { - int i; struct { const CFStringRef * name; Rank rank_assertion; @@ -555,7 +570,7 @@ PrimaryRankGetRankAssertion(CFStringRef rank_str, Boolean * is_set) }; if (rank_str != NULL) { - for (i = 0; i < countof(values); i++) { + for (size_t i = 0; i < countof(values); i++) { if (CFEqual(rank_str, *(values[i].name))) { if (is_set != NULL) { *is_set = TRUE; @@ -615,7 +630,6 @@ static CFStringRef S_private_resolvers = NULL; #if !TARGET_OS_SIMULATOR static IPv4RouteListRef S_ipv4_routelist = NULL; static IPv6RouteListRef S_ipv6_routelist = NULL; - #endif /* !TARGET_OS_SIMULATOR */ static boolean_t S_append_state = FALSE; @@ -624,6 +638,12 @@ static CFDictionaryRef S_dns_dict = NULL; static Boolean S_dnsinfo_synced = TRUE; +#if !TARGET_OS_SIMULATOR +// Note: access should be gated with __network_change_queue() +static CFMutableSetRef S_nat64_prefix_changes = NULL; +static CFMutableSetRef S_nat64_prefix_requests = NULL; +#endif /* !TARGET_OS_SIMULATOR */ + static nwi_state_t S_nwi_state = NULL; static Boolean S_nwi_synced = TRUE; @@ -637,6 +657,7 @@ static uint32_t S_network_change_needed = 0; #if !TARGET_OS_IPHONE #define NETWORK_CHANGE_SMB 1<<3 #endif /* !TARGET_OS_IPHONE */ +#define NETWORK_CHANGE_NAT64 1<<4 static struct timeval S_network_change_start; static Boolean S_network_change_timeout = FALSE; static dispatch_source_t S_network_change_timer = NULL; @@ -904,86 +925,6 @@ keyChangeListApplyToStore(keyChangeListRef keys, SCDynamicStoreRef session) return; } -static void -S_nwi_ifstate_dump(nwi_ifstate_t ifstate, int i) -{ - const char * addr_str; - void * address; - char ntopbuf[INET6_ADDRSTRLEN]; - char vpn_ntopbuf[INET6_ADDRSTRLEN]; - const struct sockaddr * vpn_addr; - - address = nwi_ifstate_get_address(ifstate); - addr_str = inet_ntop(ifstate->af, address, ntopbuf, sizeof(ntopbuf)); - vpn_addr = nwi_ifstate_get_vpn_server(ifstate); - if (vpn_addr != NULL) { - _SC_sockaddr_to_string(nwi_ifstate_get_vpn_server(ifstate), - vpn_ntopbuf, - sizeof(vpn_ntopbuf)); - } - my_log(LOG_INFO, - " [%d]: %s%s%s%s rank 0x%x iaddr %s%s%s reach_flags 0x%x", - i, ifstate->ifname, - nwi_ifstate_get_diff_str(ifstate), - (ifstate->flags & NWI_IFSTATE_FLAGS_HAS_DNS) != 0 - ? " dns" : "", - (ifstate->flags & NWI_IFSTATE_FLAGS_NOT_IN_LIST) != 0 - ? " never" : "", - ifstate->rank, - addr_str, - (vpn_addr != NULL) ? " vpn_server_addr: " : "", - (vpn_addr != NULL) ? vpn_ntopbuf : "", - ifstate->reach_flags); - return; -} - -static void -S_nwi_state_dump(nwi_state_t state) -{ - int i; - nwi_ifstate_t scan; - - if (state == NULL) { - my_log(LOG_INFO, "nwi_state = "); - return; - } - my_log(LOG_INFO, - "nwi_state = { " - "gen=%llu size=%lu #v4=%u #v6=%u " - "reach_flags=(v4=0x%x, v6=0x%x) }", - state->generation_count, - nwi_state_size(state), - state->ipv4_count, - state->ipv6_count, - nwi_state_get_reachability_flags(state, AF_INET), - nwi_state_get_reachability_flags(state, AF_INET6)); - if (state->ipv4_count) { - my_log(LOG_INFO, "IPv4:"); - for (i = 0, scan = nwi_state_ifstate_list(state, AF_INET); - i < state->ipv4_count; i++, scan++) { - S_nwi_ifstate_dump(scan, i); - } - } - if (state->ipv6_count) { - my_log(LOG_INFO, "IPv6:"); - for (i = 0, scan = nwi_state_ifstate_list(state, AF_INET6); - i < state->ipv6_count; i++, scan++) { - S_nwi_ifstate_dump(scan, i); - } - } - if (state->max_if_count) { - nwi_ifindex_t * ifindex; - - my_log(LOG_INFO, "%d interfaces:", state->if_list_count); - for (i = 0, ifindex = nwi_state_if_list(state); - i < state->if_list_count; - i++, ifindex++) { - my_log(LOG_INFO, "%s", state->ifstate_list[*ifindex].ifname); - } - } - return; -} - static boolean_t S_is_network_boot() { @@ -1114,8 +1055,25 @@ my_CFDictionaryGetArray(CFDictionaryRef dict, CFStringRef key) return (isA_CFArray(CFDictionaryGetValue(dict, key))); } +#if !TARGET_OS_SIMULATOR +static void +my_CFSetAddValue_async(dispatch_queue_t queue, CFMutableSetRef *set, CFTypeRef value) +{ + CFRetain(value); + dispatch_async(queue, ^{ + if (*set == NULL) { + *set = CFSetCreateMutable(NULL, 0, &kCFTypeSetCallBacks); + } + CFSetAddValue(*set, value); + CFRelease(value); + }); + + return; +} +#endif /* !TARGET_OS_SIMULATOR */ + static boolean_t -cfstring_to_ipvx(int family, CFStringRef str, void * addr, int addr_size) +cfstring_to_ipvx(int family, CFStringRef str, void * addr, size_t addr_size) { char buf[128]; @@ -2928,7 +2886,7 @@ IPv4RouteListCreateWithDictionary(IPv4RouteListRef routes, r->prefix_length = IPV4_ROUTE_ALL_BITS_SET; r->ifindex = ifindex; r->ifa = addr; - r->rank = primary_rank; + r->rank = rank; r++; /* add multicast route (rdar://problem/26457121) */ @@ -2940,7 +2898,7 @@ IPv4RouteListCreateWithDictionary(IPv4RouteListRef routes, r->prefix_length = PREFIX_LENGTH_IN_CLASSD; r->ifindex = ifindex; r->ifa = addr; - r->rank = primary_rank; + r->rank = rank; r++; } @@ -3058,9 +3016,7 @@ in6_len2mask(struct in6_addr * mask, int len) static void in6_maskaddr(struct in6_addr * addr, const struct in6_addr * mask) { - int i; - - for (i = 0; i < sizeof(addr->s6_addr); i++) { + for (size_t i = 0; i < sizeof(addr->s6_addr); i++) { addr->s6_addr[i] &= mask->s6_addr[i]; } return; @@ -3861,6 +3817,7 @@ service_dict_copy(CFStringRef serviceID) return (service_dict); } + __private_extern__ boolean_t service_is_scoped_only(CFDictionaryRef service_dict) { @@ -4017,6 +3974,35 @@ service_dict_get(CFStringRef serviceID, CFStringRef entity) return (CFDictionaryGetValue(service_dict, entity)); } +#if !TARGET_OS_SIMULATOR +static CFStringRef +service_copy_interface(CFStringRef serviceID, CFDictionaryRef new_service) +{ + CFDictionaryRef dict; + CFStringRef interface = NULL; + + if (new_service != NULL) { + interface = ipdict_get_ifname(new_service); + } + if (interface == NULL) { + dict = service_dict_get(serviceID, kSCEntNetIPv4); + if (dict != NULL) { + interface = ipdict_get_ifname(dict); + } + } + if (interface == NULL) { + dict = service_dict_get(serviceID, kSCEntNetIPv6); + if (dict != NULL) { + interface = ipdict_get_ifname(dict); + } + } + if (interface != NULL) { + CFRetain(interface); + } + return interface; +} +#endif /* !TARGET_OS_SIMULATOR */ + #ifndef kSCPropNetHostname #define kSCPropNetHostname CFSTR("Hostname") #endif @@ -4420,6 +4406,7 @@ static boolean_t get_ipv4_changes(CFStringRef serviceID, CFDictionaryRef state_dict, CFDictionaryRef setup_dict, CFDictionaryRef info) { +#pragma unused(info) CFDictionaryRef dict = NULL; boolean_t changed = FALSE; CFNumberRef rank_assertion = NULL; @@ -4446,33 +4433,58 @@ get_ipv4_changes(CFStringRef serviceID, CFDictionaryRef state_dict, return (changed); } + static boolean_t get_ipv6_changes(CFStringRef serviceID, CFDictionaryRef state_dict, CFDictionaryRef setup_dict, CFDictionaryRef info) { +#pragma unused(info) CFDictionaryRef dict = NULL; boolean_t changed = FALSE; +#if !TARGET_OS_SIMULATOR + CFStringRef interface; +#endif /* !TARGET_OS_SIMULATOR */ CFNumberRef rank_assertion = NULL; CFDictionaryRef service_options; if (state_dict == NULL) { + // if no State: goto done; } + service_options = service_dict_get(serviceID, kSCEntNetService); if (service_options != NULL) { rank_assertion = CFDictionaryGetValue(service_options, kServiceOptionRankAssertion); } + dict = IPDictCreate(AF_INET6, state_dict, setup_dict, rank_assertion); done: + +#if !TARGET_OS_SIMULATOR + interface = service_copy_interface(serviceID, dict); +#endif /* !TARGET_OS_SIMULATOR */ + #if !TARGET_OS_SIMULATOR ipv6_service_update_router(serviceID, dict); -#endif /* !TARGET_OS_SIMULATOR */ +#endif /* !TARGET_OS_SIMULATOR */ + changed = service_dict_set(serviceID, kSCEntNetIPv6, dict); + +#if !TARGET_OS_SIMULATOR + if (interface != NULL) { + if (changed) { + // IPv6 configuration changed for this interface, poke NAT64 + my_CFSetAddValue_async(__network_change_queue(), &S_nat64_prefix_changes, interface); + } + CFRelease(interface); + } +#endif /* !TARGET_OS_SIMULATOR */ + if (dict == NULL) { - /* clean up the rank too */ + /* service removed, clean up the rank too */ CFDictionaryRemoveValue(S_ipv6_service_rank_dict, serviceID); } my_CFRelease(&dict); @@ -4741,7 +4753,6 @@ get_dns_changes(CFStringRef serviceID, CFDictionaryRef state_dict, CFStringRef interface = NULL; CFDictionaryRef ipv4; CFDictionaryRef ipv6; - int i; const struct { CFStringRef key; uint32_t flags; @@ -4762,7 +4773,7 @@ get_dns_changes(CFStringRef serviceID, CFDictionaryRef state_dict, kSCPropNetDNSServiceIdentifier, kSCPropNetDNSSupplementalMatchDomainsNoSearch, }; - Boolean trust_state = FALSE; + Boolean trust_state = FALSE; if ((state_dict == NULL) && (setup_dict == NULL)) { /* there is no DNS content */ @@ -4839,7 +4850,7 @@ get_dns_changes(CFStringRef serviceID, CFDictionaryRef state_dict, interface); } - for (i = 0; i < countof(merge_list); i++) { + for (size_t i = 0; i < countof(merge_list); i++) { merge_array_prop(new_dict, merge_list[i].key, state_dict, @@ -4848,7 +4859,7 @@ get_dns_changes(CFStringRef serviceID, CFDictionaryRef state_dict, merge_list[i].append); } - for (i = 0; i < countof(pick_list); i++) { + for (size_t i = 0; i < countof(pick_list); i++) { pick_prop(new_dict, pick_list[i], state_dict, @@ -4914,7 +4925,25 @@ get_dns_changes(CFStringRef serviceID, CFDictionaryRef state_dict, } done: + +#if !TARGET_OS_SIMULATOR + if (interface != NULL) { + CFRetain(interface); + } +#endif /* !TARGET_OS_SIMULATOR */ + changed = service_dict_set(serviceID, kSCEntNetDNS, new_dict); + +#if !TARGET_OS_SIMULATOR + if (interface != NULL) { + if (changed) { + // DNS configuration changed for this interface, poke NAT64 + my_CFSetAddValue_async(__network_change_queue(), &S_nat64_prefix_changes, interface); + } + CFRelease(interface); + } +#endif /* !TARGET_OS_SIMULATOR */ + my_CFRelease(&new_dict); return (changed); } @@ -5050,7 +5079,6 @@ get_proxies_changes(CFStringRef serviceID, CFDictionaryRef state_dict, } if ((setup_dict != NULL) && (state_dict != NULL)) { - CFIndex i; CFMutableDictionaryRef setup_copy; /* @@ -5062,7 +5090,7 @@ get_proxies_changes(CFStringRef serviceID, CFDictionaryRef state_dict, * the "Setup:" keys and others from the "State:" keys. */ new_dict = CFDictionaryCreateMutableCopy(NULL, 0, state_dict); - for (i = 0; i < countof(merge_list); i++) { + for (size_t i = 0; i < countof(merge_list); i++) { merge_array_prop(new_dict, merge_list[i].key, state_dict, @@ -5072,7 +5100,7 @@ get_proxies_changes(CFStringRef serviceID, CFDictionaryRef state_dict, } setup_copy = CFDictionaryCreateMutableCopy(NULL, 0, setup_dict); - for (i = 0; i < countof(pick_list); i++) { + for (size_t i = 0; i < countof(pick_list); i++) { if (CFDictionaryContainsKey(setup_copy, pick_list[i].key1)) { /* * if a "Setup:" enabled key has been provided than we want to @@ -5229,8 +5257,8 @@ static boolean_t get_smb_changes(CFStringRef serviceID, CFDictionaryRef state_dict, CFDictionaryRef setup_dict, CFDictionaryRef info) { +#pragma unused(info) boolean_t changed = FALSE; - int i; CFMutableDictionaryRef new_dict = NULL; const CFStringRef pick_list[] = { kSCPropNetSMBNetBIOSName, @@ -5261,7 +5289,7 @@ get_smb_changes(CFStringRef serviceID, CFDictionaryRef state_dict, setup_dict, 0, FALSE); - for (i = 0; i < countof(pick_list); i++) { + for (size_t i = 0; i < countof(pick_list); i++) { pick_prop(new_dict, pick_list[i], state_dict, @@ -5320,9 +5348,8 @@ get_transient_status_changes(CFStringRef serviceID, CFDictionaryRef services_info) { boolean_t changed = FALSE; - int i; - for (i = 0; i < countof(transientServiceInfo); i++) { + for (size_t i = 0; i < countof(transientServiceInfo); i++) { CFDictionaryRef dict; CFNumberRef status = NULL; CFMutableDictionaryRef ts_dict = NULL; @@ -5447,6 +5474,7 @@ get_rank_changes(CFStringRef serviceID, CFDictionaryRef state_options, CFDictionaryRef setup_options, CFDictionaryRef services_info) { boolean_t changed = FALSE; + CFStringRef interface; boolean_t ip_is_coupled = FALSE; CFMutableDictionaryRef new_dict = NULL; Rank rank_assertion = kRankAssertionDefault; @@ -5524,12 +5552,10 @@ get_rank_changes(CFStringRef serviceID, CFDictionaryRef state_options, } } - if (!rank_assertion_is_set) { - /* check for a rank assertion on the interface */ - CFStringRef interface; - - interface = services_info_get_interface(services_info, serviceID); - if (interface != NULL) { + interface = services_info_get_interface(services_info, serviceID); + if (interface != NULL) { + if (!rank_assertion_is_set) { + /* check for a rank assertion on the interface */ CFNumberRef if_rank = NULL; if (S_if_rank_dict != NULL) { @@ -5538,11 +5564,20 @@ get_rank_changes(CFStringRef serviceID, CFDictionaryRef state_options, rank_assertion = InterfaceRankGetRankAssertion(if_rank, &rank_assertion_is_set); +#define kNotSetString ((CFTypeRef)CFSTR("not set")) my_log(LOG_INFO, - "serviceID %@ interface %@ rank = %@", + "serviceID %@ interface %@ rank = 0x%x (%@)%s", serviceID, interface, - (if_rank != NULL) ? (CFTypeRef)if_rank : (CFTypeRef)CFSTR("Not set)")); + rank_assertion, + (if_rank != NULL) ? (CFTypeRef)if_rank : kNotSetString, + ip_is_coupled ? " [coupled]" : ""); + } + else { + my_log(LOG_INFO, + "serviceID %@ interface %@ rank = 0x%x%s", + serviceID, interface, rank_assertion, + ip_is_coupled ? " [coupled]" : ""); } } @@ -5585,10 +5620,12 @@ add_service_keys(CFStringRef serviceID, } for (i = 0; i < ENTITY_TYPES_COUNT; i++) { - key = setup_service_key(serviceID, *entityTypeNames[i]); + CFStringRef name = *entityTypeNames[i]; + + key = setup_service_key(serviceID, name); CFArrayAppendValue(keys, key); CFRelease(key); - key = state_service_key(serviceID, *entityTypeNames[i]); + key = state_service_key(serviceID, name); CFArrayAppendValue(keys, key); CFRelease(key); } @@ -5610,9 +5647,7 @@ add_service_keys(CFStringRef serviceID, static void add_transient_status_keys(CFStringRef service_id, CFMutableArrayRef patterns) { - int i; - - for (i = 0; i < countof(transientServiceInfo); i++) { + for (size_t i = 0; i < countof(transientServiceInfo); i++) { CFStringRef pattern; pattern = state_service_key(service_id, @@ -5635,9 +5670,7 @@ static const CFStringRef *reachabilitySetupKeys[] = { static void add_reachability_patterns(CFMutableArrayRef patterns) { - int i; - - for (i = 0; i < countof(reachabilitySetupKeys); i++) { + for (size_t i = 0; i < countof(reachabilitySetupKeys); i++) { CFStringRef pattern; pattern = setup_service_key(kSCCompAnyRegex, *reachabilitySetupKeys[i]); CFArrayAppendValue(patterns, pattern); @@ -5673,7 +5706,6 @@ services_info_copy(SCDynamicStoreRef session, CFArrayRef service_list) CFMutableArrayRef get_keys; CFMutableArrayRef get_patterns; CFDictionaryRef info; - CFIndex s; count = CFArrayGetCount(service_list); get_keys = CFArrayCreateMutable(NULL, 0, &kCFTypeArrayCallBacks); @@ -5683,7 +5715,7 @@ services_info_copy(SCDynamicStoreRef session, CFArrayRef service_list) CFArrayAppendValue(get_keys, S_multicast_resolvers); CFArrayAppendValue(get_keys, S_private_resolvers); - for (s = 0; s < count; s++) { + for (CFIndex s = 0; s < count; s++) { CFStringRef serviceID = CFArrayGetValueAtIndex(service_list, s); add_service_keys(serviceID, get_keys, get_patterns); @@ -5759,11 +5791,17 @@ set_dns(CFArrayRef val_search_domains, CFIndex n; SCPrint(TRUE, f, CFSTR("#\n")); - SCPrint(TRUE, f, CFSTR("# Mac OS X Notice\n")); + SCPrint(TRUE, f, CFSTR("# macOS Notice\n")); + SCPrint(TRUE, f, CFSTR("#\n")); + SCPrint(TRUE, f, CFSTR("# This file is not consulted for DNS hostname resolution, address\n")); + SCPrint(TRUE, f, CFSTR("# resolution, or the DNS query routing mechanism used by most\n")); + SCPrint(TRUE, f, CFSTR("# processes on this system.\n")); SCPrint(TRUE, f, CFSTR("#\n")); - SCPrint(TRUE, f, CFSTR("# This file is not used by the host name and address resolution\n")); - SCPrint(TRUE, f, CFSTR("# or the DNS query routing mechanisms used by most processes on\n")); - SCPrint(TRUE, f, CFSTR("# this Mac OS X system.\n")); + SCPrint(TRUE, f, CFSTR("# To view the DNS configuration used by this system, use:\n")); + SCPrint(TRUE, f, CFSTR("# scutil --dns\n")); + SCPrint(TRUE, f, CFSTR("#\n")); + SCPrint(TRUE, f, CFSTR("# SEE ALSO\n")); + SCPrint(TRUE, f, CFSTR("# dns-sd(1), scutil(8)\n")); SCPrint(TRUE, f, CFSTR("#\n")); SCPrint(TRUE, f, CFSTR("# This file is automatically generated.\n")); SCPrint(TRUE, f, CFSTR("#\n")); @@ -6060,6 +6098,7 @@ update_dns(CFDictionaryRef services_info, CFStringRef primary, keyChangeListRef keys) { +#pragma unused(services_info) Boolean changed = FALSE; CFDictionaryRef dict = NULL; @@ -6156,7 +6195,7 @@ update_nwi(nwi_state_t state) // save [new] configuration my_log(LOG_INFO, "Updating network information"); - S_nwi_state_dump(state); + _nwi_state_log(state, TRUE, NULL); if (!_nwi_state_store(state)) { my_log(LOG_ERR, "Notifying nwi_state_store failed"); @@ -6209,6 +6248,7 @@ update_smb(CFDictionaryRef services_info, CFStringRef primary, keyChangeListRef keys) { +#pragma unused(services_info) Boolean changed = FALSE; CFDictionaryRef dict = NULL; @@ -6330,7 +6370,7 @@ CollectTransientServices(const void * key, const void * value, void * context) { - int i; +#pragma unused(value) CFStringRef service = key; CFMutableArrayRef vif_setup_keys = context; @@ -6339,7 +6379,7 @@ CollectTransientServices(const void * key, return; } - for (i = 0; i < countof(transientInterfaceEntityNames); i++) { + for (size_t i = 0; i < countof(transientInterfaceEntityNames); i++) { if (CFStringHasSuffix(service, *transientInterfaceEntityNames[i])) { CFArrayAppendValue(vif_setup_keys, service); break; @@ -6578,7 +6618,6 @@ VPNAttributesGet(CFStringRef service_id, CFStringRef *server_address, int af) { - int i; CFDictionaryRef entity_dict; CFNumberRef num; CFDictionaryRef p_state = NULL; @@ -6587,8 +6626,7 @@ VPNAttributesGet(CFStringRef service_id, if (af == AF_INET) { entity_dict = service_dict_get(service_id, kSCEntNetIPv4); - } - else { + } else { entity_dict = service_dict_get(service_id, kSCEntNetIPv6); } entity_dict = ipdict_get_service(entity_dict); @@ -6596,7 +6634,7 @@ VPNAttributesGet(CFStringRef service_id, return; } - for (i = 0; i < countof(transientServiceInfo); i++) { + for (size_t i = 0; i < countof(transientServiceInfo); i++) { CFStringRef entity = *transientServiceInfo[i].entityName; p_state = service_dict_get(service_id, entity); @@ -6851,18 +6889,16 @@ ElectionResultsCopy(int af, CFArrayRef order) * but a higher ranked service has IPv4 or IPv6. */ static Boolean -ElectionResultsCandidateNeedsDemotion(ElectionResultsRef other_results, +ElectionResultsCandidateNeedsDemotion(CandidateRef other_candidate, CandidateRef candidate) { - CandidateRef other_candidate; Boolean ret = FALSE; - if (other_results == NULL + if (other_candidate == NULL || !candidate->ip_is_coupled || RANK_ASSERTION_MASK(candidate->rank) == kRankAssertionNever) { goto done; } - other_candidate = other_results->candidates; if (CFEqual(other_candidate->if_name, candidate->if_name)) { /* they are over the same interface, no need to demote */ goto done; @@ -6879,6 +6915,11 @@ ElectionResultsCandidateNeedsDemotion(ElectionResultsRef other_results, /* we're higher ranked than the other candidate, ignore */ goto done; } + if (candidate->rank == other_candidate->rank + && other_candidate->ip_is_coupled) { + /* same rank as another service that is coupled, ignore */ + goto done; + } ret = TRUE; done: @@ -6992,7 +7033,7 @@ add_reachability_flags_to_candidate(CandidateRef candidate, CFDictionaryRef serv return; } /* - * Function: ElectionResultsCopyPrimary + * Function: ElectionResultsGetPrimary * Purpose: * Use the results of the current protocol and the other protocol to * determine which service should become primary. @@ -7000,14 +7041,14 @@ add_reachability_flags_to_candidate(CandidateRef candidate, CFDictionaryRef serv * At the same time, generate the IPv4/IPv6 routing table and * the nwi_state for the protocol. */ -static CFStringRef -ElectionResultsCopyPrimary(ElectionResultsRef results, - ElectionResultsRef other_results, - nwi_state_t nwi_state, int af, - RouteListRef * ret_routes, - CFDictionaryRef services_info) -{ - CFStringRef primary = NULL; +static CandidateRef +ElectionResultsGetPrimary(ElectionResultsRef results, + CandidateRef other_candidate, + nwi_state_t nwi_state, int af, + RouteListRef * ret_routes, + CFDictionaryRef services_info) +{ + CandidateRef primary = NULL; Boolean primary_is_null = FALSE; RouteListRef routes = NULL; @@ -7045,7 +7086,7 @@ ElectionResultsCopyPrimary(ElectionResultsRef results, if (!scan->ineligible && primary == NULL && RANK_ASSERTION_MASK(scan->rank) != kRankAssertionNever) { - if (ElectionResultsCandidateNeedsDemotion(other_results, + if (ElectionResultsCandidateNeedsDemotion(other_candidate, scan)) { /* demote the service */ my_log(LOG_NOTICE, @@ -7055,7 +7096,7 @@ ElectionResultsCopyPrimary(ElectionResultsRef results, skip = TRUE; } else { - primary = CFRetain(scan->serviceID); + primary = scan; is_primary = TRUE; } } @@ -7109,7 +7150,7 @@ ElectionResultsCopyPrimary(ElectionResultsRef results, free(routes); } if (primary_is_null) { - my_CFRelease(&primary); + primary = NULL; } return (primary); } @@ -7226,19 +7267,23 @@ service_changed(CFDictionaryRef services_info, CFStringRef serviceID) services_info)) { changed |= (1 << kEntityTypeServiceOptions); } + /* update IPv4, IPv6, DNS, Proxies, SMB, ... */ for (i = 0; i < ENTITY_TYPES_COUNT; i++) { - GetEntityChangesFuncRef func = entityChangeFunc[i]; + GetEntityChangesFuncRef func; + CFStringRef name; + + func = entityChangeFunc[i]; + name = *entityTypeNames[i]; if ((*func)(serviceID, - get_service_state_entity(services_info, serviceID, - *entityTypeNames[i]), - get_service_setup_entity(services_info, serviceID, - *entityTypeNames[i]), + get_service_state_entity(services_info, serviceID, name), + get_service_setup_entity(services_info, serviceID, name), services_info)) { changed |= (1 << i); } } + /* update transient service status */ if (get_transient_status_changes(serviceID, services_info)) { changed |= (1 << kEntityTypeTransientStatus); } @@ -7488,7 +7533,7 @@ update_interface_order(nwi_state_t state, int sockfd) // Set interface order into the kernel struct if_order interface_order; interface_order.ifo_count = (uint32_t)state->if_list_count; - interface_order.ifo_ordered_indices = calloc((size_t)interface_order.ifo_count, sizeof(uint32_t)); + interface_order.ifo_ordered_indices = (mach_vm_address_t)calloc((size_t)interface_order.ifo_count, sizeof(uint32_t)); if (((uint32_t *)interface_order.ifo_ordered_indices) != NULL) { int i; nwi_ifindex_t *scan; @@ -7505,8 +7550,8 @@ update_interface_order(nwi_state_t state, int sockfd) success = TRUE; } if (((uint32_t *)interface_order.ifo_ordered_indices) != NULL) { - free(interface_order.ifo_ordered_indices); - interface_order.ifo_ordered_indices = NULL; + free((void *)interface_order.ifo_ordered_indices); + interface_order.ifo_ordered_indices = (mach_vm_address_t)NULL; } return success; @@ -7516,7 +7561,7 @@ update_interface_order(nwi_state_t state, int sockfd) #ifdef MANAGE_IF_SIGNATURE static int siocsifnetsignature(int s, const char * ifname, int af, - const uint8_t * signature, int signature_length) + const uint8_t * signature, size_t signature_length) { struct if_nsreq nsreq; @@ -7627,7 +7672,14 @@ process_nwi_changes(CFMutableStringRef log_output, boolean_t smb_changed, CFDictionaryRef old_primary_smb) { - int idx; +#ifndef MANAGE_IF_ORDER +#pragma unused(new_state) +#pragma unused(old_state) +#endif // !MANAGE_IF_ORDER +#if TARGET_OS_IPHONE +#pragma unused(smb_changed) +#pragma unused(old_primary_smb) +#endif // TARGET_OS_IPHONE if (changes_state != NULL) { const sa_family_t af_list[] = {AF_INET, AF_INET6}; @@ -7642,7 +7694,7 @@ process_nwi_changes(CFMutableStringRef log_output, } #endif /* MANAGE_IF_ORDER */ - for (idx = 0; idx < countof(af_list); idx++) { + for (size_t idx = 0; idx < countof(af_list); idx++) { int af = af_list[idx]; CFMutableStringRef changes = NULL; CFMutableStringRef primary_str = NULL; @@ -7763,6 +7815,8 @@ post_network_change_when_ready() { int status; + dispatch_assert_queue(__network_change_queue()); + if (S_network_change_needed == 0) { return; } @@ -7807,6 +7861,12 @@ post_network_change_when_ready() /* We are about to post a network change to everyone, get the agents up to date */ +#if !TARGET_OS_SIMULATOR + if ((S_network_change_needed & NETWORK_CHANGE_DNS) != 0) { + /* Setup or Update config agents */ + process_AgentMonitor_DNS(); + } +#endif //!TARGET_OS_SIMULATOR if ((S_network_change_needed & NETWORK_CHANGE_NET) != 0) { status = notify_post(_SC_NOTIFY_NETWORK_CHANGE_NWI); @@ -7817,12 +7877,6 @@ post_network_change_when_ready() } if ((S_network_change_needed & NETWORK_CHANGE_DNS) != 0) { - - -#if !TARGET_OS_SIMULATOR - /* Setup or Update config agents */ - process_AgentMonitor_DNS(); -#endif //!TARGET_OS_SIMULATOR status = notify_post(_SC_NOTIFY_NETWORK_CHANGE_DNS); if (status != NOTIFY_STATUS_OK) { my_log(LOG_ERR, @@ -7831,7 +7885,6 @@ post_network_change_when_ready() } if ((S_network_change_needed & NETWORK_CHANGE_PROXY) != 0) { - #if !TARGET_OS_SIMULATOR /* Setup or Update config agents */ process_AgentMonitor_Proxy(); @@ -7843,10 +7896,26 @@ post_network_change_when_ready() } } - status = notify_post(_SC_NOTIFY_NETWORK_CHANGE); - if (status != NOTIFY_STATUS_OK) { - my_log(LOG_ERR, - "notify_post(" _SC_NOTIFY_NETWORK_CHANGE ") failed: error=%d", status); + if ((S_network_change_needed & NETWORK_CHANGE_NAT64) != 0) { +#if !TARGET_OS_SIMULATOR + // process any NAT64 prefix update requests (and refresh existing prefixes on change) + if ((S_nat64_prefix_requests != NULL) || (S_nat64_prefix_changes != NULL)) { + nat64_configuration_update(S_nat64_prefix_requests, S_nat64_prefix_changes); + my_CFRelease(&S_nat64_prefix_requests); + my_CFRelease(&S_nat64_prefix_changes); + } +#endif /* !TARGET_OS_SIMULATOR */ + + S_network_change_needed &= ~(NETWORK_CHANGE_NAT64); + } + + if (S_network_change_needed != 0) { + // if more than just a NAT64 prefix change + status = notify_post(_SC_NOTIFY_NETWORK_CHANGE); + if (status != NOTIFY_STATUS_OK) { + my_log(LOG_ERR, + "notify_post(" _SC_NOTIFY_NETWORK_CHANGE ") failed: error=%d", status); + } } S_network_change_needed = 0; @@ -7859,6 +7928,8 @@ post_network_change_when_ready() static void post_network_change(uint32_t change) { + dispatch_assert_queue(__network_change_queue()); + if (S_network_change_needed == 0) { // set the start time (void) gettimeofday(&S_network_change_start, NULL); @@ -7921,9 +7992,9 @@ IPMonitorProcessChanges(SCDynamicStoreRef session, CFArrayRef changed_keys, boolean_t dnsinfo_changed = FALSE; boolean_t global_ipv4_changed = FALSE; boolean_t global_ipv6_changed = FALSE; - CFIndex i; keyChangeList keys; CFIndex n; + boolean_t nat64_changed = FALSE; CFMutableStringRef network_change_msg = NULL; int n_services; nwi_state_t old_nwi_state = NULL; @@ -7983,8 +8054,13 @@ IPMonitorProcessChanges(SCDynamicStoreRef session, CFArrayRef changed_keys, service_changes = CFArrayCreateMutable(NULL, 0, &kCFTypeArrayCallBacks); - for (i = 0; i < count; i++) { - CFStringRef change = CFArrayGetValueAtIndex(changed_keys, i); + for (CFIndex i = 0; i < count; i++) { + CFStringRef change; +#if !TARGET_OS_SIMULATOR + CFStringRef interface = NULL; +#endif /* !TARGET_OS_SIMULATOR */ + + change = CFArrayGetValueAtIndex(changed_keys, i); if (CFEqual(change, S_setup_global_ipv4)) { global_ipv4_changed = TRUE; global_ipv6_changed = TRUE; @@ -8010,8 +8086,6 @@ IPMonitorProcessChanges(SCDynamicStoreRef session, CFArrayRef changed_keys, } } else if (CFStringHasPrefix(change, S_setup_service_prefix)) { - int j; - CFStringRef serviceID = parse_component(change, S_setup_service_prefix); if (serviceID) { @@ -8019,7 +8093,7 @@ IPMonitorProcessChanges(SCDynamicStoreRef session, CFArrayRef changed_keys, CFRelease(serviceID); } - for (j = 0; j < countof(transientInterfaceEntityNames); j++) { + for (size_t j = 0; j < countof(transientInterfaceEntityNames); j++) { if (CFStringHasSuffix(change, *transientInterfaceEntityNames[j])) { reachability_changed = TRUE; @@ -8031,12 +8105,18 @@ IPMonitorProcessChanges(SCDynamicStoreRef session, CFArrayRef changed_keys, reachability_changed = TRUE; } } +#if !TARGET_OS_SIMULATOR + else if (is_nat64_prefix_request(change, &interface)) { + my_CFSetAddValue_async(__network_change_queue(), &S_nat64_prefix_requests, interface); + nat64_changed = TRUE; + } +#endif /* !TARGET_OS_SIMULATOR */ } /* determine which serviceIDs are impacted by the interface rank changes */ if (if_rank_changes != NULL) { n = CFArrayGetCount(if_rank_changes); - for (i = 0; i < n; i++) { + for (CFIndex i = 0; i < n; i++) { CFStringRef ifname = CFArrayGetValueAtIndex(if_rank_changes, i); if ((S_IPMonitor_debug & kDebugFlag1) != 0) { @@ -8055,8 +8135,9 @@ IPMonitorProcessChanges(SCDynamicStoreRef session, CFArrayRef changed_keys, } } + /* process protocol (v4, v6, rank, ...) and configuration (dns, proxies, smb, ...) changes */ n = CFArrayGetCount(service_changes); - for (i = 0; i < n; i++) { + for (CFIndex i = 0; i < n; i++) { uint32_t changes; CFStringRef serviceID; @@ -8077,6 +8158,7 @@ IPMonitorProcessChanges(SCDynamicStoreRef session, CFArrayRef changed_keys, global_ipv6_changed = TRUE; dnsinfo_changed = TRUE; proxies_changed = TRUE; + nat64_changed = TRUE; } } if ((changes & (1 << kEntityTypeDNS)) != 0) { @@ -8084,6 +8166,7 @@ IPMonitorProcessChanges(SCDynamicStoreRef session, CFArrayRef changed_keys, dns_changed = TRUE; } dnsinfo_changed = TRUE; + nat64_changed = TRUE; } if ((changes & (1 << kEntityTypeProxies)) != 0) { proxies_changed = TRUE; @@ -8098,8 +8181,8 @@ IPMonitorProcessChanges(SCDynamicStoreRef session, CFArrayRef changed_keys, if ((changes & (1 << kEntityTypeTransientStatus)) != 0 && (service_dict_get(serviceID, kSCEntNetIPv4) != NULL || service_dict_get(serviceID, kSCEntNetIPv6) != NULL)) { - dnsinfo_changed = TRUE; - } + dnsinfo_changed = TRUE; + } } /* ensure S_nwi_state can hold as many services as we have currently */ @@ -8131,6 +8214,8 @@ IPMonitorProcessChanges(SCDynamicStoreRef session, CFArrayRef changed_keys, CFStringRef new_primary_smb = NULL; #endif /* !TARGET_OS_IPHONE */ RouteListUnion new_routelist; + CandidateRef other_candidate; + CandidateRef primary_candidate; if (S_nwi_state != NULL) { nwi_state_clear(S_nwi_state, AF_INET); @@ -8140,26 +8225,31 @@ IPMonitorProcessChanges(SCDynamicStoreRef session, CFArrayRef changed_keys, /* IPv4 */ my_log(LOG_DEBUG, "electing IPv4 primary"); new_routelist.ptr = NULL; - new_primary = ElectionResultsCopyPrimary(S_ipv4_results, - S_ipv6_results, - S_nwi_state, AF_INET, - &new_routelist.common, - services_info); + other_candidate = (S_ipv6_results != NULL) /* get IPv6 primary */ + ? S_ipv6_results->candidates : NULL; + primary_candidate = ElectionResultsGetPrimary(S_ipv4_results, + other_candidate, + S_nwi_state, AF_INET, + &new_routelist.common, + services_info); + new_primary = (primary_candidate != NULL) + ? primary_candidate->serviceID : NULL; (void)set_new_primary(&S_primary_ipv4, new_primary, "IPv4"); update_ipv4(S_primary_ipv4, new_routelist.v4, &keys); - my_CFRelease(&new_primary); /* IPv6 */ my_log(LOG_DEBUG, "electing IPv6 primary"); new_routelist.ptr = NULL; - new_primary = ElectionResultsCopyPrimary(S_ipv6_results, - S_ipv4_results, - S_nwi_state, AF_INET6, - &new_routelist.common, - services_info); + other_candidate = primary_candidate; /* get IPv4 primary */ + primary_candidate = ElectionResultsGetPrimary(S_ipv6_results, + other_candidate, + S_nwi_state, AF_INET6, + &new_routelist.common, + services_info); + new_primary = (primary_candidate != NULL) + ? primary_candidate->serviceID : NULL; (void)set_new_primary(&S_primary_ipv6, new_primary, "IPv6"); update_ipv6(S_primary_ipv6, new_routelist.v6, &keys); - my_CFRelease(&new_primary); nwi_state_finalize(S_nwi_state); @@ -8301,6 +8391,9 @@ IPMonitorProcessChanges(SCDynamicStoreRef session, CFArrayRef changed_keys, } } #endif /* !TARGET_OS_IPHONE */ + if (nat64_changed) { + changes |= NETWORK_CHANGE_NAT64; + } my_CFRelease(&service_changes); my_CFRelease(&services_info); @@ -8343,6 +8436,8 @@ IPMonitorProcessChanges(SCDynamicStoreRef session, CFArrayRef changed_keys, my_log(LOG_NOTICE, "network changed:%@", network_change_msg); } else if (keyChangeListActive(&keys)) { my_log(LOG_NOTICE, "network changed"); + } else if (nat64_changed) { + my_log(LOG_NOTICE, "nat64 update"); } else { my_log(LOG_INFO, "network event w/no changes"); } @@ -8365,8 +8460,9 @@ IPMonitorProcessChanges(SCDynamicStoreRef session, CFArrayRef changed_keys, static void IPMonitorNotify(SCDynamicStoreRef session, CFArrayRef changed_keys, - void * not_used) + void * info) { +#pragma unused(info) IPMonitorProcessChanges(session, changed_keys, NULL); return; } @@ -8402,32 +8498,21 @@ watch_proxies() #include "IPMonitorControlPrefs.h" static void -prefs_changed(__unused SCPreferencesRef prefs) +prefs_changed(SCPreferencesRef prefs) { +#pragma unused(prefs) if (S_bundle_logging_verbose || IPMonitorControlPrefsIsVerbose()) { S_IPMonitor_debug = kDebugFlagDefault; S_IPMonitor_verbose = TRUE; - SCLoggerSetFlags(S_IPMonitor_logger, kSCLoggerFlagsFile | kSCLoggerFlagsDefault); my_log(LOG_DEBUG, "Setting logging verbose mode on"); } else { my_log(LOG_DEBUG, "Setting logging verbose mode off"); S_IPMonitor_debug = 0; S_IPMonitor_verbose = FALSE; - SCLoggerSetFlags(S_IPMonitor_logger, kSCLoggerFlagsDefault); } return; } -#define LOGGER_ID CFSTR("com.apple.networking.IPMonitor") -static void -my_log_init() -{ - S_IPMonitor_logger = SCLoggerCreate(LOGGER_ID); - return; - -} - - #if !TARGET_OS_SIMULATOR static int flush_routes(int s) @@ -8638,6 +8723,11 @@ ip_plugin_init() CFSTR(kDNSServiceCompPrivateDNS)); CFArrayAppendValue(keys, S_private_resolvers); +#if !TARGET_OS_SIMULATOR + /* add NAT64 prefix request pattern */ + nat64_prefix_request_add_pattern(patterns); +#endif /* !TARGET_OS_SIMULATOR */ + if (!SCDynamicStoreSetNotificationKeys(S_session, keys, patterns)) { my_log(LOG_ERR, "SCDynamicStoreSetNotificationKeys() failed: %s", @@ -8710,6 +8800,7 @@ S_get_plist_boolean(CFDictionaryRef plist, CFStringRef key, static void InterfaceRankChanged(void * info) { +#pragma unused(info) os_activity_t activity; CFDictionaryRef assertions = NULL; CFArrayRef changes; @@ -8778,12 +8869,11 @@ load_IPMonitor(CFBundleRef bundle, Boolean bundleVerbose) S_IPMonitor_verbose = TRUE; } - my_log_init(); - - /* register to receive changes to verbose and read the initial setting */ + /* register to receive changes to the "verbose" flag and read the initial setting */ IPMonitorControlPrefsInit(CFRunLoopGetCurrent(), prefs_changed); prefs_changed(NULL); + /* start DNS configuration (dnsinfo) server */ load_DNSConfiguration(bundle, // bundle ^(Boolean inSync) { // syncHandler dispatch_async(__network_change_queue(), ^{ @@ -8800,6 +8890,7 @@ load_IPMonitor(CFBundleRef bundle, Boolean bundleVerbose) }); }); + /* start Network Information (nwi) server */ load_NetworkInformation(bundle, // bundle ^(Boolean inSync) { // syncHandler dispatch_async(__network_change_queue(), ^{ @@ -8807,12 +8898,21 @@ load_IPMonitor(CFBundleRef bundle, Boolean bundleVerbose) post_network_change_when_ready(); }); }); + #if !TARGET_OS_SIMULATOR + /* start IPMonitor Control (InterfaceRank) server */ StartIPMonitorControlServer(); #endif /* !TARGET_OS_IPHONE */ + /* initialize DNS configuration */ dns_configuration_init(bundle); +#if !TARGET_OS_SIMULATOR + /* initialize NAT64 configuration */ + nat64_configuration_init(bundle); +#endif /* !TARGET_OS_SIMULATOR */ + + /* initialize proxy configuration */ proxy_configuration_init(bundle); ip_plugin_init(); diff --git a/Plugins/IPMonitor/ip_plugin.h b/Plugins/IPMonitor/ip_plugin.h index 7fdb1b0..78da7e3 100644 --- a/Plugins/IPMonitor/ip_plugin.h +++ b/Plugins/IPMonitor/ip_plugin.h @@ -48,15 +48,13 @@ #define kIsNULL CFSTR("IsNULL") /* CFBoolean */ -#ifdef TEST_ROUTELIST - -#define my_log(__level, __format, ...) SCPrint(TRUE, stdout, CFSTR(__format "\n"), ## __VA_ARGS__) - -#else /* TEST_ROUTELIST */ - -#define my_log(__level, __format, ...) SC_log(__level, __format, ## __VA_ARGS__) - -#endif /* TEST_ROUTELIST */ +#ifndef my_log + #ifdef TEST_ROUTELIST + #define my_log(__level, __format, ...) SCPrint(TRUE, stdout, CFSTR(__format "\n"), ## __VA_ARGS__) + #else /* TEST_ROUTELIST */ + #define my_log(__level, __format, ...) SC_log(__level, __format, ## __VA_ARGS__) + #endif /* TEST_ROUTELIST */ +#endif // !my_log os_log_t __log_IPMonitor(); diff --git a/Plugins/IPMonitor/nat64-configuration.c b/Plugins/IPMonitor/nat64-configuration.c new file mode 100644 index 0000000..182a532 --- /dev/null +++ b/Plugins/IPMonitor/nat64-configuration.c @@ -0,0 +1,288 @@ +/* + * Copyright (c) 2017 Apple Inc. All rights reserved. + * + * @APPLE_LICENSE_HEADER_START@ + * + * This file contains Original Code and/or Modifications of Original Code + * as defined in and that are subject to the Apple Public Source License + * Version 2.0 (the 'License'). You may not use this file except in + * compliance with the License. Please obtain a copy of the License at + * http://www.opensource.apple.com/apsl/ and read it before using this + * file. + * + * The Original Code and all software distributed under the License are + * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, + * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. + * Please see the License for the specific language governing rights and + * limitations under the License. + * + * @APPLE_LICENSE_HEADER_END@ + */ + +/* + * Modification History + * + * April 17, 2017 Allan Nathanson + * - initial revision + */ + + +#include "nat64-configuration.h" + +#include +#include +#include +#include +#include "ip_plugin.h" + +#define INET6 1 + +#include +#include +#include +#include +#include +#include + + +static CFMutableSetRef nat64_prefix_requests = NULL; + + +static dispatch_queue_t +nat64_dispatch_queue() +{ + static dispatch_once_t once; + static dispatch_queue_t q; + + dispatch_once(&once, ^{ + q = dispatch_queue_create("nat64 prefix request queue", NULL); + }); + + return q; +} + + +static __inline__ void +_nat64_prefix_request_complete(const char *if_name, + int32_t num_prefixes, + nw_nat64_prefix_t *prefixes) +{ + struct if_nat64req req; + int ret; + int s; + + SC_log(LOG_DEBUG, "%s: _nat64_prefix_request_complete", if_name); + + // pass NAT64 prefixes to the kernel + bzero(&req, sizeof(req)); + strlcpy(req.ifnat64_name, if_name, sizeof(req.ifnat64_name)); + + if (num_prefixes == 0) { + SC_log(LOG_INFO, "%s: nat64 prefix not (or no longer) available", if_name); + } + + for (int32_t i = 0; i < num_prefixes; i++) { + char prefix_str[NW_NAT64_PREFIX_STR_LENGTH] = {0}; + + nw_nat64_write_prefix_to_string(&prefixes[i], prefix_str, sizeof(prefix_str)); + SC_log(LOG_DEBUG, "%s: nat64 prefix[%d] = %s", if_name, i, prefix_str); + + if (i < NAT64_MAX_NUM_PREFIXES) { + req.ifnat64_prefixes[i].prefix_len = prefixes[i].length; + bcopy(&prefixes[i].data, + &req.ifnat64_prefixes[i].ipv6_prefix, + MIN(sizeof(req.ifnat64_prefixes[i].ipv6_prefix), sizeof(prefixes[i].data))); // MIN(16, 12) + } + } + + s = socket(AF_INET, SOCK_DGRAM, 0); + if (s == -1) { + SC_log(LOG_ERR, "socket() failed: %s", strerror(errno)); + return; + } + ret = ioctl(s, SIOCSIFNAT64PREFIX, &req); + close(s); + if (ret == -1) { + if ((errno != ENOENT) || (num_prefixes != 0)) { + SC_log(LOG_ERR, "%s: ioctl(SIOCSIFNAT64PREFIX) failed: %s", if_name, strerror(errno)); + } + return; + } + + SC_log(LOG_INFO, "%s: nat64 prefix%s updated", if_name, (num_prefixes != 1) ? "es" : ""); + return; +} + + +static void +_nat64_prefix_request_start(const void *value) +{ + unsigned int if_index; + char *if_name; + CFStringRef interface = (CFStringRef)value; + bool ok; + + SC_log(LOG_DEBUG, "%@: _nat64_prefix_request_start", interface); + + if_name = _SC_cfstring_to_cstring(interface, NULL, 0, kCFStringEncodingASCII); + if (if_name == NULL) { + SC_log(LOG_NOTICE, "%@: could not convert interface name", interface); + return; + } + + if_index = my_if_nametoindex(if_name); + if (if_index == 0) { + SC_log(LOG_NOTICE, "%s: no interface index", if_name); + CFAllocatorDeallocate(NULL, if_name); + return; + } + + // keep track of interfaces with active nat64 prefix requests + CFSetAddValue(nat64_prefix_requests, interface); + + CFRetain(interface); + ok = nw_nat64_copy_prefixes_async(&if_index, + nat64_dispatch_queue(), + ^(int32_t num_prefixes, nw_nat64_prefix_t *prefixes) { + if (num_prefixes >= 0) { + // update interface + _nat64_prefix_request_complete(if_name, num_prefixes, prefixes); + } else { + SC_log(LOG_ERR, + "%s: nw_nat64_copy_prefixes_async() num_prefixes(%d) < 0", + if_name, + num_prefixes); + } + + if (num_prefixes <= 0) { + // remove from active list + CFSetRemoveValue(nat64_prefix_requests, interface); + } + + // cleanup + CFRelease(interface); + CFAllocatorDeallocate(NULL, if_name); + }); + if (!ok) { + SC_log(LOG_ERR, "%s: nw_nat64_copy_prefixes_async() failed", if_name); + + // remove from active list + CFSetRemoveValue(nat64_prefix_requests, interface); + + CFRelease(interface); + CFAllocatorDeallocate(NULL, if_name); + } + + return; +} + + +static void +_nat64_prefix_request(const void *value, void *context) +{ + CFSetRef changes = (CFSetRef)context; + CFStringRef interface = (CFStringRef)value; + + if (!CFSetContainsValue(nat64_prefix_requests, interface) || + ((changes != NULL) && CFSetContainsValue(changes, interface))) { + // if new request + // ... or a [refresh] request that hasn't already been started + _nat64_prefix_request_start(interface); + } + + return; +} + + +static void +_nat64_prefix_update(const void *value, void *context) +{ +#pragma unused(context) + CFStringRef interface = (CFStringRef)value; + + if (CFSetContainsValue(nat64_prefix_requests, interface)) { + _nat64_prefix_request_start(interface); + } + + return; +} + + +#pragma mark - +#pragma mark NAT64 prefix functions (for IPMonitor) + + +__private_extern__ +Boolean +is_nat64_prefix_request(CFStringRef change, CFStringRef *interface) +{ + CFArrayRef components; + static CFStringRef prefix = NULL; + Boolean yn = FALSE; + static dispatch_once_t once; + + dispatch_once(&once, ^{ + prefix = SCDynamicStoreKeyCreateNetworkInterface(NULL, kSCDynamicStoreDomainState); + }); + + *interface = NULL; + if (!CFStringHasPrefix(change, prefix) || + !CFStringHasSuffix(change, kSCEntNetNAT64PrefixRequest)) { + return FALSE; + } + + components = CFStringCreateArrayBySeparatingStrings(NULL, change, CFSTR("/")); + if (CFArrayGetCount(components) == 5) { + *interface = CFArrayGetValueAtIndex(components, 3); + CFRetain(*interface); + yn = TRUE; + } + CFRelease(components); + + return yn; +} + + +__private_extern__ void +nat64_prefix_request_add_pattern(CFMutableArrayRef patterns) +{ + CFStringRef pattern; + + pattern = SCDynamicStoreKeyCreateNetworkInterfaceEntity(NULL, + kSCDynamicStoreDomainState, + kSCCompAnyRegex, + kSCEntNetNAT64PrefixRequest); + CFArrayAppendValue(patterns, pattern); + CFRelease(pattern); + return; +} + + +__private_extern__ +void +nat64_configuration_init(CFBundleRef bundle) +{ +#pragma unused(bundle) + nat64_prefix_requests = CFSetCreateMutable(NULL, 0, &kCFTypeSetCallBacks); + return; +} + + +__private_extern__ +void +nat64_configuration_update(CFSetRef requests, CFSetRef changes) +{ + // for any interface that changed, refresh the nat64 prefix + if (changes != NULL) { + CFSetApplyFunction(changes, _nat64_prefix_update, NULL); + } + + // for any requested interface, query the nat64 prefix + if (requests != NULL) { + CFSetApplyFunction(requests, _nat64_prefix_request, (void *)changes); + } + + return; +} diff --git a/Plugins/IPMonitor/nat64-configuration.h b/Plugins/IPMonitor/nat64-configuration.h new file mode 100644 index 0000000..eea5652 --- /dev/null +++ b/Plugins/IPMonitor/nat64-configuration.h @@ -0,0 +1,50 @@ +/* + * Copyright (c) 2017 Apple Inc. All rights reserved. + * + * @APPLE_LICENSE_HEADER_START@ + * + * This file contains Original Code and/or Modifications of Original Code + * as defined in and that are subject to the Apple Public Source License + * Version 2.0 (the 'License'). You may not use this file except in + * compliance with the License. Please obtain a copy of the License at + * http://www.opensource.apple.com/apsl/ and read it before using this + * file. + * + * The Original Code and all software distributed under the License are + * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, + * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. + * Please see the License for the specific language governing rights and + * limitations under the License. + * + * @APPLE_LICENSE_HEADER_END@ + */ + +#ifndef _NAT64_CONFIGURATION_H +#define _NAT64_CONFIGURATION_H + +#include +#include +#include + + +__BEGIN_DECLS + +Boolean +is_nat64_prefix_request (CFStringRef change, + CFStringRef *interface); + +void +nat64_prefix_request_add_pattern (CFMutableArrayRef patterns); + +void +nat64_configuration_init (CFBundleRef bundle); + +void +nat64_configuration_update (CFSetRef interface_changes, + CFSetRef interface_requests); + +__END_DECLS + +#endif /* _NAT64_CONFIGURATION_H */ diff --git a/Plugins/IPMonitor/proxy-configuration.c b/Plugins/IPMonitor/proxy-configuration.c index 05dc0ae..9116f42 100644 --- a/Plugins/IPMonitor/proxy-configuration.c +++ b/Plugins/IPMonitor/proxy-configuration.c @@ -1,15 +1,15 @@ /* - * Copyright (c) 2011-2015 Apple Inc. All rights reserved. + * Copyright (c) 2011-2017 Apple Inc. All rights reserved. * * @APPLE_LICENSE_HEADER_START@ - * + * * This file contains Original Code and/or Modifications of Original Code * as defined in and that are subject to the Apple Public Source License * Version 2.0 (the 'License'). You may not use this file except in * compliance with the License. Please obtain a copy of the License at * http://www.opensource.apple.com/apsl/ and read it before using this * file. - * + * * The Original Code and all software distributed under the License are * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, @@ -17,7 +17,7 @@ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. * Please see the License for the specific language governing rights and * limitations under the License. - * + * * @APPLE_LICENSE_HEADER_END@ */ @@ -239,6 +239,7 @@ add_supplemental_proxies(CFMutableArrayRef proxies, CFDictionaryRef services, CF static CFComparisonResult compareBySearchOrder(const void *val1, const void *val2, void *context) { +#pragma unused(context) CFDictionaryRef proxy1 = (CFDictionaryRef)val1; CFDictionaryRef proxy2 = (CFDictionaryRef)val2; CFNumberRef num1; @@ -295,6 +296,7 @@ isSupplementalProxy(CFDictionaryRef proxy) static CFArrayRef copy_supplemental_proxies(CFArrayRef proxies, Boolean skip) { +#pragma unused(skip) CFIndex i; CFIndex n_proxies; CFMutableArrayRef supplemental = NULL; diff --git a/Plugins/IPMonitor/set-hostname.c b/Plugins/IPMonitor/set-hostname.c index 56273de..d91c409 100644 --- a/Plugins/IPMonitor/set-hostname.c +++ b/Plugins/IPMonitor/set-hostname.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2004-2016 Apple Inc. All rights reserved. + * Copyright (c) 2004-2017 Apple Inc. All rights reserved. * * @APPLE_LICENSE_HEADER_START@ * @@ -279,6 +279,7 @@ hostname_match_first_label(CFArrayRef hosts, CFIndex count, CFStringRef nameToMa static void ptr_query_callback(SCNetworkReachabilityRef target, SCNetworkReachabilityFlags flags, void *info) { +#pragma unused(info) CFStringRef hostname = NULL; struct timeval ptrQueryComplete; struct timeval ptrQueryElapsed; @@ -442,6 +443,8 @@ ptr_query_start(CFStringRef address) static void update_hostname(SCDynamicStoreRef store, CFArrayRef changedKeys, void *info) { +#pragma unused(changedKeys) +#pragma unused(info) CFStringRef address = NULL; CFStringRef hostname = NULL; CFStringRef serviceID = NULL; @@ -532,6 +535,7 @@ __private_extern__ void load_hostname(Boolean verbose) { +#pragma unused(verbose) CFStringRef key; CFMutableArrayRef keys = NULL; dispatch_block_t notify_block; @@ -619,6 +623,7 @@ load_hostname(Boolean verbose) ¬ify_token, queue, ^(int token){ +#pragma unused(token) CFRunLoopPerformBlock(rl, kCFRunLoopDefaultMode, notify_block); diff --git a/Plugins/IPMonitor/smb-configuration.c b/Plugins/IPMonitor/smb-configuration.c index 34dfc22..a6ac14e 100644 --- a/Plugins/IPMonitor/smb-configuration.c +++ b/Plugins/IPMonitor/smb-configuration.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2006-2016 Apple Inc. All rights reserved. + * Copyright (c) 2006-2017 Apple Inc. All rights reserved. * * @APPLE_LICENSE_HEADER_START@ * @@ -57,16 +57,18 @@ #include "ip_plugin.h" #endif // MAIN -#define HW_MODEL_LEN 64 // Note: must be >= NETBIOS_NAME_LEN (below) +#define HW_MODEL_LEN 64 // Note: must be >= NETBIOS_NAME_LEN (below) -#define NETBIOS_NAME_LEN 16 +#define NETBIOS_NAME_LEN 16 -#define SMB_STARTUP_DELAY 60.0 -#define SMB_DEBOUNCE_DELAY 5.0 +#define SMB_STARTUP_DELAY 60.0 +#define SMB_DEBOUNCE_DELAY 5.0 +#define SMB_CONFIGURATION_QUEUE "com.apple.config.smb-configuration" static SCDynamicStoreRef store = NULL; static CFRunLoopRef rl = NULL; static CFRunLoopSourceRef rls = NULL; +static dispatch_queue_t queue = NULL; static int notify_token = -1; @@ -104,7 +106,7 @@ static CFStringRef copy_default_name(void) { CFStringRef model; - size_t n; + CFIndex n; CFMutableStringRef str; // get HW model name @@ -465,6 +467,7 @@ ptr_query_stop() static void ptr_query_callback(SCNetworkReachabilityRef target, SCNetworkReachabilityFlags flags, void *info) { +#pragma unused(info) CFDictionaryRef dict; CFStringRef name; CFMutableDictionaryRef newDict; @@ -618,8 +621,9 @@ ptr_query_start(CFStringRef address) static void -smb_update_configuration(__unused CFRunLoopTimerRef _timer, void *info) +smb_update_configuration(CFRunLoopTimerRef _timer, void *info) { +#pragma unused(_timer) CFStringRef address = NULL; CFDictionaryRef dict; CFStringRef name; @@ -713,6 +717,8 @@ smb_update_configuration(__unused CFRunLoopTimerRef _timer, void *info) static void configuration_changed(SCDynamicStoreRef store, CFArrayRef changedKeys, void *info) { +#pragma unused(changedKeys) +#pragma unused(info) CFRunLoopTimerContext context = { 0, (void *)store, CFRetain, CFRelease, NULL }; CFAbsoluteTime time_boot; CFAbsoluteTime time_now ; @@ -751,6 +757,7 @@ __private_extern__ void load_smb_configuration(Boolean verbose) { +#pragma unused(verbose) CFStringRef key; CFMutableArrayRef keys = NULL; dispatch_block_t notify_block; @@ -759,6 +766,12 @@ load_smb_configuration(Boolean verbose) uint32_t status; /* initialize a few globals */ + queue = dispatch_queue_create(SMB_CONFIGURATION_QUEUE, NULL); + if (queue == NULL) { + my_log(LOG_ERR, + "dispatch_queue_create() failed"); + goto error; + } store = SCDynamicStoreCreate(NULL, CFSTR("smb-configuration"), configuration_changed, NULL); if (store == NULL) { @@ -828,8 +841,9 @@ load_smb_configuration(Boolean verbose) }; status = notify_register_dispatch(_SC_NOTIFY_NETWORK_CHANGE, ¬ify_token, - dispatch_get_main_queue(), + queue, ^(int token){ +#pragma unused(token) CFRunLoopPerformBlock(rl, kCFRunLoopDefaultMode, notify_block); @@ -853,6 +867,10 @@ load_smb_configuration(Boolean verbose) CFRelease(store); store = NULL; } + if (queue != NULL) { + dispatch_release(queue); + queue = NULL; + } return; } diff --git a/Plugins/InterfaceNamer/Info.plist b/Plugins/InterfaceNamer/Info.plist index 79321b7..22ed8d9 100644 --- a/Plugins/InterfaceNamer/Info.plist +++ b/Plugins/InterfaceNamer/Info.plist @@ -17,10 +17,10 @@ CFBundlePackageType BNDL CFBundleShortVersionString - 1.14 + 1.17 CFBundleSignature ???? CFBundleVersion - 1.14 + 1.17 diff --git a/Plugins/InterfaceNamer/ifnamer.c b/Plugins/InterfaceNamer/ifnamer.c index 68c9942..e796110 100644 --- a/Plugins/InterfaceNamer/ifnamer.c +++ b/Plugins/InterfaceNamer/ifnamer.c @@ -75,7 +75,6 @@ #include -#define SC_LOG_HANDLE __log_InterfaceNamer() #include #include #include @@ -120,7 +119,7 @@ enum { #define WAIT_STACK_TIMEOUT_DEFAULT 300.0 #define WAIT_QUIET_TIMEOUT_KEY "WaitQuietTimeout" -#define WAIT_QUIET_TIMEOUT_DEFAULT 60.0 +#define WAIT_QUIET_TIMEOUT_DEFAULT 240.0 /* * S_connect @@ -216,7 +215,8 @@ static CFArrayRef S_vlans = NULL; /* * Logging */ -static os_log_t +__private_extern__ +os_log_t __log_InterfaceNamer() { static os_log_t log = NULL; @@ -248,6 +248,7 @@ addTimestamp(CFMutableDictionaryRef dict, CFStringRef key) static CFComparisonResult if_unit_compare(const void *val1, const void *val2, void *context) { +#pragma unused(context) CFComparisonResult res; CFNumberRef type1; CFNumberRef type2; @@ -556,6 +557,7 @@ updateVirtualNetworkInterfaceConfiguration(SCPreferencesRef prefs, SCPreferencesNotification notificationType, void *info) { +#pragma unused(info) os_activity_t activity; if ((notificationType & kSCPreferencesNotificationApply) != kSCPreferencesNotificationApply) { @@ -603,6 +605,7 @@ updateVirtualNetworkInterfaceConfiguration(SCPreferencesRef prefs, static void updateBTPANInformation(const void *value, void *context) { +#pragma unused(context) CFDataRef addr; CFDictionaryRef dict = (CFDictionaryRef)value; CFStringRef if_name; @@ -1873,11 +1876,15 @@ updateNetworkConfiguration(CFArrayRef if_list) set = SCNetworkSetCopyCurrent(prefs); if (set == NULL) { - SC_log(LOG_INFO, "No current set"); - goto done; + SC_log(LOG_INFO, "No current set, adding default"); + set = _SCNetworkSetCreateDefault(prefs); + if (set == NULL) { + SC_log(LOG_NOTICE, "_SCNetworkSetCreateDefault() failed: %s", SCErrorString(SCError())); + goto done; + } } - n = CFArrayGetCount(if_list); + n = (if_list != NULL) ? CFArrayGetCount(if_list) : 0; for (i = 0; i < n; i++) { SCNetworkInterfaceRef interface; @@ -2076,6 +2083,7 @@ updateInterfaces() static void interfaceArrivalCallback(void *refcon, io_iterator_t iter) { +#pragma unused(refcon) os_activity_t activity; io_object_t obj; @@ -2117,6 +2125,7 @@ interfaceArrivalCallback(void *refcon, io_iterator_t iter) static void stackCallback(void *refcon, io_iterator_t iter) { +#pragma unused(refcon) os_activity_t activity; kern_return_t kr; io_object_t stack; @@ -2172,6 +2181,8 @@ quietCallback(void *refcon, natural_t messageType, void *messageArgument) { +#pragma unused(refcon) +#pragma unused(service) os_activity_t activity; if (messageArgument != NULL) { @@ -2347,6 +2358,8 @@ captureBusy() static void timerCallback(CFRunLoopTimerRef timer, void *info) { +#pragma unused(timer) +#pragma unused(info) os_activity_t activity; activity = os_activity_create("process IOKit timer", @@ -2375,6 +2388,7 @@ timerCallback(CFRunLoopTimerRef timer, void *info) static Boolean setup_IOKit(CFBundleRef bundle) { +#pragma unused(bundle) uint32_t busy; kern_return_t kr; mach_port_t masterPort = MACH_PORT_NULL; @@ -2541,6 +2555,7 @@ setup_IOKit(CFBundleRef bundle) static Boolean setup_Virtual(CFBundleRef bundle) { +#pragma unused(bundle) // open a SCPreferences session S_prefs = SCPreferencesCreate(NULL, CFSTR(MY_PLUGIN_NAME), NULL); if (S_prefs == NULL) { @@ -2658,6 +2673,7 @@ __private_extern__ void load_InterfaceNamer(CFBundleRef bundle, Boolean bundleVerbose) { +#pragma unused(bundleVerbose) pthread_attr_t tattr; pthread_t tid; diff --git a/Plugins/KernelEventMonitor/Info.plist b/Plugins/KernelEventMonitor/Info.plist index 54ce80e..96d2b1a 100644 --- a/Plugins/KernelEventMonitor/Info.plist +++ b/Plugins/KernelEventMonitor/Info.plist @@ -17,11 +17,11 @@ CFBundlePackageType BNDL CFBundleShortVersionString - 1.14 + 1.17 CFBundleSignature ???? CFBundleVersion - 1.14 + 1.17 Requires com.apple.SystemConfiguration.InterfaceNamer diff --git a/Plugins/KernelEventMonitor/ev_dlil.c b/Plugins/KernelEventMonitor/ev_dlil.c index 9157a1a..2e759d5 100644 --- a/Plugins/KernelEventMonitor/ev_dlil.c +++ b/Plugins/KernelEventMonitor/ev_dlil.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2002-2016 Apple Inc. All rights reserved. + * Copyright (c) 2002-2017 Apple Inc. All rights reserved. * * @APPLE_LICENSE_HEADER_START@ * @@ -218,10 +218,13 @@ link_update_quality_metric(const char *if_name) quality = ifr.ifr_link_quality_metric; } -done: + done: + interface_update_quality_metric(if_name, quality); - if (sock != -1) + + if (sock != -1) { close(sock); + } return; } @@ -341,7 +344,7 @@ void link_update_status(const char *if_name, boolean_t attach, boolean_t only_if_different) { CFBooleanRef active = NULL; - CFBooleanRef expensive; + CFBooleanRef expensive = NULL; struct ifmediareq ifm; int sock; @@ -377,8 +380,13 @@ link_update_status(const char *if_name, boolean_t attach, boolean_t only_if_diff update: - /* get "Expensive" */ - expensive = interface_update_expensive(if_name); + if ((active == NULL) || CFBooleanGetValue(active)) { + /* + * if link status not available or active (link UP), + * set "Expensive" + */ + expensive = interface_update_expensive(if_name); + } /* update status */ interface_update_status(if_name, active, attach, expensive, only_if_different); diff --git a/Plugins/KernelEventMonitor/ev_extra.m b/Plugins/KernelEventMonitor/ev_extra.m index 32bf151..cfd0163 100644 --- a/Plugins/KernelEventMonitor/ev_extra.m +++ b/Plugins/KernelEventMonitor/ev_extra.m @@ -75,11 +75,17 @@ ifexpensive_set(int s, const char * name, uint32_t expensive) { #if defined(SIOCSIFEXPENSIVE) && !defined(MAIN) struct ifreq ifr; + int ret; bzero(&ifr, sizeof(ifr)); strlcpy(ifr.ifr_name, name, sizeof(ifr.ifr_name)); ifr.ifr_expensive = expensive; - return (ioctl(s, SIOCSIFEXPENSIVE, &ifr)); + ret = ioctl(s, SIOCSIFEXPENSIVE, &ifr); + if (ret == -1) { + SC_log(LOG_ERR, "%s: ioctl(SIOCSIFEXPENSIVE) failed: %s", name, strerror(errno)); + } + + return ret; #else // defined(SIOCSIFEXPENSIVE) && !defined(MAIN) return 0; #endif // defined(SIOCSIFEXPENSIVE) && !defined(MAIN) diff --git a/Plugins/KernelEventMonitor/ev_ipv4.c b/Plugins/KernelEventMonitor/ev_ipv4.c index d0b765e..109b47e 100644 --- a/Plugins/KernelEventMonitor/ev_ipv4.c +++ b/Plugins/KernelEventMonitor/ev_ipv4.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2002-2015 Apple Inc. All rights reserved. + * Copyright (c) 2002-2017 Apple Inc. All rights reserved. * * @APPLE_LICENSE_HEADER_START@ * @@ -119,7 +119,13 @@ updateStore(const void *key, const void *value, void *context) SC_log(LOG_DEBUG, "Update interface configuration: %@: %@", key, newDict); cache_SCDynamicStoreSetValue(store, key, newDict); } else if (dict) { - SC_log(LOG_DEBUG, "Update interface configuration: %@: ", key); + CFDictionaryRef oldDict; + + oldDict = cache_SCDynamicStoreCopyValue(store, key); + if (oldDict != NULL) { + SC_log(LOG_DEBUG, "Update interface configuration: %@: ", key); + CFRelease(oldDict); + } cache_SCDynamicStoreRemoveValue(store, key); } network_changed = TRUE; diff --git a/Plugins/KernelEventMonitor/ev_ipv6.c b/Plugins/KernelEventMonitor/ev_ipv6.c index 43468d0..6d8f6f9 100644 --- a/Plugins/KernelEventMonitor/ev_ipv6.c +++ b/Plugins/KernelEventMonitor/ev_ipv6.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2002-2007, 2011, 2013, 2015 Apple Inc. All rights reserved. + * Copyright (c) 2002-2007, 2011, 2013, 2015, 2017 Apple Inc. All rights reserved. * * @APPLE_LICENSE_HEADER_START@ * @@ -107,7 +107,7 @@ appendPrefixLen(CFMutableDictionaryRef dict, struct sockaddr_in6 *sin6) CFArrayRef prefixLens; CFMutableArrayRef newPrefixLens; - register int byte; + register size_t byte; register int bit; int plen = 0; @@ -238,7 +238,13 @@ updateStore(const void *key, const void *value, void *context) SC_log(LOG_DEBUG, "Update interface configuration: %@: %@", key, newDict); cache_SCDynamicStoreSetValue(store, key, newDict); } else if (dict) { - SC_log(LOG_DEBUG, "Update interface configuration: %@: ", key); + CFDictionaryRef oldDict; + + oldDict = cache_SCDynamicStoreCopyValue(store, key); + if (oldDict != NULL) { + SC_log(LOG_DEBUG, "Update interface configuration: %@: ", key); + CFRelease(oldDict); + } cache_SCDynamicStoreRemoveValue(store, key); } network_changed = TRUE; @@ -436,3 +442,38 @@ ipv6_duplicated_address(const char * if_name, const struct in6_addr * addr, CFRelease(prefix); CFRelease(if_name_cf); } + +__private_extern__ +void +nat64_prefix_request(const char *if_name) +{ + CFStringRef if_name_cf; + CFStringRef key; + + if_name_cf = CFStringCreateWithCString(NULL, if_name, kCFStringEncodingASCII); + key = SCDynamicStoreKeyCreateNetworkInterfaceEntity(NULL, + kSCDynamicStoreDomainState, + if_name_cf, + kSCEntNetNAT64PrefixRequest); + CFRelease(if_name_cf); + SC_log(LOG_DEBUG, "Post NAT64 prefix request: %@", key); + cache_SCDynamicStoreNotifyValue(store, key); + CFRelease(key); +} + +__private_extern__ void +ipv6_router_expired(const char *if_name) +{ + CFStringRef if_name_cf; + CFStringRef key; + + if_name_cf = CFStringCreateWithCString(NULL, if_name, kCFStringEncodingASCII); + key = SCDynamicStoreKeyCreateNetworkInterfaceEntity(NULL, + kSCDynamicStoreDomainState, + if_name_cf, + kSCEntNetIPv6RouterExpired); + CFRelease(if_name_cf); + SC_log(LOG_DEBUG, "Post IPv6 Router Expired: %@", key); + cache_SCDynamicStoreNotifyValue(store, key); + CFRelease(key); +} diff --git a/Plugins/KernelEventMonitor/ev_ipv6.h b/Plugins/KernelEventMonitor/ev_ipv6.h index 562ad50..88f810e 100644 --- a/Plugins/KernelEventMonitor/ev_ipv6.h +++ b/Plugins/KernelEventMonitor/ev_ipv6.h @@ -1,15 +1,15 @@ /* - * Copyright (c) 2002, 2004, 2011, 2012, 2015 Apple Inc. All rights reserved. + * Copyright (c) 2002, 2004, 2011, 2012, 2015, 2017 Apple Inc. All rights reserved. * * @APPLE_LICENSE_HEADER_START@ - * + * * This file contains Original Code and/or Modifications of Original Code * as defined in and that are subject to the Apple Public Source License * Version 2.0 (the 'License'). You may not use this file except in * compliance with the License. Please obtain a copy of the License at * http://www.opensource.apple.com/apsl/ and read it before using this * file. - * + * * The Original Code and all software distributed under the License are * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, @@ -17,7 +17,7 @@ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. * Please see the License for the specific language governing rights and * limitations under the License. - * + * * @APPLE_LICENSE_HEADER_END@ */ @@ -39,6 +39,9 @@ __BEGIN_DECLS void interface_update_ipv6(struct ifaddrs *ifap, const char *if_name); void ipv6_duplicated_address(const char * if_name, const struct in6_addr * addr, int hw_len, const void * hw_addr); +void nat64_prefix_request(const char *if_name); +void ipv6_router_expired(const char *if_name); + __END_DECLS #endif /* _EV_IPV6_H */ diff --git a/Plugins/KernelEventMonitor/eventmon.c b/Plugins/KernelEventMonitor/eventmon.c index dc9d36a..73fd9a1 100644 --- a/Plugins/KernelEventMonitor/eventmon.c +++ b/Plugins/KernelEventMonitor/eventmon.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2000-2016 Apple Inc. All rights reserved. + * Copyright (c) 2000-2017 Apple Inc. All rights reserved. * * @APPLE_LICENSE_HEADER_START@ * @@ -62,6 +62,7 @@ #include #include #include +#include static dispatch_queue_t S_kev_queue; static dispatch_source_t S_kev_source; @@ -250,8 +251,8 @@ post_network_changed(void) static void logEvent(CFStringRef evStr, struct kern_event_msg *ev_msg) { - int i; - int j; + int i; + uint32_t j; if (!_verbose) { return; @@ -282,10 +283,10 @@ static uint8_t info_zero[DLIL_MODARGLEN]; static void processEvent_Apple_Network(struct kern_event_msg *ev_msg) { - int dataLen = (ev_msg->total_size - KEV_MSG_HEADER_SIZE); - void * event_data = &ev_msg->event_data[0]; - Boolean handled = TRUE; - char ifr_name[IFNAMSIZ]; + size_t dataLen = (ev_msg->total_size - KEV_MSG_HEADER_SIZE); + void * event_data = &ev_msg->event_data[0]; + char ifr_name[IFNAMSIZ]; + Boolean handled = TRUE; switch (ev_msg->kev_subclass) { case KEV_INET_SUBCLASS : { @@ -384,7 +385,6 @@ processEvent_Apple_Network(struct kern_event_msg *ev_msg) case KEV_INET6_ADDR_DELETED : case KEV_INET6_NEW_LL_ADDR : case KEV_INET6_NEW_RTADV_ADDR : - case KEV_INET6_DEFROUTER : if (dataLen < sizeof(*ev)) { handled = FALSE; break; @@ -405,6 +405,16 @@ processEvent_Apple_Network(struct kern_event_msg *ev_msg) } break; + case KEV_INET6_REQUEST_NAT64_PREFIX : + if (dataLen < sizeof(*ev)) { + handled = FALSE; + break; + } + copy_if_name(&ev->link_data, ifr_name, sizeof(ifr_name)); + SC_log(LOG_INFO, "Process NAT64 prefix request: %s", (char *)ifr_name); + nat64_prefix_request(ifr_name); + break; + default : break; } @@ -466,9 +476,10 @@ processEvent_Apple_Network(struct kern_event_msg *ev_msg) } copy_if_name(&protoEvent->link_data, ifr_name, sizeof(ifr_name)); - SC_log(LOG_INFO, "Process protocol %s: %s (n=%d)", + SC_log(LOG_INFO, "Process protocol %s: %s (pf=%d, n=%d)", (ev_msg->event_code == KEV_DL_PROTO_ATTACHED) ? "attach" : "detach", (char *)ifr_name, + protoEvent->proto_family, protoEvent->proto_remaining_count); if (protoEvent->proto_remaining_count == 0) { mark_if_down(ifr_name); @@ -573,6 +584,33 @@ processEvent_Apple_Network(struct kern_event_msg *ev_msg) #ifdef KEV_ND6_SUBCLASS case KEV_ND6_SUBCLASS : { + struct kev_nd6_event * ev; + + ev = (struct kev_nd6_event *)event_data; + switch (ev_msg->event_code) { + case KEV_ND6_ADDR_DETACHED : + case KEV_ND6_ADDR_DEPRECATED : + case KEV_ND6_ADDR_EXPIRED : + if (dataLen < sizeof(*ev)) { + handled = FALSE; + break; + } + copy_if_name(&ev->link_data, ifr_name, sizeof(ifr_name)); + SC_log(LOG_INFO, "Process ND6 address change: %s: %d", (char *)ifr_name, ev_msg->event_code); + interface_update_ipv6(NULL, ifr_name); + break; + case KEV_ND6_RTR_EXPIRED : + if (dataLen < sizeof(*ev)) { + handled = FALSE; + break; + } + copy_if_name(&ev->link_data, ifr_name, sizeof(ifr_name)); + SC_log(LOG_INFO, "Process IPv6 router expired: %s: %d", (char *)ifr_name, ev_msg->event_code); + ipv6_router_expired(ifr_name); + break; + default : + break; + } break; } #endif // KEV_ND6_SUBCLASS @@ -614,13 +652,13 @@ processEvent_Apple_Network(struct kern_event_msg *ev_msg) static Boolean eventCallback(int so) { - ssize_t status; union { char bytes[1024]; struct kern_event_msg ev_msg1; // first kernel event } buf; struct kern_event_msg *ev_msg = &buf.ev_msg1; ssize_t offset = 0; + ssize_t status; status = recv(so, &buf, sizeof(buf), 0); if (status == -1) { @@ -631,7 +669,7 @@ eventCallback(int so) cache_open(); while (offset < status) { - if ((offset + ev_msg->total_size) > status) { + if ((offset + (ssize_t)ev_msg->total_size) > status) { SC_log(LOG_NOTICE, "missed SYSPROTO_EVENT event, buffer not big enough"); break; } @@ -751,6 +789,7 @@ schedule_timer(void) static void check_for_new_interfaces(void * context) { +#pragma unused(context) static int count; char msg[32]; diff --git a/Plugins/LinkConfiguration/Info.plist b/Plugins/LinkConfiguration/Info.plist index 28308f6..bccd851 100644 --- a/Plugins/LinkConfiguration/Info.plist +++ b/Plugins/LinkConfiguration/Info.plist @@ -17,11 +17,11 @@ CFBundlePackageType BNDL CFBundleShortVersionString - 1.14 + 1.17 CFBundleSignature ???? CFBundleVersion - 1.14 + 1.17 Requires com.apple.SystemConfiguration.InterfaceNamer diff --git a/Plugins/LinkConfiguration/linkconfig.c b/Plugins/LinkConfiguration/linkconfig.c index 1690d54..0da7db8 100644 --- a/Plugins/LinkConfiguration/linkconfig.c +++ b/Plugins/LinkConfiguration/linkconfig.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2002-2007, 2011, 2013, 2015, 2016 Apple Inc. All rights reserved. + * Copyright (c) 2002-2007, 2011, 2013, 2015-2017 Apple Inc. All rights reserved. * * @APPLE_LICENSE_HEADER_START@ * @@ -37,7 +37,8 @@ #include #include -#define SC_LOG_HANDLE __log_LinkConfiguration() +#define SC_LOG_HANDLE __log_LinkConfiguration() +#define SC_LOG_HANDLE_TYPE static #include "SCNetworkConfigurationInternal.h" #include // for _SCDPluginExecCommand @@ -136,7 +137,7 @@ _SCNetworkInterfaceSetCapabilities(SCNetworkInterfaceRef interface, ret = ioctl(sock, SIOCSIFCAP, (caddr_t)&ifr); (void)close(sock); if (ret == -1) { - SC_log(LOG_INFO, "ioctl(SIOCSIFCAP) failed: %s", strerror(errno)); + SC_log(LOG_ERR, "%@: ioctl(SIOCSIFCAP) failed: %s", interfaceName, strerror(errno)); return FALSE; } #endif // SIOCSIFCAP @@ -265,7 +266,7 @@ _SCNetworkInterfaceSetMediaOptions(SCNetworkInterfaceRef interface, (void)_SC_cfstring_to_cstring(interfaceName, ifm.ifm_name, sizeof(ifm.ifm_name), kCFStringEncodingASCII); if (ioctl(sock, SIOCGIFMEDIA, (caddr_t)&ifm) == -1) { - SC_log(LOG_NOTICE, "ioctl(SIOCGIFMEDIA) failed: %s", strerror(errno)); + SC_log(LOG_ERR, "%@: ioctl(SIOCGIFMEDIA) failed: %s", interfaceName, strerror(errno)); goto done; } @@ -278,7 +279,7 @@ _SCNetworkInterfaceSetMediaOptions(SCNetworkInterfaceRef interface, SC_log(LOG_INFO, "new media settings: 0x%8.8x", ifr.ifr_media); if (ioctl(sock, SIOCSIFMEDIA, (caddr_t)&ifr) == -1) { - SC_log(LOG_NOTICE, "%@: ioctl(SIOCSIFMEDIA) failed: %s", interfaceName, strerror(errno)); + SC_log(LOG_ERR, "%@: ioctl(SIOCSIFMEDIA) failed: %s", interfaceName, strerror(errno)); goto done; } @@ -303,6 +304,8 @@ _SCNetworkInterfaceSetMediaOptions(SCNetworkInterfaceRef interface, static void ifconfig_exit(pid_t pid, int status, struct rusage *rusage, void *context) { +#pragma unused(pid) +#pragma unused(rusage) char *if_name = (char *)context; if (WIFEXITED(status)) { @@ -437,7 +440,7 @@ _SCNetworkInterfaceSetMTU(SCNetworkInterfaceRef interface, ret = ioctl(sock, SIOCSIFMTU, (caddr_t)&ifr); (void)close(sock); if (ret == -1) { - SC_log(LOG_NOTICE, "ioctl(SIOCSIFMTU) failed: %s", strerror(errno)); + SC_log(LOG_ERR, "%@: ioctl(SIOCSIFMTU) failed: %s", interfaceName, strerror(errno)); ok = FALSE; goto done; } @@ -658,6 +661,7 @@ updateLink(CFStringRef interfaceName, CFDictionaryRef options) static void linkConfigChangedCallback(SCDynamicStoreRef store, CFArrayRef changedKeys, void *arg) { +#pragma unused(arg) os_activity_t activity; CFDictionaryRef changes; CFIndex i; @@ -721,6 +725,7 @@ __private_extern__ void load_LinkConfiguration(CFBundleRef bundle, Boolean bundleVerbose) { +#pragma unused(bundleVerbose) CFStringRef key; CFMutableArrayRef keys = NULL; Boolean ok; diff --git a/Plugins/PreferencesMonitor/Info.plist b/Plugins/PreferencesMonitor/Info.plist index 7532788..f23fa3b 100644 --- a/Plugins/PreferencesMonitor/Info.plist +++ b/Plugins/PreferencesMonitor/Info.plist @@ -15,11 +15,11 @@ CFBundlePackageType BNDL CFBundleShortVersionString - 1.14 + 1.17 CFBundleSignature ???? CFBundleVersion - 1.14 + 1.17 Builtin Requires diff --git a/Plugins/PreferencesMonitor/prefsmon.c b/Plugins/PreferencesMonitor/prefsmon.c index 52e7fe9..ac7bbdd 100644 --- a/Plugins/PreferencesMonitor/prefsmon.c +++ b/Plugins/PreferencesMonitor/prefsmon.c @@ -43,7 +43,8 @@ #include -#define SC_LOG_HANDLE __log_PreferencesMonitor() +#define SC_LOG_HANDLE __log_PreferencesMonitor() +#define SC_LOG_HANDLE_TYPE static #include #include #include @@ -327,8 +328,12 @@ establishNewPreferences() } if (!ok) { - SC_log(LOG_NOTICE, "Could not establish network configuration: %s", - SCErrorString(sc_status)); + if (sc_status == kSCStatusOK) { + SC_log(LOG_NOTICE, "Network configuration not updated"); + } else { + SC_log(LOG_NOTICE, "Could not establish network configuration: %s", + SCErrorString(sc_status)); + } } (void)SCPreferencesUnlock(prefs); @@ -382,8 +387,6 @@ watchSCDynamicStore() } - - static Boolean previousConfigurationAvailable() { @@ -408,6 +411,7 @@ done: static void storeCallback(SCDynamicStoreRef store, CFArrayRef changedKeys, void *info) { +#pragma unused(info) CFDictionaryRef dict; Boolean quiet = FALSE; Boolean timeout = FALSE; @@ -542,6 +546,7 @@ storeCallback(SCDynamicStoreRef store, CFArrayRef changedKeys, void *info) static void updateCache(const void *key, const void *value, void *context) { +#pragma unused(context) CFStringRef configKey = (CFStringRef)key; CFPropertyListRef configData = (CFPropertyListRef)value; CFPropertyListRef cacheData; @@ -1056,6 +1061,7 @@ updateConfiguration(SCPreferencesRef prefs, SCPreferencesNotification notificationType, void *info) { +#pragma unused(info) os_activity_t activity; activity = os_activity_create("processing [SC] preferences.plist changes", @@ -1118,6 +1124,8 @@ __private_extern__ void load_PreferencesMonitor(CFBundleRef bundle, Boolean bundleVerbose) { +#pragma unused(bundle) +#pragma unused(bundleVerbose) SC_log(LOG_DEBUG, "load() called"); SC_log(LOG_DEBUG, " bundle ID = %@", CFBundleGetIdentifier(bundle)); diff --git a/Plugins/QoSMarking/Info.plist b/Plugins/QoSMarking/Info.plist index e0a7b05..a50488c 100644 --- a/Plugins/QoSMarking/Info.plist +++ b/Plugins/QoSMarking/Info.plist @@ -17,21 +17,17 @@ CFBundlePackageType BNDL CFBundleShortVersionString - 1.14 + 1.17 CFBundleSignature ???? CFBundleVersion - 1.14 + 1.17 QoSMarking_AppleAudioVideoCalls_BundleIDs com.apple.datausage.telephony.ims com.apple.facetime com.apple.siri - QoSMarking_AppleAudioVideoCalls_ExecutablePaths - - /usr/libexec/networkserviceproxy - Requires com.apple.SystemConfiguration.InterfaceNamer diff --git a/Plugins/QoSMarking/qos-marking.m b/Plugins/QoSMarking/qos-marking.m index c08f1b5..6c3f953 100644 --- a/Plugins/QoSMarking/qos-marking.m +++ b/Plugins/QoSMarking/qos-marking.m @@ -1,5 +1,5 @@ /* - * Copyright (c) 2016 Apple Inc. All rights reserved. + * Copyright (c) 2016, 2017 Apple Inc. All rights reserved. * * @APPLE_LICENSE_HEADER_START@ * @@ -135,16 +135,24 @@ supportsQoSMarking(int s, const char *ifname) bzero(&ifr, sizeof(ifr)); strlcpy(ifr.ifr_name, ifname, sizeof(ifr.ifr_name)); if (ioctl(s, SIOCGIFTYPE, (caddr_t)&ifr) == -1) { - SC_log(LOG_NOTICE, "%s: ioctl(SIOCGIFTYPE) failed: %m", ifname); + SC_log(LOG_NOTICE, "%s: ioctl(SIOCGIFTYPE) failed: %s", + ifname, + strerror(errno)); ifr.ifr_type.ift_type = 0; ifr.ifr_type.ift_family = IFRTYPE_FAMILY_ANY; ifr.ifr_type.ift_subfamily = IFRTYPE_SUBFAMILY_ANY; } +#if !TARGET_OS_IPHONE + if (ifr.ifr_type.ift_family == IFRTYPE_FAMILY_ETHERNET) { + return true; + } +#else // !TARGET_OS_IPHONE if ((ifr.ifr_type.ift_family == IFRTYPE_FAMILY_ETHERNET) && (ifr.ifr_type.ift_subfamily == IFRTYPE_SUBFAMILY_WIFI)) { return true; } +#endif // !TARGET_OS_IPHONE return false; } @@ -227,55 +235,7 @@ qosMarkingSetEnabled(int s, const char *ifname, BOOL enabled) - (NEPolicySession *)createPolicySession { - NEPolicySession *session = nil; -#if !TARGET_OS_IPHONE - /* - * Note: we cannot have entitlements on OSX so we open a kernel - * control socket and use it to create a policy session - */ - - struct sockaddr_ctl kernctl_addr; - struct ctl_info kernctl_info; - int sock; - - // Create kernel control socket - sock = socket(PF_SYSTEM, SOCK_DGRAM, SYSPROTO_CONTROL); - if (sock == -1) { - SC_log(LOG_ERR, "socket() failed: %s", strerror(errno)); - return nil; - } - - bzero(&kernctl_info, sizeof(kernctl_info)); - strlcpy(kernctl_info.ctl_name, NECP_CONTROL_NAME, sizeof(kernctl_info.ctl_name)); - if (ioctl(sock, CTLIOCGINFO, &kernctl_info)) { - SC_log(LOG_ERR, "ioctl() failed: %s", strerror(errno)); - close(sock); - return nil; - } - - bzero(&kernctl_addr, sizeof(kernctl_addr)); - kernctl_addr.sc_len = sizeof(kernctl_addr); - kernctl_addr.sc_family = AF_SYSTEM; - kernctl_addr.ss_sysaddr = AF_SYS_CONTROL; - kernctl_addr.sc_id = kernctl_info.ctl_id; - kernctl_addr.sc_unit = 0; - if (connect(sock, (struct sockaddr *)&kernctl_addr, sizeof(kernctl_addr))) { - SC_log(LOG_ERR, "connect() failed: %s", strerror(errno)); - close(sock); - return nil; - } - - /* Create policy session */ - session = [[NEPolicySession alloc] initWithSocket:sock]; - if (session == nil) { - close(sock); - } - -#else // !TARGET_OS_IPHONE - session = [[NEPolicySession alloc] init]; -#endif // !TARGET_OS_IPHONE - - return session; + return [[NEPolicySession alloc] init]; } @@ -613,6 +573,7 @@ qosMarkingSetEnabled(int s, const char *ifname, BOOL enabled) uuids = [NSMutableArray array]; xpc_array_apply(mapping, ^bool(size_t index, xpc_object_t value) { +#pragma unused(index) if ((value != NULL) && (xpc_get_type(value) == XPC_TYPE_UUID)) { NSUUID * uuid; @@ -1074,6 +1035,7 @@ parse_component(CFStringRef key, CFStringRef prefix) static void qosMarkingConfigChangedCallback(SCDynamicStoreRef store, CFArrayRef changedKeys, void *arg) { +#pragma unused(arg) os_activity_t activity; CFDictionaryRef changes; CFIndex n; @@ -1149,6 +1111,7 @@ __private_extern__ void load_QoSMarking(CFBundleRef bundle, Boolean bundleVerbose) { +#pragma unused(bundleVerbose) CFDictionaryRef dict; CFStringRef key; CFMutableArrayRef keys; diff --git a/Plugins/SimulatorSupport/Info.plist b/Plugins/SimulatorSupport/Info.plist index a53febe..47f1a6b 100644 --- a/Plugins/SimulatorSupport/Info.plist +++ b/Plugins/SimulatorSupport/Info.plist @@ -17,10 +17,10 @@ CFBundlePackageType BNDL CFBundleShortVersionString - 1.14 + 1.17 CFBundleSignature ???? CFBundleVersion - 1.14 + 1.17 diff --git a/Plugins/SimulatorSupport/simulator_support.c b/Plugins/SimulatorSupport/simulator_support.c index f05022d..3a8def0 100644 --- a/Plugins/SimulatorSupport/simulator_support.c +++ b/Plugins/SimulatorSupport/simulator_support.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013, 2015, 2016 Apple Inc. All rights reserved. + * Copyright (c) 2013, 2015-2017 Apple Inc. All rights reserved. * * @APPLE_LICENSE_HEADER_START@ * @@ -72,6 +72,7 @@ __log_SimulatorSupport() static void mirror(SCDynamicStoreRef store, CFArrayRef changes, void *info) { +#pragma unused(store) CFDictionaryRef content_host; CFDictionaryRef content_sim; CFIndex i; @@ -255,6 +256,7 @@ __private_extern__ void load_SimulatorSupport(CFBundleRef bundle, Boolean bundleVerbose) { +#pragma unused(bundleVerbose) Boolean ok; CFMutableDictionaryRef options; CFRunLoopSourceRef rls; diff --git a/Plugins/common/IPMonitorControlPrefs.c b/Plugins/common/IPMonitorControlPrefs.c index 358e298..d6eddca 100644 --- a/Plugins/common/IPMonitorControlPrefs.c +++ b/Plugins/common/IPMonitorControlPrefs.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013, 2015, 2016 Apple Inc. All rights reserved. + * Copyright (c) 2013, 2015-2017 Apple Inc. All rights reserved. * * @APPLE_LICENSE_HEADER_START@ * @@ -67,8 +67,9 @@ IPMonitorControlPrefsGet(void) } static void -prefs_changed(__unused void * arg) +prefs_changed(void * arg) { +#pragma unused(arg) os_activity_t activity; activity = os_activity_create("processing IPMonitor [rank] preference change", @@ -139,6 +140,7 @@ enable_prefs_observer(CFRunLoopRef runloop) static void enable_prefs_observer(CFRunLoopRef runloop) { +#pragma unused(runloop) return; } @@ -149,6 +151,9 @@ IPMonitorControlPrefsChanged(SCPreferencesRef prefs, SCPreferencesNotification type, void * info) { +#pragma unused(prefs) +#pragma unused(type) +#pragma unused(info) prefs_changed(NULL); return; } diff --git a/Plugins/common/IPMonitorControlPrefs.h b/Plugins/common/IPMonitorControlPrefs.h index e34d378..b1b0002 100644 --- a/Plugins/common/IPMonitorControlPrefs.h +++ b/Plugins/common/IPMonitorControlPrefs.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013 Apple Inc. All rights reserved. + * Copyright (c) 2013, 2017 Apple Inc. All rights reserved. * * @APPLE_LICENSE_HEADER_START@ * @@ -21,8 +21,8 @@ * @APPLE_LICENSE_HEADER_END@ */ -#ifndef _EAP8021X_EAPOLCONTROLPREFS_H -#define _EAP8021X_EAPOLCONTROLPREFS_H +#ifndef _IPMONITORCONTROLPREFS_H +#define _IPMONITORCONTROLPREFS_H /* * IPMonitorControlPrefs.h @@ -51,4 +51,4 @@ IPMonitorControlPrefsIsVerbose(void); Boolean IPMonitorControlPrefsSetVerbose(Boolean verbose); -#endif /* _COMMON_IPMONITORCONTROLPREFS_H */ +#endif /* _IPMONITORCONTROLPREFS_H */ diff --git a/Plugins/common/InterfaceNamerControlPrefs.c b/Plugins/common/InterfaceNamerControlPrefs.c index c559026..2fa9dd4 100644 --- a/Plugins/common/InterfaceNamerControlPrefs.c +++ b/Plugins/common/InterfaceNamerControlPrefs.c @@ -39,8 +39,6 @@ #include #include "InterfaceNamerControlPrefs.h" -os_log_t __log_InterfaceNamer(); - /* * kInterfaceNamerControlPrefsID * - identifies the InterfaceNamer preferences file that contains 'AllowNewInterfaces' diff --git a/Plugins/common/cache.c b/Plugins/common/cache.c index c006238..49b614e 100644 --- a/Plugins/common/cache.c +++ b/Plugins/common/cache.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2004, 2006, 2011, 2015, 2016 Apple Inc. All rights reserved. + * Copyright (c) 2003, 2004, 2006, 2011, 2015-2017 Apple Inc. All rights reserved. * * @APPLE_LICENSE_HEADER_START@ * @@ -109,6 +109,7 @@ __private_extern__ void cache_SCDynamicStoreSetValue(SCDynamicStoreRef store, CFStringRef key, CFPropertyListRef value) { +#pragma unused(store) CFIndex i; i = CFArrayGetFirstIndexOfValue(cached_removals, @@ -128,6 +129,7 @@ __private_extern__ void cache_SCDynamicStoreRemoveValue(SCDynamicStoreRef store, CFStringRef key) { +#pragma unused(store) CFDictionaryRemoveValue(cached_set, key); if (!CFArrayContainsValue(cached_removals, @@ -144,6 +146,7 @@ __private_extern__ void cache_SCDynamicStoreNotifyValue(SCDynamicStoreRef store, CFStringRef key) { +#pragma unused(store) if (!CFArrayContainsValue(cached_notifys, CFRangeMake(0, CFArrayGetCount(cached_notifys)), key)) { diff --git a/SCMonitor/English.lproj/Localizable.strings b/SCMonitor/English.lproj/Localizable.strings index 254469037da82dfcc7cc9eed965dc5cbdea2726e..1234856f1d9e5a586a7b612bb3ca50f21c77c13a 100644 GIT binary patch delta 43 zcmX@XbA*TK|G&vcnanm?9%JN?QBY-YV31Xqtk0~nS)b`XGc$vl!el`CFBundlePackageType BNDL CFBundleShortVersionString - 1.14 + 1.17 CFBundleSignature ???? CFBundleVersion diff --git a/SCMonitor/monitor.c b/SCMonitor/monitor.c index d0d43f6..e54134a 100644 --- a/SCMonitor/monitor.c +++ b/SCMonitor/monitor.c @@ -33,7 +33,8 @@ #include #include -#define SC_LOG_HANDLE __log_SCMonitor() +#define SC_LOG_HANDLE __log_SCMonitor() +#define SC_LOG_HANDLE_TYPE static #include #include @@ -204,6 +205,7 @@ freeAuthorization(MyType *myInstance) static void open_NetworkPrefPane(MyType *myInstance) { +#pragma unused(myInstance) AEDesc aeDesc = { typeNull, NULL }; CFArrayRef prefArray; CFURLRef prefURL; @@ -393,7 +395,7 @@ notify_add(MyType *myInstance) CFStringRef message; CFStringRef name; -#define MESSAGE_1 "The \"%@\" network interface has not been set up. To set up this interface, use Network Preferences." +#define MESSAGE_1 "The “%@” network interface has not been set up. To set up this interface, use Network Preferences." format = CFBundleCopyLocalizedString(bundle, CFSTR("MESSAGE_1"), @@ -779,6 +781,8 @@ updateInterfaceList(MyType *myInstance) static void update_lan(SCDynamicStoreRef store, CFArrayRef changes, void * arg) { +#pragma unused(store) +#pragma unused(changes) MyType *myInstance = (MyType *)arg; updateInterfaceList(myInstance); @@ -806,7 +810,7 @@ watcher_add_lan(MyType *myInstance) // watch for changes to the list of network interfaces keys = CFArrayCreate(NULL, (const void **)&key, 1, &kCFTypeArrayCallBacks); - SCDynamicStoreSetNotificationKeys(store, NULL, keys); + SCDynamicStoreSetNotificationKeys(store, keys, NULL); CFRelease(keys); myInstance->monitorRls = SCDynamicStoreCreateRunLoopSource(NULL, store, 0); CFRunLoopAddSource(CFRunLoopGetCurrent(), @@ -889,6 +893,7 @@ add_node_watcher(MyType *myInstance, io_registry_entry_t node, io_registry_entry static void update_node(void *refCon, io_service_t service, natural_t messageType, void *messageArgument) { +#pragma unused(messageArgument) CFIndex i; CFDataRef myData = (CFDataRef)refCon; MyType *myInstance; @@ -909,7 +914,7 @@ update_node(void *refCon, io_service_t service, natural_t messageType, void *mes return; } - val = IORegistryEntryCreateCFProperty(service, CFSTR("Initializing"), NULL, 0); + val = IORegistryEntryCreateCFProperty(service, kSCNetworkInterfaceInitializingKey, NULL, 0); if (val != NULL) { initializing = (isA_CFBoolean(val) && CFBooleanGetValue(val)); CFRelease(val); @@ -1362,6 +1367,7 @@ static UserEventAgentInterfaceStruct UserEventAgentInterfaceFtbl = { void * UserEventAgentFactory(CFAllocatorRef allocator, CFUUIDRef typeID) { +#pragma unused(allocator) MyType *newOne = NULL; if (CFEqual(typeID, kUserEventAgentTypeID)) { diff --git a/SystemConfiguration.fproj/BondConfiguration.c b/SystemConfiguration.fproj/BondConfiguration.c index aaf33be..dc16ad5 100644 --- a/SystemConfiguration.fproj/BondConfiguration.c +++ b/SystemConfiguration.fproj/BondConfiguration.c @@ -502,7 +502,7 @@ _SCBondInterfaceCopyActive(void) SCBondInterfaceRef SCBondInterfaceCreate(SCPreferencesRef prefs) { - CFAllocatorRef allocator; + CFAllocatorRef allocator; SCBondInterfaceRef bond = NULL; CFIndex i; @@ -1062,7 +1062,7 @@ static pthread_once_t bondStatus_init = PTHREAD_ONCE_INIT; static CFStringRef __SCBondStatusCopyDescription(CFTypeRef cf) { - CFAllocatorRef allocator = CFGetAllocator(cf); + CFAllocatorRef allocator = CFGetAllocator(cf); CFMutableStringRef result; SCBondStatusPrivateRef statusPrivate = (SCBondStatusPrivateRef)cf; @@ -1123,10 +1123,10 @@ __SCBondStatusInitialize(void) static SCBondStatusRef -__SCBondStatusCreatePrivate(CFAllocatorRef allocator, - SCBondInterfaceRef bond, - CFDictionaryRef status_bond, - CFDictionaryRef status_interfaces) +__SCBondStatusCreatePrivate(CFAllocatorRef __nullable allocator, + SCBondInterfaceRef bond, + CFDictionaryRef status_bond, + CFDictionaryRef status_interfaces) { SCBondStatusPrivateRef statusPrivate; uint32_t size; @@ -1638,7 +1638,7 @@ _SCBondInterfaceUpdateConfiguration(SCPreferencesRef prefs) a_bond = CFArrayGetValueAtIndex(active, j); a_bond_if = SCNetworkInterfaceGetBSDName(a_bond); a_bond_interfaces = SCBondInterfaceGetMemberInterfaces(a_bond); - a_bond_mode = SCBondInterfaceGetMode(a_bond); + a_bond_mode = SCBondInterfaceGetMode(a_bond); a_count = (a_bond_interfaces != NULL) ? CFArrayGetCount(a_bond_interfaces) : 0; if (CFEqual(c_bond_if, a_bond_if)) { diff --git a/SystemConfiguration.fproj/BridgeConfiguration.c b/SystemConfiguration.fproj/BridgeConfiguration.c index 3d984a0..55da5cf 100644 --- a/SystemConfiguration.fproj/BridgeConfiguration.c +++ b/SystemConfiguration.fproj/BridgeConfiguration.c @@ -136,7 +136,7 @@ add_interface(CFMutableArrayRef *interfaces, CFStringRef if_name, SCPreferencesR } if (interface == NULL) { interface = _SCNetworkInterfaceCreateWithBSDName(NULL, if_name, - kIncludeNoVirtualInterfaces); + kIncludeNoVirtualInterfaces); } if (interface != NULL) { @@ -454,10 +454,8 @@ _SCBridgeInterfaceCopyActive(void) // add member interfaces if (ibc_p->ifbic_len > 0) { - int i; - // iterate over each member interface - for (i = 0; i < ibc_p->ifbic_len / sizeof(struct ifbreq); i++) { + for (size_t i = 0; i < ibc_p->ifbic_len / sizeof(struct ifbreq); i++) { struct ifbreq *ibr_p; CFStringRef member; @@ -705,15 +703,36 @@ SCBridgeInterfaceSetMemberInterfaces(SCBridgeInterfaceRef bridge, CFArrayRef mem return FALSE; } - if ((members != NULL) && !isA_CFArray(members)) { - _SCErrorSet(kSCStatusInvalidArgument); - return FALSE; + if (members != NULL) { + CFIndex n_members; + + if (!isA_CFArray(members)) { + _SCErrorSet(kSCStatusInvalidArgument); + return FALSE; + } + + n_members = CFArrayGetCount(members); + for (CFIndex i = 0; i < n_members; i++) { + SCNetworkInterfaceRef member; + CFStringRef memberName; + + member = CFArrayGetValueAtIndex(members, i); + if (!isA_SCNetworkInterface(member)) { + _SCErrorSet(kSCStatusInvalidArgument); + return FALSE; + } + + memberName = SCNetworkInterfaceGetBSDName(member); + if (memberName == NULL) { + _SCErrorSet(kSCStatusInvalidArgument); + return FALSE; + } + } } if (interfacePrivate->prefs != NULL) { CFArrayRef available; CFArrayRef current; - CFIndex i; CFIndex n_available; CFIndex n_current; CFIndex n_members; @@ -726,7 +745,7 @@ SCBridgeInterfaceSetMemberInterfaces(SCBridgeInterfaceRef bridge, CFArrayRef mem n_available = (available != NULL) ? CFArrayGetCount(available) : 0; n_members = (members != NULL) ? CFArrayGetCount(members) : 0; - for (i = 0; i < n_members; i++) { + for (CFIndex i = 0; i < n_members; i++) { SCNetworkInterfaceRef member; member = CFArrayGetValueAtIndex(members, i); diff --git a/SystemConfiguration.fproj/DHCP.c b/SystemConfiguration.fproj/DHCP.c index 11d8302..88b8628 100644 --- a/SystemConfiguration.fproj/DHCP.c +++ b/SystemConfiguration.fproj/DHCP.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2001, 2003-2005, 2011, 2013, 2015 Apple Inc. All rights reserved. + * Copyright (c) 2001, 2003-2005, 2011, 2013, 2015, 2017 Apple Inc. All rights reserved. * * @APPLE_LICENSE_HEADER_START@ * @@ -101,7 +101,7 @@ S_application_path(CFStringRef applicationID) Boolean DHCPClientPreferencesSetApplicationOptions(CFStringRef applicationID, - UInt8 * options, + const UInt8 * options, CFIndex count) { CFMutableDictionaryRef dict = NULL; diff --git a/SystemConfiguration.fproj/DHCPClientPreferences.h b/SystemConfiguration.fproj/DHCPClientPreferences.h index 8d39c98..7010d0f 100644 --- a/SystemConfiguration.fproj/DHCPClientPreferences.h +++ b/SystemConfiguration.fproj/DHCPClientPreferences.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2001, 2004, 2005, 2008, 2015 Apple Inc. All rights reserved. + * Copyright (c) 2001, 2004, 2005, 2008, 2015, 2017 Apple Inc. All rights reserved. * * @APPLE_LICENSE_HEADER_START@ * @@ -58,7 +58,7 @@ __BEGIN_DECLS Boolean DHCPClientPreferencesSetApplicationOptions (CFStringRef applicationID, - UInt8 * __nullable options, + const UInt8 * __nullable options, CFIndex count) __OSX_AVAILABLE_STARTING(__MAC_10_1,__IPHONE_2_0/*SPI*/); /*! diff --git a/SystemConfiguration.fproj/English.lproj/NetworkInterface.strings b/SystemConfiguration.fproj/English.lproj/NetworkInterface.strings index aba71b56672fc53e7aabd2d775de7a1abe1f3404..dd0b14bef0fc9f3312aca03bdd6ff65f0b586418 100644 GIT binary patch delta 84 zcmaE7^vZa{8Zlud21kYhAk1M%Wl&%UWe8?)n%u}JIyr}#OFosMh(QS`Y74}8)G-6q KZC)&Pnh5|zP!kgX delta 12 TcmaE5{LW~@8nMk9;)j?3DCGra diff --git a/SystemConfiguration.fproj/Info-Embedded.plist b/SystemConfiguration.fproj/Info-Embedded.plist index 1f27296..b42b8df 100644 --- a/SystemConfiguration.fproj/Info-Embedded.plist +++ b/SystemConfiguration.fproj/Info-Embedded.plist @@ -7,7 +7,7 @@ CFBundleExecutable SystemConfiguration CFBundleGetInfoString - 1.14 + 1.17 CFBundleIdentifier $(PRODUCT_BUNDLE_IDENTIFIER) CFBundleInfoDictionaryVersion @@ -17,10 +17,10 @@ CFBundlePackageType FMWK CFBundleShortVersionString - 1.14 + 1.17 CFBundleSignature ???? CFBundleVersion - 1.14 + 1.17 diff --git a/SystemConfiguration.fproj/Info.plist b/SystemConfiguration.fproj/Info.plist index 1f27296..b42b8df 100644 --- a/SystemConfiguration.fproj/Info.plist +++ b/SystemConfiguration.fproj/Info.plist @@ -7,7 +7,7 @@ CFBundleExecutable SystemConfiguration CFBundleGetInfoString - 1.14 + 1.17 CFBundleIdentifier $(PRODUCT_BUNDLE_IDENTIFIER) CFBundleInfoDictionaryVersion @@ -17,10 +17,10 @@ CFBundlePackageType FMWK CFBundleShortVersionString - 1.14 + 1.17 CFBundleSignature ???? CFBundleVersion - 1.14 + 1.17 diff --git a/SystemConfiguration.fproj/LinkConfiguration.c b/SystemConfiguration.fproj/LinkConfiguration.c index dc4ef3f..bbbc281 100644 --- a/SystemConfiguration.fproj/LinkConfiguration.c +++ b/SystemConfiguration.fproj/LinkConfiguration.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2002-2007, 2010, 2011, 2013, 2015, 2016 Apple Inc. All rights reserved. + * Copyright (c) 2002-2007, 2010, 2011, 2013, 2015-2017 Apple Inc. All rights reserved. * * @APPLE_LICENSE_HEADER_START@ * @@ -80,9 +80,7 @@ static const struct { static CFIndex findCapability(CFStringRef capability) { - CFIndex i; - - for (i = 0; i < sizeof(capabilityMappings) / sizeof(capabilityMappings[0]); i++) { + for (size_t i = 0; i < sizeof(capabilityMappings) / sizeof(capabilityMappings[0]); i++) { if (CFEqual(capability, *capabilityMappings[i].name)) { return i; } @@ -152,7 +150,6 @@ __SCNetworkInterfaceCreateCapabilities(SCNetworkInterfaceRef interface, { int cap_available = 0; int cap_current = capability_base; - CFIndex i; CFStringRef interfaceName; if (!isA_SCNetworkInterface(interface)) { @@ -180,7 +177,7 @@ __SCNetworkInterfaceCreateCapabilities(SCNetworkInterfaceRef interface, goto done; } - for (i = 0; i < sizeof(capabilityMappings) / sizeof(capabilityMappings[0]); i++) { + for (size_t i = 0; i < sizeof(capabilityMappings) / sizeof(capabilityMappings[0]); i++) { int cap_val; CFTypeRef val; @@ -216,7 +213,6 @@ SCNetworkInterfaceCopyCapability(SCNetworkInterfaceRef interface, int cap_current = 0; int cap_available = 0; int cap_val; - CFIndex i; CFStringRef interfaceName; CFTypeRef val = NULL; @@ -239,7 +235,7 @@ SCNetworkInterfaceCopyCapability(SCNetworkInterfaceRef interface, CFMutableDictionaryRef all = NULL; // if ALL capabilities requested - for (i = 0; i < sizeof(capabilityMappings) / sizeof(capabilityMappings[0]); i++) { + for (size_t i = 0; i < sizeof(capabilityMappings) / sizeof(capabilityMappings[0]); i++) { if ((cap_available & capabilityMappings[i].val) == capabilityMappings[i].val) { if (all == NULL) { all = CFDictionaryCreateMutable(NULL, @@ -257,6 +253,8 @@ SCNetworkInterfaceCopyCapability(SCNetworkInterfaceRef interface, val = all; } else { + CFIndex i; + i = findCapability(capability); if (i == kCFNotFound) { // if unknown capability diff --git a/SystemConfiguration.fproj/SCD.c b/SystemConfiguration.fproj/SCD.c index c9dfe7d..9212a21 100644 --- a/SystemConfiguration.fproj/SCD.c +++ b/SystemConfiguration.fproj/SCD.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2000-2008, 2010-2016 Apple Inc. All rights reserved. + * Copyright (c) 2000-2008, 2010-2017 Apple Inc. All rights reserved. * * @APPLE_LICENSE_HEADER_START@ * @@ -34,7 +34,6 @@ #include #include #include -#include #include #include #include @@ -44,18 +43,13 @@ #include "SCD.h" #include "config.h" /* MiG generated file */ -// asl logging -#define INSTALL_FACILITY "install" #define INSTALL_ENVIRONMENT "__OSINSTALL_ENVIRONMENT" -// LIBASL SPI -extern asl_object_t _asl_server_control_query(void); - /* framework variables */ int _sc_debug = FALSE; /* non-zero if debugging enabled */ int _sc_verbose = FALSE; /* non-zero if verbose logging enabled */ int _sc_log = TRUE; /* 0 if SC messages should be written to stdout/stderr, - 1 if SC messages should be logged w/asl(3), + 1 if SC messages should be logged w/os_log(3), 2 if SC messages should be written to stdout/stderr AND logged */ @@ -73,7 +67,6 @@ __SCThreadSpecificDataFinalize(void *arg) __SCThreadSpecificDataRef tsd = (__SCThreadSpecificDataRef)arg; if (tsd != NULL) { - if (tsd->_asl != NULL) asl_release(tsd->_asl); if (tsd->_sc_store != NULL) CFRelease(tsd->_sc_store); CFAllocatorDeallocate(kCFAllocatorSystemDefault, tsd); } @@ -99,7 +92,6 @@ __SCGetThreadSpecificData() tsd = pthread_getspecific(tsDataKey); if (tsd == NULL) { tsd = CFAllocatorAllocate(kCFAllocatorSystemDefault, sizeof(__SCThreadSpecificData), 0); - tsd->_asl = NULL; tsd->_sc_error = kSCStatusOK; tsd->_sc_store = NULL; pthread_setspecific(tsDataKey, tsd); @@ -437,82 +429,13 @@ _SC_syslog_os_log_mapping(int level) }; static void -__SCLog(asl_object_t asl, asl_object_t msg, int level, void *ret_addr, CFStringRef formatString, va_list formatArguments) +__SCLog(void *ret_addr, os_log_type_t type, const char *formatString, va_list formatArguments) { - char *line; - CFArrayRef lines; - CFStringRef str; - - if ((asl == NULL) && (level >= 0)) { - const char *__format; - - __format = CFStringGetCStringPtr(formatString, kCFStringEncodingUTF8); - if (__format != NULL) { - os_log_type_t __type; - - __type = _SC_syslog_os_log_mapping(level); - os_log_with_args(_SC_LOG_DEFAULT(), - __type, - __format, - formatArguments, - ret_addr); - return; - } - } - - if (asl == NULL) { - __SCThreadSpecificDataRef tsd; - - tsd = __SCGetThreadSpecificData(); - if (tsd->_asl == NULL) { - tsd->_asl = asl_open(NULL, (_SC_isInstallEnvironment() ? INSTALL_FACILITY : NULL), 0); - asl_set_filter(tsd->_asl, ASL_FILTER_MASK_UPTO(ASL_LEVEL_DEBUG)); - } - asl = tsd->_asl; - } - -#ifdef ENABLE_SC_FORMATTING - str = _CFStringCreateWithFormatAndArgumentsAux(NULL, - _SCCopyDescription, - NULL, - formatString, - formatArguments); -#else /* ENABLE_SC_FORMATTING */ - str = CFStringCreateWithFormatAndArguments (NULL, - NULL, - formatString, - formatArguments); -#endif /* !ENABLE_SC_FORMATTING */ - - if (level >= 0) { - lines = CFStringCreateArrayBySeparatingStrings(NULL, str, CFSTR("\n")); - if (lines != NULL) { - CFIndex i; - CFIndex n = CFArrayGetCount(lines); - - for (i = 0; i < n; i++) { - line =_SC_cfstring_to_cstring_ext(CFArrayGetValueAtIndex(lines, i), - NULL, - 0, - kCFStringEncodingUTF8, - (UInt8)'?', - NULL); - asl_log(asl, msg, level, "%s", line); - CFAllocatorDeallocate(NULL, line); - } - CFRelease(lines); - } - } else { - line =_SC_cfstring_to_cstring_ext(str, - NULL, - 0, - kCFStringEncodingUTF8, - (UInt8)'?', - NULL); - asl_log(asl, msg, ~level, "%s", line); - CFAllocatorDeallocate(NULL, line); - } - CFRelease(str); + os_log_with_args(_SC_LOG_DEFAULT(), + type, + formatString, + formatArguments, + ret_addr); return; } @@ -570,60 +493,10 @@ __SCPrint(FILE *stream, CFStringRef formatString, va_list formatArguments, Boole } -void -SCLog(Boolean condition, int level, CFStringRef formatString, ...) -{ - va_list formatArguments; - va_list formatArguments_print; - Boolean log = FALSE; - Boolean print = FALSE; - - if (!condition) { - return; - } - - /* - * Note: The following are the expected values for _sc_log - * - * 0 if SC messages should be written to stdout/stderr - * 1 if SC messages should be logged w/asl(3) - * 2 if SC messages should be written to stdout/stderr AND logged - */ - - if (_sc_log > 0) { - log = TRUE; // log requested - va_start(formatArguments, formatString); - - if (_sc_log > 1) { - print = TRUE; // log AND print requested - va_copy(formatArguments_print, formatArguments); - } - } else { - print = TRUE; // print requested - va_start(formatArguments_print, formatString); - } - - if (log) { - __SCLog(NULL, NULL, level, __builtin_return_address(0), formatString, formatArguments); - va_end(formatArguments); - } - - if (print) { - __SCPrint((LOG_PRI(level) > LOG_NOTICE) ? stderr : stdout, - formatString, - formatArguments_print, - (_sc_log > 0), // trace - TRUE); // add newline - va_end(formatArguments_print); - } - - return; -} - - void __SC_Log(int level, CFStringRef format_CF, os_log_t log, os_log_type_t type, const char *format, ...) { +#pragma unused(level) Boolean do_log = FALSE; Boolean do_print = FALSE; va_list args_log; @@ -633,12 +506,12 @@ __SC_Log(int level, CFStringRef format_CF, os_log_t log, os_log_type_t type, con * Note: The following are the expected values for _sc_log * * 0 if SC messages should be written to stdout/stderr - * 1 if SC messages should be logged w/asl(3) + * 1 if SC messages should be logged w/os_log(3) * 2 if SC messages should be written to stdout/stderr AND logged */ if (_sc_log > 0) { - log = TRUE; // log requested + do_log = TRUE; // log requested va_start(args_log, format); if (_sc_log > 1) { @@ -651,21 +524,11 @@ __SC_Log(int level, CFStringRef format_CF, os_log_t log, os_log_type_t type, con } if (do_log) { - if (level >= 0) { - os_log_with_args(log, - type, - format, - args_log, - __builtin_return_address(0)); - } else { - // if we need to break apart a multi-line message - __SCLog(NULL, - NULL, - level, - __builtin_return_address(0), - format_CF, - args_log); - } + os_log_with_args(log, + type, + format, + args_log, + __builtin_return_address(0)); va_end(args_log); } @@ -679,23 +542,26 @@ __SC_Log(int level, CFStringRef format_CF, os_log_t log, os_log_type_t type, con } return; - } void -SCLOG(asl_object_t asl, asl_object_t msg, int level, CFStringRef formatString, ...) +SCLog(Boolean condition, int level, CFStringRef formatString, ...) { va_list formatArguments; va_list formatArguments_print; Boolean log = FALSE; Boolean print = FALSE; + if (!condition) { + return; + } + /* * Note: The following are the expected values for _sc_log * * 0 if SC messages should be written to stdout/stderr - * 1 if SC messages should be logged w/asl(3) + * 1 if SC messages should be logged w/os_log(3) * 2 if SC messages should be written to stdout/stderr AND logged */ @@ -713,15 +579,20 @@ SCLOG(asl_object_t asl, asl_object_t msg, int level, CFStringRef formatString, . } if (log) { - __SCLog(asl, msg, level, __builtin_return_address(0), formatString, formatArguments); + const char *__format; + + __format = CFStringGetCStringPtr(formatString, kCFStringEncodingUTF8); + if (__format != NULL) { + os_log_type_t __type; + + __type = _SC_syslog_os_log_mapping(level); + __SCLog(__builtin_return_address(0), __type, __format, formatArguments); + } va_end(formatArguments); } if (print) { - if (level < 0) { - level = ~level; - } - __SCPrint((level > ASL_LEVEL_NOTICE) ? stderr : stdout, + __SCPrint((LOG_PRI(level) > LOG_NOTICE) ? stderr : stdout, formatString, formatArguments_print, (_sc_log > 0), // trace @@ -750,349 +621,6 @@ SCPrint(Boolean condition, FILE *stream, CFStringRef formatString, ...) } -#pragma mark - -#pragma mark ASL Functions - - -static CFTypeID __kSCLoggerTypeID = _kCFRuntimeNotATypeID; - -typedef enum { - kModuleStatusEnabled, - kModuleStatusDisabled, - kModuleStatusDoesNotExist -} ModuleStatus; - -struct SCLogger -{ - CFRuntimeBase cf_base; - - char * loggerID; // LoggerID - SCLoggerFlags flags; - asl_object_t aslc; - asl_object_t aslm; - ModuleStatus module_status; - pthread_mutex_t lock; -}; - - -static void __SCLoggerDeallocate(CFTypeRef cf); -static const CFRuntimeClass __SCLoggerClass = { - 0, /* version */ - "SCLogger", /* className */ - NULL, /* init */ - NULL, /* copy */ - __SCLoggerDeallocate, /* deallocate */ - NULL, /* equal */ - NULL, /* hash */ - NULL, /* copyFormattingDesc */ - NULL /* copyDebugDesc */ -}; - - -#define DATETIMEBUFFERSIZE 32 - - -static pthread_once_t registerLoggerOnce = PTHREAD_ONCE_INIT; -static pthread_once_t defaultLoggerOnce = PTHREAD_ONCE_INIT; - -typedef enum { - kLoggerASLControlEnableModule, - kLoggerASLControlDisableModule, - kLoggerASLControlLogFileCheckpoint -} LoggerASLControl; - -static SCLoggerRef defaultLogger = NULL; -static SCLoggerRef __SCLoggerCreate(void); -static void __SCLoggerDefaultLoggerInit(); -static SCLoggerRef SCLoggerGetDefaultLogger(); -static void SCLoggerSetLoggerID(SCLoggerRef logger, CFStringRef loggerID); -static void SCLoggerSendMessageToModuleOnly(SCLoggerRef logger, Boolean isPrivate); -static void SCLoggerSendASLControl(SCLoggerRef logger, LoggerASLControl control); -static ModuleStatus GetModuleStatus(const char * loggerID); - -static void -__SCLoggerRegisterClass(void) -{ - if (__kSCLoggerTypeID == _kCFRuntimeNotATypeID) { - __kSCLoggerTypeID = _CFRuntimeRegisterClass(&__SCLoggerClass); - } - return; -} - -static SCLoggerRef -__SCLoggerAllocate(CFAllocatorRef allocator) -{ - SCLoggerRef state; - int size; - - pthread_once(®isterLoggerOnce, __SCLoggerRegisterClass); - - size = sizeof(*state) - sizeof(CFRuntimeBase); - state = (SCLoggerRef) _CFRuntimeCreateInstance(allocator, - __kSCLoggerTypeID, - size, - NULL); - return (state); -} - -static void -__SCLoggerDeallocate(CFTypeRef cf) -{ - SCLoggerRef logger = (SCLoggerRef)cf; - - if (logger != NULL) { - // Rotate on close behavior - if (logger->module_status != kModuleStatusDoesNotExist) { - SCLoggerSendASLControl(logger, - kLoggerASLControlLogFileCheckpoint); - } - if (logger->loggerID != NULL) { - CFAllocatorDeallocate(NULL, logger->loggerID); - logger->loggerID = NULL; - } - if (logger->aslm != NULL) { - asl_release(logger->aslm); - logger->aslm = NULL; - } - if (logger->aslc != NULL) { - asl_release(logger->aslc); - logger->aslc = NULL; - } - } -} - -static SCLoggerRef -__SCLoggerCreate(void) -{ - SCLoggerRef tempLogger = NULL; - - tempLogger = __SCLoggerAllocate(kCFAllocatorDefault); - tempLogger->loggerID = NULL; - tempLogger->flags = kSCLoggerFlagsDefault; - tempLogger->aslc = asl_open(NULL, (_SC_isInstallEnvironment() ? INSTALL_FACILITY : NULL), ASL_OPT_NO_DELAY); - tempLogger->aslm = asl_new(ASL_TYPE_MSG); - pthread_mutex_init(&(tempLogger->lock), NULL); - tempLogger->module_status = kModuleStatusDoesNotExist; - - return tempLogger; -} - -SCLoggerFlags -SCLoggerGetFlags(SCLoggerRef logger) -{ - return logger->flags; -} - -void -SCLoggerSetFlags(SCLoggerRef logger, SCLoggerFlags flags) -{ - if (logger == defaultLogger) { - return; - } - pthread_mutex_lock(&(logger->lock)); - if (flags != kSCLoggerFlagsNone) { - logger->module_status = GetModuleStatus(logger->loggerID); - if (logger->module_status == kModuleStatusDoesNotExist) { - goto done; - } - if ((flags & kSCLoggerFlagsFile) != 0) { - if ((logger->flags & kSCLoggerFlagsFile) == 0) { - // Enable the module if disabled - if (logger->module_status == kModuleStatusDisabled) { - SCLoggerSendASLControl(logger, kLoggerASLControlEnableModule); - } - // Setting ASL Filter level to debug - asl_set_filter(logger->aslc, ASL_FILTER_MASK_UPTO(ASL_LEVEL_DEBUG)); - if (logger->loggerID != NULL) { - asl_set(logger->aslm, kLoggerID, - logger->loggerID); - } - } - } - else if ((logger->flags & kSCLoggerFlagsFile) != 0) { - asl_unset(logger->aslm, kLoggerID); - asl_set_filter(logger->aslc, ASL_FILTER_MASK_UPTO(ASL_LEVEL_NOTICE)); - SCLoggerSendMessageToModuleOnly(logger, false); - } - if ((flags & kSCLoggerFlagsDefault) != 0) { - if ((logger->flags & kSCLoggerFlagsDefault) == 0) { - SCLoggerSendMessageToModuleOnly(logger, false); - } - } - else if ((logger->flags & kSCLoggerFlagsDefault) != 0) { - SCLoggerSendMessageToModuleOnly(logger, true); - } - } - logger->flags = flags; - done: - pthread_mutex_unlock(&(logger->lock)); -} - - -static void -SCLoggerSetLoggerID(SCLoggerRef logger, CFStringRef loggerID) -{ - logger->loggerID - = _SC_cfstring_to_cstring(loggerID, NULL, 0, - kCFStringEncodingUTF8); - // Enable the module if disabled - logger->module_status = GetModuleStatus(logger->loggerID); - if (logger->module_status == kModuleStatusDisabled) { - SCLoggerSendASLControl(logger, kLoggerASLControlEnableModule); - } -} - -static ModuleStatus -GetModuleStatus(const char * loggerID) -{ - ModuleStatus moduleStatus = kModuleStatusDoesNotExist; - asl_object_t response = NULL; - const char* value = NULL; - - if (loggerID != NULL) { - response = _asl_server_control_query(); - if (response == NULL) { - goto done; - } - value = asl_get(response, loggerID); - if (value == NULL) { - moduleStatus = kModuleStatusDoesNotExist; - goto done; - } - - if (strcmp(value, "enabled") == 0) { - moduleStatus = kModuleStatusEnabled; - } - else { - moduleStatus = kModuleStatusDisabled; - } - } -done: - asl_release(response); - - return moduleStatus; -} - -static void -SCLoggerSendMessageToModuleOnly(SCLoggerRef logger, Boolean isPrivate) -{ - if (isPrivate) { - asl_set(logger->aslm, kASLModule, logger->loggerID); - } - else { - if (asl_get(logger->aslm, kASLModule) != NULL) { - asl_unset(logger->aslm, kASLModule); - } - } -} - -static void -SCLoggerSendASLControl(SCLoggerRef logger, LoggerASLControl control) -{ - SCLoggerRef defLogger = SCLoggerGetDefaultLogger(); - pthread_mutex_lock(&(defLogger->lock)); - - // this next line turns the asl_log()'s that follow into control messages - asl_set(defLogger->aslm, kASLOption, "control"); - - switch (control) { - case kLoggerASLControlEnableModule: - asl_log(defLogger->aslc, defLogger->aslm, - ASL_LEVEL_NOTICE, "@ %s enable 1", - logger->loggerID); - break; - case kLoggerASLControlDisableModule: - asl_log(defLogger->aslc, defLogger->aslm, - ASL_LEVEL_NOTICE, "@ %s enable 0", - logger->loggerID); - break; - case kLoggerASLControlLogFileCheckpoint: - asl_log(defLogger->aslc, defLogger->aslm, - ASL_LEVEL_NOTICE, "@ %s checkpoint", - logger->loggerID); - break; - default: - break; - } - - // turn off control mode - asl_unset(defLogger->aslm, kASLOption); - pthread_mutex_unlock(&defLogger->lock); - return; -} - -SCLoggerRef -SCLoggerCreate(CFStringRef loggerID) -{ - SCLoggerRef logger = NULL; - - logger = __SCLoggerCreate(); - if (loggerID != NULL) { - SCLoggerSetLoggerID(logger, loggerID); - } - SCLoggerSetFlags(logger, kSCLoggerFlagsDefault); - return logger; -} - -static void -__SCLoggerDefaultLoggerInit() -{ - if (defaultLogger == NULL) { - defaultLogger = __SCLoggerCreate(); - defaultLogger->flags = kSCLoggerFlagsDefault; - } -} - -static SCLoggerRef -SCLoggerGetDefaultLogger() -{ - pthread_once(&defaultLoggerOnce, __SCLoggerDefaultLoggerInit); - return defaultLogger; -} - -static void -SCLoggerVLogInternal(SCLoggerRef logger, int loglevel, void *ret_addr, - CFStringRef formatString, va_list args) -{ - asl_object_t aslc; - asl_object_t aslm; - - if (logger == NULL - || logger->module_status == kModuleStatusDoesNotExist) { - logger = SCLoggerGetDefaultLogger(); - } - pthread_mutex_lock(&(logger->lock)); - if (logger->flags == kSCLoggerFlagsNone) { - pthread_mutex_unlock(&(logger->lock)); - return; - } - aslc = logger->aslc; - aslm = logger->aslm; - __SCLog(aslc, aslm, loglevel, ret_addr, formatString, args); - pthread_mutex_unlock(&(logger->lock)); - return; -} - -void -SCLoggerLog(SCLoggerRef logger, int loglevel, CFStringRef formatString, ...) -{ - va_list args; - - va_start(args, formatString); - SCLoggerVLogInternal(logger, loglevel, __builtin_return_address(0), formatString, args); - va_end(args); - - return; -} - -void -SCLoggerVLog(SCLoggerRef logger, int loglevel, CFStringRef formatString, va_list args) -{ - SCLoggerVLogInternal(logger, loglevel, __builtin_return_address(0), formatString, args); - return; -} - - #pragma mark - #pragma mark SC error handling / logging diff --git a/SystemConfiguration.fproj/SCD.h b/SystemConfiguration.fproj/SCD.h index 747030b..45f9a54 100644 --- a/SystemConfiguration.fproj/SCD.h +++ b/SystemConfiguration.fproj/SCD.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2011, 2016 Apple Inc. All rights reserved. + * Copyright (c) 2011, 2016, 2017 Apple Inc. All rights reserved. * * @APPLE_LICENSE_HEADER_START@ * @@ -27,12 +27,10 @@ #include #include #include -#include #include typedef struct { - aslclient _asl; int _sc_error; SCDynamicStoreRef _sc_store; } __SCThreadSpecificData, *__SCThreadSpecificDataRef; diff --git a/SystemConfiguration.fproj/SCDAdd.c b/SystemConfiguration.fproj/SCDAdd.c index 3142f66..6589099 100644 --- a/SystemConfiguration.fproj/SCDAdd.c +++ b/SystemConfiguration.fproj/SCDAdd.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2000-2005, 2009-2011, 2013, 2016 Apple Inc. All rights reserved. + * Copyright (c) 2000-2005, 2009-2011, 2013, 2016, 2017 Apple Inc. All rights reserved. * * @APPLE_LICENSE_HEADER_START@ * @@ -73,7 +73,9 @@ SCDynamicStoreAddTemporaryValue(SCDynamicStoreRef store, CFStringRef key, CFProp return FALSE; } +#ifdef VERBOSE_ACTIVITY_LOGGING os_activity_scope(storePrivate->activity); +#endif // VERBOSE_ACTIVITY_LOGGING retry : @@ -148,7 +150,9 @@ SCDynamicStoreAddValue(SCDynamicStoreRef store, CFStringRef key, CFPropertyListR return FALSE; } +#ifdef VERBOSE_ACTIVITY_LOGGING os_activity_scope(storePrivate->activity); +#endif // VERBOSE_ACTIVITY_LOGGING retry : diff --git a/SystemConfiguration.fproj/SCDGet.c b/SystemConfiguration.fproj/SCDGet.c index 19d67c5..ed0d196 100644 --- a/SystemConfiguration.fproj/SCDGet.c +++ b/SystemConfiguration.fproj/SCDGet.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2000-2005, 2009-2011, 2013, 2016 Apple Inc. All rights reserved. + * Copyright (c) 2000-2005, 2009-2011, 2013, 2016, 2017 Apple Inc. All rights reserved. * * @APPLE_LICENSE_HEADER_START@ * @@ -86,7 +86,9 @@ SCDynamicStoreCopyMultiple(SCDynamicStoreRef store, } } +#ifdef VERBOSE_ACTIVITY_LOGGING os_activity_scope(storePrivate->activity); +#endif // VERBOSE_ACTIVITY_LOGGING retry : @@ -167,7 +169,9 @@ SCDynamicStoreCopyValue(SCDynamicStoreRef store, CFStringRef key) return NULL; } +#ifdef VERBOSE_ACTIVITY_LOGGING os_activity_scope(storePrivate->activity); +#endif // VERBOSE_ACTIVITY_LOGGING retry : diff --git a/SystemConfiguration.fproj/SCDHostName.c b/SystemConfiguration.fproj/SCDHostName.c index 193d835..9d47b51 100644 --- a/SystemConfiguration.fproj/SCDHostName.c +++ b/SystemConfiguration.fproj/SCDHostName.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2000-2008, 2011, 2013-2016 Apple Inc. All rights reserved. + * Copyright (c) 2000-2008, 2011, 2013-2017 Apple Inc. All rights reserved. * * @APPLE_LICENSE_HEADER_START@ * @@ -449,7 +449,7 @@ SCDynamicStoreCopyLocalHostName(SCDynamicStoreRef store) Boolean _SC_stringIsValidDNSName(const char *name) { - int i; + size_t i; size_t len = strlen(name); char prev = '\0'; const char *scan; diff --git a/SystemConfiguration.fproj/SCDList.c b/SystemConfiguration.fproj/SCDList.c index 3c631a4..c11c2dd 100644 --- a/SystemConfiguration.fproj/SCDList.c +++ b/SystemConfiguration.fproj/SCDList.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2000-2005, 2009-2011, 2013, 2016 Apple Inc. All rights reserved. + * Copyright (c) 2000-2005, 2009-2011, 2013, 2016, 2017 Apple Inc. All rights reserved. * * @APPLE_LICENSE_HEADER_START@ * @@ -68,7 +68,9 @@ SCDynamicStoreCopyKeyList(SCDynamicStoreRef store, CFStringRef pattern) return NULL; } +#ifdef VERBOSE_ACTIVITY_LOGGING os_activity_scope(storePrivate->activity); +#endif // VERBOSE_ACTIVITY_LOGGING retry : diff --git a/SystemConfiguration.fproj/SCDNotifierAdd.c b/SystemConfiguration.fproj/SCDNotifierAdd.c index b48c02f..d9f581b 100644 --- a/SystemConfiguration.fproj/SCDNotifierAdd.c +++ b/SystemConfiguration.fproj/SCDNotifierAdd.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2000-2005, 2009-2011, 2013, 2016 Apple Inc. All rights reserved. + * Copyright (c) 2000-2005, 2009-2011, 2013, 2016, 2017 Apple Inc. All rights reserved. * * @APPLE_LICENSE_HEADER_START@ * @@ -75,7 +75,9 @@ SCDynamicStoreAddWatchedKey(SCDynamicStoreRef store, CFStringRef key, Boolean is return FALSE; } +#ifdef VERBOSE_ACTIVITY_LOGGING os_activity_scope(storePrivate->activity); +#endif // VERBOSE_ACTIVITY_LOGGING retry : diff --git a/SystemConfiguration.fproj/SCDNotifierCancel.c b/SystemConfiguration.fproj/SCDNotifierCancel.c index fff2d32..91c67ef 100644 --- a/SystemConfiguration.fproj/SCDNotifierCancel.c +++ b/SystemConfiguration.fproj/SCDNotifierCancel.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2000-2005, 2008-2011, 2015, 2016 Apple Inc. All rights reserved. + * Copyright (c) 2000-2005, 2008-2011, 2015-2017 Apple Inc. All rights reserved. * * @APPLE_LICENSE_HEADER_START@ * @@ -37,7 +37,9 @@ Boolean SCDynamicStoreNotifyCancel(SCDynamicStoreRef store) { +#ifdef VERBOSE_ACTIVITY_LOGGING struct os_activity_scope_state_s activity_state; +#endif // VERBOSE_ACTIVITY_LOGGING SCDynamicStorePrivateRef storePrivate = (SCDynamicStorePrivateRef)store; kern_return_t status; int sc_status; @@ -76,7 +78,9 @@ SCDynamicStoreNotifyCancel(SCDynamicStoreRef store) goto done; } +#ifdef VERBOSE_ACTIVITY_LOGGING os_activity_scope_enter(storePrivate->activity, &activity_state); +#endif // VERBOSE_ACTIVITY_LOGGING status = notifycancel(storePrivate->server, (int *)&sc_status); @@ -87,7 +91,9 @@ SCDynamicStoreNotifyCancel(SCDynamicStoreRef store) sc_status = kSCStatusOK; } +#ifdef VERBOSE_ACTIVITY_LOGGING os_activity_scope_leave(&activity_state); +#endif // VERBOSE_ACTIVITY_LOGGING done : diff --git a/SystemConfiguration.fproj/SCDNotifierGetChanges.c b/SystemConfiguration.fproj/SCDNotifierGetChanges.c index 5f70d1b..1ff609f 100644 --- a/SystemConfiguration.fproj/SCDNotifierGetChanges.c +++ b/SystemConfiguration.fproj/SCDNotifierGetChanges.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2000, 2001, 2003-2005, 2009-2011, 2016 Apple Inc. All rights reserved. + * Copyright (c) 2000, 2001, 2003-2005, 2009-2011, 2016, 2017 Apple Inc. All rights reserved. * * @APPLE_LICENSE_HEADER_START@ * @@ -55,7 +55,9 @@ SCDynamicStoreCopyNotifiedKeys(SCDynamicStoreRef store) return NULL; } +#ifdef VERBOSE_ACTIVITY_LOGGING os_activity_scope(storePrivate->activity); +#endif // VERBOSE_ACTIVITY_LOGGING retry : diff --git a/SystemConfiguration.fproj/SCDNotifierInformViaCallback.c b/SystemConfiguration.fproj/SCDNotifierInformViaCallback.c index a0e5f44..4c8812b 100644 --- a/SystemConfiguration.fproj/SCDNotifierInformViaCallback.c +++ b/SystemConfiguration.fproj/SCDNotifierInformViaCallback.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2000-2005, 2008-2016 Apple Inc. All rights reserved. + * Copyright (c) 2000-2005, 2008-2017 Apple Inc. All rights reserved. * * @APPLE_LICENSE_HEADER_START@ * @@ -55,6 +55,7 @@ notifyMPCopyDescription(const void *info) static void rlsCallback(CFMachPortRef port, void *msg, CFIndex size, void *info) { +#pragma unused(size) mach_no_senders_notification_t *buf = msg; mach_msg_id_t msgid = buf->not_header.msgh_id; SCDynamicStoreRef store = (SCDynamicStoreRef)info; @@ -127,7 +128,7 @@ rlsSchedule(void *info, CFRunLoopRef rl, CFStringRef mode) bzero(&opts, sizeof(opts)); opts.flags = MPO_CONTEXT_AS_GUARD|MPO_INSERT_SEND_RIGHT; - kr = mach_port_construct(mach_task_self(), &opts, store, &port); + kr = mach_port_construct(mach_task_self(), &opts, (mach_port_context_t)store, &port); #else // HAVE_MACHPORT_GUARDS kr = mach_port_allocate(mach_task_self(), MACH_PORT_RIGHT_RECEIVE, &port); #endif // HAVE_MACHPORT_GUARDS @@ -184,7 +185,9 @@ rlsSchedule(void *info, CFRunLoopRef rl, CFStringRef mode) SC_log(LOG_DEBUG, " establish notification request with SCDynamicStore server"); #endif /* DEBUG */ +#ifdef VERBOSE_ACTIVITY_LOGGING os_activity_scope(storePrivate->activity); +#endif // VERBOSE_ACTIVITY_LOGGING retry : @@ -206,7 +209,7 @@ rlsSchedule(void *info, CFRunLoopRef rl, CFStringRef mode) /* remove our receive right */ #ifdef HAVE_MACHPORT_GUARDS - (void) mach_port_destruct(mach_task_self(), port, 0, store); + (void) mach_port_destruct(mach_task_self(), port, 0, (mach_port_context_t)store); #else // HAVE_MACHPORT_GUARDS (void) mach_port_mod_refs(mach_task_self(), port, MACH_PORT_RIGHT_RECEIVE, -1); #endif // HAVE_MACHPORT_GUARDS @@ -216,7 +219,7 @@ rlsSchedule(void *info, CFRunLoopRef rl, CFStringRef mode) if (sc_status != kSCStatusOK) { /* something [else] didn't work, remove our receive right */ #ifdef HAVE_MACHPORT_GUARDS - (void) mach_port_destruct(mach_task_self(), port, 0, store); + (void) mach_port_destruct(mach_task_self(), port, 0, (mach_port_context_t)store); #else // HAVE_MACHPORT_GUARDS (void) mach_port_mod_refs(mach_task_self(), port, MACH_PORT_RIGHT_RECEIVE, -1); #endif // HAVE_MACHPORT_GUARDS @@ -327,7 +330,7 @@ rlsCancel(void *info, CFRunLoopRef rl, CFStringRef mode) /* and, finally, remove our receive right */ #ifdef HAVE_MACHPORT_GUARDS - (void) mach_port_destruct(mach_task_self(), mp, 0, store); + (void) mach_port_destruct(mach_task_self(), mp, 0, (mach_port_context_t)store); #else // HAVE_MACHPORT_GUARDS (void) mach_port_mod_refs(mach_task_self(), mp, MACH_PORT_RIGHT_RECEIVE, -1); #endif // HAVE_MACHPORT_GUARDS @@ -337,7 +340,9 @@ rlsCancel(void *info, CFRunLoopRef rl, CFStringRef mode) SC_log(LOG_DEBUG, " cancel notification request with SCDynamicStore server"); #endif /* DEBUG */ +#ifdef VERBOSE_ACTIVITY_LOGGING os_activity_scope(storePrivate->activity); +#endif // VERBOSE_ACTIVITY_LOGGING if (storePrivate->server != MACH_PORT_NULL) { kr = notifycancel(storePrivate->server, (int *)&sc_status); diff --git a/SystemConfiguration.fproj/SCDNotifierInformViaFD.c b/SystemConfiguration.fproj/SCDNotifierInformViaFD.c index 05f5165..e8abafa 100644 --- a/SystemConfiguration.fproj/SCDNotifierInformViaFD.c +++ b/SystemConfiguration.fproj/SCDNotifierInformViaFD.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2000, 2001, 2003-2005, 2008-2011, 2013, 2015, 2016 Apple Inc. All rights reserved. + * Copyright (c) 2000, 2001, 2003-2005, 2008-2011, 2013, 2015-2017 Apple Inc. All rights reserved. * * @APPLE_LICENSE_HEADER_START@ * @@ -45,7 +45,9 @@ SCDynamicStoreNotifyFileDescriptor(SCDynamicStoreRef store, int32_t identifier, int *fd) { +#ifdef VERBOSE_ACTIVITY_LOGGING struct os_activity_scope_state_s activity_state; +#endif // VERBOSE_ACTIVITY_LOGGING int fildes[2] = { -1, -1 }; fileport_t fileport = MACH_PORT_NULL; int ret; @@ -91,7 +93,9 @@ SCDynamicStoreNotifyFileDescriptor(SCDynamicStoreRef store, goto fail; } +#ifdef VERBOSE_ACTIVITY_LOGGING os_activity_scope_enter(storePrivate->activity, &activity_state); +#endif // VERBOSE_ACTIVITY_LOGGING retry : @@ -107,7 +111,9 @@ SCDynamicStoreNotifyFileDescriptor(SCDynamicStoreRef store, goto retry; } +#ifdef VERBOSE_ACTIVITY_LOGGING os_activity_scope_leave(&activity_state); +#endif // VERBOSE_ACTIVITY_LOGGING if (status != KERN_SUCCESS) { _SCErrorSet(status); diff --git a/SystemConfiguration.fproj/SCDNotifierInformViaSignal.c b/SystemConfiguration.fproj/SCDNotifierInformViaSignal.c index c4aa6ef..1f8e737 100644 --- a/SystemConfiguration.fproj/SCDNotifierInformViaSignal.c +++ b/SystemConfiguration.fproj/SCDNotifierInformViaSignal.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2000, 2001, 2004, 2005, 2009-2011, 2015, 2016 Apple Inc. All rights reserved. + * Copyright (c) 2000, 2001, 2004, 2005, 2009-2011, 2015-2017 Apple Inc. All rights reserved. * * @APPLE_LICENSE_HEADER_START@ * @@ -67,7 +67,9 @@ SCDynamicStoreNotifySignal(SCDynamicStoreRef store, pid_t pid, int sig) return FALSE; } +#ifdef VERBOSE_ACTIVITY_LOGGING os_activity_scope(storePrivate->activity); +#endif // VERBOSE_ACTIVITY_LOGGING retry : diff --git a/SystemConfiguration.fproj/SCDNotifierRemove.c b/SystemConfiguration.fproj/SCDNotifierRemove.c index d538274..07bd9f9 100644 --- a/SystemConfiguration.fproj/SCDNotifierRemove.c +++ b/SystemConfiguration.fproj/SCDNotifierRemove.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2000-2005, 2009-2011, 2013, 2016 Apple Inc. All rights reserved. + * Copyright (c) 2000-2005, 2009-2011, 2013, 2016, 2017 Apple Inc. All rights reserved. * * @APPLE_LICENSE_HEADER_START@ * @@ -85,7 +85,9 @@ SCDynamicStoreRemoveWatchedKey(SCDynamicStoreRef store, CFStringRef key, Boolean return FALSE; } +#ifdef VERBOSE_ACTIVITY_LOGGING os_activity_scope(storePrivate->activity); +#endif // VERBOSE_ACTIVITY_LOGGING retry : diff --git a/SystemConfiguration.fproj/SCDNotifierSetKeys.c b/SystemConfiguration.fproj/SCDNotifierSetKeys.c index ff71643..93f0f49 100644 --- a/SystemConfiguration.fproj/SCDNotifierSetKeys.c +++ b/SystemConfiguration.fproj/SCDNotifierSetKeys.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2000, 2001, 2003-2005, 2009-2011, 2013, 2016 Apple Inc. All rights reserved. + * Copyright (c) 2000, 2001, 2003-2005, 2009-2011, 2013, 2016, 2017 Apple Inc. All rights reserved. * * @APPLE_LICENSE_HEADER_START@ * @@ -75,7 +75,9 @@ SCDynamicStoreSetNotificationKeys(SCDynamicStoreRef store, } } +#ifdef VERBOSE_ACTIVITY_LOGGING os_activity_scope(storePrivate->activity); +#endif // VERBOSE_ACTIVITY_LOGGING retry : diff --git a/SystemConfiguration.fproj/SCDNotifierWait.c b/SystemConfiguration.fproj/SCDNotifierWait.c index 62f92fb..8a2310f 100644 --- a/SystemConfiguration.fproj/SCDNotifierWait.c +++ b/SystemConfiguration.fproj/SCDNotifierWait.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2000, 2001, 2004, 2006, 2009-2011, 2015, 2016 Apple Inc. All rights reserved. + * Copyright (c) 2000, 2001, 2004, 2006, 2009-2011, 2015-2017 Apple Inc. All rights reserved. * * @APPLE_LICENSE_HEADER_START@ * @@ -135,7 +135,9 @@ SCDynamicStoreNotifyWait(SCDynamicStoreRef store) SC_log(LOG_NOTICE, "oldNotify != MACH_PORT_NULL"); } +#ifdef VERBOSE_ACTIVITY_LOGGING os_activity_scope(storePrivate->activity); +#endif // VERBOSE_ACTIVITY_LOGGING retry : @@ -193,7 +195,9 @@ SCDynamicStoreNotifyWait(SCDynamicStoreRef store) return FALSE; } +#ifdef VERBOSE_ACTIVITY_LOGGING os_activity_scope(storePrivate->activity); +#endif // VERBOSE_ACTIVITY_LOGGING // something changed, cancelling notification request status = notifycancel(storePrivate->server, diff --git a/SystemConfiguration.fproj/SCDNotify.c b/SystemConfiguration.fproj/SCDNotify.c index 6850959..2f7997d 100644 --- a/SystemConfiguration.fproj/SCDNotify.c +++ b/SystemConfiguration.fproj/SCDNotify.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2000-2005, 2009-2011, 2013, 2016 Apple Inc. All rights reserved. + * Copyright (c) 2000-2005, 2009-2011, 2013, 2016, 2017 Apple Inc. All rights reserved. * * @APPLE_LICENSE_HEADER_START@ * @@ -64,7 +64,9 @@ SCDynamicStoreNotifyValue(SCDynamicStoreRef store, return FALSE; } +#ifdef VERBOSE_ACTIVITY_LOGGING os_activity_scope(storePrivate->activity); +#endif // VERBOSE_ACTIVITY_LOGGING retry : diff --git a/SystemConfiguration.fproj/SCDOpen.c b/SystemConfiguration.fproj/SCDOpen.c index f377070..ae2825b 100644 --- a/SystemConfiguration.fproj/SCDOpen.c +++ b/SystemConfiguration.fproj/SCDOpen.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2000-2006, 2008-2016 Apple Inc. All rights reserved. + * Copyright (c) 2000-2006, 2008-2017 Apple Inc. All rights reserved. * * @APPLE_LICENSE_HEADER_START@ * @@ -176,8 +176,10 @@ __SCDynamicStoreDeallocate(CFTypeRef cf) if (storePrivate->name != NULL) CFRelease(storePrivate->name); if (storePrivate->options != NULL) CFRelease(storePrivate->options); +#ifdef VERBOSE_ACTIVITY_LOGGING /* release activity tracing */ if (storePrivate->activity != NULL) os_release(storePrivate->activity); +#endif // VERBOSE_ACTIVITY_LOGGING return; } @@ -253,6 +255,7 @@ __SCDynamicStoreInitialize(void) static mach_port_t __SCDynamicStoreServerPort(SCDynamicStorePrivateRef storePrivate, kern_return_t *status) { +#pragma unused(storePrivate) mach_port_t server = MACH_PORT_NULL; char *server_name; @@ -334,10 +337,12 @@ __SCDynamicStoreCreatePrivate(CFAllocatorRef allocator, /* client side of the "configd" session */ storePrivate->name = (name != NULL) ? CFRetain(name) : NULL; +#ifdef VERBOSE_ACTIVITY_LOGGING /* "client" activity tracing */ storePrivate->activity = os_activity_create("accessing SCDynamicStore", OS_ACTIVITY_CURRENT, OS_ACTIVITY_FLAG_DEFAULT); +#endif // VERBOSE_ACTIVITY_LOGGING /* Notification status */ storePrivate->notifyStatus = NotifierNotRegistered; @@ -389,7 +394,9 @@ updateServerPort(SCDynamicStorePrivateRef storePrivate, mach_port_t *server, int static Boolean __SCDynamicStoreAddSession(SCDynamicStorePrivateRef storePrivate) { +#ifdef VERBOSE_ACTIVITY_LOGGING struct os_activity_scope_state_s activity_state; +#endif // VERBOSE_ACTIVITY_LOGGING kern_return_t kr = KERN_SUCCESS; CFDataRef myName; /* serialized name */ xmlData_t myNameRef; @@ -419,7 +426,9 @@ __SCDynamicStoreAddSession(SCDynamicStorePrivateRef storePrivate) updateServerPort(storePrivate, &server, &sc_status); +#ifdef VERBOSE_ACTIVITY_LOGGING os_activity_scope_enter(storePrivate->activity, &activity_state); +#endif // VERBOSE_ACTIVITY_LOGGING while (server != MACH_PORT_NULL) { // if SCDynamicStore server available @@ -442,6 +451,11 @@ __SCDynamicStoreAddSession(SCDynamicStorePrivateRef storePrivate) storePrivate->server = server; sc_status = kSCStatusOK; } else { + if (kr == KERN_INVALID_RIGHT) { + // We can get KERN_INVALID_RIGHT if the server dies and we try to + // add a send right to a stale (now dead) port name + kr = MACH_SEND_INVALID_DEST; + } storePrivate->server = MACH_PORT_NULL; } } else { @@ -467,7 +481,9 @@ __SCDynamicStoreAddSession(SCDynamicStorePrivateRef storePrivate) } __MACH_PORT_DEBUG(TRUE, "*** SCDynamicStoreAddSession", storePrivate->server); +#ifdef VERBOSE_ACTIVITY_LOGGING os_activity_scope_leave(&activity_state); +#endif // VERBOSE_ACTIVITY_LOGGING // clean up CFRelease(myName); @@ -483,7 +499,8 @@ __SCDynamicStoreAddSession(SCDynamicStorePrivateRef storePrivate) sc_status = kSCStatusNoStoreServer; break; default : - SC_log((kr == KERN_SUCCESS) ? LOG_INFO : LOG_ERR, "configopen() failed: %s", + SC_log((kr == KERN_SUCCESS) ? LOG_INFO : LOG_ERR, "configopen() failed: %d: %s", + sc_status, SCErrorString(sc_status)); break; } @@ -555,6 +572,8 @@ __SCDynamicStoreCheckRetryAndHandleError(SCDynamicStoreRef store, if (__SCDynamicStoreReconnect(store)) { /* retry needed */ return TRUE; + } else { + status = SCError(); } } else { /* an unexpected error, leave the [session] port alone */ @@ -777,6 +796,7 @@ SCDynamicStoreGetTypeID(void) { return __kSCDynamicStoreTypeID; } + Boolean SCDynamicStoreSetDisconnectCallBack(SCDynamicStoreRef store, SCDynamicStoreDisconnectCallBack callout) diff --git a/SystemConfiguration.fproj/SCDPlugin.c b/SystemConfiguration.fproj/SCDPlugin.c index 54e3f5d..44d7a7e 100644 --- a/SystemConfiguration.fproj/SCDPlugin.c +++ b/SystemConfiguration.fproj/SCDPlugin.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2002-2006, 2013, 2015 Apple Computer, Inc. All rights reserved. + * Copyright (c) 2002-2006, 2013, 2015, 2017 Apple Computer, Inc. All rights reserved. * * @APPLE_LICENSE_HEADER_START@ * @@ -110,6 +110,7 @@ unblockSignal() static void reaper(int sigraised) { +#pragma unused(sigraised) /* * block additional SIGCHLD's until current children have * been reaped. @@ -129,6 +130,10 @@ reaper(int sigraised) static void childrenReaped(CFMachPortRef port, void *msg, CFIndex size, void *info) { +#pragma unused(port) +#pragma unused(msg) +#pragma unused(size) +#pragma unused(info) pid_t pid = 0; childInfoRef reapedChildren = NULL; @@ -214,6 +219,7 @@ childrenReaped(CFMachPortRef port, void *msg, CFIndex size, void *info) static CFStringRef childReapedMPCopyDescription(const void *info) { +#pragma unused(info) return CFStringCreateWithFormat(NULL, NULL, CFSTR("")); } diff --git a/SystemConfiguration.fproj/SCDPrivate.c b/SystemConfiguration.fproj/SCDPrivate.c index 818967f..4e618f7 100644 --- a/SystemConfiguration.fproj/SCDPrivate.c +++ b/SystemConfiguration.fproj/SCDPrivate.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2000-2016 Apple Inc. All rights reserved. + * Copyright (c) 2000-2017 Apple Inc. All rights reserved. * * @APPLE_LICENSE_HEADER_START@ * @@ -170,7 +170,7 @@ _SC_sockaddr_to_string(const struct sockaddr *address, char *buf, size_t bufLen) size_t n; n = strlen(buf); - if ((n+IF_NAMESIZE+1) <= (int)bufLen) { + if ((n+IF_NAMESIZE+1) <= bufLen) { buf[n++] = '%'; if_indextoname(addr.sin6->sin6_scope_id, &buf[n]); } @@ -295,16 +295,17 @@ _SC_trimDomain(CFStringRef domain) CFSTR("."), CFRangeMake(0, length), kCFCompareAnchored|kCFCompareBackwards, - NULL))) { - CFMutableStringRef trimmed; - - trimmed = CFStringCreateMutableCopy(NULL, 0, domain); - CFStringTrim(trimmed, CFSTR(".")); - domain = (CFStringRef)trimmed; - length = CFStringGetLength(domain); - } else { - CFRetain(domain); - } + NULL)) + ) { + CFMutableStringRef trimmed; + + trimmed = CFStringCreateMutableCopy(NULL, 0, domain); + CFStringTrim(trimmed, CFSTR(".")); + domain = (CFStringRef)trimmed; + length = CFStringGetLength(domain); + } else { + CFRetain(domain); + } if (length == 0) { CFRelease(domain); @@ -1007,10 +1008,93 @@ done: } +/* + * cachedInfo + * + * bundleID-tableName + * + * ... property list from non-localized bundle URL + * + * + */ +static CFMutableDictionaryRef cachedInfo = NULL; + + +static dispatch_queue_t +_SC_CFBundleCachedInfoQueue() +{ + static dispatch_once_t once; + static dispatch_queue_t q; + + dispatch_once(&once, ^{ + q = dispatch_queue_create("_SC_CFBundleCachedInfo", NULL); + }); + + return q; +} + + +static CFStringRef +_SC_CFBundleCachedInfoCopyTableKey(CFBundleRef bundle, CFStringRef tableName) +{ + CFStringRef bundleID; + CFStringRef tableKey; + + bundleID = CFBundleGetIdentifier(bundle); + tableKey = CFStringCreateWithFormat(NULL, NULL, CFSTR("%@: %@"), bundleID, tableName); + return tableKey; +} + + +static CFDictionaryRef +_SC_CFBundleCachedInfoCopyTable(CFBundleRef bundle, CFStringRef tableName) +{ + __block CFDictionaryRef dict = NULL; + + dispatch_sync(_SC_CFBundleCachedInfoQueue(), ^{ + if (cachedInfo != NULL) { + CFStringRef tableKey; + + tableKey = _SC_CFBundleCachedInfoCopyTableKey(bundle, tableName); + dict = CFDictionaryGetValue(cachedInfo, tableKey); + if (dict != NULL) { + CFRetain(dict); + } + CFRelease(tableKey); + } + }); + + return dict; +} + + +static void +_SC_CFBundleCachedInfoSaveTable(CFBundleRef bundle, CFStringRef tableName, CFDictionaryRef table) +{ + + dispatch_sync(_SC_CFBundleCachedInfoQueue(), ^{ + CFStringRef tableKey; + + tableKey = _SC_CFBundleCachedInfoCopyTableKey(bundle, tableName); + SC_log(LOG_DEBUG, "Caching %@", tableKey); + + if (cachedInfo == NULL) { + cachedInfo = CFDictionaryCreateMutable(NULL, + 0, + &kCFTypeDictionaryKeyCallBacks, + &kCFTypeDictionaryValueCallBacks); + } + CFDictionarySetValue(cachedInfo, tableKey, table); + CFRelease(tableKey); + }); + + return; +} + + CFStringRef _SC_CFBundleCopyNonLocalizedString(CFBundleRef bundle, CFStringRef key, CFStringRef value, CFStringRef tableName) { - CFURLRef resourcesURL; CFStringRef str = NULL; CFDictionaryRef table = NULL; CFURLRef url; @@ -1019,36 +1103,7 @@ _SC_CFBundleCopyNonLocalizedString(CFBundleRef bundle, CFStringRef key, CFString tableName = CFSTR("Localizable"); } - /* - * First, try getting the requested string using a manually constructed - * URL to /Resources/English.lproj/.strings. Do this - * because CFBundleCopyResourceURLForLocalization() uses CFPreferences - * to get the preferred localizations, CFPreferences talks to - * OpenDirectory, and OpenDirectory tries to obtain the platform UUID. - * On machines where the platform UUID is set by InterfaceNamer, a - * deadlock can occur if InterfaceNamer calls - * CFBundleCopyResourceURLForLocalization() before setting the - * platform UUID in the kernel. - */ - resourcesURL = CFBundleCopyResourcesDirectoryURL(bundle); - if (resourcesURL != NULL) { - CFURLRef en_lproj; - CFStringRef fileName; - - en_lproj = CFURLCreateCopyAppendingPathComponent(NULL, - resourcesURL, - CFSTR("English.lproj"), - TRUE); - fileName = CFStringCreateWithFormat(NULL, NULL, CFSTR("%@.strings"), tableName); - url = CFURLCreateCopyAppendingPathComponent(NULL, en_lproj, fileName, FALSE); - CFRelease(en_lproj); - CFRelease(fileName); - CFRelease(resourcesURL); - - table = _SCCreatePropertyListFromResource(url); - CFRelease(url); - } - + table = _SC_CFBundleCachedInfoCopyTable(bundle, tableName); if (table == NULL) { url = CFBundleCopyResourceURLForLocalization(bundle, tableName, @@ -1058,6 +1113,9 @@ _SC_CFBundleCopyNonLocalizedString(CFBundleRef bundle, CFStringRef key, CFString if (url != NULL) { table = _SCCreatePropertyListFromResource(url); CFRelease(url); + if (table != NULL) { + _SC_CFBundleCachedInfoSaveTable(bundle, tableName, table); + } } else { SC_log(LOG_ERR, "failed to get resource url: {bundle:%@, table: %@}", bundle, tableName); } @@ -1274,122 +1332,153 @@ _SC_logMachPortStatus(void) } -void -_SC_logMachPortReferences(const char *str, mach_port_t port) +__private_extern__ +kern_return_t +_SC_getMachPortReferences(mach_port_t port, + mach_port_type_t *pt, + mach_port_urefs_t *refs_send, + mach_port_urefs_t *refs_recv, + mach_port_status_t *recv_status, + mach_port_urefs_t *refs_once, + mach_port_urefs_t *refs_pset, + mach_port_urefs_t *refs_dead, + const char *err_prefix) { - const char *blanks = " "; - char buf[60]; - mach_port_type_t pt; - mach_port_status_t recv_status = { 0 }; - mach_port_urefs_t refs_send = 0; - mach_port_urefs_t refs_recv = 0; - mach_port_urefs_t refs_once = 0; - mach_port_urefs_t refs_pset = 0; - mach_port_urefs_t refs_dead = 0; kern_return_t status; - buf[0] = '\0'; - if (str != NULL) { - static int is_configd = -1; - - if (is_configd == -1) { - is_configd = (strcmp(getprogname(), _SC_SERVER_PROG) == 0); - } - if (is_configd == 1) { - // if "configd", add indication if this is the M[ain] or [P]lugin thread - strlcpy(buf, - (CFRunLoopGetMain() == CFRunLoopGetCurrent()) ? "M " : "P ", - sizeof(buf)); - } - - // add provided string - strlcat(buf, str, sizeof(buf)); - - // fill - strlcat(buf, blanks, sizeof(buf)); - if (strcmp(&buf[sizeof(buf) - 3], " ") == 0) { - buf[sizeof(buf) - 3] = ':'; - } - } - - status = mach_port_type(mach_task_self(), port, &pt); + status = mach_port_type(mach_task_self(), port, pt); if (status != KERN_SUCCESS) { SC_log(LOG_DEBUG, "%smach_port_type(..., 0x%x): %s", - buf, + err_prefix, port, mach_error_string(status)); - return; + return status; } - if ((pt & MACH_PORT_TYPE_SEND) != 0) { - status = mach_port_get_refs(mach_task_self(), port, MACH_PORT_RIGHT_SEND, &refs_send); + if ((refs_send != NULL) && ((*pt & MACH_PORT_TYPE_SEND) != 0)) { + status = mach_port_get_refs(mach_task_self(), port, MACH_PORT_RIGHT_SEND, refs_send); if (status != KERN_SUCCESS) { SC_log(LOG_DEBUG, "%smach_port_get_refs(..., 0x%x, MACH_PORT_RIGHT_SEND): %s", - buf, + err_prefix, port, mach_error_string(status)); - return; + return status; } } - if ((pt & MACH_PORT_TYPE_RECEIVE) != 0) { + if ((refs_recv != NULL) && (recv_status != NULL) && ((*pt & MACH_PORT_TYPE_RECEIVE) != 0)) { mach_msg_type_number_t count; - status = mach_port_get_refs(mach_task_self(), port, MACH_PORT_RIGHT_RECEIVE, &refs_recv); + status = mach_port_get_refs(mach_task_self(), port, MACH_PORT_RIGHT_RECEIVE, refs_recv); if (status != KERN_SUCCESS) { SC_log(LOG_DEBUG, "%smach_port_get_refs(..., 0x%x, MACH_PORT_RIGHT_RECEIVE): %s", - buf, + err_prefix, port, mach_error_string(status)); - return; + return status; } count = MACH_PORT_RECEIVE_STATUS_COUNT; status = mach_port_get_attributes(mach_task_self(), port, MACH_PORT_RECEIVE_STATUS, - (mach_port_info_t)&recv_status, + (mach_port_info_t)recv_status, &count); if (status != KERN_SUCCESS) { SC_log(LOG_DEBUG, "%smach_port_get_attributes(..., 0x%x, MACH_PORT_RECEIVE_STATUS): %s", - buf, + err_prefix, port, mach_error_string(status)); - return; + return status; } } - if ((pt & MACH_PORT_TYPE_SEND_ONCE) != 0) { - status = mach_port_get_refs(mach_task_self(), port, MACH_PORT_RIGHT_SEND_ONCE, &refs_once); + if ((refs_once != NULL) && ((*pt & MACH_PORT_TYPE_SEND_ONCE) != 0)) { + status = mach_port_get_refs(mach_task_self(), port, MACH_PORT_RIGHT_SEND_ONCE, refs_once); if (status != KERN_SUCCESS) { SC_log(LOG_DEBUG, "%smach_port_get_refs(..., 0x%x, MACH_PORT_RIGHT_SEND_ONCE): %s", - buf, + err_prefix, port, mach_error_string(status)); - return; + return status; } } - if ((pt & MACH_PORT_TYPE_PORT_SET) != 0) { - status = mach_port_get_refs(mach_task_self(), port, MACH_PORT_RIGHT_PORT_SET, &refs_pset); + if ((refs_pset != NULL) && ((*pt & MACH_PORT_TYPE_PORT_SET) != 0)) { + status = mach_port_get_refs(mach_task_self(), port, MACH_PORT_RIGHT_PORT_SET, refs_pset); if (status != KERN_SUCCESS) { SC_log(LOG_DEBUG, "%smach_port_get_refs(..., 0x%x, MACH_PORT_RIGHT_PORT_SET): %s", - buf, + err_prefix, port, mach_error_string(status)); - return; + return status; } } - if ((pt & MACH_PORT_TYPE_DEAD_NAME) != 0) { - status = mach_port_get_refs(mach_task_self(), port, MACH_PORT_RIGHT_DEAD_NAME, &refs_dead); + if ((refs_dead != NULL) && ((*pt & MACH_PORT_TYPE_DEAD_NAME) != 0)) { + status = mach_port_get_refs(mach_task_self(), port, MACH_PORT_RIGHT_DEAD_NAME, refs_dead); if (status != KERN_SUCCESS) { SC_log(LOG_DEBUG, "%smach_port_get_refs(..., 0x%x, MACH_PORT_RIGHT_DEAD_NAME): %s", - buf, + err_prefix, port, mach_error_string(status)); - return; + return status; + } + } + + return KERN_SUCCESS; +} + + +void +_SC_logMachPortReferences(const char *str, mach_port_t port) +{ + const char *blanks = " "; + char buf[60]; + mach_port_type_t pt; + mach_port_status_t recv_status = { .mps_nsrequest = 0, }; + mach_port_urefs_t refs_send = 0; + mach_port_urefs_t refs_recv = 0; + mach_port_urefs_t refs_once = 0; + mach_port_urefs_t refs_pset = 0; + mach_port_urefs_t refs_dead = 0; + kern_return_t status; + + buf[0] = '\0'; + if (str != NULL) { + static int is_configd = -1; + + if (is_configd == -1) { + is_configd = (strcmp(getprogname(), _SC_SERVER_PROG) == 0); } + if (is_configd == 1) { + // if "configd", add indication if this is the M[ain] or [P]lugin thread + strlcpy(buf, + (CFRunLoopGetMain() == CFRunLoopGetCurrent()) ? "M " : "P ", + sizeof(buf)); + } + + // add provided string + strlcat(buf, str, sizeof(buf)); + + // fill + strlcat(buf, blanks, sizeof(buf)); + if (strcmp(&buf[sizeof(buf) - 3], " ") == 0) { + buf[sizeof(buf) - 3] = ':'; + } + } + + status = _SC_getMachPortReferences(port, + &pt, + &refs_send, + &refs_recv, + &recv_status, + &refs_once, + &refs_pset, + &refs_dead, + buf); + if (status != KERN_SUCCESS) { + return; } SC_log(LOG_DEBUG, "%smach port 0x%x (%d): send=%d, receive=%d, send once=%d, port set=%d, dead name=%d%s%s", @@ -1451,6 +1540,13 @@ asm(".desc ___crashreporter_info__, 0x10"); static Boolean _SC_SimulateCrash(const char *crash_info, CFStringRef notifyHeader, CFStringRef notifyMessage) { +#if !TARGET_OS_EMBEDDED || defined(DO_NOT_INFORM) +#pragma unused(notifyHeader) +#pragma unused(notifyMessage) +#endif // !TARGET_OS_EMBEDDED || defined(DO_NOT_INFORM) +#if TARGET_OS_SIMULATOR +#pragma unused(crash_info) +#endif // TARGET_OS_SIMULATOR Boolean ok = FALSE; #if !TARGET_OS_SIMULATOR diff --git a/SystemConfiguration.fproj/SCDRemove.c b/SystemConfiguration.fproj/SCDRemove.c index 50355d3..ccf6240 100644 --- a/SystemConfiguration.fproj/SCDRemove.c +++ b/SystemConfiguration.fproj/SCDRemove.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2000-2005, 2009-2011, 2013, 2016 Apple Inc. All rights reserved. + * Copyright (c) 2000-2005, 2009-2011, 2013, 2016, 2017 Apple Inc. All rights reserved. * * @APPLE_LICENSE_HEADER_START@ * @@ -67,7 +67,9 @@ SCDynamicStoreRemoveValue(SCDynamicStoreRef store, CFStringRef key) return FALSE; } +#ifdef VERBOSE_ACTIVITY_LOGGING os_activity_scope(storePrivate->activity); +#endif // VERBOSE_ACTIVITY_LOGGING retry : diff --git a/SystemConfiguration.fproj/SCDSet.c b/SystemConfiguration.fproj/SCDSet.c index 75a567b..3a1b6f1 100644 --- a/SystemConfiguration.fproj/SCDSet.c +++ b/SystemConfiguration.fproj/SCDSet.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2000-2006, 2009-2011, 2013, 2016 Apple Inc. All rights reserved. + * Copyright (c) 2000-2006, 2009-2011, 2013, 2016, 2017 Apple Inc. All rights reserved. * * @APPLE_LICENSE_HEADER_START@ * @@ -107,7 +107,9 @@ SCDynamicStoreSetMultiple(SCDynamicStoreRef store, } } +#ifdef VERBOSE_ACTIVITY_LOGGING os_activity_scope(storePrivate->activity); +#endif // VERBOSE_ACTIVITY_LOGGING retry : @@ -184,7 +186,9 @@ SCDynamicStoreSetValue(SCDynamicStoreRef store, CFStringRef key, CFPropertyListR return FALSE; } +#ifdef VERBOSE_ACTIVITY_LOGGING os_activity_scope(storePrivate->activity); +#endif // VERBOSE_ACTIVITY_LOGGING retry : diff --git a/SystemConfiguration.fproj/SCDSnapshot.c b/SystemConfiguration.fproj/SCDSnapshot.c index bc08c9f..eccc54d 100644 --- a/SystemConfiguration.fproj/SCDSnapshot.c +++ b/SystemConfiguration.fproj/SCDSnapshot.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2000, 2001, 2004, 2005, 2009-2011, 2016 Apple Inc. All rights reserved. + * Copyright (c) 2000, 2001, 2004, 2005, 2009-2011, 2016, 2017 Apple Inc. All rights reserved. * * @APPLE_LICENSE_HEADER_START@ * @@ -57,7 +57,9 @@ SCDynamicStoreSnapshot(SCDynamicStoreRef store) return FALSE; } +#ifdef VERBOSE_ACTIVITY_LOGGING os_activity_scope(storePrivate->activity); +#endif // VERBOSE_ACTIVITY_LOGGING retry : diff --git a/SystemConfiguration.fproj/SCDynamicStoreInternal.h b/SystemConfiguration.fproj/SCDynamicStoreInternal.h index 01e6490..04f9293 100644 --- a/SystemConfiguration.fproj/SCDynamicStoreInternal.h +++ b/SystemConfiguration.fproj/SCDynamicStoreInternal.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2000-2004, 2006, 2009-2011, 2013, 2015, 2016 Apple Inc. All rights reserved. + * Copyright (c) 2000-2004, 2006, 2009-2011, 2013, 2015-2017 Apple Inc. All rights reserved. * * @APPLE_LICENSE_HEADER_START@ * @@ -32,7 +32,9 @@ #include #include #include +#ifdef VERBOSE_ACTIVITY_LOGGING #include +#endif // VERBOSE_ACTIVITY_LOGGING #include #include #include @@ -66,8 +68,10 @@ typedef struct { CFStringRef name; CFDictionaryRef options; +#ifdef VERBOSE_ACTIVITY_LOGGING /* activity tracing */ os_activity_t activity; +#endif // VERBOSE_ACTIVITY_LOGGING /* server side of the "configd" session */ mach_port_t server; diff --git a/SystemConfiguration.fproj/SCLocation.c b/SystemConfiguration.fproj/SCLocation.c index 6d5a2ba..b554fbb 100644 --- a/SystemConfiguration.fproj/SCLocation.c +++ b/SystemConfiguration.fproj/SCLocation.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2002, 2004, 2006, 2010, 2011, 2015 Apple Inc. All rights reserved. + * Copyright (c) 2002, 2004, 2006, 2010, 2011, 2015, 2017 Apple Inc. All rights reserved. * * @APPLE_LICENSE_HEADER_START@ * @@ -36,6 +36,7 @@ CFStringRef SCDynamicStoreKeyCreateLocation(CFAllocatorRef allocator) { +#pragma unused(allocator) return CFRetain(kSCDynamicStoreDomainSetup); } diff --git a/SystemConfiguration.fproj/SCNetworkConfigurationInternal.h b/SystemConfiguration.fproj/SCNetworkConfigurationInternal.h index 8bce2fd..60d5e24 100644 --- a/SystemConfiguration.fproj/SCNetworkConfigurationInternal.h +++ b/SystemConfiguration.fproj/SCNetworkConfigurationInternal.h @@ -156,7 +156,6 @@ typedef struct { CFStringRef path; uint64_t entryID; CFMutableDictionaryRef overrides; - Boolean modemIsV92; CFStringRef prefix; CFNumberRef type; CFNumberRef unit; @@ -208,7 +207,8 @@ __BEGIN_DECLS #pragma mark SCNetworkInterface configuration (internal) Boolean -__SCNetworkInterfaceMatchesName (CFStringRef name, CFStringRef key); +__SCNetworkInterfaceMatchesName (CFStringRef name, + CFStringRef key); CFArrayRef __SCNetworkInterfaceCopyAll_IONetworkInterface (Boolean keep_pre_configured); @@ -222,7 +222,7 @@ __SCNetworkInterfaceCopyAll_IONetworkInterface (Boolean keep_pre_configured); You must release the returned value. */ CFDictionaryRef -__SCNetworkInterfaceCopyStorageEntity (SCNetworkInterfaceRef interface); +__SCNetworkInterfaceCopyStorageEntity (SCNetworkInterfaceRef interface); /*! @function __SCNetworkInterfaceCopyStoredWithPreferences @@ -234,7 +234,7 @@ __SCNetworkInterfaceCopyStorageEntity (SCNetworkInterfaceRef interface); */ CFArrayRef // SCNetworkInterfaceRef -__SCNetworkInterfaceCopyStoredWithPreferences (SCPreferencesRef ni_prefs); +__SCNetworkInterfaceCopyStoredWithPreferences (SCPreferencesRef ni_prefs); SCNetworkInterfacePrivateRef __SCNetworkInterfaceCreateCopy (CFAllocatorRef allocator, @@ -246,12 +246,12 @@ __SCNetworkInterfaceCreateCopy (CFAllocatorRef allocator, @function __SCNetworkInterfaceCreateMappingUsingBSDName @discussion This function creates mapping of BSD name and network interface using preferences which point to the NetworkInterfaces.plist file. - @param ni_prefs Preferences pointing to NetworkInterfaces.plist + @param interfaces An array of network interfaces to use for the mapping. @result BSD Mapping in a dictionary. You must release the returned value. */ CFDictionaryRef -__SCNetworkInterfaceCreateMappingUsingBSDName(CFArrayRef interfaces); +__SCNetworkInterfaceCreateMappingUsingBSDName (CFArrayRef interfaces); SCNetworkInterfaceRef __SCNetworkInterfaceCreateWithNIPreferencesUsingBSDName(CFAllocatorRef allocator, @@ -412,6 +412,12 @@ Boolean __SCBridgeInterfaceSetMemberInterfaces (SCBridgeInterfaceRef bridge, CFArrayRef members); +void +_SCNetworkInterfaceCacheOpen(); + +void +_SCNetworkInterfaceCacheClose(); + #pragma mark - #pragma mark SCNetworkProtocol configuration (internal) diff --git a/SystemConfiguration.fproj/SCNetworkConfigurationPrivate.h b/SystemConfiguration.fproj/SCNetworkConfigurationPrivate.h index 306d56c..37791a1 100644 --- a/SystemConfiguration.fproj/SCNetworkConfigurationPrivate.h +++ b/SystemConfiguration.fproj/SCNetworkConfigurationPrivate.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2005-2016 Apple Inc. All rights reserved. + * Copyright (c) 2005-2017 Apple Inc. All rights reserved. * * @APPLE_LICENSE_HEADER_START@ * @@ -175,8 +175,8 @@ _SCNetworkInterfaceCompare (const void *val1, @function _SCNetworkInterfaceCopyActive @discussion Creates an SCNetworkInterface and associated with interface name and SCDynamicStoreRef - @param the interface name - @param the SCDynamicStoreRef + @param store The SCDynamicStoreRef + @param bsdName The interface name @result the SCNetworkInterface */ SCNetworkInterfaceRef @@ -261,7 +261,7 @@ _SCNetworkInterfaceCreateWithIONetworkInterfaceObject (io_object_t if_obj) __ /*! @function SCNetworkInterfaceGetPrimaryRank @discussion We allow caller to retrieve the rank on an interface. - @param the interface to get the rank + @param interface The interface to get the rank @result SCNetworkServicePrimaryRank */ SCNetworkServicePrimaryRank @@ -272,8 +272,8 @@ SCNetworkInterfaceGetPrimaryRank (SCNetworkInterfaceRef interface) __OSX_AVAI @discussion We allow caller to set an assertion on an interface. The rank assertion lives as long as the SCNetworkInterfaceRef remains valid. - @param the interface to set the rank assertion - @param the new rank to be set + @param interface The interface to set the rank assertion + @param newRank The new rank to be set @result TRUE if operation is successful; FALSE if an error was encountered. */ Boolean @@ -446,16 +446,6 @@ _SCNetworkInterfaceIsBuiltin (SCNetworkInterfaceRef interface) __OSX_AVAILAB Boolean _SCNetworkInterfaceIsHiddenConfiguration (SCNetworkInterfaceRef interface) __OSX_AVAILABLE_STARTING(__MAC_10_7,__IPHONE_4_0); -/*! - @function _SCNetworkInterfaceIsModemV92 - @discussion Identifies if a modem network interface supports - v.92 (hold). - @param interface The network interface. - @result TRUE if the interface is "v.92" modem. - */ -Boolean -_SCNetworkInterfaceIsModemV92 (SCNetworkInterfaceRef interface) __OSX_AVAILABLE_STARTING(__MAC_10_5,__IPHONE_2_0); - /*! @function _SCNetworkInterfaceIsTethered @discussion Identifies if a network interface is an Apple tethered device (e.g. an iPhone). @@ -750,11 +740,11 @@ SCNetworkInterfaceSetDisableUntilNeeded (SCNetworkInterfaceRef interface, CFDictionaryRef -SCNetworkInterfaceGetQoSMarkingPolicy (SCNetworkInterfaceRef interface) __OSX_AVAILABLE_STARTING(__MAC_10_12,__IPHONE_10_0); +SCNetworkInterfaceGetQoSMarkingPolicy (SCNetworkInterfaceRef interface) __OSX_AVAILABLE_STARTING(__MAC_10_13,__IPHONE_10_0); Boolean SCNetworkInterfaceSetQoSMarkingPolicy (SCNetworkInterfaceRef interface, - CFDictionaryRef policy) __OSX_AVAILABLE_STARTING(__MAC_10_12,__IPHONE_10_0); + CFDictionaryRef policy) __OSX_AVAILABLE_STARTING(__MAC_10_13,__IPHONE_10_0); #pragma mark - @@ -772,6 +762,19 @@ isA_SCNetworkProtocol(CFTypeRef obj) return (isA_CFType(obj, SCNetworkProtocolGetTypeID())); } +/*! + @function _SCNetworkProtocolCompare + @discussion Compares two SCNetworkProtocol objects. + @param val1 The SCNetworkProtocol object. + @param val2 The SCNetworkProtocol object. + @param context Not used. + @result A comparison result. + */ +CFComparisonResult +_SCNetworkProtocolCompare (const void *val1, + const void *val2, + void *context) __OSX_AVAILABLE_STARTING(__MAC_10_13,__IPHONE_11_0); + #pragma mark - #pragma mark SCNetworkService configuration (SPI) @@ -809,7 +812,7 @@ _SCNetworkServiceCompare (const void *val1, API in that queries and operations interact with the "active" service represented in the SCDynamicStore. Only a limited subset of the SCNetworkService APIs are supported. - @param prefs The dynamic store session. + @param store The dynamic store session. @param serviceID The unique identifier for the service. @result A reference to the SCNetworkService represented in the SCDynamicStore; NULL if the serviceID does not exist in the SCDynamicStore or if an @@ -906,6 +909,19 @@ isA_SCNetworkSet(CFTypeRef obj) } +/*! + @function _SCNetworkSetCompare + @discussion Compares two SCNetworkSet objects. + @param val1 The SCNetworkSet object. + @param val2 The SCNetworkSet object. + @param context Not used. + @result A comparison result. + */ +CFComparisonResult +_SCNetworkSetCompare (const void *val1, + const void *val2, + void *context) __OSX_AVAILABLE_STARTING(__MAC_10_13,__IPHONE_11_0); + /*! @function SCNetworkSetCopyAvailableInterfaces @discussion Returns all available interfaces for the set. @@ -1131,10 +1147,10 @@ _SCNetworkConfigurationCopyMigrationPaths(CFDictionaryRef options) __OSX_AVAI CF_RETURNS_RETAINED CFArrayRef -_SCNetworkConfigurationPerformMigration(CFURLRef sourceDir, - CFURLRef currentDir, - CFURLRef targetDir, - CFDictionaryRef options) __OSX_AVAILABLE_STARTING(__MAC_10_10,__IPHONE_8_0); +_SCNetworkConfigurationPerformMigration (CFURLRef sourceDir, + CFURLRef currentDir, + CFURLRef targetDir, + CFDictionaryRef options) __OSX_AVAILABLE_STARTING(__MAC_10_10,__IPHONE_8_0); /*! @@ -1148,8 +1164,8 @@ _SCNetworkConfigurationPerformMigration(CFURLRef sourceDir, */ Boolean -_SCNetworkConfigurationCheckValidity(CFURLRef configDir, - CFDictionaryRef options) __OSX_AVAILABLE_STARTING(__MAC_10_10,__IPHONE_8_0); +_SCNetworkConfigurationCheckValidity (CFURLRef configDir, + CFDictionaryRef options) __OSX_AVAILABLE_STARTING(__MAC_10_10,__IPHONE_8_0); /*! @@ -1162,31 +1178,29 @@ _SCNetworkConfigurationCheckValidity(CFURLRef configDir, */ Boolean -_SCNetworkConfigurationCheckValidityWithPreferences (SCPreferencesRef prefs, - SCPreferencesRef ni_prefs, - CFDictionaryRef options) __OSX_AVAILABLE_STARTING(__MAC_10_11, __IPHONE_9_0); +_SCNetworkConfigurationCheckValidityWithPreferences + (SCPreferencesRef prefs, + SCPreferencesRef ni_prefs, + CFDictionaryRef options) __OSX_AVAILABLE_STARTING(__MAC_10_11, __IPHONE_9_0); /*! @function _SCNetworkMigrationAreConfigurationsIdentical @discussion Compares the migration output between network configurations with the expected output. - @param configPref Preferences pointing toward preferences.plist file to - be compared with expected file. - @param configNetworkInterfacePref Preferences pointing toward NetworkInterfaces.plist - file to be compared with expected file. - @param expectedConfigPref Preferences pointing toward preferences.plist file - which is the expected result. - @param expectedNetworkInterfacePref Preferences pointing toward NetworkInterfaces.plist - file which is the expected file. + @param configurationURL A URL pointing to the top-level directory of the + configuration to compare. This directory is expected to have + a Library/Preferences/SystemConfiguration subdirectoy. + @param expectedConfigurationURL A URL pointing to the top-level directory of + the expected configuration. This directory is expected to have + a Library/Preferences/SystemConfiguration subdirectoy. @result TRUE if configurations match with the expected configurations */ Boolean -_SCNetworkMigrationAreConfigurationsIdentical (CFURLRef configurationURL, - CFURLRef expectedConfigurationURL) - __OSX_AVAILABLE_STARTING(__MAC_10_10,__IPHONE_8_0); +_SCNetworkMigrationAreConfigurationsIdentical (CFURLRef configurationURL, + CFURLRef expectedConfigurationURL) __OSX_AVAILABLE_STARTING(__MAC_10_10,__IPHONE_8_0); /*! @function _SCNetworkConfigurationCopyMigrationRemovePaths diff --git a/SystemConfiguration.fproj/SCNetworkConnection.c b/SystemConfiguration.fproj/SCNetworkConnection.c index 1d3d0e1..c34e3c4 100644 --- a/SystemConfiguration.fproj/SCNetworkConnection.c +++ b/SystemConfiguration.fproj/SCNetworkConnection.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003-2016 Apple Inc. All rights reserved. + * Copyright (c) 2003-2017 Apple Inc. All rights reserved. * * @APPLE_LICENSE_HEADER_START@ * @@ -178,11 +178,16 @@ __SCNetworkConnectionUseNetworkExtension(SCNetworkConnectionPrivateRef connectio * In that case, we try to get the service type/subtype from the dynamic store. */ if (!result && SCError() == kSCStatusInvalidArgument) { - CFStringRef interfaceKey = SCDynamicStoreKeyCreateNetworkServiceEntity(kCFAllocatorDefault, - kSCDynamicStoreDomainSetup, - SCNetworkServiceGetServiceID(connectionPrivate->service), - kSCEntNetInterface); - CFDictionaryRef interfaceDict = SCDynamicStoreCopyValue(NULL, interfaceKey); + CFStringRef interfaceKey; + CFDictionaryRef interfaceDict; + CFStringRef serviceID; + + serviceID = SCNetworkServiceGetServiceID(connectionPrivate->service); + interfaceKey = SCDynamicStoreKeyCreateNetworkServiceEntity(kCFAllocatorDefault, + kSCDynamicStoreDomainSetup, + serviceID, + kSCEntNetInterface); + interfaceDict = SCDynamicStoreCopyValue(NULL, interfaceKey); if (isA_CFDictionary(interfaceDict)) { CFStringRef interfaceType = CFDictionaryGetValue(interfaceDict, kSCPropNetInterfaceType); if (isA_CFString(interfaceType)) { @@ -217,6 +222,7 @@ __SCNetworkConnectionUsingNetworkExtension(SCNetworkConnectionPrivateRef connect #if !TARGET_OS_SIMULATOR return (connectionPrivate->ne_session != NULL); #else +#pragma unused(connectionPrivate) return FALSE; #endif /* !TARGET_OS_SIMULATOR */ } @@ -401,19 +407,24 @@ __SCNetworkConnectionNotify(SCNetworkConnectionRef connection, void (*context_release)(const void *), void *context_info) { +#ifdef VERBOSE_ACTIVITY_LOGGING os_activity_t activity; - activity = os_activity_create("processing SCHelper request", + activity = os_activity_create("processing SCNetworkConnection notification", OS_ACTIVITY_CURRENT, OS_ACTIVITY_FLAG_DEFAULT); os_activity_scope(activity); +#endif // VERBOSE_ACTIVITY_LOGGING SC_log(LOG_DEBUG, "exec SCNetworkConnection callout"); (*rlsFunction)(connection, nc_status, context_info); if ((context_release != NULL) && (context_info != NULL)) { (*context_release)(context_info); } + +#ifdef VERBOSE_ACTIVITY_LOGGING os_release(activity); +#endif // VERBOSE_ACTIVITY_LOGGING return; } @@ -561,6 +572,8 @@ __SCNetworkConnectionCallBack(void *connection) static void __SCNetworkConnectionMachCallBack(CFMachPortRef port, void * msg, CFIndex size, void * info) { +#pragma unused(port) +#pragma unused(size) mach_no_senders_notification_t *buf = msg; mach_msg_id_t msgid = buf->not_header.msgh_id; SCNetworkConnectionRef connection = (SCNetworkConnectionRef)info; @@ -2488,6 +2501,7 @@ __SCNetworkConnectionUnscheduleFromRunLoop(SCNetworkConnectionRef connection, CFStringRef runLoopMode, dispatch_queue_t queue) { +#pragma unused(queue) SCNetworkConnectionPrivateRef connectionPrivate = (SCNetworkConnectionPrivateRef)connection; dispatch_group_t drainGroup = NULL; dispatch_queue_t drainQueue = NULL; @@ -2731,6 +2745,7 @@ SCNetworkConnectionTriggerOnDemandIfNeeded (CFStringRef hostName, dispatch_retain(wait_for_session); ne_session_set_event_handler(new_session, __SCNetworkConnectionQueue(), ^(ne_session_event_t event, void *event_data) { +#pragma unused(event_data) os_activity_t activity; activity = os_activity_create("processing ne_session notification", @@ -2920,7 +2935,7 @@ SCNetworkConnectionCopyFlowDivertToken(SCNetworkConnectionRef connection, int -SCNetworkConnectionGetServiceIdentifier (SCNetworkConnectionRef connection) +SCNetworkConnectionGetServiceIdentifier (SCNetworkConnectionRef connection) { SCNetworkConnectionPrivateRef connectionPrivate = (SCNetworkConnectionPrivateRef)connection; int service_identifier = -1; @@ -3396,8 +3411,7 @@ __SCNetworkConnectionCopyMatchingTriggerWithName(CFDictionaryRef configuration, CFDictionaryRef result = NULL; int sc_status = kSCStatusOK; CFArrayRef triggers; - uint64_t triggersCount = 0; - int triggersIndex; + CFIndex triggersCount = 0; Boolean usedOnDemandRetry = FALSE; if (triggerNow != NULL) { @@ -3410,7 +3424,7 @@ __SCNetworkConnectionCopyMatchingTriggerWithName(CFDictionaryRef configuration, triggers = CFDictionaryGetValue(configuration, kSCNetworkConnectionOnDemandTriggers); triggersCount = isA_CFArray(triggers) ? CFArrayGetCount(triggers) : 0; - for (triggersIndex = 0; triggersIndex < triggersCount; triggersIndex++) { + for (CFIndex triggersIndex = 0; triggersIndex < triggersCount; triggersIndex++) { CFStringRef matched_domain = NULL; CFStringRef matched_probe_string = NULL; CFDictionaryRef trigger; @@ -3536,12 +3550,11 @@ __SCNetworkConnectionCopyTriggerWithService(CFDictionaryRef configuration, CFStringRef service_id) { CFArrayRef triggers; - uint64_t triggersCount = 0; - int triggersIndex; + CFIndex triggersCount; triggers = CFDictionaryGetValue(configuration, kSCNetworkConnectionOnDemandTriggers); triggersCount = isA_CFArray(triggers) ? CFArrayGetCount(triggers) : 0; - for (triggersIndex = 0; triggersIndex < triggersCount; triggersIndex++) { + for (CFIndex triggersIndex = 0; triggersIndex < triggersCount; triggersIndex++) { CFDictionaryRef trigger; CFStringRef trigger_service_id; @@ -3634,6 +3647,7 @@ __SCNetworkConnectionCopyOnDemandInfoWithName(SCDynamicStoreRef *storeP, SCNetworkConnectionStatus *connectionStatus, CFStringRef *vpnRemoteAddress) /* CFDictionaryRef *info */ { +#pragma unused(storeP) CFDictionaryRef configuration; Boolean ok = FALSE; int sc_status = kSCStatusOK; @@ -4093,9 +4107,7 @@ __SCNetworkConnectionIPv4AddressMatchesRoutes (struct sockaddr_in *addr_in, CFDi void __SCNetworkConnectionMaskIPv6Address(struct in6_addr *addr, struct in6_addr *mask) { - int i; - - for (i = 0; i < sizeof(struct in6_addr); i++) + for (size_t i = 0; i < sizeof(struct in6_addr); i++) addr->s6_addr[i] &= mask->s6_addr[i]; } @@ -4931,6 +4943,7 @@ copyPasswordFromKeychain(CFStringRef uniqueID) return password; #else // !TARGET_OS_IPHONE +#pragma unused(uniqueID) return NULL; #endif // !TARGET_OS_IPHONE } diff --git a/SystemConfiguration.fproj/SCNetworkConnectionPrivate.c b/SystemConfiguration.fproj/SCNetworkConnectionPrivate.c index 8f58c2f..9e01fc5 100644 --- a/SystemConfiguration.fproj/SCNetworkConnectionPrivate.c +++ b/SystemConfiguration.fproj/SCNetworkConnectionPrivate.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2006-2012, 2015, 2016 Apple Inc. All rights reserved. + * Copyright (c) 2006-2012, 2015-2017 Apple Inc. All rights reserved. * * @APPLE_LICENSE_HEADER_START@ * @@ -496,6 +496,9 @@ removeCallout(CFStringRef serviceID, void *context2, void *context3) { +#pragma unused(serviceID) +#pragma unused(context2) +#pragma unused(context3) CFStringRef matchID = (CFStringRef)context1; if (current == NULL) { @@ -537,6 +540,9 @@ setCurrentCallout(CFStringRef serviceID, void *context2, void *context3) { +#pragma unused(serviceID) +#pragma unused(context2) +#pragma unused(context3) CFStringRef matchID = (CFStringRef)context1; CFMutableDictionaryRef newDict; @@ -584,6 +590,9 @@ copyNameCallout(CFStringRef serviceID, void *context2, void *context3) { +#pragma unused(serviceID) +#pragma unused(context2) +#pragma unused(context3) CFStringRef matchID = (CFStringRef)context1; CFStringRef *name = (CFStringRef *)context3; @@ -651,6 +660,9 @@ setNameCallout(CFStringRef serviceID, void *context2, void *context3) { +#pragma unused(serviceID) +#pragma unused(context2) +#pragma unused(context3) CFStringRef matchID = (CFStringRef)context1; CFMutableDictionaryRef newDict; CFStringRef newName = (CFStringRef)context2; @@ -726,6 +738,7 @@ copyInterfaceConfigurationCallout(CFStringRef serviceID, void *context2, void *context3) { +#pragma unused(serviceID) CFDictionaryRef *dict = (CFDictionaryRef *)context3; CFStringRef interfaceType = (CFStringRef)context2; CFStringRef matchID = (CFStringRef)context1; @@ -792,11 +805,12 @@ SCUserPreferencesCopyInterfaceConfiguration(SCUserPreferencesRef userPreferences static CF_RETURNS_RETAINED CFDictionaryRef setInterfaceConfigurationCallout(CFStringRef serviceID, - CFDictionaryRef current, - void *context1, - void *context2, - void *context3) + CFDictionaryRef current, + void *context1, + void *context2, + void *context3) { +#pragma unused(serviceID) CFStringRef interfaceType = (CFStringRef)context2; CFStringRef matchID = (CFStringRef)context1; CFMutableDictionaryRef newDict; @@ -969,6 +983,8 @@ copyAllCallout(CFStringRef serviceID, void *context2, void *context3) { +#pragma unused(context1) +#pragma unused(context2) CFMutableArrayRef *prefs = (CFMutableArrayRef *)context3; CFStringRef prefsID; SCUserPreferencesPrivateRef userPrivate; @@ -1034,6 +1050,8 @@ copyCurrentCallout(CFStringRef serviceID, void *context2, void *context3) { +#pragma unused(context1) +#pragma unused(context2) CFBooleanRef isDefault; CFStringRef prefsID; SCUserPreferencesPrivateRef *userPrivate = (SCUserPreferencesPrivateRef *)context3; @@ -1098,6 +1116,9 @@ createCallout(CFStringRef serviceID, void *context2, void *context3) { +#pragma unused(serviceID) +#pragma unused(context2) +#pragma unused(context3) CFMutableDictionaryRef newDict; CFStringRef newPrefsID = (CFStringRef)context1; @@ -1327,6 +1348,8 @@ copyOptionsCallout(CFStringRef serviceID, void *context2, void *context3) { +#pragma unused(serviceID) +#pragma unused(context2) CFStringRef matchID = (CFStringRef)context1; CFMutableDictionaryRef *userOptions = (CFMutableDictionaryRef *)context3; diff --git a/SystemConfiguration.fproj/SCNetworkInterface.c b/SystemConfiguration.fproj/SCNetworkInterface.c index cdbbaeb..ae1622a 100644 --- a/SystemConfiguration.fproj/SCNetworkInterface.c +++ b/SystemConfiguration.fproj/SCNetworkInterface.c @@ -67,10 +67,6 @@ #include "dy_framework.h" -#ifndef kIODeviceSupportsHoldKey -#define kIODeviceSupportsHoldKey "V92Modem" -#endif - #ifndef kPCIThunderboltString #define kPCIThunderboltString "PCI-Thunderbolt" #endif @@ -106,6 +102,9 @@ static CFStringRef __SCNetworkInterfaceCopyFormattingDescription (CFTypeRef cf, static void __SCNetworkInterfaceDeallocate (CFTypeRef cf); static Boolean __SCNetworkInterfaceEqual (CFTypeRef cf1, CFTypeRef cf2); static CFHashCode __SCNetworkInterfaceHash (CFTypeRef cf); +static void __SCNetworkInterfaceCacheAdd (CFStringRef bsdName, CFArrayRef matchingInterfaces); +static Boolean __SCNetworkInterfaceCacheIsOpen (); +static CFArrayRef __SCNetworkInterfaceCacheCopy (CFStringRef bsdName); enum { @@ -172,6 +171,11 @@ const SCNetworkInterfaceRef kSCNetworkInterfaceLoopback = (SCNetworkInterfaceRef static CFMutableSetRef vendor_interface_types = NULL; +// A thread-specific convenience cache of all interfaces matching a bsd name +// Key: CFStringRef (BSD name) +// Value: CFArrayRef (matching interfaces) +static __thread CFMutableDictionaryRef S_interface_cache = NULL; + #pragma mark - #pragma mark SCNetworkInterface configuration details @@ -329,9 +333,6 @@ __SCNetworkInterfaceCopyFormattingDescription(CFTypeRef cf, CFDictionaryRef form if (interfacePrivate->hidden) { CFStringAppendFormat(result, NULL, CFSTR(", hidden = TRUE")); } - if (interfacePrivate->modemIsV92) { - CFStringAppendFormat(result, NULL, CFSTR(", v.92")); - } if (interfacePrivate->location != NULL) { CFStringAppendFormat(result, NULL, CFSTR(", location = %@"), interfacePrivate->location); } @@ -966,6 +967,7 @@ split_path(CFStringRef path) CFComparisonResult _SCNetworkInterfaceCompare(const void *val1, const void *val2, void *context) { +#pragma unused(context) SCNetworkInterfacePrivateRef dev1 = (SCNetworkInterfacePrivateRef)val1; SCNetworkInterfacePrivateRef dev2 = (SCNetworkInterfacePrivateRef)val2; CFComparisonResult res = kCFCompareEqualTo; @@ -1275,8 +1277,6 @@ pci_slot(io_registry_entry_t interface, CFTypeRef *pci_slot_name) slot_name = IORegistryEntryCreateCFProperty(interface, CFSTR("AAPL,slot-name"), NULL, 0); if (slot_name != NULL) { - CFIndex i; - slot = CFStringCreateMutable(NULL, 0); if (isA_CFString(slot_name)) { if (pci_slot_name != NULL) *pci_slot_name = CFStringCreateCopy(NULL, slot_name); @@ -1288,7 +1288,7 @@ pci_slot(io_registry_entry_t interface, CFTypeRef *pci_slot_name) kCFStringEncodingUTF8); } - for (i = 0; i < sizeof(slot_prefixes)/sizeof(slot_prefixes[0]); i++) { + for (size_t i = 0; i < sizeof(slot_prefixes)/sizeof(slot_prefixes[0]); i++) { CFIndex len; len = CFStringGetLength(slot_prefixes[i]); @@ -1301,7 +1301,7 @@ pci_slot(io_registry_entry_t interface, CFTypeRef *pci_slot_name) } } - for (i = 0; i < sizeof(slot_mappings)/sizeof(slot_mappings[0]); i++) { + for (size_t i = 0; i < sizeof(slot_mappings)/sizeof(slot_mappings[0]); i++) { if (CFStringCompare(slot, slot_mappings[i].name, kCFCompareCaseInsensitive) == kCFCompareEqualTo) { @@ -1351,6 +1351,7 @@ pci_slot(io_registry_entry_t interface, CFTypeRef *pci_slot_name) static CFComparisonResult compare_bsdNames(const void *val1, const void *val2, void *context) { +#pragma unused(context) CFStringRef bsd1 = (CFStringRef)val1; CFStringRef bsd2 = (CFStringRef)val2; @@ -1598,6 +1599,15 @@ processUSBInterface(SCNetworkInterfacePrivateRef interfacePrivate, io_registry_entry_t bus, CFDictionaryRef bus_dict) { +#if TARGET_OS_SIMULATOR +#pragma unused(interfacePrivate) +#pragma unused(interface) +#endif // TARGET_OS_SIMULATOR +#pragma unused(interface_dict) +#pragma unused(controller) +#pragma unused(controller_dict) +#pragma unused(bus) +#pragma unused(bus_dict) #if !TARGET_OS_SIMULATOR // capture USB info if (interfacePrivate->usb.name == NULL) { @@ -2266,22 +2276,6 @@ processSerialInterface(SCNetworkInterfacePrivateRef interfacePrivate, // Modem interfacePrivate->interface_type = kSCNetworkInterfaceTypeModem; interfacePrivate->sort_order = kSortModem; - - // V.92 support - val = IORegistryEntrySearchCFProperty(interface, - kIOServicePlane, - CFSTR(kIODeviceSupportsHoldKey), - NULL, - kIORegistryIterateRecursively | kIORegistryIterateParents); - if (val != NULL) { - uint32_t v92; - - if (isA_CFNumber(val) && - CFNumberGetValue(val, kCFNumberSInt32Type, &v92)) { - interfacePrivate->modemIsV92 = (v92 == 1); - } - CFRelease(val); - } } // Entity (Type) @@ -2731,9 +2725,7 @@ findMatchingInterfaces(CFDictionaryRef matching, static CFIndex findConfiguration(CFStringRef interface_type) { - CFIndex i; - - for (i = 0; i < sizeof(configurations)/sizeof(configurations[0]); i++) { + for (size_t i = 0; i < sizeof(configurations)/sizeof(configurations[0]); i++) { if (CFEqual(interface_type, *configurations[i].interface_type)) { return i; } @@ -2868,6 +2860,7 @@ typedef struct { static void __addExtendedConfigurationType(const void *key, const void *value, void *context) { +#pragma unused(value) CFStringRef extendedType = (CFStringRef)key; extendedConfigurationRef myContextRef = (extendedConfigurationRef)context; @@ -3169,19 +3162,6 @@ __SCNetworkInterfaceCopyInterfaceEntity(SCNetworkInterfaceRef interface) kSCPropUserDefinedName, SCNetworkInterfaceGetLocalizedDisplayName(interface)); - // note that this is a V.92 capable modem - if (CFEqual(interfacePrivate->interface_type, kSCNetworkInterfaceTypeModem) && - interfacePrivate->modemIsV92) { - int one = 1; - CFNumberRef num; - - num = CFNumberCreate(NULL, kCFNumberIntType, &one); - CFDictionarySetValue(entity, - kSCPropNetInterfaceSupportsModemOnHold, - num); - CFRelease(num); - } - return entity; } @@ -3341,10 +3321,11 @@ copy_ppp_entity(CFStringRef bsdName) SCNetworkInterfaceRef -_SCNetworkInterfaceCreateWithBSDName(CFAllocatorRef allocator, - CFStringRef bsdName, - UInt32 flags) +_SCNetworkInterfaceCreateWithBSDName(CFAllocatorRef allocator, + CFStringRef bsdName, + UInt32 flags) { +#pragma unused(allocator) CFMutableDictionaryRef entity = NULL; struct ifreq ifr; SCNetworkInterfaceRef interface; @@ -3729,10 +3710,10 @@ __SCNetworkInterfaceMatchesName(CFStringRef name, CFStringRef key) static SCNetworkInterfaceRef -__SCNetworkInterfaceCreateWithStorageEntity (CFAllocatorRef allocator, - CFDictionaryRef interface_entity, - SCPreferencesRef prefs) +__SCNetworkInterfaceCreateWithStorageEntity(CFAllocatorRef allocator, + CFDictionaryRef interface_entity) { +#pragma unused(allocator) SCNetworkInterfacePrivateRef interfacePrivate = NULL; CFBooleanRef active = NULL; CFStringRef bsdName = NULL; @@ -3865,11 +3846,75 @@ done: } +void +_SCNetworkInterfaceCacheOpen() +{ + if (!__SCNetworkInterfaceCacheIsOpen()) { + S_interface_cache = CFDictionaryCreateMutable(NULL, + 0, + &kCFTypeDictionaryKeyCallBacks, + &kCFTypeDictionaryValueCallBacks); + SC_log(LOG_DEBUG, "SCNetworkInterface cache (%p): open", S_interface_cache); + } +} + + +void +_SCNetworkInterfaceCacheClose() +{ + if (__SCNetworkInterfaceCacheIsOpen()) { + SC_log(LOG_DEBUG, "SCNetworkInterface cache (%p): close", S_interface_cache); + CFRelease(S_interface_cache); + S_interface_cache = NULL; + } +} + + +static void +__SCNetworkInterfaceCacheAdd(CFStringRef bsdName, CFArrayRef matchingInterfaces) +{ + if (__SCNetworkInterfaceCacheIsOpen() && + bsdName != NULL && + matchingInterfaces != NULL) { + SC_log(LOG_DEBUG, "SCNetworkInterface cache (%p): add %@", S_interface_cache, bsdName); + CFDictionaryAddValue(S_interface_cache, bsdName, matchingInterfaces); + } +} + + +static inline Boolean +__SCNetworkInterfaceCacheIsOpen() +{ + return (S_interface_cache != NULL); +} + + +static CFArrayRef +__SCNetworkInterfaceCacheCopy(CFStringRef bsdName) +{ + if (__SCNetworkInterfaceCacheIsOpen() && + bsdName != NULL) { + CFArrayRef matchingInterfaces = CFDictionaryGetValue(S_interface_cache, bsdName); + if (matchingInterfaces) { + CFRetain(matchingInterfaces); + SC_log(LOG_DEBUG, "SCNetworkInterface cache (%p): copy w/ match for %@", S_interface_cache, bsdName); + } else { + SC_log(LOG_DEBUG, "SCNetworkInterface cache (%p): copy w/ no match for %@", S_interface_cache, bsdName); + } + + return matchingInterfaces; + } + + return NULL; +} + + SCNetworkInterfaceRef -_SCNetworkInterfaceCreateWithEntity(CFAllocatorRef allocator, - CFDictionaryRef interface_entity, - SCNetworkServiceRef service) +_SCNetworkInterfaceCreateWithEntity(CFAllocatorRef allocator, + CFDictionaryRef interface_entity, + SCNetworkServiceRef service) { +#pragma unused(allocator) SCNetworkInterfacePrivateRef interfacePrivate = NULL; CFStringRef ifDevice; CFStringRef ifName = NULL; @@ -3886,7 +3931,7 @@ _SCNetworkInterfaceCreateWithEntity(CFAllocatorRef allocator, if (service != NULL) { servicePref = ((SCNetworkServicePrivateRef)service)->prefs; useSystemInterfaces = ((__SCPreferencesUsingDefaultPrefs(servicePref)) && - (__SCPreferencesGetLimitSCNetworkConfiguration(servicePref) == FALSE)); + (!__SCPreferencesGetLimitSCNetworkConfiguration(servicePref))); } ifType = CFDictionaryGetValue(interface_entity, kSCPropNetInterfaceType); @@ -3932,19 +3977,25 @@ _SCNetworkInterfaceCreateWithEntity(CFAllocatorRef allocator, goto done; } if (useSystemInterfaces) { - if (_SC_cfstring_to_cstring(ifDevice, bsdName, sizeof(bsdName), kCFStringEncodingASCII) == NULL) { - goto done; - } + // Check to see if we already have the info in the cache + matching_interfaces = __SCNetworkInterfaceCacheCopy(ifDevice); + if (matching_interfaces == NULL) { + if (_SC_cfstring_to_cstring(ifDevice, bsdName, sizeof(bsdName), kCFStringEncodingASCII) == NULL) { + goto done; + } - matching = IOBSDNameMatching(masterPort, 0, bsdName); - if (matching == NULL) { - goto done; + matching = IOBSDNameMatching(masterPort, 0, bsdName); + if (matching == NULL) { + goto done; + } + matching_interfaces = findMatchingInterfaces(matching, + processNetworkInterface, + kSCNetworkInterfaceHiddenInterfaceKey, + TRUE); + + __SCNetworkInterfaceCacheAdd(ifDevice, matching_interfaces); + CFRelease(matching); } - matching_interfaces = findMatchingInterfaces(matching, - processNetworkInterface, - kSCNetworkInterfaceHiddenInterfaceKey, - TRUE); - CFRelease(matching); } } else if (CFEqual(ifType, kSCValNetInterfaceTypePPP)) { if (CFEqual(ifSubType, kSCValNetInterfaceSubTypePPPSerial)) { @@ -4489,7 +4540,7 @@ __SCNetworkInterfaceCopyAll_RS232() #if !TARGET_OS_IPHONE static void -addBTPANInterface(SCPreferencesRef prefs, CFMutableArrayRef all_interfaces) +addBTPANInterface(CFMutableArrayRef all_interfaces) { CFIndex i; SCNetworkInterfaceRef interface; @@ -4667,7 +4718,7 @@ _SCNetworkInterfaceCopyAllWithPreferences(SCPreferencesRef prefs) #if !TARGET_OS_IPHONE // add BT-PAN interface - addBTPANInterface(prefs, all_interfaces); + addBTPANInterface(all_interfaces); #endif // !TARGET_OS_IPHONE if (temp_preferences) CFRelease(prefs); @@ -5176,7 +5227,7 @@ SCNetworkInterfaceGetHardwareAddressString(SCNetworkInterfaceRef interface) (interfacePrivate->addressString == NULL)) { uint8_t *bp; char *cp; - CFIndex n; + size_t n; char mac[sizeof("xx:xx:xx:xx:xx:xx:xx:xx")]; char *mac_p = mac; @@ -7310,7 +7361,9 @@ _SCNetworkInterfaceCopySlashDevPath(SCNetworkInterfaceRef interface) Boolean _SCNetworkInterfaceIsApplePreconfigured(SCNetworkInterfaceRef interface) { -#if !TARGET_OS_SIMULATOR +#if TARGET_OS_SIMULATOR +#pragma unused(interface) +#else // TARGET_OS_SIMULATOR SCNetworkInterfacePrivateRef interfacePrivate = (SCNetworkInterfacePrivateRef)interface; if (!interfacePrivate->hidden) { @@ -7339,7 +7392,7 @@ _SCNetworkInterfaceIsApplePreconfigured(SCNetworkInterfaceRef interface) return TRUE; } } -#endif // !TARGET_OS_SIMULATOR +#endif // TARGET_OS_SIMULATOR return FALSE; } @@ -7381,15 +7434,6 @@ _SCNetworkInterfaceIsHiddenConfiguration(SCNetworkInterfaceRef interface) } -Boolean -_SCNetworkInterfaceIsModemV92(SCNetworkInterfaceRef interface) -{ - SCNetworkInterfacePrivateRef interfacePrivate = (SCNetworkInterfacePrivateRef)interface; - - return interfacePrivate->modemIsV92; -} - - Boolean _SCNetworkInterfaceIsTethered(SCNetworkInterfaceRef interface) { @@ -7494,6 +7538,7 @@ __SCNetworkInterfaceCreateCopy(CFAllocatorRef allocator, SCPreferencesRef prefs, CFStringRef serviceID) { +#pragma unused(allocator) SCNetworkInterfacePrivateRef oldPrivate = (SCNetworkInterfacePrivateRef)interface; SCNetworkInterfacePrivateRef newPrivate; @@ -7563,7 +7608,6 @@ __SCNetworkInterfaceCreateCopy(CFAllocatorRef allocator, if (oldPrivate->overrides != NULL) { newPrivate->overrides = CFDictionaryCreateMutableCopy(NULL, 0, oldPrivate->overrides); } - newPrivate->modemIsV92 = oldPrivate->modemIsV92; if (oldPrivate->type != NULL) { newPrivate->type = CFRetain(oldPrivate->type); } @@ -8019,6 +8063,7 @@ SCNetworkInterfaceSetDisableUntilNeeded(SCNetworkInterfaceRef interface, Boolean SCNetworkServicePrimaryRank SCNetworkInterfaceGetPrimaryRank(SCNetworkInterfaceRef interface) { +#pragma unused(interface) return (kSCNetworkServicePrimaryRankDefault); } @@ -8026,6 +8071,8 @@ Boolean SCNetworkInterfaceSetPrimaryRank(SCNetworkInterfaceRef interface, SCNetworkServicePrimaryRank newRank) { +#pragma unused(interface) +#pragma unused(newRank) _SCErrorSet(kSCStatusInvalidArgument); return (FALSE); } @@ -8033,18 +8080,23 @@ SCNetworkInterfaceSetPrimaryRank(SCNetworkInterfaceRef interface, Boolean SCNetworkInterfaceGetDisableUntilNeeded(SCNetworkInterfaceRef interface) { +#pragma unused(interface) return (FALSE); } Boolean __SCNetworkInterfaceSetDisableUntilNeededValue(SCNetworkInterfaceRef interface, CFTypeRef disable) { +#pragma unused(interface) +#pragma unused(disable) return (FALSE); } Boolean SCNetworkInterfaceSetDisableUntilNeeded(SCNetworkInterfaceRef interface, Boolean disable) { +#pragma unused(interface) +#pragma unused(disable) _SCErrorSet(kSCStatusInvalidArgument); return (FALSE); } @@ -8054,12 +8106,12 @@ SCNetworkInterfaceSetDisableUntilNeeded(SCNetworkInterfaceRef interface, Boolean __private_extern__ CFArrayRef // SCNetworkInterfaceRef -__SCNetworkInterfaceCopyStoredWithPreferences (SCPreferencesRef ni_prefs) +__SCNetworkInterfaceCopyStoredWithPreferences(SCPreferencesRef ni_prefs) { - CFMutableArrayRef interfaceList = NULL; + CFStringRef defaultNetworkInterfacePath = NULL; CFArrayRef if_list; - SCNetworkInterfaceRef interfaceNamer = NULL; - CFStringRef defaultNetworkInterfacePath = NULL; + CFMutableArrayRef interfaceList = NULL; + SCNetworkInterfaceRef interfaceNamer = NULL; /* initialize runtime */ pthread_once(&initialized, __SCNetworkInterfaceInitialize); @@ -8071,8 +8123,7 @@ __SCNetworkInterfaceCopyStoredWithPreferences (SCPreferencesRef ni_prefs) } if_list = SCPreferencesGetValue(ni_prefs, INTERFACES); - - if (isA_CFArray(if_list) != NULL) { + if (isA_CFArray(if_list)) { CFIndex i; CFIndex n = CFArrayGetCount(if_list); @@ -8082,7 +8133,7 @@ __SCNetworkInterfaceCopyStoredWithPreferences (SCPreferencesRef ni_prefs) dict = CFArrayGetValueAtIndex(if_list, i); if (isA_CFDictionary(dict) != NULL) { - interfaceNamer = __SCNetworkInterfaceCreateWithStorageEntity(NULL, dict, ni_prefs); + interfaceNamer = __SCNetworkInterfaceCreateWithStorageEntity(NULL, dict); if (interfaceNamer != NULL) { CFArrayAppendValue(interfaceList, interfaceNamer); @@ -8170,7 +8221,7 @@ __SCNetworkInterfaceCreateWithNIPreferencesUsingBSDName(CFAllocatorRef allocator continue; } if (CFEqual(bsdName, tmp_bsdName)) { - interface = __SCNetworkInterfaceCreateWithStorageEntity(allocator, dict, ni_prefs); + interface = __SCNetworkInterfaceCreateWithStorageEntity(allocator, dict); break; } } diff --git a/SystemConfiguration.fproj/SCNetworkMigration.c b/SystemConfiguration.fproj/SCNetworkMigration.c index 3d4c53f..3116811 100644 --- a/SystemConfiguration.fproj/SCNetworkMigration.c +++ b/SystemConfiguration.fproj/SCNetworkMigration.c @@ -81,7 +81,7 @@ _SCNetworkConfigurationCopyMigrationPathsWithBaseURL(CFURLRef baseURL, CFURLRef } else { baseURL = CFURLCreateFromFileSystemRepresentation(NULL, (UInt8*)PREFS_DEFAULT_DIR_PLIST, - sizeof(PREFS_DEFAULT_DIR_PLIST), + sizeof(PREFS_DEFAULT_DIR_PLIST) - 1, TRUE); } @@ -103,6 +103,7 @@ _SCNetworkConfigurationCopyMigrationPathsWithBaseURL(CFURLRef baseURL, CFURLRef CFArrayRef _SCNetworkConfigurationCopyMigrationPaths(CFDictionaryRef options) { +#pragma unused(options) CFURLRef interfaces; CFMutableArrayRef migrationPaths = NULL; CFURLRef prefs; @@ -138,7 +139,7 @@ _SCNetworkConfigurationRemoveConfigurationFiles(CFURLRef configDir) sizeof(configPathString))) { SC_log(LOG_NOTICE, "Cannot get file system representation for url: %@", configPathURL); } else { - if (remove(configPathString) != 0) { + if ((remove(configPathString) != 0) && (errno != ENOENT)) { SC_log(LOG_INFO, "remove(\"%s\") failed: %s", configPathString, strerror(errno)); } } @@ -150,7 +151,7 @@ _SCNetworkConfigurationRemoveConfigurationFiles(CFURLRef configDir) sizeof(configNetworkInterfacesPathString))) { SC_log(LOG_NOTICE, "Cannot get file system representation for url: %@", configNetworkInterfacesPathURL); } else { - if (remove(configNetworkInterfacesPathString) != 0) { + if ((remove(configNetworkInterfacesPathString) != 0) && (errno != ENOENT)) { SC_log(LOG_INFO, "remove(\"%s\") failed: %s", configNetworkInterfacesPathString, strerror(errno)); } } @@ -219,7 +220,8 @@ SCNetworkConfigurationCopyConfigurationFiles(CFURLRef configDir, } state = copyfile_state_alloc(); - if ((error = copyfile(preferencesPathString, targetPathString, state, COPYFILE_ALL)) != 0) { + error = copyfile(preferencesPathString, targetPathString, state, COPYFILE_ALL); + if (error != 0) { SC_log(LOG_NOTICE, "copyFile(\"%s\", \"%s\", ...) failed: %s", preferencesPathString, targetPathString, @@ -232,7 +234,8 @@ SCNetworkConfigurationCopyConfigurationFiles(CFURLRef configDir, (void)chmod(targetPathString, mode); networkInterfacesState = copyfile_state_alloc(); - if ((error = copyfile(networkInterfacesPathString, targetNetworkInterfacesPathString, networkInterfacesState, COPYFILE_ALL)) != 0) { + error = copyfile(networkInterfacesPathString, targetNetworkInterfacesPathString, networkInterfacesState, COPYFILE_ALL); + if (error != 0) { SC_log(LOG_NOTICE, "copyFile(\"%s\", \"%s\", ...) failed: %s", networkInterfacesPathString, targetNetworkInterfacesPathString, @@ -359,16 +362,14 @@ __SCNetworkCreateDefaultNIPrefs(CFStringRef prefsID) SC_log(LOG_NOTICE, "networkInterfaces is NULL"); return NULL; } + if (prefsID == NULL) { prefsID = CFStringCreateWithFormat(NULL, NULL, CFSTR("%@/%@"), PREFS_DEFAULT_DIR, NETWORK_INTERFACES_PREFS); - } - else { + } else { CFRetain(prefsID); } - - ni_prefs = SCPreferencesCreate(NULL, PLUGIN_ID , prefsID); + ni_prefs = SCPreferencesCreate(NULL, PLUGIN_ID, prefsID); CFRelease(prefsID); - if (ni_prefs == NULL) { SC_log(LOG_NOTICE, "ni_prefs is NULL"); goto done; @@ -440,6 +441,7 @@ CF_RETURNS_RETAINED CFArrayRef _SCNetworkConfigurationPerformMigration(CFURLRef sourceDir, CFURLRef currentDir, CFURLRef targetDir, CFDictionaryRef options) { +#pragma unused(options) CFURLRef currentDirConfig = NULL; CFURLRef currentSystemPath = NULL; Boolean migrationComplete = FALSE; @@ -452,6 +454,21 @@ _SCNetworkConfigurationPerformMigration(CFURLRef sourceDir, CFURLRef currentDir, _sc_debug = 1; } + if ((sourceDir != NULL) && !CFURLHasDirectoryPath(sourceDir)) { + SC_log(LOG_INFO, "sourceDir is not a directory: %@", sourceDir); + goto done; + } + + if ((currentDir != NULL) && !CFURLHasDirectoryPath(currentDir)) { + SC_log(LOG_INFO, "currentDir is not a directory: %@", currentDir); + goto done; + } + + if ((targetDir != NULL) && !CFURLHasDirectoryPath(targetDir)) { + SC_log(LOG_INFO, "targetDir is not a directory: %@", targetDir); + goto done; + } + // Both sourceDir and currentDir cannot be NULL because NULL value indicates using current system if (sourceDir == NULL && currentDir == NULL) { SC_log(LOG_INFO, "Both sourceDir and currentDir are NULL"); @@ -465,8 +482,7 @@ _SCNetworkConfigurationPerformMigration(CFURLRef sourceDir, CFURLRef currentDir, // if either of the sourceDir or currentDir are NULL, then populate it with current system path if (sourceDir == NULL) { sourceDirConfig = CFRetain(currentSystemPath); - } - else { + } else { sourceDirConfig = CFURLCreateWithFileSystemPathRelativeToBase(NULL, PREFS_DEFAULT_DIR_RELATIVE, kCFURLPOSIXPathStyle, TRUE, sourceDir); } @@ -476,8 +492,7 @@ _SCNetworkConfigurationPerformMigration(CFURLRef sourceDir, CFURLRef currentDir, // If the targetDir is not provided then migration will take place in currentDir if (targetDir == NULL) { targetDirConfig = CFRetain(currentSystemPath); - } - else { + } else { targetDirConfig = CFURLCreateWithFileSystemPathRelativeToBase(NULL, PREFS_DEFAULT_DIR_RELATIVE, kCFURLPOSIXPathStyle, TRUE, targetDir); } // Source directory cannot be the same as Target Directory @@ -496,8 +511,7 @@ _SCNetworkConfigurationPerformMigration(CFURLRef sourceDir, CFURLRef currentDir, SC_log(LOG_INFO, "Could not copy configuration files from \"%@\" to \"%@\"", currentDirConfig, targetDirConfig); - } - else if (currentDirConfig != NULL) { + } else if (currentDirConfig != NULL) { removeTargetOnFailure = TRUE; // Configuration files were copied over to target directory // If migration failed, then we should remove those configuration // files since current directory and target directory are not @@ -509,8 +523,7 @@ _SCNetworkConfigurationPerformMigration(CFURLRef sourceDir, CFURLRef currentDir, if ((currentDirConfig != NULL) && CFEqual(sourceDirConfig, currentDirConfig)) { SC_log(LOG_INFO, "No migration needed, source and current configurations point to same path"); migrationComplete = TRUE; - } - else { + } else { migrationComplete = _SCNetworkConfigurationMigrateConfiguration(sourceDirConfig, targetDirConfig); } if (migrationComplete) { @@ -601,7 +614,7 @@ __SCNetworkConfigurationMigrateConfigurationFilesPresent(CFURLRef baseURL, CFArr for (CFIndex idx = 0; idx < count; idx++) { filePath = CFArrayGetValueAtIndex(*migrationPaths, idx); - if (_SCNetworkConfigurationMigrateIsFilePresent(filePath) == FALSE) { + if (!_SCNetworkConfigurationMigrateIsFilePresent(filePath)) { SC_log(LOG_INFO, "Required migration file not present: %@", filePath); goto done; } @@ -677,7 +690,7 @@ _SCNetworkInterfaceStorageCopyMaxUnitPerInterfaceType(SCPreferencesRef ni_prefs) } type = _SCNetworkInterfaceGetIOInterfaceType(interface); - if (isA_CFNumber(type) == NULL) { + if (!isA_CFNumber(type)) { SC_log(LOG_INFO, "No interface type"); continue; } @@ -694,8 +707,7 @@ _SCNetworkInterfaceStorageCopyMaxUnitPerInterfaceType(SCPreferencesRef ni_prefs) } unit = _SCNetworkInterfaceGetIOInterfaceUnit(interface); - - if (isA_CFNumber(unit) == NULL) { + if (!isA_CFNumber(unit)) { continue; } @@ -825,8 +837,7 @@ _SCNetworkConfigurationCopyExternalInterfaceMapping (SCPreferencesRef sourcePref if (cfMaxTargetUnit != NULL) { CFNumberGetValue(cfMaxTargetUnit, kCFNumberIntType, &maxTargetUnit); newTargetUnit = maxTargetUnit + 1; - } - else { + } else { newTargetUnit = 0; } @@ -838,8 +849,7 @@ _SCNetworkConfigurationCopyExternalInterfaceMapping (SCPreferencesRef sourcePref SC_log(LOG_DEBUG, "sourceInterface: %p, target Interface: %p", sourceInterface, targetInterface); currentInterfaceUnit = _SCNetworkInterfaceGetIOInterfaceUnit(targetInterface); - - if ((isA_CFNumber(currentInterfaceUnit) == NULL) || + if (!isA_CFNumber(currentInterfaceUnit) || !CFEqual(currentInterfaceUnit, cfMaxTargetUnit)) { // Update the interface unit __SCNetworkInterfaceSetIOInterfaceUnit(targetInterface, cfMaxTargetUnit); @@ -871,6 +881,7 @@ __SCNetworkConfigurationInterfaceNameIsEquiv(CFStringRef interfaceName1, CFStrin static Boolean _SCNetworkConfigurationIsInterfaceNamerMappable(SCNetworkInterfaceRef interface1, SCNetworkInterfaceRef interface2, Boolean bypassActive) { +#pragma unused(bypassActive) Boolean interface1IsBuiltin; CFStringRef interface1Prefix; CFStringRef interface1Type; @@ -966,8 +977,7 @@ __SCNetworkConfigurationInterfaceNameIsEquiv(CFStringRef interfaceName1, CFStrin return TRUE; } } - } - else { + } else { return TRUE; } } @@ -1070,7 +1080,7 @@ _SCNetworkConfigurationCollectMissingService(const void *key, const void *value, CFMutableArrayRef interfacesMissingServices = ctx->interfacesMissingServices; CFDictionaryRef serviceInterfaceMapping = ctx->interfaceMapping; - if ((isA_SCNetworkInterface(interface) == NULL) || + if (!isA_SCNetworkInterface(interface) || !_SCNetworkInterfaceIsBuiltin(interface)) { return; } @@ -1194,7 +1204,7 @@ add_service(const void *value, void *context) } } - // Add Service to current set + // Add service to current set currentSet = SCNetworkSetCopyCurrent(prefs); if (currentSet == NULL) { SCNetworkServiceRemove(service); @@ -1207,7 +1217,9 @@ add_service(const void *value, void *context) SC_log(LOG_INFO, "Could not add service to current set"); goto done; } -done: + + done: + if (service != NULL) { CFRelease(service); } @@ -1380,8 +1392,7 @@ validate_bridge(const void *value, void *context) if (CFArrayGetCount(memberInterfacesMutable) == 0) { SC_log(LOG_INFO, "Removing invalid bridge configuration: %@", bridge); SCBridgeInterfaceRemove(bridge); - } - else { + } else { SCBridgeInterfaceSetMemberInterfaces(bridge, memberInterfacesMutable); } CFRelease(memberInterfacesMutable); @@ -1416,8 +1427,7 @@ validate_bond(const void *value, void *context) if (CFArrayGetCount(memberInterfacesMutable) == 0) { SC_log(LOG_INFO, "Removing invalid bond configuration: %@", bond); SCBondInterfaceRemove(bond); - } - else { + } else { SCBondInterfaceSetMemberInterfaces(bond, memberInterfacesMutable); } CFRelease(memberInterfacesMutable); @@ -1577,8 +1587,7 @@ _SCNetworkConfigurationCheckValidityWithPreferences(SCPreferencesRef prefs, if (!SCPreferencesCommitChanges(prefs)) { SC_log(LOG_INFO, "SCPreferencesCommitChanges() failed"); } - } - else { + } else { goto done; } } @@ -1799,6 +1808,7 @@ typedef struct { static void _SCNetworkConfigurationCollectInterfaceStorageEntity(const void *key, const void *value, void *context) { +#pragma unused(key) SCExternalMappingContext* ctx = context; CFDictionaryRef interface_entity = NULL; SCNetworkInterfaceRef targetInterface = (SCNetworkInterfaceRef)value; @@ -1832,8 +1842,7 @@ _SCNetworkMigrationCreateNetworkInterfaceArray(SCPreferencesRef ni_prefs, CFDict } if_list = SCPreferencesGetValue(ni_prefs, INTERFACES); - - if ((isA_CFArray(if_list) == NULL) || + if (!isA_CFArray(if_list) || ((count = CFArrayGetCount(if_list)) == 0)) { SC_log(LOG_INFO, "No interfaces"); return NULL; @@ -1844,16 +1853,17 @@ _SCNetworkMigrationCreateNetworkInterfaceArray(SCPreferencesRef ni_prefs, CFDict // Keep the same builtin and external interfaces for (CFIndex idx = 0; idx < count; idx++) { interface_entity = CFArrayGetValueAtIndex(if_list, idx); - if (isA_CFDictionary(interface_entity) == NULL) { + if (!isA_CFDictionary(interface_entity)) { continue; } CFArrayAppendValue(networkInterfaceList, interface_entity); } - if (isA_CFDictionary(externalMapping) == NULL) { + if (!isA_CFDictionary(externalMapping)) { SC_log(LOG_INFO, "No external mapping"); goto done; } + // Add any new external interfaces found externalInterfaceList = _SCNetworkInterfaceCopyInterfacesFilteredByBuiltinWithPreferences(ni_prefs, FALSE); context.externalInterfaceList = externalInterfaceList; @@ -1904,7 +1914,7 @@ _SCNetworkMigrationCreateBSDNameMapping(CFDictionaryRef internalMapping, CFDicti &kCFTypeDictionaryKeyCallBacks, &kCFTypeDictionaryValueCallBacks); - if ((internalMapping == NULL) && externalMapping == NULL) { + if ((internalMapping == NULL) && (externalMapping == NULL)) { goto done; } @@ -2037,8 +2047,7 @@ _SCNetworkMigrationCreateSetMapping(SCPreferencesRef sourcePrefs, targetSet = CFArrayGetValueAtIndex(targetSetsMutable, 0); CFRetain(targetSet); CFArrayRemoveValueAtIndex(targetSetsMutable, 0); - } - else { + } else { targetSet = SCNetworkSetCreate(targetPrefs); } SCNetworkSetSetName(targetSet, setName); @@ -2047,7 +2056,8 @@ _SCNetworkMigrationCreateSetMapping(SCPreferencesRef sourcePrefs, CFRelease(targetSet); } -done: + done: + if (sourceSets != NULL) { CFRelease(sourceSets); } @@ -2194,8 +2204,7 @@ _SCNetworkMigrationCreateServiceMappingUsingBSDMapping(SCPreferencesRef sourcePr CFArrayRemoveValueAtIndex(targetSCNetworkServicesMutable, idx2); break; } - } - else { + } else { // Source Interface Type should be VPN targetInterfaceType = __SCNetworkInterfaceGetEntityType(targetInterface); if ((isA_CFString(targetInterfaceType) == NULL) || @@ -2228,7 +2237,9 @@ _SCNetworkMigrationCreateServiceMappingUsingBSDMapping(SCPreferencesRef sourcePr CFDictionaryAddValue(serviceMapping, sourceService, kCFBooleanFalse); } } -done: + + done : + if (sourceSCNetworkServices != NULL) { CFRelease(sourceSCNetworkServices); } @@ -2346,7 +2357,6 @@ _SCNetworkMigrationDoSystemMigration(SCPreferencesRef sourcePrefs, SCPreferences } computerName = _SCPreferencesCopyComputerName(sourcePrefs, &nameEncoding); - if (computerName != NULL) { SCPreferencesSetComputerName(targetPrefs, computerName, nameEncoding); CFRelease(computerName); @@ -2358,7 +2368,6 @@ _SCNetworkMigrationDoSystemMigration(SCPreferencesRef sourcePrefs, SCPreferences kSCCompNetwork, BACK_TO_MY_MAC); btmm = SCPreferencesPathGetValue(sourcePrefs, btmmPath); - if (btmm != NULL) { SCPreferencesPathSetValue(targetPrefs, btmmPath, btmm); } @@ -2545,6 +2554,7 @@ _SCNetworkMigrationDoBridgeMigration (SCPreferencesRef sourcePrefs, CFDictionaryRef setMapping, CFDictionaryRef serviceSetMapping) { +#pragma unused(sourceNIPrefs) CFArrayRef allSourceBridges; CFArrayRef allTargetBridges; SCBridgeInterfaceRef bridge; @@ -2748,6 +2758,7 @@ _SCNetworkMigrationDoBondMigration (SCPreferencesRef sourcePrefs, CFDictionaryRef setMapping, CFDictionaryRef serviceSetMapping) { +#pragma unused(sourceNIPrefs) CFArrayRef allSourceBonds; CFArrayRef allTargetBonds; SCBondInterfaceRef bond; @@ -2977,6 +2988,7 @@ _SCNetworkMigrationDoVLANMigration (SCPreferencesRef sourcePrefs, CFDictionaryRef setMapping, CFDictionaryRef serviceSetMapping) { +#pragma unused(sourceNIPrefs) CFArrayRef allSourceVLAN; CFArrayRef allTargetVLAN; SCVirtualInterfaceContext context; @@ -3160,6 +3172,7 @@ preserve_service_order(const void *key, const void *value, void *context) if (*success == FALSE) { return; } + migratedServiceOrder = CFArrayCreateMutable(NULL, 0, &kCFTypeArrayCallBacks); nonMigratedServices = CFArrayCreateMutable(NULL, 0, &kCFTypeArrayCallBacks); @@ -3180,7 +3193,6 @@ preserve_service_order(const void *key, const void *value, void *context) // Creating a list of service IDs which were migrated in the target set // while maintaining the service order or the source set CFArrayApplyFunction(sourceServiceOrder, CFRangeMake(0, CFArrayGetCount(sourceServiceOrder)), create_migrated_order, &migrated_context); - if (*success == FALSE) { goto done; } @@ -3220,9 +3232,11 @@ _SCNetworkMigrationDoServiceOrderMigration(SCPreferencesRef sourcePrefs, SCPreferencesRef targetPrefs, CFDictionaryRef setMapping) { +#pragma unused(sourcePrefs) +#pragma unused(targetPrefs) Boolean success = TRUE; - if (isA_CFDictionary(setMapping) == NULL) { + if (!isA_CFDictionary(setMapping)) { success = FALSE; goto done; } @@ -3327,8 +3341,7 @@ _SCNetworkConfigurationMigrateConfiguration(CFURLRef sourceDir, CFURLRef targetD if ((targetPrefs == NULL) || (targetNetworkInterfacePrefs == NULL)) { goto done; } - } - else { + } else { targetPrefs = __SCNetworkCreateDefaultPref(targetPreferencesFileString); targetNetworkInterfacePrefs = __SCNetworkCreateDefaultNIPrefs(targetNetworkInterfaceFileString); @@ -3435,8 +3448,7 @@ _SCNetworkConfigurationMigrateConfiguration(CFURLRef sourceDir, CFURLRef targetD } CFRelease(upgradeSourcePrefs); CFRelease(upgradeSourceNIPrefs); - } - else { + } else { builtinMapping = _SCNetworkConfigurationCopyBuiltinMapping(sourceNetworkInterfacePrefs, targetNetworkInterfacePrefs); externalMapping = _SCNetworkConfigurationCopyExternalInterfaceMapping(sourceNetworkInterfacePrefs, targetNetworkInterfacePrefs); @@ -3578,26 +3590,26 @@ _SCNetworkMigrationAreServicesIdentical(SCPreferencesRef configPref, SCPreferenc CFMutableArrayRef expectedServiceArray = NULL; CFIndex expectedServiceArrayCount = 0; CFDictionaryRef expectedServiceDict = NULL; - CFIndex expectedServiceDictCount = 0; + size_t expectedServiceDictCount = 0; CFDictionaryRef expectedServiceEntity = 0; Boolean foundMatch = FALSE; CFMutableArrayRef serviceArray = NULL; CFIndex serviceArrayCount = 0; CFDictionaryRef serviceDict = NULL; - CFIndex serviceDictCount = 0; + size_t serviceDictCount = 0; CFDictionaryRef serviceEntity = NULL; Boolean success = FALSE; const void * vals_q[N_QUICK]; const void ** vals = vals_q; serviceDict = SCPreferencesGetValue(configPref, kSCPrefNetworkServices); - if (isA_CFDictionary(serviceDict) == NULL) { + if (!isA_CFDictionary(serviceDict)) { goto done; } serviceDictCount = CFDictionaryGetCount(serviceDict); expectedServiceDict = SCPreferencesGetValue(expectedConfigPref, kSCPrefNetworkServices); - if (isA_CFDictionary(expectedServiceDict) == NULL) { + if (!isA_CFDictionary(expectedServiceDict)) { goto done; } expectedServiceDictCount = CFDictionaryGetCount(expectedServiceDict); @@ -3613,7 +3625,7 @@ _SCNetworkMigrationAreServicesIdentical(SCPreferencesRef configPref, SCPreferenc CFDictionaryGetKeysAndValues(serviceDict, NULL, vals); serviceArray = CFArrayCreateMutable(NULL, 0, &kCFTypeArrayCallBacks); - for (CFIndex idx=0; idx < serviceDictCount; idx++) { + for (size_t idx=0; idx < serviceDictCount; idx++) { serviceEntity = vals[idx]; if (!isA_CFDictionary(serviceEntity)) { continue; @@ -3630,7 +3642,7 @@ _SCNetworkMigrationAreServicesIdentical(SCPreferencesRef configPref, SCPreferenc CFDictionaryGetKeysAndValues(expectedServiceDict, NULL, expected_vals); expectedServiceArray = CFArrayCreateMutable(NULL, 0, &kCFTypeArrayCallBacks); - for (CFIndex idx = 0; idx < expectedServiceDictCount; idx++) { + for (size_t idx = 0; idx < expectedServiceDictCount; idx++) { serviceEntity = expected_vals[idx]; if (!isA_CFDictionary(serviceEntity)) { continue; @@ -3687,14 +3699,14 @@ _SCNetworkMigrationAreNetworkInterfaceConfigurationsIdentical (SCPreferencesRef Boolean success = FALSE; interfaceList = SCPreferencesGetValue(configNetworkInterfacePref, INTERFACES); - if (isA_CFArray(interfaceList) == NULL) { + if (!isA_CFArray(interfaceList)) { goto done; } interfaceListMutable = CFArrayCreateMutableCopy(NULL, 0, interfaceList); interfaceListCount = CFArrayGetCount(interfaceListMutable); expectedInterfaceList = SCPreferencesGetValue(expectedNetworkInterfacePref, INTERFACES); - if (isA_CFArray(expectedInterfaceList) == NULL) { + if (!isA_CFArray(expectedInterfaceList)) { goto done; } expectedInterfaceListCount = CFArrayGetCount(expectedInterfaceList); @@ -3821,8 +3833,7 @@ done: expectedNetworkInterfacePref == NULL) { SC_log(LOG_INFO, "One of the preferences is NULL"); isIdentical = FALSE; - } - else { + } else { isIdentical = (_SCNetworkMigrationAreServicesIdentical(configPref, expectedConfigPref) && _SCNetworkMigrationAreNetworkInterfaceConfigurationsIdentical(configNetworkInterfacePref, expectedNetworkInterfacePref)); } diff --git a/SystemConfiguration.fproj/SCNetworkProtocol.c b/SystemConfiguration.fproj/SCNetworkProtocol.c index 33bf633..537b902 100644 --- a/SystemConfiguration.fproj/SCNetworkProtocol.c +++ b/SystemConfiguration.fproj/SCNetworkProtocol.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2004-2008, 2016 Apple Inc. All rights reserved. + * Copyright (c) 2004-2008, 2016, 2017 Apple Inc. All rights reserved. * * @APPLE_LICENSE_HEADER_START@ * @@ -116,10 +116,10 @@ __SCNetworkProtocolEqual(CFTypeRef cf1, CFTypeRef cf2) return FALSE; // if not the same protocol type if (p1->service == p2->service) - return TRUE; // if both point to the same service + return TRUE; // if both point to the same service if ((p1->service != NULL) && (p2->service != NULL) && CFEqual(p1->service, p2->service)) - return TRUE; // if both effectively point to the same service + return TRUE; // if both effectively point to the same service return FALSE; } @@ -154,11 +154,11 @@ __SCNetworkProtocolCreatePrivate(CFAllocatorRef allocator, pthread_once(&initialized, __SCNetworkProtocolInitialize); /* allocate target */ - size = sizeof(SCNetworkProtocolPrivate) - sizeof(CFRuntimeBase); + size = sizeof(SCNetworkProtocolPrivate) - sizeof(CFRuntimeBase); protocolPrivate = (SCNetworkProtocolPrivateRef)_CFRuntimeCreateInstance(allocator, - __kSCNetworkProtocolTypeID, - size, - NULL); + __kSCNetworkProtocolTypeID, + size, + NULL); if (protocolPrivate == NULL) { return NULL; } @@ -174,8 +174,7 @@ __SCNetworkProtocolCreatePrivate(CFAllocatorRef allocator, __private_extern__ Boolean __SCNetworkProtocolIsValidType(CFStringRef protocolType) { - int i; - static const CFStringRef *valid_types[] = { + static const CFStringRef *valid_types[] = { &kSCNetworkProtocolTypeDNS, &kSCNetworkProtocolTypeIPv4, &kSCNetworkProtocolTypeIPv6, @@ -185,7 +184,7 @@ __SCNetworkProtocolIsValidType(CFStringRef protocolType) #endif // !TARGET_OS_IPHONE }; - for (i = 0; i < sizeof(valid_types)/sizeof(valid_types[0]); i++) { + for (size_t i = 0; i < sizeof(valid_types)/sizeof(valid_types[0]); i++) { if (CFEqual(protocolType, *valid_types[i])) { // if known/valid protocol type return TRUE; @@ -209,12 +208,12 @@ static CFStringRef copyProtocolConfigurationPath(SCNetworkProtocolPrivateRef protocolPrivate) { CFStringRef path; - SCNetworkServicePrivateRef servicePrivate; + SCNetworkServicePrivateRef servicePrivate; servicePrivate = (SCNetworkServicePrivateRef)protocolPrivate->service; path = SCPreferencesPathKeyCreateNetworkServiceEntity(NULL, // allocator servicePrivate->serviceID, // service - protocolPrivate->entityID); // entity + protocolPrivate->entityID); // entity return path; } @@ -223,6 +222,22 @@ copyProtocolConfigurationPath(SCNetworkProtocolPrivateRef protocolPrivate) #pragma mark SCNetworkProtocol APIs +CFComparisonResult +_SCNetworkProtocolCompare(const void *val1, const void *val2, void *context) +{ +#pragma unused(context) + SCNetworkProtocolRef p1 = (SCNetworkProtocolRef)val1; + SCNetworkProtocolRef p2 = (SCNetworkProtocolRef)val2; + CFStringRef type1; + CFStringRef type2; + + type1 = SCNetworkProtocolGetProtocolType(p1); + type2 = SCNetworkProtocolGetProtocolType(p2); + + return CFStringCompare(type1, type2, 0); +} + + CFTypeID SCNetworkProtocolGetTypeID() { @@ -237,13 +252,14 @@ SCNetworkProtocolGetConfiguration(SCNetworkProtocolRef protocol) CFDictionaryRef config; CFStringRef path; SCNetworkProtocolPrivateRef protocolPrivate = (SCNetworkProtocolPrivateRef)protocol; - SCNetworkServicePrivateRef servicePrivate = (SCNetworkServicePrivateRef)protocolPrivate->service; + SCNetworkServicePrivateRef servicePrivate; if (!isA_SCNetworkProtocol(protocol)) { _SCErrorSet(kSCStatusInvalidArgument); return NULL; } + servicePrivate = (SCNetworkServicePrivateRef)protocolPrivate->service; path = copyProtocolConfigurationPath(protocolPrivate); config = __getPrefsConfiguration(servicePrivate->prefs, path); CFRelease(path); @@ -258,13 +274,14 @@ SCNetworkProtocolGetEnabled(SCNetworkProtocolRef protocol) Boolean enabled; CFStringRef path; SCNetworkProtocolPrivateRef protocolPrivate = (SCNetworkProtocolPrivateRef)protocol; - SCNetworkServicePrivateRef servicePrivate = (SCNetworkServicePrivateRef)protocolPrivate->service; + SCNetworkServicePrivateRef servicePrivate; if (!isA_SCNetworkProtocol(protocol)) { _SCErrorSet(kSCStatusInvalidArgument); return FALSE; } + servicePrivate = (SCNetworkServicePrivateRef)protocolPrivate->service; path = copyProtocolConfigurationPath(protocolPrivate); enabled = __getPrefsEnabled(servicePrivate->prefs, path); CFRelease(path); @@ -293,13 +310,14 @@ SCNetworkProtocolSetConfiguration(SCNetworkProtocolRef protocol, CFDictionaryRef Boolean ok; CFStringRef path; SCNetworkProtocolPrivateRef protocolPrivate = (SCNetworkProtocolPrivateRef)protocol; - SCNetworkServicePrivateRef servicePrivate = (SCNetworkServicePrivateRef)protocolPrivate->service; + SCNetworkServicePrivateRef servicePrivate; if (!isA_SCNetworkProtocol(protocol)) { _SCErrorSet(kSCStatusInvalidArgument); return FALSE; } + servicePrivate = (SCNetworkServicePrivateRef)protocolPrivate->service; path = copyProtocolConfigurationPath(protocolPrivate); ok = __setPrefsConfiguration(servicePrivate->prefs, path, config, TRUE); CFRelease(path); @@ -320,13 +338,14 @@ SCNetworkProtocolSetEnabled(SCNetworkProtocolRef protocol, Boolean enabled) Boolean ok; CFStringRef path; SCNetworkProtocolPrivateRef protocolPrivate = (SCNetworkProtocolPrivateRef)protocol; - SCNetworkServicePrivateRef servicePrivate = (SCNetworkServicePrivateRef)protocolPrivate->service; + SCNetworkServicePrivateRef servicePrivate; if (!isA_SCNetworkProtocol(protocol)) { _SCErrorSet(kSCStatusInvalidArgument); return FALSE; } + servicePrivate = (SCNetworkServicePrivateRef)protocolPrivate->service; path = copyProtocolConfigurationPath(protocolPrivate); ok = __setPrefsEnabled(servicePrivate->prefs, path, enabled); CFRelease(path); diff --git a/SystemConfiguration.fproj/SCNetworkReachability.c b/SystemConfiguration.fproj/SCNetworkReachability.c index 4553e0e..6792525 100644 --- a/SystemConfiguration.fproj/SCNetworkReachability.c +++ b/SystemConfiguration.fproj/SCNetworkReachability.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003-2016 Apple Inc. All rights reserved. + * Copyright (c) 2003-2017 Apple Inc. All rights reserved. * * @APPLE_LICENSE_HEADER_START@ * @@ -58,7 +58,8 @@ #include #include -#define SC_LOG_HANDLE __log_SCNetworkReachability() +#define SC_LOG_HANDLE __log_SCNetworkReachability() +#define SC_LOG_HANDLE_TYPE static #include #include #include @@ -285,6 +286,7 @@ __SCNetworkReachabilityCopyDescription(CFTypeRef cf) CFStringAppendFormat(result, NULL, CFSTR(" (%s"), (targetPrivate->lastResolverStatus == nw_resolver_status_complete) ? "complete" : "in progress"); if (nw_array_get_count(targetPrivate->lastResolvedEndpoints) > 0) { nw_array_apply(targetPrivate->lastResolvedEndpoints, ^bool(size_t index, nw_object_t object) { +#pragma unused(index) nw_endpoint_t endpoint = (nw_endpoint_t)object; nw_endpoint_type_t endpoint_type = nw_endpoint_get_type(endpoint); if (endpoint_type == nw_endpoint_type_address) { @@ -513,6 +515,7 @@ SCNetworkReachabilityCreateWithAddress(CFAllocatorRef allocator, } +#if !TARGET_OS_IPHONE static Boolean is_ipv4_loopback(const struct sockaddr *sa) { @@ -528,6 +531,7 @@ is_ipv4_loopback(const struct sockaddr *sa) addr = ntohl(sin->sin_addr.s_addr); return IN_LOOPBACK(addr) ? TRUE : FALSE; } +#endif // !TARGET_OS_IPHONE static Boolean @@ -768,7 +772,7 @@ SCNetworkReachabilityCreateWithOptions(CFAllocatorRef allocator, } data = CFDictionaryGetValue(options, kSCNetworkReachabilityOptionLocalAddress); if (data != NULL) { - if (!isA_CFData(data) || (CFDataGetLength(data) < sizeof(struct sockaddr_in))) { + if (!isA_CFData(data) || ((size_t)CFDataGetLength(data) < sizeof(struct sockaddr_in))) { _SCErrorSet(kSCStatusInvalidArgument); return NULL; } @@ -776,7 +780,7 @@ SCNetworkReachabilityCreateWithOptions(CFAllocatorRef allocator, } data = CFDictionaryGetValue(options, kSCNetworkReachabilityOptionPTRAddress); if (data != NULL) { - if (!isA_CFData(data) || (CFDataGetLength(data) < sizeof(struct sockaddr_in))) { + if (!isA_CFData(data) || ((size_t)CFDataGetLength(data) < sizeof(struct sockaddr_in))) { _SCErrorSet(kSCStatusInvalidArgument); return NULL; } @@ -784,7 +788,7 @@ SCNetworkReachabilityCreateWithOptions(CFAllocatorRef allocator, } data = CFDictionaryGetValue(options, kSCNetworkReachabilityOptionRemoteAddress); if (data != NULL) { - if (!isA_CFData(data) || (CFDataGetLength(data) < sizeof(struct sockaddr_in))) { + if (!isA_CFData(data) || ((size_t)CFDataGetLength(data) < sizeof(struct sockaddr_in))) { _SCErrorSet(kSCStatusInvalidArgument); return NULL; } @@ -969,6 +973,7 @@ SCNetworkReachabilityCopyResolvedAddress(SCNetworkReachabilityRef target, if (nw_array_get_count(targetPrivate->lastResolvedEndpoints) > 0) { array = CFArrayCreateMutable(kCFAllocatorDefault, 0, &kCFTypeArrayCallBacks); nw_array_apply(targetPrivate->lastResolvedEndpoints, ^bool(size_t index, nw_object_t object) { +#pragma unused(index) nw_endpoint_type_t endpoint_type = nw_endpoint_get_type((nw_endpoint_t)object); if (endpoint_type == nw_endpoint_type_address) { const struct sockaddr *address = nw_endpoint_get_address((nw_endpoint_t)object); @@ -1104,7 +1109,8 @@ __SCNetworkReachabilityGetFlagsFromPath(nw_path_t path, xpc_object_t agent_dictionary = nw_path_copy_netagent_dictionary(path); if (agent_dictionary != NULL) { if (xpc_dictionary_get_count(agent_dictionary) > 0) { - xpc_dictionary_apply(agent_dictionary, ^bool(__unused const char *key, xpc_object_t value) { + xpc_dictionary_apply(agent_dictionary, ^bool(const char *key, xpc_object_t value) { +#pragma unused(key) Boolean vpn = FALSE; Boolean onDemand = FALSE; __SCNetworkReachabilityGetAgentVPNFlags(value, &vpn, &onDemand); @@ -1717,6 +1723,7 @@ __SCNetworkReachabilityRestartResolver(SCNetworkReachabilityPrivateRef targetPri targetPrivate->lastResolvedEndpointFlags = 0; targetPrivate->lastResolvedEndpointInterfaceIndex = 0; nw_array_apply(targetPrivate->lastResolvedEndpoints, ^bool(size_t index, nw_object_t object) { +#pragma unused(index) SCNetworkReachabilityFlags flags = 0; uint interfaceIndex = 0; ReachabilityRankType rank; @@ -1934,6 +1941,8 @@ _SC_checkResolverReachabilityByAddress(SCDynamicStoreRef *storeP, Boolean *haveDNS, struct sockaddr *sa) { +#pragma unused(storeP) +#pragma unused(sa) nw_path_evaluator_t evaluator = nw_path_create_default_evaluator(); nw_path_t path = nw_path_evaluator_copy_path(evaluator); if (nw_path_get_status(path) == nw_path_status_unsatisfied_network) { diff --git a/SystemConfiguration.fproj/SCNetworkReachabilityInternal.h b/SystemConfiguration.fproj/SCNetworkReachabilityInternal.h index 5e354f1..79c342c 100644 --- a/SystemConfiguration.fproj/SCNetworkReachabilityInternal.h +++ b/SystemConfiguration.fproj/SCNetworkReachabilityInternal.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003-2016 Apple Inc. All rights reserved. + * Copyright (c) 2003-2017 Apple Inc. All rights reserved. * * @APPLE_LICENSE_HEADER_START@ * @@ -126,79 +126,6 @@ CFStringRef _SCNetworkReachabilityCopyTargetDescription (SCNetworkReachabilityRef target); -static __inline__ CFStringRef -__SCNetworkReachabilityCopyFlags(SCNetworkReachabilityFlags flags, CFStringRef prefix, Boolean debug) -{ - CFMutableStringRef str = CFStringCreateMutable(NULL, 0); - - if (prefix != NULL) { - CFStringAppend(str, prefix); - } - - if (debug) { - CFStringAppendFormat(str, NULL, CFSTR("0x%08x ("), flags); - } - - if (flags == 0) { - CFStringAppend(str, CFSTR("Not Reachable")); - } - if (flags & kSCNetworkReachabilityFlagsReachable) { - flags &= ~kSCNetworkReachabilityFlagsReachable; - CFStringAppendFormat(str, NULL, CFSTR("Reachable%s"), - flags != 0 ? ", " : ""); - } - if (flags & kSCNetworkReachabilityFlagsTransientConnection) { - flags &= ~kSCNetworkReachabilityFlagsTransientConnection; - CFStringAppendFormat(str, NULL, CFSTR("Transient Connection%s"), - flags != 0 ? ", " : ""); - } - if (flags & kSCNetworkReachabilityFlagsConnectionRequired) { - flags &= ~kSCNetworkReachabilityFlagsConnectionRequired; - CFStringAppendFormat(str, NULL, CFSTR("Connection Required%s"), - flags != 0 ? ", " : ""); - } - if (flags & kSCNetworkReachabilityFlagsConnectionOnTraffic) { - flags &= ~kSCNetworkReachabilityFlagsConnectionOnTraffic; - CFStringAppendFormat(str, NULL, CFSTR("Automatic Connection On Traffic%s"), - flags != 0 ? ", " : ""); - } - if (flags & kSCNetworkReachabilityFlagsConnectionOnDemand) { - flags &= ~kSCNetworkReachabilityFlagsConnectionOnDemand; - CFStringAppendFormat(str, NULL, CFSTR("Automatic Connection On Demand%s"), - flags != 0 ? ", " : ""); - } - if (flags & kSCNetworkReachabilityFlagsInterventionRequired) { - flags &= ~kSCNetworkReachabilityFlagsInterventionRequired; - CFStringAppendFormat(str, NULL, CFSTR("Intervention Required%s"), - flags != 0 ? ", " : ""); - } - if (flags & kSCNetworkReachabilityFlagsIsLocalAddress) { - flags &= ~kSCNetworkReachabilityFlagsIsLocalAddress; - CFStringAppendFormat(str, NULL, CFSTR("Local Address%s"), - flags != 0 ? ", " : ""); - } - if (flags & kSCNetworkReachabilityFlagsIsDirect) { - flags &= ~kSCNetworkReachabilityFlagsIsDirect; - CFStringAppendFormat(str, NULL, CFSTR("Directly Reachable Address%s"), - flags != 0 ? ", " : ""); - } -#if TARGET_OS_IPHONE - if (flags & kSCNetworkReachabilityFlagsIsWWAN) { - flags &= ~kSCNetworkReachabilityFlagsIsWWAN; - CFStringAppendFormat(str, NULL, CFSTR("WWAN%s"), flags != 0 ? ", " : ""); - } -#endif // TARGET_OS_IPHONE - if (flags != 0) { - CFStringAppendFormat(str, NULL, CFSTR("0x%08x"), flags); - } - - if (debug) { - CFStringAppend(str, CFSTR(")")); - } - - return str; -} - static __inline__ ReachabilityRankType __SCNetworkReachabilityRank(SCNetworkReachabilityFlags flags) { diff --git a/SystemConfiguration.fproj/SCNetworkReachabilityLogging.h b/SystemConfiguration.fproj/SCNetworkReachabilityLogging.h new file mode 100644 index 0000000..8c82764 --- /dev/null +++ b/SystemConfiguration.fproj/SCNetworkReachabilityLogging.h @@ -0,0 +1,149 @@ +/* + * Copyright (c) 2017 Apple Inc. All rights reserved. + * + * @APPLE_LICENSE_HEADER_START@ + * + * This file contains Original Code and/or Modifications of Original Code + * as defined in and that are subject to the Apple Public Source License + * Version 2.0 (the 'License'). You may not use this file except in + * compliance with the License. Please obtain a copy of the License at + * http://www.opensource.apple.com/apsl/ and read it before using this + * file. + * + * The Original Code and all software distributed under the License are + * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, + * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. + * Please see the License for the specific language governing rights and + * limitations under the License. + * + * @APPLE_LICENSE_HEADER_END@ + */ + +#ifndef _SCNETWORKREACHABILITYLOGGING_H +#define _SCNETWORKREACHABILITYLOGGING_H + +#include +#include +#include +#include +#include + +__BEGIN_DECLS + +/* + * __SCNetworkReachability_flags_string() + * + * Returns a string representation of the SCNetworkReachability flags. + * debug==FALSE : " Reachable,Transient Connection,WWAN,..." + * debug==TRUE : " 0x01234567 (Reachable,Transient Connection,WWAN,...)" + */ +static __inline__ void +__SCNetworkReachability_flags_string(SCNetworkReachabilityFlags flags, Boolean debug, char *str, size_t len) +{ + size_t n; + size_t op; // open paren + SCNetworkReachabilityFlags remaining; + + assert((len >= sizeof("Not Reachable," )) && // check min buffer size + (len >= sizeof("0x01234567 (Not Reachable)")) && + (len >= sizeof("0x01234567 (0x01234567)" ))); + + if (!debug) { + n = 0; + str[n] = '\0'; + } else { + n = snprintf(str, len, "0x%08x (", flags); + len--; // leave room for the closing paren + } + op = n; + remaining = flags; + + if ((remaining == 0) && + (n < len) && ((len - n) > sizeof("Not Reachable,"))) { + n = strlcat(str, "Not Reachable,", len); + } + + if ((remaining & kSCNetworkReachabilityFlagsReachable) && + (n < len) && ((len - n) > sizeof("Reachable,"))) { + n = strlcat(str, "Reachable,", len); + remaining &= ~kSCNetworkReachabilityFlagsReachable; + } + + if ((remaining & kSCNetworkReachabilityFlagsTransientConnection) && + (n < len) && ((len - n) > sizeof("Transient Connection,"))) { + n = strlcat(str, "Transient Connection,", len); + remaining &= ~kSCNetworkReachabilityFlagsTransientConnection; + } + + if ((remaining & kSCNetworkReachabilityFlagsConnectionRequired) && + (n < len) && ((len - n) > sizeof("Connection Required,"))) { + n = strlcat(str, "Connection Required,", len); + remaining &= ~kSCNetworkReachabilityFlagsConnectionRequired; + } + + if ((remaining & kSCNetworkReachabilityFlagsConnectionOnTraffic) && + (n < len) && ((len - n) > sizeof("Automatic Connection On Traffic,"))) { + n = strlcat(str, "Automatic Connection On Traffic,", len); + remaining &= ~kSCNetworkReachabilityFlagsConnectionOnTraffic; + } + + if ((remaining & kSCNetworkReachabilityFlagsConnectionOnDemand) && + (n < len) && ((len - n) > sizeof("Automatic Connection On Demand,"))) { + n = strlcat(str, "Automatic Connection On Demand,", len); + remaining &= ~kSCNetworkReachabilityFlagsConnectionOnDemand; + } + + if ((remaining & kSCNetworkReachabilityFlagsInterventionRequired) && + (n < len) && ((len - n) > sizeof("Intervention Required,"))) { + n = strlcat(str, "Intervention Required,", len); + remaining &= ~kSCNetworkReachabilityFlagsInterventionRequired; + } + + if ((remaining & kSCNetworkReachabilityFlagsIsLocalAddress) && + (n < len) && ((len - n) > sizeof("Local Address,"))) { + n = strlcat(str, "Local Address,", len); + remaining &= ~kSCNetworkReachabilityFlagsIsLocalAddress; + } + + if ((remaining & kSCNetworkReachabilityFlagsIsDirect) && + (n < len) && ((len - n) > sizeof("Directly Reachable Address,"))) { + n = strlcat(str, "Directly Reachable Address,", len); + remaining &= ~kSCNetworkReachabilityFlagsIsDirect; + } + +#if TARGET_OS_IPHONE + if ((remaining & kSCNetworkReachabilityFlagsIsWWAN) && + (n < len) && ((len - n) > sizeof("WWAN,"))) { + n = strlcat(str, "WWAN,", len); + remaining &= ~kSCNetworkReachabilityFlagsIsWWAN; + } +#endif // TARGET_OS_IPHONE + + if (remaining != 0) { + if ((n >= len) || + ((len - n) <= sizeof("0x01234567,"))) { + // if we don't have enough space, truncate and start over + str[op] = '\0'; + n = op; + remaining = flags; + } + + n += snprintf(str + n, len - n, "0x%08x,", remaining); + } + + if (n-- > 0) { + if (!debug) { + str[n] = '\0'; // remove trailing "," + } else { + str[n] = ')'; // trailing "," --> ")" + } + } + + return; +} + +__END_DECLS + +#endif /* _SCNETWORKREACHABILITYLOGGING_H */ diff --git a/SystemConfiguration.fproj/SCNetworkService.c b/SystemConfiguration.fproj/SCNetworkService.c index 4034ee2..727c56c 100644 --- a/SystemConfiguration.fproj/SCNetworkService.c +++ b/SystemConfiguration.fproj/SCNetworkService.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2004-2016 Apple Inc. All rights reserved. + * Copyright (c) 2004-2017 Apple Inc. All rights reserved. * * @APPLE_LICENSE_HEADER_START@ * @@ -560,13 +560,12 @@ _copyInterfaceEntityTypes(CFDictionaryRef protocols) CFStringRef entities[] = { kSCPropNetInterfaceType, kSCPropNetInterfaceSubType, kSCPropNetInterfaceHardware }; - int i; // include the "Interface" entity itself CFSetAddValue(interface_entity_types, kSCEntNetInterface); // include the entities associated with the interface - for (i = 0; i < sizeof(entities)/sizeof(entities[0]); i++) { + for (size_t i = 0; i < sizeof(entities)/sizeof(entities[0]); i++) { CFStringRef entity; entity = CFDictionaryGetValue(interface, entities[i]); @@ -1091,7 +1090,7 @@ SCNetworkServiceGetName(SCNetworkServiceRef service) CFRelease(path); useSystemInterfaces = ((__SCPreferencesUsingDefaultPrefs(servicePrivate->prefs)) && - (__SCPreferencesGetLimitSCNetworkConfiguration(servicePrivate->prefs) == FALSE)); + !__SCPreferencesGetLimitSCNetworkConfiguration(servicePrivate->prefs)); if (isA_CFDictionary(entity)) { name = CFDictionaryGetValue(entity, kSCPropUserDefinedName); @@ -1256,11 +1255,10 @@ SCNetworkServiceRemove(SCNetworkServiceRef service) sets = SCNetworkSetCopyAll(servicePrivate->prefs); if (sets != NULL) { - CFIndex i; CFIndex n; n = CFArrayGetCount(sets); - for (i = 0; i < n; i++) { + for (CFIndex i = 0; i < n; i++) { SCNetworkSetRef set; set = CFArrayGetValueAtIndex(sets, i); @@ -1940,7 +1938,7 @@ replaceServiceID(const void *value, void *context) } // remove link between "set" and old "service" - SCPreferencesPathRemoveValue(setPrivate->prefs, path); + (void) SCPreferencesPathRemoveValue(setPrivate->prefs, path); CFRelease(path); // create the link between "set" and the "service" @@ -1951,7 +1949,7 @@ replaceServiceID(const void *value, void *context) link = SCPreferencesPathKeyCreateNetworkServiceEntity(NULL, // allocator service_context->newServiceID, // service NULL); // entity - SCPreferencesPathSetLink(setPrivate->prefs, path, link); + (void) SCPreferencesPathSetLink(setPrivate->prefs, path, link); done: diff --git a/SystemConfiguration.fproj/SCNetworkSet.c b/SystemConfiguration.fproj/SCNetworkSet.c index 60b30ab..0ace9a3 100644 --- a/SystemConfiguration.fproj/SCNetworkSet.c +++ b/SystemConfiguration.fproj/SCNetworkSet.c @@ -467,7 +467,12 @@ SCNetworkSetAddService(SCNetworkSetRef set, SCNetworkServiceRef service) ok = SCPreferencesPathSetLink(setPrivate->prefs, path, link); #ifdef PREVENT_DUPLICATE_SERVICE_NAMES if (ok) { + // We use the interface cache here to not reach into the + // IORegistry for every service we go through + _SCNetworkInterfaceCacheOpen(); ok = ensure_unique_service_name(service); + _SCNetworkInterfaceCacheClose(); + if (!ok) { // if we could not ensure a unique name, remove the (just added) // link between the "set" and the "service" @@ -1551,6 +1556,38 @@ skipInterface(SCNetworkInterfaceRef interface) } +CFComparisonResult +_SCNetworkSetCompare(const void *val1, const void *val2, void *context) +{ +#pragma unused(context) + CFStringRef id1; + CFStringRef id2; + CFStringRef name1; + CFStringRef name2; + SCNetworkSetRef s1 = (SCNetworkSetRef)val1; + SCNetworkSetRef s2 = (SCNetworkSetRef)val2; + + name1 = SCNetworkSetGetName(s1); + name2 = SCNetworkSetGetName(s2); + + if (name1 != NULL) { + if (name2 != NULL) { + return CFStringCompare(name1, name2, 0); + } else { + return kCFCompareLessThan; + } + } + + if (name2 != NULL) { + return kCFCompareGreaterThan; + } + + id1 = SCNetworkSetGetSetID(s1); + id2 = SCNetworkSetGetSetID(s2); + return CFStringCompare(id1, id2, 0); +} + + static Boolean __SCNetworkSetEstablishDefaultConfigurationForInterfaces(SCNetworkSetRef set, CFArrayRef interfaces, Boolean excludeHidden) { diff --git a/SystemConfiguration.fproj/SCNetworkSignature.c b/SystemConfiguration.fproj/SCNetworkSignature.c index 31e3df7..aa855e7 100644 --- a/SystemConfiguration.fproj/SCNetworkSignature.c +++ b/SystemConfiguration.fproj/SCNetworkSignature.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2006, 2008, 2009, 2011-2015 Apple Inc. All rights reserved. + * Copyright (c) 2006, 2008, 2009, 2011-2015, 2017 Apple Inc. All rights reserved. * * @APPLE_LICENSE_HEADER_START@ * @@ -89,9 +89,9 @@ create_ipv6_services_pattern(void) } static CFDictionaryRef -copy_services_for_address_family(CFAllocatorRef alloc, - int af) +copy_services_for_address_family(CFAllocatorRef alloc, int af) { +#pragma unused(alloc) CFDictionaryRef info; CFArrayRef patterns; CFStringRef pattern; @@ -134,6 +134,7 @@ CFStringRef SCNetworkSignatureCopyActiveIdentifierForAddress(CFAllocatorRef alloc, const struct sockaddr * addr) { +#pragma unused(alloc) CFStringRef ident = NULL; CFDictionaryRef info = NULL; CFStringRef global_state_v4_key = NULL; @@ -235,6 +236,7 @@ done: CFArrayRef /* of CFStringRef's */ SCNetworkSignatureCopyActiveIdentifiers(CFAllocatorRef alloc) { +#pragma unused(alloc) CFMutableArrayRef active = NULL; CFIndex count = 0; CFStringRef global_setup_v4_key = NULL; diff --git a/SystemConfiguration.fproj/SCNetworkSignature.h b/SystemConfiguration.fproj/SCNetworkSignature.h index 675ae3f..256ebda 100644 --- a/SystemConfiguration.fproj/SCNetworkSignature.h +++ b/SystemConfiguration.fproj/SCNetworkSignature.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2006, 2008, 2011, 2012 Apple Inc. All rights reserved. + * Copyright (c) 2006, 2008, 2011, 2012, 2017 Apple Inc. All rights reserved. * * @APPLE_LICENSE_HEADER_START@ * @@ -46,7 +46,7 @@ __BEGIN_DECLS @function SCNetworkSignatureCopyActiveIdentifiers @discussion Find all currently active networks and return a list of (string) identifiers, one for each network. - @param allocator The CFAllocator that should be used to allocate + @param alloc The CFAllocator that should be used to allocate memory for the local dynamic store object. This parameter may be NULL in which case the current default CFAllocator is used. If this reference is not @@ -62,7 +62,7 @@ SCNetworkSignatureCopyActiveIdentifiers(CFAllocatorRef alloc) __OSX_AVAILABLE_ @discussion Find the one active network associated with the specified address and return the unique (string) identifier that represents it. - @param allocator The CFAllocator that should be used to allocate + @param alloc The CFAllocator that should be used to allocate memory for the local dynamic store object. This parameter may be NULL in which case the current default CFAllocator is used. If this reference is not @@ -81,7 +81,7 @@ SCNetworkSignatureCopyActiveIdentifierForAddress(CFAllocatorRef alloc, @function SCNetworkSignatureCopyIdentifierForConnectedSocket @discussion Find the identifier for the given file descriptor corresponding to a connected socket. - @param allocator The CFAllocator that should be used to allocate + @param alloc The CFAllocator that should be used to allocate memory for the local dynamic store object. This parameter may be NULL in which case the current default CFAllocator is used. If this reference is not diff --git a/SystemConfiguration.fproj/SCP.c b/SystemConfiguration.fproj/SCP.c index 9c0d541..2873294 100644 --- a/SystemConfiguration.fproj/SCP.c +++ b/SystemConfiguration.fproj/SCP.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2000, 2001, 2003-2005, 2007-2009, 2011, 2014-2016 Apple Inc. All rights reserved. + * Copyright (c) 2000, 2001, 2003-2005, 2007-2009, 2011, 2014-2017 Apple Inc. All rights reserved. * * @APPLE_LICENSE_HEADER_START@ * @@ -171,7 +171,8 @@ __SCPreferencesCreateNIPrefsFromPrefs(SCPreferencesRef prefs) newPath = CFStringCreateMutable(NULL, 0); CFStringAppendFormat(newPath, NULL, CFSTR("%s"), prefsPath); - CFStringFindAndReplace(newPath, PREFS_DEFAULT_CONFIG, + CFStringFindAndReplace(newPath, + PREFS_DEFAULT_CONFIG, NETWORK_INTERFACES_PREFS, CFRangeMake(0, CFStringGetLength(newPath)), kCFCompareBackwards); @@ -179,8 +180,7 @@ __SCPreferencesCreateNIPrefsFromPrefs(SCPreferencesRef prefs) newURL = CFURLCreateWithFileSystemPath(NULL, newPath, kCFURLPOSIXPathStyle, FALSE); if (!CFURLResourceIsReachable(newURL, NULL)) { ni_prefs = __SCNetworkCreateDefaultNIPrefs(newPath); - } - else { + } else { ni_prefs = SCPreferencesCreate(NULL, prefsPrivate->name, newPath); } CFAllocatorDeallocate(NULL, prefsPath); diff --git a/SystemConfiguration.fproj/SCPCommit.c b/SystemConfiguration.fproj/SCPCommit.c index 3d17b53..717c345 100644 --- a/SystemConfiguration.fproj/SCPCommit.c +++ b/SystemConfiguration.fproj/SCPCommit.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2000-2008, 2010-2013, 2015, 2016 Apple Inc. All rights reserved. + * Copyright (c) 2000-2008, 2010-2013, 2015-2017 Apple Inc. All rights reserved. * * @APPLE_LICENSE_HEADER_START@ * @@ -197,6 +197,9 @@ SCPreferencesCommitChanges(SCPreferencesRef prefs) int fd; CFDataRef newPrefs; CFIndex pathLen; +#if TARGET_OS_EMBEDDED + CFStringRef protectionClass; +#endif // TARGET_OS_EMBEDDED char * thePath; if (stat(prefsPrivate->path, &statBuf) == -1) { @@ -217,7 +220,29 @@ SCPreferencesCommitChanges(SCPreferencesRef prefs) thePath = CFAllocatorAllocate(NULL, pathLen, 0); snprintf(thePath, pathLen, "%s-new", path); +#if TARGET_OS_EMBEDDED + if ((prefsPrivate->options != NULL) && + CFDictionaryGetValueIfPresent(prefsPrivate->options, + kSCPreferencesOptionProtectionClass, + (const void **)&protectionClass)) { + int pc; + const char *str; + + if (!isA_CFString(protectionClass) || + (CFStringGetLength(protectionClass) != 1) || + ((str = CFStringGetCStringPtr(protectionClass, kCFStringEncodingASCII)) == NULL) || + (str[0] < 'A') || (str[0] > 'F') + ) { + _SCErrorSet(kSCStatusInvalidArgument); + goto done; + } + + pc = str[0] - 'A' + 1; // PROTECTION_CLASS_[ABCDEF] + fd = open_dprotected_np(thePath, O_WRONLY|O_CREAT, pc, 0, statBuf.st_mode); + } else +#endif // TARGET_OS_EMBEDDED fd = open(thePath, O_WRONLY|O_CREAT, statBuf.st_mode); + if (fd == -1) { _SCErrorSet(errno); SC_log(LOG_INFO, "open() failed: %s", strerror(errno)); diff --git a/SystemConfiguration.fproj/SCPLock.c b/SystemConfiguration.fproj/SCPLock.c index 21f20bb..4ec7564 100644 --- a/SystemConfiguration.fproj/SCPLock.c +++ b/SystemConfiguration.fproj/SCPLock.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2000-2010, 2013, 2015, 2016 Apple Inc. All rights reserved. + * Copyright (c) 2000-2010, 2013, 2015-2017 Apple Inc. All rights reserved. * * @APPLE_LICENSE_HEADER_START@ * @@ -131,7 +131,7 @@ createParentDirectory(const char *path) static gid_t group = -1; // set group - if (group == -1) { + if (group == (gid_t)-1) { char buf[256]; struct group grp; struct group *grpP = NULL; diff --git a/SystemConfiguration.fproj/SCPOpen.c b/SystemConfiguration.fproj/SCPOpen.c index ec6f0ff..91c9447 100644 --- a/SystemConfiguration.fproj/SCPOpen.c +++ b/SystemConfiguration.fproj/SCPOpen.c @@ -1,5 +1,5 @@ /* - * Copyright(c) 2000-2016 Apple Inc. All rights reserved. + * Copyright(c) 2000-2017 Apple Inc. All rights reserved. * * @APPLE_LICENSE_HEADER_START@ * @@ -108,6 +108,8 @@ __SCPreferencesDeallocate(CFTypeRef cf) { SCPreferencesPrivateRef prefsPrivate = (SCPreferencesPrivateRef)cf; + SC_log(LOG_DEBUG, "release %@", prefsPrivate); + /* release resources */ pthread_mutex_destroy(&prefsPrivate->lock); @@ -606,6 +608,10 @@ SCPreferencesCreate(CFAllocatorRef allocator, SCPreferencesPrivateRef prefsPrivate; prefsPrivate = __SCPreferencesCreate(allocator, name, prefsID, NULL, NULL); + if (prefsPrivate != NULL) { + SC_log(LOG_DEBUG, "create %@", prefsPrivate); + } + return (SCPreferencesRef)prefsPrivate; } @@ -720,6 +726,29 @@ SCPreferencesCreateWithOptions(CFAllocatorRef allocator, } prefsPrivate = __SCPreferencesCreate(allocator, name, prefsID, authorizationData, options); + if (prefsPrivate != NULL) { + const char *astr = ""; + const char *ostr = ""; + + if (options != NULL) { + ostr = "options"; + } + + if (authorization != NULL) { + if (authorization == kSCPreferencesUseEntitlementAuthorization) { + astr = "entitlement"; + } else { + astr = "authorization"; + } + } + + SC_log(LOG_DEBUG, "create w/%s%s%s %@", + ostr, + ((ostr != "") && (astr != "")) ? " + " : "", + astr, + prefsPrivate); + } + if (authorizationData != NULL) CFRelease(authorizationData); return (SCPreferencesRef)prefsPrivate; @@ -736,6 +765,7 @@ SCPreferencesGetTypeID(void) { static void prefsNotify(SCDynamicStoreRef store, CFArrayRef changedKeys, void *info) { +#pragma unused(store) void *context_info; void (*context_release)(const void *); CFIndex i; @@ -782,7 +812,8 @@ prefsNotify(SCDynamicStoreRef store, CFArrayRef changedKeys, void *info) if (rlsFunction != NULL) { SC_log(LOG_DEBUG, "exec SCPreferences callout: %s%s%s", ((notify & kSCPreferencesNotificationCommit) != 0) ? "commit" : "", - ((notify & kSCPreferencesNotificationCommit|kSCPreferencesNotificationApply) != 0) ? ", " : "", + (((notify & kSCPreferencesNotificationCommit) != 0) && + ((notify & kSCPreferencesNotificationApply ) != 0)) ? ", " : "", ((notify & kSCPreferencesNotificationApply) != 0) ? "apply" : ""); (*rlsFunction)(prefs, notify, context_info); } @@ -840,6 +871,8 @@ __SCPreferencesAddSession(SCPreferencesRef prefs) SC_log(LOG_INFO, "SCDynamicStoreCreate() failed"); return FALSE; } + + SC_log(LOG_DEBUG, "added SCDynamicStore session (for prefs)"); } prefsPrivate->sessionRefcnt++; @@ -856,6 +889,8 @@ __SCPreferencesRemoveSession(SCPreferencesRef prefs) if (--prefsPrivate->sessionRefcnt == 0) { CFRelease(prefsPrivate->session); prefsPrivate->session = NULL; + + SC_log(LOG_DEBUG, "removed SCDynamicStore session (for prefs)"); } } @@ -944,6 +979,8 @@ __SCPreferencesScheduleWithRunLoop(SCPreferencesRef prefs, prefsPrivate->rlList = CFArrayCreateMutable(NULL, 0, &kCFTypeArrayCallBacks); } + SC_log(LOG_DEBUG, "scheduled"); + prefsPrivate->scheduled = TRUE; } @@ -1034,6 +1071,8 @@ __SCPreferencesUnscheduleFromRunLoop(SCPreferencesRef prefs, if (n == 0) { CFArrayRef changedKeys; + SC_log(LOG_DEBUG, "unscheduled"); + // if *all* notifications have been unscheduled prefsPrivate->scheduled = FALSE; diff --git a/SystemConfiguration.fproj/SCPreferencesKeychainPrivate.c b/SystemConfiguration.fproj/SCPreferencesKeychainPrivate.c index 5970514..83cc678 100644 --- a/SystemConfiguration.fproj/SCPreferencesKeychainPrivate.c +++ b/SystemConfiguration.fproj/SCPreferencesKeychainPrivate.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2006, 2007, 2010, 2014, 2016 Apple Inc. All rights reserved. + * Copyright (c) 2006, 2007, 2010, 2014, 2016, 2017 Apple Inc. All rights reserved. * * @APPLE_LICENSE_HEADER_START@ * @@ -325,6 +325,8 @@ _SCSecKeychainPasswordItemCopy(SecKeychainRef keychain, return keychain_password; #else // !TARGET_OS_IPHONE +#pragma unused(keychain) +#pragma unused(unique_id) _SCErrorSet(kSCStatusAccessError); return NULL; #endif // !TARGET_OS_IPHONE @@ -347,6 +349,8 @@ _SCSecKeychainPasswordItemExists(SecKeychainRef keychain, CFStringRef unique_id) CFRelease(item); return TRUE; #else // !TARGET_OS_IPHONE +#pragma unused(keychain) +#pragma unused(unique_id) _SCErrorSet(kSCStatusAccessError); return FALSE; #endif // !TARGET_OS_IPHONE @@ -375,6 +379,8 @@ _SCSecKeychainPasswordItemRemove(SecKeychainRef keychain, CFStringRef unique_id) return TRUE; #else // !TARGET_OS_IPHONE +#pragma unused(keychain) +#pragma unused(unique_id) _SCErrorSet(kSCStatusAccessError); return FALSE; #endif // !TARGET_OS_IPHONE @@ -545,6 +551,13 @@ _SCSecKeychainPasswordItemSet(SecKeychainRef keychain, return TRUE; #else // !TARGET_OS_IPHONE +#pragma unused(keychain) +#pragma unused(unique_id) +#pragma unused(label) +#pragma unused(description) +#pragma unused(account) +#pragma unused(password) +#pragma unused(options) _SCErrorSet(kSCStatusAccessError); return FALSE; #endif // !TARGET_OS_IPHONE @@ -658,6 +671,8 @@ _SCPreferencesSystemKeychainPasswordItemCopy(SCPreferencesRef prefs, if (keychain != NULL) CFRelease(keychain); return password; #else // !TARGET_OS_IPHONE +#pragma unused(prefs) +#pragma unused(unique_id) _SCErrorSet(kSCStatusAccessError); return NULL; #endif // !TARGET_OS_IPHONE @@ -701,6 +716,8 @@ _SCPreferencesSystemKeychainPasswordItemExists(SCPreferencesRef prefs, if (keychain != NULL) CFRelease(keychain); return ok; #else // !TARGET_OS_IPHONE +#pragma unused(prefs) +#pragma unused(unique_id) _SCErrorSet(kSCStatusAccessError); return FALSE; #endif // !TARGET_OS_IPHONE @@ -803,6 +820,8 @@ _SCPreferencesSystemKeychainPasswordItemRemove(SCPreferencesRef prefs, if (keychain != NULL) CFRelease(keychain); return ok; #else // !TARGET_OS_IPHONE +#pragma unused(prefs) +#pragma unused(unique_id) _SCErrorSet(kSCStatusAccessError); return FALSE; #endif // !TARGET_OS_IPHONE @@ -1006,6 +1025,13 @@ _SCPreferencesSystemKeychainPasswordItemSet(SCPreferencesRef prefs, if (keychain != NULL) CFRelease(keychain); return ok; #else // !TARGET_OS_IPHONE +#pragma unused(prefs) +#pragma unused(unique_id) +#pragma unused(label) +#pragma unused(description) +#pragma unused(account) +#pragma unused(password) +#pragma unused(options) _SCErrorSet(kSCStatusAccessError); return FALSE; #endif // !TARGET_OS_IPHONE diff --git a/SystemConfiguration.fproj/SCPreferencesPrivate.h b/SystemConfiguration.fproj/SCPreferencesPrivate.h index 303ffdd..0767e50 100644 --- a/SystemConfiguration.fproj/SCPreferencesPrivate.h +++ b/SystemConfiguration.fproj/SCPreferencesPrivate.h @@ -1,15 +1,15 @@ /* - * Copyright (c) 2000-2005, 2007-2009, 2011, 2012 Apple Inc. All rights reserved. + * Copyright (c) 2000-2005, 2007-2009, 2011, 2012, 2017 Apple Inc. All rights reserved. * * @APPLE_LICENSE_HEADER_START@ - * + * * This file contains Original Code and/or Modifications of Original Code * as defined in and that are subject to the Apple Public Source License * Version 2.0 (the 'License'). You may not use this file except in * compliance with the License. Please obtain a copy of the License at * http://www.opensource.apple.com/apsl/ and read it before using this * file. - * + * * The Original Code and all software distributed under the License are * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, @@ -17,7 +17,7 @@ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. * Please see the License for the specific language governing rights and * limitations under the License. - * + * * @APPLE_LICENSE_HEADER_END@ */ @@ -26,6 +26,7 @@ #include +#include #include #include #include @@ -42,6 +43,15 @@ */ #define kSCPreferencesOptionChangeNetworkSet CFSTR("change-network-set") // CFBooleanRef +#if TARGET_OS_EMBEDDED +/*! + @defined kSCPreferencesOptionProtectionClass + @abstract The SCPreferences "option" used to indicate the file + protection class of the .plist. + */ +#define kSCPreferencesOptionProtectionClass CFSTR("ProtectionClass") // CFStringRef["A"-"F"] +#endif // TARGET_OS_EMBEDDED + /*! @defined kSCPreferencesOptionRemoveWhenEmpty @abstract The SCPreferences "option" used to indicate that the .plist diff --git a/SystemConfiguration.fproj/SCPrivate.h b/SystemConfiguration.fproj/SCPrivate.h index 53f2234..aa34c5d 100644 --- a/SystemConfiguration.fproj/SCPrivate.h +++ b/SystemConfiguration.fproj/SCPrivate.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2000-2016 Apple Inc. All rights reserved. + * Copyright (c) 2000-2017 Apple Inc. All rights reserved. * * @APPLE_LICENSE_HEADER_START@ * @@ -27,7 +27,6 @@ #include #include #include -#include #include #include #include @@ -94,11 +93,19 @@ #endif +/* crash report(s) directory path */ +#if !TARGET_OS_EMBEDDED +#define _SC_CRASH_DIR "/Library/Logs/DiagnosticReports" +#else +#define _SC_CRASH_DIR "/Library/Logs/CrashReporter" +#endif + + /* framework variables */ extern int _sc_debug; /* non-zero if debugging enabled */ extern int _sc_verbose; /* non-zero if verbose logging enabled */ extern int _sc_log; /* 0 if SC messages should be written to stdout/stderr, - 1 if SC messages should be logged w/asl(3), + 1 if SC messages should be logged w/os_log(3), 2 if SC messages should be written to stdout/stderr AND logged */ @@ -415,17 +422,17 @@ void _SC_sendMachMessage (mach_port_t port, /*! @function _SC_LOG_DEFAULT - @discussion Maps a syslog/asl logging level to an os_log level. - @param level The syslog/asl logging level - @result The os_log level + @discussion A function returning a default os_log_t object to be + used for [SystemConfiguration] logging. + @result The os_log_t object */ os_log_t _SC_LOG_DEFAULT (); /*! @function _SC_syslog_os_log_mapping - @discussion Maps a syslog/asl logging level to an os_log level. - @param level The syslog/asl logging level + @discussion Maps a syslog logging level to an os_log level. + @param level The syslog logging level @result The os_log level */ os_log_type_t _SC_syslog_os_log_mapping (int level); @@ -449,8 +456,6 @@ CFStringRef _SCCopyDescription (CFTypeRef cf, @param condition A boolean value indicating if the message should be logged @param level A syslog(3) logging priority. @param formatString The format string - @result The specified message will be written to the system message - logger (See syslogd(8)). */ void SCLog (Boolean condition, int level, @@ -458,75 +463,6 @@ void SCLog (Boolean condition, ...) CF_FORMAT_FUNCTION(3, 4); -typedef CF_ENUM(uint32_t, SCLoggerFlags) { - kSCLoggerFlagsNone = 0x0, - kSCLoggerFlagsDefault = 0x1, - kSCLoggerFlagsFile = 0x2 -}; - -typedef struct SCLogger * SCLoggerRef; - - -/*! - @function SCLoggerLog - @discussion Logs messages using SCLoggerRef - @param logger A SCLoggerRef which keeps information about how logging - needs to be done. Passing NULL uses the default logger instance. - @param level An asl(3) logging priority. Passing the complement of a logging - priority (e.g. ~ASL_LEVEL_NOTICE) will result in log message lines - NOT being split by a "\n". - @param formatString The format string followed by format arguments - @result The specified message will be written to the system message - logger (See syslogd(8)). If logger is in verbose mode, the message - will be also written to a file specified in the ASL Module - */ -void SCLoggerLog (SCLoggerRef logger, - int level, - CFStringRef formatString, - ...) CF_FORMAT_FUNCTION(3, 4) - __OSX_AVAILABLE_STARTING(__MAC_10_8,__IPHONE_6_0); - -/*! - @function SCLoggerVLog - @discussion Logs messages using SCLoggerRef - @param logger A SCLoggerRef which keeps information about how logging - needs to be done. Passing NULL uses the default logger instance. - @param level An asl(3) logging priority. Passing the complement of a logging - priority (e.g. ~ASL_LEVEL_NOTICE) will result in log message lines - NOT being split by a "\n". - @param formatString The format string - @param args The va_list representing the arguments - @result The specified message will be written to the system message - logger (See syslogd(8)). If logger is in verbose mode, the message - will be also written to a file specified in the ASL Module - */ -void SCLoggerVLog (SCLoggerRef logger, - int level, - CFStringRef formatString, - va_list args) __OSX_AVAILABLE_STARTING(__MAC_10_9,__IPHONE_7_0); - - -/*! - @function SCLOG - @discussion Issue a log message. - @param asl An asl client handle to be used for logging. If NULL, a shared - handle will be used. - @param msg An asl msg structure to be used for logging. If NULL, a default - asl msg will be used. - @param level A asl(3) logging priority. Passing the complement of a logging - priority (e.g. ~ASL_LEVEL_NOTICE) will result in log message lines - NOT being split by a "\n". - @param formatString The format string - @result The specified message will be written to the system message - logger (See syslogd(8)). - */ -void SCLOG (asl_object_t asl, - asl_object_t msg, - int level, - CFStringRef formatString, - ...) CF_FORMAT_FUNCTION(4, 5); - - /*! @function SC_log @discussion Issue an os_log() message. @@ -546,24 +482,26 @@ void SCLOG (asl_object_t asl, @result The specified message will be written to the unified logging system. */ #ifndef SC_log - -#ifndef SC_LOG_HANDLE -#define SC_LOG_HANDLE _SC_LOG_DEFAULT() // use [SC] default os_log handle - -#ifndef SC_LOG_OR_PRINT -#define USE_SC_LOG_OR_PRINT // use '_sc_log' to control os_log, printf -#endif // !SC_LOG_OR_PRINT - -#endif // !SC_LOG_HANDLE - -#ifdef USE_SC_LOG_OR_PRINT - -#define SC_log(__level, __format, ...) \ + #ifdef SC_LOG_HANDLE + #ifndef SC_LOG_HANDLE_TYPE + #define SC_LOG_HANDLE_TYPE + #endif // SC_LOG_HANDLE_TYPE + SC_LOG_HANDLE_TYPE os_log_t SC_LOG_HANDLE; + #else // SC_LOG_HANDLE + #define SC_LOG_HANDLE _SC_LOG_DEFAULT() // use [SC] default os_log handle + #ifndef SC_LOG_OR_PRINT + #define USE_SC_LOG_OR_PRINT 1 // and use '_sc_log' to control os_log, printf + #endif // !SC_LOG_OR_PRINT + #endif // !SC_LOG_HANDLE + + #if USE_SC_LOG_OR_PRINT + #define SC_log(__level, __format, ...) \ do { \ os_log_t __handle = SC_LOG_HANDLE; \ os_log_type_t __type = _SC_syslog_os_log_mapping(__level); \ \ - if ((_sc_log != 1) || os_log_type_enabled(__handle, __type)) { \ + if (((_sc_log != 1) && ((__level > LOG_DEBUG) || _sc_debug)) || \ + os_log_type_enabled(__handle, __type)) { \ __SC_Log(__level, \ CFSTR( __format ), \ __handle, \ @@ -572,30 +510,26 @@ void SCLOG (asl_object_t asl, ## __VA_ARGS__); \ } \ } while (0) - -#else // USE_SC_LOG_OR_PRINT - -#define SC_log(__level, __format, ...) \ + #else // USE_SC_LOG_OR_PRINT + #define SC_log(__level, __format, ...) \ do { \ os_log_type_t __type = _SC_syslog_os_log_mapping(__level); \ os_log_with_type(SC_LOG_HANDLE, __type, __format, ## __VA_ARGS__); \ } while (0) - -#endif // USE_SC_LOG_OR_PRINT - + #endif // USE_SC_LOG_OR_PRINT #endif // !SC_log /*! @function __SC_Log @discussion Issue a log message w/os_log(3) or printf(3). + The specified message will be written to the system message + logger. @param level A syslog(3) logging priority. If less than 0, log message is multi-line @param format_CF The format string (as a CFString for stdout/stderr) @param log The os_log_t handle (for logging) @param type The os_log_type_t type (for logging) @param format The format string (for logging) - @result The specified message will be written to the system message - logger. stream. */ void __SC_Log (int level, @@ -609,11 +543,10 @@ void __SC_Log (int level, /*! @function SCPrint @discussion Conditionally issue a debug message. + The message will be written to the specified output stream. @param condition A boolean value indicating if the message should be written @param stream The output stream for the log message. @param formatString The format string - @result The message will be written to the specified stream - stream. */ void SCPrint (Boolean condition, FILE *stream, @@ -621,43 +554,14 @@ void SCPrint (Boolean condition, ...) CF_FORMAT_FUNCTION(3, 4); - -/*! - @function SCLoggerCreate - @discussion Create a reference to logger which stores information like verbose mode or not, loggerID, etc. - loggerID and moduleName both need to be non NULL, or else the function returns NULL. - If the moduleName points to a module which doesn't exist, then SCLoggerCreate will fail and - return NULL; - @param loggerID CFStringRef which will be appended to the log message when in verbose mode. It will also be - used to identify the module where the rules are being defined. - */ -SCLoggerRef -SCLoggerCreate (CFStringRef loggerID); - -/*! - @function SCLoggerGetFlags - @discussion Returns the log flags for the logging reference - @param logger Reference which points to the logger information - */ -SCLoggerFlags -SCLoggerGetFlags (SCLoggerRef logger); - -/*! - @function SCLoggerSetFlags - @discussion Sets the log flags for the logger reference - @param logger A reference to the logger - @param flags SCLoggerFlags value determining where the logs from the logger will be directed - */ -void SCLoggerSetFlags (SCLoggerRef logger, - SCLoggerFlags flags); - #pragma mark - #pragma mark Proxies /*! @function SCNetworkProxiesCopyMatching - @discussion + @discussion Return the proxy configurations matching a target host + and/or one associated with a specific network interface. @param globalConfiguration the proxy dictionary currently returned by SCDynamicStoreCopyProxies(). @param server A CFString specying the hostname of interest; NULL if @@ -682,7 +586,8 @@ SCNetworkProxiesCopyMatching (CFDictionaryRef globalConfiguration, /*! @function SCNetworkProxiesCopyMatchingWithOptions - @discussion + @discussion Return the proxy configurations matching a target host + and/or one associated with a specific network interface. @param globalConfiguration the proxy dictionary currently returned by SCDynamicStoreCopyProxies(). @param options A dictionary containing any (or none) of the following: @@ -711,21 +616,21 @@ SCNetworkProxiesCopyMatchingWithOptions (CFDictionaryRef globalConfiguration, extern const CFStringRef kSCProxiesNoGlobal; /*! - @function SCNetworkProxiesCreateProxyAgentData - @discussion - + @function SCNetworkProxiesCreateProxyAgentData + @discussion Returns a serialized representation of a proxy configuration. @param proxyConfig A dictionary representing a proxy configuration - @result returns a CFData representing a proxy configuration. This data is readable by all - "config-agents" (Agents with domain as "SystemConfig") via config_agent_copy_proxy_information(). - You must release the returned value. + @result returns a CFData representing a proxy configuration. This data is + readable by all "config-agents" (Agents with domain as "SystemConfig") + via config_agent_copy_proxy_information(). + You must release the returned value. */ CFDataRef SCNetworkProxiesCreateProxyAgentData(CFDictionaryRef proxyConfig) __OSX_AVAILABLE_STARTING(__MAC_10_12,__IPHONE_10_0/*SPI*/); /*! - @function SCDynamicStoreCopyProxiesWithOptions - @discussion - + @function SCDynamicStoreCopyProxiesWithOptions + @discussion Return the proxy configurations matching the provided + criteria. @param store An SCDynamicStoreRef representing the dynamic store session that should be used for communication with the server. If NULL, a temporary session will be used. diff --git a/SystemConfiguration.fproj/SCSchemaDefinitions.c b/SystemConfiguration.fproj/SCSchemaDefinitions.c index ac7e2be..683f4e5 100644 --- a/SystemConfiguration.fproj/SCSchemaDefinitions.c +++ b/SystemConfiguration.fproj/SCSchemaDefinitions.c @@ -70,9 +70,11 @@ const CFStringRef kSCEntNetAppLayer = CFSTR("AppL const CFStringRef kSCEntNetEAPOL = CFSTR("EAPOL"); const CFStringRef kSCEntNetIPv4RouterARPFailure = CFSTR("IPv4RouterARPFailure"); const CFStringRef kSCEntNetIPv4RouterARPAlive = CFSTR("IPv4RouterARPAlive"); +const CFStringRef kSCEntNetIPv6RouterExpired = CFSTR("IPv6RouterExpired"); const CFStringRef kSCEntNetLinkIssues = CFSTR("LinkIssues"); const CFStringRef kSCEntNetLinkQuality = CFSTR("LinkQuality"); const CFStringRef kSCEntNetLoopback = CFSTR("Loopback"); +const CFStringRef kSCEntNetNAT64PrefixRequest = CFSTR("NAT64PrefixRequest"); const CFStringRef kSCEntNetOnDemand = CFSTR("OnDemand"); const CFStringRef kSCEntNetQoSMarkingPolicy = CFSTR("QoSMarkingPolicy"); const CFStringRef kSCEntNetService = CFSTR("__SERVICE__"); diff --git a/SystemConfiguration.fproj/SCSchemaDefinitions.h b/SystemConfiguration.fproj/SCSchemaDefinitions.h index d6714c4..ea059e1 100644 --- a/SystemConfiguration.fproj/SCSchemaDefinitions.h +++ b/SystemConfiguration.fproj/SCSchemaDefinitions.h @@ -124,7 +124,6 @@ * kSCPropNetInterfaceHardware "Hardware" CFString * kSCPropNetInterfaceType "Type" CFString * kSCPropNetInterfaceSubType "SubType" CFString - * kSCPropNetInterfaceSupportsModemOnHold "SupportsModemOnHold" CFNumber (0 or 1) * * --- kSCPropNetInterfaceType values --- * kSCValNetInterfaceTypeEthernet "Ethernet" @@ -967,7 +966,7 @@ extern const CFStringRef kSCPropNetInterfaceSubType __OS @const kSCPropNetInterfaceSupportsModemOnHold @discussion Value is a CFNumber (0 or 1) */ -extern const CFStringRef kSCPropNetInterfaceSupportsModemOnHold __OSX_AVAILABLE_STARTING(__MAC_10_2,__IPHONE_2_0/*SPI*/); +extern const CFStringRef kSCPropNetInterfaceSupportsModemOnHold __OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_2,__MAC_10_13,__IPHONE_2_0/*SPI*/,__IPHONE_FUTURE/*SPI*/); #define kSCPropNetInterfaceSupportsModemOnHold kSCPropNetInterfaceSupportsModemOnHold /*! diff --git a/SystemConfiguration.fproj/SCSchemaDefinitionsPrivate.h b/SystemConfiguration.fproj/SCSchemaDefinitionsPrivate.h index 1efd836..6f31a42 100644 --- a/SystemConfiguration.fproj/SCSchemaDefinitionsPrivate.h +++ b/SystemConfiguration.fproj/SCSchemaDefinitionsPrivate.h @@ -46,9 +46,11 @@ * kSCEntNetEAPOL "EAPOL" CFDictionary * kSCEntNetIPv4RouterARPFailure "IPv4RouterARPFailure" * kSCEntNetIPv4RouterARPAlive "IPv4RouterARPAlive" + * kSCEntNetIPv6RouterExpired "IPv6RouterExpired" * kSCEntNetLinkIssues "LinkIssues" CFDictionary * kSCEntNetLinkQuality "LinkQuality" CFDictionary * kSCEntNetLoopback "Loopback" CFDictionary + * kSCEntNetNAT64PrefixRequest "NAT64PrefixRequest" * kSCEntNetOnDemand "OnDemand" CFDictionary * kSCEntNetQoSMarkingPolicy "QoSMarkingPolicy" CFDictionary * kSCEntNetService "__SERVICE__" CFDictionary @@ -396,6 +398,12 @@ extern const CFStringRef kSCEntNetIPv4RouterARPFailure __OS extern const CFStringRef kSCEntNetIPv4RouterARPAlive __OSX_AVAILABLE_STARTING(__MAC_10_10,__IPHONE_8_0/*SPI*/); #define kSCEntNetIPv4RouterARPAlive kSCEntNetIPv4RouterARPAlive +/*! + @const kSCEntNetIPv6RouterExpired + */ +extern const CFStringRef kSCEntNetIPv6RouterExpired __OSX_AVAILABLE_STARTING(__MAC_10_13,__IPHONE_11_0/*SPI*/); +#define kSCEntNetIPv6RouterExpired kSCEntNetIPv6RouterExpired + /*! @const kSCEntNetLinkIssues @discussion Value is a CFDictionary @@ -417,6 +425,12 @@ extern const CFStringRef kSCEntNetLinkQuality __OS extern const CFStringRef kSCEntNetLoopback __OSX_AVAILABLE_STARTING(__MAC_10_7,__IPHONE_4_0/*SPI*/); #define kSCEntNetLoopback kSCEntNetLoopback +/*! + @const kSCEntNetNAT64PrefixRequest + */ +extern const CFStringRef kSCEntNetNAT64PrefixRequest __OSX_AVAILABLE_STARTING(__MAC_10_13,__IPHONE_11_0/*SPI*/); +#define kSCEntNetNAT64PrefixRequest kSCEntNetNAT64PrefixRequest + /*! @const kSCEntNetOnDemand @discussion Value is a CFDictionary @@ -428,7 +442,7 @@ extern const CFStringRef kSCEntNetOnDemand __OS @const kSCEntNetQoSMarkingPolicy @discussion Value is a CFDictionary */ -extern const CFStringRef kSCEntNetQoSMarkingPolicy __OSX_AVAILABLE_STARTING(__MAC_10_12,__IPHONE_10_0/*SPI*/); +extern const CFStringRef kSCEntNetQoSMarkingPolicy __OSX_AVAILABLE_STARTING(__MAC_10_13,__IPHONE_10_0/*SPI*/); #define kSCEntNetQoSMarkingPolicy kSCEntNetQoSMarkingPolicy /*! @@ -1002,21 +1016,21 @@ extern const CFStringRef kSCPropNetProxiesSupplementalMatchDomain __OS @const kSCPropNetQoSMarkingAppleAudioVideoCalls @discussion Value is a CFBoolean */ -extern const CFStringRef kSCPropNetQoSMarkingAppleAudioVideoCalls __OSX_AVAILABLE_STARTING(__MAC_10_12,__IPHONE_10_0/*SPI*/); +extern const CFStringRef kSCPropNetQoSMarkingAppleAudioVideoCalls __OSX_AVAILABLE_STARTING(__MAC_10_13,__IPHONE_10_0/*SPI*/); #define kSCPropNetQoSMarkingAppleAudioVideoCalls kSCPropNetQoSMarkingAppleAudioVideoCalls /*! @const kSCPropNetQoSMarkingEnabled @discussion Value is a CFBoolean */ -extern const CFStringRef kSCPropNetQoSMarkingEnabled __OSX_AVAILABLE_STARTING(__MAC_10_12,__IPHONE_10_0/*SPI*/); +extern const CFStringRef kSCPropNetQoSMarkingEnabled __OSX_AVAILABLE_STARTING(__MAC_10_13,__IPHONE_10_0/*SPI*/); #define kSCPropNetQoSMarkingEnabled kSCPropNetQoSMarkingEnabled /*! @const kSCPropNetQoSMarkingWhitelistedAppIdentifiers @discussion Value is a CFArray[CFString] */ -extern const CFStringRef kSCPropNetQoSMarkingWhitelistedAppIdentifiers __OSX_AVAILABLE_STARTING(__MAC_10_12,__IPHONE_10_0/*SPI*/); +extern const CFStringRef kSCPropNetQoSMarkingWhitelistedAppIdentifiers __OSX_AVAILABLE_STARTING(__MAC_10_13,__IPHONE_10_0/*SPI*/); #define kSCPropNetQoSMarkingWhitelistedAppIdentifiers kSCPropNetQoSMarkingWhitelistedAppIdentifiers /*! diff --git a/SystemConfiguration.fproj/VPNConfiguration.c b/SystemConfiguration.fproj/VPNConfiguration.c index 3cbf047..77dfa20 100644 --- a/SystemConfiguration.fproj/VPNConfiguration.c +++ b/SystemConfiguration.fproj/VPNConfiguration.c @@ -1,4 +1,4 @@ /* - * Copyright (c) 2009-2016 Apple Inc. All rights reserved. + * Copyright (c) 2009-2017 Apple Inc. All rights reserved. */ diff --git a/SystemConfiguration.fproj/VPNFlow.h b/SystemConfiguration.fproj/VPNFlow.h index 8033ce0..c40b5d5 100644 --- a/SystemConfiguration.fproj/VPNFlow.h +++ b/SystemConfiguration.fproj/VPNFlow.h @@ -1,4 +1,4 @@ /* - * Copyright (c) 2012-2015 Apple Inc. All rights reserved. + * Copyright (c) 2012-2015, 2017 Apple Inc. All rights reserved. */ diff --git a/SystemConfiguration.fproj/VPNPrivate.c b/SystemConfiguration.fproj/VPNPrivate.c index ca26b2b..f9604ea 100644 --- a/SystemConfiguration.fproj/VPNPrivate.c +++ b/SystemConfiguration.fproj/VPNPrivate.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2009-2016 Apple Inc. All rights reserved. + * Copyright (c) 2009-2017 Apple Inc. All rights reserved. */ diff --git a/SystemConfiguration.fproj/VPNService.c b/SystemConfiguration.fproj/VPNService.c index 29f0f5e..b4dd2f0 100644 --- a/SystemConfiguration.fproj/VPNService.c +++ b/SystemConfiguration.fproj/VPNService.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2012, 2013, 2016 Apple Inc. All rights reserved. + * Copyright (c) 2012, 2013, 2016, 2017 Apple Inc. All rights reserved. */ #include "SCNetworkConfigurationInternal.h" @@ -38,7 +38,7 @@ static CFArrayRef copy_matching_services(SCPreferencesRef prefs, CFStringRef identifierDomain, CFStringRef identifier) { CFMutableArrayRef results = NULL; - CFArrayRef services; + CFArrayRef services; services = SCNetworkServiceCopyAll(prefs); if (services != NULL) { @@ -46,8 +46,8 @@ copy_matching_services(SCPreferencesRef prefs, CFStringRef identifierDomain, CFS CFIndex service_count = CFArrayGetCount(services); for (idx = 0; idx < service_count; idx++) { - SCNetworkServiceRef service = CFArrayGetValueAtIndex(services, idx); - Boolean matches = FALSE; + SCNetworkServiceRef service = CFArrayGetValueAtIndex(services, idx); + Boolean matches = FALSE; if (isA_VPNService(service)) { if (isA_CFString(identifierDomain) && isA_CFString(identifier)) { @@ -134,7 +134,7 @@ validate_app_rule(CFDictionaryRef ruleSettings, Boolean check_for_apple_apps) if (check_for_apple_apps && CFStringHasPrefix(signingID, g_apple_app_prefix)) { for (exception_idx = 0; - exception_idx < sizeof(g_apple_app_exceptions) / sizeof(g_apple_app_exceptions[0]); + exception_idx < (CFIndex)(sizeof(g_apple_app_exceptions) / sizeof(g_apple_app_exceptions[0])); exception_idx++) { if (CFStringCompare(signingID, g_apple_app_exceptions[exception_idx].signing_id, 0) == 0) { @@ -262,16 +262,22 @@ VPNServiceCopyAll(SCPreferencesRef prefs) CFArrayRef VPNServiceCopyAppRuleIDs(VPNServiceRef service) { - CFMutableArrayRef results = NULL; - CFDictionaryRef vpn_config; + SCNetworkInterfaceRef interface; + CFMutableArrayRef results = NULL; + CFDictionaryRef vpn_config; if (!isA_VPNService(service)) { _SCErrorSet(kSCStatusInvalidArgument); return NULL; } - vpn_config = SCNetworkInterfaceGetConfiguration(SCNetworkServiceGetInterface(service)); + interface = SCNetworkServiceGetInterface(service); + if (interface == NULL) { + _SCErrorSet(kSCStatusInvalidArgument); + return NULL; + } + vpn_config = SCNetworkInterfaceGetConfiguration(interface); if (isA_CFDictionary(vpn_config)) { CFArrayRef app_rules = CFDictionaryGetValue(vpn_config, kSCPropNetVPNAppRules); if (isA_CFArray(app_rules)) { @@ -305,15 +311,16 @@ VPNServiceCopyAppRuleIDs(VPNServiceRef service) Boolean VPNServiceSetAppRule(VPNServiceRef service, CFStringRef ruleIdentifier, CFDictionaryRef ruleSettings) { - CFArrayRef accounts; - CFArrayRef app_rules; - CFArrayRef executables; - CFIndex existing_idx = -1; - CFArrayRef match_domains; - CFMutableArrayRef new_app_rules; + CFArrayRef accounts; + CFArrayRef app_rules; + CFArrayRef executables; + CFIndex existing_idx = -1; + SCNetworkInterfaceRef interface; + CFArrayRef match_domains; + CFMutableArrayRef new_app_rules; CFMutableDictionaryRef new_settings; CFMutableDictionaryRef new_vpn_config; - CFDictionaryRef vpn_config; + CFDictionaryRef vpn_config; /* Basic parameter validation */ @@ -327,21 +334,27 @@ VPNServiceSetAppRule(VPNServiceRef service, CFStringRef ruleIdentifier, CFDictio return FALSE; } + interface = SCNetworkServiceGetInterface(service); + if (interface == NULL) { + _SCErrorSet(kSCStatusInvalidArgument); + return FALSE; + } + executables = CFDictionaryGetValue(ruleSettings, kSCValNetVPNAppRuleExecutableMatch); match_domains = CFDictionaryGetValue(ruleSettings, kSCValNetVPNAppRuleDNSDomainMatch); accounts = CFDictionaryGetValue(ruleSettings, kSCValNetVPNAppRuleAccountIdentifierMatch); /* Set the new rule config, replacing any existing rule */ - vpn_config = SCNetworkInterfaceGetConfiguration(SCNetworkServiceGetInterface(service)); + vpn_config = SCNetworkInterfaceGetConfiguration(interface); if (isA_CFDictionary(vpn_config)) { existing_idx = find_app_rule(vpn_config, ruleIdentifier); new_vpn_config = CFDictionaryCreateMutableCopy(kCFAllocatorDefault, 0, vpn_config); } else { new_vpn_config = CFDictionaryCreateMutable(kCFAllocatorDefault, - 0, - &kCFTypeDictionaryKeyCallBacks, - &kCFTypeDictionaryValueCallBacks); + 0, + &kCFTypeDictionaryKeyCallBacks, + &kCFTypeDictionaryValueCallBacks); } app_rules = CFDictionaryGetValue(new_vpn_config, kSCPropNetVPNAppRules); @@ -349,14 +362,14 @@ VPNServiceSetAppRule(VPNServiceRef service, CFStringRef ruleIdentifier, CFDictio new_app_rules = CFArrayCreateMutableCopy(kCFAllocatorDefault, 0, app_rules); } else { new_app_rules = CFArrayCreateMutable(kCFAllocatorDefault, - 0, - &kCFTypeArrayCallBacks); + 0, + &kCFTypeArrayCallBacks); } new_settings = CFDictionaryCreateMutable(kCFAllocatorDefault, - 0, - &kCFTypeDictionaryKeyCallBacks, - &kCFTypeDictionaryValueCallBacks); + 0, + &kCFTypeDictionaryKeyCallBacks, + &kCFTypeDictionaryValueCallBacks); CFDictionarySetValue(new_settings, kSCValNetVPNAppRuleIdentifier, ruleIdentifier); if (executables != NULL && CFArrayGetCount(executables) > 0) { @@ -377,7 +390,7 @@ VPNServiceSetAppRule(VPNServiceRef service, CFStringRef ruleIdentifier, CFDictio CFDictionarySetValue(new_vpn_config, kSCPropNetVPNAppRules, new_app_rules); - SCNetworkInterfaceSetConfiguration(SCNetworkServiceGetInterface(service), new_vpn_config); + SCNetworkInterfaceSetConfiguration(interface, new_vpn_config); CFRelease(new_vpn_config); CFRelease(new_app_rules); @@ -390,14 +403,21 @@ VPNServiceSetAppRule(VPNServiceRef service, CFStringRef ruleIdentifier, CFDictio CFDictionaryRef VPNServiceCopyAppRule(VPNServiceRef service, CFStringRef ruleIdentifier) { - CFDictionaryRef vpn_config; + SCNetworkInterfaceRef interface; + CFDictionaryRef vpn_config; if (!isA_VPNService(service) || !isA_CFString(ruleIdentifier)) { _SCErrorSet(kSCStatusInvalidArgument); return NULL; } - vpn_config = SCNetworkInterfaceGetConfiguration(SCNetworkServiceGetInterface(service)); + interface = SCNetworkServiceGetInterface(service); + if (interface == NULL) { + _SCErrorSet(kSCStatusInvalidArgument); + return FALSE; + } + + vpn_config = SCNetworkInterfaceGetConfiguration(interface); if (isA_CFDictionary(vpn_config)) { CFIndex idx = find_app_rule(vpn_config, ruleIdentifier); if (idx >= 0) { @@ -423,14 +443,21 @@ VPNServiceCopyAppRule(VPNServiceRef service, CFStringRef ruleIdentifier) Boolean VPNServiceRemoveAppRule(VPNServiceRef service, CFStringRef ruleIdentifier) { - CFDictionaryRef vpn_config; + SCNetworkInterfaceRef interface; + CFDictionaryRef vpn_config; if (!isA_VPNService(service) || !isA_CFString(ruleIdentifier)) { _SCErrorSet(kSCStatusInvalidArgument); return FALSE; } - vpn_config = SCNetworkInterfaceGetConfiguration(SCNetworkServiceGetInterface(service)); + interface = SCNetworkServiceGetInterface(service); + if (interface == NULL) { + _SCErrorSet(kSCStatusInvalidArgument); + return FALSE; + } + + vpn_config = SCNetworkInterfaceGetConfiguration(interface); if (isA_CFDictionary(vpn_config)) { CFIndex idx = find_app_rule(vpn_config, ruleIdentifier); if (idx >= 0) { @@ -450,7 +477,7 @@ VPNServiceRemoveAppRule(VPNServiceRef service, CFStringRef ruleIdentifier) CFDictionaryRemoveValue(new_vpn_config, kSCPropNetVPNAppRules); } - SCNetworkInterfaceSetConfiguration(SCNetworkServiceGetInterface(service), new_vpn_config); + SCNetworkInterfaceSetConfiguration(interface, new_vpn_config); CFRelease(new_vpn_config); CFRelease(new_app_rules); diff --git a/SystemConfiguration.fproj/genSCPreferences.c b/SystemConfiguration.fproj/genSCPreferences.c index b01957b..edeb1ec 100644 --- a/SystemConfiguration.fproj/genSCPreferences.c +++ b/SystemConfiguration.fproj/genSCPreferences.c @@ -99,6 +99,7 @@ typedef enum { SC_10_5_10_7, // deprecated in 10.7 SC_10_1_10_9, // deprecated in 10.9 SC_10_2_10_9, // deprecated in 10.9 + SC_10_2_10_13, // deprecated in 10.13 SC_10_3_10_9, // deprecated in 10.9 SC_10_4_10_9, // deprecated in 10.9 SC_10_6_IPHONE_2_0, @@ -120,6 +121,8 @@ typedef enum { SC_10_10_IPHONE_8_0_PRIVATE, SC_10_11_IPHONE_9_0_PRIVATE, SC_10_12_IPHONE_10_0_PRIVATE, + SC_10_13_IPHONE_10_0_PRIVATE, + SC_10_13_IPHONE_11_0_PRIVATE, SC_IPHONE_2_0_PRIVATE, COMMENT_DEPRECATED, GROUP_DEPRECATED, @@ -273,6 +276,7 @@ typedef enum { #define EXCLUDESIMPLEHOSTNAMES "ExcludeSimpleHostnames" #define EXECUTABLE "Executable" #define EXPENSIVE "Expensive" +#define EXPIRED "Expired" #define EXTERNAL "External" #define FAILOVER "Failover" #define FAILURE "Failure" @@ -350,6 +354,7 @@ typedef enum { #define MSCHAP2 "MSCHAP2" #define MTU "MTU" #define NAME "Name" +#define NAT64 "NAT64" #define NETBIOS "NetBIOS" #define NETINFO "NetInfo" #define NETWORK "Network" @@ -383,6 +388,7 @@ typedef enum { #define PPPSERIAL "PPPSerial" #define PPTP "PPTP" #define PREFERRED "Preferred" +#define PREFIX "Prefix" #define PREFIXLENGTH "PrefixLength" #define PREFS "Prefs" #define PRIMARYINTERFACE "PrimaryInterface" @@ -407,6 +413,7 @@ typedef enum { #define REMINDER "Reminder" #define REMINDERTIME "ReminderTime" #define REMOTEADDRESS "RemoteAddress" +#define REQUEST "Request" #define REQUESTED "Requested" #define REQUIRED "Required" #define REQUIREMENT "Requirement" @@ -593,11 +600,13 @@ static schemaDefinition names[] = { { SC_10_5_PRIVATE, NETENT, EAPOL, NULL, CFDICTIONARY }, { SC_10_10_IPHONE_8_0_PRIVATE, NETENT, IPV4 ROUTER ARP FAILURE, NULL, NULL}, { SC_10_10_IPHONE_8_0_PRIVATE, NETENT, IPV4 ROUTER ARP ALIVE, NULL, NULL}, + { SC_10_13_IPHONE_11_0_PRIVATE, NETENT, IPV6 ROUTER EXPIRED, NULL, NULL}, { SC_10_9_IPHONE_7_0_PRIVATE, NETENT, LINKISSUES, NULL, CFDICTIONARY}, { SC_10_7_IPHONE_5_0_PRIVATE, NETENT, LINKQUALITY, NULL, CFDICTIONARY}, { SC_10_7_IPHONE_4_0_PRIVATE, NETENT, LOOPBACK, NULL, CFDICTIONARY }, + { SC_10_13_IPHONE_11_0_PRIVATE, NETENT, NAT64 PREFIX REQUEST, NULL, NULL}, { SC_10_6_IPHONE_3_0_PRIVATE, NETENT, ONDEMAND, NULL, CFDICTIONARY }, - { SC_10_12_IPHONE_10_0_PRIVATE, NETENT, QOSMARKING POLICY, NULL, CFDICTIONARY }, + { SC_10_13_IPHONE_10_0_PRIVATE, NETENT, QOSMARKING POLICY, NULL, CFDICTIONARY }, { SC_10_6_IPHONE_2_0_PRIVATE, NETENT, SERVICE, "__SERVICE__", CFDICTIONARY }, { SC_10_7_IPHONE_4_0_PRIVATE, NETENT, VPN, NULL, CFDICTIONARY }, { COMMENT_PRIVATE, "", NULL, NULL, NULL }, @@ -714,7 +723,7 @@ static schemaDefinition names[] = { { SC_10_1, NETPROP INTERFACE, HARDWARE, NULL, CFSTRING }, { SC_10_1, NETPROP INTERFACE, TYPE, NULL, CFSTRING }, { SC_10_1, NETPROP INTERFACE, SUBTYPE, NULL, CFSTRING }, - { SC_10_2, NETPROP INTERFACE, SUPPORTSMODEMONHOLD, NULL, CFNUMBER_BOOL }, + { SC_10_2_10_13, NETPROP INTERFACE, SUPPORTSMODEMONHOLD, NULL, CFNUMBER_BOOL }, { COMMENT, "", NULL, NULL, NULL }, { COMMENT, "--- " KEY_PREFIX NETPROP INTERFACE TYPE " values ---", NULL, NULL, NULL }, { SC_10_1, NETVAL INTERFACE TYPE, ETHERNET, NULL, NULL }, @@ -1110,13 +1119,13 @@ static schemaDefinition names[] = { { GROUP_PRIVATE, NETPROP LINK, KEY_PREFIX NETENT QOSMARKING POLICY " Entity Keys", NULL, NULL }, - { SC_10_12_IPHONE_10_0_PRIVATE, NETPROP QOSMARKING, APPLE AUDIOVIDEOCALLS, + { SC_10_13_IPHONE_10_0_PRIVATE, NETPROP QOSMARKING, APPLE AUDIOVIDEOCALLS, QOSMARKING APPLE AUDIOVIDEOCALLS, CFBOOLEAN}, - { SC_10_12_IPHONE_10_0_PRIVATE, NETPROP QOSMARKING, ENABLED, + { SC_10_13_IPHONE_10_0_PRIVATE, NETPROP QOSMARKING, ENABLED, QOSMARKING ENABLED, CFBOOLEAN}, - { SC_10_12_IPHONE_10_0_PRIVATE, NETPROP QOSMARKING, WHITELISTED APP IDENTIFIERS, + { SC_10_13_IPHONE_10_0_PRIVATE, NETPROP QOSMARKING, WHITELISTED APP IDENTIFIERS, QOSMARKING WHITELISTED APP IDENTIFIERS, CFARRAY_CFSTRING}, { COMMENT_PRIVATE, "", NULL, NULL, NULL }, @@ -1395,6 +1404,9 @@ print_headerdoc(schemaDefinition *def) case SC_10_2_10_9: printf(" __OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_2,__MAC_10_9,__IPHONE_2_0/*SPI*/,__IPHONE_FUTURE/*SPI*/);\n"); break; + case SC_10_2_10_13: + printf(" __OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_2,__MAC_10_13,__IPHONE_2_0/*SPI*/,__IPHONE_FUTURE/*SPI*/);\n"); + break; case SC_10_3_10_9: printf(" __OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_3,__MAC_10_9,__IPHONE_2_0/*SPI*/,__IPHONE_FUTURE/*SPI*/);\n"); break; @@ -1443,6 +1455,12 @@ print_headerdoc(schemaDefinition *def) case SC_10_12_IPHONE_10_0_PRIVATE: printf(" __OSX_AVAILABLE_STARTING(__MAC_10_12,__IPHONE_10_0/*SPI*/);\n"); break; + case SC_10_13_IPHONE_10_0_PRIVATE: + printf(" __OSX_AVAILABLE_STARTING(__MAC_10_13,__IPHONE_10_0/*SPI*/);\n"); + break; + case SC_10_13_IPHONE_11_0_PRIVATE: + printf(" __OSX_AVAILABLE_STARTING(__MAC_10_13,__IPHONE_11_0/*SPI*/);\n"); + break; case SC_IPHONE_2_0_PRIVATE: printf(" __OSX_AVAILABLE_STARTING(__MAC_NA,__IPHONE_2_0/*SPI*/);\n"); break; @@ -1602,6 +1620,7 @@ dump_names(int type) case SC_10_1_10_4: case SC_10_1_10_9: case SC_10_2_10_9: + case SC_10_2_10_13: case SC_10_3_10_9: case SC_10_4_10_9: // don't report deprecated keys @@ -1618,6 +1637,8 @@ dump_names(int type) case SC_10_10_IPHONE_8_0_PRIVATE: case SC_10_11_IPHONE_9_0_PRIVATE: case SC_10_12_IPHONE_10_0_PRIVATE: + case SC_10_13_IPHONE_10_0_PRIVATE: + case SC_10_13_IPHONE_11_0_PRIVATE: case SC_IPHONE_2_0_PRIVATE: // don't report private definitions break; @@ -1632,6 +1653,7 @@ dump_names(int type) case SC_10_1_10_4: case SC_10_1_10_9: case SC_10_2_10_9: + case SC_10_2_10_13: case SC_10_3_10_9: case SC_10_4_10_9: // don't report deprecated keys @@ -1648,6 +1670,8 @@ dump_names(int type) case SC_10_10_IPHONE_8_0_PRIVATE: case SC_10_11_IPHONE_9_0_PRIVATE: case SC_10_12_IPHONE_10_0_PRIVATE: + case SC_10_13_IPHONE_10_0_PRIVATE: + case SC_10_13_IPHONE_11_0_PRIVATE: case SC_IPHONE_2_0_PRIVATE: print_comment(&names[i]); break; @@ -1672,6 +1696,8 @@ dump_names(int type) case SC_10_10_IPHONE_8_0_PRIVATE: case SC_10_11_IPHONE_9_0_PRIVATE: case SC_10_12_IPHONE_10_0_PRIVATE: + case SC_10_13_IPHONE_10_0_PRIVATE: + case SC_10_13_IPHONE_11_0_PRIVATE: case SC_IPHONE_2_0_PRIVATE: // don't report private definitions break; @@ -1694,6 +1720,8 @@ dump_names(int type) case SC_10_10_IPHONE_8_0_PRIVATE: case SC_10_11_IPHONE_9_0_PRIVATE: case SC_10_12_IPHONE_10_0_PRIVATE: + case SC_10_13_IPHONE_10_0_PRIVATE: + case SC_10_13_IPHONE_11_0_PRIVATE: case SC_IPHONE_2_0_PRIVATE: print_headerdoc(&names[i]); break; diff --git a/SystemConfiguration.fproj/helper/SCHelper_server.c b/SystemConfiguration.fproj/helper/SCHelper_server.c index 63ce43d..5413fea 100644 --- a/SystemConfiguration.fproj/helper/SCHelper_server.c +++ b/SystemConfiguration.fproj/helper/SCHelper_server.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2005-2016 Apple Inc. All rights reserved. + * Copyright (c) 2005-2017 Apple Inc. All rights reserved. * * @APPLE_LICENSE_HEADER_START@ * @@ -38,7 +38,8 @@ #include #include -#define SC_LOG_HANDLE __log_SCHelper() +#define SC_LOG_HANDLE __log_SCHelper() +#define SC_LOG_HANDLE_TYPE static #include "SCPreferencesInternal.h" #include "SCHelper_client.h" #include "helper_types.h" @@ -360,7 +361,7 @@ __SCHelperSessionSetVPNFilter(SCHelperSessionRef session, Boolean vpnChange, CFA } -static CFArrayRef +static Boolean __SCHelperSessionUseVPNFilter(SCHelperSessionRef session, CFArrayRef *vpnTypes) { SCHelperSessionPrivateRef sessionPrivate = (SCHelperSessionPrivateRef)session; @@ -519,10 +520,13 @@ __SCHelperSessionCreate(CFAllocatorRef allocator) CFRelease(sessionPrivate); return NULL; } + + pthread_mutex_lock(&sessionPrivate->lock); sessionPrivate->callerReadAccess = UNKNOWN; sessionPrivate->callerWriteAccess = UNKNOWN; sessionPrivate->isSetChange = UNKNOWN; sessionPrivate->isVPNChange = UNKNOWN; + pthread_mutex_unlock(&sessionPrivate->lock); // keep track this session pthread_mutex_lock(&sessions_lock); @@ -633,7 +637,7 @@ __SCHelperSessionLogBacktrace(const void *value, void *context) snprintf(path, sizeof(path), - "/Library/Logs/CrashReporter/SCHelper-%4d-%02d-%02d-%02d%02d%02d.log", + _SC_CRASH_DIR "/" "SCHelper-%4d-%02d-%02d-%02d%02d%02d.log", tm_now.tm_year + 1900, tm_now.tm_mon + 1, tm_now.tm_mday, @@ -659,6 +663,9 @@ __SCHelperSessionLogBacktrace(const void *value, void *context) #pragma mark Helpers +#define HELPER_STATUS_NO_REPLY UINT32_MAX + + /* * EXIT * (in) data = N/A @@ -668,7 +675,11 @@ __SCHelperSessionLogBacktrace(const void *value, void *context) static Boolean do_Exit(SCHelperSessionRef session, void *info, CFDataRef data, uint32_t *status, CFDataRef *reply) { - *status = -1; +#pragma unused(session) +#pragma unused(info) +#pragma unused(data) +#pragma unused(reply) + *status = HELPER_STATUS_NO_REPLY; return FALSE; } @@ -684,6 +695,8 @@ do_Exit(SCHelperSessionRef session, void *info, CFDataRef data, uint32_t *status static Boolean do_Auth(SCHelperSessionRef session, void *info, CFDataRef data, uint32_t *status, CFDataRef *reply) { +#pragma unused(info) +#pragma unused(reply) CFDictionaryRef authorizationDict; #if !TARGET_OS_IPHONE CFDataRef authorizationData = NULL; @@ -736,6 +749,7 @@ do_Auth(SCHelperSessionRef session, void *info, CFDataRef data, uint32_t *status static Boolean do_keychain_copy(SCHelperSessionRef session, void *info, CFDataRef data, uint32_t *status, CFDataRef *reply) { +#pragma unused(info) Boolean ok = FALSE; SCPreferencesRef prefs; CFStringRef unique_id = NULL; @@ -770,6 +784,8 @@ do_keychain_copy(SCHelperSessionRef session, void *info, CFDataRef data, uint32_ static Boolean do_keychain_exists(SCHelperSessionRef session, void *info, CFDataRef data, uint32_t *status, CFDataRef *reply) { +#pragma unused(info) +#pragma unused(reply) Boolean ok = FALSE; SCPreferencesRef prefs; CFStringRef unique_id = NULL; @@ -803,6 +819,8 @@ do_keychain_exists(SCHelperSessionRef session, void *info, CFDataRef data, uint3 static Boolean do_keychain_remove(SCHelperSessionRef session, void *info, CFDataRef data, uint32_t *status, CFDataRef *reply) { +#pragma unused(info) +#pragma unused(reply) Boolean ok = FALSE; SCPreferencesRef prefs; CFStringRef unique_id = NULL; @@ -836,6 +854,8 @@ do_keychain_remove(SCHelperSessionRef session, void *info, CFDataRef data, uint3 static Boolean do_keychain_set(SCHelperSessionRef session, void *info, CFDataRef data, uint32_t *status, CFDataRef *reply) { +#pragma unused(info) +#pragma unused(reply) CFStringRef account; CFStringRef description; CFArrayRef executablePaths = NULL; @@ -927,6 +947,9 @@ do_keychain_set(SCHelperSessionRef session, void *info, CFDataRef data, uint32_t static Boolean do_interface_refresh(SCHelperSessionRef session, void *info, CFDataRef data, uint32_t *status, CFDataRef *reply) { +#pragma unused(session) +#pragma unused(info) +#pragma unused(reply) CFStringRef ifName = NULL; Boolean ok = FALSE; @@ -970,6 +993,8 @@ do_interface_refresh(SCHelperSessionRef session, void *info, CFDataRef data, uin static Boolean do_prefs_Open(SCHelperSessionRef session, void *info, CFDataRef data, uint32_t *status, CFDataRef *reply) { +#pragma unused(info) +#pragma unused(reply) CFStringRef name; CFDictionaryRef options; CFNumberRef pid; @@ -1084,6 +1109,8 @@ do_prefs_Open(SCHelperSessionRef session, void *info, CFDataRef data, uint32_t * static Boolean do_prefs_Access(SCHelperSessionRef session, void *info, CFDataRef data, uint32_t *status, CFDataRef *reply) { +#pragma unused(info) +#pragma unused(data) Boolean ok; SCPreferencesRef prefs = __SCHelperSessionGetPreferences(session); CFDataRef signature; @@ -1134,6 +1161,7 @@ do_prefs_Access(SCHelperSessionRef session, void *info, CFDataRef data, uint32_t static Boolean do_prefs_Lock(SCHelperSessionRef session, void *info, CFDataRef data, uint32_t *status, CFDataRef *reply) { +#pragma unused(reply) CFDataRef clientSignature = (CFDataRef)data; Boolean ok; SCPreferencesRef prefs = __SCHelperSessionGetPreferences(session); @@ -1172,6 +1200,7 @@ do_prefs_Lock(SCHelperSessionRef session, void *info, CFDataRef data, uint32_t * static Boolean do_prefs_Commit(SCHelperSessionRef session, void *info, CFDataRef data, uint32_t *status, CFDataRef *reply) { +#pragma unused(info) Boolean ok; SCPreferencesRef prefs = __SCHelperSessionGetPreferences(session); CFPropertyListRef prefsData = NULL; @@ -1348,6 +1377,9 @@ do_prefs_Commit(SCHelperSessionRef session, void *info, CFDataRef data, uint32_t static Boolean do_prefs_Apply(SCHelperSessionRef session, void *info, CFDataRef data, uint32_t *status, CFDataRef *reply) { +#pragma unused(info) +#pragma unused(data) +#pragma unused(reply) Boolean ok; SCPreferencesRef prefs = __SCHelperSessionGetPreferences(session); @@ -1373,6 +1405,9 @@ do_prefs_Apply(SCHelperSessionRef session, void *info, CFDataRef data, uint32_t static Boolean do_prefs_Unlock(SCHelperSessionRef session, void *info, CFDataRef data, uint32_t *status, CFDataRef *reply) { +#pragma unused(info) +#pragma unused(data) +#pragma unused(reply) Boolean ok; SCPreferencesRef prefs = __SCHelperSessionGetPreferences(session); @@ -1398,6 +1433,9 @@ do_prefs_Unlock(SCHelperSessionRef session, void *info, CFDataRef data, uint32_t static Boolean do_prefs_Close(SCHelperSessionRef session, void *info, CFDataRef data, uint32_t *status, CFDataRef *reply) { +#pragma unused(info) +#pragma unused(data) +#pragma unused(reply) SCPreferencesRef prefs = __SCHelperSessionGetPreferences(session); if (prefs == NULL) { @@ -1405,7 +1443,7 @@ do_prefs_Close(SCHelperSessionRef session, void *info, CFDataRef data, uint32_t } __SCHelperSessionSetPreferences(session, NULL); - *status = -1; + *status = HELPER_STATUS_NO_REPLY; return TRUE; } @@ -1419,6 +1457,9 @@ do_prefs_Close(SCHelperSessionRef session, void *info, CFDataRef data, uint32_t static Boolean do_prefs_Synchronize(SCHelperSessionRef session, void *info, CFDataRef data, uint32_t *status, CFDataRef *reply) { +#pragma unused(info) +#pragma unused(data) +#pragma unused(reply) SCPreferencesRef prefs = __SCHelperSessionGetPreferences(session); if (prefs == NULL) { @@ -1776,11 +1817,9 @@ static const struct helper { static int -findCommand(uint32_t command) +findCommand(int command) { - int i; - - for (i = 0; i < (int)nHELPERS; i++) { + for (int i = 0; i < (int)nHELPERS; i++) { if (helpers[i].command == command) { return i; } @@ -1793,6 +1832,7 @@ findCommand(uint32_t command) static void * newHelper(void *arg) { + int ret; CFRunLoopSourceRef rls = NULL; SCHelperSessionRef session = (SCHelperSessionRef)arg; SCHelperSessionPrivateRef sessionPrivate = (SCHelperSessionPrivateRef)session; @@ -1802,6 +1842,11 @@ newHelper(void *arg) __SCHelperSessionSetThreadName(session); + ret = pthread_set_qos_class_self_np(QOS_CLASS_USER_INITIATED, 0); + if (ret != 0) { + SC_log(LOG_ERR, "pthread_set_qos_class_self_np() failed: %s", strerror(errno)); + } + rls = CFMachPortCreateRunLoopSource(NULL, sessionPrivate->mp, 0); CFRelease(sessionPrivate->mp); @@ -1933,10 +1978,13 @@ helper_demux(mach_msg_header_t *request, mach_msg_header_t *reply) static void helperCallback(CFMachPortRef port, void *msg, CFIndex size, void *info) { +#pragma unused(port) +#pragma unused(size) +#pragma unused(info) mig_reply_error_t * bufRequest = msg; uint32_t bufReply_q[MACH_MSG_BUFFER_SIZE/sizeof(uint32_t)]; mig_reply_error_t * bufReply = (mig_reply_error_t *)bufReply_q; - static CFIndex bufSize = 0; + static size_t bufSize = 0; mach_msg_return_t mr; int options; @@ -2024,6 +2072,7 @@ helperCallback(CFMachPortRef port, void *msg, CFIndex size, void *info) static CFStringRef initMPCopyDescription(const void *info) { +#pragma unused(info) return CFStringCreateWithFormat(NULL, NULL, CFSTR("")); } @@ -2216,7 +2265,7 @@ _helperexec(mach_port_t server, (*helpers[i].func)(session, helpers[i].info, data, status, &reply); } - if ((*status != -1) || (reply != NULL)) { + if ((*status != HELPER_STATUS_NO_REPLY) || (reply != NULL)) { Boolean ok; SC_log(LOG_INFO, "%p : sending status %u%s", @@ -2249,6 +2298,7 @@ _helperexec(mach_port_t server, static CFStringRef helperMPCopyDescription(const void *info) { +#pragma unused(info) return CFStringCreateWithFormat(NULL, NULL, CFSTR("
")); } @@ -2311,6 +2361,7 @@ main(int argc, char **argv) // extern int optind; int opt; int opti; + int ret; openlog("SCHelper", LOG_CONS|LOG_PID, LOG_DAEMON); @@ -2347,6 +2398,11 @@ main(int argc, char **argv) pthread_setname_np("SCHelper main thread"); + ret = pthread_set_qos_class_self_np(QOS_CLASS_USER_INITIATED, 0); + if (ret != 0) { + SC_log(LOG_ERR, "pthread_set_qos_class_self_np() failed: %s", strerror(errno)); + } + while (!done) { SInt32 rlStatus; int gen_current; diff --git a/SystemConfiguration.fproj/helper/com.apple.SCHelper-embedded.plist b/SystemConfiguration.fproj/helper/com.apple.SCHelper-embedded.plist index 209e217..3b1ec03 100644 --- a/SystemConfiguration.fproj/helper/com.apple.SCHelper-embedded.plist +++ b/SystemConfiguration.fproj/helper/com.apple.SCHelper-embedded.plist @@ -16,6 +16,6 @@ POSIXSpawnType - Adaptive + Interactive diff --git a/SystemConfiguration.fproj/helper/com.apple.SCHelper.plist b/SystemConfiguration.fproj/helper/com.apple.SCHelper.plist index b6612a4..c364cf0 100644 --- a/SystemConfiguration.fproj/helper/com.apple.SCHelper.plist +++ b/SystemConfiguration.fproj/helper/com.apple.SCHelper.plist @@ -12,6 +12,6 @@ POSIXSpawnType - Adaptive + Interactive diff --git a/SystemConfiguration.fproj/scprefs_observer.c b/SystemConfiguration.fproj/scprefs_observer.c index fd56df8..c7ae524 100644 --- a/SystemConfiguration.fproj/scprefs_observer.c +++ b/SystemConfiguration.fproj/scprefs_observer.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2012, 2013, 2015, 2016 Apple Inc. All rights reserved. + * Copyright (c) 2012, 2013, 2015-2017 Apple Inc. All rights reserved. * * @APPLE_LICENSE_HEADER_START@ * @@ -225,6 +225,7 @@ _prefs_observer_init() &token, prefs_observer_queue, ^(int token) { +#pragma unused(token) prefs_observer_handle_notifications(); }); if (status != NOTIFY_STATUS_OK) { @@ -303,18 +304,18 @@ int main() dispatch_queue_t q1 = dispatch_queue_create("com.apple.SystemConfiguration.PrefsObserver.testQ1", NULL); dispatch_block_t b1 = ^{ - printf("Block 1 executed \n"); + printf("Block 1 executed\n"); }; dispatch_queue_t q2 = dispatch_queue_create("com.apple.SystemConfiguration.PrefsObserver.testQ2", NULL); dispatch_block_t b2 = ^{ - printf("Block 2 executed \n"); + printf("Block 2 executed\n"); }; dispatch_queue_t q3 = dispatch_queue_create("com.apple.SystemConfiguration.PrefsObserver.testQ2", NULL); dispatch_block_t b3 = ^{ - printf("Block 3 executed \n"); + printf("Block 3 executed\n"); }; __block scprefs_observer_t observer1 = _scprefs_observer_watch(scprefs_observer_type_mcx, "com.apple.SystemConfiguration", q1, b1); diff --git a/SystemConfiguration.fproj/scprefs_observer.h b/SystemConfiguration.fproj/scprefs_observer.h index 6839dc1..00ce626 100644 --- a/SystemConfiguration.fproj/scprefs_observer.h +++ b/SystemConfiguration.fproj/scprefs_observer.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2012-2014 Apple Inc. All rights reserved. + * Copyright (c) 2012-2014, 2017 Apple Inc. All rights reserved. * * @APPLE_LICENSE_HEADER_START@ * @@ -47,7 +47,7 @@ __BEGIN_DECLS @discussion Sends a notification to interested configuration agents when a particular preference file has changed. @param type the type of preference (MCX on OSX, Global/Profiles on iOS) to watch. - @param plist the name of the plist file to watch. + @param plist_name the name of the plist file to watch. @param queue the queue to be called back on. @param block the block to be called back on. @result Returns the created preferences observer diff --git a/config-agent-info/config_agent_info.c b/config-agent-info/config_agent_info.c index 8071d4d..4a6462e 100644 --- a/config-agent-info/config_agent_info.c +++ b/config-agent-info/config_agent_info.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015, 2016 Apple Inc. All rights reserved. + * Copyright (c) 2015-2017 Apple Inc. All rights reserved. * * @APPLE_LICENSE_HEADER_START@ * @@ -35,6 +35,7 @@ get_agent_uuid_if_OOB_data_required(xpc_object_t info, uuid_t uuid) if (xpc_get_type(info) == XPC_TYPE_ARRAY) { xpc_array_apply(info, ^bool(size_t index, xpc_object_t value) { +#pragma unused(index) if (value && xpc_get_type(value) == XPC_TYPE_DICTIONARY) { agent_uuid = xpc_dictionary_get_value(info, kConfigAgentOutOfBandDataUUID); diff --git a/configd.tproj/_SCD.c b/configd.tproj/_SCD.c index a9e1c50..e99272b 100644 --- a/configd.tproj/_SCD.c +++ b/configd.tproj/_SCD.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2000, 2001, 2003-2005, 2009, 2011, 2012, 2015, 2016 Apple Inc. All rights reserved. + * Copyright (c) 2000, 2001, 2003-2005, 2009, 2011, 2012, 2015-2017 Apple Inc. All rights reserved. * * @APPLE_LICENSE_HEADER_START@ * @@ -263,7 +263,7 @@ pushNotifications() storePrivate = (SCDynamicStorePrivateRef)theSession->store; /* - * deliver notifications to client sessions + * deliver [CFRunLoop/dispatch] notifications to client sessions */ if ((storePrivate->notifyStatus == Using_NotifierInformViaMachPort) && (storePrivate->notifyPort != MACH_PORT_NULL)) { diff --git a/configd.tproj/_configadd.c b/configd.tproj/_configadd.c index bdc5d4f..38ee21e 100644 --- a/configd.tproj/_configadd.c +++ b/configd.tproj/_configadd.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2000, 2001, 2003, 2004, 2006, 2008, 2011, 2012, 2014-2016 Apple Inc. All rights reserved. + * Copyright (c) 2000, 2001, 2003, 2004, 2006, 2008, 2011, 2012, 2014-2017 Apple Inc. All rights reserved. * * @APPLE_LICENSE_HEADER_START@ * @@ -130,7 +130,7 @@ _configadd(mach_port_t server, } } - if (!hasWriteAccess(mySession, key)) { + if (!hasWriteAccess(mySession, "add", key)) { *sc_status = kSCStatusAccessError; goto done; } @@ -193,7 +193,7 @@ _configadd_s(mach_port_t server, goto done; } - if (!hasWriteAccess(mySession, key)) { + if (!hasWriteAccess(mySession, "add (session)", key)) { *sc_status = kSCStatusAccessError; goto done; } diff --git a/configd.tproj/_confignotify.c b/configd.tproj/_confignotify.c index 26725d2..f3eb166 100644 --- a/configd.tproj/_confignotify.c +++ b/configd.tproj/_confignotify.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2000-2004, 2006, 2008, 2011, 2012, 2015, 2016 Apple Inc. All rights reserved. + * Copyright (c) 2000-2004, 2006, 2008, 2011, 2012, 2015-2017 Apple Inc. All rights reserved. * * @APPLE_LICENSE_HEADER_START@ * @@ -106,7 +106,7 @@ _confignotify(mach_port_t server, } } - if (!hasWriteAccess(mySession, key)) { + if (!hasWriteAccess(mySession, "notify", key)) { *sc_status = kSCStatusAccessError; goto done; } diff --git a/configd.tproj/_configopen.c b/configd.tproj/_configopen.c index da5d8a6..37f7981 100644 --- a/configd.tproj/_configopen.c +++ b/configd.tproj/_configopen.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2000-2009, 2011, 2015, 2016 Apple Inc. All rights reserved. + * Copyright (c) 2000-2009, 2011, 2015-2017 Apple Inc. All rights reserved. * * @APPLE_LICENSE_HEADER_START@ * @@ -82,6 +82,7 @@ __SCDynamicStoreOpen(SCDynamicStoreRef *store, CFStringRef name) static CFStringRef openMPCopyDescription(const void *info) { +#pragma unused(info) return CFStringCreateWithFormat(NULL, NULL, CFSTR("")); } diff --git a/configd.tproj/_configremove.c b/configd.tproj/_configremove.c index 04c532e..25d2e77 100644 --- a/configd.tproj/_configremove.c +++ b/configd.tproj/_configremove.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2000-2004, 2006, 2008, 2011, 2012, 2015, 2016 Apple Inc. All rights reserved. + * Copyright (c) 2000-2004, 2006, 2008, 2011, 2012, 2015-2017 Apple Inc. All rights reserved. * * @APPLE_LICENSE_HEADER_START@ * @@ -146,7 +146,7 @@ _configremove(mach_port_t server, } } - if (!hasWriteAccess(mySession, key)) { + if (!hasWriteAccess(mySession, "remove", key)) { *sc_status = kSCStatusAccessError; goto done; } diff --git a/configd.tproj/_configset.c b/configd.tproj/_configset.c index 432ad4f..4497e44 100644 --- a/configd.tproj/_configset.c +++ b/configd.tproj/_configset.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2000-2004, 2006, 2008, 2011, 2012, 2014-2016 Apple Inc. All rights reserved. + * Copyright (c) 2000-2004, 2006, 2008, 2011, 2012, 2014-2017 Apple Inc. All rights reserved. * * @APPLE_LICENSE_HEADER_START@ * @@ -217,6 +217,7 @@ _configset(mach_port_t server, int *sc_status, audit_token_t audit_token) { +#pragma unused(oldInstance) CFDataRef data = NULL; /* data (un-serialized) */ CFStringRef key = NULL; /* key (un-serialized) */ serverSessionRef mySession; @@ -252,7 +253,7 @@ _configset(mach_port_t server, } } - if (!hasWriteAccess(mySession, key)) { + if (!hasWriteAccess(mySession, "set", key)) { *sc_status = kSCStatusAccessError; goto done; } @@ -452,7 +453,7 @@ _configset_m(mach_port_t server, CFStringRef key; key = (CFStringRef)keys[i]; - if (!hasWriteAccess(mySession, key)) { + if (!hasWriteAccess(mySession, "set (multiple)", key)) { writeOK = FALSE; break; } @@ -475,7 +476,7 @@ _configset_m(mach_port_t server, CFStringRef key; key = CFArrayGetValueAtIndex(remove, i); - if (!hasWriteAccess(mySession, key)) { + if (!hasWriteAccess(mySession, "set/remove (multiple)", key)) { *sc_status = kSCStatusAccessError; goto done; } @@ -490,7 +491,7 @@ _configset_m(mach_port_t server, CFStringRef key; key = CFArrayGetValueAtIndex(notify, i); - if (!hasWriteAccess(mySession, key)) { + if (!hasWriteAccess(mySession, "set/notify (multiple)", key)) { *sc_status = kSCStatusAccessError; goto done; } diff --git a/configd.tproj/_configunlock.c b/configd.tproj/_configunlock.c index 2e14b25..4ccff66 100644 --- a/configd.tproj/_configunlock.c +++ b/configd.tproj/_configunlock.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2000-2004, 2006, 2011, 2015 Apple Inc. All rights reserved. + * Copyright (c) 2000-2004, 2006, 2011, 2015, 2017 Apple Inc. All rights reserved. * * @APPLE_LICENSE_HEADER_START@ * @@ -182,6 +182,7 @@ _processDeferredRemovals() static void _cleanupRemovedSessionKeys(const void *value, void *context) { +#pragma unused(context) CFStringRef removedKey = (CFStringRef)value; CFRange dRange; CFStringRef sessionKey; diff --git a/configd.tproj/_snapshot.c b/configd.tproj/_snapshot.c index 76c9370..2874345 100644 --- a/configd.tproj/_snapshot.c +++ b/configd.tproj/_snapshot.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2000-2006, 2009-2011, 2015 Apple Inc. All rights reserved. + * Copyright (c) 2000-2006, 2009-2011, 2015, 2017 Apple Inc. All rights reserved. * * @APPLE_LICENSE_HEADER_START@ * @@ -126,6 +126,7 @@ __private_extern__ int __SCDynamicStoreSnapshot(SCDynamicStoreRef store) { +#pragma unused(store) CFDictionaryRef expandedStoreData; FILE *f; int fd; diff --git a/configd.tproj/configd.m b/configd.tproj/configd.m index 623d632..24f7df0 100644 --- a/configd.tproj/configd.m +++ b/configd.tproj/configd.m @@ -1,5 +1,5 @@ /* - * Copyright (c) 2000-2011, 2013-2016 Apple Inc. All rights reserved. + * Copyright (c) 2000-2011, 2013-2017 Apple Inc. All rights reserved. * * @APPLE_LICENSE_HEADER_START@ * @@ -154,6 +154,10 @@ catcher(int signum) static void term(CFMachPortRef port, void *msg, CFIndex size, void *info) { +#pragma unused(port) +#pragma unused(msg) +#pragma unused(size) +#pragma unused(info) int status = EX_OK; Boolean wait; @@ -171,6 +175,7 @@ term(CFMachPortRef port, void *msg, CFIndex size, void *info) static void parent_exit(int i) { +#pragma unused(i) _exit (0); } @@ -257,6 +262,7 @@ fork_child() static CFStringRef termMPCopyDescription(const void *info) { +#pragma unused(info) return CFStringCreateWithFormat(NULL, NULL, CFSTR("")); } diff --git a/configd.tproj/configd_server.c b/configd.tproj/configd_server.c index d586863..f5e799c 100644 --- a/configd.tproj/configd_server.c +++ b/configd.tproj/configd_server.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2000-2011, 2013, 2015, 2016 Apple Inc. All rights reserved. + * Copyright (c) 2000-2011, 2013, 2015-2017 Apple Inc. All rights reserved. * * @APPLE_LICENSE_HEADER_START@ * @@ -98,10 +98,13 @@ __private_extern__ void configdCallback(CFMachPortRef port, void *msg, CFIndex size, void *info) { +#pragma unused(port) +#pragma unused(size) +#pragma unused(info) mig_reply_error_t * bufRequest = msg; uint32_t bufReply_q[MACH_MSG_BUFFER_SIZE/sizeof(uint32_t)]; mig_reply_error_t * bufReply = (mig_reply_error_t *)bufReply_q; - static CFIndex bufSize = 0; + static size_t bufSize = 0; mach_msg_return_t mr; int options; @@ -189,6 +192,7 @@ configdCallback(CFMachPortRef port, void *msg, CFIndex size, void *info) static CFStringRef serverMPCopyDescription(const void *info) { +#pragma unused(info) return CFStringCreateWithFormat(NULL, NULL, CFSTR("
")); } diff --git a/configd.tproj/entitlements-ios.plist b/configd.tproj/entitlements-ios.plist index 27b6f0a..d2be76c 100644 --- a/configd.tproj/entitlements-ios.plist +++ b/configd.tproj/entitlements-ios.plist @@ -34,8 +34,6 @@ com.apple.security.network.server - com.apple.springboard.launchapplications - com.apple.wifi.manager-access com.apple.wlan.authentication @@ -46,5 +44,7 @@ com.apple.networkd.modify_settings + com.apple.frontboard.launchapplications + diff --git a/configd.tproj/plugin_support.c b/configd.tproj/plugin_support.c index 54e5d7f..53cdc7c 100644 --- a/configd.tproj/plugin_support.c +++ b/configd.tproj/plugin_support.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2000-2016 Apple Inc. All rights reserved. + * Copyright (c) 2000-2017 Apple Inc. All rights reserved. * * @APPLE_LICENSE_HEADER_START@ * @@ -49,7 +49,6 @@ #include "configd.h" #include "configd_server.h" #include -#include "SCNetworkReachabilityInternal.h" void _SCDPluginExecInit(); @@ -79,10 +78,9 @@ static const CFStringRef pluginWhitelist[] = { PLUGIN_ALL ("com.apple.SystemConfiguration.InterfaceNamer"), PLUGIN_ALL ("com.apple.SystemConfiguration.KernelEventMonitor"), PLUGIN_ALL ("com.apple.SystemConfiguration.LinkConfiguration"), - PLUGIN_ALL ("com.apple.SystemConfiguration.Logger"), PLUGIN_ALL ("com.apple.SystemConfiguration.PPPController"), PLUGIN_ALL ("com.apple.SystemConfiguration.PreferencesMonitor"), - PLUGIN_IOS ("com.apple.SystemConfiguration.QoSMarking"), + PLUGIN_ALL ("com.apple.SystemConfiguration.QoSMarking"), PLUGIN_MACOSX("com.apple.print.notification"), }; #define N_PLUGIN_WHITELIST (sizeof(pluginWhitelist) / sizeof(pluginWhitelist[0])) @@ -122,9 +120,7 @@ extern SCDynamicStoreBundlePrimeFunction prime_KernelEventMonitor; extern SCDynamicStoreBundleLoadFunction load_LinkConfiguration; extern SCDynamicStoreBundleLoadFunction load_PreferencesMonitor; extern SCDynamicStoreBundlePrimeFunction prime_PreferencesMonitor; -#if TARGET_OS_IPHONE extern SCDynamicStoreBundleLoadFunction load_QoSMarking; -#endif // TARGET_OS_IPHONE #endif // !TARGET_OS_SIMULATOR @@ -174,7 +170,6 @@ static const builtin builtin_plugins[] = { &prime_PreferencesMonitor, NULL }, -#if TARGET_OS_IPHONE { CFSTR("com.apple.SystemConfiguration.QoSMarking"), &load_QoSMarking, @@ -182,7 +177,6 @@ static const builtin builtin_plugins[] = { NULL, NULL }, -#endif // TARGET_OS_IPHONE #endif // !TARGET_OS_SIMULATOR }; @@ -381,11 +375,9 @@ loadBundle(const void *value, void *context) { } if (bundleInfo->builtin) { - int i; - SC_log(LOG_INFO, "adding %@", bundleID); - for (i = 0; i < sizeof(builtin_plugins)/sizeof(builtin_plugins[0]); i++) { + for (size_t i = 0; i < sizeof(builtin_plugins)/sizeof(builtin_plugins[0]); i++) { if (CFEqual(bundleID, builtin_plugins[i].bundleID)) { bundleInfo->load = builtin_plugins[i].load; bundleInfo->start = builtin_plugins[i].start; @@ -447,7 +439,9 @@ loadBundle(const void *value, void *context) { void -callLoadFunction(const void *value, void *context) { +callLoadFunction(const void *value, void *context) +{ +#pragma unused(context) bundleInfoRef bundleInfo = (bundleInfoRef)value; if (!bundleInfo->loaded) { @@ -473,7 +467,9 @@ callLoadFunction(const void *value, void *context) { void -callStartFunction(const void *value, void *context) { +callStartFunction(const void *value, void *context) +{ +#pragma unused(context) const char *bundleDirName; bundleInfoRef bundleInfo = (bundleInfoRef)value; char bundleName[MAXNAMLEN + 1]; @@ -518,7 +514,9 @@ callStartFunction(const void *value, void *context) { void -callPrimeFunction(const void *value, void *context) { +callPrimeFunction(const void *value, void *context) +{ +#pragma unused(context) bundleInfoRef bundleInfo = (bundleInfoRef)value; if (!bundleInfo->loaded) { @@ -577,6 +575,8 @@ stopComplete(void *info) static void stopDelayed(CFRunLoopTimerRef timer, void *info) { +#pragma unused(timer) +#pragma unused(info) const void **keys; CFIndex i; CFIndex n; @@ -619,7 +619,9 @@ stopRLSCopyDescription(const void *info) static void -stopBundle(const void *value, void *context) { +stopBundle(const void *value, void *context) +{ +#pragma unused(context) bundleInfoRef bundleInfo = (bundleInfoRef)value; CFRunLoopSourceRef stopRls; CFRunLoopSourceContext stopContext = { 0 // version @@ -707,6 +709,7 @@ stopBundles() static CFStringRef termRLSCopyDescription(const void *info) { +#pragma unused(info) return CFStringCreateWithFormat(NULL, NULL, CFSTR("")); } @@ -875,14 +878,13 @@ __private_extern__ void * plugin_exec(void *arg) { - int i; CFIndex nLoaded = 0; /* keep track of bundles */ allBundles = CFArrayCreateMutable(NULL, 0, NULL); /* add white-listed plugins to those we'll allow to be loaded */ - for (i = 0; i < N_PLUGIN_WHITELIST; i++) { + for (size_t i = 0; i < N_PLUGIN_WHITELIST; i++) { if (pluginWhitelist[i] != NULL) { CFSetSetValue(_plugins_allowed, pluginWhitelist[i]); } @@ -995,7 +997,7 @@ plugin_exec(void *arg) * Since xpcd calls getpwuid_r() during its initialization, it will * block until the platform UUID is available. */ - for (i = 0; i < CFArrayGetCount(allBundles); i++) { + for (CFIndex i = 0; i < CFArrayGetCount(allBundles); i++) { bundleInfoRef bi = (bundleInfoRef)CFArrayGetValueAtIndex(allBundles, i); CFStringRef bundleID = CFBundleGetIdentifier(bi->bundle); diff --git a/configd.tproj/session.c b/configd.tproj/session.c index 5ac44c9..9fc7103 100644 --- a/configd.tproj/session.c +++ b/configd.tproj/session.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2000, 2001, 2003-2005, 2007-2016 Apple Inc. All rights reserved. + * Copyright (c) 2000, 2001, 2003-2005, 2007-2017 Apple Inc. All rights reserved. * * @APPLE_LICENSE_HEADER_START@ * @@ -211,7 +211,7 @@ addSession(mach_port_t server, CFStringRef (*copyDescription)(const void *info)) bzero(&opts, sizeof(opts)); opts.flags = MPO_CONTEXT_AS_GUARD; - kr = mach_port_construct(mach_task_self(), &opts, newSession, &mp); + kr = mach_port_construct(mach_task_self(), &opts, (mach_port_context_t)newSession, &mp); #else // HAVE_MACHPORT_GUARDS kr = mach_port_allocate(mach_task_self(), MACH_PORT_RIGHT_RECEIVE, &mp); #endif // HAVE_MACHPORT_GUARDS @@ -319,7 +319,7 @@ cleanupSession(mach_port_t server) * Our send right has already been removed. Remove our receive right. */ #ifdef HAVE_MACHPORT_GUARDS - (void) mach_port_destruct(mach_task_self(), server, 0, thisSession); + (void) mach_port_destruct(mach_task_self(), server, 0, (mach_port_context_t)thisSession); #else // HAVE_MACHPORT_GUARDS (void) mach_port_mod_refs(mach_task_self(), server, MACH_PORT_RIGHT_RECEIVE, -1); #endif // HAVE_MACHPORT_GUARDS @@ -537,6 +537,7 @@ hasRootAccess(serverSessionRef session) return (session->callerRootAccess == YES) ? TRUE : FALSE; #else // !TARGET_OS_SIMULATOR +#pragma unused(session) /* * assume that all processes interacting with @@ -550,7 +551,7 @@ hasRootAccess(serverSessionRef session) __private_extern__ Boolean -hasWriteAccess(serverSessionRef session, CFStringRef key) +hasWriteAccess(serverSessionRef session, const char *op, CFStringRef key) { Boolean isSetup; @@ -572,8 +573,9 @@ hasWriteAccess(serverSessionRef session, CFStringRef key) * general, this is unwise and we should at the * very least complain. */ - SC_log(LOG_NOTICE, "*** Non-configd process (pid=%d) attempting to modify \"%@\" ***", + SC_log(LOG_NOTICE, "*** Non-configd process (pid=%d) attempting to %s \"%@\" ***", pid, + op, key); } diff --git a/configd.tproj/session.h b/configd.tproj/session.h index 9142546..18e8ae7 100644 --- a/configd.tproj/session.h +++ b/configd.tproj/session.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2000, 2001, 2005-2007, 2009-2012, 2014, 2016 Apple Inc. All rights reserved. + * Copyright (c) 2000, 2001, 2005-2007, 2009-2012, 2014, 2016, 2017 Apple Inc. All rights reserved. * * @APPLE_LICENSE_HEADER_START@ * @@ -117,6 +117,7 @@ void listSessions (FILE *f); Boolean hasRootAccess (serverSessionRef session); Boolean hasWriteAccess (serverSessionRef session, + const char *op, CFStringRef key); Boolean hasPathAccess (serverSessionRef session, diff --git a/configd.xcodeproj/project.pbxproj b/configd.xcodeproj/project.pbxproj index ddf7c4a..e00fa48 100644 --- a/configd.xcodeproj/project.pbxproj +++ b/configd.xcodeproj/project.pbxproj @@ -44,16 +44,30 @@ buildPhases = ( ); dependencies = ( + 15631D111ECF92E70088EEDD /* PBXTargetDependency */, 72C4A4801BE44D19009D570E /* PBXTargetDependency */, 1558480607550D470046C2E9 /* PBXTargetDependency */, 1558480807550D470046C2E9 /* PBXTargetDependency */, D6DDAC3D147A24BC00A2E902 /* PBXTargetDependency */, - 72C12CB11D6EA2CA000EE61C /* PBXTargetDependency */, 150ECB300D0042DA0065E94D /* PBXTargetDependency */, + 72C12CB11D6EA2CA000EE61C /* PBXTargetDependency */, ); name = configd_executables; productName = configd_executables; }; + 15631D161ECF98FB0088EEDD /* configd_executables-EmbeddedSimulator */ = { + isa = PBXAggregateTarget; + buildConfigurationList = 15631D231ECF98FB0088EEDD /* Build configuration list for PBXAggregateTarget "configd_executables-EmbeddedSimulator" */; + buildPhases = ( + ); + dependencies = ( + 15631D271ECF99800088EEDD /* PBXTargetDependency */, + 15631D291ECF99800088EEDD /* PBXTargetDependency */, + 15631D2B1ECF99800088EEDD /* PBXTargetDependency */, + ); + name = "configd_executables-EmbeddedSimulator"; + productName = configd_executables; + }; 157BB8AE075924360025DA7A /* configd_base */ = { isa = PBXAggregateTarget; buildConfigurationList = 156EB5E60905594A00EEF749 /* Build configuration list for PBXAggregateTarget "configd_base" */; @@ -83,7 +97,6 @@ ); dependencies = ( 158317120CFB77E1006F62B9 /* PBXTargetDependency */, - 158317140CFB77E8006F62B9 /* PBXTargetDependency */, ); name = "configd_base-Embedded"; productName = Frameworks; @@ -116,9 +129,11 @@ buildPhases = ( ); dependencies = ( + 15631D131ECF93040088EEDD /* PBXTargetDependency */, 158317660CFB80D5006F62B9 /* PBXTargetDependency */, 157434210D4A8166002ACA73 /* PBXTargetDependency */, 1574341F0D4A815E002ACA73 /* PBXTargetDependency */, + 1523BBE21E075859006281F1 /* PBXTargetDependency */, 7271EA341D7660980055B1AA /* PBXTargetDependency */, ); name = "configd_executables-Embedded"; @@ -140,6 +155,8 @@ 158AD98C0754E72500124717 /* PBXTargetDependency */, 159D542C07528E85004F8947 /* PBXTargetDependency */, 158AD98E0754E72500124717 /* PBXTargetDependency */, + 155F49A91C8650E900E47D08 /* PBXTargetDependency */, + 155F49AB1C8650E900E47D08 /* PBXTargetDependency */, ); name = configd_plugins; productName = Plugins; @@ -148,7 +165,7 @@ isa = PBXAggregateTarget; buildConfigurationList = 15C64A270F684C6B00D78394 /* Build configuration list for PBXAggregateTarget "configd_libSystem" */; buildPhases = ( - 1502C5611BDD4936005CF7EA /* Move libsystem_configuration_asan.dylib */, + 1502C5611BDD4936005CF7EA /* Move libsystem_configuration_(asan|tsan).dylib */, ); dependencies = ( 15C64A220F684C4900D78394 /* PBXTargetDependency */, @@ -160,7 +177,7 @@ isa = PBXAggregateTarget; buildConfigurationList = 15C64A2B0F684C6B00D78394 /* Build configuration list for PBXAggregateTarget "configd_libSystem-Embedded" */; buildPhases = ( - 15AC9A4C1BE3ED87003071BD /* Move libsystem_configuration_asan.dylib */, + 15AC9A4C1BE3ED87003071BD /* Move libsystem_configuration_(asan|tsan).dylib */, ); dependencies = ( 15C64A310F684C8F00D78394 /* PBXTargetDependency */, @@ -203,6 +220,7 @@ dependencies = ( 157FDE44164A079B0040D6A8 /* PBXTargetDependency */, 151FE37A0D5B713C000D6DB1 /* PBXTargetDependency */, + 15631D2D1ECF99A00088EEDD /* PBXTargetDependency */, ); name = "All-EmbeddedSimulator"; productName = EmbeddedSimulator; @@ -210,11 +228,15 @@ /* End PBXAggregateTarget section */ /* Begin PBXBuildFile section */ + 1501F7691EA80189006A71B0 /* nat64-configuration.c in Sources */ = {isa = PBXBuildFile; fileRef = 15812A2D1EA5540B001CF384 /* nat64-configuration.c */; }; + 1501F76A1EA8019D006A71B0 /* nat64-configuration.c in Sources */ = {isa = PBXBuildFile; fileRef = 15812A2D1EA5540B001CF384 /* nat64-configuration.c */; }; + 1505A8D81EC3E1470089FC6A /* Foundation.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 725CB7541BF439C6000C05A8 /* Foundation.framework */; }; 15060818075A00A300B147BA /* SCSchemaDefinitions.c in Sources */ = {isa = PBXBuildFile; fileRef = 150607BD075A00A200B147BA /* SCSchemaDefinitions.c */; }; 1506081A075A00A300B147BA /* SCSchemaDefinitions.h in Headers */ = {isa = PBXBuildFile; fileRef = 150607DE075A00A300B147BA /* SCSchemaDefinitions.h */; settings = {ATTRIBUTES = (Public, ); }; }; 150BEC1814CA24F900237116 /* dnsinfo_server.c in Sources */ = {isa = PBXBuildFile; fileRef = 15B73F0D05FD1B670096477F /* dnsinfo_server.c */; }; 150BEC1A14CA252200237116 /* dnsinfo_server.c in Sources */ = {isa = PBXBuildFile; fileRef = 15B73F0D05FD1B670096477F /* dnsinfo_server.c */; }; 150D7E1E0D16DC6C00AF4BED /* Security.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 1520A3DE0846B2DC0010B584 /* Security.framework */; }; + 151D060E1EC14C8600E02E48 /* liblog_SystemConfiguration.m in Sources */ = {isa = PBXBuildFile; fileRef = 151D060D1EC14C6700E02E48 /* liblog_SystemConfiguration.m */; }; 1520A3870846829A0010B584 /* CoreFoundation.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 15CB6A6F05C0722B0099E85F /* CoreFoundation.framework */; }; 1520A3DF0846B2DD0010B584 /* Security.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 1520A3DE0846B2DC0010B584 /* Security.framework */; }; 1522FCFB0FA7FE4B00B24128 /* dnsinfo_flatfile.c in Sources */ = {isa = PBXBuildFile; fileRef = 1522FCE50FA7FD7000B24128 /* dnsinfo_flatfile.c */; }; @@ -242,12 +264,19 @@ 153ACCA914E322D5005029A5 /* network_information_server.c in Sources */ = {isa = PBXBuildFile; fileRef = 153ACCA614E322D5005029A5 /* network_information_server.c */; }; 153ACCAB14E322D5005029A5 /* network_information_server.h in Headers */ = {isa = PBXBuildFile; fileRef = 153ACCA714E322D5005029A5 /* network_information_server.h */; }; 153ACCAC14E322D5005029A5 /* network_information_server.h in Headers */ = {isa = PBXBuildFile; fileRef = 153ACCA714E322D5005029A5 /* network_information_server.h */; }; + 153E16A51EE500810027698E /* SCNetworkReachabilityInternal.h in Headers */ = {isa = PBXBuildFile; fileRef = 15C330D0134B95AA0028E36B /* SCNetworkReachabilityInternal.h */; }; + 153E16A61EE5008A0027698E /* SCNetworkReachabilityInternal.h in Headers */ = {isa = PBXBuildFile; fileRef = 15C330D0134B95AA0028E36B /* SCNetworkReachabilityInternal.h */; }; + 153E16A71EE5008F0027698E /* SCNetworkReachabilityInternal.h in Headers */ = {isa = PBXBuildFile; fileRef = 15C330D0134B95AA0028E36B /* SCNetworkReachabilityInternal.h */; }; + 153E16A81EE500E70027698E /* SCNetworkReachabilityInternal.h in Headers */ = {isa = PBXBuildFile; fileRef = 15C330D0134B95AA0028E36B /* SCNetworkReachabilityInternal.h */; }; + 153E16A91EE500ED0027698E /* SCNetworkReachabilityInternal.h in Headers */ = {isa = PBXBuildFile; fileRef = 15C330D0134B95AA0028E36B /* SCNetworkReachabilityInternal.h */; }; + 153E16AA1EE500EF0027698E /* SCNetworkReachabilityInternal.h in Headers */ = {isa = PBXBuildFile; fileRef = 15C330D0134B95AA0028E36B /* SCNetworkReachabilityInternal.h */; }; 1540E3610987DA9500157C07 /* com.apple.configd.plist in Copy Files */ = {isa = PBXBuildFile; fileRef = 1540E3600987DA9500157C07 /* com.apple.configd.plist */; }; 154361E00752C81800A8EC6C /* set-hostname.c in Sources */ = {isa = PBXBuildFile; fileRef = 159D53AB07528B36004F8947 /* set-hostname.c */; }; 1543636B0752D03C00A8EC6C /* IOKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 1543636A0752D03C00A8EC6C /* IOKit.framework */; }; 154707300D1F70C80075C28D /* SystemConfiguration.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 1547072E0D1F70C80075C28D /* SystemConfiguration.framework */; }; 154707350D1F70C80075C28D /* SystemConfiguration.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 1547072E0D1F70C80075C28D /* SystemConfiguration.framework */; }; 154CF3F407E1EA4D00D8302E /* SCPreferencesGetSpecificPrivate.h in Headers */ = {isa = PBXBuildFile; fileRef = 154CF3F307E1EA4D00D8302E /* SCPreferencesGetSpecificPrivate.h */; settings = {ATTRIBUTES = (Private, ); }; }; + 154FD13B1EC4062C00EDA8B9 /* SystemConfiguration.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 72573D331D66800C004975AD /* SystemConfiguration.framework */; }; 155281020E3E4A0F00C54315 /* ip_plugin.c in Sources */ = {isa = PBXBuildFile; fileRef = 159D53A707528B36004F8947 /* ip_plugin.c */; }; 155847470754FDCD0046C2E9 /* scutil.h in Headers */ = {isa = PBXBuildFile; fileRef = 15CB6A4305C0722B0099E85F /* scutil.h */; }; 155847480754FDCD0046C2E9 /* commands.h in Headers */ = {isa = PBXBuildFile; fileRef = 15CB6A4505C0722B0099E85F /* commands.h */; }; @@ -778,6 +807,33 @@ 15C330D3134B95AA0028E36B /* SCNetworkReachabilityInternal.h in Headers */ = {isa = PBXBuildFile; fileRef = 15C330D0134B95AA0028E36B /* SCNetworkReachabilityInternal.h */; }; 15C8C6BF170AAB4E005375CE /* cache.c in Sources */ = {isa = PBXBuildFile; fileRef = 159D53CA07528B36004F8947 /* cache.c */; }; 15C8C6C0170AAB4E005375CE /* cache.h in Headers */ = {isa = PBXBuildFile; fileRef = 159D53CB07528B36004F8947 /* cache.h */; }; + 15CB8F701EE4DCFC00726685 /* network_state_information_logging.h in Headers */ = {isa = PBXBuildFile; fileRef = 1528922C1EDE41ED00FCFE71 /* network_state_information_logging.h */; }; + 15CB8F711EE4DCFF00726685 /* network_state_information_logging.h in Headers */ = {isa = PBXBuildFile; fileRef = 1528922C1EDE41ED00FCFE71 /* network_state_information_logging.h */; }; + 15CB8F721EE4DD0400726685 /* network_state_information_logging.h in Headers */ = {isa = PBXBuildFile; fileRef = 1528922C1EDE41ED00FCFE71 /* network_state_information_logging.h */; }; + 15CB8F731EE4DD0B00726685 /* network_state_information_logging.h in Headers */ = {isa = PBXBuildFile; fileRef = 1528922C1EDE41ED00FCFE71 /* network_state_information_logging.h */; }; + 15CB8F741EE4DD1000726685 /* network_state_information_logging.h in Headers */ = {isa = PBXBuildFile; fileRef = 1528922C1EDE41ED00FCFE71 /* network_state_information_logging.h */; }; + 15CB8F751EE4DD1100726685 /* network_state_information_logging.h in Headers */ = {isa = PBXBuildFile; fileRef = 1528922C1EDE41ED00FCFE71 /* network_state_information_logging.h */; }; + 15CB8F761EE4DD1600726685 /* network_state_information_logging.h in Headers */ = {isa = PBXBuildFile; fileRef = 1528922C1EDE41ED00FCFE71 /* network_state_information_logging.h */; }; + 15CB8F771EE4DD1900726685 /* network_state_information_logging.h in Headers */ = {isa = PBXBuildFile; fileRef = 1528922C1EDE41ED00FCFE71 /* network_state_information_logging.h */; }; + 15CB8F781EE4DD1B00726685 /* network_state_information_logging.h in Headers */ = {isa = PBXBuildFile; fileRef = 1528922C1EDE41ED00FCFE71 /* network_state_information_logging.h */; }; + 15CB8F791EE4DD3B00726685 /* dnsinfo_logging.h in Headers */ = {isa = PBXBuildFile; fileRef = 1528922D1EDE41ED00FCFE71 /* dnsinfo_logging.h */; }; + 15CB8F7A1EE4DD3E00726685 /* dnsinfo_logging.h in Headers */ = {isa = PBXBuildFile; fileRef = 1528922D1EDE41ED00FCFE71 /* dnsinfo_logging.h */; }; + 15CB8F7B1EE4DD3F00726685 /* dnsinfo_logging.h in Headers */ = {isa = PBXBuildFile; fileRef = 1528922D1EDE41ED00FCFE71 /* dnsinfo_logging.h */; }; + 15CB8F7C1EE4DD4300726685 /* dnsinfo_logging.h in Headers */ = {isa = PBXBuildFile; fileRef = 1528922D1EDE41ED00FCFE71 /* dnsinfo_logging.h */; }; + 15CB8F7D1EE4DD4600726685 /* dnsinfo_logging.h in Headers */ = {isa = PBXBuildFile; fileRef = 1528922D1EDE41ED00FCFE71 /* dnsinfo_logging.h */; }; + 15CB8F7E1EE4DD4800726685 /* dnsinfo_logging.h in Headers */ = {isa = PBXBuildFile; fileRef = 1528922D1EDE41ED00FCFE71 /* dnsinfo_logging.h */; }; + 15CB8F7F1EE4DD4B00726685 /* dnsinfo_logging.h in Headers */ = {isa = PBXBuildFile; fileRef = 1528922D1EDE41ED00FCFE71 /* dnsinfo_logging.h */; }; + 15CB8F801EE4DD4D00726685 /* dnsinfo_logging.h in Headers */ = {isa = PBXBuildFile; fileRef = 1528922D1EDE41ED00FCFE71 /* dnsinfo_logging.h */; }; + 15CB8F811EE4DD4E00726685 /* dnsinfo_logging.h in Headers */ = {isa = PBXBuildFile; fileRef = 1528922D1EDE41ED00FCFE71 /* dnsinfo_logging.h */; }; + 15CB8F821EE4DE1F00726685 /* SCNetworkReachabilityLogging.h in Headers */ = {isa = PBXBuildFile; fileRef = 152EC34B1EE1B10200A1D27B /* SCNetworkReachabilityLogging.h */; }; + 15CB8F831EE4DE2200726685 /* SCNetworkReachabilityLogging.h in Headers */ = {isa = PBXBuildFile; fileRef = 152EC34B1EE1B10200A1D27B /* SCNetworkReachabilityLogging.h */; }; + 15CB8F841EE4DE2600726685 /* SCNetworkReachabilityLogging.h in Headers */ = {isa = PBXBuildFile; fileRef = 152EC34B1EE1B10200A1D27B /* SCNetworkReachabilityLogging.h */; }; + 15CB8F851EE4DE2B00726685 /* SCNetworkReachabilityLogging.h in Headers */ = {isa = PBXBuildFile; fileRef = 152EC34B1EE1B10200A1D27B /* SCNetworkReachabilityLogging.h */; }; + 15CB8F861EE4DE2E00726685 /* SCNetworkReachabilityLogging.h in Headers */ = {isa = PBXBuildFile; fileRef = 152EC34B1EE1B10200A1D27B /* SCNetworkReachabilityLogging.h */; }; + 15CB8F871EE4DE3000726685 /* SCNetworkReachabilityLogging.h in Headers */ = {isa = PBXBuildFile; fileRef = 152EC34B1EE1B10200A1D27B /* SCNetworkReachabilityLogging.h */; }; + 15CB8F881EE4DE3300726685 /* SCNetworkReachabilityLogging.h in Headers */ = {isa = PBXBuildFile; fileRef = 152EC34B1EE1B10200A1D27B /* SCNetworkReachabilityLogging.h */; }; + 15CB8F891EE4DE3600726685 /* SCNetworkReachabilityLogging.h in Headers */ = {isa = PBXBuildFile; fileRef = 152EC34B1EE1B10200A1D27B /* SCNetworkReachabilityLogging.h */; }; + 15CB8F8A1EE4DE3B00726685 /* SCNetworkReachabilityLogging.h in Headers */ = {isa = PBXBuildFile; fileRef = 152EC34B1EE1B10200A1D27B /* SCNetworkReachabilityLogging.h */; }; 15D2E437167643460078F547 /* Security.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 1520A3DE0846B2DC0010B584 /* Security.framework */; }; 15D3083916F3EB8600014F82 /* simulator_support.c in Sources */ = {isa = PBXBuildFile; fileRef = 15D3083816F3EB8600014F82 /* simulator_support.c */; }; 15D3083B16F4E81C00014F82 /* com.apple.configd_sim.plist in CopyFiles */ = {isa = PBXBuildFile; fileRef = 15D3083A16F4E6D900014F82 /* com.apple.configd_sim.plist */; }; @@ -895,6 +951,12 @@ 15E1B05416EBAE3C00E5F06F /* scprefs_observer.c in Sources */ = {isa = PBXBuildFile; fileRef = D61AAEAD1522C99C0066B003 /* scprefs_observer.c */; }; 15E1B05516EBAE3C00E5F06F /* IPMonitorControlPrefs.c in Sources */ = {isa = PBXBuildFile; fileRef = F9A3780E16A4846E00C57CDC /* IPMonitorControlPrefs.c */; }; 15F21618110F823500E89CF7 /* libbsm.dylib in Frameworks */ = {isa = PBXBuildFile; fileRef = 15BAA32207F0699A00D9EC95 /* libbsm.dylib */; }; + 15F742DD1EC6370000DA2E7A /* liblog_SystemConfiguration.m in Sources */ = {isa = PBXBuildFile; fileRef = 151D060D1EC14C6700E02E48 /* liblog_SystemConfiguration.m */; }; + 15F742DF1EC6370000DA2E7A /* Foundation.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 725CB7541BF439C6000C05A8 /* Foundation.framework */; }; + 15F742E01EC6370000DA2E7A /* SystemConfiguration.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 72573D331D66800C004975AD /* SystemConfiguration.framework */; }; + 15F742EA1EC638D100DA2E7A /* liblog_SystemConfiguration.m in Sources */ = {isa = PBXBuildFile; fileRef = 151D060D1EC14C6700E02E48 /* liblog_SystemConfiguration.m */; }; + 15F742EC1EC638D100DA2E7A /* Foundation.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 725CB7541BF439C6000C05A8 /* Foundation.framework */; }; + 15F742ED1EC638D100DA2E7A /* SystemConfiguration.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 72573D331D66800C004975AD /* SystemConfiguration.framework */; }; 15FB1F8A1E27EA8700B4F809 /* InterfaceNamerControlPrefs.c in Sources */ = {isa = PBXBuildFile; fileRef = 15FB1F881E27E9A000B4F809 /* InterfaceNamerControlPrefs.c */; }; 15FB1F8B1E27EA8900B4F809 /* InterfaceNamerControlPrefs.c in Sources */ = {isa = PBXBuildFile; fileRef = 15FB1F881E27E9A000B4F809 /* InterfaceNamerControlPrefs.c */; }; 15FBB54C17D6834C0035D752 /* libCrashReporterClient.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 15FBB54B17D6834C0035D752 /* libCrashReporterClient.a */; }; @@ -1064,6 +1126,13 @@ remoteGlobalIDString = 151FE2DD0D5B7046000D6DB1; remoteInfo = "configd_base-EmbeddedSimulator"; }; + 1523BBE11E075859006281F1 /* PBXContainerItemProxy */ = { + isa = PBXContainerItemProxy; + containerPortal = 15CB6A7705C0722B0099E85F /* Project object */; + proxyType = 1; + remoteGlobalIDString = 158337990CFB6B9E0033AB93; + remoteInfo = "SCHelper-Embedded"; + }; 1558480507550D470046C2E9 /* PBXContainerItemProxy */ = { isa = PBXContainerItemProxy; containerPortal = 15CB6A7705C0722B0099E85F /* Project object */; @@ -1085,6 +1154,20 @@ remoteGlobalIDString = 155847FA07550D210046C2E9; remoteInfo = configd_executables; }; + 155F49A81C8650E900E47D08 /* PBXContainerItemProxy */ = { + isa = PBXContainerItemProxy; + containerPortal = 15CB6A7705C0722B0099E85F /* Project object */; + proxyType = 1; + remoteGlobalIDString = 155F49861C864F1400E47D08; + remoteInfo = QoSMarking; + }; + 155F49AA1C8650E900E47D08 /* PBXContainerItemProxy */ = { + isa = PBXContainerItemProxy; + containerPortal = 15CB6A7705C0722B0099E85F /* Project object */; + proxyType = 1; + remoteGlobalIDString = 155F498E1C864F3700E47D08; + remoteInfo = QoSMarking.bundle; + }; 155F49AC1C86511300E47D08 /* PBXContainerItemProxy */ = { isa = PBXContainerItemProxy; containerPortal = 15CB6A7705C0722B0099E85F /* Project object */; @@ -1099,6 +1182,48 @@ remoteGlobalIDString = 155F499D1C864F5400E47D08; remoteInfo = "QoSMarking.bundle-Embedded"; }; + 15631D101ECF92E70088EEDD /* PBXContainerItemProxy */ = { + isa = PBXContainerItemProxy; + containerPortal = 15CB6A7705C0722B0099E85F /* Project object */; + proxyType = 1; + remoteGlobalIDString = 151D05FA1EC1491600E02E48; + remoteInfo = liblog_SystemConfiguration; + }; + 15631D121ECF93040088EEDD /* PBXContainerItemProxy */ = { + isa = PBXContainerItemProxy; + containerPortal = 15CB6A7705C0722B0099E85F /* Project object */; + proxyType = 1; + remoteGlobalIDString = 15F742DA1EC6370000DA2E7A; + remoteInfo = "liblog_SystemConfiguration-Embedded"; + }; + 15631D261ECF99800088EEDD /* PBXContainerItemProxy */ = { + isa = PBXContainerItemProxy; + containerPortal = 15CB6A7705C0722B0099E85F /* Project object */; + proxyType = 1; + remoteGlobalIDString = 15F742E71EC638D100DA2E7A; + remoteInfo = "liblog_SystemConfiguration-EmbeddedSimulator"; + }; + 15631D281ECF99800088EEDD /* PBXContainerItemProxy */ = { + isa = PBXContainerItemProxy; + containerPortal = 15CB6A7705C0722B0099E85F /* Project object */; + proxyType = 1; + remoteGlobalIDString = 15732A7616EA503200F3AC4C; + remoteInfo = "configd-EmbeddedSimulator"; + }; + 15631D2A1ECF99800088EEDD /* PBXContainerItemProxy */ = { + isa = PBXContainerItemProxy; + containerPortal = 15CB6A7705C0722B0099E85F /* Project object */; + proxyType = 1; + remoteGlobalIDString = 15732AAD16EA511900F3AC4C; + remoteInfo = "scutil-EmbeddedSimulator"; + }; + 15631D2C1ECF99A00088EEDD /* PBXContainerItemProxy */ = { + isa = PBXContainerItemProxy; + containerPortal = 15CB6A7705C0722B0099E85F /* Project object */; + proxyType = 1; + remoteGlobalIDString = 15631D161ECF98FB0088EEDD; + remoteInfo = "configd_executables-EmbeddedSimulator"; + }; 15732AE516EA6BCE00F3AC4C /* PBXContainerItemProxy */ = { isa = PBXContainerItemProxy; containerPortal = 15CB6A7705C0722B0099E85F /* Project object */; @@ -1204,13 +1329,6 @@ remoteGlobalIDString = 1572C4A60CFB55B400E2776E; remoteInfo = "SystemConfiguration.framework-Embedded"; }; - 158317130CFB77E8006F62B9 /* PBXContainerItemProxy */ = { - isa = PBXContainerItemProxy; - containerPortal = 15CB6A7705C0722B0099E85F /* Project object */; - proxyType = 1; - remoteGlobalIDString = 158337990CFB6B9E0033AB93; - remoteInfo = "SCHelper-Embedded"; - }; 158317150CFB783B006F62B9 /* PBXContainerItemProxy */ = { isa = PBXContainerItemProxy; containerPortal = 15CB6A7705C0722B0099E85F /* Project object */; @@ -1658,9 +1776,12 @@ 150607BD075A00A200B147BA /* SCSchemaDefinitions.c */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.c; path = SCSchemaDefinitions.c; sourceTree = ""; }; 150607DE075A00A300B147BA /* SCSchemaDefinitions.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = SCSchemaDefinitions.h; sourceTree = ""; }; 151356AD0CE0CF2F0017E523 /* com.apple.SCHelper-embedded.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; name = "com.apple.SCHelper-embedded.plist"; path = "helper/com.apple.SCHelper-embedded.plist"; sourceTree = ""; }; + 1513C3551F1849B50022398F /* update-sanitizer-dylib-references */ = {isa = PBXFileReference; indentWidth = 4; lastKnownFileType = text; path = "update-sanitizer-dylib-references"; sourceTree = SOURCE_ROOT; tabWidth = 8; }; 1514D76D05C08A5F00757DC9 /* config_types.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; name = config_types.h; path = SystemConfiguration.fproj/config_types.h; sourceTree = SOURCE_ROOT; }; 151BDA2B05D9E28B00657BC7 /* SCPreferencesPathKey.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; name = SCPreferencesPathKey.h; path = SystemConfiguration.fproj/SCPreferencesPathKey.h; sourceTree = SOURCE_ROOT; }; 151BDA5D05D9E2ED00657BC7 /* SCPreferencesPathKey.c */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.c; name = SCPreferencesPathKey.c; path = SystemConfiguration.fproj/SCPreferencesPathKey.c; sourceTree = SOURCE_ROOT; }; + 151D060B1EC1491600E02E48 /* liblog_SystemConfiguration.dylib */ = {isa = PBXFileReference; explicitFileType = "compiled.mach-o.dylib"; includeInIndex = 0; path = liblog_SystemConfiguration.dylib; sourceTree = BUILT_PRODUCTS_DIR; }; + 151D060D1EC14C6700E02E48 /* liblog_SystemConfiguration.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = liblog_SystemConfiguration.m; path = logging/liblog_SystemConfiguration.m; sourceTree = SOURCE_ROOT; }; 151F5D9A0CCE98E50093AC3B /* SCMonitor.plugin */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = SCMonitor.plugin; sourceTree = BUILT_PRODUCTS_DIR; }; 151F63EC09328A3C0096DCC9 /* genSCPreferences */ = {isa = PBXFileReference; explicitFileType = "compiled.mach-o.executable"; includeInIndex = 0; path = genSCPreferences; sourceTree = BUILT_PRODUCTS_DIR; }; 1520A3DE0846B2DC0010B584 /* Security.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Security.framework; path = /System/Library/Frameworks/Security.framework; sourceTree = ""; }; @@ -1670,11 +1791,14 @@ 152439E418038E5B00D91708 /* ev_extra.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = ev_extra.m; sourceTree = ""; }; 152439E7180399D800D91708 /* CoreWLAN.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = CoreWLAN.framework; path = /System/Library/Frameworks/CoreWLAN.framework; sourceTree = ""; }; 152439EB180716ED00D91708 /* MobileWiFi.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = MobileWiFi.framework; path = Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS7.0.Internal.sdk/System/Library/PrivateFrameworks/MobileWiFi.framework; sourceTree = DEVELOPER_DIR; }; + 1528922C1EDE41ED00FCFE71 /* network_state_information_logging.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = network_state_information_logging.h; path = nwi/network_state_information_logging.h; sourceTree = ""; }; + 1528922D1EDE41ED00FCFE71 /* dnsinfo_logging.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = dnsinfo_logging.h; path = dnsinfo/dnsinfo_logging.h; sourceTree = ""; }; 152CEED0070CF6640050F23C /* libedit.dylib */ = {isa = PBXFileReference; lastKnownFileType = "compiled.mach-o.dylib"; name = libedit.dylib; path = /usr/lib/libedit.2.dylib; sourceTree = ""; }; 152E0E7E10FE820E00E402F2 /* helper.defs */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.mig; name = helper.defs; path = SystemConfiguration.fproj/helper/helper.defs; sourceTree = ""; }; 152E0E8810FE824000E402F2 /* helper_types.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = helper_types.h; path = SystemConfiguration.fproj/helper/helper_types.h; sourceTree = ""; }; 152E68C00A2C89C70011FDA8 /* SCPreferencesKeychainPrivate.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = SCPreferencesKeychainPrivate.h; sourceTree = ""; }; 152E68C20A2C89E30011FDA8 /* SCPreferencesKeychainPrivate.c */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.c; path = SCPreferencesKeychainPrivate.c; sourceTree = ""; }; + 152EC34B1EE1B10200A1D27B /* SCNetworkReachabilityLogging.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = SCNetworkReachabilityLogging.h; sourceTree = ""; }; 1532629006281C9D00B1C10C /* dnsinfo_create.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; name = dnsinfo_create.h; path = dnsinfo/dnsinfo_create.h; sourceTree = ""; }; 153338BA14BE7978004FCE22 /* libSystemConfiguration_client.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; name = libSystemConfiguration_client.c; path = libSystemConfiguration/libSystemConfiguration_client.c; sourceTree = ""; }; 153338BB14BE7978004FCE22 /* libSystemConfiguration_client.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = libSystemConfiguration_client.h; path = libSystemConfiguration/libSystemConfiguration_client.h; sourceTree = ""; }; @@ -1727,6 +1851,8 @@ 157A852E0D56C91100B6F1A0 /* libLinkConfiguration.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = libLinkConfiguration.a; sourceTree = BUILT_PRODUCTS_DIR; }; 157A85440D56C96F00B6F1A0 /* libPreferencesMonitor.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = libPreferencesMonitor.a; sourceTree = BUILT_PRODUCTS_DIR; }; 157A88880A470D0F003A4256 /* SCSchemaDefinitionsPrivate.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = SCSchemaDefinitionsPrivate.h; sourceTree = ""; }; + 15812A2D1EA5540B001CF384 /* nat64-configuration.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = "nat64-configuration.c"; sourceTree = ""; }; + 15812A2E1EA5540B001CF384 /* nat64-configuration.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "nat64-configuration.h"; sourceTree = ""; }; 15828AE70753B5F900AD4710 /* KernelEventMonitor.bundle */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = KernelEventMonitor.bundle; sourceTree = BUILT_PRODUCTS_DIR; }; 158AD8700754E3D400124717 /* Info.plist */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; 158AD8C00754E3EF00124717 /* Info.plist */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; @@ -1928,6 +2054,8 @@ 15DC346E0711D49400A3311C /* net_set.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = net_set.h; sourceTree = ""; }; 15E1B05916EBAE3C00E5F06F /* libIPMonitor_sim.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = libIPMonitor_sim.a; sourceTree = BUILT_PRODUCTS_DIR; }; 15E1B06116EBAE7800E5F06F /* IPMonitor.bundle */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = IPMonitor.bundle; sourceTree = BUILT_PRODUCTS_DIR; }; + 15F742E41EC6370000DA2E7A /* liblog_SystemConfiguration.dylib */ = {isa = PBXFileReference; explicitFileType = "compiled.mach-o.dylib"; includeInIndex = 0; path = liblog_SystemConfiguration.dylib; sourceTree = BUILT_PRODUCTS_DIR; }; + 15F742F11EC638D100DA2E7A /* liblog_SystemConfiguration.dylib */ = {isa = PBXFileReference; explicitFileType = "compiled.mach-o.dylib"; includeInIndex = 0; path = liblog_SystemConfiguration.dylib; sourceTree = BUILT_PRODUCTS_DIR; }; 15FB1F881E27E9A000B4F809 /* InterfaceNamerControlPrefs.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = InterfaceNamerControlPrefs.c; sourceTree = ""; }; 15FB1F891E27E9A000B4F809 /* InterfaceNamerControlPrefs.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = InterfaceNamerControlPrefs.h; sourceTree = ""; }; 15FBB54B17D6834C0035D752 /* libCrashReporterClient.a */ = {isa = PBXFileReference; lastKnownFileType = archive.ar; name = libCrashReporterClient.a; path = /usr/local/lib/libCrashReporterClient.a; sourceTree = ""; }; @@ -1968,7 +2096,6 @@ 72573D431D6B9E72004975AD /* sctest-entitlements.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; name = "sctest-entitlements.plist"; path = "sctest/sctest-entitlements.plist"; sourceTree = SOURCE_ROOT; }; 725CB7541BF439C6000C05A8 /* Foundation.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Foundation.framework; path = System/Library/Frameworks/Foundation.framework; sourceTree = SDKROOT; }; 725CB7571BF51476000C05A8 /* configAgentDefines.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = configAgentDefines.h; sourceTree = ""; }; - 725E53D51A92D2A5009997E1 /* com.apple.networking.IPMonitor */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = com.apple.networking.IPMonitor; sourceTree = ""; }; 726DB2F11BEA80E5001B2C6C /* config_agent_info.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; name = config_agent_info.c; path = "config-agent-info/config_agent_info.c"; sourceTree = ""; }; 726DB2F21BEA80E5001B2C6C /* config_agent_info.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = config_agent_info.h; path = "config-agent-info/config_agent_info.h"; sourceTree = ""; }; 7271EA321D76600B0055B1AA /* sctest */ = {isa = PBXFileReference; explicitFileType = "compiled.mach-o.executable"; includeInIndex = 0; path = sctest; sourceTree = BUILT_PRODUCTS_DIR; }; @@ -2027,6 +2154,15 @@ /* End PBXFileReference section */ /* Begin PBXFrameworksBuildPhase section */ + 151D06061EC1491600E02E48 /* Frameworks */ = { + isa = PBXFrameworksBuildPhase; + buildActionMask = 2147483647; + files = ( + 1505A8D81EC3E1470089FC6A /* Foundation.framework in Frameworks */, + 154FD13B1EC4062C00EDA8B9 /* SystemConfiguration.framework in Frameworks */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; 151F5D980CCE98E50093AC3B /* Frameworks */ = { isa = PBXFrameworksBuildPhase; buildActionMask = 2147483647; @@ -2205,6 +2341,24 @@ ); runOnlyForDeploymentPostprocessing = 0; }; + 15F742DE1EC6370000DA2E7A /* Frameworks */ = { + isa = PBXFrameworksBuildPhase; + buildActionMask = 2147483647; + files = ( + 15F742DF1EC6370000DA2E7A /* Foundation.framework in Frameworks */, + 15F742E01EC6370000DA2E7A /* SystemConfiguration.framework in Frameworks */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; + 15F742EB1EC638D100DA2E7A /* Frameworks */ = { + isa = PBXFrameworksBuildPhase; + buildActionMask = 2147483647; + files = ( + 15F742EC1EC638D100DA2E7A /* Foundation.framework in Frameworks */, + 15F742ED1EC638D100DA2E7A /* SystemConfiguration.framework in Frameworks */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; 72573D231D667372004975AD /* Frameworks */ = { isa = PBXFrameworksBuildPhase; buildActionMask = 2147483647; @@ -2244,6 +2398,22 @@ /* End PBXFrameworksBuildPhase section */ /* Begin PBXGroup section */ + 1513C3541F1849920022398F /* Build Support */ = { + isa = PBXGroup; + children = ( + 1513C3551F1849B50022398F /* update-sanitizer-dylib-references */, + ); + name = "Build Support"; + sourceTree = ""; + }; + 151D060C1EC14C3900E02E48 /* Logging */ = { + isa = PBXGroup; + children = ( + 151D060D1EC14C6700E02E48 /* liblog_SystemConfiguration.m */, + ); + name = Logging; + sourceTree = ""; + }; 151F5DA80CCE995D0093AC3B /* SCMonitor */ = { isa = PBXGroup; children = ( @@ -2381,6 +2551,7 @@ 15B73F0905FD1B670096477F /* dnsinfo.h */, 1532629006281C9D00B1C10C /* dnsinfo_create.h */, 159C9A8D17399609003DDA1D /* dnsinfo_internal.h */, + 1528922D1EDE41ED00FCFE71 /* dnsinfo_logging.h */, 15B73F0C05FD1B670096477F /* dnsinfo_private.h */, 15B73F0E05FD1B670096477F /* dnsinfo_server.h */, ); @@ -2444,13 +2615,14 @@ isa = PBXGroup; children = ( 728015741BE1681B009F4F60 /* AgentMonitor */, - 725E53D41A92D289009997E1 /* Simulator */, D6AEB89815AE4446009F2FAF /* ip_plugin.h */, 159D53A707528B36004F8947 /* ip_plugin.c */, 155D22380AF13A7300D52ED0 /* dns-configuration.h */, 159D53AA07528B36004F8947 /* dns-configuration.c */, - 1575FD2512CD15C60003D86E /* proxy-configuration.c */, + 15812A2E1EA5540B001CF384 /* nat64-configuration.h */, + 15812A2D1EA5540B001CF384 /* nat64-configuration.c */, 1575FD2612CD15C60003D86E /* proxy-configuration.h */, + 1575FD2512CD15C60003D86E /* proxy-configuration.c */, 155D22390AF13A7300D52ED0 /* set-hostname.h */, 159D53AB07528B36004F8947 /* set-hostname.c */, 155D223A0AF13A7300D52ED0 /* smb-configuration.h */, @@ -2569,6 +2741,7 @@ children = ( 15CB693705C0722B0099E85F /* SCNetworkReachability.h */, 15C330D0134B95AA0028E36B /* SCNetworkReachabilityInternal.h */, + 152EC34B1EE1B10200A1D27B /* SCNetworkReachabilityLogging.h */, ); name = Headers; sourceTree = ""; @@ -2782,9 +2955,11 @@ 15CB68FC05C072220099E85F /* configd */ = { isa = PBXGroup; children = ( + 1513C3541F1849920022398F /* Build Support */, 15CB6A8605C072500099E85F /* MiG */, 15CB6A8305C072410099E85F /* Schema */, 15B534AD14BE778800EA6522 /* libsystem_configuration */, + 151D060C1EC14C3900E02E48 /* Logging */, 15CB690705C0722A0099E85F /* SystemConfiguration */, 151F5DA80CCE995D0093AC3B /* SCMonitor */, 15CB69C205C0722B0099E85F /* configd */, @@ -2846,6 +3021,9 @@ 155F49A21C864F5400E47D08 /* QoSMarking.bundle */, 72573D261D667372004975AD /* sctest */, 7271EA321D76600B0055B1AA /* sctest */, + 151D060B1EC1491600E02E48 /* liblog_SystemConfiguration.dylib */, + 15F742E41EC6370000DA2E7A /* liblog_SystemConfiguration.dylib */, + 15F742F11EC638D100DA2E7A /* liblog_SystemConfiguration.dylib */, ); name = Products; sourceTree = ""; @@ -3127,14 +3305,6 @@ path = sctest; sourceTree = ""; }; - 725E53D41A92D289009997E1 /* Simulator */ = { - isa = PBXGroup; - children = ( - 725E53D51A92D2A5009997E1 /* com.apple.networking.IPMonitor */, - ); - path = Simulator; - sourceTree = ""; - }; 726DB2F01BEA8075001B2C6C /* ConfigAgentInformation */ = { isa = PBXGroup; children = ( @@ -3201,6 +3371,7 @@ isa = PBXGroup; children = ( D6986A781368913C0091C931 /* network_information.h */, + 1528922C1EDE41ED00FCFE71 /* network_state_information_logging.h */, D6986A761368911E0091C931 /* network_state_information_priv.h */, 720985431C580D9F00966D30 /* network_config_agent_info_priv.h */, 153ACCA714E322D5005029A5 /* network_information_server.h */, @@ -3236,6 +3407,16 @@ /* End PBXGroup section */ /* Begin PBXHeadersBuildPhase section */ + 151D05FB1EC1491600E02E48 /* Headers */ = { + isa = PBXHeadersBuildPhase; + buildActionMask = 2147483647; + files = ( + 15CB8F7A1EE4DD3E00726685 /* dnsinfo_logging.h in Headers */, + 15CB8F721EE4DD0400726685 /* network_state_information_logging.h in Headers */, + 15CB8F841EE4DE2600726685 /* SCNetworkReachabilityLogging.h in Headers */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; 1547001908455B98006787CE /* Headers */ = { isa = PBXHeadersBuildPhase; buildActionMask = 2147483647; @@ -3249,22 +3430,26 @@ isa = PBXHeadersBuildPhase; buildActionMask = 2147483647; files = ( - 155847470754FDCD0046C2E9 /* scutil.h in Headers */, + 1558474B0754FDCD0046C2E9 /* cache.h in Headers */, 155847480754FDCD0046C2E9 /* commands.h in Headers */, 155847490754FDCD0046C2E9 /* dictionary.h in Headers */, - 1558474A0754FDCD0046C2E9 /* session.h in Headers */, - 1558474B0754FDCD0046C2E9 /* cache.h in Headers */, - 1558474C0754FDCD0046C2E9 /* notifications.h in Headers */, - 1558474D0754FDCD0046C2E9 /* tests.h in Headers */, - 1558474E0754FDCD0046C2E9 /* prefs.h in Headers */, + 15CB8F7B1EE4DD3F00726685 /* dnsinfo_logging.h in Headers */, + 72B43728113C7BFC00EBF1B6 /* nc.h in Headers */, 1558474F0754FDCD0046C2E9 /* net.h in Headers */, + 15CB8F711EE4DCFF00726685 /* network_state_information_logging.h in Headers */, 155847500754FDCD0046C2E9 /* net_interface.h in Headers */, 155847510754FDCD0046C2E9 /* net_protocol.h in Headers */, 155847520754FDCD0046C2E9 /* net_service.h in Headers */, 155847530754FDCD0046C2E9 /* net_set.h in Headers */, - 72B43728113C7BFC00EBF1B6 /* nc.h in Headers */, + 1558474C0754FDCD0046C2E9 /* notifications.h in Headers */, + 1558474E0754FDCD0046C2E9 /* prefs.h in Headers */, + 155847470754FDCD0046C2E9 /* scutil.h in Headers */, + 1558474A0754FDCD0046C2E9 /* session.h in Headers */, + 1558474D0754FDCD0046C2E9 /* tests.h in Headers */, 1581BCD31E28679A00F69B1E /* InterfaceNamerControlPrefs.h in Headers */, 1581BCD51E2867A500F69B1E /* IPMonitorControlPrefs.h in Headers */, + 153E16A81EE500E70027698E /* SCNetworkReachabilityInternal.h in Headers */, + 15CB8F831EE4DE2200726685 /* SCNetworkReachabilityLogging.h in Headers */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -3368,21 +3553,25 @@ isa = PBXHeadersBuildPhase; buildActionMask = 2147483647; files = ( - 15732AAF16EA511900F3AC4C /* scutil.h in Headers */, + 15732AB316EA511900F3AC4C /* cache.h in Headers */, 15732AB016EA511900F3AC4C /* commands.h in Headers */, 15732AB116EA511900F3AC4C /* dictionary.h in Headers */, - 15732AB216EA511900F3AC4C /* session.h in Headers */, - 15732AB316EA511900F3AC4C /* cache.h in Headers */, - 15732AB416EA511900F3AC4C /* notifications.h in Headers */, - 15732AB516EA511900F3AC4C /* tests.h in Headers */, - 15732AB616EA511900F3AC4C /* prefs.h in Headers */, + 15CB8F811EE4DD4E00726685 /* dnsinfo_logging.h in Headers */, + 15732ABC16EA511900F3AC4C /* nc.h in Headers */, 15732AB716EA511900F3AC4C /* net.h in Headers */, + 15CB8F771EE4DD1900726685 /* network_state_information_logging.h in Headers */, 15732AB816EA511900F3AC4C /* net_interface.h in Headers */, 15732AB916EA511900F3AC4C /* net_protocol.h in Headers */, 15732ABA16EA511900F3AC4C /* net_service.h in Headers */, 15732ABB16EA511900F3AC4C /* net_set.h in Headers */, - 15732ABC16EA511900F3AC4C /* nc.h in Headers */, + 15732AB416EA511900F3AC4C /* notifications.h in Headers */, + 15732AB616EA511900F3AC4C /* prefs.h in Headers */, + 15732AAF16EA511900F3AC4C /* scutil.h in Headers */, + 15732AB216EA511900F3AC4C /* session.h in Headers */, + 15732AB516EA511900F3AC4C /* tests.h in Headers */, 1581BCD91E2867C100F69B1E /* IPMonitorControlPrefs.h in Headers */, + 153E16AA1EE500EF0027698E /* SCNetworkReachabilityInternal.h in Headers */, + 15CB8F8A1EE4DE3B00726685 /* SCNetworkReachabilityLogging.h in Headers */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -3408,22 +3597,26 @@ isa = PBXHeadersBuildPhase; buildActionMask = 2147483647; files = ( - 157433F20D4A8137002ACA73 /* scutil.h in Headers */, + 157433F60D4A8137002ACA73 /* cache.h in Headers */, 157433F30D4A8137002ACA73 /* commands.h in Headers */, 157433F40D4A8137002ACA73 /* dictionary.h in Headers */, - 157433F50D4A8137002ACA73 /* session.h in Headers */, - 157433F60D4A8137002ACA73 /* cache.h in Headers */, - 157433F70D4A8137002ACA73 /* notifications.h in Headers */, - 157433F80D4A8137002ACA73 /* tests.h in Headers */, - 157433F90D4A8137002ACA73 /* prefs.h in Headers */, + 15CB8F7E1EE4DD4800726685 /* dnsinfo_logging.h in Headers */, + 72B4372A113C7BFC00EBF1B6 /* nc.h in Headers */, 157433FA0D4A8137002ACA73 /* net.h in Headers */, + 15CB8F751EE4DD1100726685 /* network_state_information_logging.h in Headers */, 157433FB0D4A8137002ACA73 /* net_interface.h in Headers */, 157433FC0D4A8137002ACA73 /* net_protocol.h in Headers */, 157433FD0D4A8137002ACA73 /* net_service.h in Headers */, 157433FE0D4A8137002ACA73 /* net_set.h in Headers */, - 72B4372A113C7BFC00EBF1B6 /* nc.h in Headers */, + 157433F70D4A8137002ACA73 /* notifications.h in Headers */, + 157433F90D4A8137002ACA73 /* prefs.h in Headers */, + 157433F20D4A8137002ACA73 /* scutil.h in Headers */, + 157433F50D4A8137002ACA73 /* session.h in Headers */, + 157433F80D4A8137002ACA73 /* tests.h in Headers */, 1581BCDD1E286E0000F69B1E /* InterfaceNamerControlPrefs.h in Headers */, 1581BCD71E2867B200F69B1E /* IPMonitorControlPrefs.h in Headers */, + 153E16A91EE500ED0027698E /* SCNetworkReachabilityInternal.h in Headers */, + 15CB8F861EE4DE2E00726685 /* SCNetworkReachabilityLogging.h in Headers */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -3443,24 +3636,28 @@ isa = PBXHeadersBuildPhase; buildActionMask = 2147483647; files = ( - F9B7AE6C186211DE00C78D18 /* IPMonitorControlServer.h in Headers */, - 157A84F60D56C7E800B6F1A0 /* dns-configuration.h in Headers */, + 720985471C5835DB00966D30 /* agent-monitor.h in Headers */, 720A4C0B1C585C93007436B8 /* controller.h in Headers */, - 15D48EC20F67061F00B4711E /* dnsinfo_create.h in Headers */, + 720A4C0A1C585C7D007436B8 /* configAgent.h in Headers */, + 725CB7591BF514F5000C05A8 /* configAgentDefines.h in Headers */, 720A4C0C1C585C97007436B8 /* dnsAgent.h in Headers */, + 15D48EC20F67061F00B4711E /* dnsinfo_create.h in Headers */, + 15CB8F7C1EE4DD4300726685 /* dnsinfo_logging.h in Headers */, + 157A84F60D56C7E800B6F1A0 /* dns-configuration.h in Headers */, + 1596A7B514EDB73D00798C39 /* libSystemConfiguration_server.h in Headers */, 720985451C580D9F00966D30 /* network_config_agent_info_priv.h in Headers */, + 153ACCAC14E322D5005029A5 /* network_information_server.h in Headers */, + 15CB8F731EE4DD0B00726685 /* network_state_information_logging.h in Headers */, E4F211D4137B0ABD00BBB915 /* network_state_information_priv.h in Headers */, 720A4C0D1C585C9F007436B8 /* proxyAgent.h in Headers */, 1575FD2812CD15C60003D86E /* proxy-configuration.h in Headers */, - F9B7AE6F186211F600C78D18 /* symbol_scope.h in Headers */, - F9B7AE68186211C900C78D18 /* IPMonitorControlPrivate.h in Headers */, - 725CB7591BF514F5000C05A8 /* configAgentDefines.h in Headers */, - 720985471C5835DB00966D30 /* agent-monitor.h in Headers */, 157A84F70D56C7E800B6F1A0 /* set-hostname.h in Headers */, - 153ACCAC14E322D5005029A5 /* network_information_server.h in Headers */, - 720A4C0A1C585C7D007436B8 /* configAgent.h in Headers */, - 1596A7B514EDB73D00798C39 /* libSystemConfiguration_server.h in Headers */, + F9B7AE6F186211F600C78D18 /* symbol_scope.h in Headers */, 1581BCD61E2867AF00F69B1E /* IPMonitorControlPrefs.h in Headers */, + F9B7AE68186211C900C78D18 /* IPMonitorControlPrivate.h in Headers */, + F9B7AE6C186211DE00C78D18 /* IPMonitorControlServer.h in Headers */, + 153E16A61EE5008A0027698E /* SCNetworkReachabilityInternal.h in Headers */, + 15CB8F851EE4DE2B00726685 /* SCNetworkReachabilityLogging.h in Headers */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -3550,24 +3747,28 @@ buildActionMask = 2147483647; files = ( 728015991BE1812B009F4F60 /* agent-monitor.h in Headers */, - 7280159B1BE1812B009F4F60 /* configAgent.h in Headers */, 7280159C1BE1812B009F4F60 /* controller.h in Headers */, + 7280159B1BE1812B009F4F60 /* configAgent.h in Headers */, + 725CB7581BF514F2000C05A8 /* configAgentDefines.h in Headers */, + 15D48EC00F67061700B4711E /* dnsinfo_create.h in Headers */, + 15CB8F791EE4DD3B00726685 /* dnsinfo_logging.h in Headers */, 7280159D1BE1812B009F4F60 /* dnsAgent.h in Headers */, - 7280159E1BE1812B009F4F60 /* proxyAgent.h in Headers */, 155D223B0AF13A7300D52ED0 /* dns-configuration.h in Headers */, - 1581BCD41E2867A300F69B1E /* IPMonitorControlPrefs.h in Headers */, - 15D48EC00F67061700B4711E /* dnsinfo_create.h in Headers */, - 725CB7581BF514F2000C05A8 /* configAgentDefines.h in Headers */, - E4F211D7137B0AF200BBB915 /* network_state_information_priv.h in Headers */, + 1596A7B414EDB73D00798C39 /* libSystemConfiguration_server.h in Headers */, 720985441C580D9F00966D30 /* network_config_agent_info_priv.h in Headers */, + 153ACCAB14E322D5005029A5 /* network_information_server.h in Headers */, + 15CB8F701EE4DCFC00726685 /* network_state_information_logging.h in Headers */, + E4F211D7137B0AF200BBB915 /* network_state_information_priv.h in Headers */, + 7280159E1BE1812B009F4F60 /* proxyAgent.h in Headers */, 1575FD2A12CD15C60003D86E /* proxy-configuration.h in Headers */, 155D223C0AF13A7300D52ED0 /* set-hostname.h in Headers */, - F9B7AE67186211C200C78D18 /* IPMonitorControlPrivate.h in Headers */, - F9B7AE6E186211F000C78D18 /* symbol_scope.h in Headers */, 155D223D0AF13A7300D52ED0 /* smb-configuration.h in Headers */, + F9B7AE6E186211F000C78D18 /* symbol_scope.h in Headers */, + 1581BCD41E2867A300F69B1E /* IPMonitorControlPrefs.h in Headers */, + F9B7AE67186211C200C78D18 /* IPMonitorControlPrivate.h in Headers */, F9B7AE6B186211DA00C78D18 /* IPMonitorControlServer.h in Headers */, - 153ACCAB14E322D5005029A5 /* network_information_server.h in Headers */, - 1596A7B414EDB73D00798C39 /* libSystemConfiguration_server.h in Headers */, + 153E16A51EE500810027698E /* SCNetworkReachabilityInternal.h in Headers */, + 15CB8F821EE4DE1F00726685 /* SCNetworkReachabilityLogging.h in Headers */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -3743,19 +3944,62 @@ isa = PBXHeadersBuildPhase; buildActionMask = 2147483647; files = ( - 15E1B04316EBAE3C00E5F06F /* dns-configuration.h in Headers */, 15E1B04416EBAE3C00E5F06F /* dnsinfo_create.h in Headers */, + 15CB8F7F1EE4DD4B00726685 /* dnsinfo_logging.h in Headers */, + 15E1B04316EBAE3C00E5F06F /* dns-configuration.h in Headers */, + 15E1B04916EBAE3C00E5F06F /* libSystemConfiguration_server.h in Headers */, + 15E1B04816EBAE3C00E5F06F /* network_information_server.h in Headers */, + 15CB8F761EE4DD1600726685 /* network_state_information_logging.h in Headers */, 15E1B04516EBAE3C00E5F06F /* network_state_information_priv.h in Headers */, 15E1B04616EBAE3C00E5F06F /* proxy-configuration.h in Headers */, - 15E1B04816EBAE3C00E5F06F /* network_information_server.h in Headers */, 1581BCD81E2867BA00F69B1E /* IPMonitorControlPrefs.h in Headers */, - 15E1B04916EBAE3C00E5F06F /* libSystemConfiguration_server.h in Headers */, + 153E16A71EE5008F0027698E /* SCNetworkReachabilityInternal.h in Headers */, + 15CB8F881EE4DE3300726685 /* SCNetworkReachabilityLogging.h in Headers */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; + 15F742DB1EC6370000DA2E7A /* Headers */ = { + isa = PBXHeadersBuildPhase; + buildActionMask = 2147483647; + files = ( + 15CB8F7D1EE4DD4600726685 /* dnsinfo_logging.h in Headers */, + 15CB8F741EE4DD1000726685 /* network_state_information_logging.h in Headers */, + 15CB8F871EE4DE3000726685 /* SCNetworkReachabilityLogging.h in Headers */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; + 15F742E81EC638D100DA2E7A /* Headers */ = { + isa = PBXHeadersBuildPhase; + buildActionMask = 2147483647; + files = ( + 15CB8F801EE4DD4D00726685 /* dnsinfo_logging.h in Headers */, + 15CB8F781EE4DD1B00726685 /* network_state_information_logging.h in Headers */, + 15CB8F891EE4DE3600726685 /* SCNetworkReachabilityLogging.h in Headers */, ); runOnlyForDeploymentPostprocessing = 0; }; /* End PBXHeadersBuildPhase section */ /* Begin PBXNativeTarget section */ + 151D05FA1EC1491600E02E48 /* liblog_SystemConfiguration */ = { + isa = PBXNativeTarget; + buildConfigurationList = 151D06081EC1491600E02E48 /* Build configuration list for PBXNativeTarget "liblog_SystemConfiguration" */; + buildPhases = ( + 151D05FB1EC1491600E02E48 /* Headers */, + 151D06011EC1491600E02E48 /* Sources */, + 151D06061EC1491600E02E48 /* Frameworks */, + 1513C35A1F186A700022398F /* Update "install_path" for address|thread sanitizers */, + ); + buildRules = ( + ); + dependencies = ( + ); + name = liblog_SystemConfiguration; + productInstallPath = /usr/local/lib/system; + productName = DNSConfiguration; + productReference = 151D060B1EC1491600E02E48 /* liblog_SystemConfiguration.dylib */; + productType = "com.apple.product-type.library.dynamic"; + }; 151F5D990CCE98E50093AC3B /* SCMonitor */ = { isa = PBXNativeTarget; buildConfigurationList = 151F5D9F0CCE98E60093AC3B /* Build configuration list for PBXNativeTarget "SCMonitor" */; @@ -3763,6 +4007,7 @@ 151F5D960CCE98E50093AC3B /* Resources */, 151F5D970CCE98E50093AC3B /* Sources */, 151F5D980CCE98E50093AC3B /* Frameworks */, + 1513C3591F18697C0022398F /* Update "install_path" for address|thread sanitizers */, ); buildRules = ( ); @@ -3796,6 +4041,7 @@ 1547001908455B98006787CE /* Headers */, 1547001A08455B98006787CE /* Sources */, 1547001B08455B98006787CE /* Frameworks */, + 15A66BB21F1817AC00F7253B /* Update "install_path" for address|thread sanitizers */, 15FF5C380CDF778F00EEC8AA /* CopyFiles */, ); buildRules = ( @@ -3815,6 +4061,7 @@ 155847460754FDCD0046C2E9 /* Headers */, 155847540754FDCD0046C2E9 /* Sources */, 155847620754FDCD0046C2E9 /* Frameworks */, + 1513C3581F1869630022398F /* Update "install_path" for address|thread sanitizers */, 155847680754FDCD0046C2E9 /* CopyFiles */, ); buildRules = ( @@ -3834,6 +4081,7 @@ 1558481407550EC10046C2E9 /* Headers */, 1558481507550EC10046C2E9 /* Sources */, 1558481707550EC10046C2E9 /* Frameworks */, + 1513C3571F1869530022398F /* Update "install_path" for address|thread sanitizers */, 1558481B07550EC10046C2E9 /* CopyFiles */, ); buildRules = ( @@ -3918,6 +4166,7 @@ 153393E40D34999D00FE74E7 /* Update Headers */, 1572C4DE0CFB55B400E2776E /* Sources */, 1572C5230CFB55B400E2776E /* Frameworks */, + 1513C35C1F186BF90022398F /* Update "install_path" for address|thread sanitizers */, 1572C4D90CFB55B400E2776E /* Resources */, 1510A7301B17E1AF00125A85 /* Add framework symlink (TEMPORARY) */, 1572C5270CFB55B400E2776E /* get-mobility-info */, @@ -3998,6 +4247,7 @@ 157433DE0D4A8122002ACA73 /* Headers */, 157433DF0D4A8122002ACA73 /* Sources */, 157433E10D4A8122002ACA73 /* Frameworks */, + 1513C3601F186C460022398F /* Update "install_path" for address|thread sanitizers */, ); buildRules = ( ); @@ -4016,6 +4266,7 @@ 157433F10D4A8137002ACA73 /* Headers */, 157433FF0D4A8137002ACA73 /* Sources */, 1574340D0D4A8137002ACA73 /* Frameworks */, + 1513C3611F186C4D0022398F /* Update "install_path" for address|thread sanitizers */, ); buildRules = ( ); @@ -4034,7 +4285,7 @@ 157A84D90D56C63900B6F1A0 /* Headers */, 157A84DD0D56C63900B6F1A0 /* Sources */, 157A84E20D56C63900B6F1A0 /* Frameworks */, - 154070A11B98E8D3003195EF /* Update "install_path" for address sanitizer */, + 154070A11B98E8D3003195EF /* Update "install_path" for address|thread sanitizers */, ); buildRules = ( ); @@ -4148,6 +4399,7 @@ 158317240CFB80A1006F62B9 /* Headers */, 1583172C0CFB80A1006F62B9 /* Sources */, 1583174B0CFB80A1006F62B9 /* Frameworks */, + 1513C35F1F186C3A0022398F /* Update "install_path" for address|thread sanitizers */, 1583175B0CFB80A1006F62B9 /* CopyFiles */, 15FBB55117D78B670035D752 /* Update MachServices */, ); @@ -4247,6 +4499,7 @@ 1583379A0CFB6B9E0033AB93 /* Headers */, 1583379D0CFB6B9E0033AB93 /* Sources */, 1583379F0CFB6B9E0033AB93 /* Frameworks */, + 1513C35D1F186C0B0022398F /* Update "install_path" for address|thread sanitizers */, 158337A40CFB6B9E0033AB93 /* CopyFiles */, 1595B4B81B0C02FA0087944E /* Update SCHelper launchd .plist */, ); @@ -4347,6 +4600,7 @@ 159D54A307529FFF004F8947 /* Headers */, 159D54AB07529FFF004F8947 /* Sources */, 159D54CA07529FFF004F8947 /* Frameworks */, + 1513C3561F1857E00022398F /* Update "install_path" for address|thread sanitizers */, 159D54D507529FFF004F8947 /* CopyFiles */, 159D54D707529FFF004F8947 /* Copy Files */, 15FBB54D17D75DE70035D752 /* Update MachServices */, @@ -4422,7 +4676,7 @@ 15DAD5E0075913CE0084A6ED /* Headers */, 15DAD5E4075913CE0084A6ED /* Sources */, 15DAD5E9075913CE0084A6ED /* Frameworks */, - 154070A01B968548003195EF /* Update "install_path" for address sanitizer */, + 154070A01B968548003195EF /* Update "install_path" for address|thread sanitizers */, ); buildRules = ( ); @@ -4443,6 +4697,7 @@ 15AC82480D376E2400A579D0 /* Update Headers */, 15DAD66C07591A1A0084A6ED /* Sources */, 15DAD6AD07591A1A0084A6ED /* Frameworks */, + 15A66BB11F18177100F7253B /* Update "install_path" for address|thread sanitizers */, 15DAD66807591A1A0084A6ED /* Resources */, 15DAD6B007591A1A0084A6ED /* get-mobility-info */, 15D9DCF910DD909F004E545D /* AppWorkaround.plist */, @@ -4490,6 +4745,43 @@ productReference = 15E1B06116EBAE7800E5F06F /* IPMonitor.bundle */; productType = "com.apple.product-type.bundle"; }; + 15F742DA1EC6370000DA2E7A /* liblog_SystemConfiguration-Embedded */ = { + isa = PBXNativeTarget; + buildConfigurationList = 15F742E11EC6370000DA2E7A /* Build configuration list for PBXNativeTarget "liblog_SystemConfiguration-Embedded" */; + buildPhases = ( + 15F742DB1EC6370000DA2E7A /* Headers */, + 15F742DC1EC6370000DA2E7A /* Sources */, + 15F742DE1EC6370000DA2E7A /* Frameworks */, + 1513C35E1F186C310022398F /* Update "install_path" for address|thread sanitizers */, + ); + buildRules = ( + ); + dependencies = ( + ); + name = "liblog_SystemConfiguration-Embedded"; + productInstallPath = /usr/local/lib/system; + productName = DNSConfiguration; + productReference = 15F742E41EC6370000DA2E7A /* liblog_SystemConfiguration.dylib */; + productType = "com.apple.product-type.library.dynamic"; + }; + 15F742E71EC638D100DA2E7A /* liblog_SystemConfiguration-EmbeddedSimulator */ = { + isa = PBXNativeTarget; + buildConfigurationList = 15F742EE1EC638D100DA2E7A /* Build configuration list for PBXNativeTarget "liblog_SystemConfiguration-EmbeddedSimulator" */; + buildPhases = ( + 15F742E81EC638D100DA2E7A /* Headers */, + 15F742E91EC638D100DA2E7A /* Sources */, + 15F742EB1EC638D100DA2E7A /* Frameworks */, + ); + buildRules = ( + ); + dependencies = ( + ); + name = "liblog_SystemConfiguration-EmbeddedSimulator"; + productInstallPath = /usr/local/lib/system; + productName = DNSConfiguration; + productReference = 15F742F11EC638D100DA2E7A /* liblog_SystemConfiguration.dylib */; + productType = "com.apple.product-type.library.dynamic"; + }; 15FD72930754DA2B001CC321 /* InterfaceNamer.bundle */ = { isa = PBXNativeTarget; buildConfigurationList = 156EB5FA0905594A00EEF749 /* Build configuration list for PBXNativeTarget "InterfaceNamer.bundle" */; @@ -4560,8 +4852,9 @@ buildPhases = ( 72573D221D667372004975AD /* Sources */, 72573D231D667372004975AD /* Frameworks */, + 1513C35B1F186AE20022398F /* Update "install_path" for address|thread sanitizers */, 72573D241D667372004975AD /* npt_configd.plist */, - 72C12CB21D6FEFBE000EE61C /* ShellScript */, + 72C12CB21D6FEFBE000EE61C /* Fix plist ownership */, ); buildRules = ( ); @@ -4578,6 +4871,7 @@ buildPhases = ( 7271EA1D1D76600B0055B1AA /* Sources */, 7271EA271D76600B0055B1AA /* Frameworks */, + 1513C3621F186C560022398F /* Update "install_path" for address|thread sanitizers */, 7271EA2C1D76600B0055B1AA /* npt_configd.plist */, 7271EA2E1D76600B0055B1AA /* Fix plist ownership */, ); @@ -4632,7 +4926,7 @@ 15CB6A7705C0722B0099E85F /* Project object */ = { isa = PBXProject; attributes = { - LastUpgradeCheck = 0800; + LastUpgradeCheck = 0900; TargetAttributes = { 72573D251D667372004975AD = { CreatedOnToolsVersion = 8.0; @@ -4681,9 +4975,11 @@ 155F49861C864F1400E47D08 /* QoSMarking */, 155F498E1C864F3700E47D08 /* QoSMarking.bundle */, 155847FA07550D210046C2E9 /* configd_executables */, + 151D05FA1EC1491600E02E48 /* liblog_SystemConfiguration */, 159D549F07529FFF004F8947 /* configd */, 1558481207550EC10046C2E9 /* scselect */, 155847430754FDCD0046C2E9 /* scutil */, + 72573D251D667372004975AD /* sctest */, 151F5D990CCE98E50093AC3B /* SCMonitor */, 151C1CC60CFB487000C5AFD6 /* All-Embedded */, 15C64A280F684C6B00D78394 /* configd_libSystem-Embedded */, @@ -4705,9 +5001,11 @@ 155F49951C864F4E00E47D08 /* QoSMarking-Embedded */, 155F499D1C864F5400E47D08 /* QoSMarking.bundle-Embedded */, 158317040CFB7782006F62B9 /* configd_executables-Embedded */, + 15F742DA1EC6370000DA2E7A /* liblog_SystemConfiguration-Embedded */, 158317230CFB80A1006F62B9 /* configd-Embedded */, 157433DD0D4A8122002ACA73 /* scselect-Embedded */, 157433F00D4A8137002ACA73 /* scutil-Embedded */, + 7271EA1B1D76600B0055B1AA /* sctest-Embedded */, 15FD13BF0D59485000F9409C /* All-EmbeddedSimulator */, 157FDE3B164A075F0040D6A8 /* configd_libSystem-EmbeddedSimulator */, 15732AD616EA6B6700F3AC4C /* libsystem_configuration-EmbeddedSimulator */, @@ -4717,14 +5015,14 @@ 15E1B05A16EBAE7800E5F06F /* IPMonitor.bundle-EmbeddedSimulator */, 15D3080F16F3E4DA00014F82 /* SimulatorSupport-EmbeddedSimulator */, 15D3082816F3E4E100014F82 /* SimulatorSupport.bundle-EmbeddedSimulator */, + 15631D161ECF98FB0088EEDD /* configd_executables-EmbeddedSimulator */, + 15F742E71EC638D100DA2E7A /* liblog_SystemConfiguration-EmbeddedSimulator */, 15732A7616EA503200F3AC4C /* configd-EmbeddedSimulator */, 15732AAD16EA511900F3AC4C /* scutil-EmbeddedSimulator */, 151F63DA09328A3C0096DCC9 /* Schema */, 15E83104167F9AF600FD51EC /* EVERYTHING */, 72D3E65D1AE6EA3900DB4C69 /* SCTest-Swift */, 72D3E6681AE6EAF600DB4C69 /* SCTest-ObjC */, - 72573D251D667372004975AD /* sctest */, - 7271EA1B1D76600B0055B1AA /* sctest-Embedded */, ); }; /* End PBXProject section */ @@ -4873,19 +5171,19 @@ /* End PBXResourcesBuildPhase section */ /* Begin PBXShellScriptBuildPhase section */ - 1502C5611BDD4936005CF7EA /* Move libsystem_configuration_asan.dylib */ = { + 1502C5611BDD4936005CF7EA /* Move libsystem_configuration_(asan|tsan).dylib */ = { isa = PBXShellScriptBuildPhase; buildActionMask = 8; files = ( ); inputPaths = ( ); - name = "Move libsystem_configuration_asan.dylib"; + name = "Move libsystem_configuration_(asan|tsan).dylib"; outputPaths = ( ); runOnlyForDeploymentPostprocessing = 1; shellPath = /bin/sh; - shellScript = "#\n# move libsystem_configuration_asan.dylib out of /usr/lib/system\n#\n# Note: to use the asan .dylib, set DYLD_INSERT_LIBRARIES=...\n#\nfor VARIANT in ${BUILD_VARIANTS}\ndo\n if [ \"${VARIANT}\" = \"asan\" ]; then\n DIR_O=\"/usr/lib/system\"\n DIR_N=\"/usr/local/lib\"\n DYLIB=\"libsystem_configuration_${VARIANT}.dylib\"\n\n\t\tmkdir -p \"${DSTROOT}/${DIR_N}\"\n\t\tmv \"${DSTROOT}/${DIR_O}/${DYLIB}\" \"${DSTROOT}/${DIR_N}/${DYLIB}\"\n\t\tif [ -d \"${DSTROOT}/${DIR_O}/${DYLIB}.dSYM\" ]; then\n\t\t\tmv \"${DSTROOT}/${DIR_O}/${DYLIB}.dSYM\" \"${DSTROOT}/${DIR_N}/${DYLIB}.dSYM\"\n\t\tfi\n fi\ndone"; + shellScript = "#\n# move libsystem_configuration_[at]san.dylib out of /usr/lib/system\n#\n# Note: to use the asan/tsan .dylib, set DYLD_INSERT_LIBRARIES=...\n#\nfor VARIANT in ${BUILD_VARIANTS}\ndo\n if [ \"${VARIANT}\" = \"asan\" -o \"${VARIANT}\" = \"tsan\" ]; then\n DIR_O=\"/usr/lib/system\"\n DIR_N=\"/usr/local/lib\"\n DYLIB=\"libsystem_configuration_${VARIANT}.dylib\"\n\n\t\tmkdir -p \"${DSTROOT}/${DIR_N}\"\n\t\tmv \"${DSTROOT}/${DIR_O}/${DYLIB}\" \"${DSTROOT}/${DIR_N}/${DYLIB}\"\n\t\tif [ -d \"${DSTROOT}/${DIR_O}/${DYLIB}.dSYM\" ]; then\n\t\t\tmv \"${DSTROOT}/${DIR_O}/${DYLIB}.dSYM\" \"${DSTROOT}/${DIR_N}/${DYLIB}.dSYM\"\n\t\tfi\n fi\ndone"; showEnvVarsInLog = 0; }; 1510A7301B17E1AF00125A85 /* Add framework symlink (TEMPORARY) */ = { @@ -4903,82 +5201,277 @@ shellScript = "if [ \"${USING_PRIVATE_SYSTEMCONFIGURATION_FRAMEWORK}\" = \"YES\" ]; then\n mkdir -p ${DSTROOT}/System/Library/Frameworks\n cd ${DSTROOT}/System/Library/Frameworks\n rm -rf SystemConfiguration.framework\n ln -s ../PrivateFrameworks/SystemConfiguration.framework .\nfi"; showEnvVarsInLog = 0; }; - 151F63DB09328A3C0096DCC9 /* ShellScript */ = { + 1513C3561F1857E00022398F /* Update "install_path" for address|thread sanitizers */ = { isa = PBXShellScriptBuildPhase; - buildActionMask = 2147483647; + buildActionMask = 12; files = ( ); inputPaths = ( - SystemConfiguration.fproj/genSCPreferences.c, ); + name = "Update \"install_path\" for address|thread sanitizers"; outputPaths = ( - "${BUILT_PRODUCTS_DIR}/SCSchemaDefinitions.h", - "${BUILT_PRODUCTS_DIR}/SCSchemaDefinitionsPrivate.h", - "${BUILT_PRODUCTS_DIR}/SCSchemaDefinitions.c", ); runOnlyForDeploymentPostprocessing = 0; shellPath = /bin/sh; - shellScript = "echo ${BUILT_PRODUCTS_DIR}\ncc -o ${BUILT_PRODUCTS_DIR}/${PRODUCT_NAME} ${SRCROOT}/SystemConfiguration.fproj/genSCPreferences.c || exit 1\n${BUILT_PRODUCTS_DIR}/${PRODUCT_NAME} header > ${BUILT_PRODUCTS_DIR}/SCSchemaDefinitions.h || exit 1\n${BUILT_PRODUCTS_DIR}/${PRODUCT_NAME} private > ${BUILT_PRODUCTS_DIR}/SCSchemaDefinitionsPrivate.h || exit 1\n${BUILT_PRODUCTS_DIR}/${PRODUCT_NAME} cfile > ${BUILT_PRODUCTS_DIR}/SCSchemaDefinitions.c || exit 1\nexit 0"; + shellScript = "${SRCROOT}/update-sanitizer-dylib-references"; + showEnvVarsInLog = 0; }; - 153393E40D34999D00FE74E7 /* Update Headers */ = { + 1513C3571F1869530022398F /* Update "install_path" for address|thread sanitizers */ = { isa = PBXShellScriptBuildPhase; - buildActionMask = 2147483647; + buildActionMask = 12; files = ( ); inputPaths = ( - "$(SRCROOT)/SystemConfiguration.fproj/update-headers", ); - name = "Update Headers"; + name = "Update \"install_path\" for address|thread sanitizers"; outputPaths = ( ); runOnlyForDeploymentPostprocessing = 0; shellPath = /bin/sh; - shellScript = "if [ -x ${SCRIPT_INPUT_FILE_0} ]; then\n\t${SCRIPT_INPUT_FILE_0} split\nfi"; + shellScript = "${SRCROOT}/update-sanitizer-dylib-references"; showEnvVarsInLog = 0; }; - 1535FEDC1B0FDDCD00B2A3AD /* Add framework symlink (TEMPORARY) */ = { + 1513C3581F1869630022398F /* Update "install_path" for address|thread sanitizers */ = { isa = PBXShellScriptBuildPhase; - buildActionMask = 2147483647; + buildActionMask = 12; files = ( ); inputPaths = ( ); - name = "Add framework symlink (TEMPORARY)"; + name = "Update \"install_path\" for address|thread sanitizers"; outputPaths = ( ); runOnlyForDeploymentPostprocessing = 0; shellPath = /bin/sh; - shellScript = "if [ \"${USING_PRIVATE_SYSTEMCONFIGURATION_FRAMEWORK}\" = \"YES\" ]; then\n mkdir -p ${DSTROOT}/System/Library/Frameworks\n cd ${DSTROOT}/System/Library/Frameworks\n rm -rf SystemConfiguration.framework\n ln -s ../PrivateFrameworks/SystemConfiguration.framework .\nfi"; + shellScript = "${SRCROOT}/update-sanitizer-dylib-references"; showEnvVarsInLog = 0; }; - 154070A01B968548003195EF /* Update "install_path" for address sanitizer */ = { + 1513C3591F18697C0022398F /* Update "install_path" for address|thread sanitizers */ = { isa = PBXShellScriptBuildPhase; - buildActionMask = 8; + buildActionMask = 12; files = ( ); inputPaths = ( ); - name = "Update \"install_path\" for address sanitizer"; + name = "Update \"install_path\" for address|thread sanitizers"; outputPaths = ( ); - runOnlyForDeploymentPostprocessing = 1; + runOnlyForDeploymentPostprocessing = 0; shellPath = /bin/sh; - shellScript = "#\n# fix address-sanitizer library @rpath references\n#\n\nfor VARIANT in ${BUILD_VARIANTS}\ndo\n if [ \"${VARIANT}\" = \"asan\" ]; then\n ASAN_SDK_DIR=\"${TOOLCHAIN_DIR}/usr/lib/clang/${CLANG_VERS}/lib/darwin\"\n ASAN_DST_DIR=\"/usr/local/lib\"\n case \"${PLATFORM_NAME}\" in\n macosx )\n\t\t\t\tASAN_LIB=\"clang_rt.asan_osx_dynamic.dylib\"\n ;;\n iphoneos )\n\t\t\t\tASAN_LIB=\"clang_rt.asan_ios_dynamic.dylib\"\n ;;\n iphonesimulator )\n\t\t\t\tASAN_LIB=\"clang_rt.asan_iossim_dynamic.dylib\"\n ;;\n tvos )\n\t\t\t\tASAN_LIB=\"clang_rt.asan_tvos_dynamic.dylib\"\n ;;\n tvsosimulator )\n\t\t\t\tASAN_LIB=\"clang_rt.asan_tvossim_dynamic.dylib\"\n ;;\n watchos )\n\t\t\t\tASAN_LIB=\"clang_rt.asan_watchos_dynamic.dylib\"\n ;;\n watchsimulator )\n\t\t\t\tASAN_LIB=\"clang_rt.asan_watchossim_dynamic.dylib\"\n ;;\n esac\n\n if [ ! -f \"${ASAN_SDK_DIR}/lib${ASAN_LIB}\" ]; then exit 0; fi\n\n\t\t# ensure that the ASAN dylib will be in the DSTROOT\n ditto \"${ASAN_SDK_DIR}/lib${ASAN_LIB}\" \"${DSTROOT}${ASAN_DST_DIR}/lib${ASAN_LIB}\"\n\n\t\t# change @rpath reference\n install_name_tool \\\n -change \\\n \"@rpath/lib${ASAN_LIB}\" \\\n \"${ASAN_DST_DIR}/lib${ASAN_LIB}\" \\\n \"${DSTROOT}${INSTALL_PATH}/${PRODUCT_NAME}_asan.dylib\"\n fi\ndone"; + shellScript = "${SRCROOT}/update-sanitizer-dylib-references"; showEnvVarsInLog = 0; }; - 154070A11B98E8D3003195EF /* Update "install_path" for address sanitizer */ = { + 1513C35A1F186A700022398F /* Update "install_path" for address|thread sanitizers */ = { isa = PBXShellScriptBuildPhase; - buildActionMask = 8; + buildActionMask = 12; files = ( ); inputPaths = ( ); - name = "Update \"install_path\" for address sanitizer"; + name = "Update \"install_path\" for address|thread sanitizers"; + outputPaths = ( + ); + runOnlyForDeploymentPostprocessing = 0; + shellPath = /bin/sh; + shellScript = "${SRCROOT}/update-sanitizer-dylib-references"; + showEnvVarsInLog = 0; + }; + 1513C35B1F186AE20022398F /* Update "install_path" for address|thread sanitizers */ = { + isa = PBXShellScriptBuildPhase; + buildActionMask = 12; + files = ( + ); + inputPaths = ( + ); + name = "Update \"install_path\" for address|thread sanitizers"; + outputPaths = ( + ); + runOnlyForDeploymentPostprocessing = 0; + shellPath = /bin/sh; + shellScript = "${SRCROOT}/update-sanitizer-dylib-references"; + showEnvVarsInLog = 0; + }; + 1513C35C1F186BF90022398F /* Update "install_path" for address|thread sanitizers */ = { + isa = PBXShellScriptBuildPhase; + buildActionMask = 8; + files = ( + ); + inputPaths = ( + ); + name = "Update \"install_path\" for address|thread sanitizers"; + outputPaths = ( + ); + runOnlyForDeploymentPostprocessing = 1; + shellPath = /bin/sh; + shellScript = "${SRCROOT}/update-sanitizer-dylib-references"; + showEnvVarsInLog = 0; + }; + 1513C35D1F186C0B0022398F /* Update "install_path" for address|thread sanitizers */ = { + isa = PBXShellScriptBuildPhase; + buildActionMask = 8; + files = ( + ); + inputPaths = ( + ); + name = "Update \"install_path\" for address|thread sanitizers"; + outputPaths = ( + ); + runOnlyForDeploymentPostprocessing = 1; + shellPath = /bin/sh; + shellScript = "${SRCROOT}/update-sanitizer-dylib-references"; + showEnvVarsInLog = 0; + }; + 1513C35E1F186C310022398F /* Update "install_path" for address|thread sanitizers */ = { + isa = PBXShellScriptBuildPhase; + buildActionMask = 8; + files = ( + ); + inputPaths = ( + ); + name = "Update \"install_path\" for address|thread sanitizers"; + outputPaths = ( + ); + runOnlyForDeploymentPostprocessing = 1; + shellPath = /bin/sh; + shellScript = "${SRCROOT}/update-sanitizer-dylib-references"; + showEnvVarsInLog = 0; + }; + 1513C35F1F186C3A0022398F /* Update "install_path" for address|thread sanitizers */ = { + isa = PBXShellScriptBuildPhase; + buildActionMask = 8; + files = ( + ); + inputPaths = ( + ); + name = "Update \"install_path\" for address|thread sanitizers"; + outputPaths = ( + ); + runOnlyForDeploymentPostprocessing = 1; + shellPath = /bin/sh; + shellScript = "${SRCROOT}/update-sanitizer-dylib-references"; + showEnvVarsInLog = 0; + }; + 1513C3601F186C460022398F /* Update "install_path" for address|thread sanitizers */ = { + isa = PBXShellScriptBuildPhase; + buildActionMask = 8; + files = ( + ); + inputPaths = ( + ); + name = "Update \"install_path\" for address|thread sanitizers"; + outputPaths = ( + ); + runOnlyForDeploymentPostprocessing = 1; + shellPath = /bin/sh; + shellScript = "${SRCROOT}/update-sanitizer-dylib-references"; + showEnvVarsInLog = 0; + }; + 1513C3611F186C4D0022398F /* Update "install_path" for address|thread sanitizers */ = { + isa = PBXShellScriptBuildPhase; + buildActionMask = 8; + files = ( + ); + inputPaths = ( + ); + name = "Update \"install_path\" for address|thread sanitizers"; + outputPaths = ( + ); + runOnlyForDeploymentPostprocessing = 1; + shellPath = /bin/sh; + shellScript = "${SRCROOT}/update-sanitizer-dylib-references"; + showEnvVarsInLog = 0; + }; + 1513C3621F186C560022398F /* Update "install_path" for address|thread sanitizers */ = { + isa = PBXShellScriptBuildPhase; + buildActionMask = 8; + files = ( + ); + inputPaths = ( + ); + name = "Update \"install_path\" for address|thread sanitizers"; + outputPaths = ( + ); + runOnlyForDeploymentPostprocessing = 1; + shellPath = /bin/sh; + shellScript = "${SRCROOT}/update-sanitizer-dylib-references"; + showEnvVarsInLog = 0; + }; + 151F63DB09328A3C0096DCC9 /* ShellScript */ = { + isa = PBXShellScriptBuildPhase; + buildActionMask = 2147483647; + files = ( + ); + inputPaths = ( + SystemConfiguration.fproj/genSCPreferences.c, + ); + outputPaths = ( + "${BUILT_PRODUCTS_DIR}/SCSchemaDefinitions.h", + "${BUILT_PRODUCTS_DIR}/SCSchemaDefinitionsPrivate.h", + "${BUILT_PRODUCTS_DIR}/SCSchemaDefinitions.c", + ); + runOnlyForDeploymentPostprocessing = 0; + shellPath = /bin/sh; + shellScript = "echo ${BUILT_PRODUCTS_DIR}\ncc -o ${BUILT_PRODUCTS_DIR}/${PRODUCT_NAME} ${SRCROOT}/SystemConfiguration.fproj/genSCPreferences.c || exit 1\n${BUILT_PRODUCTS_DIR}/${PRODUCT_NAME} header > ${BUILT_PRODUCTS_DIR}/SCSchemaDefinitions.h || exit 1\n${BUILT_PRODUCTS_DIR}/${PRODUCT_NAME} private > ${BUILT_PRODUCTS_DIR}/SCSchemaDefinitionsPrivate.h || exit 1\n${BUILT_PRODUCTS_DIR}/${PRODUCT_NAME} cfile > ${BUILT_PRODUCTS_DIR}/SCSchemaDefinitions.c || exit 1\nexit 0"; + }; + 153393E40D34999D00FE74E7 /* Update Headers */ = { + isa = PBXShellScriptBuildPhase; + buildActionMask = 2147483647; + files = ( + ); + inputPaths = ( + "$(SRCROOT)/SystemConfiguration.fproj/update-headers", + ); + name = "Update Headers"; + outputPaths = ( + ); + runOnlyForDeploymentPostprocessing = 0; + shellPath = /bin/sh; + shellScript = "if [ -x ${SCRIPT_INPUT_FILE_0} ]; then\n\t${SCRIPT_INPUT_FILE_0} split\nfi"; + showEnvVarsInLog = 0; + }; + 1535FEDC1B0FDDCD00B2A3AD /* Add framework symlink (TEMPORARY) */ = { + isa = PBXShellScriptBuildPhase; + buildActionMask = 2147483647; + files = ( + ); + inputPaths = ( + ); + name = "Add framework symlink (TEMPORARY)"; + outputPaths = ( + ); + runOnlyForDeploymentPostprocessing = 0; + shellPath = /bin/sh; + shellScript = "if [ \"${USING_PRIVATE_SYSTEMCONFIGURATION_FRAMEWORK}\" = \"YES\" ]; then\n mkdir -p ${DSTROOT}/System/Library/Frameworks\n cd ${DSTROOT}/System/Library/Frameworks\n rm -rf SystemConfiguration.framework\n ln -s ../PrivateFrameworks/SystemConfiguration.framework .\nfi"; + showEnvVarsInLog = 0; + }; + 154070A01B968548003195EF /* Update "install_path" for address|thread sanitizers */ = { + isa = PBXShellScriptBuildPhase; + buildActionMask = 12; + files = ( + ); + inputPaths = ( + ); + name = "Update \"install_path\" for address|thread sanitizers"; + outputPaths = ( + ); + runOnlyForDeploymentPostprocessing = 0; + shellPath = /bin/sh; + shellScript = "${SRCROOT}/update-sanitizer-dylib-references"; + showEnvVarsInLog = 0; + }; + 154070A11B98E8D3003195EF /* Update "install_path" for address|thread sanitizers */ = { + isa = PBXShellScriptBuildPhase; + buildActionMask = 8; + files = ( + ); + inputPaths = ( + ); + name = "Update \"install_path\" for address|thread sanitizers"; outputPaths = ( ); runOnlyForDeploymentPostprocessing = 1; shellPath = /bin/sh; - shellScript = "#\n# fix address-sanitizer library @rpath references\n#\n\nfor VARIANT in ${BUILD_VARIANTS}\ndo\n if [ \"${VARIANT}\" = \"asan\" ]; then\n ASAN_SDK_DIR=\"${TOOLCHAIN_DIR}/usr/lib/clang/${CLANG_VERS}/lib/darwin\"\n ASAN_DST_DIR=\"/usr/local/lib\"\n case \"${PLATFORM_NAME}\" in\n macosx )\n\t\t\t\tASAN_LIB=\"clang_rt.asan_osx_dynamic.dylib\"\n ;;\n iphoneos )\n\t\t\t\tASAN_LIB=\"clang_rt.asan_ios_dynamic.dylib\"\n ;;\n iphonesimulator )\n\t\t\t\tASAN_LIB=\"clang_rt.asan_iossim_dynamic.dylib\"\n ;;\n tvos )\n\t\t\t\tASAN_LIB=\"clang_rt.asan_tvos_dynamic.dylib\"\n ;;\n tvsosimulator )\n\t\t\t\tASAN_LIB=\"clang_rt.asan_tvossim_dynamic.dylib\"\n ;;\n watchos )\n\t\t\t\tASAN_LIB=\"clang_rt.asan_watchos_dynamic.dylib\"\n ;;\n watchsimulator )\n\t\t\t\tASAN_LIB=\"clang_rt.asan_watchossim_dynamic.dylib\"\n ;;\n esac\n\n if [ ! -f \"${ASAN_SDK_DIR}/lib${ASAN_LIB}\" ]; then exit 0; fi\n\n\t\t# ensure that the ASAN dylib will be in the DSTROOT\n ditto \"${ASAN_SDK_DIR}/lib${ASAN_LIB}\" \"${DSTROOT}${ASAN_DST_DIR}/lib${ASAN_LIB}\"\n\n\t\t# change @rpath reference\n install_name_tool \\\n -change \\\n \"@rpath/lib${ASAN_LIB}\" \\\n \"${ASAN_DST_DIR}/lib${ASAN_LIB}\" \\\n \"${DSTROOT}${INSTALL_PATH}/${PRODUCT_NAME}_asan.dylib\"\n fi\ndone"; + shellScript = "${SRCROOT}/update-sanitizer-dylib-references"; showEnvVarsInLog = 0; }; 1572C5270CFB55B400E2776E /* get-mobility-info */ = { @@ -5027,6 +5520,36 @@ shellScript = "if [ -x ${SCRIPT_INPUT_FILE_0} ]; then\n\t${SCRIPT_INPUT_FILE_0} split\nfi"; showEnvVarsInLog = 0; }; + 15A66BB11F18177100F7253B /* Update "install_path" for address|thread sanitizers */ = { + isa = PBXShellScriptBuildPhase; + buildActionMask = 12; + files = ( + ); + inputPaths = ( + ); + name = "Update \"install_path\" for address|thread sanitizers"; + outputPaths = ( + ); + runOnlyForDeploymentPostprocessing = 0; + shellPath = /bin/sh; + shellScript = "${SRCROOT}/update-sanitizer-dylib-references"; + showEnvVarsInLog = 0; + }; + 15A66BB21F1817AC00F7253B /* Update "install_path" for address|thread sanitizers */ = { + isa = PBXShellScriptBuildPhase; + buildActionMask = 12; + files = ( + ); + inputPaths = ( + ); + name = "Update \"install_path\" for address|thread sanitizers"; + outputPaths = ( + ); + runOnlyForDeploymentPostprocessing = 0; + shellPath = /bin/sh; + shellScript = "${SRCROOT}/update-sanitizer-dylib-references"; + showEnvVarsInLog = 0; + }; 15AC82480D376E2400A579D0 /* Update Headers */ = { isa = PBXShellScriptBuildPhase; buildActionMask = 2147483647; @@ -5043,19 +5566,19 @@ shellScript = "if [ -x ${SCRIPT_INPUT_FILE_0} ]; then\n\t${SCRIPT_INPUT_FILE_0} clean\nfi\n"; showEnvVarsInLog = 0; }; - 15AC9A4C1BE3ED87003071BD /* Move libsystem_configuration_asan.dylib */ = { + 15AC9A4C1BE3ED87003071BD /* Move libsystem_configuration_(asan|tsan).dylib */ = { isa = PBXShellScriptBuildPhase; buildActionMask = 8; files = ( ); inputPaths = ( ); - name = "Move libsystem_configuration_asan.dylib"; + name = "Move libsystem_configuration_(asan|tsan).dylib"; outputPaths = ( ); runOnlyForDeploymentPostprocessing = 1; shellPath = /bin/sh; - shellScript = "#\n# move libsystem_configuration_asan.dylib out of /usr/lib/system\n#\n# Note: to use the asan .dylib, set DYLD_INSERT_LIBRARIES=...\n#\nfor VARIANT in ${BUILD_VARIANTS}\ndo\n if [ \"${VARIANT}\" = \"asan\" ]; then\n DIR_O=\"/usr/lib/system\"\n DIR_N=\"/usr/local/lib\"\n DYLIB=\"libsystem_configuration_${VARIANT}.dylib\"\n\n\t\tmkdir -p \"${DSTROOT}/${DIR_N}\"\n\t\tmv \"${DSTROOT}/${DIR_O}/${DYLIB}\" \"${DSTROOT}/${DIR_N}/${DYLIB}\"\n\t\tif [ -d \"${DSTROOT}/${DIR_O}/${DYLIB}.dSYM\" ]; then\n\t\t\tmv \"${DSTROOT}/${DIR_O}/${DYLIB}.dSYM\" \"${DSTROOT}/${DIR_N}/${DYLIB}.dSYM\"\n\t\tfi\n fi\ndone"; + shellScript = "#\n# move libsystem_configuration_[at]san.dylib out of /usr/lib/system\n#\n# Note: to use the asan/tsan .dylib, set DYLD_INSERT_LIBRARIES=...\n#\nfor VARIANT in ${BUILD_VARIANTS}\ndo\n if [ \"${VARIANT}\" = \"asan\" -o \"${VARIANT}\" = \"tsan\" ]; then\n DIR_O=\"/usr/lib/system\"\n DIR_N=\"/usr/local/lib\"\n DYLIB=\"libsystem_configuration_${VARIANT}.dylib\"\n\n\t\tmkdir -p \"${DSTROOT}/${DIR_N}\"\n\t\tmv \"${DSTROOT}/${DIR_O}/${DYLIB}\" \"${DSTROOT}/${DIR_N}/${DYLIB}\"\n\t\tif [ -d \"${DSTROOT}/${DIR_O}/${DYLIB}.dSYM\" ]; then\n\t\t\tmv \"${DSTROOT}/${DIR_O}/${DYLIB}.dSYM\" \"${DSTROOT}/${DIR_N}/${DYLIB}.dSYM\"\n\t\tfi\n fi\ndone"; showEnvVarsInLog = 0; }; 15DAD6AC07591A1A0084A6ED /* SystemConfiguration.order */ = { @@ -5104,6 +5627,7 @@ runOnlyForDeploymentPostprocessing = 0; shellPath = /bin/sh; shellScript = "if [ -x ${SCRIPT_INPUT_FILE_0} ]; then\n ${SCRIPT_INPUT_FILE_0} com.apple.configd.plist\nfi"; + showEnvVarsInLog = 0; }; 15FBB55117D78B670035D752 /* Update MachServices */ = { isa = PBXShellScriptBuildPhase; @@ -5151,13 +5675,14 @@ shellPath = /bin/sh; shellScript = "if [ ${UID} -eq 0 ]; then\n\tchown 0:0 \"${DSTROOT}/AppleInternal/CoreOS/BATS/npt_tests/npt_configd.plist\"\nfi\n\nexit 0"; }; - 72C12CB21D6FEFBE000EE61C /* ShellScript */ = { + 72C12CB21D6FEFBE000EE61C /* Fix plist ownership */ = { isa = PBXShellScriptBuildPhase; buildActionMask = 8; files = ( ); inputPaths = ( ); + name = "Fix plist ownership"; outputPaths = ( ); runOnlyForDeploymentPostprocessing = 1; @@ -5167,6 +5692,14 @@ /* End PBXShellScriptBuildPhase section */ /* Begin PBXSourcesBuildPhase section */ + 151D06011EC1491600E02E48 /* Sources */ = { + isa = PBXSourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + 151D060E1EC14C8600E02E48 /* liblog_SystemConfiguration.m in Sources */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; 151F5D970CCE98E50093AC3B /* Sources */ = { isa = PBXSourcesBuildPhase; buildActionMask = 2147483647; @@ -5428,6 +5961,7 @@ 153ACCA914E322D5005029A5 /* network_information_server.c in Sources */, 1575FD2712CD15C60003D86E /* proxy-configuration.c in Sources */, 157A84FC0D56C7E800B6F1A0 /* set-hostname.c in Sources */, + 1501F76A1EA8019D006A71B0 /* nat64-configuration.c in Sources */, 7280158B1BE1685B009F4F60 /* controller.m in Sources */, 728015821BE16840009F4F60 /* agent-monitor.m in Sources */, 1596A7B214EDB73D00798C39 /* libSystemConfiguration_server.c in Sources */, @@ -5548,6 +6082,7 @@ 159D541707528E05004F8947 /* ip_plugin.c in Sources */, 7280158D1BE16861009F4F60 /* dnsAgent.m in Sources */, E49173E1137C4E4F0000089F /* network_state_information_priv.c in Sources */, + 1501F7691EA80189006A71B0 /* nat64-configuration.c in Sources */, 153ACCA814E322D5005029A5 /* network_information_server.c in Sources */, 1575FD2912CD15C60003D86E /* proxy-configuration.c in Sources */, 154361E00752C81800A8EC6C /* set-hostname.c in Sources */, @@ -5799,6 +6334,22 @@ ); runOnlyForDeploymentPostprocessing = 0; }; + 15F742DC1EC6370000DA2E7A /* Sources */ = { + isa = PBXSourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + 15F742DD1EC6370000DA2E7A /* liblog_SystemConfiguration.m in Sources */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; + 15F742E91EC638D100DA2E7A /* Sources */ = { + isa = PBXSourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + 15F742EA1EC638D100DA2E7A /* liblog_SystemConfiguration.m in Sources */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; 72573D221D667372004975AD /* Sources */ = { isa = PBXSourcesBuildPhase; buildActionMask = 2147483647; @@ -5860,6 +6411,11 @@ target = 151FE2DD0D5B7046000D6DB1 /* configd_base-EmbeddedSimulator */; targetProxy = 151FE3790D5B713C000D6DB1 /* PBXContainerItemProxy */; }; + 1523BBE21E075859006281F1 /* PBXTargetDependency */ = { + isa = PBXTargetDependency; + target = 158337990CFB6B9E0033AB93 /* SCHelper-Embedded */; + targetProxy = 1523BBE11E075859006281F1 /* PBXContainerItemProxy */; + }; 1558480607550D470046C2E9 /* PBXTargetDependency */ = { isa = PBXTargetDependency; target = 159D549F07529FFF004F8947 /* configd */; @@ -5875,6 +6431,16 @@ target = 155847FA07550D210046C2E9 /* configd_executables */; targetProxy = 1558480E07550DD00046C2E9 /* PBXContainerItemProxy */; }; + 155F49A91C8650E900E47D08 /* PBXTargetDependency */ = { + isa = PBXTargetDependency; + target = 155F49861C864F1400E47D08 /* QoSMarking */; + targetProxy = 155F49A81C8650E900E47D08 /* PBXContainerItemProxy */; + }; + 155F49AB1C8650E900E47D08 /* PBXTargetDependency */ = { + isa = PBXTargetDependency; + target = 155F498E1C864F3700E47D08 /* QoSMarking.bundle */; + targetProxy = 155F49AA1C8650E900E47D08 /* PBXContainerItemProxy */; + }; 155F49AD1C86511300E47D08 /* PBXTargetDependency */ = { isa = PBXTargetDependency; target = 155F49951C864F4E00E47D08 /* QoSMarking-Embedded */; @@ -5885,6 +6451,36 @@ target = 155F499D1C864F5400E47D08 /* QoSMarking.bundle-Embedded */; targetProxy = 155F49AE1C86511300E47D08 /* PBXContainerItemProxy */; }; + 15631D111ECF92E70088EEDD /* PBXTargetDependency */ = { + isa = PBXTargetDependency; + target = 151D05FA1EC1491600E02E48 /* liblog_SystemConfiguration */; + targetProxy = 15631D101ECF92E70088EEDD /* PBXContainerItemProxy */; + }; + 15631D131ECF93040088EEDD /* PBXTargetDependency */ = { + isa = PBXTargetDependency; + target = 15F742DA1EC6370000DA2E7A /* liblog_SystemConfiguration-Embedded */; + targetProxy = 15631D121ECF93040088EEDD /* PBXContainerItemProxy */; + }; + 15631D271ECF99800088EEDD /* PBXTargetDependency */ = { + isa = PBXTargetDependency; + target = 15F742E71EC638D100DA2E7A /* liblog_SystemConfiguration-EmbeddedSimulator */; + targetProxy = 15631D261ECF99800088EEDD /* PBXContainerItemProxy */; + }; + 15631D291ECF99800088EEDD /* PBXTargetDependency */ = { + isa = PBXTargetDependency; + target = 15732A7616EA503200F3AC4C /* configd-EmbeddedSimulator */; + targetProxy = 15631D281ECF99800088EEDD /* PBXContainerItemProxy */; + }; + 15631D2B1ECF99800088EEDD /* PBXTargetDependency */ = { + isa = PBXTargetDependency; + target = 15732AAD16EA511900F3AC4C /* scutil-EmbeddedSimulator */; + targetProxy = 15631D2A1ECF99800088EEDD /* PBXContainerItemProxy */; + }; + 15631D2D1ECF99A00088EEDD /* PBXTargetDependency */ = { + isa = PBXTargetDependency; + target = 15631D161ECF98FB0088EEDD /* configd_executables-EmbeddedSimulator */; + targetProxy = 15631D2C1ECF99A00088EEDD /* PBXContainerItemProxy */; + }; 15732AE616EA6BCE00F3AC4C /* PBXTargetDependency */ = { isa = PBXTargetDependency; target = 15732AD616EA6B6700F3AC4C /* libsystem_configuration-EmbeddedSimulator */; @@ -5960,11 +6556,6 @@ target = 1572C4A60CFB55B400E2776E /* SystemConfiguration.framework-Embedded */; targetProxy = 158317110CFB77E1006F62B9 /* PBXContainerItemProxy */; }; - 158317140CFB77E8006F62B9 /* PBXTargetDependency */ = { - isa = PBXTargetDependency; - target = 158337990CFB6B9E0033AB93 /* SCHelper-Embedded */; - targetProxy = 158317130CFB77E8006F62B9 /* PBXContainerItemProxy */; - }; 158317160CFB783B006F62B9 /* PBXTargetDependency */ = { isa = PBXTargetDependency; target = 158316E30CFB7761006F62B9 /* configd_plugins-Embedded */; @@ -6194,7 +6785,7 @@ isa = XCBuildConfiguration; buildSettings = { PRODUCT_NAME = configdAggregateEmbedded; - SUPPORTED_PLATFORMS = iphoneos; + SUPPORTED_PLATFORMS = "iphoneos tvos watchos bridgeos"; }; name = Debug; }; @@ -6202,7 +6793,45 @@ isa = XCBuildConfiguration; buildSettings = { PRODUCT_NAME = configdAggregateEmbedded; - SUPPORTED_PLATFORMS = iphoneos; + SUPPORTED_PLATFORMS = "iphoneos tvos watchos bridgeos"; + }; + name = Release; + }; + 151D06091EC1491600E02E48 /* Debug */ = { + isa = XCBuildConfiguration; + buildSettings = { + CLANG_ANALYZER_LOCALIZABILITY_NONLOCALIZED = NO; + CLANG_ENABLE_OBJC_ARC = YES; + EXECUTABLE_PREFIX = liblog_; + GENERATE_PROFILING_CODE_profile = YES; + INSTALLHDRS_COPY_PHASE = YES; + INSTALL_PATH = /usr/lib/log; + OTHER_CFLAGS_debug = "-O0"; + PRODUCT_NAME = SystemConfiguration; + STRIP_INSTALLED_PRODUCT_asan = NO; + STRIP_INSTALLED_PRODUCT_debug = NO; + STRIP_INSTALLED_PRODUCT_normal = YES; + STRIP_INSTALLED_PRODUCT_profile = NO; + STRIP_INSTALLED_PRODUCT_tsan = NO; + }; + name = Debug; + }; + 151D060A1EC1491600E02E48 /* Release */ = { + isa = XCBuildConfiguration; + buildSettings = { + CLANG_ANALYZER_LOCALIZABILITY_NONLOCALIZED = NO; + CLANG_ENABLE_OBJC_ARC = YES; + EXECUTABLE_PREFIX = liblog_; + GENERATE_PROFILING_CODE_profile = YES; + INSTALLHDRS_COPY_PHASE = YES; + INSTALL_PATH = /usr/lib/log; + OTHER_CFLAGS_debug = "-O0"; + PRODUCT_NAME = SystemConfiguration; + STRIP_INSTALLED_PRODUCT_asan = NO; + STRIP_INSTALLED_PRODUCT_debug = NO; + STRIP_INSTALLED_PRODUCT_normal = YES; + STRIP_INSTALLED_PRODUCT_profile = NO; + STRIP_INSTALLED_PRODUCT_tsan = NO; }; name = Release; }; @@ -6246,6 +6875,7 @@ PRODUCT_NAME = genSCPreferences; WARNING_CFLAGS = ( "-Wall", + "-Wextra", "-Wno-four-char-constants", "-Wno-unknown-pragmas", ); @@ -6260,6 +6890,7 @@ PRODUCT_NAME = genSCPreferences; WARNING_CFLAGS = ( "-Wall", + "-Wextra", "-Wno-four-char-constants", "-Wno-unknown-pragmas", ); @@ -6270,7 +6901,7 @@ isa = XCBuildConfiguration; buildSettings = { PRODUCT_NAME = "configd_base (EmbeddedSimulator)"; - SUPPORTED_PLATFORMS = iphonesimulator; + SUPPORTED_PLATFORMS = "iphonesimulator tvossimulator watchsimulator bridgesimulator"; }; name = Debug; }; @@ -6278,7 +6909,7 @@ isa = XCBuildConfiguration; buildSettings = { PRODUCT_NAME = "configd_base (EmbeddedSimulator)"; - SUPPORTED_PLATFORMS = iphonesimulator; + SUPPORTED_PLATFORMS = "iphonesimulator tvossimulator watchsimulator bridgesimulator"; }; name = Release; }; @@ -6343,7 +6974,7 @@ PRODUCT_NAME = QoSMarking; SDKROOT = iphoneos.internal; STRIP_INSTALLED_PRODUCT = NO; - SUPPORTED_PLATFORMS = iphoneos; + SUPPORTED_PLATFORMS = "iphoneos tvos watchos bridgeos"; }; name = Debug; }; @@ -6359,7 +6990,7 @@ PRODUCT_NAME = QoSMarking; SDKROOT = iphoneos.internal; STRIP_INSTALLED_PRODUCT = NO; - SUPPORTED_PLATFORMS = iphoneos; + SUPPORTED_PLATFORMS = "iphoneos tvos watchos bridgeos"; }; name = Release; }; @@ -6371,7 +7002,7 @@ PRODUCT_BUNDLE_IDENTIFIER = com.apple.SystemConfiguration.QoSMarking; PRODUCT_NAME = QoSMarking; SDKROOT = iphoneos.internal; - SUPPORTED_PLATFORMS = iphoneos; + SUPPORTED_PLATFORMS = "iphoneos tvos watchos bridgeos"; }; name = Debug; }; @@ -6383,7 +7014,23 @@ PRODUCT_BUNDLE_IDENTIFIER = com.apple.SystemConfiguration.QoSMarking; PRODUCT_NAME = QoSMarking; SDKROOT = iphoneos.internal; - SUPPORTED_PLATFORMS = iphoneos; + SUPPORTED_PLATFORMS = "iphoneos tvos watchos bridgeos"; + }; + name = Release; + }; + 15631D241ECF98FB0088EEDD /* Debug */ = { + isa = XCBuildConfiguration; + buildSettings = { + PRODUCT_NAME = "$(TARGET_NAME)"; + SUPPORTED_PLATFORMS = "iphonesimulator tvossimulator watchsimulator bridgesimulator"; + }; + name = Debug; + }; + 15631D251ECF98FB0088EEDD /* Release */ = { + isa = XCBuildConfiguration; + buildSettings = { + PRODUCT_NAME = "$(TARGET_NAME)"; + SUPPORTED_PLATFORMS = "iphonesimulator tvossimulator watchsimulator bridgesimulator"; }; name = Release; }; @@ -6419,12 +7066,28 @@ "-lsystem_trace", "-lxpc", ); - OTHER_LDFLAGS_asan = "-headerpad_max_install_names -L${TOOLCHAIN_DIR}/usr/lib/clang/${CLANG_VERS}/lib/darwin -lclang_rt.asan_osx_dynamic"; + "OTHER_LDFLAGS_asan[arch=i386]" = ""; + "OTHER_LDFLAGS_asan[sdk=iphoneos*]" = "$(inherited) -L/usr/local/lib/sanitizers -lclang_rt.asan_ios_dynamic"; + "OTHER_LDFLAGS_asan[sdk=iphonesimulator*]" = "$(inherited) -L/usr/local/lib/sanitizers -lclang_rt.asan_iossim_dynamic"; + "OTHER_LDFLAGS_asan[sdk=macosx*]" = "$(inherited) -L/usr/local/lib/sanitizers -lclang_rt.asan_osx_dynamic"; + "OTHER_LDFLAGS_asan[sdk=tvos*]" = "$(inherited) -L/usr/local/lib/sanitizers -lclang_rt.asan_tvos_dynamic"; + "OTHER_LDFLAGS_asan[sdk=tvossimulator*]" = "$(inherited) -L/usr/local/lib/sanitizers -lclang_rt.asan_tvosossim_dynamic"; + "OTHER_LDFLAGS_asan[sdk=watchos*]" = "$(inherited) -L/usr/local/lib/sanitizers -lclang_rt.asan_watchos_dynamic"; + "OTHER_LDFLAGS_asan[sdk=watchsimulator*]" = "$(inherited) -L/usr/local/lib/sanitizers -lclang_rt.asan_watchossim_dynamic"; + "OTHER_LDFLAGS_tsan[arch=i386]" = ""; + "OTHER_LDFLAGS_tsan[sdk=iphoneos*]" = "$(inherited) -L/usr/local/lib/sanitizers -lclang_rt.tsan_ios_dynamic"; + "OTHER_LDFLAGS_tsan[sdk=iphonesimulator*]" = "$(inherited) -L/usr/local/lib/sanitizers -lclang_rt.tsan_iossim_dynamic"; + "OTHER_LDFLAGS_tsan[sdk=macosx*]" = "$(inherited) -L/usr/local/lib/sanitizers -lclang_rt.tsan_osx_dynamic"; + "OTHER_LDFLAGS_tsan[sdk=tvos*]" = "$(inherited) -L/usr/local/lib/sanitizers -lclang_rt.tsan_tvos_dynamic"; + "OTHER_LDFLAGS_tsan[sdk=tvossimulator*]" = "$(inherited) -L/usr/local/lib/sanitizers -lclang_rt.tsan_tvosossim_dynamic"; + "OTHER_LDFLAGS_tsan[sdk=watchos*]" = "$(inherited) -L/usr/local/lib/sanitizers -lclang_rt.tsan_watchos_dynamic"; + "OTHER_LDFLAGS_tsan[sdk=watchsimulator*]" = "$(inherited) -L/usr/local/lib/sanitizers -lclang_rt.tsan_watchossim_dynamic"; PRODUCT_NAME = libsystem_configuration; STRIP_INSTALLED_PRODUCT_asan = NO; STRIP_INSTALLED_PRODUCT_debug = NO; STRIP_INSTALLED_PRODUCT_normal = YES; STRIP_INSTALLED_PRODUCT_profile = NO; + STRIP_INSTALLED_PRODUCT_tsan = NO; }; name = Debug; }; @@ -6460,12 +7123,28 @@ "-lsystem_trace", "-lxpc", ); - OTHER_LDFLAGS_asan = "-headerpad_max_install_names -L${TOOLCHAIN_DIR}/usr/lib/clang/${CLANG_VERS}/lib/darwin -lclang_rt.asan_osx_dynamic"; + "OTHER_LDFLAGS_asan[arch=i386]" = ""; + "OTHER_LDFLAGS_asan[sdk=iphoneos*]" = "$(inherited) -L/usr/local/lib/sanitizers -lclang_rt.asan_ios_dynamic"; + "OTHER_LDFLAGS_asan[sdk=iphonesimulator*]" = "$(inherited) -L/usr/local/lib/sanitizers -lclang_rt.asan_iossim_dynamic"; + "OTHER_LDFLAGS_asan[sdk=macosx*]" = "$(inherited) -L/usr/local/lib/sanitizers -lclang_rt.asan_osx_dynamic"; + "OTHER_LDFLAGS_asan[sdk=tvos*]" = "$(inherited) -L/usr/local/lib/sanitizers -lclang_rt.asan_tvos_dynamic"; + "OTHER_LDFLAGS_asan[sdk=tvossimulator*]" = "$(inherited) -L/usr/local/lib/sanitizers -lclang_rt.asan_tvosossim_dynamic"; + "OTHER_LDFLAGS_asan[sdk=watchos*]" = "$(inherited) -L/usr/local/lib/sanitizers -lclang_rt.asan_watchos_dynamic"; + "OTHER_LDFLAGS_asan[sdk=watchsimulator*]" = "$(inherited) -L/usr/local/lib/sanitizers -lclang_rt.asan_watchossim_dynamic"; + "OTHER_LDFLAGS_tsan[arch=i386]" = ""; + "OTHER_LDFLAGS_tsan[sdk=iphoneos*]" = "$(inherited) -L/usr/local/lib/sanitizers -lclang_rt.tsan_ios_dynamic"; + "OTHER_LDFLAGS_tsan[sdk=iphonesimulator*]" = "$(inherited) -L/usr/local/lib/sanitizers -lclang_rt.tsan_iossim_dynamic"; + "OTHER_LDFLAGS_tsan[sdk=macosx*]" = "$(inherited) -L/usr/local/lib/sanitizers -lclang_rt.tsan_osx_dynamic"; + "OTHER_LDFLAGS_tsan[sdk=tvos*]" = "$(inherited) -L/usr/local/lib/sanitizers -lclang_rt.tsan_tvos_dynamic"; + "OTHER_LDFLAGS_tsan[sdk=tvossimulator*]" = "$(inherited) -L/usr/local/lib/sanitizers -lclang_rt.tsan_tvosossim_dynamic"; + "OTHER_LDFLAGS_tsan[sdk=watchos*]" = "$(inherited) -L/usr/local/lib/sanitizers -lclang_rt.tsan_watchos_dynamic"; + "OTHER_LDFLAGS_tsan[sdk=watchsimulator*]" = "$(inherited) -L/usr/local/lib/sanitizers -lclang_rt.tsan_watchossim_dynamic"; PRODUCT_NAME = libsystem_configuration; STRIP_INSTALLED_PRODUCT_asan = NO; STRIP_INSTALLED_PRODUCT_debug = NO; STRIP_INSTALLED_PRODUCT_normal = YES; STRIP_INSTALLED_PRODUCT_profile = NO; + STRIP_INSTALLED_PRODUCT_tsan = NO; }; name = Release; }; @@ -6628,6 +7307,10 @@ DEBUG_INFORMATION_FORMAT = dwarf; INSTALL_PATH = /usr/local/lib/SystemConfiguration; LIBRARY_STYLE = STATIC; + OTHER_CFLAGS = ( + "$(inherited)", + "-DSC_LOG_HANDLE=\"__log_InterfaceNamer()\"", + ); PRODUCT_NAME = InterfaceNamer; STRIP_INSTALLED_PRODUCT = NO; }; @@ -6639,6 +7322,10 @@ DEBUG_INFORMATION_FORMAT = dwarf; INSTALL_PATH = /usr/local/lib/SystemConfiguration; LIBRARY_STYLE = STATIC; + OTHER_CFLAGS = ( + "$(inherited)", + "-DSC_LOG_HANDLE=\"__log_InterfaceNamer()\"", + ); PRODUCT_NAME = InterfaceNamer; STRIP_INSTALLED_PRODUCT = NO; }; @@ -6837,6 +7524,7 @@ "-lIPMonitor$(EXECUTABLE_VARIANT_SUFFIX)", "-lLinkConfiguration$(EXECUTABLE_VARIANT_SUFFIX)", "-lPreferencesMonitor$(EXECUTABLE_VARIANT_SUFFIX)", + "-lQoSMarking$(EXECUTABLE_VARIANT_SUFFIX)", ); PRODUCT_NAME = configd; }; @@ -6862,6 +7550,7 @@ "-lIPMonitor$(EXECUTABLE_VARIANT_SUFFIX)", "-lLinkConfiguration$(EXECUTABLE_VARIANT_SUFFIX)", "-lPreferencesMonitor$(EXECUTABLE_VARIANT_SUFFIX)", + "-lQoSMarking$(EXECUTABLE_VARIANT_SUFFIX)", ); PRODUCT_NAME = configd; }; @@ -6945,6 +7634,18 @@ normal, "${EXTRA_BUILD_VARIANT}", ); + CLANG_ANALYZER_LOCALIZABILITY_NONLOCALIZED = YES; + CLANG_WARN_BOOL_CONVERSION = YES; + CLANG_WARN_CONSTANT_CONVERSION = YES; + CLANG_WARN_DOCUMENTATION_COMMENTS = YES; + CLANG_WARN_EMPTY_BODY = YES; + CLANG_WARN_ENUM_CONVERSION = YES; + CLANG_WARN_INFINITE_RECURSION = YES; + CLANG_WARN_INT_CONVERSION = YES; + CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; + CLANG_WARN_SUSPICIOUS_MOVE = YES; + CLANG_WARN_UNREACHABLE_CODE = YES; + CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; COMBINE_HIDPI_IMAGES = YES; COPY_PHASE_STRIP = NO; CURRENT_PROJECT_VERSION = "$(RC_ProjectSourceVersion)"; @@ -6952,6 +7653,7 @@ DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; DYLIB_COMPATIBILITY_VERSION = 1; DYLIB_CURRENT_VERSION = "$(RC_ProjectSourceVersion)"; + ENABLE_STRICT_OBJC_MSGSEND = YES; ENABLE_TESTABILITY = YES; GCC_NO_COMMON_BLOCKS = YES; GCC_OPTIMIZATION_LEVEL = 0; @@ -6959,9 +7661,18 @@ "$(inherited)", "DEBUG=1", ); + GCC_WARN_64_TO_32_BIT_CONVERSION = YES; + GCC_WARN_ABOUT_RETURN_TYPE = YES; + GCC_WARN_UNDECLARED_SELECTOR = YES; + GCC_WARN_UNINITIALIZED_AUTOS = YES; + GCC_WARN_UNUSED_FUNCTION = YES; + GCC_WARN_UNUSED_VARIABLE = YES; INSTALL_PATH = /usr/sbin; INTERPOSITION_SIM_SUFFIX = ""; + "INTERPOSITION_SIM_SUFFIX[sdk=bridgesimulator*]" = _sim; "INTERPOSITION_SIM_SUFFIX[sdk=iphonesimulator*]" = _sim; + "INTERPOSITION_SIM_SUFFIX[sdk=tvossimulator*]" = _sim; + "INTERPOSITION_SIM_SUFFIX[sdk=watchsimulator*]" = _sim; OTHER_CFLAGS = ( "$(inherited)", "-fconstant-cfstrings", @@ -6969,7 +7680,13 @@ "-DOS_ACTIVITY_OBJECT_API=1", ); OTHER_CFLAGS_asan = "-fsanitize=address"; - OTHER_LDFLAGS_asan = "-fsanitize=address"; + "OTHER_CFLAGS_asan[arch=i386]" = ""; + OTHER_CFLAGS_tsan = "-fsanitize=thread"; + "OTHER_CFLAGS_tsan[arch=i386]" = ""; + OTHER_LDFLAGS_asan = "-fsanitize=address -headerpad_max_install_names"; + "OTHER_LDFLAGS_asan[arch=i386]" = ""; + OTHER_LDFLAGS_tsan = "-fsanitize=thread -headerpad_max_install_names"; + "OTHER_LDFLAGS_tsan[arch=i386]" = ""; PLIST_FILE_OUTPUT_FORMAT = binary; RUN_CLANG_STATIC_ANALYZER = YES; SDKROOT = macosx.internal; @@ -6977,6 +7694,7 @@ VERSIONING_SYSTEM = "apple-generic"; WARNING_CFLAGS = ( "-Wall", + "-Wextra", "-Wno-four-char-constants", "-Wno-unknown-pragmas", "-Wformat-security", @@ -6994,16 +7712,38 @@ normal, "${EXTRA_BUILD_VARIANT}", ); + CLANG_ANALYZER_LOCALIZABILITY_NONLOCALIZED = YES; + CLANG_WARN_BOOL_CONVERSION = YES; + CLANG_WARN_CONSTANT_CONVERSION = YES; + CLANG_WARN_DOCUMENTATION_COMMENTS = YES; + CLANG_WARN_EMPTY_BODY = YES; + CLANG_WARN_ENUM_CONVERSION = YES; + CLANG_WARN_INFINITE_RECURSION = YES; + CLANG_WARN_INT_CONVERSION = YES; + CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; + CLANG_WARN_SUSPICIOUS_MOVE = YES; + CLANG_WARN_UNREACHABLE_CODE = YES; + CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; COMBINE_HIDPI_IMAGES = YES; CURRENT_PROJECT_VERSION = "$(RC_ProjectSourceVersion)"; DEAD_CODE_STRIPPING = YES; DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; DYLIB_COMPATIBILITY_VERSION = 1; DYLIB_CURRENT_VERSION = "$(RC_ProjectSourceVersion)"; + ENABLE_STRICT_OBJC_MSGSEND = YES; GCC_NO_COMMON_BLOCKS = YES; + GCC_WARN_64_TO_32_BIT_CONVERSION = YES; + GCC_WARN_ABOUT_RETURN_TYPE = YES; + GCC_WARN_UNDECLARED_SELECTOR = YES; + GCC_WARN_UNINITIALIZED_AUTOS = YES; + GCC_WARN_UNUSED_FUNCTION = YES; + GCC_WARN_UNUSED_VARIABLE = YES; INSTALL_PATH = /usr/sbin; INTERPOSITION_SIM_SUFFIX = ""; + "INTERPOSITION_SIM_SUFFIX[sdk=bridgesimulator*]" = _sim; "INTERPOSITION_SIM_SUFFIX[sdk=iphonesimulator*]" = _sim; + "INTERPOSITION_SIM_SUFFIX[sdk=tvossimulator*]" = _sim; + "INTERPOSITION_SIM_SUFFIX[sdk=watchsimulator*]" = _sim; OTHER_CFLAGS = ( "$(inherited)", "-fconstant-cfstrings", @@ -7011,13 +7751,21 @@ "-DOS_ACTIVITY_OBJECT_API=1", ); OTHER_CFLAGS_asan = "-fsanitize=address"; - OTHER_LDFLAGS_asan = "-fsanitize=address"; + "OTHER_CFLAGS_asan[arch=i386]" = ""; + OTHER_CFLAGS_tsan = "-fsanitize=thread"; + "OTHER_CFLAGS_tsan[arch=i386]" = ""; + OTHER_LDFLAGS_asan = "-fsanitize=address -headerpad_max_install_names"; + "OTHER_LDFLAGS_asan[arch=i386]" = ""; + OTHER_LDFLAGS_tsan = "-fsanitize=thread -headerpad_max_install_names"; + "OTHER_LDFLAGS_tsan[arch=i386]" = ""; PLIST_FILE_OUTPUT_FORMAT = binary; SDKROOT = macosx.internal; SUPPORTED_PLATFORMS = macosx; + SWIFT_OPTIMIZATION_LEVEL = "-Owholemodule"; VERSIONING_SYSTEM = "apple-generic"; WARNING_CFLAGS = ( "-Wall", + "-Wextra", "-Wno-four-char-constants", "-Wno-unknown-pragmas", "-Wformat-security", @@ -7049,7 +7797,7 @@ PRODUCT_BUNDLE_IDENTIFIER = com.apple.SystemConfiguration; PRODUCT_NAME = SystemConfiguration; SDKROOT = iphoneos.internal; - SUPPORTED_PLATFORMS = iphoneos; + SUPPORTED_PLATFORMS = "iphoneos tvos watchos bridgeos"; "USING_PRIVATE_SYSTEMCONFIGURATION_FRAMEWORK[sdk=appletv*]" = NO; "USING_PRIVATE_SYSTEMCONFIGURATION_FRAMEWORK[sdk=iphone*]" = NO; "USING_PRIVATE_SYSTEMCONFIGURATION_FRAMEWORK[sdk=watch*]" = YES; @@ -7079,7 +7827,7 @@ PRODUCT_BUNDLE_IDENTIFIER = com.apple.SystemConfiguration; PRODUCT_NAME = SystemConfiguration; SDKROOT = iphoneos.internal; - SUPPORTED_PLATFORMS = iphoneos; + SUPPORTED_PLATFORMS = "iphoneos tvos watchos bridgeos"; "USING_PRIVATE_SYSTEMCONFIGURATION_FRAMEWORK[sdk=appletv*]" = NO; "USING_PRIVATE_SYSTEMCONFIGURATION_FRAMEWORK[sdk=iphone*]" = NO; "USING_PRIVATE_SYSTEMCONFIGURATION_FRAMEWORK[sdk=watch*]" = YES; @@ -7104,7 +7852,7 @@ ); PRODUCT_NAME = configd_sim; SDKROOT = iphoneos.internal; - SUPPORTED_PLATFORMS = iphonesimulator; + SUPPORTED_PLATFORMS = "iphonesimulator tvossimulator watchsimulator bridgesimulator"; }; name = Debug; }; @@ -7125,7 +7873,7 @@ ); PRODUCT_NAME = configd_sim; SDKROOT = iphoneos.internal; - SUPPORTED_PLATFORMS = iphonesimulator; + SUPPORTED_PLATFORMS = "iphonesimulator tvossimulator watchsimulator bridgesimulator"; }; name = Release; }; @@ -7144,7 +7892,7 @@ ); PRODUCT_NAME = scutil_sim; SDKROOT = iphoneos.internal; - SUPPORTED_PLATFORMS = iphonesimulator; + SUPPORTED_PLATFORMS = "iphonesimulator tvossimulator watchsimulator bridgesimulator"; }; name = Debug; }; @@ -7163,7 +7911,7 @@ ); PRODUCT_NAME = scutil_sim; SDKROOT = iphoneos.internal; - SUPPORTED_PLATFORMS = iphonesimulator; + SUPPORTED_PLATFORMS = "iphonesimulator tvossimulator watchsimulator bridgesimulator"; }; name = Release; }; @@ -7198,7 +7946,7 @@ PUBLIC_HEADERS_FOLDER_PATH = /usr/local/include; SDKROOT = iphoneos.internal; STRIP_INSTALLED_PRODUCT_normal = YES; - SUPPORTED_PLATFORMS = iphonesimulator; + SUPPORTED_PLATFORMS = "iphonesimulator tvossimulator watchsimulator bridgesimulator"; }; name = Debug; }; @@ -7233,7 +7981,7 @@ PUBLIC_HEADERS_FOLDER_PATH = /usr/local/include; SDKROOT = iphoneos.internal; STRIP_INSTALLED_PRODUCT_normal = YES; - SUPPORTED_PLATFORMS = iphonesimulator; + SUPPORTED_PLATFORMS = "iphonesimulator tvossimulator watchsimulator bridgesimulator"; }; name = Release; }; @@ -7241,10 +7989,10 @@ isa = XCBuildConfiguration; buildSettings = { FRAMEWORK_SEARCH_PATHS = "$(SYMROOT)"; - INSTALL_PATH = /usr/sbin; + INSTALL_PATH = /usr/local/bin; PRODUCT_NAME = scselect; SDKROOT = iphoneos.internal; - SUPPORTED_PLATFORMS = iphoneos; + SUPPORTED_PLATFORMS = "iphoneos tvos watchos bridgeos"; }; name = Debug; }; @@ -7252,10 +8000,10 @@ isa = XCBuildConfiguration; buildSettings = { FRAMEWORK_SEARCH_PATHS = "$(SYMROOT)"; - INSTALL_PATH = /usr/sbin; + INSTALL_PATH = /usr/local/bin; PRODUCT_NAME = scselect; SDKROOT = iphoneos.internal; - SUPPORTED_PLATFORMS = iphoneos; + SUPPORTED_PLATFORMS = "iphoneos tvos watchos bridgeos"; }; name = Release; }; @@ -7273,7 +8021,7 @@ ); PRODUCT_NAME = scutil; SDKROOT = iphoneos.internal; - SUPPORTED_PLATFORMS = iphoneos; + SUPPORTED_PLATFORMS = "iphoneos tvos watchos bridgeos"; }; name = Debug; }; @@ -7291,7 +8039,7 @@ ); PRODUCT_NAME = scutil; SDKROOT = iphoneos.internal; - SUPPORTED_PLATFORMS = iphoneos; + SUPPORTED_PLATFORMS = "iphoneos tvos watchos bridgeos"; }; name = Release; }; @@ -7303,6 +8051,7 @@ INSTALLHDRS_COPY_PHASE = YES; INSTALL_PATH = /usr/lib/system; INSTALL_PATH_asan = /usr/local/lib; + INSTALL_PATH_tsan = /usr/local/lib; LINK_WITH_STANDARD_LIBRARIES = NO; OTHER_LDFLAGS = ( "-Wl,-umbrella,System", @@ -7322,17 +8071,28 @@ "-lxpc", "-Wl,-upward-lSystem", ); - "OTHER_LDFLAGS_asan[sdk=iphoneos*]" = "-headerpad_max_install_names -L${TOOLCHAIN_DIR}/usr/lib/clang/${CLANG_VERS}/lib/darwin -lclang_rt.asan_ios_dynamic"; - "OTHER_LDFLAGS_asan[sdk=iphonesimulator*]" = "-headerpad_max_install_names -L${TOOLCHAIN_DIR}/usr/lib/clang/${CLANG_VERS}/lib/darwin -lclang_rt.asan_iossim_dynamic"; - "OTHER_LDFLAGS_asan[sdk=tvos*]" = "-headerpad_max_install_names -L${TOOLCHAIN_DIR}/usr/lib/clang/${CLANG_VERS}/lib/darwin -lclang_rt.asan_tvos_dynamic"; - "OTHER_LDFLAGS_asan[sdk=tvossimulator*]" = "-headerpad_max_install_names -L${TOOLCHAIN_DIR}/usr/lib/clang/${CLANG_VERS}/lib/darwin -lclang_rt.asan_tvosossim_dynamic"; - "OTHER_LDFLAGS_asan[sdk=watchos*]" = "-headerpad_max_install_names -L${TOOLCHAIN_DIR}/usr/lib/clang/${CLANG_VERS}/lib/darwin -lclang_rt.asan_watchos_dynamic"; - "OTHER_LDFLAGS_asan[sdk=watchsimulator*]" = "-headerpad_max_install_names -L${TOOLCHAIN_DIR}/usr/lib/clang/${CLANG_VERS}/lib/darwin -lclang_rt.asan_watchossim_dynamic"; + "OTHER_LDFLAGS_asan[arch=i386]" = ""; + "OTHER_LDFLAGS_asan[sdk=iphoneos*]" = "$(inherited) -L/usr/local/lib/sanitizers -lclang_rt.asan_ios_dynamic"; + "OTHER_LDFLAGS_asan[sdk=iphonesimulator*]" = "$(inherited) -L/usr/local/lib/sanitizers -lclang_rt.asan_iossim_dynamic"; + "OTHER_LDFLAGS_asan[sdk=macosx*]" = "$(inherited) -L/usr/local/lib/sanitizers -lclang_rt.asan_osx_dynamic"; + "OTHER_LDFLAGS_asan[sdk=tvos*]" = "$(inherited) -L/usr/local/lib/sanitizers -lclang_rt.asan_tvos_dynamic"; + "OTHER_LDFLAGS_asan[sdk=tvossimulator*]" = "$(inherited) -L/usr/local/lib/sanitizers -lclang_rt.asan_tvosossim_dynamic"; + "OTHER_LDFLAGS_asan[sdk=watchos*]" = "$(inherited) -L/usr/local/lib/sanitizers -lclang_rt.asan_watchos_dynamic"; + "OTHER_LDFLAGS_asan[sdk=watchsimulator*]" = "$(inherited) -L/usr/local/lib/sanitizers -lclang_rt.asan_watchossim_dynamic"; + "OTHER_LDFLAGS_tsan[arch=i386]" = ""; + "OTHER_LDFLAGS_tsan[sdk=iphoneos*]" = "$(inherited) -L/usr/local/lib/sanitizers -lclang_rt.tsan_ios_dynamic"; + "OTHER_LDFLAGS_tsan[sdk=iphonesimulator*]" = "$(inherited) -L/usr/local/lib/sanitizers -lclang_rt.tsan_iossim_dynamic"; + "OTHER_LDFLAGS_tsan[sdk=macosx*]" = "$(inherited) -L/usr/local/lib/sanitizers -lclang_rt.tsan_osx_dynamic"; + "OTHER_LDFLAGS_tsan[sdk=tvos*]" = "$(inherited) -L/usr/local/lib/sanitizers -lclang_rt.tsan_tvos_dynamic"; + "OTHER_LDFLAGS_tsan[sdk=tvossimulator*]" = "$(inherited) -L/usr/local/lib/sanitizers -lclang_rt.tsan_tvosossim_dynamic"; + "OTHER_LDFLAGS_tsan[sdk=watchos*]" = "$(inherited) -L/usr/local/lib/sanitizers -lclang_rt.tsan_watchos_dynamic"; + "OTHER_LDFLAGS_tsan[sdk=watchsimulator*]" = "$(inherited) -L/usr/local/lib/sanitizers -lclang_rt.tsan_watchossim_dynamic"; PRODUCT_NAME = libsystem_configuration; SDKROOT = iphoneos.internal; STRIP_INSTALLED_PRODUCT_asan = NO; STRIP_INSTALLED_PRODUCT_normal = YES; - SUPPORTED_PLATFORMS = "iphoneos tvos watchos"; + STRIP_INSTALLED_PRODUCT_tsan = NO; + SUPPORTED_PLATFORMS = "iphoneos tvos watchos bridgeos"; }; name = Debug; }; @@ -7344,6 +8104,7 @@ INSTALLHDRS_COPY_PHASE = YES; INSTALL_PATH = /usr/lib/system; INSTALL_PATH_asan = /usr/local/lib; + INSTALL_PATH_tsan = /usr/local/lib; LINK_WITH_STANDARD_LIBRARIES = NO; OTHER_LDFLAGS = ( "-Wl,-umbrella,System", @@ -7363,17 +8124,28 @@ "-lxpc", "-Wl,-upward-lSystem", ); - "OTHER_LDFLAGS_asan[sdk=iphoneos*]" = "-headerpad_max_install_names -L${TOOLCHAIN_DIR}/usr/lib/clang/${CLANG_VERS}/lib/darwin -lclang_rt.asan_ios_dynamic"; - "OTHER_LDFLAGS_asan[sdk=iphonesimulator*]" = "-headerpad_max_install_names -L${TOOLCHAIN_DIR}/usr/lib/clang/${CLANG_VERS}/lib/darwin -lclang_rt.asan_iossim_dynamic"; - "OTHER_LDFLAGS_asan[sdk=tvos*]" = "-headerpad_max_install_names -L${TOOLCHAIN_DIR}/usr/lib/clang/${CLANG_VERS}/lib/darwin -lclang_rt.asan_tvos_dynamic"; - "OTHER_LDFLAGS_asan[sdk=tvossimulator*]" = "-headerpad_max_install_names -L${TOOLCHAIN_DIR}/usr/lib/clang/${CLANG_VERS}/lib/darwin -lclang_rt.asan_tvosossim_dynamic"; - "OTHER_LDFLAGS_asan[sdk=watchos*]" = "-headerpad_max_install_names -L${TOOLCHAIN_DIR}/usr/lib/clang/${CLANG_VERS}/lib/darwin -lclang_rt.asan_watchos_dynamic"; - "OTHER_LDFLAGS_asan[sdk=watchsimulator*]" = "-headerpad_max_install_names -L${TOOLCHAIN_DIR}/usr/lib/clang/${CLANG_VERS}/lib/darwin -lclang_rt.asan_watchossim_dynamic"; + "OTHER_LDFLAGS_asan[arch=i386]" = ""; + "OTHER_LDFLAGS_asan[sdk=iphoneos*]" = "$(inherited) -L/usr/local/lib/sanitizers -lclang_rt.asan_ios_dynamic"; + "OTHER_LDFLAGS_asan[sdk=iphonesimulator*]" = "$(inherited) -L/usr/local/lib/sanitizers -lclang_rt.asan_iossim_dynamic"; + "OTHER_LDFLAGS_asan[sdk=macosx*]" = "$(inherited) -L/usr/local/lib/sanitizers -lclang_rt.asan_osx_dynamic"; + "OTHER_LDFLAGS_asan[sdk=tvos*]" = "$(inherited) -L/usr/local/lib/sanitizers -lclang_rt.asan_tvos_dynamic"; + "OTHER_LDFLAGS_asan[sdk=tvossimulator*]" = "$(inherited) -L/usr/local/lib/sanitizers -lclang_rt.asan_tvosossim_dynamic"; + "OTHER_LDFLAGS_asan[sdk=watchos*]" = "$(inherited) -L/usr/local/lib/sanitizers -lclang_rt.asan_watchos_dynamic"; + "OTHER_LDFLAGS_asan[sdk=watchsimulator*]" = "$(inherited) -L/usr/local/lib/sanitizers -lclang_rt.asan_watchossim_dynamic"; + "OTHER_LDFLAGS_tsan[arch=i386]" = ""; + "OTHER_LDFLAGS_tsan[sdk=iphoneos*]" = "$(inherited) -L/usr/local/lib/sanitizers -lclang_rt.tsan_ios_dynamic"; + "OTHER_LDFLAGS_tsan[sdk=iphonesimulator*]" = "$(inherited) -L/usr/local/lib/sanitizers -lclang_rt.tsan_iossim_dynamic"; + "OTHER_LDFLAGS_tsan[sdk=macosx*]" = "$(inherited) -L/usr/local/lib/sanitizers -lclang_rt.tsan_osx_dynamic"; + "OTHER_LDFLAGS_tsan[sdk=tvos*]" = "$(inherited) -L/usr/local/lib/sanitizers -lclang_rt.tsan_tvos_dynamic"; + "OTHER_LDFLAGS_tsan[sdk=tvossimulator*]" = "$(inherited) -L/usr/local/lib/sanitizers -lclang_rt.tsan_tvosossim_dynamic"; + "OTHER_LDFLAGS_tsan[sdk=watchos*]" = "$(inherited) -L/usr/local/lib/sanitizers -lclang_rt.tsan_watchos_dynamic"; + "OTHER_LDFLAGS_tsan[sdk=watchsimulator*]" = "$(inherited) -L/usr/local/lib/sanitizers -lclang_rt.tsan_watchossim_dynamic"; PRODUCT_NAME = libsystem_configuration; SDKROOT = iphoneos.internal; STRIP_INSTALLED_PRODUCT_asan = NO; STRIP_INSTALLED_PRODUCT_normal = YES; - SUPPORTED_PLATFORMS = "iphoneos tvos watchos"; + STRIP_INSTALLED_PRODUCT_tsan = NO; + SUPPORTED_PLATFORMS = "iphoneos tvos watchos bridgeos"; }; name = Release; }; @@ -7393,7 +8165,7 @@ PRODUCT_NAME = IPMonitor; SDKROOT = iphoneos.internal; STRIP_INSTALLED_PRODUCT = NO; - SUPPORTED_PLATFORMS = iphoneos; + SUPPORTED_PLATFORMS = "iphoneos tvos watchos bridgeos"; }; name = Debug; }; @@ -7413,7 +8185,7 @@ PRODUCT_NAME = IPMonitor; SDKROOT = iphoneos.internal; STRIP_INSTALLED_PRODUCT = NO; - SUPPORTED_PLATFORMS = iphoneos; + SUPPORTED_PLATFORMS = "iphoneos tvos watchos bridgeos"; }; name = Release; }; @@ -7423,10 +8195,14 @@ DEBUG_INFORMATION_FORMAT = dwarf; INSTALL_PATH = /usr/local/lib/SystemConfiguration; LIBRARY_STYLE = STATIC; + OTHER_CFLAGS = ( + "$(inherited)", + "-DSC_LOG_HANDLE=\"__log_IPMonitor()\"", + ); PRODUCT_NAME = InterfaceNamer; SDKROOT = iphoneos.internal; STRIP_INSTALLED_PRODUCT = NO; - SUPPORTED_PLATFORMS = iphoneos; + SUPPORTED_PLATFORMS = "iphoneos tvos watchos bridgeos"; }; name = Debug; }; @@ -7436,10 +8212,14 @@ DEBUG_INFORMATION_FORMAT = dwarf; INSTALL_PATH = /usr/local/lib/SystemConfiguration; LIBRARY_STYLE = STATIC; + OTHER_CFLAGS = ( + "$(inherited)", + "-DSC_LOG_HANDLE=\"__log_IPMonitor()\"", + ); PRODUCT_NAME = InterfaceNamer; SDKROOT = iphoneos.internal; STRIP_INSTALLED_PRODUCT = NO; - SUPPORTED_PLATFORMS = iphoneos; + SUPPORTED_PLATFORMS = "iphoneos tvos watchos bridgeos"; }; name = Release; }; @@ -7457,7 +8237,7 @@ PRODUCT_NAME = KernelEventMonitor; SDKROOT = iphoneos.internal; STRIP_INSTALLED_PRODUCT = NO; - SUPPORTED_PLATFORMS = iphoneos; + SUPPORTED_PLATFORMS = "iphoneos tvos watchos bridgeos"; }; name = Debug; }; @@ -7475,7 +8255,7 @@ PRODUCT_NAME = KernelEventMonitor; SDKROOT = iphoneos.internal; STRIP_INSTALLED_PRODUCT = NO; - SUPPORTED_PLATFORMS = iphoneos; + SUPPORTED_PLATFORMS = "iphoneos tvos watchos bridgeos"; }; name = Release; }; @@ -7488,7 +8268,7 @@ PRODUCT_NAME = LinkConfiguration; SDKROOT = iphoneos.internal; STRIP_INSTALLED_PRODUCT = NO; - SUPPORTED_PLATFORMS = iphoneos; + SUPPORTED_PLATFORMS = "iphoneos tvos watchos bridgeos"; }; name = Debug; }; @@ -7501,7 +8281,7 @@ PRODUCT_NAME = LinkConfiguration; SDKROOT = iphoneos.internal; STRIP_INSTALLED_PRODUCT = NO; - SUPPORTED_PLATFORMS = iphoneos; + SUPPORTED_PLATFORMS = "iphoneos tvos watchos bridgeos"; }; name = Release; }; @@ -7514,7 +8294,7 @@ PRODUCT_NAME = PreferencesMonitor; SDKROOT = iphoneos.internal; STRIP_INSTALLED_PRODUCT = NO; - SUPPORTED_PLATFORMS = iphoneos; + SUPPORTED_PLATFORMS = "iphoneos tvos watchos bridgeos"; }; name = Debug; }; @@ -7527,7 +8307,7 @@ PRODUCT_NAME = PreferencesMonitor; SDKROOT = iphoneos.internal; STRIP_INSTALLED_PRODUCT = NO; - SUPPORTED_PLATFORMS = iphoneos; + SUPPORTED_PLATFORMS = "iphoneos tvos watchos bridgeos"; }; name = Release; }; @@ -7535,7 +8315,7 @@ isa = XCBuildConfiguration; buildSettings = { PRODUCT_NAME = "configd_libSystem (EmbeddedSimulator)"; - SUPPORTED_PLATFORMS = iphonesimulator; + SUPPORTED_PLATFORMS = "iphonesimulator tvossimulator watchsimulator bridgesimulator"; }; name = Debug; }; @@ -7543,7 +8323,7 @@ isa = XCBuildConfiguration; buildSettings = { PRODUCT_NAME = "configd_libSystem (EmbeddedSimulator)"; - SUPPORTED_PLATFORMS = iphonesimulator; + SUPPORTED_PLATFORMS = "iphonesimulator tvossimulator watchsimulator bridgesimulator"; }; name = Release; }; @@ -7551,7 +8331,7 @@ isa = XCBuildConfiguration; buildSettings = { PRODUCT_NAME = "configd_base (Embedded)"; - SUPPORTED_PLATFORMS = iphoneos; + SUPPORTED_PLATFORMS = "iphoneos tvos watchos bridgeos"; }; name = Debug; }; @@ -7559,7 +8339,7 @@ isa = XCBuildConfiguration; buildSettings = { PRODUCT_NAME = "configd_base (Embedded)"; - SUPPORTED_PLATFORMS = iphoneos; + SUPPORTED_PLATFORMS = "iphoneos tvos watchos bridgeos"; }; name = Release; }; @@ -7567,7 +8347,7 @@ isa = XCBuildConfiguration; buildSettings = { PRODUCT_NAME = "configd_plugins (Embedded)"; - SUPPORTED_PLATFORMS = iphoneos; + SUPPORTED_PLATFORMS = "iphoneos tvos watchos bridgeos"; }; name = Debug; }; @@ -7575,7 +8355,7 @@ isa = XCBuildConfiguration; buildSettings = { PRODUCT_NAME = "configd_plugins (Embedded)"; - SUPPORTED_PLATFORMS = iphoneos; + SUPPORTED_PLATFORMS = "iphoneos tvos watchos bridgeos"; }; name = Release; }; @@ -7583,7 +8363,7 @@ isa = XCBuildConfiguration; buildSettings = { PRODUCT_NAME = "configd_executables (Embedded)"; - SUPPORTED_PLATFORMS = iphoneos; + SUPPORTED_PLATFORMS = "iphoneos tvos watchos bridgeos"; }; name = Debug; }; @@ -7591,7 +8371,7 @@ isa = XCBuildConfiguration; buildSettings = { PRODUCT_NAME = "configd_executables (Embedded)"; - SUPPORTED_PLATFORMS = iphoneos; + SUPPORTED_PLATFORMS = "iphoneos tvos watchos bridgeos"; }; name = Release; }; @@ -7620,7 +8400,7 @@ ); PRODUCT_NAME = configd; SDKROOT = iphoneos.internal; - SUPPORTED_PLATFORMS = iphoneos; + SUPPORTED_PLATFORMS = "iphoneos tvos watchos bridgeos"; }; name = Debug; }; @@ -7649,7 +8429,7 @@ ); PRODUCT_NAME = configd; SDKROOT = iphoneos.internal; - SUPPORTED_PLATFORMS = iphoneos; + SUPPORTED_PLATFORMS = "iphoneos tvos watchos bridgeos"; }; name = Release; }; @@ -7661,7 +8441,7 @@ PRODUCT_BUNDLE_IDENTIFIER = com.apple.SystemConfiguration.IPMonitor; PRODUCT_NAME = IPMonitor; SDKROOT = iphoneos.internal; - SUPPORTED_PLATFORMS = iphoneos; + SUPPORTED_PLATFORMS = "iphoneos tvos watchos bridgeos"; }; name = Debug; }; @@ -7673,7 +8453,7 @@ PRODUCT_BUNDLE_IDENTIFIER = com.apple.SystemConfiguration.IPMonitor; PRODUCT_NAME = IPMonitor; SDKROOT = iphoneos.internal; - SUPPORTED_PLATFORMS = iphoneos; + SUPPORTED_PLATFORMS = "iphoneos tvos watchos bridgeos"; }; name = Release; }; @@ -7685,7 +8465,7 @@ PRODUCT_BUNDLE_IDENTIFIER = com.apple.SystemConfiguration.InterfaceNamer; PRODUCT_NAME = InterfaceNamer; SDKROOT = iphoneos.internal; - SUPPORTED_PLATFORMS = iphoneos; + SUPPORTED_PLATFORMS = "iphoneos tvos watchos bridgeos"; }; name = Debug; }; @@ -7697,7 +8477,7 @@ PRODUCT_BUNDLE_IDENTIFIER = com.apple.SystemConfiguration.InterfaceNamer; PRODUCT_NAME = InterfaceNamer; SDKROOT = iphoneos.internal; - SUPPORTED_PLATFORMS = iphoneos; + SUPPORTED_PLATFORMS = "iphoneos tvos watchos bridgeos"; }; name = Release; }; @@ -7709,7 +8489,7 @@ PRODUCT_BUNDLE_IDENTIFIER = com.apple.SystemConfiguration.KernelEventMonitor; PRODUCT_NAME = KernelEventMonitor; SDKROOT = iphoneos.internal; - SUPPORTED_PLATFORMS = iphoneos; + SUPPORTED_PLATFORMS = "iphoneos tvos watchos bridgeos"; }; name = Debug; }; @@ -7721,7 +8501,7 @@ PRODUCT_BUNDLE_IDENTIFIER = com.apple.SystemConfiguration.KernelEventMonitor; PRODUCT_NAME = KernelEventMonitor; SDKROOT = iphoneos.internal; - SUPPORTED_PLATFORMS = iphoneos; + SUPPORTED_PLATFORMS = "iphoneos tvos watchos bridgeos"; }; name = Release; }; @@ -7733,7 +8513,7 @@ PRODUCT_BUNDLE_IDENTIFIER = com.apple.SystemConfiguration.LinkConfiguration; PRODUCT_NAME = LinkConfiguration; SDKROOT = iphoneos.internal; - SUPPORTED_PLATFORMS = iphoneos; + SUPPORTED_PLATFORMS = "iphoneos tvos watchos bridgeos"; }; name = Debug; }; @@ -7745,7 +8525,7 @@ PRODUCT_BUNDLE_IDENTIFIER = com.apple.SystemConfiguration.LinkConfiguration; PRODUCT_NAME = LinkConfiguration; SDKROOT = iphoneos.internal; - SUPPORTED_PLATFORMS = iphoneos; + SUPPORTED_PLATFORMS = "iphoneos tvos watchos bridgeos"; }; name = Release; }; @@ -7757,7 +8537,7 @@ PRODUCT_BUNDLE_IDENTIFIER = com.apple.SystemConfiguration.PreferencesMonitor; PRODUCT_NAME = PreferencesMonitor; SDKROOT = iphoneos.internal; - SUPPORTED_PLATFORMS = iphoneos; + SUPPORTED_PLATFORMS = "iphoneos tvos watchos bridgeos"; }; name = Debug; }; @@ -7769,7 +8549,7 @@ PRODUCT_BUNDLE_IDENTIFIER = com.apple.SystemConfiguration.PreferencesMonitor; PRODUCT_NAME = PreferencesMonitor; SDKROOT = iphoneos.internal; - SUPPORTED_PLATFORMS = iphoneos; + SUPPORTED_PLATFORMS = "iphoneos tvos watchos bridgeos"; }; name = Release; }; @@ -7782,7 +8562,7 @@ "INSTALL_PATH[sdk=watch*]" = "$(SYSTEM_LIBRARY_DIR)/PrivateFrameworks/SystemConfiguration.framework"; PRODUCT_NAME = SCHelper; SDKROOT = iphoneos.internal; - SUPPORTED_PLATFORMS = iphoneos; + SUPPORTED_PLATFORMS = "iphoneos tvos watchos bridgeos"; }; name = Debug; }; @@ -7795,7 +8575,7 @@ "INSTALL_PATH[sdk=watch*]" = "$(SYSTEM_LIBRARY_DIR)/PrivateFrameworks/SystemConfiguration.framework"; PRODUCT_NAME = SCHelper; SDKROOT = iphoneos.internal; - SUPPORTED_PLATFORMS = iphoneos; + SUPPORTED_PLATFORMS = "iphoneos tvos watchos bridgeos"; }; name = Release; }; @@ -7824,7 +8604,7 @@ PRODUCT_BUNDLE_IDENTIFIER = com.apple.SystemConfiguration; PRODUCT_NAME = SystemConfiguration; SDKROOT = iphoneos.internal; - SUPPORTED_PLATFORMS = iphonesimulator; + SUPPORTED_PLATFORMS = "iphonesimulator tvossimulator watchsimulator bridgesimulator"; "USING_PRIVATE_SYSTEMCONFIGURATION_FRAMEWORK[sdk=appletv*]" = NO; "USING_PRIVATE_SYSTEMCONFIGURATION_FRAMEWORK[sdk=iphone*]" = NO; "USING_PRIVATE_SYSTEMCONFIGURATION_FRAMEWORK[sdk=watch*]" = YES; @@ -7857,7 +8637,7 @@ PRODUCT_BUNDLE_IDENTIFIER = com.apple.SystemConfiguration; PRODUCT_NAME = SystemConfiguration; SDKROOT = iphoneos.internal; - SUPPORTED_PLATFORMS = iphonesimulator; + SUPPORTED_PLATFORMS = "iphonesimulator tvossimulator watchsimulator bridgesimulator"; "USING_PRIVATE_SYSTEMCONFIGURATION_FRAMEWORK[sdk=appletv*]" = NO; "USING_PRIVATE_SYSTEMCONFIGURATION_FRAMEWORK[sdk=iphone*]" = NO; "USING_PRIVATE_SYSTEMCONFIGURATION_FRAMEWORK[sdk=watch*]" = YES; @@ -7883,7 +8663,7 @@ isa = XCBuildConfiguration; buildSettings = { PRODUCT_NAME = "configd_libSystem (Embedded)"; - SUPPORTED_PLATFORMS = iphoneos; + SUPPORTED_PLATFORMS = "iphoneos tvos watchos bridgeos"; }; name = Debug; }; @@ -7891,7 +8671,7 @@ isa = XCBuildConfiguration; buildSettings = { PRODUCT_NAME = "configd_libSystem (Embedded)"; - SUPPORTED_PLATFORMS = iphoneos; + SUPPORTED_PLATFORMS = "iphoneos tvos watchos bridgeos"; }; name = Release; }; @@ -7910,7 +8690,7 @@ PRODUCT_NAME = SimulatorSupport_sim; SDKROOT = iphoneos.internal; STRIP_INSTALLED_PRODUCT = NO; - SUPPORTED_PLATFORMS = iphonesimulator; + SUPPORTED_PLATFORMS = "iphonesimulator tvossimulator watchsimulator bridgesimulator"; }; name = Debug; }; @@ -7929,7 +8709,7 @@ PRODUCT_NAME = SimulatorSupport_sim; SDKROOT = iphoneos.internal; STRIP_INSTALLED_PRODUCT = NO; - SUPPORTED_PLATFORMS = iphonesimulator; + SUPPORTED_PLATFORMS = "iphonesimulator tvossimulator watchsimulator bridgesimulator"; }; name = Release; }; @@ -7941,7 +8721,7 @@ PRODUCT_BUNDLE_IDENTIFIER = com.apple.SystemConfiguration.SimulatorSupport; PRODUCT_NAME = SimulatorSupport; SDKROOT = iphoneos.internal; - SUPPORTED_PLATFORMS = iphonesimulator; + SUPPORTED_PLATFORMS = "iphonesimulator tvossimulator watchsimulator bridgesimulator"; }; name = Debug; }; @@ -7953,7 +8733,7 @@ PRODUCT_BUNDLE_IDENTIFIER = com.apple.SystemConfiguration.SimulatorSupport; PRODUCT_NAME = SimulatorSupport; SDKROOT = iphoneos.internal; - SUPPORTED_PLATFORMS = iphonesimulator; + SUPPORTED_PLATFORMS = "iphonesimulator tvossimulator watchsimulator bridgesimulator"; }; name = Release; }; @@ -7974,7 +8754,7 @@ PRODUCT_NAME = IPMonitor_sim; SDKROOT = iphoneos.internal; STRIP_INSTALLED_PRODUCT = NO; - SUPPORTED_PLATFORMS = iphonesimulator; + SUPPORTED_PLATFORMS = "iphonesimulator tvossimulator watchsimulator bridgesimulator"; }; name = Debug; }; @@ -7995,7 +8775,7 @@ PRODUCT_NAME = IPMonitor_sim; SDKROOT = iphoneos.internal; STRIP_INSTALLED_PRODUCT = NO; - SUPPORTED_PLATFORMS = iphonesimulator; + SUPPORTED_PLATFORMS = "iphonesimulator tvossimulator watchsimulator bridgesimulator"; }; name = Release; }; @@ -8007,7 +8787,7 @@ PRODUCT_BUNDLE_IDENTIFIER = com.apple.SystemConfiguration.IPMonitor; PRODUCT_NAME = IPMonitor; SDKROOT = iphoneos.internal; - SUPPORTED_PLATFORMS = iphonesimulator; + SUPPORTED_PLATFORMS = "iphonesimulator tvossimulator watchsimulator bridgesimulator"; }; name = Debug; }; @@ -8019,7 +8799,7 @@ PRODUCT_BUNDLE_IDENTIFIER = com.apple.SystemConfiguration.IPMonitor; PRODUCT_NAME = IPMonitor; SDKROOT = iphoneos.internal; - SUPPORTED_PLATFORMS = iphonesimulator; + SUPPORTED_PLATFORMS = "iphonesimulator tvossimulator watchsimulator bridgesimulator"; }; name = Release; }; @@ -8037,11 +8817,95 @@ }; name = Release; }; + 15F742E21EC6370000DA2E7A /* Debug */ = { + isa = XCBuildConfiguration; + buildSettings = { + CLANG_ANALYZER_LOCALIZABILITY_NONLOCALIZED = NO; + CLANG_ENABLE_OBJC_ARC = YES; + EXECUTABLE_PREFIX = liblog_; + GENERATE_PROFILING_CODE_profile = YES; + INSTALLHDRS_COPY_PHASE = YES; + INSTALL_PATH = /usr/lib/log; + OTHER_CFLAGS_debug = "-O0"; + PRODUCT_NAME = SystemConfiguration; + SDKROOT = iphoneos.internal; + STRIP_INSTALLED_PRODUCT_asan = NO; + STRIP_INSTALLED_PRODUCT_debug = NO; + STRIP_INSTALLED_PRODUCT_normal = YES; + STRIP_INSTALLED_PRODUCT_profile = NO; + STRIP_INSTALLED_PRODUCT_tsan = NO; + SUPPORTED_PLATFORMS = "iphoneos tvos watchos bridgeos"; + }; + name = Debug; + }; + 15F742E31EC6370000DA2E7A /* Release */ = { + isa = XCBuildConfiguration; + buildSettings = { + CLANG_ANALYZER_LOCALIZABILITY_NONLOCALIZED = NO; + CLANG_ENABLE_OBJC_ARC = YES; + EXECUTABLE_PREFIX = liblog_; + GENERATE_PROFILING_CODE_profile = YES; + INSTALLHDRS_COPY_PHASE = YES; + INSTALL_PATH = /usr/lib/log; + OTHER_CFLAGS_debug = "-O0"; + PRODUCT_NAME = SystemConfiguration; + SDKROOT = iphoneos.internal; + STRIP_INSTALLED_PRODUCT_asan = NO; + STRIP_INSTALLED_PRODUCT_debug = NO; + STRIP_INSTALLED_PRODUCT_normal = YES; + STRIP_INSTALLED_PRODUCT_profile = NO; + STRIP_INSTALLED_PRODUCT_tsan = NO; + SUPPORTED_PLATFORMS = "iphoneos tvos watchos bridgeos"; + }; + name = Release; + }; + 15F742EF1EC638D100DA2E7A /* Debug */ = { + isa = XCBuildConfiguration; + buildSettings = { + CLANG_ANALYZER_LOCALIZABILITY_NONLOCALIZED = NO; + CLANG_ENABLE_OBJC_ARC = YES; + EXECUTABLE_PREFIX = liblog_; + GENERATE_PROFILING_CODE_profile = YES; + INSTALLHDRS_COPY_PHASE = YES; + INSTALL_PATH = /usr/lib/log; + OTHER_CFLAGS_debug = "-O0"; + PRODUCT_NAME = SystemConfiguration; + SDKROOT = iphoneos.internal; + STRIP_INSTALLED_PRODUCT_asan = NO; + STRIP_INSTALLED_PRODUCT_debug = NO; + STRIP_INSTALLED_PRODUCT_normal = YES; + STRIP_INSTALLED_PRODUCT_profile = NO; + STRIP_INSTALLED_PRODUCT_tsan = NO; + SUPPORTED_PLATFORMS = "iphonesimulator tvossimulator watchsimulator bridgesimulator"; + }; + name = Debug; + }; + 15F742F01EC638D100DA2E7A /* Release */ = { + isa = XCBuildConfiguration; + buildSettings = { + CLANG_ANALYZER_LOCALIZABILITY_NONLOCALIZED = NO; + CLANG_ENABLE_OBJC_ARC = YES; + EXECUTABLE_PREFIX = liblog_; + GENERATE_PROFILING_CODE_profile = YES; + INSTALLHDRS_COPY_PHASE = YES; + INSTALL_PATH = /usr/lib/log; + OTHER_CFLAGS_debug = "-O0"; + PRODUCT_NAME = SystemConfiguration; + SDKROOT = iphoneos.internal; + STRIP_INSTALLED_PRODUCT_asan = NO; + STRIP_INSTALLED_PRODUCT_debug = NO; + STRIP_INSTALLED_PRODUCT_normal = YES; + STRIP_INSTALLED_PRODUCT_profile = NO; + STRIP_INSTALLED_PRODUCT_tsan = NO; + SUPPORTED_PLATFORMS = "iphonesimulator tvossimulator watchsimulator bridgesimulator"; + }; + name = Release; + }; 15FD13C70D59485000F9409C /* Debug */ = { isa = XCBuildConfiguration; buildSettings = { PRODUCT_NAME = configdAggregateEmbeddedSimulator; - SUPPORTED_PLATFORMS = iphonesimulator; + SUPPORTED_PLATFORMS = "iphonesimulator tvossimulator watchsimulator bridgesimulator"; }; name = Debug; }; @@ -8049,7 +8913,7 @@ isa = XCBuildConfiguration; buildSettings = { PRODUCT_NAME = configdAggregateEmbeddedSimulator; - SUPPORTED_PLATFORMS = iphonesimulator; + SUPPORTED_PLATFORMS = "iphonesimulator tvossimulator watchsimulator bridgesimulator"; }; name = Release; }; @@ -8099,7 +8963,7 @@ PLIST_FILE_OUTPUT_FORMAT = "same-as-input"; PRODUCT_NAME = sctest; SDKROOT = iphoneos.internal; - SUPPORTED_PLATFORMS = iphoneos; + SUPPORTED_PLATFORMS = "iphoneos tvos watchos bridgeos"; }; name = Debug; }; @@ -8117,7 +8981,7 @@ PLIST_FILE_OUTPUT_FORMAT = "same-as-input"; PRODUCT_NAME = sctest; SDKROOT = iphoneos.internal; - SUPPORTED_PLATFORMS = iphoneos; + SUPPORTED_PLATFORMS = "iphoneos tvos watchos bridgeos"; }; name = Release; }; @@ -8278,6 +9142,15 @@ defaultConfigurationIsVisible = 0; defaultConfigurationName = Release; }; + 151D06081EC1491600E02E48 /* Build configuration list for PBXNativeTarget "liblog_SystemConfiguration" */ = { + isa = XCConfigurationList; + buildConfigurations = ( + 151D06091EC1491600E02E48 /* Debug */, + 151D060A1EC1491600E02E48 /* Release */, + ); + defaultConfigurationIsVisible = 0; + defaultConfigurationName = Release; + }; 151F5D9F0CCE98E60093AC3B /* Build configuration list for PBXNativeTarget "SCMonitor" */ = { isa = XCConfigurationList; buildConfigurations = ( @@ -8341,6 +9214,15 @@ defaultConfigurationIsVisible = 0; defaultConfigurationName = Release; }; + 15631D231ECF98FB0088EEDD /* Build configuration list for PBXAggregateTarget "configd_executables-EmbeddedSimulator" */ = { + isa = XCConfigurationList; + buildConfigurations = ( + 15631D241ECF98FB0088EEDD /* Debug */, + 15631D251ECF98FB0088EEDD /* Release */, + ); + defaultConfigurationIsVisible = 0; + defaultConfigurationName = Release; + }; 156EB5DA0905594A00EEF749 /* Build configuration list for PBXNativeTarget "libsystem_configuration" */ = { isa = XCConfigurationList; buildConfigurations = ( @@ -8809,6 +9691,24 @@ defaultConfigurationIsVisible = 0; defaultConfigurationName = Release; }; + 15F742E11EC6370000DA2E7A /* Build configuration list for PBXNativeTarget "liblog_SystemConfiguration-Embedded" */ = { + isa = XCConfigurationList; + buildConfigurations = ( + 15F742E21EC6370000DA2E7A /* Debug */, + 15F742E31EC6370000DA2E7A /* Release */, + ); + defaultConfigurationIsVisible = 0; + defaultConfigurationName = Release; + }; + 15F742EE1EC638D100DA2E7A /* Build configuration list for PBXNativeTarget "liblog_SystemConfiguration-EmbeddedSimulator" */ = { + isa = XCConfigurationList; + buildConfigurations = ( + 15F742EF1EC638D100DA2E7A /* Debug */, + 15F742F01EC638D100DA2E7A /* Release */, + ); + defaultConfigurationIsVisible = 0; + defaultConfigurationName = Release; + }; 15FD13C60D59485000F9409C /* Build configuration list for PBXAggregateTarget "All-EmbeddedSimulator" */ = { isa = XCConfigurationList; buildConfigurations = ( diff --git a/dnsinfo/dnsinfo.h b/dnsinfo/dnsinfo.h index 6b27c81..83a76af 100644 --- a/dnsinfo/dnsinfo.h +++ b/dnsinfo/dnsinfo.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2004-2006, 2008, 2009, 2011-2013, 2015, 2016 Apple Inc. All rights reserved. + * Copyright (c) 2004-2006, 2008, 2009, 2011-2013, 2015-2017 Apple Inc. All rights reserved. * * @APPLE_LICENSE_HEADER_START@ * @@ -35,7 +35,7 @@ #include #include -#define DNSINFO_VERSION 20160901 +#define DNSINFO_VERSION 20170629 #define DEFAULT_SEARCH_ORDER 200000 /* search order for the "default" resolver domain name */ @@ -75,7 +75,7 @@ typedef struct { DNS_VAR(uint32_t, reach_flags); /* SCNetworkReachabilityFlags */ DNS_VAR(uint32_t, service_identifier); DNS_PTR(char *, cid); /* configuration identifer */ - DNS_VAR(uint32_t, reserved[2]); + DNS_PTR(char *, if_name); /* if_index interface name */ } dns_resolver_t; #pragma pack() @@ -100,6 +100,7 @@ typedef struct { DNS_VAR(uint64_t, generation); DNS_VAR(int32_t, n_service_specific_resolver); DNS_PTR(dns_resolver_t **, service_specific_resolver); + DNS_VAR(uint32_t, version); } dns_config_t; #pragma pack() diff --git a/dnsinfo/dnsinfo_copy.c b/dnsinfo/dnsinfo_copy.c index d506920..31d28fb 100644 --- a/dnsinfo/dnsinfo_copy.c +++ b/dnsinfo/dnsinfo_copy.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2004, 2006, 2008-2013, 2015, 2016 Apple Inc. All rights reserved. + * Copyright (c) 2004, 2006, 2008-2013, 2015-2017 Apple Inc. All rights reserved. * * @APPLE_LICENSE_HEADER_START@ * @@ -33,9 +33,16 @@ #include #include #include +#ifdef VERBOSE_ACTIVITY_LOGGING #include +#endif // VERBOSE_ACTIVITY_LOGGING #include +#ifndef SC_LOG_HANDLE +#include +#define my_log(__level, __format, ...) os_log(OS_LOG_DEFAULT, __format, ## __VA_ARGS__) +#endif // SC_LOG_HANDLE + #include "libSystemConfiguration_client.h" #include "dnsinfo.h" #include "dnsinfo_private.h" @@ -61,6 +68,7 @@ static int dnsinfo_active = 0; static libSC_info_client_t *dnsinfo_client = NULL; +#ifdef VERBOSE_ACTIVITY_LOGGING static os_activity_t __dns_configuration_activity() { @@ -75,6 +83,7 @@ __dns_configuration_activity() return activity; } +#endif // VERBOSE_ACTIVITY_LOGGING static dispatch_queue_t @@ -94,9 +103,8 @@ __dns_configuration_queue() dns_config_t * dns_configuration_copy() { - uint8_t *buf = NULL; - size_t bufLen; - dns_config_t *config = NULL; + dns_config_t *dns_config = NULL; + _dns_config_buf_t *dns_config_buf = NULL; static const char *proc_name = NULL; xpc_object_t reqdict; xpc_object_t reply; @@ -141,8 +149,10 @@ dns_configuration_copy() return NULL; } +#ifdef VERBOSE_ACTIVITY_LOGGING // scope DNS configuration activity os_activity_scope(__dns_configuration_activity()); +#endif // VERBOSE_ACTIVITY_LOGGING // create message reqdict = xpc_dictionary_create(NULL, NULL, 0); @@ -166,58 +176,21 @@ dns_configuration_copy() dataRef = xpc_dictionary_get_data(reply, DNSINFO_CONFIGURATION, &dataLen); if ((dataRef != NULL) && ((dataLen >= sizeof(_dns_config_buf_t)) && (dataLen <= DNS_CONFIG_BUF_MAX))) { - _dns_config_buf_t *config = (_dns_config_buf_t *)(void *)dataRef; - size_t configLen; - uint32_t n_attribute = ntohl(config->n_attribute); - uint32_t n_padding = ntohl(config->n_padding); - - /* - * Check that the size of the configuration header plus the size of the - * attribute data matches the size of the configuration buffer. - * - * If the sizes are different, something that should NEVER happen, CRASH! - */ - configLen = sizeof(_dns_config_buf_t) + n_attribute; - assert(configLen == dataLen); - - /* - * Check that the size of the requested padding would not result in our - * allocating a configuration + padding buffer larger than our maximum size. - * - * If the requested padding size is too large, something that should NEVER - * happen, CRASH! - */ - assert(n_padding <= (DNS_CONFIG_BUF_MAX - dataLen)); - - /* - * Check that the actual size of the configuration data and any requested - * padding will be less than the maximum possible size of the in-memory - * configuration buffer. - * - * If the length needed is too large, something that should NEVER happen, CRASH! - */ - bufLen = dataLen + n_padding; - assert(bufLen <= DNS_CONFIG_BUF_MAX); - - // allocate a buffer large enough to hold both the configuration - // data and the padding. - buf = malloc(bufLen); - bcopy((void *)dataRef, buf, dataLen); - bzero(&buf[dataLen], n_padding); + dns_config_buf = _dns_configuration_buffer_create(dataRef, dataLen); } xpc_release(reply); } - if (buf != NULL) { - /* ALIGN: cast okay since _dns_config_buf_t is int aligned */ - config = _dns_configuration_expand_config((_dns_config_buf_t *)(void *)buf); - if (config == NULL) { - free(buf); + if (dns_config_buf != NULL) { + dns_config = _dns_configuration_buffer_expand(dns_config_buf); + if (dns_config == NULL) { + // if we were unable to expand the configuration + _dns_configuration_buffer_free(&dns_config_buf); } } - return config; + return dns_config; } @@ -244,6 +217,7 @@ dns_configuration_free(dns_config_t *config) void _dns_configuration_ack(dns_config_t *config, const char *bundle_id) { +#pragma unused(bundle_id) xpc_object_t reqdict; if (config == NULL) { diff --git a/dnsinfo/dnsinfo_create.c b/dnsinfo/dnsinfo_create.c index 5e0b575..2732434 100644 --- a/dnsinfo/dnsinfo_create.c +++ b/dnsinfo/dnsinfo_create.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2004-2006, 2009, 2011-2013, 2015, 2016 Apple Inc. All rights reserved. + * Copyright (c) 2004-2006, 2009, 2011-2013, 2015-2017 Apple Inc. All rights reserved. * * @APPLE_LICENSE_HEADER_START@ * @@ -63,6 +63,7 @@ _dns_configuration_create() _dns_config_buf_t *config; config = calloc(1, INITIAL_CONFIGURATION_BUF_SIZE); + config->config.version = DNSINFO_VERSION; config->config.generation = mach_absolute_time(); // config->n_attribute = 0; // config->n_padding = 0; @@ -79,7 +80,6 @@ config_add_attribute(dns_create_config_t *_config, { _dns_config_buf_t *config = (_dns_config_buf_t *)*_config; dns_attribute_t *header; - int i; uint32_t newLen; uint32_t newSize; uint32_t oldLen; @@ -90,7 +90,7 @@ config_add_attribute(dns_create_config_t *_config, oldLen = ntohl(config->n_attribute); rounded_length = ROUNDUP(attribute_length, sizeof(uint32_t)); newLen = sizeof(dns_attribute_t) + rounded_length; - newSize = sizeof(_dns_config_buf_t) + oldLen + newLen; + newSize = sizeof(_dns_config_buf_t) + oldLen + newLen; if (newSize > INITIAL_CONFIGURATION_BUF_SIZE) { config = realloc(config, newSize); } @@ -109,7 +109,7 @@ config_add_attribute(dns_create_config_t *_config, // add attribute [data] bcopy(attribute, &header->attribute[0], attribute_length); - for (i = attribute_length; i < rounded_length; i++) { + for (uint32_t i = attribute_length; i < rounded_length; i++) { header->attribute[i] = 0; } @@ -252,7 +252,6 @@ _dns_resolver_add_attribute(dns_create_resolver_t *_resolver, void *attribute) { dns_attribute_t *header; - int i; uint32_t newLen; uint32_t newSize; uint32_t oldLen; @@ -280,7 +279,7 @@ _dns_resolver_add_attribute(dns_create_resolver_t *_resolver, // add attribute [data] bcopy(attribute, &header->attribute[0], attribute_length); - for (i = attribute_length; i < rounded_length; i++) { + for (uint32_t i = attribute_length; i < rounded_length; i++) { header->attribute[i] = 0; } @@ -381,11 +380,16 @@ _dns_resolver_set_flags(dns_create_resolver_t *_resolver, uint32_t flags) __private_extern__ void -_dns_resolver_set_if_index(dns_create_resolver_t *_resolver, uint32_t if_index) +_dns_resolver_set_if_index(dns_create_resolver_t *_resolver, + uint32_t if_index, + const char *if_name) { _dns_resolver_buf_t *resolver = (_dns_resolver_buf_t *)*_resolver; resolver->resolver.if_index = htonl(if_index); + if (if_name != NULL) { + _dns_resolver_add_attribute(_resolver, RESOLVER_ATTRIBUTE_INTERFACE_NAME, (uint32_t)strlen(if_name), (void *)if_name); + } return; } diff --git a/dnsinfo/dnsinfo_create.h b/dnsinfo/dnsinfo_create.h index d03b32e..f3d805a 100644 --- a/dnsinfo/dnsinfo_create.h +++ b/dnsinfo/dnsinfo_create.h @@ -1,15 +1,15 @@ /* - * Copyright (c) 2004-2006, 2008, 2009, 2011-2013, 2015 Apple Inc. All rights reserved. + * Copyright (c) 2004-2006, 2008, 2009, 2011-2013, 2015, 2017 Apple Inc. All rights reserved. * * @APPLE_LICENSE_HEADER_START@ - * + * * This file contains Original Code and/or Modifications of Original Code * as defined in and that are subject to the Apple Public Source License * Version 2.0 (the 'License'). You may not use this file except in * compliance with the License. Please obtain a copy of the License at * http://www.opensource.apple.com/apsl/ and read it before using this * file. - * + * * The Original Code and all software distributed under the License are * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, @@ -17,7 +17,7 @@ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. * Please see the License for the specific language governing rights and * limitations under the License. - * + * * @APPLE_LICENSE_HEADER_END@ */ @@ -100,7 +100,8 @@ _dns_resolver_set_flags (dns_create_resolver_t *_resolver, void _dns_resolver_set_if_index (dns_create_resolver_t *_resolver, - uint32_t if_index) __OSX_AVAILABLE_STARTING(__MAC_10_7,__IPHONE_4_0); + uint32_t if_index, + const char *if_name) __OSX_AVAILABLE_STARTING(__MAC_10_7,__IPHONE_4_0); void _dns_resolver_set_options (dns_create_resolver_t *_resolver, diff --git a/dnsinfo/dnsinfo_flatfile.c b/dnsinfo/dnsinfo_flatfile.c index 28b0861..7317d25 100644 --- a/dnsinfo/dnsinfo_flatfile.c +++ b/dnsinfo/dnsinfo_flatfile.c @@ -1,15 +1,15 @@ /* - * Copyright (c) 2009, 2011, 2012, 2014, 2015 Apple Inc. All rights reserved. + * Copyright (c) 2009, 2011, 2012, 2014, 2015, 2017 Apple Inc. All rights reserved. * * @APPLE_LICENSE_HEADER_START@ - * + * * This file contains Original Code and/or Modifications of Original Code * as defined in and that are subject to the Apple Public Source License * Version 2.0 (the 'License'). You may not use this file except in * compliance with the License. Please obtain a copy of the License at * http://www.opensource.apple.com/apsl/ and read it before using this * file. - * + * * The Original Code and all software distributed under the License are * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, @@ -17,7 +17,7 @@ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. * Please see the License for the specific language governing rights and * limitations under the License. - * + * * @APPLE_LICENSE_HEADER_END@ */ @@ -35,6 +35,10 @@ #include #include +#ifdef MAIN +#define my_log(__level, __format, ...) SCPrint(TRUE, stdout, CFSTR(__format "\n"), ## __VA_ARGS__) +#endif // MAIN + #include "dnsinfo.h" #include "dnsinfo_private.h" #include "dnsinfo_create.h" @@ -293,7 +297,6 @@ _dnsinfo_flatfile_create_resolver(const char *dir, const char *path) if (f == NULL) return NULL; while ((buf = fgetln(f, &len)) != NULL) { - int i; char *lineptr; int max_count; int token; @@ -321,7 +324,7 @@ _dnsinfo_flatfile_create_resolver(const char *dir, const char *path) // translate config token to enumerated value token = -1; - for (i = 0; i < sizeof(tokens) / sizeof(tokens[0]); i++) { + for (size_t i = 0; i < sizeof(tokens) / sizeof(tokens[0]); i++) { if (strcasecmp(word, tokens[i].name) == 0) { token = tokens[i].token; max_count = tokens[i].max_count; @@ -389,7 +392,7 @@ _dnsinfo_flatfile_create_resolver(const char *dir, const char *path) if_index = if_nametoindex(word); if (if_index > 0) { - _dns_resolver_set_if_index(&res, if_index); + _dns_resolver_set_if_index(&res, if_index, word); } break; } @@ -562,31 +565,44 @@ _dnsinfo_flatfile_add_resolvers(dns_create_config_t *config) #ifdef MAIN #undef MAIN +#include "dnsinfo_logging.h" #include "dnsinfo_copy.c" int main(int argc, char **argv) { - uint8_t *buf; - dns_config_t *config; - dns_create_config_t create_config; - _dns_config_buf_t *config_buf; - uint32_t n_config; - uint32_t n_padding; - dns_create_resolver_t resolver; - - resolver = _dnsinfo_flatfile_create_resolver(NULL, _PATH_RESCONF); - - create_config = _dns_configuration_create(); - _dnsinfo_flatfile_add_resolvers(&create_config); - - config_buf = (_dns_config_buf_t *)create_config; - n_config = sizeof(_dns_config_buf_t) + ntohl(config_buf->n_attribute); - n_padding = ntohl(config_buf->n_padding); - buf = malloc(n_config + n_padding); - bcopy((void *)config_buf, buf, n_config); - bzero(&buf[n_config], n_padding); - config = _dns_configuration_expand_config((_dns_config_buf_t *)buf); + dns_config_t *dns_config = NULL; + _dns_config_buf_t *dns_config_buf = NULL; + dns_create_config_t dns_create_config; + dns_create_resolver_t dns_create_resolver; + + dns_create_resolver = _dnsinfo_flatfile_create_resolver(NULL, _PATH_RESCONF); + _dns_resolver_free(&dns_create_resolver); + + dns_create_config = _dns_configuration_create(); + if (dns_create_config != NULL) { + size_t n; + + _dnsinfo_flatfile_add_resolvers(&dns_create_config); + + n = sizeof(_dns_config_buf_t); + n += ntohl(((_dns_config_buf_t *)dns_create_config)->n_attribute); + dns_config_buf = _dns_configuration_buffer_create((void *)dns_create_config, n); + _dns_configuration_free(&dns_create_config); + } + + if (dns_config_buf != NULL) { + dns_config = _dns_configuration_buffer_expand(dns_config_buf); + if (dns_config == NULL) { + // if we were unable to expand the configuration + _dns_configuration_buffer_free(&dns_config_buf); + } + } + + if (dns_config != NULL) { + _dns_configuration_log(dns_config, TRUE, NULL); + free(dns_config); + } return 0; } diff --git a/dnsinfo/dnsinfo_internal.h b/dnsinfo/dnsinfo_internal.h index 71b31fb..c677213 100644 --- a/dnsinfo/dnsinfo_internal.h +++ b/dnsinfo/dnsinfo_internal.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013, 2015, 2016 Apple Inc. All rights reserved. + * Copyright (c) 2013, 2015-2017 Apple Inc. All rights reserved. * * @APPLE_LICENSE_HEADER_START@ * @@ -29,32 +29,27 @@ #include #include #include -#include "SCNetworkReachabilityInternal.h" #include #include #include "dnsinfo_private.h" +#define DNS_CONFIG_BUF_MAX 1024*1024 __BEGIN_DECLS - #ifndef my_log -#define MY_LOG_DEFINED_LOCALLY #define my_log(__level, __format, ...) SC_log(__level, __format, ## __VA_ARGS__) +#define MY_LOG_DEFINED_LOCALLY #endif // !my_log - -#define DNS_CONFIG_BUF_MAX 1024*1024 - - /* * claim space for a list [of pointers] from the expanded DNS configuration padding */ static __inline__ boolean_t -__dns_configuration_expand_add_list(void **padding, uint32_t *n_padding, int32_t count, int32_t size, void **list) +__dns_configuration_expand_add_list(void **padding, uint32_t *n_padding, uint32_t count, uint32_t size, void **list) { - int32_t need; + uint32_t need; need = count * size; if (need > *n_padding) { @@ -79,6 +74,7 @@ _dns_configuration_expand_resolver(_dns_resolver_buf_t *buf, uint32_t n_buf, voi int32_t n_nameserver = 0; int32_t n_search = 0; int32_t n_sortaddr = 0; + void *ptr; dns_resolver_t *resolver = (dns_resolver_t *)&buf->resolver; if (n_buf < sizeof(_dns_resolver_buf_t)) { @@ -96,9 +92,10 @@ _dns_configuration_expand_resolver(_dns_resolver_buf_t *buf, uint32_t n_buf, voi n_padding, resolver->n_nameserver, sizeof(DNS_PTR(struct sockaddr *, x)), - (void **)&resolver->nameserver)) { + &ptr)) { goto error; } + resolver->nameserver = ptr; // initialize port @@ -111,9 +108,10 @@ _dns_configuration_expand_resolver(_dns_resolver_buf_t *buf, uint32_t n_buf, voi n_padding, resolver->n_search, sizeof(DNS_PTR(char *, x)), - (void **)&resolver->search)) { + &ptr)) { goto error; } + resolver->search = ptr; // initialize sortaddr list @@ -122,9 +120,10 @@ _dns_configuration_expand_resolver(_dns_resolver_buf_t *buf, uint32_t n_buf, voi n_padding, resolver->n_sortaddr, sizeof(DNS_PTR(dns_sortaddr_t *, x)), - (void **)&resolver->sortaddr)) { + &ptr)) { goto error; } + resolver->sortaddr = ptr; // initialize options @@ -200,6 +199,10 @@ _dns_configuration_expand_resolver(_dns_resolver_buf_t *buf, uint32_t n_buf, voi resolver->cid = (char *)&attribute->attribute[0]; break; + case RESOLVER_ATTRIBUTE_INTERFACE_NAME : + resolver->if_name = (char *)&attribute->attribute[0]; + break; + default : break; } @@ -222,11 +225,101 @@ _dns_configuration_expand_resolver(_dns_resolver_buf_t *buf, uint32_t n_buf, voi } +/* + * initialize a DNS "configuration" buffer + */ +static __inline__ _dns_config_buf_t * +_dns_configuration_buffer_create(const void *dataRef, size_t dataLen) +{ + uint8_t *buf = NULL; + size_t bufLen; + _dns_config_buf_t *config = (_dns_config_buf_t *)dataRef; + size_t configLen; + uint32_t n_attribute = ntohl(config->n_attribute); + uint32_t n_padding = ntohl(config->n_padding); + + /* + * Check that the size of the configuration header plus the size of the + * attribute data matches the size of the configuration buffer. + * + * If the sizes are different, something that should NEVER happen, CRASH! + */ + configLen = sizeof(_dns_config_buf_t) + n_attribute; +#ifdef DEBUG + assert(configLen == dataLen); +#else // DEBUG + if (configLen != dataLen) { + my_log(LOG_ERR, "DNS configuration: size error (%zu != %zu)", configLen, dataLen); + return NULL; + } +#endif // DEBUG + + /* + * Check that the size of the requested padding would not result in our + * allocating a configuration + padding buffer larger than our maximum size. + * + * If the requested padding size is too large, something that should NEVER + * happen, CRASH! + */ +#ifdef DEBUG + assert(n_padding <= (DNS_CONFIG_BUF_MAX - dataLen)); +#else // DEBUG + if (n_padding > (DNS_CONFIG_BUF_MAX - dataLen)) { + my_log(LOG_ERR, "DNS configuration: padding error (%u > %zu)", + n_padding, + (DNS_CONFIG_BUF_MAX - dataLen)); + return NULL; + } +#endif // DEBUG + + /* + * Check that the actual size of the configuration data and any requested + * padding will be less than the maximum possible size of the in-memory + * configuration buffer. + * + * If the length needed is too large, something that should NEVER happen, CRASH! + */ + bufLen = dataLen + n_padding; +#ifdef DEBUG + assert(bufLen <= DNS_CONFIG_BUF_MAX); +#else // DEBUG + if (bufLen > DNS_CONFIG_BUF_MAX) { + my_log(LOG_ERR, "DNS configuration: length error (%zu > %u)", + bufLen, + DNS_CONFIG_BUF_MAX); + return NULL; + } +#endif // DEBUG + + // allocate a buffer large enough to hold both the configuration + // data and the padding. + buf = malloc(bufLen); + bcopy((void *)dataRef, buf, dataLen); + bzero(&buf[dataLen], n_padding); + + return (_dns_config_buf_t *)(void *)buf; +} + + +/* + * expand a DNS "configuration" from the provided buffer + */ +static __inline__ void +_dns_configuration_buffer_free(_dns_config_buf_t **buf) +{ + _dns_config_buf_t *config = (_dns_config_buf_t *)*buf; + + free(config); + *buf = NULL; + return; +} + + /* * expand a DNS "configuration" from the provided buffer */ static __inline__ dns_config_t * -_dns_configuration_expand_config(_dns_config_buf_t *buf) +_dns_configuration_buffer_expand(_dns_config_buf_t *buf) { dns_attribute_t *attribute; dns_config_t *config = (dns_config_t *)buf; @@ -236,6 +329,7 @@ _dns_configuration_expand_config(_dns_config_buf_t *buf) int32_t n_scoped_resolver = 0; int32_t n_service_specific_resolver = 0; void *padding; + void *ptr; n_attribute = ntohl(buf->n_attribute); // pre-validated (or known OK) at entry n_padding = ntohl(buf->n_padding); // pre-validated (or known OK) at entry @@ -251,27 +345,30 @@ _dns_configuration_expand_config(_dns_config_buf_t *buf) &n_padding, config->n_resolver, sizeof(DNS_PTR(dns_resolver_t *, x)), - (void **)&config->resolver)) { + &ptr)) { goto error; } + config->resolver = ptr; config->n_scoped_resolver = ntohl(config->n_scoped_resolver); if (!__dns_configuration_expand_add_list(&padding, &n_padding, config->n_scoped_resolver, sizeof(DNS_PTR(dns_resolver_t *, x)), - (void **)&config->scoped_resolver)) { + &ptr)) { goto error; } + config->scoped_resolver = ptr; config->n_service_specific_resolver = ntohl(config->n_service_specific_resolver); if (!__dns_configuration_expand_add_list(&padding, &n_padding, config->n_service_specific_resolver, sizeof(DNS_PTR(dns_resolver_t *, x)), - (void **)&config->service_specific_resolver)) { + &ptr)) { goto error; } + config->service_specific_resolver = ptr; // process configuration buffer "attribute" data @@ -346,166 +443,11 @@ _dns_configuration_expand_config(_dns_config_buf_t *buf) return NULL; } - -static __inline__ void -_dns_resolver_log(dns_resolver_t *resolver, int index, Boolean debug) -{ - int i; - uint32_t flags; - CFMutableStringRef str; - - my_log(LOG_INFO, " "); - my_log(LOG_INFO, "resolver #%d", index); - - if (resolver->domain != NULL) { - my_log(LOG_INFO, " domain : %s", resolver->domain); - } - - for (i = 0; i < resolver->n_search; i++) { - my_log(LOG_INFO, " search domain[%d] : %s", i, resolver->search[i]); - } - - for (i = 0; i < resolver->n_nameserver; i++) { - char buf[128]; - - _SC_sockaddr_to_string(resolver->nameserver[i], buf, sizeof(buf)); - my_log(LOG_INFO, " nameserver[%d] : %s", i, buf); - } - - for (i = 0; i < resolver->n_sortaddr; i++) { - char abuf[32]; - char mbuf[32]; - - (void)inet_ntop(AF_INET, &resolver->sortaddr[i]->address, abuf, sizeof(abuf)); - (void)inet_ntop(AF_INET, &resolver->sortaddr[i]->mask, mbuf, sizeof(mbuf)); - my_log(LOG_INFO, " sortaddr[%d] : %s/%s", i, abuf, mbuf); - } - - if (resolver->options != NULL) { - my_log(LOG_INFO, " options : %s", resolver->options); - } - - if (resolver->port != 0) { - my_log(LOG_INFO, " port : %hd", resolver->port); - } - - if (resolver->timeout != 0) { - my_log(LOG_INFO, " timeout : %d", resolver->timeout); - } - - if (resolver->if_index != 0) { - char buf[IFNAMSIZ]; - char *if_name; - - if_name = if_indextoname(resolver->if_index, buf); - my_log(LOG_INFO, " if_index : %d (%s)", - resolver->if_index, - (if_name != NULL) ? if_name : "?"); - } - - if (resolver->service_identifier != 0) { - my_log(LOG_INFO, " service_identifier : %d", - resolver->service_identifier); - } - - flags = resolver->flags; - str = CFStringCreateMutable(NULL, 0); - CFStringAppend(str, CFSTR(" flags : ")); - if (debug) { - CFStringAppendFormat(str, NULL, CFSTR("0x%08x ("), flags); - } - if (flags & DNS_RESOLVER_FLAGS_SCOPED) { - flags &= ~DNS_RESOLVER_FLAGS_SCOPED; - CFStringAppendFormat(str, NULL, CFSTR("Scoped%s"), flags != 0 ? ", " : ""); - } - if (flags & DNS_RESOLVER_FLAGS_SERVICE_SPECIFIC) { - flags &= ~DNS_RESOLVER_FLAGS_SERVICE_SPECIFIC; - CFStringAppendFormat(str, NULL, CFSTR("Service-specific%s"), flags != 0 ? ", " : ""); - } - if (flags & DNS_RESOLVER_FLAGS_SUPPLEMENTAL) { - flags &= ~DNS_RESOLVER_FLAGS_SUPPLEMENTAL; - CFStringAppendFormat(str, NULL, CFSTR("Supplemental%s"), flags != 0 ? ", " : ""); - } - if (flags & DNS_RESOLVER_FLAGS_REQUEST_A_RECORDS) { - flags &= ~DNS_RESOLVER_FLAGS_REQUEST_A_RECORDS; - CFStringAppendFormat(str, NULL, CFSTR("Request A records%s"), flags != 0 ? ", " : ""); - } - if (flags & DNS_RESOLVER_FLAGS_REQUEST_AAAA_RECORDS) { - flags &= ~DNS_RESOLVER_FLAGS_REQUEST_AAAA_RECORDS; - CFStringAppendFormat(str, NULL, CFSTR("Request AAAA records%s"), flags != 0 ? ", " : ""); - } - if (flags != 0) { - CFStringAppendFormat(str, NULL, CFSTR("0x%08x"), flags); - } - if (debug) { - CFStringAppend(str, CFSTR(")")); - } - my_log(LOG_INFO, "%@", str); - CFRelease(str); - - str = (CFMutableStringRef)__SCNetworkReachabilityCopyFlags(resolver->reach_flags, - CFSTR(" reach : "), - debug); - my_log(LOG_INFO, "%@", str); - CFRelease(str); - - if (resolver->search_order != 0) { - my_log(LOG_INFO, " order : %d", resolver->search_order); - } - - if (debug && (resolver->cid != NULL)) { - my_log(LOG_INFO, " config id: %s", resolver->cid); - } - - return; -} - - -static __inline__ void -_dns_configuration_log(dns_config_t *dns_config, Boolean debug) -{ - int i; - - my_log(LOG_INFO, "DNS configuration"); - - for (i = 0; i < dns_config->n_resolver; i++) { - dns_resolver_t *resolver = dns_config->resolver[i]; - - _dns_resolver_log(resolver, i + 1, debug); - } - - if ((dns_config->n_scoped_resolver > 0) && (dns_config->scoped_resolver != NULL)) { - my_log(LOG_INFO, " "); - my_log(LOG_INFO, "DNS configuration (for scoped queries)"); - - for (i = 0; i < dns_config->n_scoped_resolver; i++) { - dns_resolver_t *resolver = dns_config->scoped_resolver[i]; - - _dns_resolver_log(resolver, i + 1, debug); - } - } - - if ((dns_config->n_service_specific_resolver > 0) && (dns_config->service_specific_resolver != NULL)) { - my_log(LOG_INFO, " "); - my_log(LOG_INFO, "DNS configuration (for service-specific queries)"); - - for (i = 0; i < dns_config->n_service_specific_resolver; i++) { - dns_resolver_t *resolver = dns_config->service_specific_resolver[i]; - - _dns_resolver_log(resolver, i + 1, debug); - } - } - - return; -} - - #ifdef MY_LOG_DEFINED_LOCALLY #undef my_log #undef MY_LOG_DEFINED_LOCALLY #endif // MY_LOG_DEFINED_LOCALLY - __END_DECLS #endif /* !_S_DNSINFO_INTERNAL_H */ diff --git a/dnsinfo/dnsinfo_logging.h b/dnsinfo/dnsinfo_logging.h new file mode 100644 index 0000000..800b4b0 --- /dev/null +++ b/dnsinfo/dnsinfo_logging.h @@ -0,0 +1,245 @@ +/* + * Copyright (c) 2017 Apple Inc. All rights reserved. + * + * @APPLE_LICENSE_HEADER_START@ + * + * This file contains Original Code and/or Modifications of Original Code + * as defined in and that are subject to the Apple Public Source License + * Version 2.0 (the 'License'). You may not use this file except in + * compliance with the License. Please obtain a copy of the License at + * http://www.opensource.apple.com/apsl/ and read it before using this + * file. + * + * The Original Code and all software distributed under the License are + * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, + * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. + * Please see the License for the specific language governing rights and + * limitations under the License. + * + * @APPLE_LICENSE_HEADER_END@ + */ + +#ifndef _S_DNSINFO_LOGGING_H +#define _S_DNSINFO_LOGGING_H + +#include +#include +#include +#include +#include +#include +#include "SCNetworkReachabilityLogging.h" +#include +#include +#include +#include +#include + +#include +#include "dnsinfo_private.h" + +__BEGIN_DECLS + +#ifndef my_log +#define my_log(__level, __format, ...) SC_log(__level, __format, ## __VA_ARGS__) +#define MY_LOG_DEFINED_LOCALLY +#endif // !my_log + +#ifndef my_log_context_type +#define MY_LOG_CONTEXT_TYPE_DEFINED_LOCALLY +#define my_log_context_type void * +#endif // !my_log_context_type + +#ifndef my_log_context_name +#define MY_LOG_CONTEXT_NAME_DEFINED_LOCALLY +#define my_log_context_name context +#endif // !my_log_context_name + +static __inline__ void +_dns_resolver_log(uint32_t version, dns_resolver_t *resolver, int index, Boolean debug, my_log_context_type my_log_context_name) +{ +#if defined(MY_LOG_CONTEXT_TYPE_DEFINED_LOCALLY) && defined(MY_LOG_CONTEXT_NAME_DEFINED_LOCALLY) +#pragma unused(my_log_context_name) +#endif + int i; + uint32_t flags; + char reach_str[100]; + CFMutableStringRef str; + + my_log(LOG_INFO, "%s", ""); + my_log(LOG_INFO, "resolver #%d", index); + + if (resolver->domain != NULL) { + my_log(LOG_INFO, " domain : %s", resolver->domain); + } + + for (i = 0; i < resolver->n_search; i++) { + my_log(LOG_INFO, " search domain[%d] : %s", i, resolver->search[i]); + } + + for (i = 0; i < resolver->n_nameserver; i++) { + char buf[128]; + + _SC_sockaddr_to_string(resolver->nameserver[i], buf, sizeof(buf)); + my_log(LOG_INFO, " nameserver[%d] : %s", i, buf); + } + + for (i = 0; i < resolver->n_sortaddr; i++) { + char abuf[32]; + char mbuf[32]; + + (void)inet_ntop(AF_INET, &resolver->sortaddr[i]->address, abuf, sizeof(abuf)); + (void)inet_ntop(AF_INET, &resolver->sortaddr[i]->mask, mbuf, sizeof(mbuf)); + my_log(LOG_INFO, " sortaddr[%d] : %s/%s", i, abuf, mbuf); + } + + if (resolver->options != NULL) { + my_log(LOG_INFO, " options : %s", resolver->options); + } + + if (resolver->port != 0) { + my_log(LOG_INFO, " port : %hd", resolver->port); + } + + if (resolver->timeout != 0) { + my_log(LOG_INFO, " timeout : %d", resolver->timeout); + } + + if (resolver->if_index != 0) { +#ifndef _LIBLOG_SYSTEMCONFIGURATION_ + char buf[IFNAMSIZ]; +#endif // !_LIBLOG_SYSTEMCONFIGURATION_ + char *if_name = NULL; + + if ((version >= 20170629) && (resolver->if_name != NULL)) { + if_name = resolver->if_name; +#ifndef _LIBLOG_SYSTEMCONFIGURATION_ + } else { + if_name = if_indextoname(resolver->if_index, buf); +#endif // !_LIBLOG_SYSTEMCONFIGURATION_ + } + my_log(LOG_INFO, " if_index : %d (%s)", + resolver->if_index, + (if_name != NULL) ? if_name : "?"); + } + + if (resolver->service_identifier != 0) { + my_log(LOG_INFO, " service_identifier : %d", + resolver->service_identifier); + } + + flags = resolver->flags; + str = CFStringCreateMutable(NULL, 0); + CFStringAppend(str, CFSTR(" flags : ")); + if (debug) { + CFStringAppendFormat(str, NULL, CFSTR("0x%08x"), flags); + } + if (flags != 0) { + if (debug) { + CFStringAppendFormat(str, NULL, CFSTR(" (")); + } + if (flags & DNS_RESOLVER_FLAGS_SCOPED) { + flags &= ~DNS_RESOLVER_FLAGS_SCOPED; + CFStringAppendFormat(str, NULL, CFSTR("Scoped%s"), flags != 0 ? ", " : ""); + } + if (flags & DNS_RESOLVER_FLAGS_SERVICE_SPECIFIC) { + flags &= ~DNS_RESOLVER_FLAGS_SERVICE_SPECIFIC; + CFStringAppendFormat(str, NULL, CFSTR("Service-specific%s"), flags != 0 ? ", " : ""); + } + if (flags & DNS_RESOLVER_FLAGS_SUPPLEMENTAL) { + flags &= ~DNS_RESOLVER_FLAGS_SUPPLEMENTAL; + CFStringAppendFormat(str, NULL, CFSTR("Supplemental%s"), flags != 0 ? ", " : ""); + } + if (flags & DNS_RESOLVER_FLAGS_REQUEST_A_RECORDS) { + flags &= ~DNS_RESOLVER_FLAGS_REQUEST_A_RECORDS; + CFStringAppendFormat(str, NULL, CFSTR("Request A records%s"), flags != 0 ? ", " : ""); + } + if (flags & DNS_RESOLVER_FLAGS_REQUEST_AAAA_RECORDS) { + flags &= ~DNS_RESOLVER_FLAGS_REQUEST_AAAA_RECORDS; + CFStringAppendFormat(str, NULL, CFSTR("Request AAAA records%s"), flags != 0 ? ", " : ""); + } + if (flags != 0) { + CFStringAppendFormat(str, NULL, CFSTR("0x%08x"), flags); + } + if (debug) { + CFStringAppend(str, CFSTR(")")); + } + } + my_log(LOG_INFO, "%@", str); + CFRelease(str); + + __SCNetworkReachability_flags_string(resolver->reach_flags, TRUE, reach_str, sizeof(reach_str)); + my_log(LOG_INFO, " reach : %s", reach_str); + + if (resolver->search_order != 0) { + my_log(LOG_INFO, " order : %d", resolver->search_order); + } + + if (debug && (resolver->cid != NULL)) { + my_log(LOG_INFO, " config id: %s", resolver->cid); + } + + return; +} + +static __inline__ void +_dns_configuration_log(dns_config_t *dns_config, Boolean debug, my_log_context_type my_log_context_name) +{ +#if defined(MY_LOG_CONTEXT_TYPE_DEFINED_LOCALLY) && defined(MY_LOG_CONTEXT_NAME_DEFINED_LOCALLY) +#pragma unused(my_log_context_name) +#endif + int i; + + my_log(LOG_INFO, "%s", "DNS configuration"); + + for (i = 0; i < dns_config->n_resolver; i++) { + dns_resolver_t *resolver = dns_config->resolver[i]; + + _dns_resolver_log(dns_config->version, resolver, i + 1, debug, my_log_context_name); + } + + if ((dns_config->n_scoped_resolver > 0) && (dns_config->scoped_resolver != NULL)) { + my_log(LOG_INFO, "%s", ""); + my_log(LOG_INFO, "%s", "DNS configuration (for scoped queries)"); + + for (i = 0; i < dns_config->n_scoped_resolver; i++) { + dns_resolver_t *resolver = dns_config->scoped_resolver[i]; + + _dns_resolver_log(dns_config->version, resolver, i + 1, debug, my_log_context_name); + } + } + + if ((dns_config->n_service_specific_resolver > 0) && (dns_config->service_specific_resolver != NULL)) { + my_log(LOG_INFO, "%s", ""); + my_log(LOG_INFO, "%s", "DNS configuration (for service-specific queries)"); + + for (i = 0; i < dns_config->n_service_specific_resolver; i++) { + dns_resolver_t *resolver = dns_config->service_specific_resolver[i]; + + _dns_resolver_log(dns_config->version, resolver, i + 1, debug, my_log_context_name); + } + } + + return; +} + +#ifdef MY_LOG_DEFINED_LOCALLY +#undef my_log +#undef MY_LOG_DEFINED_LOCALLY +#endif // MY_LOG_DEFINED_LOCALLY + +#ifdef MY_LOG_CONTEXT_TYPE_DEFINED_LOCALLY +#undef my_log_context_type +#undef MY_LOG_CONTEXT_TYPE_DEFINED_LOCALLY +#endif // MY_LOG_CONTEXT_TYPE_DEFINED_LOCALLY + +#ifdef MY_LOG_CONTEXT_NAME_DEFINED_LOCALLY +#undef my_log_context_name +#undef MY_LOG_CONTEXT_NAME_DEFINED_LOCALLY +#endif // MY_LOG_CONTEXT_NAME_DEFINED_LOCALLY + +__END_DECLS + +#endif /* !_S_DNSINFO_LOGGING_H */ diff --git a/dnsinfo/dnsinfo_private.h b/dnsinfo/dnsinfo_private.h index 9c5168b..ae9ed24 100644 --- a/dnsinfo/dnsinfo_private.h +++ b/dnsinfo/dnsinfo_private.h @@ -1,15 +1,15 @@ /* - * Copyright (c) 2004-2006, 2008, 2009, 2012, 2013, 2015 Apple Inc. All rights reserved. + * Copyright (c) 2004-2006, 2008, 2009, 2012, 2013, 2015, 2017 Apple Inc. All rights reserved. * * @APPLE_LICENSE_HEADER_START@ - * + * * This file contains Original Code and/or Modifications of Original Code * as defined in and that are subject to the Apple Public Source License * Version 2.0 (the 'License'). You may not use this file except in * compliance with the License. Please obtain a copy of the License at * http://www.opensource.apple.com/apsl/ and read it before using this * file. - * + * * The Original Code and all software distributed under the License are * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, @@ -17,7 +17,7 @@ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. * Please see the License for the specific language governing rights and * limitations under the License. - * + * * @APPLE_LICENSE_HEADER_END@ */ @@ -57,32 +57,32 @@ * | struct _dns_config_buf_t | * +-+-------------+---------------------------------------------------+ * | | config | struct dns_config_t | - * | | +-+-------------------+-----------------------------+ - * | | | | n_resolver | int32_t | <- # of name resolvers - * | | | +-------------------+-----------------------------+ - * | | | | resolver | dns_resolver_t ** | <- not used during creation, filled - * | | | | | | in with pointer to a list of - * | | | | | | resolver configurations that will - * | | | | | | be established in the "padding" - * | | | +-------------------+-----------------------------+ - * | | | | n_scoped_resolver | int32_t | <- # of name scoped resolvers - * | | | +-------------------+-----------------------------+ - * | | | | scoped_resolver | dns_resolver_t ** | <- not used during creation, filled - * | | | | | | in with pointer to a list of scoped - * | | | | | | resolver configurations that will - * | | | | | | be established in the "padding" - * | | | +-------------------+-----------------------------+ - * | | | | generation | uint64_t | <- generation # of configuration - * | | | +-------------------+---------+-------------------+ + * | | +-+-----------------------------+-------------------+ + * | | | | n_resolver | int32_t | <- # of name resolvers + * | | | +-----------------------------+-------------------+ + * | | | | resolver | dns_resolver_t ** | <- not used during creation, filled + * | | | | | | in with pointer to a list of + * | | | | | | resolver configurations that will + * | | | | | | be established in the "padding" + * | | | +-----------------------------+--------------------+ + * | | | | n_scoped_resolver | int32_t | <- # of name scoped resolvers + * | | | +-----------------------------+--------------------+ + * | | | | scoped_resolver | dns_resolver_t ** | <- not used during creation, filled + * | | | | | | in with pointer to a list of scoped + * | | | | | | resolver configurations that will + * | | | | | | be established in the "padding" + * | | | +-----------------------------+--------------------+ + * | | | | generation | uint64_t | <- generation # of configuration + * | | | +-----------------------------+-------------------+ * | | | | n_service_specific_resolver | int32_t | <- # of name service-specific resolvers * | | | +-------------------+---------+-------------------+ * | | | | service_specific_resolver | dns_resolver_t ** | <- not used during creation, filled * | | | | | | in with pointer to a list of service-specific * | | | | | | resolver configurations that will be * | | | | | | established in the "padding" - * | | | +-------------------+---------+-------------------+ - * | | | | ... | ... | - * | +-------------+-+-------------------+-----------------------------+ + * | | | +-----------------------------+-------------------+ + * | | | | version | uint32_t | <- configuration structure(s) version + * | +-------------+-+-----------------------------+-------------------+ * | | n_attribute | uint32_t | <- how many bytes of "attribute" * | | | | data is associated with the * | | | | configuration @@ -173,6 +173,7 @@ enum { RESOLVER_ATTRIBUTE_SORTADDR, RESOLVER_ATTRIBUTE_OPTIONS, RESOLVER_ATTRIBUTE_CONFIGURATION_ID, + RESOLVER_ATTRIBUTE_INTERFACE_NAME, }; diff --git a/dnsinfo/dnsinfo_server.c b/dnsinfo/dnsinfo_server.c index 291db1e..b02f8d9 100644 --- a/dnsinfo/dnsinfo_server.c +++ b/dnsinfo/dnsinfo_server.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2004-2008, 2011-2016 Apple Inc. All rights reserved. + * Copyright (c) 2004-2008, 2011-2017 Apple Inc. All rights reserved. * * @APPLE_LICENSE_HEADER_START@ * @@ -38,6 +38,7 @@ #include #include #include +#include #include #include @@ -292,6 +293,65 @@ process_new_connection(xpc_connection_t c) } +#pragma mark - +#pragma mark DNS configuration state + + +static void +add_state_handler() +{ +#if !TARGET_OS_SIMULATOR + os_state_block_t state_block; + os_state_handle_t state_handle; + + state_block = ^os_state_data_t(os_state_hints_t hints) { +#pragma unused(hints) + CFIndex dnsinfo_len; + os_state_data_t state_data; + size_t state_data_size; + + dnsinfo_len = (S_dns_info.data != NULL) ? CFDataGetLength(S_dns_info.data) : 0; + state_data_size = OS_STATE_DATA_SIZE_NEEDED(dnsinfo_len); + if (state_data_size > MAX_STATEDUMP_SIZE) { + SC_log(LOG_ERR, "DNS configuration: state data too large (%zd > %zd)", + state_data_size, + MAX_STATEDUMP_SIZE); + return NULL; + } + + state_data = calloc(1, state_data_size); + if (state_data == NULL) { + SC_log(LOG_ERR, "DNS configuration: could not allocate state data"); + return NULL; + } + + state_data->osd_type = OS_STATE_DATA_CUSTOM; + state_data->osd_data_size = (uint32_t)dnsinfo_len; + strlcpy(state_data->osd_decoder.osdd_library, + "SystemConfiguration", + sizeof(state_data->osd_decoder.osdd_library)); + strlcpy(state_data->osd_decoder.osdd_type, + "dnsinfo", + sizeof(state_data->osd_decoder.osdd_type)); + strlcpy(state_data->osd_title, "DNS Configuration", sizeof(state_data->osd_title)); + if (dnsinfo_len > 0) { + memcpy(state_data->osd_data, CFDataGetBytePtr(S_dns_info.data), dnsinfo_len); + } + + return state_data; + }; + + state_handle = os_state_add_handler(_dnsinfo_server_queue(), state_block); + if (state_handle == 0) { + SC_log(LOG_ERR, "DNS configuration: os_state_add_handler() failed"); + } +#endif // !TARGET_OS_SIMULATOR + + + return; +} + + #pragma mark - #pragma mark DNS configuration server SPIs @@ -301,6 +361,7 @@ void load_DNSConfiguration(CFBundleRef bundle, _dns_sync_handler_t syncHandler) { +#pragma unused(bundle) xpc_connection_t c; const char *name; @@ -309,6 +370,11 @@ load_DNSConfiguration(CFBundleRef bundle, */ _libSC_info_server_init(&S_dns_info); + /* + * add a state dump handler + */ + add_state_handler(); + /* * save the in-sync/not-in-sync handler */ @@ -348,7 +414,6 @@ load_DNSConfiguration(CFBundleRef bundle, } else { SC_log(LOG_ERR, "DNS configuration server: unknown event type : %p", type); - } }); diff --git a/get-mobility-info b/get-mobility-info index db30d7b..0dd0052 100755 --- a/get-mobility-info +++ b/get-mobility-info @@ -75,7 +75,10 @@ if [ -z $OUTDIR ]; then if [ -d ~/Desktop ]; then OUTDIR=~/Desktop elif [ "`readlink /tmp`" = "private/var/tmp" ]; then - OUTDIR=/Library/Logs/CrashReporter + OUTDIR=/Library/Logs/DiagnosticReports + if [ ! -d /Library/Logs/DiagnosticReports -a -d /Library/Logs/CrashReporter ]; then + OUTDIR=/Library/Logs/CrashReporter + fi mkdir -p ${OUTDIR} fi fi @@ -113,8 +116,22 @@ echo "" # # collect packet capture with kernel ring buffer if available # +stop_pcap () { + # + # Stop the packet capture + # + if [ ${PCAP_STARTED} -ne 0 ]; then + trap '' SIGINT + /usr/local/bin/netdiagnose stop packetcapture 2>&1 + PCAP_STARTED=0 + fi +} + +PCAP_STARTED=0 if [ -x /usr/local/bin/netdiagnose -a ${NO_PCAP} -ne 1 ]; then + trap stop_pcap SIGINT /usr/local/bin/netdiagnose -p "${WORKDIR}" start packetcapture 2>&1 + PCAP_STARTED=1 fi # @@ -669,9 +686,7 @@ wait # # Stop the packet capture # -if [ -x /usr/local/bin/netdiagnose -a ${NO_PCAP} -ne 1 ]; then - /usr/local/bin/netdiagnose stop packetcapture 2>&1 -fi +stop_pcap if [ $NO_TAR -eq 0 ]; then # diff --git a/get-network-info b/get-network-info index bcf39c3..b2ba85d 100755 --- a/get-network-info +++ b/get-network-info @@ -1,7 +1,7 @@ #!/bin/sh # -# Copyright © 2015, 2016 Apple Inc. +# Copyright © 2015-2017 Apple Inc. # # get-network-info # @@ -325,6 +325,88 @@ run_setkey () { } +# +# skywalk configuration and statistics +# +run_skywalk () { + + if [ ! -x /usr/sbin/skywalkctl ]; then + return + fi + + echo "#" > skywalk.txt + echo "# skywalkctl list-providers -D" >> skywalk.txt + echo "#" >> skywalk.txt + /usr/sbin/skywalkctl list-providers -D >> skywalk.txt 2>&1 + + echo "#" >> skywalk.txt + echo "# skywalkctl channel-stats" >> skywalk.txt + echo "#" >> skywalk.txt + /usr/sbin/skywalkctl channel-stats >> skywalk.txt 2>&1 + + echo "#" >> skywalk.txt + echo "# skywalkctl netstat -a -n" >> skywalk.txt + echo "#" >> skywalk.txt + /usr/sbin/skywalkctl netstat -a -n >> skywalk.txt 2>&1 + + echo "#" >> skywalk.txt + echo "# skywalkctl netstat -s" >> skywalk.txt + echo "#" >> skywalk.txt + /usr/sbin/skywalkctl netstat -s >> skywalk.txt 2>&1 + + echo "#" >> skywalk.txt + echo "# skywalkctl netstat -s --global" >> skywalk.txt + echo "#" >> skywalk.txt + /usr/sbin/skywalkctl netstat -s --global >> skywalk.txt 2>&1 + + echo "#" >> skywalk.txt + echo "# skywalkctl netstat --netif" >> skywalk.txt + echo "#" >> skywalk.txt + /usr/sbin/skywalkctl netstat --netif >> skywalk.txt 2>&1 + + echo "#" >> skywalk.txt + echo "# skywalkctl netstat --flowswitch" >> skywalk.txt + echo "#" >> skywalk.txt + /usr/sbin/skywalkctl netstat --flowswitch >> skywalk.txt 2>&1 + + echo "#" >> skywalk.txt + echo "# skywalkctl netstat --flow-adv" >> skywalk.txt + echo "#" >> skywalk.txt + /usr/sbin/skywalkctl netstat --flow-adv >> skywalk.txt 2>&1 + + echo "#" >> skywalk.txt + echo "# skywalkctl netstat --flow-owner" >> skywalk.txt + echo "#" >> skywalk.txt + /usr/sbin/skywalkctl netstat --flow-owner >> skywalk.txt 2>&1 + + echo "#" >> skywalk.txt + echo "# skywalkctl netns -a" >> skywalk.txt + echo "#" >> skywalk.txt + /usr/sbin/skywalkctl netns -a >> skywalk.txt 2>&1 + + echo "#" >> skywalk.txt + echo "# skywalkctl memory" >> skywalk.txt + echo "#" >> skywalk.txt + /usr/sbin/skywalkctl memory >> skywalk.txt 2>&1 + +} + +# +# skywalk configuration and statistics +# +run_nettop () { + + if [ ! -x /usr/bin/nettop ]; then + return + fi + + echo "#" > nettop.txt + echo "# nettop -U -l 1" >> nettop.txt + echo "#" >> nettop.txt + /usr/bin/nettop -U -l 1 >> nettop.txt 2>&1 + +} + # # Network preferences # @@ -334,6 +416,7 @@ collect_configuration_files () { /Library/Preferences/com.apple.networkextension.plist \ /Library/Preferences/com.apple.networkextension.control.plist \ /Library/Preferences/com.apple.networkextension.necp.plist \ + /Library/Preferences/com.apple.networkextension.cache.plist \ /Library/Preferences/SystemConfiguration/com.apple.nat.plist \ /Library/Preferences/SystemConfiguration/com.apple.RemoteAccessServers.plist \ /Library/Preferences/SystemConfiguration/com.apple.smb.server.plist \ @@ -385,16 +468,17 @@ run_neutil () { return fi - echo "#" > necp.txt - echo "# neutil policy dump" >> necp.txt - echo "#" >> necp.txt - /usr/local/bin/neutil policy dump >> necp.txt 2>&1 - - echo "#" > network-agents.txt - echo "# neutil agent dump" >> network-agents.txt - echo "#" >> network-agents.txt - /usr/local/bin/neutil agent dump >> network-agents.txt 2>&1 - + ( + echo "#" > necp.txt + echo "# neutil policy dump" >> necp.txt + echo "#" >> necp.txt + /usr/local/bin/neutil policy dump >> necp.txt 2>&1 + + echo "#" > network-agents.txt + echo "# neutil agent dump" >> network-agents.txt + echo "#" >> network-agents.txt + /usr/local/bin/neutil agent dump >> network-agents.txt 2>&1 + ) & } # @@ -462,19 +546,7 @@ run_scutil () { echo "#" >> nc-info.txt /usr/sbin/scutil --nc list >> nc-info.txt 2>&1 - ${PRIV} /usr/sbin/scutil -p --snapshot - if [ -f /var/tmp/configd-store.plist ]; then - cat /var/tmp/configd-store.plist > configd-store.plist 2>&1 - fi - if [ -f /var/tmp/configd-pattern.plist ]; then - cat /var/tmp/configd-pattern.plist > configd-pattern.plist 2>&1 - fi - if [ -f /var/tmp/configd-session.plist ]; then - cat /var/tmp/configd-session.plist > configd-session.plist 2>&1 - fi - if [ -f /var/tmp/configd-state ]; then - cat /var/tmp/configd-state > configd-state 2>&1 - fi + /usr/sbin/scutil -p --snapshot SCDynamicStore.plist 2>&1 } @@ -565,20 +637,20 @@ run_lsof () { } start_pcap() { - # # collect a packet capture if netdiagnose is available # if [ -x /usr/local/bin/netdiagnose ]; then - /usr/local/bin/netdiagnose -p "${REQUESTED_OUTDIR}" start sysdiagpcap 2>&1 - + trap stop_pcap SIGINT + /usr/local/bin/netdiagnose -p "${REQUESTED_OUTDIR}" start sysdiagpcap 2>&1 1>/dev/null PCAP_STARTED=1 fi } stop_pcap () { if [ ${PCAP_STARTED} -ne 0 ]; then - /usr/local/bin/netdiagnose stop sysdiagpcap 2>&1 + trap '' SIGINT + /usr/local/bin/netdiagnose stop sysdiagpcap 2>&1 1>/dev/null fi } @@ -596,6 +668,7 @@ collect_sensitive_info () { run_ndp run_arp run_neutil + run_nettop run_network_test } @@ -615,6 +688,7 @@ collect_info () { run_netstat run_ipconfig run_setkey + run_skywalk collect_vpn_logs run_route run_hostname @@ -643,12 +717,16 @@ usage () { is_outdir_valid () { - if [ ! -d ${REQUESTED_OUTDIR} ] || - [ "${REQUESTED_OUTDIR}" = "" ]; then + if [ "${REQUESTED_OUTDIR}" = "" ]; then usage exit 1 fi + if [ ! -d ${REQUESTED_OUTDIR} ]; then + echo "${REQUESTED_OUTDIR} does not exist" + exit 1 + fi + if [ ! -w ${REQUESTED_OUTDIR} ]; then echo "${REQUESTED_OUTDIR} is write-protected" exit 1 diff --git a/logging/liblog_SystemConfiguration.m b/logging/liblog_SystemConfiguration.m new file mode 100644 index 0000000..e440427 --- /dev/null +++ b/logging/liblog_SystemConfiguration.m @@ -0,0 +1,190 @@ +/* + * Copyright (c) 2017 Apple Inc. All rights reserved. + * + * @APPLE_LICENSE_HEADER_START@ + * + * This file contains Original Code and/or Modifications of Original Code + * as defined in and that are subject to the Apple Public Source License + * Version 2.0 (the 'License'). You may not use this file except in + * compliance with the License. Please obtain a copy of the License at + * http://www.opensource.apple.com/apsl/ and read it before using this + * file. + * + * The Original Code and all software distributed under the License are + * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, + * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. + * Please see the License for the specific language governing rights and + * limitations under the License. + * + * @APPLE_LICENSE_HEADER_END@ + */ + +/* + * Modification History + * + * May 18, 2017 Allan Nathanson + * - initial revision + */ + +#define _LIBLOG_SYSTEMCONFIGURATION_ + +#import +#import +#import +#import + +#import +#import "dnsinfo_internal.h" +#import + +#define my_log(__level, __format, ...) [string appendFormat:@(__format "\n"), ## __VA_ARGS__] +#define my_log_context_type NSMutableString * +#define my_log_context_name string +#import "dnsinfo_logging.h" +#import "network_state_information_logging.h" +#undef my_log_context_name +#undef my_log_context_type +#undef my_log + +#define SCAS(str) \ + [[NSAttributedString alloc] initWithString:str] + +#define SCASWithFormat(format, ...) \ + SCAS(([[NSString alloc] initWithFormat:format, ##__VA_ARGS__])) + +#pragma mark - +#pragma mark os_log formatting entry point + +struct SC_OSLog_Formatters { + const char *type; + NS_RETURNS_RETAINED NSAttributedString * (*function)(id value); +}; + +NS_RETURNS_RETAINED +NSAttributedString * +OSLogCopyFormattedString(const char *type, id value, os_log_type_info_t info) +{ +#pragma unused(info) + // add functions for each type into this list + static const struct SC_OSLog_Formatters formatters[] = { +// { .type = "???", .function = _SC_OSLogCopyFormattedString_??? }, + }; + + for (int i = 0; i < (int)(sizeof(formatters) / sizeof(formatters[0])); i++) { + if (strcmp(type, formatters[i].type) == 0) { + return formatters[i].function(value); + } + } + + return SCASWithFormat(@"liblog_SystemConfiguration: Not yet supported os_log formatting type: %s", type); +} + +#pragma mark - +#pragma mark os_state formatting entry point + +#define SCNS(str) \ + [[NSString alloc] initWithString:(str)] + +#define SCNSWithFormat(format, ...) \ + [[NSString alloc] initWithFormat:format, ##__VA_ARGS__] + +static NS_RETURNS_RETAINED NSString * +_SC_OSStateCopyFormattedString_dnsinfo(uint32_t data_size, void *data) +{ + dns_config_t *dns_config = NULL; + _dns_config_buf_t *dns_config_buf; + NSMutableString *string; + + // os_state_add_handler w/ + // osd_type = OS_STATE_DATA_CUSTOM + // osd_decoder.osdd_library = "SystemConfiguration + // osd_decoder.osdd_type = "dnsinfo" + + if ((data_size == 0) || (data == NULL)) { + return @"No DNS configuration"; + } else if (data_size < sizeof(_dns_config_buf_t)) { + return SCNSWithFormat(@"DNS configuration: size error (%d < %zd)", + data_size, + sizeof(_dns_config_buf_t)); + } + + dns_config_buf = _dns_configuration_buffer_create(data, data_size); + if (dns_config_buf == NULL) { + return @"DNS configuration: data error"; + } + + dns_config = _dns_configuration_buffer_expand(dns_config_buf); + if (dns_config == NULL) { + // if we were unable to expand the configuration + _dns_configuration_buffer_free(&dns_config_buf); + return @"DNS configuration: expansion error"; + } + + string = [NSMutableString string]; + _dns_configuration_log(dns_config, TRUE, string); + if (string.length == 0) { + [string appendString:@"DNS configuration: not available"]; + } + free(dns_config); + + return string; +} + +static NS_RETURNS_RETAINED NSString * +_SC_OSStateCopyFormattedString_nwi(uint32_t data_size, void *data) +{ + nwi_state_t state = (nwi_state_t)data; + NSMutableString *string; + + // os_state_add_handler w/ + // osd_type = OS_STATE_DATA_CUSTOM + // osd_decoder.osdd_library = "SystemConfiguration + // osd_decoder.osdd_type = "nwi" + + if ((data_size == 0) || (data == NULL)) { + return @"No network information"; + } else if (data_size < sizeof(nwi_state)) { + return SCNSWithFormat(@"Network information: size error (%d < %zd)", + data_size, + sizeof(_dns_config_buf_t)); + } else if (state->version != NWI_STATE_VERSION) { + return SCNSWithFormat(@"Network information: version error (%d != %d)", + state->version, + NWI_STATE_VERSION); + } + + string = [NSMutableString string]; + _nwi_state_log(state, TRUE, string); + if (string.length == 0) { + [string appendString:@"Network information: not available"]; + } + + return string; +} + +struct SC_OSState_Formatters { + const char *type; + NS_RETURNS_RETAINED NSString * (*function)(uint32_t data_size, void *data); +}; + +NS_RETURNS_RETAINED +NSString * +OSStateCreateStringWithData(const char *type, uint32_t data_size, void *data) +{ + // add functions for each type into this list + static const struct SC_OSState_Formatters formatters[] = { + { .type = "dnsinfo", .function = _SC_OSStateCopyFormattedString_dnsinfo }, + { .type = "nwi", .function = _SC_OSStateCopyFormattedString_nwi }, + }; + + for (int i = 0; i < (int)(sizeof(formatters) / sizeof(formatters[0])); i++) { + if (strcmp(type, formatters[i].type) == 0) { + return formatters[i].function(data_size, data); + } + } + + return SCNSWithFormat(@"liblog_SystemConfiguration: Not yet supported os_state formatting type: %s", type); +} + diff --git a/nwi/network_information.c b/nwi/network_information.c index 9bf12dc..1ef59cd 100644 --- a/nwi/network_information.c +++ b/nwi/network_information.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2011-2016 Apple Inc. All rights reserved. + * Copyright (c) 2011-2017 Apple Inc. All rights reserved. * * @APPLE_LICENSE_HEADER_START@ * @@ -28,7 +28,9 @@ #include #include #include +#ifdef VERBOSE_ACTIVITY_LOGGING #include +#endif // VERBOSE_ACTIVITY_LOGGING #include #include @@ -60,6 +62,7 @@ static int nwi_active = 0; static libSC_info_client_t *nwi_client = NULL; +#ifdef VERBOSE_ACTIVITY_LOGGING static os_activity_t __nwi_client_activity() { @@ -74,6 +77,7 @@ __nwi_client_activity() return activity; } +#endif // VERBOSE_ACTIVITY_LOGGING static dispatch_queue_t @@ -229,8 +233,10 @@ _nwi_state_copy_data() return NULL; } +#ifdef VERBOSE_ACTIVITY_LOGGING // scope NWI activity os_activity_scope(__nwi_client_activity()); +#endif // VERBOSE_ACTIVITY_LOGGING // create message reqdict = xpc_dictionary_create(NULL, NULL, 0); @@ -291,8 +297,10 @@ _nwi_config_agent_copy_data(const struct netagent *agent, uint64_t *length) _nwi_client_init(); +#ifdef VERBOSE_ACTIVITY_LOGGING // scope NWI activity os_activity_scope(__nwi_client_activity()); +#endif // VERBOSE_ACTIVITY_LOGGING reqdict = xpc_dictionary_create(NULL, NULL, 0); @@ -399,6 +407,7 @@ nwi_state_copy(void) void _nwi_state_ack(nwi_state_t state, const char *bundle_id) { +#pragma unused(bundle_id) xpc_object_t reqdict; if (state == NULL) { diff --git a/nwi/network_information.h b/nwi/network_information.h index 6c8e550..3bcb87a 100644 --- a/nwi/network_information.h +++ b/nwi/network_information.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2011-2016 Apple Inc. All rights reserved. + * Copyright (c) 2011-2017 Apple Inc. All rights reserved. * * @APPLE_LICENSE_HEADER_START@ * @@ -37,7 +37,8 @@ __BEGIN_DECLS /* * Function: nwi_state_copy * Purpose: - * Returns the current network state information. + * Returns the current network state information; NULL if no state + * information is currently available. * Release after use by calling nwi_state_release(). */ nwi_state_t diff --git a/nwi/network_information_server.c b/nwi/network_information_server.c index 0c7b179..a47861a 100644 --- a/nwi/network_information_server.c +++ b/nwi/network_information_server.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2012-2016 Apple Inc. All rights reserved. + * Copyright (c) 2012-2017 Apple Inc. All rights reserved. * * @APPLE_LICENSE_HEADER_START@ * @@ -31,6 +31,7 @@ #include #include #include +#include #include #include #include @@ -373,7 +374,66 @@ process_new_connection(xpc_connection_t c) #pragma mark - -#pragma mark Network Information server SPIs +#pragma mark Network information state + + +static void +add_state_handler() +{ +#if !TARGET_OS_SIMULATOR + os_state_block_t state_block; + os_state_handle_t state_handle; + + state_block = ^os_state_data_t(os_state_hints_t hints) { +#pragma unused(hints) + os_state_data_t state_data; + size_t state_data_size; + CFIndex state_len; + + state_len = (S_nwi_info.data != NULL) ? CFDataGetLength(S_nwi_info.data) : 0; + state_data_size = OS_STATE_DATA_SIZE_NEEDED(state_len); + if (state_data_size > MAX_STATEDUMP_SIZE) { + SC_log(LOG_ERR, "Network information : state data too large (%zd > %zd)", + state_data_size, + MAX_STATEDUMP_SIZE); + return NULL; + } + + state_data = calloc(1, state_data_size); + if (state_data == NULL) { + SC_log(LOG_ERR, "Network information: could not allocate state data"); + return NULL; + } + + state_data->osd_type = OS_STATE_DATA_CUSTOM; + state_data->osd_data_size = (uint32_t)state_len; + strlcpy(state_data->osd_decoder.osdd_library, + "SystemConfiguration", + sizeof(state_data->osd_decoder.osdd_library)); + strlcpy(state_data->osd_decoder.osdd_type, + "nwi", + sizeof(state_data->osd_decoder.osdd_type)); + strlcpy(state_data->osd_title, "Network information", sizeof(state_data->osd_title)); + if (state_len > 0) { + memcpy(state_data->osd_data, CFDataGetBytePtr(S_nwi_info.data), state_len); + } + + return state_data; + }; + + state_handle = os_state_add_handler(_nwi_state_server_queue(), state_block); + if (state_handle == 0) { + SC_log(LOG_ERR, "Network information: os_state_add_handler() failed"); + } +#endif // !TARGET_OS_SIMULATOR + + + return; +} + + +#pragma mark - +#pragma mark Network information server SPIs __private_extern__ @@ -381,6 +441,7 @@ void load_NetworkInformation(CFBundleRef bundle, _nwi_sync_handler_t syncHandler) { +#pragma unused(bundle) xpc_connection_t c; const char *name; @@ -389,6 +450,11 @@ load_NetworkInformation(CFBundleRef bundle, */ _libSC_info_server_init(&S_nwi_info); + /* + * add a state dump handler + */ + add_state_handler(); + /* * save the in-sync/not-in-sync handler */ diff --git a/nwi/network_state_information_logging.h b/nwi/network_state_information_logging.h new file mode 100644 index 0000000..1f593d2 --- /dev/null +++ b/nwi/network_state_information_logging.h @@ -0,0 +1,396 @@ +/* + * Copyright (c) 2017 Apple Inc. All rights reserved. + * + * @APPLE_LICENSE_HEADER_START@ + * + * This file contains Original Code and/or Modifications of Original Code + * as defined in and that are subject to the Apple Public Source License + * Version 2.0 (the 'License'). You may not use this file except in + * compliance with the License. Please obtain a copy of the License at + * http://www.opensource.apple.com/apsl/ and read it before using this + * file. + * + * The Original Code and all software distributed under the License are + * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, + * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. + * Please see the License for the specific language governing rights and + * limitations under the License. + * + * @APPLE_LICENSE_HEADER_END@ + */ + +#ifndef _NETWORK_STATE_INFORMATION_LOGGING_H +#define _NETWORK_STATE_INFORMATION_LOGGING_H + +#include +#include +#include +#include +#include +#include + +#include +#include "network_state_information_priv.c" + +__BEGIN_DECLS + +#ifndef my_log +#define my_log(__level, __format, ...) SC_log(__level, __format, ## __VA_ARGS__) +#define MY_LOG_DEFINED_LOCALLY +#endif // !my_log + +#ifndef my_log_context_type +#define my_log_context_type void * +#define MY_LOG_CONTEXT_TYPE_DEFINED_LOCALLY +#endif // !my_log_context_type + +#ifndef my_log_context_name +#define my_log_context_name context +#define MY_LOG_CONTEXT_NAME_DEFINED_LOCALLY +#endif // !my_log_context_name + +#include "SCNetworkReachabilityLogging.h" + +/* + * _nwi_ifstate_flags_str() + * + * Returns a string representation of the nwi_state flags. + * "(IPv4,IPv6,DNS,...)" + */ +static __inline__ void +_nwi_ifstate_flags_str(nwi_ifstate_flags flags, char *str, size_t len) +{ + size_t n; + nwi_ifstate_flags remaining; + + assert(len >= sizeof("(0x01234567)")); // check min buffer size + + flags &= NWI_IFSTATE_FLAGS_MASK; + if (flags == 0) { + str[0] = '\0'; + return; + } + + len--; // leave room for the closing paren + n = strlcpy(str, "(", len); + remaining = flags; + + if ((remaining & NWI_IFSTATE_FLAGS_HAS_IPV4) && + (n < len) && ((len - n) > sizeof("IPv4,"))) { + n = strlcat(str, "IPv4,", len); + remaining &= ~NWI_IFSTATE_FLAGS_HAS_IPV4; + } + + if ((remaining & NWI_IFSTATE_FLAGS_HAS_IPV6) && + (n < len) && ((len - n) > sizeof("IPv6,"))) { + n = strlcat(str, "IPv6,", len); + remaining &= ~NWI_IFSTATE_FLAGS_HAS_IPV6; + } + + if ((remaining & NWI_IFSTATE_FLAGS_HAS_DNS) && + (n < len) && ((len - n) > sizeof("DNS,"))) { + n = strlcat(str, "DNS,", len); + remaining &= ~NWI_IFSTATE_FLAGS_HAS_DNS; + } + + if ((remaining & NWI_IFSTATE_FLAGS_NOT_IN_LIST) && + (n < len) && ((len - n) > sizeof("NOT-IN-LIST,"))) { + n = strlcat(str, "NOT-IN-LIST,", len); + remaining &= ~NWI_IFSTATE_FLAGS_NOT_IN_LIST; + } + + if ((remaining & NWI_IFSTATE_FLAGS_HAS_SIGNATURE) && + (n < len) && ((len - n) > sizeof("SIGNATURE,"))) { + n = strlcat(str, "SIGNATURE,", len); + remaining &= ~NWI_IFSTATE_FLAGS_HAS_SIGNATURE; + } + + if ((remaining & NWI_IFSTATE_FLAGS_NOT_IN_IFLIST) && + (n < len) && ((len - n) > sizeof("NOT-IN-IFLIST,"))) { + n = strlcat(str, "NOT-IN-IFLIST,", len); + remaining &= ~NWI_IFSTATE_FLAGS_NOT_IN_IFLIST; + } + + if (remaining != 0) { + if ((n >= len) || + ((len - n) <= sizeof("0x01234567,"))) { + // if we don't have enough space, truncate and start over + n = strlcpy(str, "(", len); + remaining = flags; + } + + n += snprintf(str + n, len - n, ",%p", (void *)remaining); + } + + if (n-- > 0) { + str[n] = ')'; // trailing "," --> ")" + } + + return; +} + +static __inline__ const char * +_nwi_ifstate_rank_str(Rank rank) +{ + const char *str = "???"; + + switch (RANK_ASSERTION_MASK(rank)) { + case kRankAssertionFirst: + str = "First"; + break; + case kRankAssertionDefault: + str = "Default"; + break; + case kRankAssertionLast: + str = "Last"; + break; + case kRankAssertionNever: + str = "Never"; + break; + case kRankAssertionScoped: + str = "Scoped"; + break; + default: + str = "???"; + break; + } + + return str; +} + +static __inline__ void +_nwi_ifstate_log(nwi_ifstate_t ifstate, boolean_t debug, my_log_context_type my_log_context_name) +{ +#if defined(MY_LOG_CONTEXT_TYPE_DEFINED_LOCALLY) && defined(MY_LOG_CONTEXT_NAME_DEFINED_LOCALLY) +#pragma unused(my_log_context_name) +#endif + union { + const void *bytes; + const struct in_addr *ia; + const struct in6_addr *ia6; + } addr; + char addr_str[INET6_ADDRSTRLEN]; + nwi_ifstate_flags flags_ifstate; + char flags_str[100]; + const char *if_name; + SCNetworkReachabilityFlags reach_flags; + char reach_str[100]; + const struct sockaddr *vpn_addr; + + // nwi_ifstate flags + flags_ifstate = nwi_ifstate_get_flags(ifstate); + if (debug) { + flags_ifstate |= NWI_IFSTATE_FLAGS(ifstate->flags); + } + flags_ifstate &= ~NWI_IFSTATE_FLAGS_HAS_SIGNATURE; // exclude flag ('cause we'll report the signature only if present) + _nwi_ifstate_flags_str(flags_ifstate, flags_str, sizeof(flags_str)); + + // if_name + if_name = nwi_ifstate_get_ifname(ifstate); + + // reachability flags + reach_flags = nwi_ifstate_get_reachability_flags(ifstate); + + // IP address + addr.bytes = nwi_ifstate_get_address(ifstate); + if (inet_ntop(ifstate->af, addr.bytes, addr_str, sizeof(addr_str)) == NULL) { + strlcpy(addr_str, "???", sizeof(addr_str)); + } + + // verbose format (e.g. scutil) + my_log(LOG_INFO, " %7s : flags : %p %s", + if_name, + (void *)flags_ifstate, + flags_str); + + my_log(LOG_INFO, " address : %s", addr_str); + + // VPN server address + vpn_addr = nwi_ifstate_get_vpn_server(ifstate); + if (vpn_addr != NULL) { + char vpn_str[INET6_ADDRSTRLEN]; + + _SC_sockaddr_to_string(vpn_addr, vpn_str, sizeof(vpn_str)); + my_log(LOG_INFO, " VPN server : %s", vpn_str); + } + + // reachability + __SCNetworkReachability_flags_string(reach_flags, TRUE, reach_str, sizeof(reach_str)); + my_log(LOG_INFO, " reach : %s", reach_str); + + if (debug) { + uint64_t generation; + Rank rank; + uint32_t rank_index; + const char *rank_str; + const uint8_t *signature; + int signature_length; + + // Rank + rank = ifstate->rank; + rank_str = _nwi_ifstate_rank_str(rank); + rank_index = RANK_INDEX_MASK(rank); + if (rank_index != kRankIndexMask) { + my_log(LOG_INFO, " rank : 0x%08x (%s, %u)", rank, rank_str, rank_index); + } else { + my_log(LOG_INFO, " rank : 0x%08x (%s, Last)", rank, rank_str); + } + + // signature + signature = nwi_ifstate_get_signature(ifstate, AF_UNSPEC, &signature_length); + if (signature != NULL) { + CFDataRef digest; + + digest = CFDataCreate(NULL, signature, CC_SHA1_DIGEST_LENGTH); + my_log(LOG_INFO, " signature : %@", digest); + CFRelease(digest); + } + + // generation + generation = nwi_ifstate_get_generation(ifstate); + my_log(LOG_INFO, " generation : %llu", generation); + } + + return; +} + +static __inline__ void +_nwi_state_reachability_log(nwi_state_t state, boolean_t debug, int af, my_log_context_type my_log_context_name) +{ +#if defined(MY_LOG_CONTEXT_TYPE_DEFINED_LOCALLY) && defined(MY_LOG_CONTEXT_NAME_DEFINED_LOCALLY) +#pragma unused(my_log_context_name) +#endif + uint32_t flags; + char flags_str[100]; + + flags = nwi_state_get_reachability_flags(state, af); + __SCNetworkReachability_flags_string(flags, TRUE, flags_str, sizeof(flags_str)); + if (!debug) { + my_log(LOG_INFO, "%s", ""); + } + my_log(LOG_INFO, " REACH : flags %s", flags_str); + + return; +} + +static __inline__ void +_nwi_state_log(nwi_state_t state, boolean_t debug, my_log_context_type my_log_context_name) +{ +#if defined(MY_LOG_CONTEXT_TYPE_DEFINED_LOCALLY) && defined(MY_LOG_CONTEXT_NAME_DEFINED_LOCALLY) +#pragma unused(my_log_context_name) +#endif + unsigned int count; + nwi_ifindex_t i; + nwi_ifstate_t ifstate; + + if (!debug) { + my_log(LOG_INFO, "%s", "Network information"); + } else { + my_log(LOG_INFO, + "Network information (generation %llu size=%lu)", + nwi_state_get_generation(state), + nwi_state_size(state)); + } + + // report IPv4 state + if (!debug) { + // show regular interfaces + my_log(LOG_INFO, "%s", ""); + my_log(LOG_INFO, "%s", "IPv4 network interface information"); + ifstate = nwi_state_get_first_ifstate(state, AF_INET); + if (ifstate == NULL) { + my_log(LOG_INFO, "%s", " No IPv4 states found"); + } else { + while (ifstate != NULL) { + _nwi_ifstate_log(ifstate, debug, my_log_context_name); + ifstate = nwi_ifstate_get_next(ifstate, AF_INET); + } + } + } else { + my_log(LOG_INFO, "%s", "IPv4 network interface information"); + if (state->ipv4_count > 0) { + // show ALL interfaces + for (i = 0, ifstate = nwi_state_ifstate_list(state, AF_INET); + i < state->ipv4_count; i++, ifstate++) { + _nwi_ifstate_log(ifstate, debug, my_log_context_name); + } + } else { + my_log(LOG_INFO, "%s", " No IPv4 states found"); + } + } + _nwi_state_reachability_log(state, debug, AF_INET, my_log_context_name); + + // report IPv6 state + if (!debug) { + // show regular interfaces + my_log(LOG_INFO, "%s", ""); + my_log(LOG_INFO, "%s", "IPv6 network interface information"); + ifstate = nwi_state_get_first_ifstate(state, AF_INET6); + if (ifstate == NULL) { + my_log(LOG_INFO, "%s", " No IPv6 states found\n"); + } else { + while (ifstate != NULL) { + _nwi_ifstate_log(ifstate, debug, my_log_context_name); + ifstate = nwi_ifstate_get_next(ifstate, AF_INET6); + } + } + } else { + my_log(LOG_INFO, "%s", "IPv6 network interface information"); + if (state->ipv6_count > 0) { + // show ALL interfaces + for (i = 0, ifstate = nwi_state_ifstate_list(state, AF_INET6); + i < state->ipv6_count; i++, ifstate++) { + _nwi_ifstate_log(ifstate, debug, my_log_context_name); + } + } else { + my_log(LOG_INFO, "%s", " No IPv6 states found\n"); + } + } + _nwi_state_reachability_log(state, debug, AF_INET6, my_log_context_name); + + count = nwi_state_get_interface_names(state, NULL, 0); + if (count > 0) { + const char *names[count]; + + count = nwi_state_get_interface_names(state, names, count); + if (count > 0) { + char str[count * (IFNAMSIZ + 1)]; + + memset(str, 0, sizeof(str)); + for (unsigned int i = 0; i < count; i++) { + if (i != 0) { + strlcat(str, " ", sizeof(str)); + } + strlcat(str, names[i], sizeof(str)); + } + + if (!debug) { + my_log(LOG_INFO, "%s", ""); + } + my_log(LOG_INFO, "Network interfaces: %s", str); + } + } + + return; +} + +#ifdef MY_LOG_DEFINED_LOCALLY +#undef my_log +#undef MY_LOG_DEFINED_LOCALLY +#endif // MY_LOG_DEFINED_LOCALLY + +#ifdef MY_LOG_CONTEXT_TYPE_DEFINED_LOCALLY +#undef my_log_context_type +#undef MY_LOG_CONTEXT_TYPE_DEFINED_LOCALLY +#endif // MY_LOG_CONTEXT_TYPE_DEFINED_LOCALLY + +#ifdef MY_LOG_CONTEXT_NAME_DEFINED_LOCALLY +#undef my_log_context_name +#undef MY_LOG_CONTEXT_NAME_DEFINED_LOCALLY +#endif // MY_LOG_CONTEXT_NAME_DEFINED_LOCALLY + +__END_DECLS + +#endif // _NETWORK_STATE_INFORMATION_LOGGING_H diff --git a/nwi/network_state_information_priv.c b/nwi/network_state_information_priv.c index 77e03cf..63e8f8f 100644 --- a/nwi/network_state_information_priv.c +++ b/nwi/network_state_information_priv.c @@ -1,15 +1,15 @@ /* - * Copyright (c) 2011-2015 Apple Inc. All rights reserved. + * Copyright (c) 2011-2015, 2017 Apple Inc. All rights reserved. * * @APPLE_LICENSE_HEADER_START@ - * + * * This file contains Original Code and/or Modifications of Original Code * as defined in and that are subject to the Apple Public Source License * Version 2.0 (the 'License'). You may not use this file except in * compliance with the License. Please obtain a copy of the License at * http://www.opensource.apple.com/apsl/ and read it before using this * file. - * + * * The Original Code and all software distributed under the License are * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, @@ -17,7 +17,7 @@ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. * Please see the License for the specific language governing rights and * limitations under the License. - * + * * @APPLE_LICENSE_HEADER_END@ */ @@ -103,10 +103,10 @@ nwi_state_add_to_if_list(nwi_state_t state, nwi_ifstate_t ifstate) for (i = 0, scan = nwi_state_if_list(state); i < state->if_list_count; i++, scan++) { - nwi_ifstate_t this; - - this = state->ifstate_list + *scan; - if (strcmp(this->ifname, ifstate->ifname) == 0) { + nwi_ifstate_t this_ifstate; + + this_ifstate = state->ifstate_list + *scan; + if (strcmp(this_ifstate->ifname, ifstate->ifname) == 0) { /* it's already in the list */ return; } @@ -124,15 +124,15 @@ nwi_state_set_if_list(nwi_state_t state) nwi_ifstate_t scan_v6; int v4; int v6; - + v4 = 0; v6 = 0; state->if_list_count = 0; scan_v4 = nwi_state_get_ifstate_with_index(state, AF_INET, v4); scan_v6 = nwi_state_get_ifstate_with_index(state, AF_INET6, v6); while (scan_v4 != NULL || scan_v6 != NULL) { - bool add_v4 = FALSE; - + boolean_t add_v4 = FALSE; + if (scan_v4 != NULL && scan_v6 != NULL) { /* add the higher rank of v4 or v6 */ if (scan_v4->rank <= scan_v6->rank) { @@ -173,7 +173,7 @@ nwi_state_make_copy(nwi_state_t src) return dest; } size = nwi_state_size(src); - dest = malloc(size); + dest = (nwi_state_t)malloc(size); if (dest != NULL) { bcopy(src, dest, size); @@ -200,7 +200,7 @@ nwi_state_new(nwi_state_t old_state, int max_if_count) } } size = nwi_state_compute_size(max_if_count); - state = malloc(size); + state = (nwi_state_t)malloc(size); bzero(state, size); state->max_if_count = max_if_count; state->version = NWI_STATE_VERSION; @@ -274,7 +274,7 @@ nwi_state_add_ifstate_alias(nwi_state_t state, nwi_ifstate_t ifstate) { nwi_ifstate_t alias; - alias = nwi_state_get_ifstate_with_name(state, + alias = nwi_state_get_ifstate_with_name(state, nwi_other_af(ifstate->af), ifstate->ifname); if (alias == NULL) { @@ -332,7 +332,7 @@ nwi_state_add_ifstate(nwi_state_t state, /* this is the new last ifstate */ ifstate->flags |= NWI_IFSTATE_FLAGS_LAST_ITEM; (*count_p)++; - + /* add the alias */ nwi_state_add_ifstate_alias(state, ifstate); } @@ -457,8 +457,8 @@ nwi_ifstate_has_changed(nwi_ifstate_t ifstate1, nwi_ifstate_t ifstate2) static inline nwi_ifstate_t nwi_state_diff_append(nwi_state_t state, nwi_ifstate_t scan) { - nwi_ifstate_t new_ifstate = NULL; nwi_ifindex_t * last; + nwi_ifstate_t new_ifstate = NULL; new_ifstate = nwi_state_get_last_ifstate(state, scan->af, &last); memcpy(new_ifstate, scan, sizeof(*scan)); @@ -476,32 +476,32 @@ nwi_ifstate_set_diff(nwi_ifstate_t ifstate, uint8_t diff) } static void -nwi_state_diff_add_change(nwi_state_t diff, nwi_state_t old, +nwi_state_diff_add_change(nwi_state_t diff, nwi_state_t old_ifstate, nwi_ifstate_t ifstate) { nwi_ifstate_t existing; - nwi_ifstate_t new; + nwi_ifstate_t new_ifstate; - existing = nwi_state_get_ifstate_with_name(old, + existing = nwi_state_get_ifstate_with_name(old_ifstate, ifstate->af, nwi_ifstate_get_ifname(ifstate)); - new = nwi_state_diff_append(diff, ifstate); + new_ifstate = nwi_state_diff_append(diff, ifstate); if (existing != NULL) { - if (nwi_ifstate_has_changed(existing, new)) { - nwi_ifstate_set_diff(new, + if (nwi_ifstate_has_changed(existing, new_ifstate)) { + nwi_ifstate_set_diff(new_ifstate, NWI_IFSTATE_DIFF_CHANGED); - } else if (existing->rank < new->rank) { - nwi_ifstate_set_diff(new, + } else if (existing->rank < new_ifstate->rank) { + nwi_ifstate_set_diff(new_ifstate, NWI_IFSTATE_DIFF_RANK_DOWN); - } else if (existing->rank > new->rank) { - nwi_ifstate_set_diff(new, + } else if (existing->rank > new_ifstate->rank) { + nwi_ifstate_set_diff(new_ifstate, NWI_IFSTATE_DIFF_RANK_UP); } else { - nwi_ifstate_set_diff(new, + nwi_ifstate_set_diff(new_ifstate, NWI_IFSTATE_DIFF_UNCHANGED); } } else { - nwi_ifstate_set_diff(new, NWI_IFSTATE_DIFF_ADDED); + nwi_ifstate_set_diff(new_ifstate, NWI_IFSTATE_DIFF_ADDED); } return; } @@ -524,39 +524,39 @@ nwi_state_diff_remove(nwi_state_t state, nwi_ifstate_t ifstate) } static void -nwi_state_diff_populate(nwi_state_t diff, nwi_state_t old, nwi_state_t new) +nwi_state_diff_populate(nwi_state_t diff, nwi_state_t old_ifstate, nwi_state_t new_ifstate) { int i; nwi_ifstate_t scan; - if (new != NULL) { + if (new_ifstate != NULL) { /* check for adds/changes */ - if (new->ipv4_count) { - for (i = 0, scan = new->ifstate_list; - i < new->ipv4_count; i++, scan++) { - nwi_state_diff_add_change(diff, old, scan); + if (new_ifstate->ipv4_count) { + for (i = 0, scan = new_ifstate->ifstate_list; + i < new_ifstate->ipv4_count; i++, scan++) { + nwi_state_diff_add_change(diff, old_ifstate, scan); } } - if (new->ipv6_count) { - scan = new->ifstate_list + new->max_if_count; + if (new_ifstate->ipv6_count) { + scan = new_ifstate->ifstate_list + new_ifstate->max_if_count; for (i = 0; - i < new->ipv6_count; i++, scan++) { - nwi_state_diff_add_change(diff, old, scan); + i < new_ifstate->ipv6_count; i++, scan++) { + nwi_state_diff_add_change(diff, old_ifstate, scan); } } } - if (old != NULL) { + if (old_ifstate != NULL) { /* check for removes */ - if (old->ipv4_count) { - for (i = 0, scan = old->ifstate_list; - i < old->ipv4_count; i++, scan++) { + if (old_ifstate->ipv4_count) { + for (i = 0, scan = old_ifstate->ifstate_list; + i < old_ifstate->ipv4_count; i++, scan++) { nwi_state_diff_remove(diff, scan); } } - if (old->ipv6_count) { - scan = old->ifstate_list + old->max_if_count; + if (old_ifstate->ipv6_count) { + scan = old_ifstate->ifstate_list + old_ifstate->max_if_count; for (i = 0; - i < old->ipv6_count; i++, scan++) { + i < old_ifstate->ipv6_count; i++, scan++) { nwi_state_diff_remove(diff, scan); } } @@ -574,7 +574,7 @@ nwi_state_max_af_count(nwi_state_t state) } __private_extern__ nwi_state_t -nwi_state_diff(nwi_state_t old, nwi_state_t new) +nwi_state_diff(nwi_state_t old_ifstate, nwi_state_t new_ifstate) { nwi_state_t diff; int total_count = 0; @@ -586,18 +586,18 @@ nwi_state_diff(nwi_state_t old, nwi_state_t new) * Worst case assumes that the old and new share none of the * same interfaces. */ - if (old != NULL) { - total_count += nwi_state_max_af_count(old); + if (old_ifstate != NULL) { + total_count += nwi_state_max_af_count(old_ifstate); } - if (new != NULL) { - total_count += nwi_state_max_af_count(new); + if (new_ifstate != NULL) { + total_count += nwi_state_max_af_count(new_ifstate); } if (total_count == 0) { return NULL; } diff = nwi_state_new(NULL, total_count); - nwi_state_diff_populate(diff, old, new); + nwi_state_diff_populate(diff, old_ifstate, new_ifstate); /* diff consists of a nwi_state_t with diff flags on each ifstate */ return diff; @@ -662,12 +662,12 @@ _nwi_state_update_interface_generations(nwi_state_t old_state, nwi_state_t state _nwi_ifstate_set_generation(scan, generation_count); } else { nwi_ifstate_t old_ifstate; - + old_ifstate = nwi_state_get_ifstate_with_name(old_state, AF_INET, scan->ifname); assert(old_ifstate != NULL); - + /* Set the current generation count */ _nwi_ifstate_set_generation(scan, old_ifstate->if_generation_count); @@ -686,12 +686,12 @@ _nwi_state_update_interface_generations(nwi_state_t old_state, nwi_state_t state _nwi_ifstate_set_generation(scan, generation_count); } else { nwi_ifstate_t old_ifstate; - + old_ifstate = nwi_state_get_ifstate_with_name(old_state, AF_INET6, scan->ifname); assert(old_ifstate != NULL); - + /* Set the current generation count */ _nwi_ifstate_set_generation(scan, old_ifstate->if_generation_count); diff --git a/nwi/network_state_information_priv.h b/nwi/network_state_information_priv.h index 8ccffc0..2c7da3f 100644 --- a/nwi/network_state_information_priv.h +++ b/nwi/network_state_information_priv.h @@ -1,15 +1,15 @@ /* - * Copyright (c) 2011-2013, 2016 Apple Inc. All rights reserved. + * Copyright (c) 2011-2013, 2016, 2017 Apple Inc. All rights reserved. * * @APPLE_LICENSE_HEADER_START@ - * + * * This file contains Original Code and/or Modifications of Original Code * as defined in and that are subject to the Apple Public Source License * Version 2.0 (the 'License'). You may not use this file except in * compliance with the License. Please obtain a copy of the License at * http://www.opensource.apple.com/apsl/ and read it before using this * file. - * + * * The Original Code and all software distributed under the License are * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, @@ -17,7 +17,7 @@ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. * Please see the License for the specific language governing rights and * limitations under the License. - * + * * @APPLE_LICENSE_HEADER_END@ */ @@ -34,13 +34,16 @@ #include "network_information.h" +#define NWI_STATE_VERSION ((uint32_t)0x20170601) + + #define NWI_IFSTATE_FLAGS_NOT_IN_LIST 0x0008 #define NWI_IFSTATE_FLAGS_HAS_SIGNATURE 0x0010 #define NWI_IFSTATE_FLAGS_NOT_IN_IFLIST 0x0020 /* * NWI_IFSTATE_FLAGS_MASK - * - these are the bits that get preserved, all others are + * - these are the bits that get preserved, all others are * control (last item, diff) */ #define NWI_IFSTATE_FLAGS_MASK 0x00ff @@ -56,7 +59,30 @@ typedef enum { } nwi_ifstate_difference_t; +/* + * Type: Rank + * Purpose: + * A 32-bit value to encode the relative rank of a service. + * + * The top 8 bits are used to hold the rank assertion (first, default, last, + * never, scoped); + * + * The bottom 24 bits are used to store the service index (i.e. the + * position within the service order array). + */ typedef uint32_t Rank; +#define RANK_ASSERTION_MAKE(r) ((Rank)(r) << 24) // rank assertion (top 8 bits) +#define kRankAssertionFirst RANK_ASSERTION_MAKE(0) +#define kRankAssertionDefault RANK_ASSERTION_MAKE(1) +#define kRankAssertionLast RANK_ASSERTION_MAKE(2) +#define kRankAssertionNever RANK_ASSERTION_MAKE(3) +#define kRankAssertionScoped RANK_ASSERTION_MAKE(4) +#define kRankAssertionMask RANK_ASSERTION_MAKE(0xff) +#define RANK_ASSERTION_MASK(r) ((Rank)(r) & kRankAssertionMask) +#define RANK_INDEX_MAKE(r) ((Rank)(r)) // rank index (bottom 24 bits) +#define kRankIndexMask RANK_INDEX_MAKE(0xffffff) +#define RANK_INDEX_MASK(r) ((Rank)(r) & kRankIndexMask) + typedef int32_t nwi_ifindex_t; #pragma pack(4) @@ -80,8 +106,6 @@ typedef struct _nwi_ifstate { } nwi_ifstate; #pragma pack() -#define NWI_STATE_VERSION ((uint32_t)0x20150214) - #pragma pack(4) typedef struct _nwi_state { uint32_t version; /* NWI_STATE_VERSION */ diff --git a/sctest/SCTestConfigAgents.m b/sctest/SCTestConfigAgents.m index 122f258..dd27b33 100644 --- a/sctest/SCTestConfigAgents.m +++ b/sctest/SCTestConfigAgents.m @@ -1,5 +1,5 @@ /* - * Copyright (c) 2016 Apple Inc. All rights reserved. + * Copyright (c) 2016, 2017 Apple Inc. All rights reserved. * * @APPLE_LICENSE_HEADER_START@ * @@ -187,8 +187,16 @@ SET_PROXY_CONFIG(SOCKS); if ([proxyConfig count] > 0) { - NSString *matchDomain = self.options[kSCTestConfigAgentProxyMatchDomain] ? self.options[kSCTestConfigAgentProxyMatchDomain] : @TEST_DOMAIN; - [proxyConfig setObject:@[matchDomain] forKey:(__bridge NSString *)kSCPropNetProxiesSupplementalMatchDomains]; + + NSArray *domains = nil; + NSString *matchDomains = self.options[kSCTestConfigAgentProxyMatchDomain]; + if (matchDomains == nil) { + domains = @[@TEST_DOMAIN]; + } else { + domains = [matchDomains componentsSeparatedByString:@","]; + } + + [proxyConfig setObject:domains forKey:(__bridge NSString *)kSCPropNetProxiesSupplementalMatchDomains]; } else { proxyConfig = nil; } @@ -644,6 +652,8 @@ change:(NSDictionary *)change context:(void *)context { +#pragma unused(change) +#pragma unused(context) NWPathEvaluator *pathEvaluator = (NWPathEvaluator *)object; if ([keyPath isEqualToString:@"path"]) { self.pathProxy = pathEvaluator.path.proxySettings; diff --git a/sctest/SCTestDynamicStore.m b/sctest/SCTestDynamicStore.m index 6ece952..3100473 100644 --- a/sctest/SCTestDynamicStore.m +++ b/sctest/SCTestDynamicStore.m @@ -1,5 +1,5 @@ /* - * Copyright (c) 2016 Apple Inc. All rights reserved. + * Copyright (c) 2016, 2017 Apple Inc. All rights reserved. * * @APPLE_LICENSE_HEADER_START@ * @@ -228,6 +228,8 @@ void myTestCallback(SCDynamicStoreRef store, CFArrayRef changedKeys, void *ctx) { +#pragma unused(store) +#pragma unused(changedKeys) SCTestDynamicStore *test = (__bridge SCTestDynamicStore *)ctx; test.counter++; if (test.sem != NULL) { diff --git a/sctest/SCTestOptions.h b/sctest/SCTestOptions.h index 665987c..46be006 100644 --- a/sctest/SCTestOptions.h +++ b/sctest/SCTestOptions.h @@ -91,7 +91,7 @@ extern const NSString * const kSCTestUnitTestTestMethodList; "-gopher_proxy : Add a proxy agent with Gopher proxy. Format of the argument is 'server:port'\n"\ "-http_proxy : Add a proxy agent with HTTP proxy. Format of the argument is 'server:port'\n"\ "-https_proxy : Add a proxy agent with HTTPS proxy. Format of the argument is 'server:port'\n"\ - "-proxy_match_domain : Add a proxy agent for a match domain. If this option is not specified, 'apple.com' will be used\n"\ + "-proxy_match_domain : Configures the Proxy server for certain domains. A comma-separated list of domains can be specified. Default is 'apple.com'\n"\ "-remove_proxy : Remove a proxy configuration, previously configured via 'sctest'\n"\ "-socks_proxy : Add a proxy agent with SOCKS proxy. Format of the argument is 'server:port'\n"\ "\n============== reachability options =============\n"\ diff --git a/sctest/SCTestPreferences.m b/sctest/SCTestPreferences.m index f444586..eaae58a 100644 --- a/sctest/SCTestPreferences.m +++ b/sctest/SCTestPreferences.m @@ -1,5 +1,5 @@ /* - * Copyright (c) 2016 Apple Inc. All rights reserved. + * Copyright (c) 2016, 2017 Apple Inc. All rights reserved. * * @APPLE_LICENSE_HEADER_START@ * @@ -107,72 +107,125 @@ - (BOOL)unitTestNetworkServicesSanity { // We verify that every service has a unique name, an interface, an IPv4 config method and and IPv6 config method. + NSArray *sets; NSDictionary *services; - NSMutableArray *serviceNameArray; SCTestPreferences *test; test = [[SCTestPreferences alloc] initWithOptions:self.options]; + + sets = (__bridge_transfer NSArray *)SCNetworkSetCopyAll(test.prefs); + if (sets == nil || [sets count] == 0) { + SCTestLog("No sets present!"); + return NO; + } + services = (__bridge NSDictionary *)SCPreferencesGetValue(test.prefs, kSCPrefNetworkServices); - if (services == NULL) { + if (services == nil || [services count] == 0) { SCTestLog("No services present!"); return NO; } - serviceNameArray = [[NSMutableArray alloc] init]; - for (NSString *serviceID in services) { - NSDictionary *serviceDict; - NSString *serviceName; - NSDictionary *interfaceDict; - NSString *interfaceType; - NSDictionary *ipv4Dict; - NSDictionary *ipv6Dict; - - serviceDict = [services objectForKey:serviceID]; - if (![serviceDict isKindOfClass:[NSDictionary class]]) { - SCTestLog("Service is not a dictionary"); - return NO; + for (id setPtr in sets) { + SCNetworkSetRef set = (__bridge SCNetworkSetRef)setPtr; + NSArray *serviceArray = nil; + NSMutableArray *serviceNameArray = nil; + NSString *setID; + + setID = (__bridge NSString *)SCNetworkSetGetSetID(set); + + serviceArray = (__bridge_transfer NSArray *)SCNetworkSetCopyServices(set); + if (serviceArray == nil) { + SCTestLog("No services in set %@!", setID); + continue; } - serviceName = [serviceDict objectForKey:(__bridge NSString *)kSCPropNetServiceUserDefinedName]; - if (serviceName != nil) { - // Check if the name is unique - BOOL namePresent = [serviceNameArray containsObject:serviceName]; - if (!namePresent) { - [serviceNameArray addObject:serviceName]; + serviceNameArray = [[NSMutableArray alloc] init]; + for (id servicePTR in serviceArray) { + NSDictionary *serviceDict; + NSDictionary *ipv4Dict; + NSDictionary *ipv6Dict; + NSDictionary *ipv4ProtocolConfig; + NSDictionary *ipv6ProtocolConfig; + NSString *serviceName; + NSString *serviceID; + NSString *interfaceType; + SCNetworkServiceRef service; + SCNetworkInterfaceRef interface; + SCNetworkProtocolRef ipv4Protocol; + SCNetworkProtocolRef ipv6Protocol; + + + service = (__bridge SCNetworkServiceRef)servicePTR; + serviceID = (__bridge NSString *)SCNetworkServiceGetServiceID(service); + + serviceDict = [services objectForKey:serviceID]; + if (![serviceDict isKindOfClass:[NSDictionary class]]) { + SCTestLog("Service is not a dictionary"); + return NO; + } + + serviceName = (__bridge NSString *)SCNetworkServiceGetName(service); + if (serviceName != nil) { + // Check if the name is unique + BOOL namePresent = [serviceNameArray containsObject:serviceName]; + if (!namePresent) { + [serviceNameArray addObject:serviceName]; + } else { + SCTestLog("Duplicate services with name %@ exist", serviceName); + return NO; + } } else { - SCTestLog("Duplicate services with name %@ exist", serviceName); + SCTestLog("Service ID %@ does not have a name", serviceID); return NO; } - } else { - SCTestLog("Service ID %@ does not have a name", serviceID); - return NO; - } - interfaceDict = [serviceDict objectForKey:(__bridge NSString *)kSCCompInterface]; - if (interfaceDict == nil) { - SCTestLog("Service %@ does not have an interface", serviceName); - return NO; - } + interface = SCNetworkServiceGetInterface(service); + if (interface == nil) { + SCTestLog("Service %@ does not have an interface", serviceName); + return NO; + } - interfaceType = [interfaceDict objectForKey:(__bridge NSString *)kSCPropNetInterfaceType]; - if (interfaceType != nil && [interfaceType containsString:@"CommCenter"]) { - // CommCenter services typically do not have an ipv4/v6 data OR config method. Skip such services. - continue; - } + interfaceType = (__bridge NSString *)SCNetworkInterfaceGetInterfaceType(interface); + if (interfaceType == nil || [interfaceType length] == 0) { + SCTestLog("Service %@ does not have an interface type", serviceName); + return NO; + } +#if TARGET_OS_IPHONE + if ([interfaceType containsString:@"CommCenter"]) { + // CommCenter services typically do not have an ipv4/v6 data OR config method. Skip such services. + continue; + } +#endif // TARGET_OS_IPHONE + ipv4Protocol = SCNetworkServiceCopyProtocol(service, kSCNetworkProtocolTypeIPv4); + ipv6Protocol = SCNetworkServiceCopyProtocol(service, kSCNetworkProtocolTypeIPv6); + + if (ipv4Protocol != NULL) { + ipv4ProtocolConfig = (__bridge NSDictionary *)SCNetworkProtocolGetConfiguration(ipv4Protocol); + if (ipv4ProtocolConfig != nil) { + ipv4Dict = [ipv4ProtocolConfig copy]; + } + CFRelease(ipv4Protocol); + } - ipv4Dict = [serviceDict objectForKey:(__bridge NSString *)kSCEntNetIPv4]; - ipv6Dict = [serviceDict objectForKey:(__bridge NSString *)kSCEntNetIPv6]; + if (ipv6Protocol != NULL) { + ipv6ProtocolConfig = (__bridge NSDictionary *)SCNetworkProtocolGetConfiguration(ipv6Protocol); + if (ipv6ProtocolConfig != nil) { + ipv6Dict = [ipv6ProtocolConfig copy]; + } + CFRelease(ipv6Protocol); + } - // Check that we have at least one IP config method - if (ipv4Dict == nil && ipv6Dict == nil) { - SCTestLog("Service %@ does not have an IP dictionary", serviceName); - return NO; - } + // Check that we have at least one IP config method + if (ipv4Dict == nil && ipv6Dict == nil) { + SCTestLog("Service %@ does not have an IP dictionary", serviceName); + return NO; + } - if ([ipv4Dict objectForKey:(__bridge NSString *)kSCPropNetIPv4ConfigMethod] == nil && - [ipv6Dict objectForKey:(__bridge NSString *)kSCPropNetIPv6ConfigMethod] == nil) { - SCTestLog("Service %@ does not have an IP Config Method", serviceName); - return NO; + if ([ipv4Dict objectForKey:(__bridge NSString *)kSCPropNetIPv4ConfigMethod] == nil && + [ipv6Dict objectForKey:(__bridge NSString *)kSCPropNetIPv6ConfigMethod] == nil) { + SCTestLog("Service %@ does not have an IP Config Method", serviceName); + return NO; + } } } @@ -215,7 +268,7 @@ - (BOOL)unitTestPreferencesAPI { BOOL ok = NO; - int iterations = 1000; + int iterations = 100; NSDictionary *prefsOptions; NSMutableArray *keys; NSMutableArray *values; diff --git a/sctest/SCTestReachability.m b/sctest/SCTestReachability.m index c638a66..0045d03 100644 --- a/sctest/SCTestReachability.m +++ b/sctest/SCTestReachability.m @@ -1,5 +1,5 @@ /* - * Copyright (c) 2016 Apple Inc. All rights reserved. + * Copyright (c) 2016, 2017 Apple Inc. All rights reserved. * * @APPLE_LICENSE_HEADER_START@ * @@ -101,8 +101,10 @@ } void -myReachabilityCallback(SCNetworkReachabilityRef target, SCNetworkReachabilityFlags flags, void *info) +myReachabilityCallback(SCNetworkReachabilityRef target, SCNetworkReachabilityFlags flags, void *info) { +#pragma unused(target) +#pragma unused(info) struct tm tm_now; struct timeval tv_now; (void)gettimeofday(&tv_now, NULL); diff --git a/sctest/genSCTestOptions.c b/sctest/genSCTestOptions.c index dabf9f3..4374622 100644 --- a/sctest/genSCTestOptions.c +++ b/sctest/genSCTestOptions.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2016 Apple Inc. All rights reserved. + * Copyright (c) 2016, 2017 Apple Inc. All rights reserved. * * @APPLE_LICENSE_HEADER_START@ * @@ -62,7 +62,7 @@ SCTestOption testOptions[] = { {"config_agent", "gopher_proxy", "kSCTestConfigAgentGopherProxy", required_argument, "Add a proxy agent with Gopher proxy. Format of the argument is 'server:port'"}, {"config_agent", "http_proxy", "kSCTestConfigAgentHTTPProxy", required_argument, "Add a proxy agent with HTTP proxy. Format of the argument is 'server:port'"}, {"config_agent", "https_proxy", "kSCTestConfigAgentHTTPSProxy", required_argument, "Add a proxy agent with HTTPS proxy. Format of the argument is 'server:port'"}, - {"config_agent", "proxy_match_domain", "kSCTestConfigAgentProxyMatchDomain", required_argument, "Add a proxy agent for a match domain. If this option is not specified, 'apple.com' will be used"}, + {"config_agent", "proxy_match_domain", "kSCTestConfigAgentProxyMatchDomain", required_argument, "Configures the Proxy server for certain domains. A comma-separated list of domains can be specified. Default is 'apple.com'"}, {"config_agent", "remove_proxy", "kSCTestConfigAgentRemoveProxy", no_argument, "Remove a proxy configuration, previously configured via 'sctest'"}, {"config_agent", "socks_proxy", "kSCTestConfigAgentSOCKSProxy", required_argument, "Add a proxy agent with SOCKS proxy. Format of the argument is 'server:port'"}, diff --git a/scutil.tproj/cache.c b/scutil.tproj/cache.c index b8016e7..b04dc05 100644 --- a/scutil.tproj/cache.c +++ b/scutil.tproj/cache.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2000-2005, 2011 Apple Inc. All rights reserved. + * Copyright (c) 2000-2005, 2011, 2017 Apple Inc. All rights reserved. * * @APPLE_LICENSE_HEADER_START@ * @@ -114,6 +114,7 @@ cache_SCDynamicStoreCopyValue(SCDynamicStoreRef store, CFStringRef key) static void cache_SCDynamicStoreSetValue(SCDynamicStoreRef store, CFStringRef key, CFPropertyListRef value) { +#pragma unused (store) CFIndex i; i = CFArrayGetFirstIndexOfValue(cached_removals, @@ -132,6 +133,7 @@ cache_SCDynamicStoreSetValue(SCDynamicStoreRef store, CFStringRef key, CFPropert static void cache_SCDynamicStoreRemoveValue(SCDynamicStoreRef store, CFStringRef key) { +#pragma unused (store) CFDictionaryRemoveValue(cached_set, key); if (!CFArrayContainsValue(cached_removals, @@ -147,6 +149,7 @@ cache_SCDynamicStoreRemoveValue(SCDynamicStoreRef store, CFStringRef key) static void cache_SCDynamicStoreNotifyValue(SCDynamicStoreRef store, CFStringRef key) { +#pragma unused (store) if (!CFArrayContainsValue(cached_notifys, CFRangeMake(0, CFArrayGetCount(cached_notifys)), key)) { @@ -258,7 +261,9 @@ do_block(int argc, char **argv) static CFComparisonResult -sort_keys(const void *p1, const void *p2, void *context) { +sort_keys(const void *p1, const void *p2, void *context) +{ +#pragma unused(context) CFStringRef key1 = (CFStringRef)p1; CFStringRef key2 = (CFStringRef)p2; return CFStringCompare(key1, key2, 0); @@ -401,6 +406,7 @@ __private_extern__ void do_get(int argc, char **argv) { +#pragma unused(argc) CFStringRef key; CFPropertyListRef newValue; @@ -429,6 +435,7 @@ __private_extern__ void do_set(int argc, char **argv) { +#pragma unused(argc) CFStringRef key; key = CFStringCreateWithCString(NULL, argv[0], kCFStringEncodingUTF8); @@ -518,6 +525,7 @@ __private_extern__ void do_remove(int argc, char **argv) { +#pragma unused(argc) CFStringRef key; key = CFStringCreateWithCString(NULL, argv[0], kCFStringEncodingUTF8); @@ -537,6 +545,7 @@ __private_extern__ void do_notify(int argc, char **argv) { +#pragma unused(argc) CFStringRef key; key = CFStringCreateWithCString(NULL, argv[0], kCFStringEncodingUTF8); diff --git a/scutil.tproj/commands.c b/scutil.tproj/commands.c index d29719e..24afcdd 100644 --- a/scutil.tproj/commands.c +++ b/scutil.tproj/commands.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2000-2011, 2013, 2014 Apple Inc. All rights reserved. + * Copyright (c) 2000-2011, 2013, 2014, 2017 Apple Inc. All rights reserved. * * @APPLE_LICENSE_HEADER_START@ * @@ -140,8 +140,8 @@ const cmdInfo commands_store[] = { { "n.cancel", 0, 1, do_notify_cancel, 5, 0, " n.cancel : cancel notification requests" }, - { "snapshot", 0, 0, do_snapshot, 99, 2, - " snapshot : save snapshot of store and session data" } + { "snapshot", 0, 1, do_snapshot, 99, 2, + " snapshot [file] : save snapshot of store and session data" } }; __private_extern__ const int nCommands_store = (sizeof(commands_store)/sizeof(cmdInfo)); @@ -354,6 +354,8 @@ __private_extern__ void do_help(int argc, char **argv) { +#pragma unused(argc) +#pragma unused(argv) int g = -1; /* current group */ int i; @@ -386,6 +388,7 @@ __private_extern__ void do_readFile(int argc, char **argv) { +#pragma unused(argc) InputRef src; /* allocate command input stream */ @@ -424,6 +427,8 @@ __private_extern__ void do_quit(int argc, char **argv) { +#pragma unused(argc) +#pragma unused(argv) termRequested = TRUE; return; } diff --git a/scutil.tproj/dictionary.c b/scutil.tproj/dictionary.c index 49a1fdd..d587fa2 100644 --- a/scutil.tproj/dictionary.c +++ b/scutil.tproj/dictionary.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2000-2005, 2009-2011, 2013, 2016 Apple Inc. All rights reserved. + * Copyright (c) 2000-2005, 2009-2011, 2013, 2016, 2017 Apple Inc. All rights reserved. * * @APPLE_LICENSE_HEADER_START@ * @@ -39,6 +39,8 @@ __private_extern__ void do_dictInit(int argc, char **argv) { +#pragma unused(argc) +#pragma unused(argv) if (value != NULL) { CFRelease(value); } @@ -57,6 +59,8 @@ __private_extern__ void do_dictShow(int argc, char **argv) { +#pragma unused(argc) +#pragma unused(argv) if (value == NULL) { SCPrint(TRUE, stdout, CFSTR("d.show: dictionary must be initialized.\n")); return; @@ -239,6 +243,7 @@ __private_extern__ void do_dictRemoveKey(int argc, char **argv) { +#pragma unused(argc) CFStringRef key; CFMutableDictionaryRef val; diff --git a/scutil.tproj/nc.c b/scutil.tproj/nc.c index 31769e1..db52aa6 100644 --- a/scutil.tproj/nc.c +++ b/scutil.tproj/nc.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2010-2015 Apple Inc. All rights reserved. + * Copyright (c) 2010-2015, 2017 Apple Inc. All rights reserved. * * @APPLE_LICENSE_HEADER_START@ * @@ -558,6 +558,7 @@ checkOnDemandHost(SCDynamicStoreRef store, CFStringRef nodeName, Boolean retry) static void nc_ondemand_callback(SCDynamicStoreRef store, CFArrayRef changedKeys, void *info) { +#pragma unused(info) CFStringRef key = NULL; CFDictionaryRef ondemand_dict = NULL; struct tm tm_now; @@ -765,6 +766,8 @@ nc_print_VPN_service(SCNetworkServiceRef service) static void nc_list(int argc, char **argv) { +#pragma unused(argc) +#pragma unused(argv) CFIndex count; CFIndex i; CFArrayRef services = NULL; @@ -1139,6 +1142,8 @@ done: static void nc_help(int argc, char **argv) { +#pragma unused(argc) +#pragma unused(argv) SCPrint(TRUE, stderr, CFSTR("Valid commands for scutil --nc (VPN connections)\n")); SCPrint(TRUE, stderr, CFSTR("Usage: scutil --nc [command]\n")); SCPrint(TRUE, stderr, CFSTR("\n")); diff --git a/scutil.tproj/net.c b/scutil.tproj/net.c index 6327c58..d793a7c 100644 --- a/scutil.tproj/net.c +++ b/scutil.tproj/net.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2004-2007, 2009-2011, 2014, 2016 Apple Inc. All rights reserved. + * Copyright (c) 2004-2007, 2009-2011, 2014, 2016, 2017 Apple Inc. All rights reserved. * * @APPLE_LICENSE_HEADER_START@ * @@ -163,9 +163,14 @@ _process_options(optionsRef options, int nOptions, int argc, char **argv, CFMuta return FALSE; } - CFDictionarySetValue(newConfiguration, - *(options[optionIndex].key), - *(choices[i].key)); + if (choices[i].key != NULL) { + CFDictionarySetValue(newConfiguration, + *(options[optionIndex].key), + *(choices[i].key)); + } else { + CFDictionaryRemoveValue(newConfiguration, + *(options[optionIndex].key)); + } } else { SCPrint(TRUE, stdout, CFSTR("invalid %s\n"), @@ -583,6 +588,8 @@ __private_extern__ void do_net_commit(int argc, char **argv) { +#pragma unused(argc) +#pragma unused(argv) if (!SCPreferencesCommitChanges(prefs)) { SCPrint(TRUE, stdout, CFSTR("%s\n"), SCErrorString(SCError())); return; @@ -597,6 +604,8 @@ __private_extern__ void do_net_apply(int argc, char **argv) { +#pragma unused(argc) +#pragma unused(argv) if (!SCPreferencesApplyChanges(prefs)) { SCPrint(TRUE, stdout, CFSTR("%s\n"), SCErrorString(SCError())); } @@ -849,6 +858,7 @@ do_net_migrate_perform(int argc, char **argv) static void do_net_migrate_validate(int argc, char **argv) { +#pragma unused(argc) char *configuration = NULL; CFURLRef configurationURL = NULL; char *expectedConfiguration = NULL; @@ -890,13 +900,11 @@ do_net_migrate(int argc, char **argv) argv++; argc--; - if (strncmp(key, "perform", strlen(key)) == 0) { + if (strcmp(key, "perform") == 0) { do_net_migrate_perform(argc, argv); - } - else if (strncmp(key, "validate", strlen(key)) == 0) { + } else if (strcmp(key, "validate") == 0) { do_net_migrate_validate(argc, argv); - } - else { + } else { SCPrint(TRUE, stderr, CFSTR("migrate what?\n")); return; } @@ -1006,6 +1014,8 @@ __private_extern__ void do_net_update(int argc, char **argv) { +#pragma unused(argc) +#pragma unused(argv) SCNetworkSetRef set; Boolean setCreated = FALSE; Boolean setUpdated = FALSE; @@ -1075,6 +1085,8 @@ __private_extern__ void do_net_snapshot(int argc, char **argv) { +#pragma unused(argc) +#pragma unused(argv) if (prefs == NULL) { SCPrint(TRUE, stdout, CFSTR("network configuration not open\n")); return; diff --git a/scutil.tproj/net_interface.c b/scutil.tproj/net_interface.c index a18ef93..c570db5 100644 --- a/scutil.tproj/net_interface.c +++ b/scutil.tproj/net_interface.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2004-2011, 2013-2016 Apple Inc. All rights reserved. + * Copyright (c) 2004-2011, 2013-2017 Apple Inc. All rights reserved. * * @APPLE_LICENSE_HEADER_START@ * @@ -277,7 +277,13 @@ _find_interface(int argc, char **argv, int *nArgs) selected = _SCNetworkInterfaceCreateWithBSDName(NULL, select_name, kIncludeNoVirtualInterfaces); if (selected != NULL) { - goto done; + if (_SCNetworkInterfaceGetIOPath(selected) != NULL) { + // if [real] interface exists + goto done; + } + + CFRelease(selected); + selected = NULL; } // try to select the interface by its interface type @@ -937,6 +943,8 @@ __private_extern__ void show_interfaces(int argc, char **argv) { +#pragma unused(argc) +#pragma unused(argv) CFIndex i; CFIndex n; @@ -1047,6 +1055,9 @@ show_interfaces(int argc, char **argv) static int __doRank(CFStringRef key, const char *description, void *info, int argc, char **argv, CFMutableDictionaryRef newConfiguration) { +#pragma unused(key) +#pragma unused(info) +#pragma unused(newConfiguration) SCNetworkInterfaceRef interface; CFStringRef interfaceName; Boolean ok = FALSE; @@ -1151,6 +1162,10 @@ static options qosOptions[] = { static int __doQoSMarking(CFStringRef key, const char *description, void *info, int argc, char **argv, CFMutableDictionaryRef newConfiguration) { +#pragma unused(key) +#pragma unused(description) +#pragma unused(info) +#pragma unused(newConfiguration) CFStringRef interfaceName; CFMutableDictionaryRef newPolicy; Boolean ok; @@ -1340,6 +1355,7 @@ set_interface_airport(int argc, char **argv, CFMutableDictionaryRef newConfigura static int __doCapability(CFStringRef key, const char *description, void *info, int argc, char **argv, CFMutableDictionaryRef newConfiguration) { +#pragma unused(info) Boolean ok = FALSE; if (argc < 1) { @@ -1436,6 +1452,8 @@ set_interface_ethernet(int argc, char **argv, CFMutableDictionaryRef newConfigur static int __doIPSecSharedSecret(CFStringRef key, const char *description, void *info, int argc, char **argv, CFMutableDictionaryRef newConfiguration) { +#pragma unused(description) +#pragma unused(info) CFStringRef encryptionType; if (argc < 1) { @@ -1514,6 +1532,8 @@ __doIPSecSharedSecret(CFStringRef key, const char *description, void *info, int static int __doIPSecSharedSecretType(CFStringRef key, const char *description, void *info, int argc, char **argv, CFMutableDictionaryRef newConfiguration) { +#pragma unused(description) +#pragma unused(info) if (argc < 1) { SCPrint(TRUE, stdout, CFSTR("IPSec shared secret type mode not specified\n")); return -1; @@ -1540,6 +1560,8 @@ __doIPSecSharedSecretType(CFStringRef key, const char *description, void *info, static int __doIPSecXAuthPassword(CFStringRef key, const char *description, void *info, int argc, char **argv, CFMutableDictionaryRef newConfiguration) { +#pragma unused(description) +#pragma unused(info) CFStringRef encryptionType; if (argc < 1) { @@ -1619,6 +1641,8 @@ __doIPSecXAuthPassword(CFStringRef key, const char *description, void *info, int static int __doIPSecXAuthPasswordType(CFStringRef key, const char *description, void *info, int argc, char **argv, CFMutableDictionaryRef newConfiguration) { +#pragma unused(description) +#pragma unused(info) if (argc < 1) { SCPrint(TRUE, stdout, CFSTR("IPSec XAuth password type mode not specified\n")); return -1; @@ -1662,6 +1686,8 @@ __cleanupDomainName(CFStringRef domain) static int __doOnDemandDomains(CFStringRef key, const char *description, void *info, int argc, char **argv, CFMutableDictionaryRef newConfiguration) { +#pragma unused(description) +#pragma unused(info) CFMutableArrayRef domains; if (argc < 1) { @@ -1733,6 +1759,9 @@ static options ipsecOnDemandOptions[] = { static int __doIPSecOnDemandMatch(CFStringRef key, const char *description, void *info, int argc, char **argv, CFMutableDictionaryRef newConfiguration) { +#pragma unused(key) +#pragma unused(description) +#pragma unused(info) Boolean ok; if (argc < 1) { @@ -1920,6 +1949,8 @@ set_interface_modem(int argc, char **argv, CFMutableDictionaryRef newConfigurati static int __doPPPAuthPW(CFStringRef key, const char *description, void *info, int argc, char **argv, CFMutableDictionaryRef newConfiguration) { +#pragma unused(description) +#pragma unused(info) CFStringRef encryptionType; if (argc < 1) { @@ -1999,6 +2030,8 @@ __doPPPAuthPW(CFStringRef key, const char *description, void *info, int argc, ch static int __doPPPAuthPWType(CFStringRef key, const char *description, void *info, int argc, char **argv, CFMutableDictionaryRef newConfiguration) { +#pragma unused(description) +#pragma unused(info) if (argc < 1) { SCPrint(TRUE, stdout, CFSTR("PPP password type mode not specified\n")); return -1; @@ -2038,6 +2071,10 @@ static options l2tp_ipsecOptions[] = { static int __doPPPIPSec(CFStringRef key, const char *description, void *info, int argc, char **argv, CFMutableDictionaryRef newPPPConfiguration) { +#pragma unused(key) +#pragma unused(description) +#pragma unused(info) +#pragma unused(newPPPConfiguration) SCNetworkInterfaceRef childInterface; CFStringRef childInterfaceType; CFDictionaryRef configuration; @@ -2265,6 +2302,9 @@ set_interface_ppp(int argc, char **argv, CFMutableDictionaryRef newConfiguration static Boolean set_interface_vlan(int argc, char **argv, CFMutableDictionaryRef newConfiguration) { +#pragma unused(argc) +#pragma unused(argv) +#pragma unused(newConfiguration) // xxxxx ("device", "tag") SCPrint(TRUE, stdout, CFSTR("vlan interface management not yet supported\n")); return FALSE; @@ -2278,6 +2318,8 @@ SCPrint(TRUE, stdout, CFSTR("vlan interface management not yet supported\n")); static int __doVPNAuthPW(CFStringRef key, const char *description, void *info, int argc, char **argv, CFMutableDictionaryRef newConfiguration) { +#pragma unused(description) +#pragma unused(info) CFStringRef encryptionType; if (argc < 1) { @@ -2356,6 +2398,8 @@ __doVPNAuthPW(CFStringRef key, const char *description, void *info, int argc, ch static int __doVPNAuthPWType(CFStringRef key, const char *description, void *info, int argc, char **argv, CFMutableDictionaryRef newConfiguration) { +#pragma unused(description) +#pragma unused(info) if (argc < 1) { SCPrint(TRUE, stdout, CFSTR("VPN password type mode not specified\n")); return -1; diff --git a/scutil.tproj/net_protocol.c b/scutil.tproj/net_protocol.c index a1b6f60..81f4ac7 100644 --- a/scutil.tproj/net_protocol.c +++ b/scutil.tproj/net_protocol.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2004-2009, 2011, 2014 Apple Inc. All rights reserved. + * Copyright (c) 2004-2009, 2011, 2014, 2017 Apple Inc. All rights reserved. * * @APPLE_LICENSE_HEADER_START@ * @@ -44,22 +44,6 @@ /* -------------------- */ -__private_extern__ -CFComparisonResult -_compare_protocols(const void *val1, const void *val2, void *context) -{ - SCNetworkProtocolRef p1 = (SCNetworkProtocolRef)val1; - SCNetworkProtocolRef p2 = (SCNetworkProtocolRef)val2; - CFStringRef type1; - CFStringRef type2; - - type1 = SCNetworkProtocolGetProtocolType(p1); - type2 = SCNetworkProtocolGetProtocolType(p2); - - return CFStringCompare(type1, type2, 0); -} - - static CFStringRef __copyIPv4Address(const char *arg) { @@ -121,7 +105,7 @@ _find_protocol(char *match) sorted = CFArrayCreateMutableCopy(NULL, 0, protocols); CFArraySortValues(sorted, CFRangeMake(0, n), - _compare_protocols, + _SCNetworkProtocolCompare, NULL); CFRelease(protocols); protocols = sorted; @@ -386,6 +370,7 @@ __private_extern__ void select_protocol(int argc, char **argv) { +#pragma unused(argc) SCNetworkProtocolRef protocol; protocol = _find_protocol(argv[0]); @@ -429,6 +414,8 @@ __cleanupDomainName(CFStringRef domain) static int __doDNSDomain(CFStringRef key, const char *description, void *info, int argc, char **argv, CFMutableDictionaryRef newConfiguration) { +#pragma unused(description) +#pragma unused(info) if (argc < 1) { SCPrint(TRUE, stdout, CFSTR("DNS domain name not specified\n")); return -1; @@ -460,6 +447,8 @@ __doDNSDomain(CFStringRef key, const char *description, void *info, int argc, ch static int __doDNSDomainArray(CFStringRef key, const char *description, void *info, int argc, char **argv, CFMutableDictionaryRef newConfiguration) { +#pragma unused(description) +#pragma unused(info) CFMutableArrayRef domains; if (argc < 1) { @@ -513,6 +502,8 @@ __doDNSDomainArray(CFStringRef key, const char *description, void *info, int arg static int __doDNSServerAddresses(CFStringRef key, const char *description, void *info, int argc, char **argv, CFMutableDictionaryRef newConfiguration) { +#pragma unused(description) +#pragma unused(info) CFMutableArrayRef servers; if (argc < 1) { @@ -629,6 +620,10 @@ static selections ipv4ConfigMethods[] = { static int __doIPv4ConfigMethod(CFStringRef key, const char *description, void *info, int argc, char **argv, CFMutableDictionaryRef newConfiguration) { +#pragma unused(description) +#pragma unused(info) +#pragma unused(argc) +#pragma unused(argv) unsigned int flags; CFStringRef method; CFIndex methodIndex; @@ -660,6 +655,8 @@ __doIPv4ConfigMethod(CFStringRef key, const char *description, void *info, int a static int __doIPv4Addresses(CFStringRef key, const char *description, void *info, int argc, char **argv, CFMutableDictionaryRef newConfiguration) { +#pragma unused(description) +#pragma unused(argc) Boolean useArray = (info == (void *)FALSE) ? FALSE : TRUE; if (strlen(argv[0]) > 0) { @@ -790,6 +787,10 @@ static selections ipv6ConfigMethods[] = { static int __doIPv6ConfigMethod(CFStringRef key, const char *description, void *info, int argc, char **argv, CFMutableDictionaryRef newConfiguration) { +#pragma unused(description) +#pragma unused(info) +#pragma unused(argc) +#pragma unused(argv) unsigned int flags; CFStringRef method; CFIndex methodIndex; @@ -818,6 +819,8 @@ __doIPv6ConfigMethod(CFStringRef key, const char *description, void *info, int a static int __doIPv6Addresses(CFStringRef key, const char *description, void *info, int argc, char **argv, CFMutableDictionaryRef newConfiguration) { +#pragma unused(description) +#pragma unused(argc) Boolean useArray = (info == (void *)FALSE) ? FALSE : TRUE; if (strlen(argv[0]) > 0) { @@ -1011,6 +1014,9 @@ static options proxyOptions[] = { static int __doProxySelect(CFStringRef key, const char *description, void *info, int argc, char **argv, CFMutableDictionaryRef newConfiguration) { +#pragma unused(key) +#pragma unused(description) +#pragma unused(newConfiguration) CFIndex nextOption; if (argc < 1) { @@ -1034,6 +1040,10 @@ __doProxySelect(CFStringRef key, const char *description, void *info, int argc, static int __doProxyEnable(CFStringRef key, const char *description, void *info, int argc, char **argv, CFMutableDictionaryRef newConfiguration) { +#pragma unused(key) +#pragma unused(description) +#pragma unused(argc) +#pragma unused(argv) Boolean enabled = (info == (void *)FALSE) ? FALSE : TRUE; if (currentProxy == NULL) { @@ -1095,6 +1105,9 @@ __proxy_enabled(CFDictionaryRef configuration, const CFStringRef *enableKey) static int __doProxyHost(CFStringRef key, const char *description, void *info, int argc, char **argv, CFMutableDictionaryRef newConfiguration) { +#pragma unused(key) +#pragma unused(description) +#pragma unused(info) if (currentProxy == NULL) { SCPrint(TRUE, stdout, CFSTR("proxy not specified\n")); return -1; @@ -1132,6 +1145,9 @@ __doProxyHost(CFStringRef key, const char *description, void *info, int argc, ch static int __doProxyPort(CFStringRef key, const char *description, void *info, int argc, char **argv, CFMutableDictionaryRef newConfiguration) { +#pragma unused(key) +#pragma unused(description) +#pragma unused(info) if (currentProxy == NULL) { SCPrint(TRUE, stdout, CFSTR("proxy not specified\n")); return -1; @@ -1178,6 +1194,9 @@ __doProxyPort(CFStringRef key, const char *description, void *info, int argc, ch static int __doProxyURL(CFStringRef key, const char *description, void *info, int argc, char **argv, CFMutableDictionaryRef newConfiguration) { +#pragma unused(key) +#pragma unused(description) +#pragma unused(info) if (currentProxy == NULL) { SCPrint(TRUE, stdout, CFSTR("proxy not specified\n")); return -1; @@ -1215,6 +1234,12 @@ __doProxyURL(CFStringRef key, const char *description, void *info, int argc, cha static int __doProxyFTPPassive(CFStringRef key, const char *description, void *info, int argc, char **argv, CFMutableDictionaryRef newConfiguration) { +#pragma unused(key) +#pragma unused(description) +#pragma unused(info) +#pragma unused(argc) +#pragma unused(argv) +#pragma unused(newConfiguration) if (currentProxy == NULL) { SCPrint(TRUE, stdout, CFSTR("proxy not specified\n")); return -1; @@ -1265,6 +1290,8 @@ __cleanupName(CFStringRef name) static int __doSMBName(CFStringRef key, const char *description, void *info, int argc, char **argv, CFMutableDictionaryRef newConfiguration) { +#pragma unused(description) +#pragma unused(info) if (argc < 1) { SCPrint(TRUE, stdout, CFSTR("NetBIOS name not specified\n")); return -1; @@ -1296,6 +1323,8 @@ __doSMBName(CFStringRef key, const char *description, void *info, int argc, char static int __doSMBWorkgroup(CFStringRef key, const char *description, void *info, int argc, char **argv, CFMutableDictionaryRef newConfiguration) { +#pragma unused(description) +#pragma unused(info) if (argc < 1) { SCPrint(TRUE, stdout, CFSTR("Workgroup not specified\n")); return -1; @@ -1327,6 +1356,8 @@ __doSMBWorkgroup(CFStringRef key, const char *description, void *info, int argc, static int __doSMBWINSAddresses(CFStringRef key, const char *description, void *info, int argc, char **argv, CFMutableDictionaryRef newConfiguration) { +#pragma unused(description) +#pragma unused(info) CFMutableArrayRef servers; if (argc < 1) { @@ -1550,6 +1581,8 @@ __private_extern__ void show_protocols(int argc, char **argv) { +#pragma unused(argc) +#pragma unused(argv) CFIndex i; CFIndex n; @@ -1577,7 +1610,7 @@ show_protocols(int argc, char **argv) sorted = CFArrayCreateMutableCopy(NULL, 0, protocols); CFArraySortValues(sorted, CFRangeMake(0, n), - _compare_protocols, + _SCNetworkProtocolCompare, NULL); CFRelease(protocols); protocols = sorted; @@ -1691,11 +1724,23 @@ _protocol_description(SCNetworkProtocolRef protocol, Boolean skipEmpty) CFArrayGetValueAtIndex(addresses, 0)); } else if (CFEqual(method, kSCValNetIPv4ConfigMethodManual) && isA_CFArray(addresses)) { + CFStringRef router; + CFStringAppendFormat(description, NULL, CFSTR("%@, address=%@"), method, CFArrayGetValueAtIndex(addresses, 0)); + + if (CFDictionaryGetValueIfPresent(configuration, + kSCPropNetIPv4Router, + (const void **)&router) && + isA_CFString(router)) { + CFStringAppendFormat(description, + NULL, + CFSTR(", router=%@"), + router); + } } else { CFStringAppendFormat(description, NULL, @@ -1714,11 +1759,10 @@ _protocol_description(SCNetworkProtocolRef protocol, Boolean skipEmpty) method); } } else if (CFEqual(protocolType, kSCNetworkProtocolTypeProxies)) { - CFIndex i; static proxyKeys *keys[] = { &proxyKeys_FTP, &proxyKeys_Gopher, &proxyKeys_HTTP, &proxyKeys_HTTPS, &proxyKeys_RTSP, &proxyKeys_SOCKS, &proxyKeys_PAC, &proxyKeys_WPAD }; - for (i = 0; i < sizeof(keys)/sizeof(keys[0]); i++) { + for (size_t i = 0; i < sizeof(keys)/sizeof(keys[0]); i++) { proxyKeys *currentProxy = keys[i]; if (!__proxy_enabled(configuration, currentProxy->keyEnable)) { diff --git a/scutil.tproj/net_protocol.h b/scutil.tproj/net_protocol.h index 976cf11..feeebae 100644 --- a/scutil.tproj/net_protocol.h +++ b/scutil.tproj/net_protocol.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2004, 2011 Apple Computer, Inc. All rights reserved. + * Copyright (c) 2004, 2011, 2017 Apple Computer, Inc. All rights reserved. * * @APPLE_LICENSE_HEADER_START@ * @@ -35,8 +35,6 @@ __BEGIN_DECLS -CFComparisonResult _compare_protocols (const void *val1, const void *val2, void *context); - CF_RETURNS_RETAINED CFStringRef _protocol_description (SCNetworkProtocolRef protocol, Boolean skipEmpty); diff --git a/scutil.tproj/net_service.c b/scutil.tproj/net_service.c index b17fa45..bc20cdd 100644 --- a/scutil.tproj/net_service.c +++ b/scutil.tproj/net_service.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2004-2010, 2013, 2014, 2016 Apple Inc. All rights reserved. + * Copyright (c) 2004-2010, 2013, 2014, 2016, 2017 Apple Inc. All rights reserved. * * @APPLE_LICENSE_HEADER_START@ * @@ -490,6 +490,7 @@ __private_extern__ void select_service(int argc, char **argv) { +#pragma unused(argc) SCNetworkInterfaceRef interface; SCNetworkServiceRef service; CFStringRef serviceName; @@ -789,7 +790,7 @@ __show_service_protocols(SCNetworkServiceRef service, const char *prefix, Boolea sorted = CFArrayCreateMutableCopy(NULL, 0, protocols); CFArraySortValues(sorted, CFRangeMake(0, n), - _compare_protocols, + _SCNetworkProtocolCompare, NULL); CFRelease(protocols); protocols = sorted; @@ -858,16 +859,16 @@ show_service(int argc, char **argv) // nothing to report break; case kSCNetworkServicePrimaryRankFirst : - SCPrint(TRUE, stdout, CFSTR("primary rank = FIRST\n")); + SCPrint(TRUE, stdout, CFSTR("primary rank = %@\n"), kSCValNetServicePrimaryRankFirst); break; case kSCNetworkServicePrimaryRankLast : - SCPrint(TRUE, stdout, CFSTR("primary rank = LAST\n")); + SCPrint(TRUE, stdout, CFSTR("primary rank = %@\n"), kSCValNetServicePrimaryRankLast); break; case kSCNetworkServicePrimaryRankNever : - SCPrint(TRUE, stdout, CFSTR("primary rank = NEVER\n")); + SCPrint(TRUE, stdout, CFSTR("primary rank = %@\n"), kSCValNetServicePrimaryRankNever); break; case kSCNetworkServicePrimaryRankScoped : - SCPrint(TRUE, stdout, CFSTR("primary rank = SCOPED\n")); + SCPrint(TRUE, stdout, CFSTR("primary rank = %@\n"), kSCValNetServicePrimaryRankScoped); break; default : SCPrint(TRUE, stdout, CFSTR("primary rank = %d\n"), serviceRank); @@ -903,7 +904,7 @@ show_service(int argc, char **argv) sorted = CFArrayCreateMutableCopy(NULL, 0, protocols); CFArraySortValues(sorted, CFRangeMake(0, n), - _compare_protocols, + _SCNetworkProtocolCompare, NULL); CFRelease(protocols); protocols = sorted; @@ -943,6 +944,7 @@ __private_extern__ void show_services(int argc, char **argv) { +#pragma unused(argv) CFIndex i; CFIndex n; diff --git a/scutil.tproj/net_set.c b/scutil.tproj/net_set.c index 8028abd..c51516c 100644 --- a/scutil.tproj/net_set.c +++ b/scutil.tproj/net_set.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2004, 2005, 2009-2011, 2013-2015 Apple Inc. All rights reserved. + * Copyright (c) 2004, 2005, 2009-2011, 2013-2015, 2017 Apple Inc. All rights reserved. * * @APPLE_LICENSE_HEADER_START@ * @@ -39,37 +39,6 @@ /* -------------------- */ -static CFComparisonResult -_compare_sets(const void *val1, const void *val2, void *context) -{ - CFStringRef id1; - CFStringRef id2; - CFStringRef name1; - CFStringRef name2; - SCNetworkSetRef s1 = (SCNetworkSetRef)val1; - SCNetworkSetRef s2 = (SCNetworkSetRef)val2; - - name1 = SCNetworkSetGetName(s1); - name2 = SCNetworkSetGetName(s2); - - if (name1 != NULL) { - if (name2 != NULL) { - return CFStringCompare(name1, name2, 0); - } else { - return kCFCompareLessThan; - } - } - - if (name2 != NULL) { - return kCFCompareGreaterThan; - } - - id1 = SCNetworkSetGetSetID(s1); - id2 = SCNetworkSetGetSetID(s2); - return CFStringCompare(id1, id2, 0); -} - - static CFArrayRef _copy_sets() { @@ -85,7 +54,7 @@ _copy_sets() sorted = CFArrayCreateMutableCopy(NULL, 0, sets); CFArraySortValues(sorted, CFRangeMake(0, CFArrayGetCount(sorted)), - _compare_sets, + _SCNetworkSetCompare, NULL); CFRelease(sets); @@ -372,6 +341,7 @@ __private_extern__ void select_set(int argc, char **argv) { +#pragma unused(argc) SCNetworkSetRef set; CFStringRef setName; @@ -649,7 +619,7 @@ show_set(int argc, char **argv) n = CFArrayGetCount(interfaces); for (i = 0; i < n; i++) { interface = CFArrayGetValueAtIndex(interfaces, i); - SCPrint(TRUE, stdout, CFSTR(" %2ld: %@ \n"), + SCPrint(TRUE, stdout, CFSTR(" %2ld: %@\n"), i + 1, SCNetworkInterfaceGetLocalizedDisplayName(interface)); } @@ -669,6 +639,8 @@ __private_extern__ void show_sets(int argc, char **argv) { +#pragma unused(argc) +#pragma unused(argv) SCNetworkSetRef current; CFIndex i; CFIndex n; diff --git a/scutil.tproj/notifications.c b/scutil.tproj/notifications.c index dbf6a09..2f19a45 100644 --- a/scutil.tproj/notifications.c +++ b/scutil.tproj/notifications.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2000-2005, 2008-2015 Apple Inc. All rights reserved. + * Copyright (c) 2000-2005, 2008-2015, 2017 Apple Inc. All rights reserved. * * @APPLE_LICENSE_HEADER_START@ * @@ -49,7 +49,7 @@ static struct sigaction *oact = NULL; static char * elapsed() { - int n; + size_t n; static char str[128]; struct tm tm_diff; struct tm tm_now; @@ -80,7 +80,9 @@ elapsed() static CFComparisonResult -sort_keys(const void *p1, const void *p2, void *context) { +sort_keys(const void *p1, const void *p2, void *context) +{ +#pragma unused(context) CFStringRef key1 = (CFStringRef)p1; CFStringRef key2 = (CFStringRef)p2; return CFStringCompare(key1, key2, 0); @@ -91,6 +93,7 @@ __private_extern__ void storeCallback(SCDynamicStoreRef store, CFArrayRef changedKeys, void *info) { +#pragma unused(info) int i; CFIndex n; @@ -118,6 +121,7 @@ __private_extern__ void do_notify_list(int argc, char **argv) { +#pragma unused(argv) int i; CFArrayRef list; CFIndex listCnt; @@ -247,6 +251,8 @@ __private_extern__ void do_notify_changes(int argc, char **argv) { +#pragma unused(argc) +#pragma unused(argv) CFArrayRef list; CFIndex listCnt; int i; @@ -279,6 +285,7 @@ do_notify_changes(int argc, char **argv) static void * _watcher(void *arg) { +#pragma unused(arg) notifyRl = CFRunLoopGetCurrent(); if (notifyRl == NULL) { SCPrint(TRUE, stdout, CFSTR(" CFRunLoopGetCurrent() failed\n")); @@ -312,6 +319,8 @@ __private_extern__ void do_notify_watch(int argc, char **argv) { +#pragma unused(argc) +#pragma unused(argv) pthread_attr_t tattr; pthread_t tid; @@ -335,6 +344,8 @@ __private_extern__ void do_notify_wait(int argc, char **argv) { +#pragma unused(argc) +#pragma unused(argv) if (!SCDynamicStoreNotifyWait(store)) { SCPrint(TRUE, stdout, CFSTR(" %s\n"), SCErrorString(SCError())); return; @@ -489,6 +500,8 @@ __private_extern__ void do_notify_cancel(int argc, char **argv) { +#pragma unused(argc) +#pragma unused(argv) if (notifyRls != NULL) { if (doDispatch) { if (!SCDynamicStoreSetDispatchQueue(store, NULL)) { diff --git a/scutil.tproj/prefs.c b/scutil.tproj/prefs.c index e2ab8b2..17b5578 100644 --- a/scutil.tproj/prefs.c +++ b/scutil.tproj/prefs.c @@ -146,6 +146,9 @@ __private_extern__ Boolean _prefs_open(CFStringRef name, CFStringRef prefsID) { +#if TARGET_OS_EMBEDDED + char *env = NULL; +#endif // TARGET_OS_EMBEDDED CFMutableDictionaryRef options = NULL; Boolean useHelper = FALSE; Boolean useOptions = FALSE; @@ -164,18 +167,34 @@ _prefs_open(CFStringRef name, CFStringRef prefsID) } if (getenv("SCPREFERENCES_REMOVE_WHEN_EMPTY") != NULL) { - // if we have options - useOptions = TRUE; - if (options == NULL) { options = CFDictionaryCreateMutable(NULL, 0, &kCFTypeDictionaryKeyCallBacks, &kCFTypeDictionaryValueCallBacks); + useOptions = TRUE; } CFDictionarySetValue(options, kSCPreferencesOptionRemoveWhenEmpty, kCFBooleanTrue); } +#if TARGET_OS_EMBEDDED + env = getenv("SCPREFERENCES_PROTECTION_CLASS"); + if (env != NULL) { + CFStringRef str; + + if (options == NULL) { + options = CFDictionaryCreateMutable(NULL, + 0, + &kCFTypeDictionaryKeyCallBacks, + &kCFTypeDictionaryValueCallBacks); + useOptions = TRUE; + } + str = CFStringCreateWithCString(NULL, env, kCFStringEncodingASCII); + CFDictionarySetValue(options, kSCPreferencesOptionProtectionClass, str); + CFRelease(str); + } +#endif // TARGET_OS_EMBEDDED + if (!useHelper && !useOptions) { // if no helper/options needed prefs = SCPreferencesCreate(NULL, name, prefsID); @@ -286,6 +305,8 @@ _prefs_commitRequired(int argc, char **argv, const char *command) static void get_ComputerName(int argc, char **argv) { +#pragma unused(argc) +#pragma unused(argv) CFStringEncoding encoding; CFStringRef hostname; @@ -362,6 +383,8 @@ set_ComputerName(int argc, char **argv) static void get_HostName(int argc, char **argv) { +#pragma unused(argc) +#pragma unused(argv) CFStringRef hostname; Boolean ok; @@ -442,6 +465,8 @@ set_HostName(int argc, char **argv) static void get_LocalHostName(int argc, char **argv) { +#pragma unused(argc) +#pragma unused(argv) CFStringRef hostname; hostname = SCDynamicStoreCopyLocalHostName(NULL); @@ -655,6 +680,7 @@ __private_extern__ void do_prefs_lock(int argc, char **argv) { +#pragma unused(argv) Boolean wait = (argc > 0) ? TRUE : FALSE; if (!SCPreferencesLock(prefs, wait)) { @@ -670,6 +696,8 @@ __private_extern__ void do_prefs_unlock(int argc, char **argv) { +#pragma unused(argc) +#pragma unused(argv) if (!SCPreferencesUnlock(prefs)) { SCPrint(TRUE, stdout, CFSTR("%s\n"), SCErrorString(SCError())); return; @@ -683,6 +711,8 @@ __private_extern__ void do_prefs_commit(int argc, char **argv) { +#pragma unused(argc) +#pragma unused(argv) if (!SCPreferencesCommitChanges(prefs)) { SCPrint(TRUE, stdout, CFSTR("%s\n"), SCErrorString(SCError())); return; @@ -697,6 +727,8 @@ __private_extern__ void do_prefs_apply(int argc, char **argv) { +#pragma unused(argc) +#pragma unused(argv) if (!SCPreferencesApplyChanges(prefs)) { SCPrint(TRUE, stdout, CFSTR("%s\n"), SCErrorString(SCError())); } @@ -737,13 +769,17 @@ __private_extern__ void do_prefs_synchronize(int argc, char **argv) { +#pragma unused(argc) +#pragma unused(argv) SCPreferencesSynchronize(prefs); return; } static CFComparisonResult -sort_paths(const void *p1, const void *p2, void *context) { +sort_paths(const void *p1, const void *p2, void *context) +{ +#pragma unused(context) CFStringRef path1 = (CFStringRef)p1; CFStringRef path2 = (CFStringRef)p2; return CFStringCompare(path1, path2, 0); @@ -822,6 +858,7 @@ __private_extern__ void do_prefs_get(int argc, char **argv) { +#pragma unused(argc) CFDictionaryRef dict; CFStringRef link; CFIndex n; @@ -955,6 +992,7 @@ __private_extern__ void do_prefs_remove(int argc, char **argv) { +#pragma unused(argc) CFStringRef path; path = CFStringCreateWithCString(NULL, argv[0], kCFStringEncodingUTF8); diff --git a/scutil.tproj/scutil.c b/scutil.tproj/scutil.c index dda8ac2..b458640 100644 --- a/scutil.tproj/scutil.c +++ b/scutil.tproj/scutil.c @@ -391,6 +391,7 @@ usage(const char *command) static char * prompt(EditLine *el) { +#pragma unused(el) #if !TARGET_OS_SIMULATOR return "> "; #else // !TARGET_OS_SIMULATOR @@ -431,7 +432,7 @@ main(int argc, char * const argv[]) /* process any arguments */ - while ((opt = getopt_long(argc, argv, "dDvprt:w:W", longopts, &opti)) != -1) + while ((opt = getopt_long(argc, argv, "dDvprt:w:W", longopts, &opti)) != -1) { switch(opt) { case 'd': _sc_debug = TRUE; @@ -518,6 +519,8 @@ main(int argc, char * const argv[]) default : usage(prog); } + } + argc -= optind; argv += optind; @@ -565,11 +568,7 @@ main(int argc, char * const argv[]) } if (doSnap) { - if (!enablePrivateAPI -#if !TARGET_OS_SIMULATOR - || (geteuid() != 0) -#endif // !TARGET_OS_SIMULATOR - ) { + if (!enablePrivateAPI) { usage(prog); } diff --git a/scutil.tproj/session.c b/scutil.tproj/session.c index ed31af1..3655aae 100644 --- a/scutil.tproj/session.c +++ b/scutil.tproj/session.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2000-2004, 2010, 2011 Apple Inc. All rights reserved. + * Copyright (c) 2000-2004, 2010, 2011, 2017 Apple Inc. All rights reserved. * * @APPLE_LICENSE_HEADER_START@ * @@ -40,6 +40,8 @@ static void reconnected(SCDynamicStoreRef store, void *info) { +#pragma unused(store) +#pragma unused(info) SCPrint(TRUE, stdout, CFSTR("SCDynamicStore server restarted, session reconnected\n")); return; } @@ -49,6 +51,7 @@ __private_extern__ void do_open(int argc, char **argv) { +#pragma unused(argv) if (store) { CFRelease(store); CFRelease(watchedKeys); @@ -92,6 +95,8 @@ __private_extern__ void do_close(int argc, char **argv) { +#pragma unused(argc) +#pragma unused(argv) if (notifyRls != NULL) { if (doDispatch) { (void) SCDynamicStoreSetDispatchQueue(store, NULL); diff --git a/scutil.tproj/tests.c b/scutil.tproj/tests.c index b80f9a1..83022d3 100644 --- a/scutil.tproj/tests.c +++ b/scutil.tproj/tests.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2000, 2001, 2003-2016 Apple Inc. All rights reserved. + * Copyright (c) 2000, 2001, 2003-2017 Apple Inc. All rights reserved. * * @APPLE_LICENSE_HEADER_START@ * @@ -52,9 +52,14 @@ #include #include "dnsinfo_internal.h" +#include "dnsinfo_logging.h" + #include +#include "network_state_information_logging.h" #include "network_state_information_priv.h" + #include "SCNetworkReachabilityInternal.h" + #include @@ -425,8 +430,8 @@ static void _printReachability(SCNetworkReachabilityRef target) { SCNetworkReachabilityFlags flags; + char flags_str[100]; Boolean ok; - CFStringRef str; ok = SCNetworkReachabilityGetFlags(target, &flags); if (!ok) { @@ -434,9 +439,10 @@ _printReachability(SCNetworkReachabilityRef target) return; } - str = __SCNetworkReachabilityCopyFlags(flags, CFSTR("flags = "), _sc_debug); - SCPrint(TRUE, stdout, CFSTR("%@\n"), str); - CFRelease(str); + __SCNetworkReachability_flags_string(flags, _sc_debug, flags_str, sizeof(flags_str)); + SCPrint(TRUE, stdout, + _sc_debug ? CFSTR("flags = %s\n") : CFSTR("%s\n"), + flags_str); if (resolver_bypass && _sc_debug) { int if_index; @@ -467,143 +473,29 @@ do_checkReachability(int argc, char **argv) } -static void -_printNWIFlags(nwi_ifstate_flags flags) -{ - flags &= NWI_IFSTATE_FLAGS_MASK; - if (flags == 0) { - return; - } - - SCPrint(TRUE, stdout, CFSTR(" (")); - if (flags & NWI_IFSTATE_FLAGS_HAS_IPV4) { - SCPrint(TRUE, stdout, CFSTR("IPv4")); - flags &= ~NWI_IFSTATE_FLAGS_HAS_IPV4; - SCPrint(flags != 0, stdout, CFSTR(",")); - } - if (flags & NWI_IFSTATE_FLAGS_HAS_IPV6) { - SCPrint(TRUE, stdout, CFSTR("IPv6")); - flags &= ~NWI_IFSTATE_FLAGS_HAS_IPV6; - SCPrint(flags != 0, stdout, CFSTR(",")); - } - if (flags & NWI_IFSTATE_FLAGS_HAS_DNS) { - SCPrint(TRUE, stdout, CFSTR("DNS")); - flags &= ~NWI_IFSTATE_FLAGS_HAS_DNS; - SCPrint(flags != 0, stdout, CFSTR(",")); - } - if (flags & NWI_IFSTATE_FLAGS_NOT_IN_LIST) { - SCPrint(TRUE, stdout, CFSTR("NOT-IN-LIST")); - flags &= ~NWI_IFSTATE_FLAGS_NOT_IN_LIST; - SCPrint(flags != 0, stdout, CFSTR(",")); - } - if (flags & NWI_IFSTATE_FLAGS_HAS_SIGNATURE) { - SCPrint(TRUE, stdout, CFSTR("SIGNATURE")); - flags &= ~NWI_IFSTATE_FLAGS_HAS_SIGNATURE; - SCPrint(flags != 0, stdout, CFSTR(",")); - } - if (flags & NWI_IFSTATE_FLAGS_NOT_IN_IFLIST) { - SCPrint(TRUE, stdout, CFSTR("NOT-IN-IFLIST")); - flags &= ~NWI_IFSTATE_FLAGS_NOT_IN_IFLIST; - SCPrint(flags != 0, stdout, CFSTR(",")); - } - if (flags != 0) { - SCPrint(TRUE, stdout, CFSTR("%p"), (void *)flags); - } - SCPrint(TRUE, stdout, CFSTR(")")); - - return; -} - - -static void -_printNWIInfo(nwi_ifstate_t ifstate) -{ - nwi_ifstate_flags ifstate_flags; - SCNetworkReachabilityFlags reach_flags = nwi_ifstate_get_reachability_flags(ifstate); - const uint8_t *signature; - int signature_length; - CFStringRef str; - const struct sockaddr *vpn_addr = nwi_ifstate_get_vpn_server(ifstate); - - ifstate_flags = nwi_ifstate_get_flags(ifstate); - if (_sc_debug) { - ifstate_flags |= ifstate->flags; - } - - SCPrint(TRUE, stdout, - CFSTR(" %7s : flags %p"), - nwi_ifstate_get_ifname(ifstate), - (void *)ifstate_flags); - _printNWIFlags(ifstate_flags); - - str = __SCNetworkReachabilityCopyFlags(reach_flags, CFSTR(" reach "), TRUE); - SCPrint(TRUE, stdout, CFSTR("\n%@"), str); - CFRelease(str); - - if (vpn_addr != NULL) { - char vpn_ntopbuf[INET6_ADDRSTRLEN]; - - _SC_sockaddr_to_string(vpn_addr, vpn_ntopbuf, sizeof(vpn_ntopbuf)); - SCPrint(TRUE, stdout, CFSTR("\n VPN server: %s"), vpn_ntopbuf); - } - - signature = nwi_ifstate_get_signature(ifstate, AF_UNSPEC, &signature_length); - if (signature != NULL) { - CFDataRef digest = NULL; - - digest = CFDataCreate(NULL, signature, CC_SHA1_DIGEST_LENGTH); - SCPrint(TRUE, stdout, CFSTR("\n Signature Hash: %@"), digest); - CFRelease(digest); - } else { - SCPrint(TRUE, stdout, CFSTR("\n Signature Hash: ")); - } - - SCPrint(TRUE, stdout, CFSTR("\n generation %llu\n"), - nwi_ifstate_get_generation(ifstate)); - - return; -} - - -static void -_printNWIReachInfo(nwi_state_t state, int af) -{ - uint32_t reach_flags; - CFStringRef str; - - reach_flags = nwi_state_get_reachability_flags(state, af); - - str = __SCNetworkReachabilityCopyFlags(reach_flags, CFSTR(" REACH : flags "), TRUE); - SCPrint(TRUE, stdout, CFSTR("\n%@\n"), str); - CFRelease(str); - - return; -} - - static void do_printNWI(int argc, char **argv, nwi_state_t state) { - unsigned int count; - nwi_ifstate_t ifstate; - if (state == NULL) { SCPrint(TRUE, stdout, CFSTR("No network information\n")); return; } if (argc > 0) { + nwi_ifstate_t ifstate; + ifstate = nwi_state_get_ifstate(state, argv[0]); if (ifstate != NULL) { nwi_ifstate_t alias; + int alias_af; - _printNWIInfo(ifstate); + _nwi_ifstate_log(ifstate, _sc_debug, NULL); - alias = nwi_ifstate_get_alias(ifstate, - ifstate->af == AF_INET ? AF_INET6 : AF_INET); + alias_af = (ifstate->af == AF_INET) ? AF_INET6 : AF_INET; + alias = nwi_ifstate_get_alias(ifstate, alias_af); if (alias != NULL) { SCPrint(TRUE, stdout, CFSTR("\n")); - _printNWIInfo(alias); + _nwi_ifstate_log(alias, _sc_debug, NULL); } } else { SCPrint(TRUE, stdout, CFSTR("No network information (for %s)\n"), argv[0]); @@ -611,50 +503,7 @@ do_printNWI(int argc, char **argv, nwi_state_t state) return; } - SCPrint(TRUE, stdout, CFSTR("Network information (generation %llu)"), - nwi_state_get_generation(state)); - - SCPrint(TRUE, stdout, CFSTR("\nIPv4 network interface information\n")); - - ifstate = nwi_state_get_first_ifstate(state, AF_INET); - if (ifstate == NULL) { - SCPrint(TRUE, stdout, CFSTR(" No IPv4 states found\n")); - } else { - while (ifstate != NULL) { - _printNWIInfo(ifstate); - ifstate = nwi_ifstate_get_next(ifstate, AF_INET); - } - } - _printNWIReachInfo(state, AF_INET); - - SCPrint(TRUE, stdout, CFSTR("\nIPv6 network interface information\n")); - - ifstate = nwi_state_get_first_ifstate(state, AF_INET6); - if (ifstate == NULL) { - SCPrint(TRUE, stdout, CFSTR(" No IPv6 states found\n")); - } else { - while (ifstate != NULL) { - _printNWIInfo(ifstate); - ifstate = nwi_ifstate_get_next(ifstate, AF_INET6); - } - } - _printNWIReachInfo(state, AF_INET6); - - count = nwi_state_get_interface_names(state, NULL, 0); - if (count > 0) { - const char * names[count]; - - count = nwi_state_get_interface_names(state, names, count); - if (count > 0) { - int i; - - printf("\nNetwork interfaces:"); - for (i = 0; i < count; i++) { - printf(" %s", names[i]); - } - printf("\n"); - } - } + _nwi_state_log(state, _sc_debug, NULL); return; } @@ -695,6 +544,7 @@ do_watchNWI(int argc, char **argv) &token, dispatch_get_main_queue(), ^(int token){ +#pragma unused(token) nwi_state_t state; struct tm tm_now; struct timeval tv_now; @@ -822,6 +672,8 @@ do_watchReachability(int argc, char **argv) static void do_printDNSConfiguration(int argc, char **argv, dns_config_t *dns_config) { +#pragma unused(argc) +#pragma unused(argv) int _sc_log_save; if (dns_config == NULL) { @@ -831,7 +683,7 @@ do_printDNSConfiguration(int argc, char **argv, dns_config_t *dns_config) _sc_log_save = _sc_log; _sc_log = FALSE; - _dns_configuration_log(dns_config, _sc_debug); + _dns_configuration_log(dns_config, _sc_debug, NULL); _sc_log = _sc_log_save; if (_sc_debug) { @@ -878,6 +730,7 @@ do_watchDNSConfiguration(int argc, char **argv) &token, dispatch_get_main_queue(), ^(int token){ +#pragma unused(token) dns_config_t *dns_config; struct tm tm_now; struct timeval tv_now; @@ -1034,8 +887,51 @@ __private_extern__ void do_snapshot(int argc, char **argv) { - if (!SCDynamicStoreSnapshot(store)) { - SCPrint(TRUE, stdout, CFSTR(" %s\n"), SCErrorString(SCError())); +#pragma unused(argc) +#pragma unused(argv) + if (argc == 1) { + CFDictionaryRef dict; + int fd; + CFMutableArrayRef patterns; + + fd = open(argv[0], O_WRONLY|O_CREAT|O_TRUNC|O_EXCL, 0644); + if (fd == -1) { + SCPrint(TRUE, stdout, CFSTR("open() failed: %s\n"), strerror(errno)); + return; + } + + patterns = CFArrayCreateMutable(NULL, 0, &kCFTypeArrayCallBacks); + CFArrayAppendValue(patterns, CFSTR(".*")); + dict = SCDynamicStoreCopyMultiple(store, NULL, patterns); + CFRelease(patterns); + if (dict != NULL) { + CFDataRef xmlData; + + xmlData = CFPropertyListCreateData(NULL, dict, kCFPropertyListXMLFormat_v1_0, 0, NULL); + CFRelease(dict); + if (xmlData != NULL) { + (void) write(fd, CFDataGetBytePtr(xmlData), CFDataGetLength(xmlData)); + CFRelease(xmlData); + } else { + SC_log(LOG_NOTICE, "CFPropertyListCreateData() failed"); + } + } else { + if (SCError() == kSCStatusOK) { + SCPrint(TRUE, stdout, CFSTR("No SCDynamicStore content\n")); + } else { + SCPrint(TRUE, stdout, CFSTR("%s\n"), SCErrorString(SCError())); + } + } + (void) close(fd); + } else { +#if !TARGET_OS_SIMULATOR + if (geteuid() != 0) { + SCPrint(TRUE, stdout, CFSTR("Need to be \"root\" to capture snapshot\n")); + } else +#endif // !TARGET_OS_SIMULATOR + if (!SCDynamicStoreSnapshot(store)) { + SCPrint(TRUE, stdout, CFSTR("%s\n"), SCErrorString(SCError())); + } } return; @@ -1163,6 +1059,7 @@ waitKeyFound() static void waitTimeout(int sigraised) { +#pragma unused(sigraised) exit(1); } diff --git a/update-sanitizer-dylib-references b/update-sanitizer-dylib-references new file mode 100755 index 0000000..da32ed4 --- /dev/null +++ b/update-sanitizer-dylib-references @@ -0,0 +1,108 @@ +#!/bin/sh + +# +# fix address-sanitizer library @rpath references +# + +xsan_setup() { + XSAN_DIR="/usr/local/lib/sanitizers" + case "${PLATFORM_NAME}" in + macosx ) + ASAN_DYLIB="clang_rt.asan_osx_dynamic.dylib" + TSAN_DYLIB="clang_rt.tsan_osx_dynamic.dylib" + ;; + iphoneos ) + ASAN_DYLIB="clang_rt.asan_ios_dynamic.dylib" + TSAN_DYLIB="clang_rt.tsan_ios_dynamic.dylib" + ;; + iphonesimulator ) + ASAN_DYLIB="clang_rt.asan_iossim_dynamic.dylib" + TSAN_DYLIB="clang_rt.tsan_iossim_dynamic.dylib" + ;; + tvos ) + ASAN_DYLIB="clang_rt.asan_tvos_dynamic.dylib" + TSAN_DYLIB="clang_rt.tsan_tvos_dynamic.dylib" + ;; + tvsosimulator ) + ASAN_DYLIB="clang_rt.asan_tvossim_dynamic.dylib" + TSAN_DYLIB="clang_rt.tsan_tvossim_dynamic.dylib" + ;; + watchos ) + ASAN_DYLIB="clang_rt.asan_watchos_dynamic.dylib" + TSAN_DYLIB="clang_rt.tsan_watchos_dynamic.dylib" + ;; + watchsimulator ) + ASAN_DYLIB="clang_rt.asan_watchossim_dynamic.dylib" + TSAN_DYLIB="clang_rt.tsan_watchossim_dynamic.dylib" + ;; + * ) + ASAN_DYLIB="clang_rt.asan_$(RC_PROJECT_COMPILATION_PLATFORM)_dynamic.dylib" + TSAN_DYLIB="clang_rt.tsan_$(RC_PROJECT_COMPILATION_PLATFORM)_dynamic.dylib" + ;; + esac +} + +xsan_setup=0 +for VARIANT in ${BUILD_VARIANTS} +do + case "${VARIANT}" in + "asan" ) + # + # change address sanitizer @rpath reference + # + ASAN_FILE="${DSTROOT}${INSTALL_PATH}/" + if [ -n "${EXECUTABLE_FOLDER_PATH}" ]; then + ASAN_FILE+="${EXECUTABLE_FOLDER_PATH}/" + fi + ASAN_FILE+="${EXECUTABLE_PREFIX}${PRODUCT_NAME}_asan${EXECUTABLE_SUFFIX}" + + if [ -x "${ASAN_FILE}" ]; then + if [ ${xsan_setup} -eq 0 ]; then + xsan_setup + xsan_setup=1 + fi + + install_name_tool \ + -change \ + "@rpath/lib${ASAN_DYLIB}" \ + "${XSAN_DIR}/lib${ASAN_DYLIB}" \ + "${ASAN_FILE}" + if [ $? -ne 0 ]; then + echo "install_name_tool failed" + printenv | sort + exit 1 + fi + fi + ;; + "tsan" ) + # + # change thread sanitizer @rpath reference + # + TSAN_FILE="${DSTROOT}${INSTALL_PATH}/" + if [ -n "${EXECUTABLE_FOLDER_PATH}" ]; then + TSAN_FILE+="${EXECUTABLE_FOLDER_PATH}/" + fi + TSAN_FILE+="${EXECUTABLE_PREFIX}${PRODUCT_NAME}_tsan${EXECUTABLE_SUFFIX}" + + if [ -x "${TSAN_FILE}" ]; then + if [ ${xsan_setup} -eq 0 ]; then + xsan_setup + xsan_setup=1 + fi + + install_name_tool \ + -change \ + "@rpath/lib${TSAN_DYLIB}" \ + "${XSAN_DIR}/lib${TSAN_DYLIB}" \ + "${TSAN_FILE}" + if [ $? -ne 0 ]; then + echo "install_name_tool failed" + printenv | sort + exit 1 + fi + fi + ;; + * ) + ;; + esac +done -- 2.47.2