From 59647b27048e1ce6e0c139a16100fd587f4e826e Mon Sep 17 00:00:00 2001 From: Apple Date: Wed, 29 Jul 2020 22:11:14 +0000 Subject: [PATCH] configd-1061.141.1.tar.gz --- Plugins/IPMonitor/dns-configuration.c | 9 +- Plugins/IPMonitor/ip_plugin.c | 10 +- Plugins/IPMonitor/proxy-configuration.c | 4 +- Plugins/IPMonitor/set-hostname.c | 6 +- Plugins/IPMonitor/smb-configuration.c | 4 +- Plugins/InterfaceNamer/ifnamer.c | 156 +++- Plugins/KernelEventMonitor/eventmon.c | 4 +- Plugins/LinkConfiguration/linkconfig.c | 4 +- Plugins/PreferencesMonitor/prefsmon.c | 2 +- Plugins/QoSMarking/qos-marking.m | 2 +- Plugins/SimulatorSupport/simulator_support.c | 4 +- SCMonitor/monitor.c | 2 +- SCTest-ObjC/test-objC.m | 51 +- SystemConfiguration.fproj/BondConfiguration.c | 4 +- .../BridgeConfiguration.c | 8 +- SystemConfiguration.fproj/SCD.c | 168 +++- .../SCNetworkConfigurationInternal.c | 2 + .../SCNetworkConfigurationInternal.h | 6 +- .../SCNetworkConfigurationPrivate.c | 157 ++-- .../SCNetworkInterface.c | 8 +- .../SCNetworkMigration.c | 769 +++++++++++------- .../SCNetworkReachability.c | 2 +- SystemConfiguration.fproj/SCNetworkService.c | 2 +- SystemConfiguration.fproj/SCNetworkSet.c | 1 + SystemConfiguration.fproj/SCP.c | 33 +- SystemConfiguration.fproj/SCPCommit.c | 2 +- SystemConfiguration.fproj/SCPOpen.c | 19 +- .../SCPreferencesInternal.h | 6 +- SystemConfiguration.fproj/SCPrivate.h | 103 ++- .../SystemConfigurationInternal.h | 10 +- SystemConfiguration.fproj/VLANConfiguration.c | 6 +- SystemConfiguration.fproj/dy_framework.c | 5 +- configd.tproj/configd.m | 21 +- configd.xcodeproj/project.pbxproj | 351 ++++---- dnsinfo/dnsinfo_server.c | 6 +- get-network-info | 16 +- nwi/network_information_server.c | 4 +- scselect.tproj/scselect.c | 4 +- sctest/main.m | 4 +- scutil.tproj/scutil.c | 4 +- scutil.tproj/scutil.h | 1 - scutil.tproj/tests.c | 4 +- 42 files changed, 1294 insertions(+), 690 deletions(-) diff --git a/Plugins/IPMonitor/dns-configuration.c b/Plugins/IPMonitor/dns-configuration.c index 3d0121f..cb61799 100644 --- a/Plugins/IPMonitor/dns-configuration.c +++ b/Plugins/IPMonitor/dns-configuration.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2004-2019 Apple Inc. All rights reserved. + * Copyright (c) 2004-2020 Apple Inc. All rights reserved. * * @APPLE_LICENSE_HEADER_START@ * @@ -42,7 +42,7 @@ #include #include #include -extern uint32_t notify_monitor_file(int token, const char *name, int flags); +#include #include #include @@ -1841,7 +1841,10 @@ dns_configuration_monitor(SCDynamicStoreRef store, SCDynamicStoreCallBack callou return; } +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wdeprecated" status = notify_monitor_file(notify_token, resolver_directory_path, 0); +#pragma GCC diagnostic pop if (status != NOTIFY_STATUS_OK) { my_log(LOG_ERR, "notify_monitor_file() failed"); (void)notify_cancel(notify_token); @@ -1997,7 +2000,7 @@ main(int argc, char **argv) SCDynamicStoreRef store; _sc_debug = TRUE; - _sc_log = FALSE; + _sc_log = kSCLogDestinationFile; _sc_verbose = (argc > 1) ? TRUE : FALSE; store = SCDynamicStoreCreate(NULL, CFSTR("TEST"), NULL, NULL); diff --git a/Plugins/IPMonitor/ip_plugin.c b/Plugins/IPMonitor/ip_plugin.c index b31b6e6..f770c0e 100644 --- a/Plugins/IPMonitor/ip_plugin.c +++ b/Plugins/IPMonitor/ip_plugin.c @@ -86,7 +86,7 @@ #include #include #include -#include +#include #include #include #include @@ -9176,7 +9176,7 @@ load_IPMonitor(CFBundleRef bundle, Boolean bundleVerbose) int main(int argc, char **argv) { - _sc_log = FALSE; + _sc_log = kSCLogDestinationFile; S_IPMonitor_debug = kDebugFlag1; if (argc > 1) { @@ -9980,7 +9980,7 @@ main(int argc, char **argv) { IPv4RouteTestRef * test; - _sc_log = FALSE; + _sc_log = kSCLogDestinationFile; _sc_verbose = (argc > 1) ? TRUE : FALSE; S_IPMonitor_debug = kDebugFlag1 | kDebugFlag2 | kDebugFlag4; if (argc > 1) { @@ -10645,7 +10645,7 @@ main(int argc, char **argv) { IPv6RouteTestRef * test; - _sc_log = FALSE; + _sc_log = kSCLogDestinationFile; _sc_verbose = (argc > 1) ? TRUE : FALSE; S_IPMonitor_debug = kDebugFlag1 | kDebugFlag2 | kDebugFlag4; if (argc > 1) { @@ -10902,7 +10902,7 @@ apply_test(DNSOrderTestRef test) int main(int argc, char **argv) { - _sc_log = FALSE; + _sc_log = kSCLogDestinationFile; _sc_verbose = (argc > 1) ? TRUE : FALSE; S_IPMonitor_debug = kDebugFlag1 | kDebugFlag2 | kDebugFlag4; if (argc > 1) { diff --git a/Plugins/IPMonitor/proxy-configuration.c b/Plugins/IPMonitor/proxy-configuration.c index 9116f42..628ff25 100644 --- a/Plugins/IPMonitor/proxy-configuration.c +++ b/Plugins/IPMonitor/proxy-configuration.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2011-2017 Apple Inc. All rights reserved. + * Copyright (c) 2011-2017, 2020 Apple Inc. All rights reserved. * * @APPLE_LICENSE_HEADER_START@ * @@ -893,7 +893,7 @@ main(int argc, char **argv) CFDictionaryRef state_global_ipv4; SCDynamicStoreRef store; - _sc_log = FALSE; + _sc_log = kSCLogDestinationFile; _sc_verbose = (argc > 1) ? TRUE : FALSE; store = SCDynamicStoreCreate(NULL, CFSTR("TEST"), NULL, NULL); diff --git a/Plugins/IPMonitor/set-hostname.c b/Plugins/IPMonitor/set-hostname.c index b97697e..5489ce7 100644 --- a/Plugins/IPMonitor/set-hostname.c +++ b/Plugins/IPMonitor/set-hostname.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2004-2018 Apple Inc. All rights reserved. + * Copyright (c) 2004-2018, 2020 Apple Inc. All rights reserved. * * @APPLE_LICENSE_HEADER_START@ * @@ -664,7 +664,7 @@ main(int argc, char **argv) #ifdef DEBUG - _sc_log = FALSE; + _sc_log = kSCLogDestinationFile; if ((argc > 1) && (strcmp(argv[1], "-d") == 0)) { _sc_verbose = TRUE; argv++; @@ -746,7 +746,7 @@ main(int argc, char **argv) #else /* DEBUG */ - _sc_log = FALSE; + _sc_log = kSCLogDestinationFile; _sc_verbose = (argc > 1) ? TRUE : FALSE; load_hostname((argc > 1) ? TRUE : FALSE); diff --git a/Plugins/IPMonitor/smb-configuration.c b/Plugins/IPMonitor/smb-configuration.c index 2bb434a..fa51672 100644 --- a/Plugins/IPMonitor/smb-configuration.c +++ b/Plugins/IPMonitor/smb-configuration.c @@ -888,7 +888,7 @@ main(int argc, char **argv) CFStringRef serviceID; SCDynamicStoreRef store; - _sc_log = FALSE; + _sc_log = kSCLogDestinationFile; if ((argc > 1) && (strcmp(argv[1], "-d") == 0)) { _sc_verbose = TRUE; argv++; @@ -952,7 +952,7 @@ main(int argc, char **argv) #else /* DEBUG */ - _sc_log = FALSE; + _sc_log = kSCLogDestinationFile; _sc_verbose = (argc > 1) ? TRUE : FALSE; load_smb_configuration((argc > 1) ? TRUE : FALSE); diff --git a/Plugins/InterfaceNamer/ifnamer.c b/Plugins/InterfaceNamer/ifnamer.c index 13db1ec..2e5a074 100644 --- a/Plugins/InterfaceNamer/ifnamer.c +++ b/Plugins/InterfaceNamer/ifnamer.c @@ -1644,6 +1644,117 @@ builtinCount(CFArrayRef if_list, CFIndex last, CFNumberRef if_type) } +#pragma mark - +#pragma mark Internet Sharing configuration support + + +#if TARGET_OS_OSX + +static SCPreferencesRef nat_configuration = NULL; // com.apple.nat.plist +static SCPreferencesRef nat_preferences = NULL; // preferences.plist + + +static void +sharingConfigurationClose(void) +{ + if (nat_configuration != NULL) { + CFRelease(nat_configuration); + nat_configuration = NULL; + } + + if (nat_preferences != NULL) { + CFRelease(nat_preferences); + nat_preferences = NULL; + } + + return; +} + + +static Boolean +sharingConfigurationUsesInterface(CFStringRef bsdName, Boolean keepOpen) +{ + CFDictionaryRef config; + Boolean isShared = FALSE; + + if (nat_configuration == NULL) { + nat_configuration = SCPreferencesCreate(NULL, CFSTR(MY_PLUGIN_NAME ":sharingConfigurationUsesInterface"), CFSTR("com.apple.nat.plist")); + if (nat_configuration == NULL) { + return FALSE; + } + } + + config = SCPreferencesGetValue(nat_configuration, CFSTR("NAT")); + if (isA_CFDictionary(config)) { + CFBooleanRef bVal = NULL; + Boolean enabled = FALSE; + CFStringRef sharedFromServiceID = NULL; + CFArrayRef sharedToInterfaces = NULL; + + if (CFDictionaryGetValueIfPresent(config, + CFSTR("Enabled"), + (const void **)&bVal) && + isA_CFBoolean(bVal)) { + enabled = CFBooleanGetValue(bVal); + } + + if (enabled && + CFDictionaryGetValueIfPresent(config, + CFSTR("SharingDevices"), + (const void **)&sharedToInterfaces) && + isA_CFArray(sharedToInterfaces)) { + CFIndex n; + + // if "To computers using" interfaces configured + n = CFArrayGetCount(sharedToInterfaces); + for (CFIndex i = 0; i < n; i++) { + CFStringRef sharedToInterface_bsdName; + + sharedToInterface_bsdName = CFArrayGetValueAtIndex(sharedToInterfaces, i); + if (_SC_CFEqual(bsdName, sharedToInterface_bsdName)) { + isShared = TRUE; + break; + } + } + } + + if (enabled && + !isShared && + CFDictionaryGetValueIfPresent(config, + CFSTR("PrimaryService"), + (const void **)&sharedFromServiceID) && + isA_CFString(sharedFromServiceID)) { + if (nat_preferences == NULL) { + nat_preferences = SCPreferencesCreateCompanion(nat_configuration, NULL); + } + if (nat_preferences != NULL) { + SCNetworkServiceRef sharedFromService; + + // if "Share your connection from" service configured + sharedFromService = SCNetworkServiceCopy(nat_preferences, sharedFromServiceID); + if (sharedFromService != NULL) { + CFStringRef sharedFromService_bsdName; + SCNetworkInterfaceRef sharedFromService_interface; + + sharedFromService_interface = SCNetworkServiceGetInterface(sharedFromService); + sharedFromService_bsdName = SCNetworkInterfaceGetBSDName(sharedFromService_interface); + isShared = _SC_CFEqual(bsdName, sharedFromService_bsdName); + CFRelease(sharedFromService); + } + } + } + } + + if (!keepOpen) { + sharingConfigurationClose(); + } + + return isShared; +} + +#endif // TARGET_OS_OSX + + #pragma mark - #pragma mark Interface monitoring (e.g. watch for "detach") @@ -1673,26 +1784,41 @@ updateWatchedInterface(void *refCon, io_service_t service, natural_t messageType #pragma unused(messageArgument) switch (messageType) { case kIOMessageServiceIsTerminated : { // if [watched] interface yanked - SCNetworkInterfaceRef remove = NULL; + SCNetworkInterfaceRef remove; CFDataRef watched = (CFDataRef)refCon; WatchedInfo *watchedInfo = (WatchedInfo *)(void *)CFDataGetBytePtr(watched); remove = watchedInfo->interface; - if (!_SCNetworkInterfaceIsBuiltin(remove) && - _SCNetworkInterfaceIsApplePreconfigured(remove)) { - // if not built-in *and* pre-configured, retain for cleanup - CFRetain(remove); - } else { + if (_SCNetworkInterfaceIsBuiltin(remove)) { + // if built-in, keep + remove = NULL; + } else if (!_SCNetworkInterfaceIsApplePreconfigured(remove)) { + // if not pre-configured, keep remove = NULL; + } else { + // if not built-in *and* pre-configured + CFRetain(remove); } +#if TARGET_OS_OSX + if (remove != NULL) { + CFStringRef bsdName; + + bsdName = SCNetworkInterfaceGetBSDName(remove); + if ((bsdName != NULL) && sharingConfigurationUsesInterface(bsdName, FALSE)) { + // if referenced in the Internet Sharing configuration, keep + CFRelease(remove); + remove = NULL; + } + } +#endif // TARGET_OS_OSX + CFRetain(watched); watchedInfo->callback(watched, messageType, messageArgument); watcherRelease(watched); CFRelease(watched); if (remove != NULL) { - // if interface is not built-in *and* pre-configured SC_log(LOG_INFO, "Interface released unit %@ (from database)", _SCNetworkInterfaceGetIOInterfaceUnit(remove)); removeInterface(S_dblist, remove, NULL); @@ -3129,6 +3255,14 @@ removeInactiveInterfaces(void) CFNumberGetValue(vidNum, kCFNumberIntType, &vid) && (vid == kIOUSBAppleVendorID)) { // if [hidden] Apple interface + +#if TARGET_OS_OSX + if (sharingConfigurationUsesInterface(name, TRUE)) { + // do not remove interfaces referenced in the sharing configuration + continue; + } +#endif // TARGET_OS_OSX + goto remove; } } @@ -3147,6 +3281,10 @@ removeInactiveInterfaces(void) } } +#if TARGET_OS_OSX + sharingConfigurationClose(); +#endif // TARGET_OS_OSX + return; } @@ -3858,7 +3996,7 @@ main(int argc, char ** argv) CFArrayRef interfaces_all; CFIndex n; - _sc_log = FALSE; + _sc_log = kSCLogDestinationFile; _sc_verbose = (argc > 1) ? TRUE : FALSE; bundle = CFBundleGetMainBundle(); @@ -3908,7 +4046,7 @@ main(int argc, char ** argv) int main(int argc, char ** argv) { - _sc_log = FALSE; + _sc_log = kSCLogDestinationFile; _sc_verbose = (argc > 1) ? TRUE : FALSE; captureBusy(); diff --git a/Plugins/KernelEventMonitor/eventmon.c b/Plugins/KernelEventMonitor/eventmon.c index 9e0a245..38e1556 100644 --- a/Plugins/KernelEventMonitor/eventmon.c +++ b/Plugins/KernelEventMonitor/eventmon.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2000-2019 Apple Inc. All rights reserved. + * Copyright (c) 2000-2020 Apple Inc. All rights reserved. * * @APPLE_LICENSE_HEADER_START@ * @@ -915,7 +915,7 @@ load_KernelEventMonitor(CFBundleRef bundle, Boolean bundleVerbose) int main(int argc, char **argv) { - _sc_log = FALSE; + _sc_log = kSCLogDestinationFile; _sc_verbose = (argc > 1) ? TRUE : FALSE; load_KernelEventMonitor(CFBundleGetMainBundle(), (argc > 1) ? TRUE : FALSE); diff --git a/Plugins/LinkConfiguration/linkconfig.c b/Plugins/LinkConfiguration/linkconfig.c index 39f84f6..6ea3694 100644 --- a/Plugins/LinkConfiguration/linkconfig.c +++ b/Plugins/LinkConfiguration/linkconfig.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2002-2007, 2011, 2013, 2015-2019 Apple Inc. All rights reserved. + * Copyright (c) 2002-2007, 2011, 2013, 2015-2020 Apple Inc. All rights reserved. * * @APPLE_LICENSE_HEADER_START@ * @@ -823,7 +823,7 @@ main(int argc, char **argv) { SCPreferencesRef prefs; - _sc_log = FALSE; + _sc_log = kSCLogDestinationFile; _sc_verbose = (argc > 1) ? TRUE : FALSE; prefs = SCPreferencesCreate(NULL, CFSTR("linkconfig"), NULL); diff --git a/Plugins/PreferencesMonitor/prefsmon.c b/Plugins/PreferencesMonitor/prefsmon.c index db757db..31ce760 100644 --- a/Plugins/PreferencesMonitor/prefsmon.c +++ b/Plugins/PreferencesMonitor/prefsmon.c @@ -1107,7 +1107,7 @@ load_PreferencesMonitor(CFBundleRef bundle, Boolean bundleVerbose) int main(int argc, char **argv) { - _sc_log = FALSE; + _sc_log = kSCLogDestinationFile; _sc_verbose = (argc > 1) ? TRUE : FALSE; load_PreferencesMonitor(CFBundleGetMainBundle(), (argc > 1) ? TRUE : FALSE); diff --git a/Plugins/QoSMarking/qos-marking.m b/Plugins/QoSMarking/qos-marking.m index de2afca..99de79c 100644 --- a/Plugins/QoSMarking/qos-marking.m +++ b/Plugins/QoSMarking/qos-marking.m @@ -1221,7 +1221,7 @@ load_QoSMarking(CFBundleRef bundle, Boolean bundleVerbose) int main(int argc, char **argv) { - _sc_log = FALSE; + _sc_log = kSCLogDestinationFile; _sc_verbose = (argc > 1) ? TRUE : FALSE; load_QoSMarking(CFBundleGetMainBundle(), (argc > 1) ? TRUE : FALSE); diff --git a/Plugins/SimulatorSupport/simulator_support.c b/Plugins/SimulatorSupport/simulator_support.c index 4f5cf9b..b81ac1f 100644 --- a/Plugins/SimulatorSupport/simulator_support.c +++ b/Plugins/SimulatorSupport/simulator_support.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013, 2015-2018 Apple Inc. All rights reserved. + * Copyright (c) 2013, 2015-2020 Apple Inc. All rights reserved. * * @APPLE_LICENSE_HEADER_START@ * @@ -311,7 +311,7 @@ load_SimulatorSupport(CFBundleRef bundle, Boolean bundleVerbose) int main(int argc, char **argv) { - _sc_log = FALSE; + _sc_log = kSCLogDestinationFile; _sc_verbose = (argc > 1) ? TRUE : FALSE; load_SimulatorSupport(CFBundleGetMainBundle(), (argc > 1) ? TRUE : FALSE); diff --git a/SCMonitor/monitor.c b/SCMonitor/monitor.c index 3037150..c24a97a 100644 --- a/SCMonitor/monitor.c +++ b/SCMonitor/monitor.c @@ -1389,7 +1389,7 @@ main(int argc, char **argv) { MyType *newOne = (MyType *)malloc(sizeof(MyType)); - _sc_log = FALSE; + _sc_log = kSCLogDestinationFile; _sc_verbose = (argc > 1) ? TRUE : FALSE; memset(newOne, 0, sizeof(*newOne)); diff --git a/SCTest-ObjC/test-objC.m b/SCTest-ObjC/test-objC.m index 6fc5240..164a2bf 100644 --- a/SCTest-ObjC/test-objC.m +++ b/SCTest-ObjC/test-objC.m @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015, 2018 Apple Inc. All rights reserved. + * Copyright (c) 2015, 2018, 2020 Apple Inc. All rights reserved. * * @APPLE_LICENSE_HEADER_START@ * @@ -33,15 +33,25 @@ */ #import + +#if !defined(USING_PUBLIC_SDK) @import Foundation; @import SystemConfiguration; @import SystemConfiguration_Private; +#else // !defined(USING_PUBLIC_SDK) +#include +#include +#endif // !defined(USING_PUBLIC_SDK) + +#if TARGET_OS_MACCATALYST +#pragma message "Building for IOS_MAC" +#endif #define MY_APP_NAME CFSTR("SCTestObjC") #define TARGET_HOST "www.apple.com" -#if !TARGET_OS_SIMULATOR +#if !TARGET_OS_SIMULATOR && !defined(USING_PUBLIC_SDK) static void test_SCDynamicStore() { @@ -61,9 +71,9 @@ test_SCDynamicStore() CFRelease(dict); CFRelease(key); } -#endif // !TARGET_OS_SIMULATOR +#endif // !TARGET_OS_SIMULATOR && !defined(USING_PUBLIC_SDK) -#if !TARGET_OS_SIMULATOR +#if !TARGET_OS_SIMULATOR && !defined(USING_PUBLIC_SDK) static void test_SCNetworkConfiguration() { @@ -86,7 +96,7 @@ test_SCNetworkConfiguration() CFRelease(interfaces); } -#endif // !TARGET_OS_SIMULATOR +#endif // !TARGET_OS_SIMULATOR && !defined(USING_PUBLIC_SDK) void test_SCNetworkReachability() @@ -102,7 +112,7 @@ test_SCNetworkReachability() CFRelease(target); } -#if !TARGET_OS_SIMULATOR +#if !TARGET_OS_SIMULATOR && !defined(USING_PUBLIC_SDK) static void test_SCPreferences() { @@ -134,30 +144,43 @@ test_SCPreferences() CFRelease(prefs); CFRelease(services); } -#endif // !TARGET_OS_SIMULATOR +#endif // !TARGET_OS_SIMULATOR && !defined(USING_PUBLIC_SDK) void SCTest() { -#if !TARGET_OS_SIMULATOR +#if !TARGET_OS_SIMULATOR && !defined(USING_PUBLIC_SDK) test_SCDynamicStore(); -#endif // !TARGET_OS_SIMULATOR +#endif // !TARGET_OS_SIMULATOR && !defined(USING_PUBLIC_SDK) -#if !TARGET_OS_SIMULATOR +#if !TARGET_OS_SIMULATOR && !defined(USING_PUBLIC_SDK) test_SCNetworkConfiguration(); -#endif // !TARGET_OS_SIMULATOR +#endif // !TARGET_OS_SIMULATOR && !defined(USING_PUBLIC_SDK) test_SCNetworkReachability(); -#if !TARGET_OS_SIMULATOR +#if !TARGET_OS_SIMULATOR && !defined(USING_PUBLIC_SDK) test_SCPreferences(); -#endif // !TARGET_OS_SIMULATOR +#endif // !TARGET_OS_SIMULATOR && !defined(USING_PUBLIC_SDK) } -int main(int argc, const char * argv[]) { +int +main(int argc, const char * argv[]) { #pragma unused(argc, argv) + +#if TARGET_OS_MACCATALYST +#if !defined(USING_PUBLIC_SDK) +#include +#else // !defined(USING_PUBLIC_SDK) +extern Boolean _CFMZEnabled(void); +#endif // !defined(USING_PUBLIC_SDK) + if (_CFMZEnabled()) { + NSLog(@"*** IOS_MAC ***\n"); + } +#endif + @autoreleasepool { SCTest(); } diff --git a/SystemConfiguration.fproj/BondConfiguration.c b/SystemConfiguration.fproj/BondConfiguration.c index 1fe9ceb..1ca1eb0 100644 --- a/SystemConfiguration.fproj/BondConfiguration.c +++ b/SystemConfiguration.fproj/BondConfiguration.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2004-2019 Apple Inc. All rights reserved. + * Copyright (c) 2004-2020 Apple Inc. All rights reserved. * * @APPLE_LICENSE_HEADER_START@ * @@ -263,7 +263,7 @@ SCBondInterfaceCopyAll(SCPreferencesRef prefs) if (__SCPreferencesUsingDefaultPrefs(prefs)) { ni_prefs = NULL; } else { - ni_prefs = __SCPreferencesCreateNIPrefsFromPrefs(prefs); + ni_prefs = SCPreferencesCreateCompanion(prefs, INTERFACES_DEFAULT_CONFIG); } context.bonds = CFArrayCreateMutable(NULL, 0, &kCFTypeArrayCallBacks); diff --git a/SystemConfiguration.fproj/BridgeConfiguration.c b/SystemConfiguration.fproj/BridgeConfiguration.c index e410d8e..fff6188 100644 --- a/SystemConfiguration.fproj/BridgeConfiguration.c +++ b/SystemConfiguration.fproj/BridgeConfiguration.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2009-2018 Apple Inc. All rights reserved. + * Copyright (c) 2009-2018, 2020 Apple Inc. All rights reserved. * * @APPLE_LICENSE_HEADER_START@ * @@ -249,8 +249,9 @@ SCBridgeInterfaceCopyAll(SCPreferencesRef prefs) if (__SCPreferencesUsingDefaultPrefs(prefs)) { ni_prefs = NULL; } else { - ni_prefs = __SCPreferencesCreateNIPrefsFromPrefs(prefs); + ni_prefs = SCPreferencesCreateCompanion(prefs, INTERFACES_DEFAULT_CONFIG); } + context.bridges = CFArrayCreateMutable(NULL, 0, &kCFTypeArrayCallBacks); context.prefs = prefs; context.ni_prefs = ni_prefs; @@ -261,10 +262,11 @@ SCBridgeInterfaceCopyAll(SCPreferencesRef prefs) kSCPrefVirtualNetworkInterfaces, kSCNetworkInterfaceTypeBridge); dict = SCPreferencesPathGetValue(prefs, path); + CFRelease(path); if (isA_CFDictionary(dict)) { my_CFDictionaryApplyFunction(dict, add_configured_interface, &context); } - CFRelease(path); + if (ni_prefs != NULL) { CFRelease(ni_prefs); } diff --git a/SystemConfiguration.fproj/SCD.c b/SystemConfiguration.fproj/SCD.c index 74a6777..473ceb2 100644 --- a/SystemConfiguration.fproj/SCD.c +++ b/SystemConfiguration.fproj/SCD.c @@ -32,10 +32,13 @@ */ #include +#include #include #include #include #include + +#define OS_LOG_PACK_SPI #include #include @@ -46,12 +49,9 @@ #define INSTALL_ENVIRONMENT "__OSINSTALL_ENVIRONMENT" /* framework variables */ -int _sc_debug = FALSE; /* non-zero if debugging enabled */ -int _sc_verbose = FALSE; /* non-zero if verbose logging enabled */ -int _sc_log = 1; /* 0 if SC messages should be written to stdout/stderr, - 1 if SC messages should be logged w/os_log(3), - 2 if SC messages should be logged AND written to stdout/stderr - 3 if SC messages should be logged AND written to stdout/stderr (w/o timestamp) */ +int _sc_debug = FALSE; /* non-zero if debugging enabled */ +int _sc_verbose = FALSE; /* non-zero if verbose logging enabled */ +_SCLogDestination _sc_log = kSCLogDestinationDefault; #pragma mark - @@ -438,7 +438,7 @@ __SCLog(void *ret_addr, os_log_type_t type, const char *formatString, va_list fo static void -__SCPrint(FILE *stream, CFStringRef formatString, va_list formatArguments, Boolean trace, Boolean addNL) +__SCPrint(FILE *stream, CFStringRef formatString, va_list formatArguments, Boolean addTime, Boolean addNL) { char *line; CFStringRef str; @@ -469,7 +469,7 @@ __SCPrint(FILE *stream, CFStringRef formatString, va_list formatArguments, Boole } pthread_mutex_lock(&lock); - if (trace) { + if (addTime) { struct tm tm_now; struct timeval tv_now; @@ -490,6 +490,12 @@ __SCPrint(FILE *stream, CFStringRef formatString, va_list formatArguments, Boole } +/* + * NOTE: We need to keep this function in place (for a least a while) to ensure + * that any [old] code that was using an earlier version of SC_log() will + * have the needed support code to perform the actual logging. Newly + * compiled code uses the new/replacement _SC_log_send() function. + */ void __SC_Log(int level, CFStringRef format_CF, os_log_t log, os_log_type_t type, const char *format, ...) { @@ -499,20 +505,11 @@ __SC_Log(int level, CFStringRef format_CF, os_log_t log, os_log_type_t type, con va_list args_log; va_list args_print; - /* - * 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/os_log(3) - * 2 if SC messages should be written to stdout/stderr AND logged - * 3 if SC messages should be logged AND written to stdout/stderr (w/o timestamp) - */ - - if (_sc_log > 0) { + if (_sc_log > kSCLogDestinationFile) { do_log = TRUE; // log requested va_start(args_log, format); - if (_sc_log > 1) { + if (_sc_log >= kSCLogDestinationBoth) { do_print = TRUE; // log AND print requested va_copy(args_print, args_log); } @@ -534,8 +531,8 @@ __SC_Log(int level, CFStringRef format_CF, os_log_t log, os_log_type_t type, con __SCPrint(stdout, format_CF, args_print, - (_sc_log == 2), // trace - TRUE); // add newline + (_sc_log == kSCLogDestinationBoth), // trace + TRUE); // add newline va_end(args_print); } @@ -543,6 +540,127 @@ __SC_Log(int level, CFStringRef format_CF, os_log_t log, os_log_type_t type, con } +Boolean +__SC_log_enabled(int level, os_log_t log, os_log_type_t type) +{ + if (os_log_type_enabled(log, type)) { + return TRUE; + } + + if (_sc_log != kSCLogDestinationDefault) { + // if os_log'ing not enabled and the messages is targeted to stdout/stderr + if (level < LOG_INFO) { + // if not LOG_INFO/LOG_DEBUG message, print + return TRUE; + } else if ((level == LOG_INFO) && _sc_verbose) { + // if LOG_INFO and _sc_verbose, print + return TRUE; + } else if (_sc_debug) { + // if _sc_debug, print + return TRUE; + } + } + + if (_SC_isInstallEnvironment()) { + // if OSInstaller environment + if (level < LOG_INFO) { + // if not LOG_INFO/LOG_DEBUG message, syslog + return TRUE; + } else if ((level == LOG_INFO) && _SC_isAppleInternal()) { + // if LOG_INFO and internal, syslog + return TRUE; + } else if (_sc_debug) { + // if _sc_debug, syslog + return TRUE; + } + } + + return FALSE; +} + + +void +__SC_log_send(int level, os_log_t log, os_log_type_t type, os_log_pack_t pack) +{ + Boolean addTime = (_sc_log == kSCLogDestinationBoth); + char buffer[256]; + const char *buffer_ptr = buffer; + char *composed = NULL; + Boolean do_print = FALSE; + Boolean do_syslog = FALSE; + + if (_sc_log > kSCLogDestinationFile) { + if (_SC_isInstallEnvironment()) { + /* + * os_log(3) messages are not persisted in the + * install environment. So, we use syslog(3) + * instead. + */ + do_syslog = TRUE; + } + + if (_sc_log >= kSCLogDestinationBoth) { + do_print = TRUE; // log AND print requested + } + } else { + do_print = TRUE; // print requested + } + + if (!do_print && !do_syslog) { + // if only os_log requested + os_log_pack_send(pack, log, type); + } else if (do_print && !do_syslog) { + // if os_log and print requested + composed = os_log_pack_send_and_compose(pack, log, type, buffer, sizeof(buffer)); + } else { + // if print-only and/or syslog requested + mach_get_times(NULL, &pack->olp_continuous_time, &pack->olp_wall_time); + composed = os_log_pack_compose(pack, log, type, buffer, sizeof(buffer)); + } + + if (do_print && + ( + (level < LOG_INFO) || // print most messages + ((level == LOG_INFO) && _sc_verbose) || // with _sc_verbose, include LOG_INFO + _sc_debug // with _sc_debug, include LOG_DEBUG + ) + ) { + // if printing + pthread_mutex_lock(&lock); + if (addTime) { + struct tm tm_now; + struct timeval tv_now; + + tv_now.tv_sec = (time_t)&pack->olp_wall_time.tv_sec; + tv_now.tv_usec = (suseconds_t)((uint64_t)&pack->olp_wall_time.tv_nsec / NSEC_PER_USEC); + (void)localtime_r(&tv_now.tv_sec, &tm_now); + (void)fprintf(stdout, "%2d:%02d:%02d.%03d ", + tm_now.tm_hour, tm_now.tm_min, tm_now.tm_sec, tv_now.tv_usec / 1000); + } + (void)fprintf(stdout, "%s\n", composed); + fflush (stdout); + pthread_mutex_unlock(&lock); + } + + if (do_syslog && + ( + (level < LOG_INFO) || + ((level == LOG_INFO) && _SC_isAppleInternal()) || + _sc_debug + ) + ) { + // if [install/upgrade] syslog'ing + syslog(level | LOG_INSTALL, "%s", composed); + } + + if (composed != buffer_ptr) { + free(composed); + } + + return; +} + + void SCLog(Boolean condition, int level, CFStringRef formatString, ...) { @@ -564,11 +682,11 @@ SCLog(Boolean condition, int level, CFStringRef formatString, ...) * 3 if SC messages should be logged AND written to stdout/stderr (w/o timestamp) */ - if (_sc_log > 0) { + if (_sc_log > kSCLogDestinationFile) { log = TRUE; // log requested va_start(formatArguments, formatString); - if (_sc_log > 1) { + if (_sc_log >= kSCLogDestinationBoth) { print = TRUE; // log AND print requested va_copy(formatArguments_print, formatArguments); } @@ -594,8 +712,8 @@ SCLog(Boolean condition, int level, CFStringRef formatString, ...) __SCPrint((LOG_PRI(level) > LOG_NOTICE) ? stderr : stdout, formatString, formatArguments_print, - (_sc_log == 2), // trace - TRUE); // add newline + (_sc_log == kSCLogDestinationBoth), // trace + TRUE); // add newline va_end(formatArguments_print); } diff --git a/SystemConfiguration.fproj/SCNetworkConfigurationInternal.c b/SystemConfiguration.fproj/SCNetworkConfigurationInternal.c index d64b6df..32806c1 100644 --- a/SystemConfiguration.fproj/SCNetworkConfigurationInternal.c +++ b/SystemConfiguration.fproj/SCNetworkConfigurationInternal.c @@ -740,3 +740,5 @@ _SCNetworkConfigurationSetBypassSystemInterfaces(SCPreferencesRef prefs, Boolean return; } + + diff --git a/SystemConfiguration.fproj/SCNetworkConfigurationInternal.h b/SystemConfiguration.fproj/SCNetworkConfigurationInternal.h index 9470344..8cf01f7 100644 --- a/SystemConfiguration.fproj/SCNetworkConfigurationInternal.h +++ b/SystemConfiguration.fproj/SCNetworkConfigurationInternal.h @@ -207,8 +207,12 @@ __BEGIN_DECLS #pragma mark SCNetworkConfiguration (internal) + Boolean -__SCNetworkConfigurationBackup (SCPreferencesRef prefs) SPI_AVAILABLE(macos(10.15.4), ios(13.4), tvos(13.4), watchos(6.2), bridgeos(4.0)); +__SCNetworkConfigurationBackup (SCPreferencesRef prefs, + CFStringRef suffix, + SCPreferencesRef relativeTo); + #pragma mark - diff --git a/SystemConfiguration.fproj/SCNetworkConfigurationPrivate.c b/SystemConfiguration.fproj/SCNetworkConfigurationPrivate.c index 01576ea..52ce138 100644 --- a/SystemConfiguration.fproj/SCNetworkConfigurationPrivate.c +++ b/SystemConfiguration.fproj/SCNetworkConfigurationPrivate.c @@ -29,13 +29,14 @@ */ -#define USE_SC_LOG_OR_PRINT 1 // use '_sc_log' to control os_log, printf - #include "SCNetworkConfigurationInternal.h" #include "SCPreferencesInternal.h" #include +#define logDetails (_sc_log == kSCLogDestinationDefault) || _sc_debug + + static Boolean savePreferences(SCPreferencesRef prefs, CFStringRef save_prefsID, @@ -92,28 +93,55 @@ savePreferences(SCPreferencesRef prefs, __private_extern__ Boolean -__SCNetworkConfigurationBackup(SCPreferencesRef prefs) +__SCNetworkConfigurationBackup(SCPreferencesRef prefs, CFStringRef suffix, SCPreferencesRef relativeTo) { - Boolean ok; - CFStringRef save_prefsID; - struct tm tm_now; - struct timeval tv_now; - - SC_log(LOG_NOTICE, "creating [configuration] backup"); - - (void)gettimeofday(&tv_now, NULL); - (void)localtime_r(&tv_now.tv_sec, &tm_now); - save_prefsID = CFStringCreateWithFormat(NULL, - NULL, - CFSTR("preferences-%4d-%02d-%02d-%02d%02d%02d.plist"), - tm_now.tm_year + 1900, - tm_now.tm_mon + 1, - tm_now.tm_mday, - tm_now.tm_hour, - tm_now.tm_min, - tm_now.tm_sec); - ok = savePreferences(prefs, save_prefsID, CFSTR(""), FALSE, NULL, NULL); - CFRelease(save_prefsID); + SCPreferencesRef backup; + CFMutableStringRef backupPrefsID; + Boolean ok = FALSE; + CFPropertyListRef plist; + CFRange range; + SCPreferencesPrivateRef sourcePrivate = (SCPreferencesPrivateRef)prefs; + CFStringRef sourcePrefsID; + + SC_log(LOG_NOTICE, "creating [%@] backup", suffix); + + sourcePrefsID = (sourcePrivate->prefsID != NULL) ? sourcePrivate->prefsID : PREFS_DEFAULT_CONFIG; + backupPrefsID = CFStringCreateMutableCopy(NULL, 0, sourcePrefsID); + if (CFStringFindWithOptions(backupPrefsID, + CFSTR("/"), + CFRangeMake(0, CFStringGetLength(backupPrefsID)), + kCFCompareBackwards, + &range)) { + // if slash, remove path prefix + range.length = range.location + 1; + range.location = 0; + CFStringReplace(backupPrefsID, range, CFSTR("")); + } + CFStringInsert(backupPrefsID, + CFStringGetLength(backupPrefsID) - sizeof(".plist") + 1, + CFSTR("-")); + CFStringInsert(backupPrefsID, + CFStringGetLength(backupPrefsID) - sizeof(".plist") + 1, + suffix); + backup = SCPreferencesCreateCompanion(relativeTo, backupPrefsID); + CFRelease(backupPrefsID); + + SC_log(LOG_INFO, + "__SCNetworkConfigurationBackup()" + "\n relativeTo = %@" + "\n prefs = %@" + "\n backup = %@", + relativeTo, + prefs, + backup); + + if (backup != NULL) { + plist = SCPreferencesPathGetValue(prefs, CFSTR("/")); + SCPreferencesPathSetValue(backup, CFSTR("/"), plist); + ok = SCPreferencesCommitChanges(backup); + CFRelease(backup); + } + return ok; } @@ -329,9 +357,9 @@ __SCNetworkConfigurationUpgrade(SCPreferencesRef *prefs_p, done : if (prefs_added) { -// if (ok && (prefs_p != NULL)) { -// *prefs_p = CFRetain(prefs); -// } + // per the expected usage, even if we on-the-fly create + // a [preferences.plist] companion it is not returned to + // the caller. So, just release. CFRelease(prefs); } @@ -550,8 +578,10 @@ __SCNetworkConfigurationCleanHiddenInterfaces(SCPreferencesRef prefs, SCPreferen CFArrayRef interfaces; CFMutableArrayRef interfaces_thin; CFIndex n; +#if TARGET_OS_OSX CFDictionaryRef nat_config; SCPreferencesRef nat_prefs; +#endif // TARGET_OS_OSX CFArrayRef services; int updated = 0; @@ -574,7 +604,7 @@ __SCNetworkConfigurationCleanHiddenInterfaces(SCPreferencesRef prefs, SCPreferen if (bsdName == NULL) { // if no interface name - if ((_sc_log == 1) || _sc_debug) { + if (logDetails) { SC_log(LOG_INFO, "skipping service : %@ : %@ (no interface)", SCNetworkServiceGetServiceID(service), @@ -589,7 +619,7 @@ __SCNetworkConfigurationCleanHiddenInterfaces(SCPreferencesRef prefs, SCPreferen thin = "effectively hidden"; } else { // if not HiddenConfiguration - if ((_sc_log == 1) || _sc_debug) { + if (logDetails) { SC_log(LOG_INFO, "skipping service : %@ : %@ : %@ (not hidden)", SCNetworkServiceGetServiceID(service), @@ -602,7 +632,7 @@ __SCNetworkConfigurationCleanHiddenInterfaces(SCPreferencesRef prefs, SCPreferen conflict = serviceMatchesTemplate(prefs, service); if (conflict != NULL) { // if any part of the service's configuration was changed - if ((_sc_log == 1) || _sc_debug) { + if (logDetails) { SC_log(LOG_INFO, "skipping service : %@ : %@ : %@ (%s, non-default, %@)", SCNetworkServiceGetServiceID(service), @@ -615,7 +645,7 @@ __SCNetworkConfigurationCleanHiddenInterfaces(SCPreferencesRef prefs, SCPreferen continue; } - if ((_sc_log == 1) || _sc_debug) { + if (logDetails) { SC_log(LOG_INFO, "candidate interface : %@ (%s)", bsdName, thin); } @@ -646,7 +676,7 @@ __SCNetworkConfigurationCleanHiddenInterfaces(SCPreferencesRef prefs, SCPreferen bsdName = SCNetworkInterfaceGetBSDName(member); if ((bsdName != NULL) && thinRemove(interfaces_thin, bsdName)) { - if ((_sc_log == 1) || _sc_debug) { + if (logDetails) { SC_log(LOG_INFO, "skipping interface : %@ (bond member)", bsdName); } } @@ -677,7 +707,7 @@ __SCNetworkConfigurationCleanHiddenInterfaces(SCPreferencesRef prefs, SCPreferen bsdName = SCNetworkInterfaceGetBSDName(member); if ((bsdName != NULL) && thinRemove(interfaces_thin, bsdName)) { - if ((_sc_log == 1) || _sc_debug) { + if (logDetails) { SC_log(LOG_INFO, "skipping interface : %@ (bridge member)", bsdName); } } @@ -701,7 +731,7 @@ __SCNetworkConfigurationCleanHiddenInterfaces(SCPreferencesRef prefs, SCPreferen bsdName = SCNetworkInterfaceGetBSDName(physicalInterface); if ((bsdName != NULL) && thinRemove(interfaces_thin, bsdName)) { - if ((_sc_log == 1) || _sc_debug) { + if (logDetails) { SC_log(LOG_INFO, "skipping interface : %@ (vlan physical)", bsdName); } } @@ -712,13 +742,24 @@ __SCNetworkConfigurationCleanHiddenInterfaces(SCPreferencesRef prefs, SCPreferen // remove any "shared" interfaces from the list +#if TARGET_OS_OSX nat_prefs = SCPreferencesCreateCompanion(prefs, CFSTR("com.apple.nat.plist")); nat_config = SCPreferencesGetValue(nat_prefs, CFSTR("NAT")); if (isA_CFDictionary(nat_config)) { + CFBooleanRef bVal = NULL; + Boolean enabled = FALSE; CFStringRef sharedFrom = NULL; CFArrayRef sharedTo = NULL; if (CFDictionaryGetValueIfPresent(nat_config, + CFSTR("Enabled"), + (const void **)&bVal) && + isA_CFBoolean(bVal)) { + enabled = CFBooleanGetValue(bVal); + } + + if (enabled && + CFDictionaryGetValueIfPresent(nat_config, CFSTR("PrimaryService"), (const void **)&sharedFrom) && isA_CFString(sharedFrom)) { @@ -732,7 +773,7 @@ __SCNetworkConfigurationCleanHiddenInterfaces(SCPreferencesRef prefs, SCPreferen bsdName = SCNetworkInterfaceGetBSDName(interface); if ((bsdName != NULL) && thinRemove(interfaces_thin, bsdName)) { - if ((_sc_log == 1) || _sc_debug) { + if (logDetails) { SC_log(LOG_INFO, "skipping interface : %@ (Share your connection from)", bsdName); } } @@ -742,23 +783,25 @@ __SCNetworkConfigurationCleanHiddenInterfaces(SCPreferencesRef prefs, SCPreferen } } - if (CFDictionaryGetValueIfPresent(nat_config, - CFSTR("SharingDevices"), - (const void **)&sharedTo) && - isA_CFArray(sharedTo)) { - // if "To computers using" interfaces configured - n = CFArrayGetCount(sharedTo); - for (CFIndex i = 0; i < n; i++) { - bsdName = CFArrayGetValueAtIndex(sharedTo, i); - if (thinRemove(interfaces_thin, bsdName)) { - if ((_sc_log == 1) || _sc_debug) { - SC_log(LOG_INFO, "skipping interface : %@ (To computers using)", bsdName); - } - } - } - } + if (enabled && + CFDictionaryGetValueIfPresent(nat_config, + CFSTR("SharingDevices"), + (const void **)&sharedTo) && + isA_CFArray(sharedTo)) { + // if "To computers using" interfaces configured + n = CFArrayGetCount(sharedTo); + for (CFIndex i = 0; i < n; i++) { + bsdName = CFArrayGetValueAtIndex(sharedTo, i); + if (thinRemove(interfaces_thin, bsdName)) { + if (logDetails) { + SC_log(LOG_INFO, "skipping interface : %@ (To computers using)", bsdName); + } + } + } + } } CFRelease(nat_prefs); +#endif // TARGET_OS_OSX // thin preferences.plist n = (services != NULL) ? CFArrayGetCount(services) : 0; @@ -783,7 +826,7 @@ __SCNetworkConfigurationCleanHiddenInterfaces(SCPreferencesRef prefs, SCPreferen } // remove this service associated with a "thinned" interface - if ((_sc_log == 1) || _sc_verbose) { + if (logDetails || _sc_verbose) { SC_log(LOG_INFO, "thinned network service : %@ : %@ : %@", SCNetworkServiceGetServiceID(service), @@ -795,7 +838,7 @@ __SCNetworkConfigurationCleanHiddenInterfaces(SCPreferencesRef prefs, SCPreferen } if (updated > 0) { - if ((_sc_log == 1) || _sc_debug) { + if (logDetails) { SC_log(LOG_NOTICE, "Updating \"preferences.plist\" (thinned %d service%s)", updated, @@ -823,12 +866,12 @@ __SCNetworkConfigurationCleanHiddenInterfaces(SCPreferencesRef prefs, SCPreferen bsdName = CFDictionaryGetValue(if_dict, CFSTR(kIOBSDNameKey)); if (isThin(interfaces_thin, bsdName)) { if (CFDictionaryContainsKey(if_dict, CFSTR(kSCNetworkInterfaceActive))) { - if ((_sc_log == 1) || _sc_debug) { + if (logDetails) { SC_log(LOG_INFO, "skipping interface : %@ (active)", bsdName); } } else { // remove this "thinned" interface - if ((_sc_log == 1) || _sc_debug || _sc_verbose) { + if (logDetails || _sc_verbose) { SC_log(LOG_INFO, "thinned network interface : %@", bsdName); } updated++; @@ -842,7 +885,7 @@ __SCNetworkConfigurationCleanHiddenInterfaces(SCPreferencesRef prefs, SCPreferen CFRelease(interfaces_new); if (updated > 0) { - if ((_sc_log == 1) || _sc_debug) { + if (logDetails) { SC_log(LOG_INFO, "Updating \"NetworkInterfaces.plist\" (thinned %d interface%s)", updated, @@ -1065,7 +1108,7 @@ __SCNetworkConfigurationCleanServiceOrderIssues(SCPreferencesRef prefs) // check if serviceID already known/processed if (CFSetContainsValue(known, serviceID)) { // if duplicate/removed service, remove from serviceOrder - if ((_sc_log == 1) || _sc_debug) { + if (logDetails) { SC_log(LOG_NOTICE, "set: %@, removing serviceID %@ (duplicate/removed)", setID, @@ -1084,7 +1127,7 @@ __SCNetworkConfigurationCleanServiceOrderIssues(SCPreferencesRef prefs) service = SCNetworkServiceCopy(prefs, serviceID); if (service == NULL) { // if no service, remove from serviceOrder - if ((_sc_log == 1) || _sc_debug) { + if (logDetails) { SC_log(LOG_NOTICE, "set: %@, removing serviceID %@ (no service)", setID, @@ -1098,7 +1141,7 @@ __SCNetworkConfigurationCleanServiceOrderIssues(SCPreferencesRef prefs) if (!__SCNetworkServiceExists(service)) { // if service already removed, remove from serviceOrder - if ((_sc_log == 1) || _sc_debug) { + if (logDetails) { SC_log(LOG_NOTICE, "set: %@, removing serviceID %@ (service already removed)", setID, diff --git a/SystemConfiguration.fproj/SCNetworkInterface.c b/SystemConfiguration.fproj/SCNetworkInterface.c index b9c0ba4..bec3468 100644 --- a/SystemConfiguration.fproj/SCNetworkInterface.c +++ b/SystemConfiguration.fproj/SCNetworkInterface.c @@ -3455,7 +3455,7 @@ _SCNetworkInterfaceCopyPrefixFromBSDName(CFStringRef bsdName) CFIndex length = 0; if (!isA_CFString(bsdName)) { - SC_log(LOG_DEBUG, "no BSD name"); + SC_log(LOG_DEBUG, "No BSD name"); goto done; } @@ -3819,7 +3819,7 @@ __SCNetworkInterfaceCreateWithStorageEntity(CFDictionaryRef interface_entity) } bsdName = CFDictionaryGetValue(interface_entity, CFSTR(kSCNetworkInterfaceBSDName)); if (!isA_CFString(bsdName)) { - SC_log(LOG_INFO, "No BSD name"); + SC_log(LOG_DEBUG, "No BSD name"); goto done; } hidden = CFDictionaryGetValue(interface_entity, kSCNetworkInterfaceHiddenConfigurationKey); @@ -8451,6 +8451,7 @@ __SCNetworkInterfaceCreateMappingUsingBSDName(CFArrayRef interfaces) SC_log(LOG_INFO, "No interfaces"); return NULL; } + mappingBSDToInterface = CFDictionaryCreateMutable(NULL, 0, &kCFTypeDictionaryKeyCallBacks, &kCFTypeDictionaryValueCallBacks); for (CFIndex idx = 0; idx < count; idx++) { @@ -8458,11 +8459,12 @@ __SCNetworkInterfaceCreateMappingUsingBSDName(CFArrayRef interfaces) bsdName = SCNetworkInterfaceGetBSDName(interface); if (!isA_CFString(bsdName)) { - SC_log(LOG_INFO, "No BSD name"); + SC_log(LOG_DEBUG, "No BSD name"); continue; } CFDictionaryAddValue(mappingBSDToInterface, bsdName, interface); } + if (CFDictionaryGetCount(mappingBSDToInterface) == 0) { CFRelease(mappingBSDToInterface); mappingBSDToInterface = NULL; diff --git a/SystemConfiguration.fproj/SCNetworkMigration.c b/SystemConfiguration.fproj/SCNetworkMigration.c index 091645c..ab9b39d 100644 --- a/SystemConfiguration.fproj/SCNetworkMigration.c +++ b/SystemConfiguration.fproj/SCNetworkMigration.c @@ -106,17 +106,21 @@ _SCNetworkConfigurationCopyMigrationPaths(CFDictionaryRef options) CFMutableArrayRef migrationPaths = NULL; CFURLRef prefs; - if (_SC_isInstallEnvironment()) { - _sc_debug = 1; - } - _SCNetworkConfigurationCopyMigrationPathsWithBaseURL(NULL, &prefs, &interfaces); - migrationPaths = CFArrayCreateMutable(NULL, 0, &kCFTypeArrayCallBacks); - CFArrayInsertValueAtIndex(migrationPaths, PREFERENCES_PLIST_INDEX, prefs); - CFArrayInsertValueAtIndex(migrationPaths, NETWORK_INTERFACES_PLIST_INDEX, interfaces); - + _SCNetworkConfigurationCopyMigrationPathsWithBaseURL(NULL, &prefs, &interfaces); + CFArrayAppendValue(migrationPaths, prefs); + CFArrayAppendValue(migrationPaths, interfaces); CFRelease(prefs); CFRelease(interfaces); + + SC_log(LOG_INFO, + "_SCNetworkConfigurationCopyMigrationPaths() called%s" + "\n options = %@" + "\n paths = %@", + _SC_isInstallEnvironment() ? " (INSTALLER ENVIRONMENT)" : "", + options, + migrationPaths); + return migrationPaths; } @@ -138,7 +142,7 @@ _SCNetworkConfigurationRemoveConfigurationFiles(CFURLRef configDir) SC_log(LOG_NOTICE, "Cannot get file system representation for url: %@", configPathURL); } else { if ((remove(configPathString) != 0) && (errno != ENOENT)) { - SC_log(LOG_INFO, "remove(\"%s\") failed: %s", configPathString, strerror(errno)); + SC_log(LOG_NOTICE, "remove(\"%s\") failed: %s", configPathString, strerror(errno)); } } CFRelease(configPathURL); @@ -150,7 +154,7 @@ _SCNetworkConfigurationRemoveConfigurationFiles(CFURLRef configDir) SC_log(LOG_NOTICE, "Cannot get file system representation for url: %@", configNetworkInterfacesPathURL); } else { if ((remove(configNetworkInterfacesPathString) != 0) && (errno != ENOENT)) { - SC_log(LOG_INFO, "remove(\"%s\") failed: %s", configNetworkInterfacesPathString, strerror(errno)); + SC_log(LOG_NOTICE, "remove(\"%s\") failed: %s", configNetworkInterfacesPathString, strerror(errno)); } } CFRelease(configNetworkInterfacesPathURL); @@ -273,62 +277,51 @@ static Boolean _SCNetworkConfigurationMakePathIfNeeded(CFURLRef pathURL) { char *c; - mode_t newmask; char path[PATH_MAX]; - char thepath[PATH_MAX]; - CFIndex slen=0; - struct stat sb; - Boolean success = FALSE; + Boolean success = FALSE; if (!CFURLGetFileSystemRepresentation(pathURL, TRUE, (UInt8 *)path, sizeof(path))) { SC_log(LOG_NOTICE, "Cannot get file system representation for url: %@", pathURL); return success; } - SC_log(LOG_INFO, "creating path: %s", path); - - newmask = S_IRWXU | S_IRGRP | S_IROTH | S_IXGRP | S_IXOTH; - slen = strlen(path); + SC_log(LOG_INFO, "creating path: %s", path); - strlcpy(thepath, path, slen+1); - c = thepath; - if (*c == '/') - c++; - for(; !success; c++){ + c = path; + if (*c == '/') { + c++; // skip leading / + } + for(; !success; c++) { if ((*c == '/') || (*c == '\0')){ - if (*c == '\0') + if (*c == '\0') { success = TRUE; - else + } else { *c = '\0'; - if (mkdir(thepath, newmask)){ - if (errno == EEXIST || errno == EISDIR){ - if (stat(thepath, &sb) < 0){ - SC_log(LOG_ERR, "stat returned value < 0"); - break; - } - } else { - SC_log(LOG_ERR, "received error: %s", strerror(errno)); + } + if (mkdir(path, (S_IRWXU | S_IRGRP | S_IROTH | S_IXGRP | S_IXOTH)) != 0) { + if ((errno != EEXIST) && (errno != EISDIR)) { + SC_log(LOG_NOTICE, "mkdir(%s) failed: %s", path, strerror(errno)); break; } } *c = '/'; } } + return success; } -static SCPreferencesRef -__SCNetworkCreateDefaultPref(CFStringRef prefsID) +static void +__SCNetworkPopulateDefaultPrefs(SCPreferencesRef prefs) { SCNetworkSetRef currentSet; CFStringRef model; - SCPreferencesRef prefs; CFNumberRef version; - prefs = SCPreferencesCreate(NULL, PLUGIN_ID, prefsID); - if (prefs == NULL) { - return NULL; - } + SC_log(LOG_INFO, + "Populating preferences.plist" + "\n %@", + prefs); currentSet = SCNetworkSetCopyCurrent(prefs); if (currentSet == NULL) { @@ -343,7 +336,7 @@ __SCNetworkCreateDefaultPref(CFStringRef prefsID) SCPreferencesSetValue(prefs, MODEL, model); } - version = SCPreferencesGetValue(prefs, MODEL); + version = SCPreferencesGetValue(prefs, kSCPrefVersion); if (version == NULL) { const int new_version = NETWORK_CONFIGURATION_VERSION; @@ -352,7 +345,7 @@ __SCNetworkCreateDefaultPref(CFStringRef prefsID) CFRelease(version); } - return prefs; + return; } __private_extern__ @@ -371,9 +364,14 @@ __SCNetworkPopulateDefaultNIPrefs(SCPreferencesRef ni_prefs) return; } + SC_log(LOG_INFO, + "Populating NetworkInterfaces.plist" + "\n %@", + ni_prefs); + networkInterfaces = __SCNetworkInterfaceCopyAll_IONetworkInterface(TRUE); if (networkInterfaces == NULL) { - SC_log(LOG_NOTICE, "networkInterfaces is NULL"); + SC_log(LOG_NOTICE, "Cannot populate NetworkInterfaces.plist, no network interfaces"); return; } @@ -427,7 +425,7 @@ __SCNetworkPopulateDefaultNIPrefs(SCPreferencesRef ni_prefs) SCPreferencesSetValue(ni_prefs, MODEL, model); } - version = SCPreferencesGetValue(ni_prefs, MODEL); + version = SCPreferencesGetValue(ni_prefs, kSCPrefVersion); if (version == NULL) { const int new_version = NETWORK_CONFIGURATION_VERSION; @@ -458,28 +456,36 @@ _SCNetworkConfigurationPerformMigration(CFURLRef sourceDir, CFURLRef currentDir, CFURLRef sourceDirConfig = NULL; CFURLRef targetDirConfig = NULL; - if (_SC_isInstallEnvironment()) { - _sc_debug = 1; - } + SC_log(LOG_INFO, + "_SCNetworkConfigurationPerformMigration() called%s" + "\n sourceDir = %@" + "\n currentDir = %@" + "\n targetDir = %@" + "\n options = %@", + _SC_isInstallEnvironment() ? " (INSTALLER ENVIRONMENT)" : "", + sourceDir, + currentDir, + targetDir, + options); if ((sourceDir != NULL) && !CFURLHasDirectoryPath(sourceDir)) { - SC_log(LOG_INFO, "sourceDir is not a directory: %@", sourceDir); + SC_log(LOG_NOTICE, "Migration source is not a directory: %@", sourceDir); goto done; } if ((currentDir != NULL) && !CFURLHasDirectoryPath(currentDir)) { - SC_log(LOG_INFO, "currentDir is not a directory: %@", currentDir); + SC_log(LOG_NOTICE, "Migration current is not a directory: %@", currentDir); goto done; } if ((targetDir != NULL) && !CFURLHasDirectoryPath(targetDir)) { - SC_log(LOG_INFO, "targetDir is not a directory: %@", targetDir); + SC_log(LOG_NOTICE, "Migration target 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"); + SC_log(LOG_NOTICE, "Both migration source and current are NULL"); goto done; } @@ -515,20 +521,20 @@ _SCNetworkConfigurationPerformMigration(CFURLRef sourceDir, CFURLRef currentDir, TRUE, targetDir); } - // Source directory cannot be the same as Target Directory + // Source directory cannot be the same as target directory if (CFEqual(sourceDirConfig, targetDirConfig)) { - SC_log(LOG_INFO, "Source directory cannot be the same as target directory"); + SC_log(LOG_NOTICE, "Source directory cannot be the same as target directory"); goto done; } if ((currentDirConfig == NULL) || !CFEqual(currentDirConfig, targetDirConfig)) { if (!_SCNetworkConfigurationMakePathIfNeeded(targetDirConfig)) { - SC_log(LOG_INFO, "Could not create target directory"); + SC_log(LOG_NOTICE, "Could not create target directory"); goto done; } if (!SCNetworkConfigurationCopyConfigurationFiles(currentDirConfig, targetDirConfig)) { - SC_log(LOG_INFO, "Could not copy configuration files from \"%@\" to \"%@\"", + SC_log(LOG_NOTICE, "Could not copy configuration files from \"%@\" to \"%@\"", currentDirConfig, targetDirConfig); } else if (currentDirConfig != NULL) { @@ -541,7 +547,7 @@ _SCNetworkConfigurationPerformMigration(CFURLRef sourceDir, CFURLRef currentDir, // If both source and current configurations point to current system, then no migration needs to be done. if ((currentDirConfig != NULL) && CFEqual(sourceDirConfig, currentDirConfig)) { - SC_log(LOG_INFO, "No migration needed, source and current configurations point to same path"); + SC_log(LOG_NOTICE, "No migration needed, source and current configurations have the same path"); migrationComplete = TRUE; } else { migrationComplete = _SCNetworkConfigurationMigrateConfiguration(sourceDirConfig, targetDirConfig); @@ -552,7 +558,7 @@ _SCNetworkConfigurationPerformMigration(CFURLRef sourceDir, CFURLRef currentDir, } else { SC_log(LOG_NOTICE, "Migration failed: %s", SCErrorString(SCError())); - // If migration fails, then remove configuration files from target config if they are + // If migration fails, then remove configuration files from target config if they were // copied from the current directory if (removeTargetOnFailure) { _SCNetworkConfigurationRemoveConfigurationFiles(targetDirConfig); @@ -571,6 +577,7 @@ done: if (targetDirConfig != NULL) { CFRelease(targetDirConfig); } + return paths; } @@ -583,7 +590,7 @@ _SCNetworkConfigurationMigrateIsFilePresent(CFURLRef filePath) struct stat statStruct = {0, }; if (filePath == NULL) { - SC_log(LOG_DEBUG, "filePath is NULL"); + SC_log(LOG_NOTICE, "_SCNetworkConfigurationMigrateIsFilePresent: No path"); goto done; } @@ -594,14 +601,37 @@ _SCNetworkConfigurationMigrateIsFilePresent(CFURLRef filePath) statResult = stat(filePathStr, &statStruct); if (statResult == 0) { - fileExists = TRUE; + SCPreferencesRef prefs; + CFStringRef prefsID; + + if (statStruct.st_size == 0) { + SC_log(LOG_INFO, "_SCNetworkConfigurationMigrateIsFilePresent: empty .plist: %@", filePath); // REMOVE + goto done; + } + + prefsID = CFStringCreateWithCString(NULL, filePathStr, kCFStringEncodingUTF8); + prefs = SCPreferencesCreate(NULL, PLUGIN_ID, prefsID); + CFRelease(prefsID); + if (prefs == NULL) { + SC_log(LOG_NOTICE, "_SCNetworkConfigurationMigrateIsFilePresent: bad .plist: %@", filePath); + goto done; + } + + if (!__SCPreferencesIsEmpty(prefs)) { + // if non-empty .plist + fileExists = TRUE; + } else { + SC_log(LOG_NOTICE, "_SCNetworkConfigurationMigrateIsFilePresent: effectively empty .plist: %@", filePath); + } + + CFRelease(prefs); } done: return fileExists; } static Boolean -__SCNetworkConfigurationMigrateConfigurationFilesPresent(CFURLRef baseURL, CFArrayRef* migrationPaths) +__SCNetworkConfigurationMigrateConfigurationFilesPresent(CFURLRef baseURL, CFArrayRef* migrationPaths, Boolean expected) { Boolean configFilesPresent = FALSE; CFIndex count; @@ -611,31 +641,29 @@ __SCNetworkConfigurationMigrateConfigurationFilesPresent(CFURLRef baseURL, CFArr CFURLRef prefs; if (baseURL == NULL) { - SC_log(LOG_INFO, "No base migration URL"); + SC_log(LOG_NOTICE, "No base migration URL"); goto done; } - _SCNetworkConfigurationCopyMigrationPathsWithBaseURL(baseURL, &prefs, &interfaces); - migrationPathsMutable = CFArrayCreateMutable(kCFAllocatorDefault, 0, &kCFTypeArrayCallBacks); - CFArrayInsertValueAtIndex(migrationPathsMutable, PREFERENCES_PLIST_INDEX, prefs); - CFArrayInsertValueAtIndex(migrationPathsMutable, NETWORK_INTERFACES_PLIST_INDEX, interfaces); - + _SCNetworkConfigurationCopyMigrationPathsWithBaseURL(baseURL, &prefs, &interfaces); + CFArrayAppendValue(migrationPathsMutable, prefs); + CFArrayAppendValue(migrationPathsMutable, interfaces); CFRelease(prefs); CFRelease(interfaces); *migrationPaths = migrationPathsMutable; - if ((*migrationPaths == NULL) || - ((count = CFArrayGetCount(*migrationPaths)) == 0)) { - SC_log(LOG_INFO, "No migration paths"); - goto done; - } - + count = CFArrayGetCount(*migrationPaths); for (CFIndex idx = 0; idx < count; idx++) { + Boolean present; + filePath = CFArrayGetValueAtIndex(*migrationPaths, idx); - if (!_SCNetworkConfigurationMigrateIsFilePresent(filePath)) { - SC_log(LOG_INFO, "Required migration file not present: %@", filePath); + present = _SCNetworkConfigurationMigrateIsFilePresent(filePath); + if (!present) { + if (expected) { + SC_log(LOG_INFO, "Expected migration file not present: %@", filePath); + } goto done; } } @@ -656,7 +684,6 @@ _SCNetworkInterfaceCopyInterfacesFilteredByBuiltinWithPreferences(SCPreferencesR interfaceList = __SCNetworkInterfaceCopyStoredWithPreferences(ni_prefs); if (interfaceList == NULL) { - SC_log(LOG_INFO, "No interfaces"); goto done; } @@ -705,7 +732,7 @@ _SCNetworkInterfaceStorageCopyMaxUnitPerInterfaceType(SCPreferencesRef ni_prefs) cfMaxUnit = NULL; interface = CFArrayGetValueAtIndex(ifList, idx); - if (isA_SCNetworkInterface(interface) == NULL) { + if (!isA_SCNetworkInterface(interface)) { continue; } @@ -753,22 +780,49 @@ _SCNetworkConfigurationCopyBuiltinMapping (SCPreferencesRef sourcePrefs, SCPrefe SCNetworkInterfaceRef targetInterface; sourceBuiltinInterfaces = _SCNetworkInterfaceCopyInterfacesFilteredByBuiltinWithPreferences(sourcePrefs, TRUE); - if (isA_CFArray(sourceBuiltinInterfaces) == NULL) { + if (!isA_CFArray(sourceBuiltinInterfaces)) { SC_log(LOG_INFO, "No source built-in interfaces"); goto done; } sourceBuiltinInterfaceCount = CFArrayGetCount(sourceBuiltinInterfaces); targetBuiltinInterfaces = _SCNetworkInterfaceCopyInterfacesFilteredByBuiltinWithPreferences(targetPrefs, TRUE); - if (isA_CFArray(targetBuiltinInterfaces) == NULL) { + if (!isA_CFArray(targetBuiltinInterfaces)) { SC_log(LOG_INFO, "No target built-in interfaces"); goto done; } - targetBuiltinInterfaceCount = CFArrayGetCount(targetBuiltinInterfaces); // Builtin Mapping will try to map all source interfaces into target interfaces for (CFIndex idx = 0; idx < sourceBuiltinInterfaceCount; idx++) { + Boolean matched = FALSE; + sourceInterface = CFArrayGetValueAtIndex(sourceBuiltinInterfaces, idx); + targetBuiltinInterfaceCount = CFArrayGetCount(targetBuiltinInterfaces); + + for (CFIndex idx2 = 0; idx2 < targetBuiltinInterfaceCount; idx2++) { + CFDataRef sourceHardwareAddress; + CFDataRef targetHardwareAddress; + + targetInterface = CFArrayGetValueAtIndex(targetBuiltinInterfaces, idx2); + sourceHardwareAddress = _SCNetworkInterfaceGetHardwareAddress(sourceInterface); + targetHardwareAddress = _SCNetworkInterfaceGetHardwareAddress(targetInterface); + if (_SC_CFEqual(sourceHardwareAddress, targetHardwareAddress)) { + if (builtinMapping == NULL) { + builtinMapping = CFDictionaryCreateMutable(NULL, 0, + &kCFTypeDictionaryKeyCallBacks, + &kCFTypeDictionaryValueCallBacks); + } + CFDictionaryAddValue(builtinMapping, sourceInterface, targetInterface); + CFArrayRemoveValueAtIndex(targetBuiltinInterfaces, idx2); + matched = TRUE; + break; + } + } + if (matched) { + // proceed to next source interface + continue; + } + for (CFIndex idx2 = 0; idx2 < targetBuiltinInterfaceCount; idx2++) { targetInterface = CFArrayGetValueAtIndex(targetBuiltinInterfaces, idx2); @@ -783,7 +837,6 @@ _SCNetworkConfigurationCopyBuiltinMapping (SCPreferencesRef sourcePrefs, SCPrefe break; } } - targetBuiltinInterfaceCount = CFArrayGetCount(targetBuiltinInterfaces); } done: @@ -814,7 +867,7 @@ _SCNetworkConfigurationCopyExternalInterfaceMapping (SCPreferencesRef sourcePref CFNumberRef type; sourceExternalInterfaces = _SCNetworkInterfaceCopyInterfacesFilteredByBuiltinWithPreferences(sourcePref, FALSE); - if (isA_CFArray(sourceExternalInterfaces) == NULL) { + if (!isA_CFArray(sourceExternalInterfaces)) { SC_log(LOG_INFO, "No source external interfaces"); goto done; } @@ -825,7 +878,7 @@ _SCNetworkConfigurationCopyExternalInterfaceMapping (SCPreferencesRef sourcePref } targetExternalInterfaces = _SCNetworkInterfaceCopyInterfacesFilteredByBuiltinWithPreferences(targetPrefs, FALSE); - if (isA_CFArray(targetExternalInterfaces) == NULL) { + if (!isA_CFArray(targetExternalInterfaces)) { SC_log(LOG_INFO, "No target external interfaces"); goto done; } @@ -835,53 +888,78 @@ _SCNetworkConfigurationCopyExternalInterfaceMapping (SCPreferencesRef sourcePref // Map all external interfaces which exist in both source and target for (CFIndex idx = 0; idx < sourceExternalInterfaceCount; idx++) { + Boolean matched = FALSE; + sourceInterface = CFArrayGetValueAtIndex(sourceExternalInterfaces, idx); targetExternalInterfaceCount = CFArrayGetCount(targetExternalInterfaces); currentInterfaceUnit = NULL; for (CFIndex idx2 = 0; idx2 < targetExternalInterfaceCount; idx2++) { - targetInterface = CFArrayGetValueAtIndex(targetExternalInterfaces, idx2); + CFDataRef sourceHardwareAddress; + CFDataRef targetHardwareAddress; - if (_SCNetworkConfigurationIsInterfaceNamerMappable(sourceInterface, targetInterface, TRUE)) { + targetInterface = CFArrayGetValueAtIndex(targetExternalInterfaces, idx2); + sourceHardwareAddress = _SCNetworkInterfaceGetHardwareAddress(sourceInterface); + targetHardwareAddress = _SCNetworkInterfaceGetHardwareAddress(targetInterface); + if (_SC_CFEqual(sourceHardwareAddress, targetHardwareAddress)) { CFDictionaryAddValue(externalMapping, sourceInterface, targetInterface); CFArrayRemoveValueAtIndex(targetExternalInterfaces, idx2); + matched = TRUE; break; } } + if (matched) { + // proceed to next source interface + continue; + } - if (!CFDictionaryContainsKey(externalMapping, sourceInterface)) { - // Create new mappings for external source interfaces which don't exist in the target - type = _SCNetworkInterfaceGetIOInterfaceType(sourceInterface); + for (CFIndex idx2 = 0; idx2 < targetExternalInterfaceCount; idx2++) { + targetInterface = CFArrayGetValueAtIndex(targetExternalInterfaces, idx2); - cfMaxTargetUnit = CFDictionaryGetValue(interfaceTypeToMaxUnitMapping, type); - if (cfMaxTargetUnit != NULL) { - CFNumberGetValue(cfMaxTargetUnit, kCFNumberIntType, &maxTargetUnit); - newTargetUnit = maxTargetUnit + 1; - } else { - newTargetUnit = 0; + if (_SCNetworkConfigurationIsInterfaceNamerMappable(sourceInterface, targetInterface, TRUE)) { + CFDictionaryAddValue(externalMapping, sourceInterface, targetInterface); + CFArrayRemoveValueAtIndex(targetExternalInterfaces, idx2); + matched = TRUE; + break; } + } + if (matched) { + // proceed to next source interface + continue; + } - cfMaxTargetUnit = CFNumberCreate(NULL, kCFNumberIntType, &newTargetUnit); - CFDictionarySetValue(interfaceTypeToMaxUnitMapping, type, cfMaxTargetUnit); + // Create new mappings for external source interfaces which don't exist in the target + type = _SCNetworkInterfaceGetIOInterfaceType(sourceInterface); - targetInterface = (SCNetworkInterfaceRef)__SCNetworkInterfaceCreateCopy(NULL, sourceInterface, NULL, NULL); + cfMaxTargetUnit = CFDictionaryGetValue(interfaceTypeToMaxUnitMapping, type); + if (cfMaxTargetUnit != NULL) { + CFNumberGetValue(cfMaxTargetUnit, kCFNumberIntType, &maxTargetUnit); + newTargetUnit = maxTargetUnit + 1; + } else { + newTargetUnit = 0; + } - SC_log(LOG_DEBUG, "sourceInterface: %p, target Interface: %p", sourceInterface, targetInterface); + cfMaxTargetUnit = CFNumberCreate(NULL, kCFNumberIntType, &newTargetUnit); + CFDictionarySetValue(interfaceTypeToMaxUnitMapping, type, cfMaxTargetUnit); - currentInterfaceUnit = _SCNetworkInterfaceGetIOInterfaceUnit(targetInterface); - if (!isA_CFNumber(currentInterfaceUnit) || - !CFEqual(currentInterfaceUnit, cfMaxTargetUnit)) { - // Update the interface unit - __SCNetworkInterfaceSetIOInterfaceUnit(targetInterface, cfMaxTargetUnit); - } + targetInterface = (SCNetworkInterfaceRef)__SCNetworkInterfaceCreateCopy(NULL, sourceInterface, NULL, NULL); - CFDictionaryAddValue(externalMapping, sourceInterface, targetInterface); + SC_log(LOG_INFO, "sourceInterface: %p, target Interface: %p", sourceInterface, targetInterface); - CFRelease(targetInterface); - targetInterface = NULL; - CFRelease(cfMaxTargetUnit); - cfMaxTargetUnit = NULL; + currentInterfaceUnit = _SCNetworkInterfaceGetIOInterfaceUnit(targetInterface); + if (!isA_CFNumber(currentInterfaceUnit) || + !CFEqual(currentInterfaceUnit, cfMaxTargetUnit)) { + // Update the interface unit + __SCNetworkInterfaceSetIOInterfaceUnit(targetInterface, cfMaxTargetUnit); } + + CFDictionaryAddValue(externalMapping, sourceInterface, targetInterface); + + CFRelease(targetInterface); + targetInterface = NULL; + CFRelease(cfMaxTargetUnit); + cfMaxTargetUnit = NULL; + } done: if (sourceExternalInterfaces != NULL) { @@ -1055,7 +1133,9 @@ _SCNetworkConfigurationValidateInterface (const void *key, const void *value, vo (((bsdNameToBondServices != NULL) && !CFDictionaryContainsKey(bsdNameToBondServices, bsdName))) && (((bsdNameToVLANServices != NULL) && !CFDictionaryContainsKey(bsdNameToVLANServices, bsdName)))) { // Not a virtual interface - SC_log(LOG_INFO, "No real interface with BSD name (%@) for service", bsdName); + SC_log(LOG_NOTICE, + "No real interface with BSD name (%@) for service", + bsdName); if (repair) { CFArrayAppendValue(interfaceToBeRemoved, serviceInterface); @@ -1070,14 +1150,18 @@ _SCNetworkConfigurationValidateInterface (const void *key, const void *value, vo serviceInterfaceUserDefinedName = __SCNetworkInterfaceGetUserDefinedName(serviceInterface); if (!__SCNetworkConfigurationInterfaceNameIsEquiv(interfaceUserDefinedName, serviceInterfaceUserDefinedName)) { - SC_log(LOG_INFO, "Interface user defined name (%@) doesn't match service/interface user defined name: %@", + SC_log(LOG_NOTICE, + "Interface user defined name (%@) doesn't match service/interface user defined name: %@", interfaceUserDefinedName, serviceInterfaceUserDefinedName); *ctx->isValid = FALSE; // Check if the service interface name is set to localized key if (isA_CFArray(interfacePreserveServiceInformation) != NULL && __SCNetworkInterfaceMatchesName(interfaceUserDefinedName, serviceInterfaceUserDefinedName)) { - SC_log(LOG_NOTICE, "serviceInterfaceUserDefinedName: %@ is the localized key for interface name: %@", serviceInterfaceUserDefinedName, interfaceUserDefinedName); + SC_log(LOG_NOTICE, + "serviceInterfaceUserDefinedName: %@ is the localized key for interface name: %@", + serviceInterfaceUserDefinedName, + interfaceUserDefinedName); CFArrayAppendValue(interfacePreserveServiceInformation, serviceInterface); } // Add service interface to the interfaceToBeReplaced list @@ -1132,18 +1216,18 @@ _SCNetworkConfigurationCreateBuiltinInterfaceServices(SCPreferencesRef pref, mappingBSDNameToInterface = __SCNetworkInterfaceCreateMappingUsingBSDName(interfaces); CFRelease(interfaces); - if (isA_CFDictionary(mappingBSDNameToInterface) == NULL) { + if (!isA_CFDictionary(mappingBSDNameToInterface)) { goto done; } interfaces = __SCNetworkServiceCopyAllInterfaces(pref); if (interfaces == NULL) { - SC_log(LOG_INFO, "No interfaces"); + SC_log(LOG_NOTICE, "No [service] interfaces"); goto done; } mappingServiceBSDNameToInterface = __SCNetworkInterfaceCreateMappingUsingBSDName(interfaces); CFRelease(interfaces); - if (isA_CFDictionary(mappingServiceBSDNameToInterface) == NULL) { + if (!isA_CFDictionary(mappingServiceBSDNameToInterface)) { goto done; } @@ -1161,7 +1245,7 @@ _SCNetworkConfigurationCreateBuiltinInterfaceServices(SCPreferencesRef pref, interface = CFArrayGetValueAtIndex(interfacesWithoutService, idx); if (!__SCNetworkServiceCreate(pref, interface, NULL)) { - SC_log(LOG_INFO, "Could not add service for interface: %@", interface); + SC_log(LOG_NOTICE, "Could not create service for interface: %@", interface); success = FALSE; } } @@ -1197,13 +1281,13 @@ add_service(const void *value, void *context) } service = SCNetworkServiceCreate(prefs, interface); if (service == NULL) { - SC_log(LOG_INFO, "Could not create new service"); + SC_log(LOG_NOTICE, "Could not create new service"); goto done; } if (!SCNetworkServiceEstablishDefaultConfiguration(service)) { + SC_log(LOG_NOTICE, "SCNetworkServiceEstablishDefaultConfiguration() failed"); SCNetworkServiceRemove(service); - SC_log(LOG_INFO, "SCNetworkServiceEstablishDefaultConfiguration() failed"); goto done; } @@ -1227,14 +1311,14 @@ add_service(const void *value, void *context) // Add service to current set currentSet = SCNetworkSetCopyCurrent(prefs); if (currentSet == NULL) { + SC_log(LOG_NOTICE, "Could not find current set"); SCNetworkServiceRemove(service); - SC_log(LOG_INFO, "Could not find current set"); goto done; } if (!SCNetworkSetAddService(currentSet, service)) { + SC_log(LOG_NOTICE, "Could not add service to current set"); SCNetworkServiceRemove(service); - SC_log(LOG_INFO, "Could not add service to current set"); goto done; } @@ -1327,7 +1411,7 @@ _SCNetworkConfigurationRepairUsingPreferences(SCPreferencesRef prefs, return FALSE; } // Backup current preferences before making changes - __SCNetworkConfigurationBackup(prefs); + __SCNetworkConfigurationBackup(prefs, CFSTR("pre-repair"), prefs); serviceList = SCNetworkServiceCopyAll(prefs); CFArrayApplyFunction(serviceList, CFRangeMake(0, CFArrayGetCount(serviceList)), create_bsd_name_service_protocol_mapping, context); @@ -1364,7 +1448,7 @@ validate_bridge(const void *value, void *context) } if (CFArrayGetCount(memberInterfacesMutable) == 0) { - SC_log(LOG_INFO, "Removing invalid bridge configuration: %@", bridge); + SC_log(LOG_NOTICE, "Removing bridge w/no member interfaces: %@", bridge); SCBridgeInterfaceRemove(bridge); } else { SCBridgeInterfaceSetMemberInterfaces(bridge, memberInterfacesMutable); @@ -1399,7 +1483,7 @@ validate_bond(const void *value, void *context) } if (CFArrayGetCount(memberInterfacesMutable) == 0) { - SC_log(LOG_INFO, "Removing invalid bond configuration: %@", bond); + SC_log(LOG_NOTICE, "Removing bond w/no member interfaces: %@", bond); SCBondInterfaceRemove(bond); } else { SCBondInterfaceSetMemberInterfaces(bond, memberInterfacesMutable); @@ -1436,7 +1520,7 @@ validate_vlan(const void *value, void *context) done: if (!isValid) { - SC_log(LOG_INFO, "Removing invalid VLAN configuration: %@", vlan); + SC_log(LOG_NOTICE, "Removing VLAN w/no physical interface: %@", vlan); SCVLANInterfaceRemove(vlan); } } @@ -1473,21 +1557,43 @@ _SCNetworkConfigurationCheckValidityWithPreferences(SCPreferencesRef prefs, repairConfiguration = CFBooleanGetValue(repair); } } + + SC_log(LOG_INFO, + "%sbypassing system interfaces for %@", + _SCNetworkConfigurationBypassSystemInterfaces(prefs) ? "" : "not ", + prefs); + if (!_SCNetworkConfigurationBypassSystemInterfaces(prefs)) { _SCNetworkConfigurationSetBypassSystemInterfaces(prefs, TRUE); revertBypassSystemInterfaces = TRUE; } - /* + /* Check the validity by: - Comparing if the models are the same */ model = SCPreferencesGetValue(prefs, MODEL); + if (!isA_CFString(model)) { + SC_log(LOG_INFO, + "Configuration validity check: no \"Model\" property in preferences.plist" + "\n %@", + prefs); + } ni_model = SCPreferencesGetValue(ni_prefs, MODEL); - - if (isA_CFString(model) == NULL || isA_CFString(ni_model) == NULL || CFStringCompare(model, ni_model, 0) != kCFCompareEqualTo) { + if (!isA_CFString(ni_model)) { + SC_log(LOG_INFO, + "Configuration validity check: no \"Model\" property in NetworkInterfaces.plist" + "\n %@", + ni_prefs); + } + if (isA_CFString(model) && isA_CFString(ni_model) && !CFEqual(model, ni_model)) { isValid = FALSE; - SC_log(LOG_INFO, "Model names do not match in preferences.plist and NetworkInterfaces.plist"); + SC_log(LOG_NOTICE, + "Configuration validity check: model names do not match!" + "\n %@" + "\n %@", + prefs, + ni_prefs); goto done; } @@ -1498,17 +1604,22 @@ _SCNetworkConfigurationCheckValidityWithPreferences(SCPreferencesRef prefs, __SCNetworkInterfaceCreateMappingUsingBSDName(SCPreferencesRef prefs); */ interfaces = __SCNetworkInterfaceCopyStoredWithPreferences(ni_prefs); - if (!isA_CFArray(interfaces)) { - if (interfaces != NULL) CFRelease(interfaces); - SC_log(LOG_NOTICE, "No interfaces"); + if (interfaces == NULL) { + SC_log(LOG_NOTICE, + "Configuration validity check: no network interfaces!" + "\n %@", + ni_prefs); isValid = FALSE; goto done; } mappingBSDNameToInterface = __SCNetworkInterfaceCreateMappingUsingBSDName(interfaces); CFRelease(interfaces); - if (isA_CFDictionary(mappingBSDNameToInterface) == NULL) { + if (!isA_CFDictionary(mappingBSDNameToInterface)) { isValid = FALSE; - SC_log(LOG_INFO, "No BSD name to interface mapping"); + SC_log(LOG_NOTICE, + "Configuration validity check: no BSD name to network interface mapping!" + "\n %@", + ni_prefs); goto done; } @@ -1516,14 +1627,20 @@ _SCNetworkConfigurationCheckValidityWithPreferences(SCPreferencesRef prefs, if (!isA_CFArray(interfaces)) { if (interfaces != NULL) CFRelease(interfaces); isValid = FALSE; - SC_log(LOG_INFO, "No interfaces"); + SC_log(LOG_NOTICE, + "Configuration validity check: no service interfaces!" + "\n %@", + prefs); goto done; } mappingServiceBSDNameToInterface = __SCNetworkInterfaceCreateMappingUsingBSDName(interfaces); CFRelease(interfaces); - if (isA_CFDictionary(mappingServiceBSDNameToInterface) == NULL) { + if (!isA_CFDictionary(mappingServiceBSDNameToInterface)) { isValid = FALSE; - SC_log(LOG_INFO, "No Service BSD name to interface mapping"); + SC_log(LOG_NOTICE, + "Configuration validity check: no BSD name to service interface mapping!" + "\n %@", + prefs); goto done; } @@ -1553,7 +1670,12 @@ _SCNetworkConfigurationCheckValidityWithPreferences(SCPreferencesRef prefs, CFDictionaryApplyFunction(mappingServiceBSDNameToInterface, _SCNetworkConfigurationValidateInterface, &context); if (!isValid) { - SC_log(LOG_INFO, "mismatch between interface names in NetworkInterfaces.plist and preferences.plist"); + SC_log(LOG_NOTICE, + "Configuration validity check: mismatch between interface names in NetworkInterfaces.plist and preferences.plist!" + "\n %@" + "\n %@", + prefs, + ni_prefs); if (repairConfiguration) { isValid = _SCNetworkConfigurationRepairUsingPreferences(prefs, &context); if (!isValid) { @@ -1561,40 +1683,47 @@ _SCNetworkConfigurationCheckValidityWithPreferences(SCPreferencesRef prefs, } // Save the changes if repair fixed an invalid configuration if (!SCPreferencesCommitChanges(prefs)) { - SC_log(LOG_INFO, "SCPreferencesCommitChanges() failed"); + SC_log(LOG_NOTICE, "SCPreferencesCommitChanges() failed"); } } else { goto done; } } + /* - Check if all the network services mentioned in the SCNetworkSet are actually present in the SCNetworkService array */ - allServices = SCNetworkServiceCopyAll(prefs); - if (isA_CFArray(allServices) == NULL) { + if (!isA_CFArray(allServices)) { isValid = FALSE; - SC_log(LOG_INFO, "No services"); + SC_log(LOG_NOTICE, + "Configuration validity check: no services!" + "\n %@", + prefs); goto done; } allSets = SCNetworkSetCopyAll(prefs); - if (isA_CFArray(allSets) == NULL) { + if (!isA_CFArray(allSets)) { isValid = FALSE; - SC_log(LOG_INFO, "No sets"); + SC_log(LOG_NOTICE, + "Configuration validity check: no sets!" + "\n %@", + prefs); goto done; } for (CFIndex idx = 0; ((idx < CFArrayGetCount(allSets)) && isValid); idx++) { SCNetworkSetRef set = CFArrayGetValueAtIndex(allSets, idx); - if (isA_SCNetworkSet(set) == NULL) { - SC_log(LOG_INFO, "No set"); - continue; - } setServices = SCNetworkSetCopyServices(set); if (setServices == NULL) { - SC_log(LOG_INFO, "No services"); + SC_log(LOG_NOTICE, + "Configuration validity check: set w/no services!" + "\n %@" + "\n %@", + prefs, + set); continue; } for (CFIndex idx2 = 0; idx2 < CFArrayGetCount(setServices); idx2++) { @@ -1602,7 +1731,8 @@ _SCNetworkConfigurationCheckValidityWithPreferences(SCPreferencesRef prefs, if (!CFArrayContainsValue(allServices, CFRangeMake(0, CFArrayGetCount(allServices)), service)) { isValid = FALSE; - SC_log(LOG_INFO, "All network services in the network set are not present in SCNetworkService array"); + SC_log(LOG_NOTICE, + "All network services in the network set are not present in SCNetworkService array"); break; } } @@ -1619,7 +1749,10 @@ _SCNetworkConfigurationCheckValidityWithPreferences(SCPreferencesRef prefs, SCNetworkServiceRef service = CFArrayGetValueAtIndex(setServiceOrder, idx2); if (!CFArrayContainsValue(setServiceOrder, CFRangeMake(0, CFArrayGetCount(setServiceOrder)), service) && !CFArrayContainsValue(allServices, CFRangeMake(0, CFArrayGetCount(allServices)), service)) { - SC_log(LOG_INFO, "Service: %@ is not present in the service order for set %@", service, set); + SC_log(LOG_NOTICE, + "Service: %@ is not present in the service order for set %@", + service, + set); break; } } @@ -1712,7 +1845,7 @@ _SCNetworkConfigurationCheckValidity(CFURLRef configDir, CFDictionaryRef options char prefsStr[PATH_MAX]; if (configDir == NULL) { - SC_log(LOG_INFO, "Migration files not found in directory: %@", + SC_log(LOG_NOTICE, "Migration files not found in directory: %@", (configDir == NULL) ? CFSTR("NULL") : CFURLGetString(configDir)); goto done; } @@ -1801,7 +1934,7 @@ _SCNetworkConfigurationCollectInterfaceStorageEntity(const void *key, const void SCNetworkInterfaceRef targetInterface = (SCNetworkInterfaceRef)value; if (CFArrayContainsValue(ctx->externalInterfaceList, CFRangeMake(0, CFArrayGetCount(ctx->externalInterfaceList)), targetInterface)) { - SC_log(LOG_INFO, "Target interface (%@) already exists, not adding to NetworkInterfaces.plist", targetInterface); + SC_log(LOG_NOTICE, "Target interface (%@) already exists, not adding to NetworkInterfaces.plist", targetInterface); return; // If the target interface already exists then do not add it to NetworkInterfaces.plist } ctx->foundNewInterfaces = TRUE; @@ -1824,14 +1957,14 @@ _SCNetworkMigrationCreateNetworkInterfaceArray(SCPreferencesRef ni_prefs, CFDict CFMutableArrayRef networkInterfaceList = NULL; if (ni_prefs == NULL) { - SC_log(LOG_INFO, "No NetworkInterfaces.plist"); + SC_log(LOG_NOTICE, "No NetworkInterfaces.plist"); return NULL; } if_list = SCPreferencesGetValue(ni_prefs, INTERFACES); if (!isA_CFArray(if_list) || ((count = CFArrayGetCount(if_list)) == 0)) { - SC_log(LOG_INFO, "No interfaces"); + SC_log(LOG_NOTICE, "No interfaces"); return NULL; } @@ -1847,7 +1980,7 @@ _SCNetworkMigrationCreateNetworkInterfaceArray(SCPreferencesRef ni_prefs, CFDict } if (!isA_CFDictionary(externalMapping)) { - SC_log(LOG_INFO, "No external mapping"); + // if no external mapping goto done; } @@ -1879,12 +2012,12 @@ SCNetworkMigrationMapSourceToTargetName(const void *key, const void *value, void CFStringRef targetBSDName = NULL; sourceBSDName = SCNetworkInterfaceGetBSDName(interfaceKey); - if (isA_CFString(sourceBSDName) == NULL) { + if (!isA_CFString(sourceBSDName)) { return; } targetBSDName = SCNetworkInterfaceGetBSDName(interfaceValue); - if (isA_CFString(targetBSDName) == NULL) { + if (!isA_CFString(targetBSDName)) { return; } @@ -2015,7 +2148,7 @@ _SCNetworkMigrationCreateSetMapping(SCPreferencesRef sourcePrefs, CFRelease(targetSet); } else { - SC_log(LOG_ERR, "Number of sets in the target should be at least 1, but is found to be %ld", targetCount); + SC_log(LOG_NOTICE, "Number of sets in the target should be at least 1, but is found to be %ld", targetCount); goto done; } } @@ -2058,12 +2191,6 @@ _SCNetworkMigrationCreateSetMapping(SCPreferencesRef sourcePrefs, CFRelease(currentSourceSet); } - if (setMapping != NULL) { - SC_log(LOG_NOTICE, "Set mapping: %@", setMapping); - } else { - SC_log(LOG_INFO, "Set mapping: NULL"); - } - return setMapping; } @@ -2095,17 +2222,17 @@ _SCNetworkMigrationCreateServiceMappingUsingBSDMapping(SCPreferencesRef sourcePr // We need BSD Mapping to successfully create service mapping if (bsdNameMapping == NULL) { - SC_log(LOG_INFO, "No BSD name mapping"); + SC_log(LOG_NOTICE, "No BSD name mapping"); goto done; } sourceSCNetworkServices = SCNetworkServiceCopyAll(sourcePrefs); - if (isA_CFArray(sourceSCNetworkServices) == NULL) { - SC_log(LOG_INFO, "No source network services"); + if (!isA_CFArray(sourceSCNetworkServices)) { + SC_log(LOG_NOTICE, "No source network services"); goto done; } targetSCNetworkServices = SCNetworkServiceCopyAll(targetPrefs); - if (isA_CFArray(targetSCNetworkServices) == NULL) { - SC_log(LOG_INFO, "No target network services"); + if (!isA_CFArray(targetSCNetworkServices)) { + SC_log(LOG_NOTICE, "No target network services"); goto done; } @@ -2129,7 +2256,7 @@ _SCNetworkMigrationCreateServiceMappingUsingBSDMapping(SCPreferencesRef sourcePr sourceInterface = SCNetworkServiceGetInterface(sourceService); if (sourceInterface == NULL) { - SC_log(LOG_INFO, "No source interface"); + SC_log(LOG_NOTICE, "No source interface"); continue; } @@ -2138,8 +2265,8 @@ _SCNetworkMigrationCreateServiceMappingUsingBSDMapping(SCPreferencesRef sourcePr (CFEqual(sourceInterfaceType, kSCValNetInterfaceTypeVPN) || CFEqual(sourceInterfaceType, kSCValNetInterfaceTypePPP))) { sourceInterfaceSubType = __SCNetworkInterfaceGetEntitySubType(sourceInterface); - if (isA_CFString(sourceInterfaceSubType) == NULL) { - SC_log(LOG_INFO, "No source interface SubType"); + if (!isA_CFString(sourceInterfaceSubType)) { + SC_log(LOG_NOTICE, "No source interface SubType"); continue; } } @@ -2151,14 +2278,14 @@ _SCNetworkMigrationCreateServiceMappingUsingBSDMapping(SCPreferencesRef sourcePr sourceBSDName = SCNetworkInterfaceGetBSDName(sourceInterface); if (!isA_CFString(sourceBSDName) || !CFDictionaryContainsKey(bsdNameMapping, sourceBSDName)) { - SC_log(LOG_INFO, "No BSD name mapping for %@", + SC_log(LOG_NOTICE, "No BSD name mapping for %@", (sourceBSDName == NULL) ? CFSTR("NULL") : sourceBSDName); continue; } bsdNameMapTarget = CFDictionaryGetValue(bsdNameMapping, sourceBSDName); - if (isA_CFString(bsdNameMapTarget) == NULL) { - SC_log(LOG_INFO, "No BSD name mapping target"); + if (!isA_CFString(bsdNameMapTarget)) { + SC_log(LOG_NOTICE, "No BSD name mapping target"); continue; } } @@ -2174,19 +2301,19 @@ _SCNetworkMigrationCreateServiceMappingUsingBSDMapping(SCPreferencesRef sourcePr targetInterface = SCNetworkServiceGetInterface(targetService); if (targetInterface == NULL) { - SC_log(LOG_INFO, "No target interface"); + SC_log(LOG_NOTICE, "No target interface"); continue; } - SC_log(LOG_INFO, "targetInterface: %@", targetInterface); + SC_log(LOG_NOTICE, "targetInterface: %@", targetInterface); if (sourceBSDName != NULL) { targetBSDName = SCNetworkInterfaceGetBSDName(targetInterface); - if (isA_CFString(targetBSDName) == NULL) { - SC_log(LOG_INFO, "No target BSD name"); + if (!isA_CFString(targetBSDName)) { + SC_log(LOG_NOTICE, "No target BSD name"); continue; } if (CFEqual(targetBSDName, bsdNameMapTarget)) { - SC_log(LOG_INFO, "Removing target BSD name: %@", targetBSDName); + SC_log(LOG_NOTICE, "Removing target BSD name: %@", targetBSDName); CFDictionaryAddValue(serviceMapping, sourceService, targetService); CFArrayRemoveValueAtIndex(targetSCNetworkServicesMutable, idx2); break; @@ -2194,23 +2321,23 @@ _SCNetworkMigrationCreateServiceMappingUsingBSDMapping(SCPreferencesRef sourcePr } else { // Source Interface Type should be VPN targetInterfaceType = __SCNetworkInterfaceGetEntityType(targetInterface); - if ((isA_CFString(targetInterfaceType) == NULL) || + if ((!isA_CFString(targetInterfaceType)) || (!CFEqual(targetInterfaceType, kSCValNetInterfaceTypeVPN) && !CFEqual(targetInterfaceType, kSCValNetInterfaceTypePPP))) { - SC_log(LOG_INFO, "Unexpected target interface type: %@", + SC_log(LOG_NOTICE, "Unexpected target interface type: %@", (targetInterfaceType != NULL) ? targetInterfaceType : CFSTR("NULL")); continue; } targetInterfaceSubType = __SCNetworkInterfaceGetEntitySubType(targetInterface); - if (isA_CFString(targetInterfaceSubType) == NULL) { - SC_log(LOG_INFO, "No target interface SubType"); + if (!isA_CFString(targetInterfaceSubType)) { + SC_log(LOG_NOTICE, "No target interface SubType"); continue; } // Check if the target interface type and the target interface sub type match if (CFEqual(targetInterfaceType, sourceInterfaceType) && CFEqual(targetInterfaceSubType, sourceInterfaceSubType)) { - SC_log(LOG_INFO, "Removing target BSD Name: %@ for VPN", targetBSDName); + SC_log(LOG_NOTICE, "Removing target BSD Name: %@ for VPN", targetBSDName); CFDictionaryAddValue(serviceMapping, sourceService, targetService); CFArrayRemoveValueAtIndex(targetSCNetworkServicesMutable, idx2); break; @@ -2220,7 +2347,7 @@ _SCNetworkMigrationCreateServiceMappingUsingBSDMapping(SCPreferencesRef sourcePr // Check if sourceService has found a mapping or not, if not the create a NULL mapping to indicate // the this service needs to be added and not replaced if (!CFDictionaryContainsKey(serviceMapping, sourceService)) { - SC_log(LOG_INFO, "Service needs to be added: %@", sourceService); + SC_log(LOG_NOTICE, "Service needs to be added: %@", sourceService); CFDictionaryAddValue(serviceMapping, sourceService, kCFBooleanFalse); } } @@ -2240,12 +2367,6 @@ _SCNetworkMigrationCreateServiceMappingUsingBSDMapping(SCPreferencesRef sourcePr CFRelease(targetSCNetworkServicesMutable); } - if (serviceMapping != NULL) { - SC_log(LOG_NOTICE, "Service mapping: %@", serviceMapping); - } else { - SC_log(LOG_INFO, "Service mapping: NULL"); - } - return serviceMapping; } @@ -2276,7 +2397,7 @@ ServiceMigrationAddOrReplace(const void *key, const void *value, void *context) sourceServiceSetMapping = ctx->serviceSetMapping; if ((setMapping != NULL || sourceServiceSetMapping != NULL)) { - if (isA_SCNetworkService(targetService) != NULL) { + if (isA_SCNetworkService(targetService)) { SC_log(LOG_INFO, "Removing target service: %@", targetService); SCNetworkServiceRemove(targetService); } @@ -2295,10 +2416,25 @@ _SCNetworkMigrationDoServiceMigration(SCPreferencesRef sourcePrefs, SCPreference ServiceMigrationContext context; Boolean success = FALSE; + SC_log(LOG_INFO, + "_SCNetworkMigrationDoServiceMigration() called" + "\n sourcePrefs = %@" + "\n targetPrefs = %@" + "\n serviceMapping = %@" + "\n bsdMapping = %@" + "\n setMapping = %@" + "\n serviceSetMapping = %@", + sourcePrefs, + targetPrefs, + serviceMapping, + bsdMapping, + setMapping, + serviceSetMapping); + if ((sourcePrefs == NULL) || (targetPrefs == NULL) || - (isA_CFDictionary(serviceMapping) == NULL) || - (isA_CFDictionary(bsdMapping) == NULL)) { + !isA_CFDictionary(serviceMapping) || + !isA_CFDictionary(bsdMapping)) { SC_log(LOG_INFO, "No sourcePrefs, targetPrefs, serviceMapping, or bsdMapping"); goto done; } @@ -2326,6 +2462,12 @@ _SCNetworkMigrationDoSystemMigration(SCPreferencesRef sourcePrefs, SCPreferences CFStringRef btmmDSIDPath; CFStringRef btmmPath; + SC_log(LOG_INFO, + "_SCNetworkMigrationDoSystemMigration() called" + "\n sourcePrefs = %@" + "\n targetPrefs = %@", + sourcePrefs, + targetPrefs); if ((sourcePrefs == NULL) || (targetPrefs == NULL)) { @@ -2335,18 +2477,21 @@ _SCNetworkMigrationDoSystemMigration(SCPreferencesRef sourcePrefs, SCPreferences hostname = SCPreferencesGetHostName(sourcePrefs); if (hostname != NULL) { SCPreferencesSetHostName(targetPrefs, hostname); + SC_log(LOG_NOTICE, " copied HostName"); } localHostname = _SCPreferencesCopyLocalHostName(sourcePrefs); if (localHostname != NULL) { SCPreferencesSetLocalHostName(targetPrefs, localHostname); CFRelease(localHostname); + SC_log(LOG_NOTICE, " copied LocalHostName"); } computerName = _SCPreferencesCopyComputerName(sourcePrefs, &nameEncoding); if (computerName != NULL) { SCPreferencesSetComputerName(targetPrefs, computerName, nameEncoding); CFRelease(computerName); + SC_log(LOG_NOTICE, " copied ComputerName"); } btmmPath = CFStringCreateWithFormat(NULL, NULL, @@ -2374,6 +2519,7 @@ _SCNetworkMigrationDoSystemMigration(SCPreferencesRef sourcePrefs, SCPreferences return TRUE; } + #if !TARGET_OS_IPHONE typedef struct { @@ -2412,7 +2558,7 @@ add_virtual_interface(const void *value, void *context) newInterface = __SCNetworkInterfaceCreateWithNIPreferencesUsingBSDName(NULL, ctx->ni_prefs, newInterfaceBSDName); if (newInterface != NULL) { - SC_log(LOG_INFO, "Adding interface to interfaceList: %@", newInterface); + SC_log(LOG_INFO, "adding interface to interfaceList: %@", newInterface); CFArrayAppendValue(interfaceList, newInterface); CFRelease(newInterface); } @@ -2449,7 +2595,7 @@ add_target_bridge(const void *key, const void *value, void *context) newBridge = SCBridgeInterfaceCreate(prefs); if (!__SCBridgeInterfaceSetMemberInterfaces(newBridge, newInterfaceList)) { - SC_log(LOG_INFO, "__SCBridgeInterfaceSetMemberInterfaces() failed"); + SC_log(LOG_NOTICE, "__SCBridgeInterfaceSetMemberInterfaces() failed"); } CFRelease(newInterfaceList); @@ -2477,7 +2623,7 @@ add_target_bridge(const void *key, const void *value, void *context) for (CFIndex idx = 0; idx < CFArrayGetCount(oldServiceList); idx++) { SCNetworkServiceRef oldService = CFArrayGetValueAtIndex(oldServiceList, idx); if (!__SCNetworkServiceMigrateNew(prefs, oldService, bridgeBSDNameMapping, setMapping, serviceSetMapping)) { - SC_log(LOG_INFO, "Could not migrate Bridge service: %@", oldService); + SC_log(LOG_NOTICE, "could not migrate bridge service: %@", oldService); } } done: @@ -2496,7 +2642,7 @@ _SCNetworkMigrationRemoveBridgeServices(SCPreferencesRef prefs) if ((bsdName != NULL) && (SCNetworkInterfaceGetInterfaceType(interface) == kSCNetworkInterfaceTypeBridge)) { - SC_log(LOG_INFO, "Removing service: %@", service); + SC_log(LOG_INFO, "removing service: %@", service); SCNetworkServiceRemove(service); } } @@ -2594,7 +2740,7 @@ _SCNetworkMigrationDoBridgeMigration (SCPreferencesRef sourcePrefs, for (CFIndex idx = 0; idx < CFArrayGetCount(allTargetBridges); idx++) { bridge = CFArrayGetValueAtIndex(allTargetBridges, idx); if (!SCBridgeInterfaceRemove(bridge)) { - SC_log(LOG_INFO, "SCBridgeInterfaceRemove() failed: %@", bridge); + SC_log(LOG_NOTICE, "SCBridgeInterfaceRemove() failed: %@", bridge); goto done; } } @@ -2651,7 +2797,7 @@ add_target_bond(const void *key, const void *value, void *context) newBond = SCBondInterfaceCreate(prefs); if (!__SCBondInterfaceSetMemberInterfaces(newBond, newInterfaceList)) { - SC_log(LOG_INFO, "__SCBondInterfaceSetMemberInterfaces() failed"); + SC_log(LOG_NOTICE, "__SCBondInterfaceSetMemberInterfaces() failed"); } CFRelease(newInterfaceList); @@ -2682,7 +2828,7 @@ add_target_bond(const void *key, const void *value, void *context) for (CFIndex idx = 0; idx < CFArrayGetCount(oldServiceList); idx++) { SCNetworkServiceRef oldService = CFArrayGetValueAtIndex(oldServiceList, idx); if (!__SCNetworkServiceMigrateNew(prefs, oldService, bondBSDNameMapping, setMapping, serviceSetMapping)) { - SC_log(LOG_INFO, "Could not migrate Bond service: %@", oldService); + SC_log(LOG_NOTICE, "could not migrate bond service: %@", oldService); } } done: @@ -2797,7 +2943,7 @@ _SCNetworkMigrationDoBondMigration (SCPreferencesRef sourcePrefs, for (CFIndex idx = 0; idx < CFArrayGetCount(allTargetBonds); idx++) { bond = CFArrayGetValueAtIndex(allTargetBonds, idx); if (!SCBondInterfaceRemove(bond)) { - SC_log(LOG_INFO, "SCBondInterfaceRemove() failed: %@", bond); + SC_log(LOG_NOTICE, "SCBondInterfaceRemove() failed: %@", bond); goto done; } } @@ -2850,36 +2996,36 @@ add_target_vlan(const void *value, void *context) oldPhysicalInterface = SCVLANInterfaceGetPhysicalInterface(oldVLAN); if (oldPhysicalInterface == NULL) { - SC_log(LOG_INFO, "No old VLAN physical interface"); + SC_log(LOG_NOTICE, "No old VLAN physical interface"); goto done; } oldPhysicalInterfaceName = SCNetworkInterfaceGetBSDName(oldPhysicalInterface); if (oldPhysicalInterfaceName == NULL) { - SC_log(LOG_INFO, "No old VLAN physical interface name"); + SC_log(LOG_NOTICE, "No old VLAN physical interface name"); goto done; } newPhysicalInterfaceName = CFDictionaryGetValue(bsdMapping, oldPhysicalInterfaceName); if (newPhysicalInterfaceName == NULL) { - SC_log(LOG_INFO, "No new VLAN physical interface name"); + SC_log(LOG_NOTICE, "No new VLAN physical interface name"); goto done; } newPhysicalInterface = __SCNetworkInterfaceCreateWithNIPreferencesUsingBSDName(NULL, ctx->ni_prefs, newPhysicalInterfaceName); if (newPhysicalInterface == NULL) { - SC_log(LOG_INFO, "Could not create new VLAN physical interface"); + SC_log(LOG_NOTICE, "Could not create new VLAN physical interface"); goto done; } vlanTag = SCVLANInterfaceGetTag(oldVLAN); if (vlanTag == NULL) { - SC_log(LOG_INFO, "No old VLAN interface tag"); + SC_log(LOG_NOTICE, "No old VLAN interface tag"); goto done; } newVLAN = SCVLANInterfaceCreate(prefs, newPhysicalInterface, vlanTag); if (newVLAN == NULL) { - SC_log(LOG_INFO, "Could not create new VLAN interface"); + SC_log(LOG_NOTICE, "Could not create new VLAN interface"); goto done; } @@ -2906,7 +3052,7 @@ add_target_vlan(const void *value, void *context) for (CFIndex idx = 0; idx < CFArrayGetCount(oldServiceList); idx++) { oldService = CFArrayGetValueAtIndex(oldServiceList, idx); if (!__SCNetworkServiceMigrateNew(prefs, oldService, vlanBSDMapping, setMapping, serviceSetMapping)) { - SC_log(LOG_INFO, "Could not migrate VLAN service: %@", oldService); + SC_log(LOG_NOTICE, "Could not migrate VLAN service: %@", oldService); } } @@ -2998,12 +3144,7 @@ _SCNetworkMigrationDoVLANMigration (SCPreferencesRef sourcePrefs, vlan = CFArrayGetValueAtIndex(allSourceVLAN, idx); CFStringRef vlanBSDName = SCNetworkInterfaceGetBSDName(vlan); SCNetworkInterfaceRef physicalInterface = SCVLANInterfaceGetPhysicalInterface(vlan); - CFStringRef physicalInterfaceName; - - SC_log(LOG_DEBUG, "physical VLAN interface: %@", physicalInterface); - - physicalInterfaceName = SCNetworkInterfaceGetBSDName(physicalInterface); - SC_log(LOG_DEBUG, "physical VLAN interface name: %@", physicalInterfaceName); + CFStringRef physicalInterfaceName = SCNetworkInterfaceGetBSDName(physicalInterface); // Add VLAN to be migrated if the mapping between interfaces exists if (CFDictionaryContainsKey(bsdMapping, physicalInterfaceName)) { @@ -3021,7 +3162,7 @@ _SCNetworkMigrationDoVLANMigration (SCPreferencesRef sourcePrefs, for (CFIndex idx = 0; idx < CFArrayGetCount(allTargetVLAN); idx++) { vlan = CFArrayGetValueAtIndex(allTargetVLAN, idx); if (!SCVLANInterfaceRemove(vlan)) { - SC_log(LOG_INFO, "SCVLANInterfaceRemove() failed: %@", vlan); + SC_log(LOG_NOTICE, "SCVLANInterfaceRemove() failed: %@", vlan); goto done; } } @@ -3060,21 +3201,21 @@ _SCNetworkMigrationDoVirtualNetworkInterfaceMigration(SCPreferencesRef sourcePre if (!_SCNetworkMigrationDoBridgeMigration(sourcePrefs, sourceNIPrefs, targetPrefs, targetNIPrefs, bsdMapping, setMapping, serviceSetMapping)) { - SC_log(LOG_INFO, "Bridge migration failed"); + SC_log(LOG_NOTICE, "Bridge migration failed"); } // Handle Bonds if (!_SCNetworkMigrationDoBondMigration(sourcePrefs, sourceNIPrefs, targetPrefs, targetNIPrefs, bsdMapping, setMapping, serviceSetMapping)) { - SC_log(LOG_INFO, "Bond migration failed"); + SC_log(LOG_NOTICE, "Bond migration failed"); } // Handle VLANs if (!_SCNetworkMigrationDoVLANMigration(sourcePrefs, sourceNIPrefs, targetPrefs, targetNIPrefs, bsdMapping, setMapping, serviceSetMapping)) { - SC_log(LOG_INFO, "VLAN migration failed"); + SC_log(LOG_NOTICE, "VLAN migration failed"); } return TRUE; } @@ -3099,6 +3240,7 @@ create_migrated_order(const void *value, void *context) if (*success == FALSE) { return; } + // Preserving the service order in the source configuration for the services // which were migrated into the target configuration for (CFIndex idx = 0; idx < CFArrayGetCount(targetServiceOrder); idx++) { @@ -3124,14 +3266,15 @@ create_non_migrated_service_list(const void *value, void *context) if (*success == FALSE) { return; } - // Adding all services not present in migratedServiceOrder into nonMigrated service - for (CFIndex idx = 0; idx < CFArrayGetCount(migratedServiceOrder); idx++) { - CFStringRef migratedServiceID = CFArrayGetValueAtIndex(migratedServiceOrder, idx); - if (CFEqual(targetServiceID, migratedServiceID)) { - return; - } + // Adding all services not present in migratedServiceOrder into nonMigrated service + if (CFArrayGetFirstIndexOfValue(migratedServiceOrder, + CFRangeMake(0, CFArrayGetCount(migratedServiceOrder)), + targetServiceID)) { + // if service already present + return; } + service = SCNetworkServiceCopy(prefs, targetServiceID); if (service == NULL) { *success = FALSE; @@ -3258,6 +3401,7 @@ _SCNetworkConfigurationMigrateConfiguration(CFURLRef sourceDir, CFURLRef targetD char sourcePreferencesFileStr[PATH_MAX]; CFStringRef sourcePreferencesFileString = NULL; SCPreferencesRef sourcePrefs = NULL; + CFStringRef suffix; CFArrayRef targetConfigurationFiles = NULL; // Path to the target configuration files where migration will take place to Boolean targetConfigurationFilesPresent; CFStringRef targetModel = NULL; @@ -3272,9 +3416,16 @@ _SCNetworkConfigurationMigrateConfiguration(CFURLRef sourceDir, CFURLRef targetD Boolean isUpgradeScenario = FALSE; CFMutableDictionaryRef validityOptions = NULL; + SC_log(LOG_INFO, + "_SCNetworkConfigurationMigrateConfiguration() called" + "\n sourceDir = %@" + "\n targetDir = %@", + sourceDir, + targetDir); + // Check if configuration files exist in sourceDir - if (!__SCNetworkConfigurationMigrateConfigurationFilesPresent(sourceDir, &sourceConfigurationFiles)) { - SC_log(LOG_INFO, "sourceDir: (%@) doesn't contain configuration files", sourceDir); + if (!__SCNetworkConfigurationMigrateConfigurationFilesPresent(sourceDir, &sourceConfigurationFiles, TRUE)) { + SC_log(LOG_NOTICE, "sourceDir: (%@) missing configuration files", sourceDir); goto done; } @@ -3299,13 +3450,14 @@ _SCNetworkConfigurationMigrateConfiguration(CFURLRef sourceDir, CFURLRef targetD goto done; } - targetConfigurationFilesPresent = __SCNetworkConfigurationMigrateConfigurationFilesPresent(targetDir, &targetConfigurationFiles); + targetConfigurationFilesPresent = __SCNetworkConfigurationMigrateConfigurationFilesPresent(targetDir, &targetConfigurationFiles, FALSE); if (!targetConfigurationFilesPresent) { + // if the expected configuration files are not present in the target directory if (targetConfigurationFiles == NULL) { - SC_log(LOG_DEBUG, "targetConfigurationFiles is NULL"); + // but we don't know what files are needed (no target URL) + SC_log(LOG_NOTICE, "targetConfigurationFiles is NULL"); goto done; } - SC_log(LOG_INFO, "targetDir: (%@) doesn't contain configuration files ... Need to create default configuration", targetDir); } targetPreferencesFile = CFArrayGetValueAtIndex(targetConfigurationFiles, PREFERENCES_PLIST_INDEX); @@ -3322,34 +3474,46 @@ _SCNetworkConfigurationMigrateConfiguration(CFURLRef sourceDir, CFURLRef targetD targetPreferencesFileString = CFStringCreateWithCString(NULL, targetPreferencesFileStr, kCFStringEncodingUTF8); targetNetworkInterfaceFileString = CFStringCreateWithCString(NULL, targetNetworkInterfaceFileStr, kCFStringEncodingUTF8); + SC_log(LOG_INFO, + "Migrating network configuration:" + "\n target configuration files %s present" + "\n target preferences.plist path = %@" + "\n target NetworkInterfaces.plist path = %@", + targetConfigurationFilesPresent ? "are" : "are not", + targetPreferencesFileString, + targetNetworkInterfaceFileString); + if (targetConfigurationFilesPresent) { targetPrefs = SCPreferencesCreate(NULL, PLUGIN_ID, targetPreferencesFileString); targetNetworkInterfacePrefs = SCPreferencesCreate(NULL, PLUGIN_ID, targetNetworkInterfaceFileString); if ((targetPrefs == NULL) || (targetNetworkInterfacePrefs == NULL)) { + SC_log(LOG_NOTICE, "Could not open target prefs/ni_prefs"); goto done; } } else { - targetPrefs = __SCNetworkCreateDefaultPref(targetPreferencesFileString); - targetNetworkInterfacePrefs = __SCPreferencesCreateNIPrefsFromPrefs(targetPrefs); + // create and populate a new preferences.plist + targetPrefs = SCPreferencesCreate(NULL, PLUGIN_ID, targetPreferencesFileString); + __SCNetworkPopulateDefaultPrefs(targetPrefs); - if ((targetPrefs == NULL) || (targetNetworkInterfacePrefs == NULL)) { - SC_log(LOG_DEBUG, "Could not create default configuration"); - goto done; - } + // create and populate a new NetworkInterfaces.plist + targetNetworkInterfacePrefs = SCPreferencesCreateCompanion(targetPrefs, INTERFACES_DEFAULT_CONFIG); + __SCNetworkPopulateDefaultNIPrefs(targetNetworkInterfacePrefs); } validityOptions = CFDictionaryCreateMutable(NULL, 0, &kCFTypeDictionaryKeyCallBacks, &kCFTypeDictionaryValueCallBacks); CFDictionaryAddValue(validityOptions, kSCNetworkConfigurationRepair, kCFBooleanTrue); - SC_log(LOG_DEBUG, "sourcePreferenceFileString: %@\n" - "sourceNetworkInterfaceFileString:%@\n" - "targetPreferencesFileString:%@\n" - "targetNetworkInterfaceFileString:%@", - sourcePreferencesFileString, - sourceNetworkInterfaceFileString, - targetPreferencesFileString, - targetNetworkInterfaceFileString); + SC_log(LOG_INFO, + "Migrating network configuration:" + "\n sourcePrefs = %@" + "\n sourceNetworkInterfacePrefs = %@" + "\n targetPrefs = %@" + "\n targetNetworkInterfacePrefs = %@", + sourcePrefs, + sourceNetworkInterfacePrefs, + targetPrefs, + targetNetworkInterfacePrefs); // Setting Bypass Interface to avoid looking at system interfaces _SCNetworkConfigurationSetBypassSystemInterfaces(sourcePrefs, TRUE); @@ -3359,6 +3523,28 @@ _SCNetworkConfigurationMigrateConfiguration(CFURLRef sourceDir, CFURLRef targetD targetModel = SCPreferencesGetValue(targetPrefs, MODEL); isUpgradeScenario = (isA_CFString(sourceModel) && isA_CFString(targetModel) && CFStringCompare(sourceModel, targetModel, 0) == kCFCompareEqualTo); + if (isUpgradeScenario) { + SC_log(LOG_NOTICE, "Migrating network configuration: performing an \"upgrade\""); + } else { + SC_log(LOG_NOTICE, "Migrating network configuration: performing a \"migration\""); + } + + // create backup of migration source + suffix = CFStringCreateWithFormat(NULL, NULL, + CFSTR("pre-%s-source"), + isUpgradeScenario ? "upgrade" : "migration"); + __SCNetworkConfigurationBackup(sourcePrefs, suffix, targetPrefs); + __SCNetworkConfigurationBackup(sourceNetworkInterfacePrefs, suffix, targetPrefs); + CFRelease(suffix); + + // create backup of migration target + suffix = CFStringCreateWithFormat(NULL, NULL, + CFSTR("pre-%s-%starget"), + isUpgradeScenario ? "upgrade" : "migration", + targetConfigurationFilesPresent ? "" : "new-"); + __SCNetworkConfigurationBackup(targetPrefs, suffix, targetPrefs); + __SCNetworkConfigurationBackup(targetNetworkInterfacePrefs, suffix, targetPrefs); + CFRelease(suffix); // Create services for builtin interfaces at source if they don't exist (void)_SCNetworkConfigurationCreateBuiltinInterfaceServices(sourcePrefs, sourceNetworkInterfacePrefs); @@ -3366,7 +3552,7 @@ _SCNetworkConfigurationMigrateConfiguration(CFURLRef sourceDir, CFURLRef targetD if (!_SCNetworkConfigurationCheckValidityWithPreferences(sourcePrefs, sourceNetworkInterfacePrefs, validityOptions)) { - SC_log(LOG_INFO, "Source configuration not valid"); + SC_log(LOG_NOTICE, "Source configuration not valid"); goto skipServiceMigration; } // Only call this function if configuration files were not created by default @@ -3376,17 +3562,24 @@ _SCNetworkConfigurationMigrateConfiguration(CFURLRef sourceDir, CFURLRef targetD if (!_SCNetworkConfigurationCheckValidityWithPreferences(targetPrefs, targetNetworkInterfacePrefs, validityOptions)) { - SC_log(LOG_INFO, "Target configuration not valid"); + SC_log(LOG_NOTICE, "Target configuration not valid"); goto skipServiceMigration; } } - SC_log(LOG_DEBUG, "This is %san upgrade scenario", isUpgradeScenario ? "" : "not "); // Upgrade scenario, source and target models match if (isUpgradeScenario) { Boolean foundNewInterface = FALSE; // Create SCPreferences to copy the target prefs - SCPreferencesRef upgradeSourcePrefs = SCPreferencesCreate(NULL, CFSTR("Upgrade Source Prefs"), NULL); - SCPreferencesRef upgradeSourceNIPrefs = SCPreferencesCreate(NULL, CFSTR("Upgrade Source NI Prefs"), NULL); + SCPreferencesRef upgradeSourcePrefs = SCPreferencesCreate(NULL, CFSTR("Upgrade Source Prefs"), NULL); + SCPreferencesRef upgradeSourceNIPrefs = SCPreferencesCreate(NULL, CFSTR("Upgrade Source NI Prefs"), INTERFACES_DEFAULT_CONFIG); + + SC_log(LOG_INFO, + "Migrating network configuration:" + "\n upgradeSourcePrefs [temp] = %@" + "\n upgradeSourceNIPrefs [temp] = %@" + "\n Copying target --> upgrade, source --> target", + upgradeSourcePrefs, + upgradeSourceNIPrefs); // Content of target prefs CFDictionaryRef targetPrefsContent = SCPreferencesPathGetValue(targetPrefs, CFSTR("/")); @@ -3406,69 +3599,85 @@ _SCNetworkConfigurationMigrateConfiguration(CFURLRef sourceDir, CFURLRef targetD // Getting the mapping of the non builtin interfaces between source and target externalMapping = _SCNetworkConfigurationCopyExternalInterfaceMapping(upgradeSourceNIPrefs, targetNetworkInterfacePrefs); + SC_log(LOG_INFO, + "Upgradng, external interface mapping: %@", + externalMapping); newTargetNetworkInterfaceEntity = _SCNetworkMigrationCreateNetworkInterfaceArray(targetNetworkInterfacePrefs, externalMapping, &foundNewInterface); + + SC_log(LOG_INFO, + "Upgrading, %s new interfaces" + "\n newTargetNetworkInterfaceEntity = %@", + foundNewInterface ? "found" : "no", + newTargetNetworkInterfaceEntity); + if (foundNewInterface) { - if (isA_CFArray(newTargetNetworkInterfaceEntity) == NULL) { - SC_log(LOG_INFO, "newTargetNetworkInterfaceEntity is NULL or not of correct type"); + if (newTargetNetworkInterfaceEntity == NULL) { + SC_log(LOG_NOTICE, "Upgrading, failed w/no new interface list"); CFRelease(upgradeSourcePrefs); CFRelease(upgradeSourceNIPrefs); goto done; } - // Write new interface mapping to NetworkInterfaces.plist + + // add new interface mapping to NetworkInterfaces.plist if (!__SCNetworkInterfaceSaveStoredWithPreferences(targetNetworkInterfacePrefs, newTargetNetworkInterfaceEntity)) { - SC_log(LOG_INFO, "SCNetworkInterfaceSaveStoreWithPreferences: failed to update NetworkInterfaces.plist"); + SC_log(LOG_NOTICE, "Upgrading, failed to update NetworkInterfaces.plist"); CFRelease(upgradeSourcePrefs); CFRelease(upgradeSourceNIPrefs); goto done; } - // Create BSD Name Mapping to facilitate mapping of services + // create BSD name mapping to facilitate mapping of services bsdNameMapping = _SCNetworkMigrationCreateBSDNameMapping(NULL, externalMapping); serviceMapping = _SCNetworkMigrationCreateServiceMappingUsingBSDMapping(upgradeSourcePrefs, targetPrefs, bsdNameMapping); - _SCNetworkMigrationDoServiceMigration(upgradeSourcePrefs, targetPrefs, - serviceMapping, bsdNameMapping, - NULL, NULL); + _SCNetworkMigrationDoServiceMigration(upgradeSourcePrefs, + targetPrefs, + serviceMapping, + bsdNameMapping, + NULL, + NULL); } CFRelease(upgradeSourcePrefs); CFRelease(upgradeSourceNIPrefs); } else { builtinMapping = _SCNetworkConfigurationCopyBuiltinMapping(sourceNetworkInterfacePrefs, targetNetworkInterfacePrefs); + externalMapping = _SCNetworkConfigurationCopyExternalInterfaceMapping(sourceNetworkInterfacePrefs, targetNetworkInterfacePrefs); + SC_log(LOG_INFO, + "Migrating, external interface mapping: %@", + externalMapping); newTargetNetworkInterfaceEntity = _SCNetworkMigrationCreateNetworkInterfaceArray(targetNetworkInterfacePrefs, externalMapping, NULL); - if (isA_CFArray(newTargetNetworkInterfaceEntity) == NULL) { - SC_log(LOG_INFO, "newTargetNetworkInterfaceEntity is NULL or not of correct type"); + if (newTargetNetworkInterfaceEntity == NULL) { + SC_log(LOG_NOTICE, "Migrating, failed w/no new interface list"); goto done; } + // Write new interface mapping to NetworkInterfaces.plist if (!__SCNetworkInterfaceSaveStoredWithPreferences(targetNetworkInterfacePrefs, newTargetNetworkInterfaceEntity)) { - SC_log(LOG_INFO, "SCNetworkInterfaceSaveStoreWithPreferences: failed to update NetworkInterfaces.plist"); + SC_log(LOG_NOTICE, "Migrating, failed to update NetworkInterfaces.plist"); goto done; } - // Create BSD Name Mapping to facilitate mapping of services + + // create BSD name mapping to facilitate mapping of services bsdNameMapping = _SCNetworkMigrationCreateBSDNameMapping(builtinMapping, externalMapping); - if (isA_CFDictionary(bsdNameMapping) == NULL) { - SC_log(LOG_INFO, "BSD name mapping is NULL"); - goto done; - } - SC_log(LOG_DEBUG, "BSD Name Mapping: %@", bsdNameMapping); serviceMapping = _SCNetworkMigrationCreateServiceMappingUsingBSDMapping(sourcePrefs, targetPrefs, bsdNameMapping); if (serviceMapping == NULL) { goto done; } setMapping = _SCNetworkMigrationCreateSetMapping(sourcePrefs, targetPrefs); + sourceServiceSetMapping = _SCNetworkMigrationCreateServiceSetMapping(sourcePrefs); // Perform the migration of services if (!_SCNetworkMigrationDoServiceMigration(sourcePrefs, targetPrefs, serviceMapping, bsdNameMapping, setMapping, sourceServiceSetMapping)) { - SC_log(LOG_INFO, "SCNetworkMigrationDoServiceMigration: failed to complete successfully"); + SC_log(LOG_NOTICE, "SCNetworkMigrationDoServiceMigration(): service migration failed"); goto done; } @@ -3477,12 +3686,12 @@ _SCNetworkConfigurationMigrateConfiguration(CFURLRef sourceDir, CFURLRef targetD if (!_SCNetworkMigrationDoVirtualNetworkInterfaceMigration(sourcePrefs, sourceNetworkInterfacePrefs, targetPrefs, targetNetworkInterfacePrefs, bsdNameMapping, setMapping, sourceServiceSetMapping)) { - SC_log(LOG_INFO, "_SCNetworkMigrationDoVirtualNetworkInterfaceMigration: failed to complete successfully"); + SC_log(LOG_NOTICE, "SCNetworkMigrationDoServiceMigration(): virtual interface migration failed"); } #endif // !TARGET_OS_IPHONE // Migrate Service Order if (!_SCNetworkMigrationDoServiceOrderMigration(sourcePrefs, targetPrefs, setMapping)) { - SC_log(LOG_INFO, "_SCNetworkMigrationDoServiceOrderMigration: failed to complete successfully"); + SC_log(LOG_NOTICE, "SCNetworkMigrationDoServiceMigration(): service order migration failed"); } } @@ -3490,20 +3699,20 @@ skipServiceMigration: // Migrating System Information if (!isUpgradeScenario) { if (!_SCNetworkMigrationDoSystemMigration(sourcePrefs, targetPrefs)) { - SC_log(LOG_INFO, "_SCNetworkMigrationDoSystemMigration: failed to complete successfully"); + SC_log(LOG_NOTICE, "SCNetworkMigrationDoServiceMigration(): system setting migration failed"); } } if (!_SCNetworkConfigurationCheckValidityWithPreferences(targetPrefs, targetNetworkInterfacePrefs, validityOptions)) { - SC_log(LOG_INFO, "Migrated configuration not valid"); + SC_log(LOG_NOTICE, "Migrated configuration not valid"); goto done; } if (!SCPreferencesCommitChanges(targetPrefs)) { - SC_log(LOG_INFO, "SCPreferencesCommitChanges(target preferences.plist) failed: %s", SCErrorString(SCError())); + SC_log(LOG_NOTICE, "SCPreferencesCommitChanges(target preferences.plist) failed: %s", SCErrorString(SCError())); goto done; } if (!SCPreferencesCommitChanges(targetNetworkInterfacePrefs)) { - SC_log(LOG_INFO, "SCPreferencesCommitChanges(target NetworkInterfaces.plist) failed: %s", SCErrorString(SCError())); + SC_log(LOG_NOTICE, "SCPreferencesCommitChanges(target NetworkInterfaces.plist) failed: %s", SCErrorString(SCError())); goto done; } migrationSuccess = TRUE; @@ -3765,9 +3974,8 @@ _SCNetworkMigrationAreConfigurationsIdentical (CFURLRef configurationURL, sizeof(PREFS_DEFAULT_CONFIG_PLIST), FALSE, baseConfigURL); - if (!CFURLResourceIsReachable(configPreferencesURL, NULL)) { - SC_log(LOG_INFO, "No preferences.plist file"); + SC_log(LOG_NOTICE, "No preferences.plist file: %@", configPreferencesURL); goto done; } @@ -3776,9 +3984,8 @@ _SCNetworkMigrationAreConfigurationsIdentical (CFURLRef configurationURL, sizeof(INTERFACES_DEFAULT_CONFIG_PLIST), FALSE, baseConfigURL); - if (!CFURLResourceIsReachable(configNetworkInterfacesURL, NULL)) { - SC_log(LOG_INFO, "No NetworkInterfaces.plist file"); + SC_log(LOG_NOTICE, "No NetworkInterfaces.plist file: %@", configNetworkInterfacesURL); goto done; } @@ -3803,7 +4010,7 @@ _SCNetworkMigrationAreConfigurationsIdentical (CFURLRef configurationURL, baseExpectedConfigURL); if (!CFURLResourceIsReachable(expectedPreferencesURL, NULL)) { - SC_log(LOG_INFO, "No expected preferences.plist file"); + SC_log(LOG_NOTICE, "No expected preferences.plist file"); goto done; } @@ -3814,7 +4021,7 @@ _SCNetworkMigrationAreConfigurationsIdentical (CFURLRef configurationURL, baseExpectedConfigURL); if (!CFURLResourceIsReachable(expectedNetworkInterfaceURL, NULL)) { - SC_log(LOG_INFO, "No expected NetworkInterfaces.plist file"); + SC_log(LOG_NOTICE, "No expected NetworkInterfaces.plist file"); goto done; } @@ -3841,7 +4048,7 @@ done: expectedConfigPref == NULL || configNetworkInterfacePref == NULL || expectedNetworkInterfacePref == NULL) { - SC_log(LOG_INFO, "One of the preferences is NULL"); + SC_log(LOG_NOTICE, "One of the preferences is NULL"); isIdentical = FALSE; } else { isIdentical = (_SCNetworkMigrationAreServicesIdentical(configPref, expectedConfigPref) && diff --git a/SystemConfiguration.fproj/SCNetworkReachability.c b/SystemConfiguration.fproj/SCNetworkReachability.c index 5b57236..72f88e2 100644 --- a/SystemConfiguration.fproj/SCNetworkReachability.c +++ b/SystemConfiguration.fproj/SCNetworkReachability.c @@ -410,7 +410,7 @@ __SCNetworkReachabilityCreatePrivate(CFAllocatorRef allocator) /* initialize non-zero/NULL members */ MUTEX_INIT(&targetPrivate->lock); - if (_sc_log > 0) { + if (_sc_log > kSCLogDestinationFile) { snprintf(targetPrivate->log_prefix, sizeof(targetPrivate->log_prefix), "[%p] ", diff --git a/SystemConfiguration.fproj/SCNetworkService.c b/SystemConfiguration.fproj/SCNetworkService.c index c643116..a74c861 100644 --- a/SystemConfiguration.fproj/SCNetworkService.c +++ b/SystemConfiguration.fproj/SCNetworkService.c @@ -2442,7 +2442,7 @@ __SCNetworkServiceMigrateNew(SCPreferencesRef prefs, if (targetDeviceName != NULL) { // update mapping CFDictionarySetValue(interfaceEntityMutable, kSCPropNetInterfaceDeviceName, targetDeviceName); - ni_prefs = __SCPreferencesCreateNIPrefsFromPrefs(prefs); + ni_prefs = SCPreferencesCreateCompanion(prefs, INTERFACES_DEFAULT_CONFIG); ni_interface = __SCNetworkInterfaceCreateWithNIPreferencesUsingBSDName(NULL, ni_prefs, targetDeviceName); if (ni_interface != NULL) { userDefinedNameInterface = __SCNetworkInterfaceGetUserDefinedName(ni_interface); diff --git a/SystemConfiguration.fproj/SCNetworkSet.c b/SystemConfiguration.fproj/SCNetworkSet.c index 9679534..915b577 100644 --- a/SystemConfiguration.fproj/SCNetworkSet.c +++ b/SystemConfiguration.fproj/SCNetworkSet.c @@ -828,6 +828,7 @@ SCNetworkSetCopyServices(SCNetworkSetRef set) return NULL; } + path = SCPreferencesPathKeyCreateSetNetworkService(NULL, setPrivate->setID, NULL); dict = SCPreferencesPathGetValue(setPrivate->prefs, path); CFRelease(path); diff --git a/SystemConfiguration.fproj/SCP.c b/SystemConfiguration.fproj/SCP.c index 80181cf..b220ae6 100644 --- a/SystemConfiguration.fproj/SCP.c +++ b/SystemConfiguration.fproj/SCP.c @@ -142,6 +142,24 @@ __SCPreferencesPath(CFAllocatorRef allocator, } +__private_extern__ +Boolean +__SCPreferencesIsEmpty(SCPreferencesRef prefs) +{ + SCPreferencesPrivateRef prefsPrivate = (SCPreferencesPrivateRef)prefs; + + assert(prefs != NULL); + __SCPreferencesAccess(prefs); + + if ((prefsPrivate->prefs == NULL) || + (CFDictionaryGetCount(prefsPrivate->prefs) == 0)) { + return TRUE; + } + + return FALSE; +} + + __private_extern__ off_t __SCPreferencesPrefsSize(SCPreferencesRef prefs) @@ -185,21 +203,6 @@ __SCPreferencesUsingDefaultPrefs(SCPreferencesRef prefs) return isDefault; } -__private_extern__ -SCPreferencesRef -__SCPreferencesCreateNIPrefsFromPrefs(SCPreferencesRef prefs) -{ - SCPreferencesRef ni_prefs; - - // open [companion] NetworkInterfaces.plist - ni_prefs = SCPreferencesCreateCompanion(prefs, INTERFACES_DEFAULT_CONFIG); - - // if needed, populate - __SCNetworkPopulateDefaultNIPrefs(ni_prefs); - - return ni_prefs; -} - CFDataRef SCPreferencesGetSignature(SCPreferencesRef prefs) { diff --git a/SystemConfiguration.fproj/SCPCommit.c b/SystemConfiguration.fproj/SCPCommit.c index fa358df..7a2543c 100644 --- a/SystemConfiguration.fproj/SCPCommit.c +++ b/SystemConfiguration.fproj/SCPCommit.c @@ -177,7 +177,7 @@ SCPreferencesCommitChanges(SCPreferencesRef prefs) /* * check if the preferences should be removed */ - if (CFDictionaryGetCount(prefsPrivate->prefs) == 0) { + if (__SCPreferencesIsEmpty(prefs)) { CFBooleanRef val; /* if empty */ diff --git a/SystemConfiguration.fproj/SCPOpen.c b/SystemConfiguration.fproj/SCPOpen.c index ebaddeb..ee73ee8 100644 --- a/SystemConfiguration.fproj/SCPOpen.c +++ b/SystemConfiguration.fproj/SCPOpen.c @@ -600,7 +600,7 @@ __SCPreferencesAccess(SCPreferencesRef prefs) 0, &kCFTypeDictionaryKeyCallBacks, &kCFTypeDictionaryValueCallBacks); - prefsPrivate->changed = TRUE; + prefsPrivate->changed = FALSE; } SC_log(LOG_DEBUG, "SCPreferences() access: %s, size=%lld", @@ -712,25 +712,26 @@ SCPreferencesCreateWithOptions(CFAllocatorRef allocator, prefsPrivate = __SCPreferencesCreate(allocator, name, prefsID, authorizationData, options); if (prefsPrivate != NULL) { - const char *astr = ""; - const char *ostr = ""; + const char *opt_none = ""; + const char *opt_1 = opt_none; + const char *opt_2 = opt_none; if (options != NULL) { - ostr = "options"; + opt_2 = "options"; } if (authorization != NULL) { if (authorization == kSCPreferencesUseEntitlementAuthorization) { - astr = "entitlement"; + opt_1 = "entitlement"; } else { - astr = "authorization"; + opt_1 = "authorization"; } } SC_log(LOG_DEBUG, "create w/%s%s%s %@", - ostr, - ((ostr != "") && (astr != "")) ? " + " : "", - astr, + opt_2, + ((opt_2 != opt_none) && (opt_1 != opt_none)) ? " + " : "", + opt_1, prefsPrivate); } diff --git a/SystemConfiguration.fproj/SCPreferencesInternal.h b/SystemConfiguration.fproj/SCPreferencesInternal.h index af98043..8fe9c85 100644 --- a/SystemConfiguration.fproj/SCPreferencesInternal.h +++ b/SystemConfiguration.fproj/SCPreferencesInternal.h @@ -165,6 +165,9 @@ __SCPreferencesAddSessionKeys (SCPreferencesRef prefs); Boolean __SCPreferencesAddSession (SCPreferencesRef prefs); +Boolean +__SCPreferencesIsEmpty (SCPreferencesRef prefs); + void __SCPreferencesRemoveSession (SCPreferencesRef prefs); @@ -202,9 +205,6 @@ __SCPreferencesSetNetworkConfigurationFlags Boolean __SCPreferencesUsingDefaultPrefs (SCPreferencesRef prefs); -SCPreferencesRef -__SCPreferencesCreateNIPrefsFromPrefs (SCPreferencesRef prefs); - __END_DECLS #endif /* _SCPREFERENCESINTERNAL_H */ diff --git a/SystemConfiguration.fproj/SCPrivate.h b/SystemConfiguration.fproj/SCPrivate.h index b721acd..c3ec86c 100644 --- a/SystemConfiguration.fproj/SCPrivate.h +++ b/SystemConfiguration.fproj/SCPrivate.h @@ -30,6 +30,7 @@ #include #include #include +#include #include #include @@ -101,13 +102,17 @@ #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/os_log(3), - 2 if SC messages should be logged AND written to stdout/stderr - 3 if SC messages should be logged AND written to stdout/stderr (w/o timestamp) */ +/* framework debugging/logging variables */ +typedef CF_ENUM(int, _SCLogDestination) { + kSCLogDestinationFile = 0, // if SC messages should be written to stdout/stderr + kSCLogDestinationDefault = 1, // if SC messages should be logged w/os_log(3) + kSCLogDestinationBoth = 2, // if SC messages should be logged AND written to stdout/stderr + kSCLogDestinationBoth_NoTime = 3, // if SC messages should be logged AND written to stdout/stderr (w/o timestamp) +}; + +extern int _sc_debug; /* non-zero if debugging enabled */ +extern _SCLogDestination _sc_log; +extern int _sc_verbose; /* non-zero if verbose logging enabled */ /* notify(3) keys */ @@ -474,10 +479,6 @@ void SCLog (Boolean condition, of an os_log_t global (or a function that returns an os_log_t) *BEFORE* this header is #include'd. In that case, the noted log handle will be used. - - Also, by #define'ing SC_LOG_OR_PRINT, we will check the "_sc_log" - global to see if the messages should [also] be directed to stdout/stderr. - @param level The syslog(3 logging priority. @param __string The format string @result The specified message will be written to the unified logging system. @@ -490,57 +491,55 @@ void SCLog (Boolean condition, SC_LOG_HANDLE_TYPE os_log_t SC_LOG_HANDLE(void); #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) && ((__level > LOG_DEBUG) || _sc_debug)) || \ - os_log_type_enabled(__handle, __type)) { \ - __SC_Log(__level, \ - CFSTR( __format ), \ - __handle, \ - __type, \ - __format, \ - ## __VA_ARGS__); \ - } \ - } while (0) - #else // 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); \ - \ - os_log_with_type(__handle, __type, __format, ## __VA_ARGS__); \ - } while (0) - #endif // USE_SC_LOG_OR_PRINT -#endif // !SC_log + #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_enabled(__level, __handle, __type)) { \ + size_t __pack_size = os_log_pack_size(__format, ##__VA_ARGS__); \ + \ + _Pragma("clang diagnostic push") \ + _Pragma("clang diagnostic ignored \"-Wvla\"") \ + _Pragma("clang diagnostic ignored \"-Wgnu-statement-expression\"") \ + os_log_pack_decl(__pack, __pack_size); \ + os_log_pack_fill(__pack, __pack_size, errno, __format, ##__VA_ARGS__); \ + _Pragma("clang diagnostic pop") \ + \ + __SC_log_send(__level, __handle, __type, __pack); \ + } \ + } while (0) + +/*! + @function __SC_log_enabled + @discussion Checks to see whether a log message will be issued + @param level A syslog(3) logging priority. If less than 0, log message is multi-line + @param log The os_log_t handle (for logging) + @param type The os_log_type_t type (for logging) + */ +Boolean __SC_log_enabled (int level, + os_log_t log, + os_log_type_t type); /*! - @function __SC_Log - @discussion Issue a log message w/os_log(3) or printf(3). + @function __SC_log_send + @discussion Issue an os_log_pack message w/os_log(3), syslog(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) - stream. - */ -void __SC_Log (int level, - CFStringRef format_CF, - os_log_t log, - os_log_type_t type, - const char *format, - ...) CF_FORMAT_FUNCTION(2, 6) __attribute__((format(os_log, 5, 6))); + @param pack The os_log_pack_t message + */ +void __SC_log_send (int level, + os_log_t log, + os_log_type_t type, + os_log_pack_t pack); + +#endif // !SC_log /*! diff --git a/SystemConfiguration.fproj/SystemConfigurationInternal.h b/SystemConfiguration.fproj/SystemConfigurationInternal.h index a961d64..beed343 100644 --- a/SystemConfiguration.fproj/SystemConfigurationInternal.h +++ b/SystemConfiguration.fproj/SystemConfigurationInternal.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2018 Apple Inc. All rights reserved. + * Copyright (c) 2018, 2020 Apple Inc. All rights reserved. * * @APPLE_LICENSE_HEADER_START@ * @@ -45,6 +45,14 @@ __BEGIN_DECLS void _SCDPluginExecInit (void); +void +__SC_Log (int level, + CFStringRef format_CF, + os_log_t log, + os_log_type_t type, + const char *format, + ...) CF_FORMAT_FUNCTION(2, 6) __attribute__((format(os_log, 5, 6))); + __END_DECLS #endif // _SYSTEMCONFIGURATIONINTERNAL_H diff --git a/SystemConfiguration.fproj/VLANConfiguration.c b/SystemConfiguration.fproj/VLANConfiguration.c index e505e57..357a5b0 100644 --- a/SystemConfiguration.fproj/VLANConfiguration.c +++ b/SystemConfiguration.fproj/VLANConfiguration.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003-2013, 2015-2018 Apple Inc. All rights reserved. + * Copyright (c) 2003-2013, 2015-2018, 2020 Apple Inc. All rights reserved. * * @APPLE_LICENSE_HEADER_START@ * @@ -222,8 +222,9 @@ SCVLANInterfaceCopyAll(SCPreferencesRef prefs) if (__SCPreferencesUsingDefaultPrefs(prefs)) { ni_prefs = NULL; } else { - ni_prefs = __SCPreferencesCreateNIPrefsFromPrefs(prefs); + ni_prefs = SCPreferencesCreateCompanion(prefs, INTERFACES_DEFAULT_CONFIG); } + context.vlans = CFArrayCreateMutable(NULL, 0, &kCFTypeArrayCallBacks); context.ni_prefs = ni_prefs; context.prefs = prefs; @@ -238,6 +239,7 @@ SCVLANInterfaceCopyAll(SCPreferencesRef prefs) if (isA_CFDictionary(dict)) { my_CFDictionaryApplyFunction(dict, add_configured_interface, &context); } + if (ni_prefs != NULL) { CFRelease(ni_prefs); } diff --git a/SystemConfiguration.fproj/dy_framework.c b/SystemConfiguration.fproj/dy_framework.c index ba030bc..88b13d3 100644 --- a/SystemConfiguration.fproj/dy_framework.c +++ b/SystemConfiguration.fproj/dy_framework.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2002-2008, 2010-2015, 2017 Apple Inc. All rights reserved. + * Copyright (c) 2002-2008, 2010-2015, 2017, 2020 Apple Inc. All rights reserved. * * @APPLE_LICENSE_HEADER_START@ * @@ -610,7 +610,10 @@ __private_extern__ OSStatus _SecTrustedApplicationCreateFromPath(const char *path, SecTrustedApplicationRef *app) { #undef SecTrustedApplicationCreateFromPath +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wdeprecated" static typeof (SecTrustedApplicationCreateFromPath) *dyfunc = NULL; +#pragma GCC diagnostic pop if (!dyfunc) { void *image = __loadSecurity(); if (image) dyfunc = dlsym(image, "SecTrustedApplicationCreateFromPath"); diff --git a/configd.tproj/configd.m b/configd.tproj/configd.m index d94730f..5043bb3 100644 --- a/configd.tproj/configd.m +++ b/configd.tproj/configd.m @@ -1,5 +1,5 @@ /* - * Copyright (c) 2000-2011, 2013-2019 Apple Inc. All rights reserved. + * Copyright (c) 2000-2011, 2013-2020 Apple Inc. All rights reserved. * * @APPLE_LICENSE_HEADER_START@ * @@ -126,7 +126,7 @@ catcher(int signum) case SIGINT : case SIGTERM : if (termRequested != NULL) { - if (_sc_log > 0) { + if (_sc_log > kSCLogDestinationFile) { /* * if we've received a [shutdown] SIGTERM * and we are syslog'ing than it's likely @@ -134,7 +134,7 @@ catcher(int signum) * such, let's also push any remaining log * messages to stdout/stderr. */ - _sc_log = 2; + _sc_log = kSCLogDestinationBoth; } /* @@ -404,24 +404,17 @@ main(int argc, char * const argv[]) * setup logging. */ if (!forceForeground || forcePlugin) { - int facility = LOG_DAEMON; - int logopt = LOG_CONS|LOG_NDELAY|LOG_PID; - if (!is_launchd_job && !forcePlugin) { init_fds(); } - if (_configd_verbose) { - logopt |= LOG_CONS; - } - if (_SC_isInstallEnvironment()) { - facility = LOG_INSTALL; + openlog("configd", + LOG_CONS|LOG_NDELAY|LOG_PID, // logopt + LOG_INSTALL); // facility } - - openlog("configd", logopt, facility); } else { - _sc_log = FALSE; /* redirect SCLog() to stdout/stderr */ + _sc_log = kSCLogDestinationFile; /* redirect SCLog() to stdout/stderr */ } /* add signal handler to catch a SIGHUP */ diff --git a/configd.xcodeproj/project.pbxproj b/configd.xcodeproj/project.pbxproj index 6d1d504..0f89bc4 100644 --- a/configd.xcodeproj/project.pbxproj +++ b/configd.xcodeproj/project.pbxproj @@ -280,6 +280,7 @@ 150BEC1A14CA252200237116 /* dnsinfo_server.c in Sources */ = {isa = PBXBuildFile; fileRef = 15B73F0D05FD1B670096477F /* dnsinfo_server.c */; }; 150D7E1E0D16DC6C00AF4BED /* Security.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 1520A3DE0846B2DC0010B584 /* Security.framework */; }; 150EC0FF21016BFD0047F4BF /* SystemConfiguration.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 1547072E0D1F70C80075C28D /* SystemConfiguration.framework */; }; + 1514055A23EC9F3F0007B23F /* SystemConfiguration.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 1559C4440D349A4E0098FD59 /* SystemConfiguration.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 */; }; @@ -376,6 +377,7 @@ 1565D85018B847590097062B /* SCNetworkMigration.c in Sources */ = {isa = PBXBuildFile; fileRef = 55A3DB9D183C2A8200ED3DB7 /* SCNetworkMigration.c */; }; 1565D85118B847F20097062B /* SCNetworkMigration.c in Sources */ = {isa = PBXBuildFile; fileRef = 55A3DB9D183C2A8200ED3DB7 /* SCNetworkMigration.c */; }; 156BD6BC07E0DFA9008698FF /* SCPreferencesSetSpecificPrivate.h in Headers */ = {isa = PBXBuildFile; fileRef = 156BD6BB07E0DFA9008698FF /* SCPreferencesSetSpecificPrivate.h */; settings = {ATTRIBUTES = (Private, ); }; }; + 15703B2922320A940018D2EE /* test-objC.m in Sources */ = {isa = PBXBuildFile; fileRef = 72D3E66B1AE6EAF600DB4C69 /* test-objC.m */; }; 1572AA8D1D8235940021E093 /* plugin_shared.h in Headers */ = {isa = PBXBuildFile; fileRef = 1572AA8B1D8234500021E093 /* plugin_shared.h */; }; 1572AA8E1D8235A40021E093 /* plugin_shared.h in Headers */ = {isa = PBXBuildFile; fileRef = 1572AA8B1D8234500021E093 /* plugin_shared.h */; }; 1572AA8F1D82375A0021E093 /* plugin_shared.h in Headers */ = {isa = PBXBuildFile; fileRef = 1572AA8B1D8234500021E093 /* plugin_shared.h */; }; @@ -1902,42 +1904,6 @@ name = "Copy Files"; runOnlyForDeploymentPostprocessing = 1; }; - 15E91DBA21893E83001155DC /* CopyFiles */ = { - isa = PBXCopyFilesBuildPhase; - buildActionMask = 2147483647; - dstPath = /usr/share/man/man1/; - dstSubfolderSpec = 0; - files = ( - ); - runOnlyForDeploymentPostprocessing = 1; - }; - 15E91DD221893EE1001155DC /* CopyFiles */ = { - isa = PBXCopyFilesBuildPhase; - buildActionMask = 2147483647; - dstPath = /usr/share/man/man1/; - dstSubfolderSpec = 0; - files = ( - ); - runOnlyForDeploymentPostprocessing = 1; - }; - 15EF89AD21894636003B2C5C /* CopyFiles */ = { - isa = PBXCopyFilesBuildPhase; - buildActionMask = 2147483647; - dstPath = /usr/share/man/man1/; - dstSubfolderSpec = 0; - files = ( - ); - runOnlyForDeploymentPostprocessing = 1; - }; - 15EF89B821894665003B2C5C /* CopyFiles */ = { - isa = PBXCopyFilesBuildPhase; - buildActionMask = 2147483647; - dstPath = /usr/share/man/man1/; - dstSubfolderSpec = 0; - files = ( - ); - runOnlyForDeploymentPostprocessing = 1; - }; 15FF5C380CDF778F00EEC8AA /* CopyFiles */ = { isa = PBXCopyFilesBuildPhase; buildActionMask = 8; @@ -1970,24 +1936,6 @@ name = npt_configd.plist; runOnlyForDeploymentPostprocessing = 1; }; - 72D3E65C1AE6EA3900DB4C69 /* CopyFiles */ = { - isa = PBXCopyFilesBuildPhase; - buildActionMask = 2147483647; - dstPath = /usr/share/man/man1/; - dstSubfolderSpec = 0; - files = ( - ); - runOnlyForDeploymentPostprocessing = 1; - }; - 72D3E6671AE6EAF600DB4C69 /* CopyFiles */ = { - isa = PBXCopyFilesBuildPhase; - buildActionMask = 2147483647; - dstPath = /usr/share/man/man1/; - dstSubfolderSpec = 0; - files = ( - ); - runOnlyForDeploymentPostprocessing = 1; - }; F963400F20FE8E4100F1E1F1 /* CopyFiles */ = { isa = PBXCopyFilesBuildPhase; buildActionMask = 8; @@ -2736,6 +2684,7 @@ buildActionMask = 2147483647; files = ( C4666C72206ED01800247AB6 /* EventFactory.framework in Frameworks */, + 1514055A23EC9F3F0007B23F /* SystemConfiguration.framework in Frameworks */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -4604,6 +4553,22 @@ productReference = 155F49A21C864F5400E47D08 /* QoSMarking.bundle */; productType = "com.apple.product-type.bundle"; }; + 15703B2422320A940018D2EE /* SCTest-ObjC-iOSMac */ = { + isa = PBXNativeTarget; + buildConfigurationList = 15703B2D22320A940018D2EE /* Build configuration list for PBXNativeTarget "SCTest-ObjC-iOSMac" */; + buildPhases = ( + 15703B2722320A940018D2EE /* Flush Module Cache */, + 15703B2822320A940018D2EE /* Sources */, + 15703B2A22320A940018D2EE /* Frameworks */, + ); + buildRules = ( + ); + dependencies = ( + ); + name = "SCTest-ObjC-iOSMac"; + productName = "SCTest-ObjC"; + productType = "com.apple.product-type.tool"; + }; 1572C4A60CFB55B400E2776E /* SystemConfiguration.framework-Embedded */ = { isa = PBXNativeTarget; buildConfigurationList = 1572C5290CFB55B400E2776E /* Build configuration list for PBXNativeTarget "SystemConfiguration.framework-Embedded" */; @@ -5197,7 +5162,6 @@ 15E91DB521893E83001155DC /* Flush Module Cache */, 15E91DB621893E83001155DC /* Sources */, 15E91DB821893E83001155DC /* Frameworks */, - 15E91DBA21893E83001155DC /* CopyFiles */, ); buildRules = ( ); @@ -5213,9 +5177,9 @@ isa = PBXNativeTarget; buildConfigurationList = 15E91DD321893EE1001155DC /* Build configuration list for PBXNativeTarget "SCTest-Swift-Embedded" */; buildPhases = ( + 15EB93A7243D4AFA0088A86B /* Flush Module Cache */, 15E91DCF21893EE1001155DC /* Sources */, 15E91DD121893EE1001155DC /* Frameworks */, - 15E91DD221893EE1001155DC /* CopyFiles */, ); buildRules = ( ); @@ -5234,7 +5198,6 @@ 15EF89A821894636003B2C5C /* Flush Module Cache */, 15EF89A921894636003B2C5C /* Sources */, 15EF89AB21894636003B2C5C /* Frameworks */, - 15EF89AD21894636003B2C5C /* CopyFiles */, ); buildRules = ( ); @@ -5252,7 +5215,6 @@ buildPhases = ( 15EF89B521894665003B2C5C /* Sources */, 15EF89B721894665003B2C5C /* Frameworks */, - 15EF89B821894665003B2C5C /* CopyFiles */, ); buildRules = ( ); @@ -5407,9 +5369,9 @@ isa = PBXNativeTarget; buildConfigurationList = 72D3E6621AE6EA3A00DB4C69 /* Build configuration list for PBXNativeTarget "SCTest-Swift" */; buildPhases = ( + 15EB93A8243D51390088A86B /* Flush Module Cache */, 72D3E65A1AE6EA3900DB4C69 /* Sources */, 72D3E65B1AE6EA3900DB4C69 /* Frameworks */, - 72D3E65C1AE6EA3900DB4C69 /* CopyFiles */, ); buildRules = ( ); @@ -5428,7 +5390,6 @@ 150EC0FE21016BAA0047F4BF /* Flush Module Cache */, 72D3E6651AE6EAF600DB4C69 /* Sources */, 72D3E6661AE6EAF600DB4C69 /* Frameworks */, - 72D3E6671AE6EAF600DB4C69 /* CopyFiles */, ); buildRules = ( ); @@ -5444,6 +5405,7 @@ isa = PBXNativeTarget; buildConfigurationList = C4666C77206ED01800247AB6 /* Build configuration list for PBXNativeTarget "SystemConfigurationEventFactory" */; buildPhases = ( + 1553688B24397CC6004735C3 /* Flush Module Cache */, C4666C6D206ED01800247AB6 /* Sources */, C4666C6E206ED01800247AB6 /* Frameworks */, ); @@ -5462,7 +5424,7 @@ 15CB6A7705C0722B0099E85F /* Project object */ = { isa = PBXProject; attributes = { - LastUpgradeCheck = 1100; + LastUpgradeCheck = 1200; TargetAttributes = { 15401C1C21991506006326B7 = { CreatedOnToolsVersion = 11.0; @@ -5473,6 +5435,7 @@ }; 72D3E65D1AE6EA3900DB4C69 = { CreatedOnToolsVersion = 7.0; + LastSwiftMigration = 1140; }; 72D3E6681AE6EAF600DB4C69 = { CreatedOnToolsVersion = 7.0; @@ -5569,6 +5532,7 @@ 72D3E6681AE6EAF600DB4C69 /* SCTest-ObjC */, 15E91DB221893E83001155DC /* SCTest-ObjC-Embedded */, 15EF89A521894636003B2C5C /* SCTest-ObjC-EmbeddedSimulator */, + 15703B2422320A940018D2EE /* SCTest-ObjC-iOSMac */, 72D3E65D1AE6EA3900DB4C69 /* SCTest-Swift */, 15E91DCC21893EE1001155DC /* SCTest-Swift-Embedded */, 15EF89B221894665003B2C5C /* SCTest-Swift-EmbeddedSimulator */, @@ -6099,6 +6063,44 @@ shellScript = "${SRCROOT}/update-sanitizer-dylib-references"; showEnvVarsInLog = 0; }; + 1553688B24397CC6004735C3 /* Flush Module Cache */ = { + isa = PBXShellScriptBuildPhase; + buildActionMask = 2147483647; + files = ( + ); + inputFileListPaths = ( + ); + inputPaths = ( + ); + name = "Flush Module Cache"; + outputFileListPaths = ( + ); + outputPaths = ( + ); + runOnlyForDeploymentPostprocessing = 0; + shellPath = /bin/sh; + shellScript = "rm -rf \"${CLANG_MODULE_CACHE_PATH}\"\n"; + showEnvVarsInLog = 0; + }; + 15703B2722320A940018D2EE /* Flush Module Cache */ = { + isa = PBXShellScriptBuildPhase; + buildActionMask = 2147483647; + files = ( + ); + inputFileListPaths = ( + ); + inputPaths = ( + ); + name = "Flush Module Cache"; + outputFileListPaths = ( + ); + outputPaths = ( + ); + runOnlyForDeploymentPostprocessing = 0; + shellPath = /bin/sh; + shellScript = "rm -rf \"${CLANG_MODULE_CACHE_PATH}\"\n"; + showEnvVarsInLog = 0; + }; 1572C5270CFB55B400E2776E /* get-mobility-info */ = { isa = PBXShellScriptBuildPhase; buildActionMask = 8; @@ -6241,6 +6243,44 @@ shellScript = "rm -rf \"${CLANG_MODULE_CACHE_PATH}\"\n"; showEnvVarsInLog = 0; }; + 15EB93A7243D4AFA0088A86B /* Flush Module Cache */ = { + isa = PBXShellScriptBuildPhase; + buildActionMask = 2147483647; + files = ( + ); + inputFileListPaths = ( + ); + inputPaths = ( + ); + name = "Flush Module Cache"; + outputFileListPaths = ( + ); + outputPaths = ( + ); + runOnlyForDeploymentPostprocessing = 0; + shellPath = /bin/sh; + shellScript = "rm -rf \"${CLANG_MODULE_CACHE_PATH}\"\n"; + showEnvVarsInLog = 0; + }; + 15EB93A8243D51390088A86B /* Flush Module Cache */ = { + isa = PBXShellScriptBuildPhase; + buildActionMask = 2147483647; + files = ( + ); + inputFileListPaths = ( + ); + inputPaths = ( + ); + name = "Flush Module Cache"; + outputFileListPaths = ( + ); + outputPaths = ( + ); + runOnlyForDeploymentPostprocessing = 0; + shellPath = /bin/sh; + shellScript = "rm -rf \"${CLANG_MODULE_CACHE_PATH}\"\n"; + showEnvVarsInLog = 0; + }; 15EF89A821894636003B2C5C /* Flush Module Cache */ = { isa = PBXShellScriptBuildPhase; buildActionMask = 2147483647; @@ -6411,6 +6451,14 @@ ); runOnlyForDeploymentPostprocessing = 0; }; + 15703B2822320A940018D2EE /* Sources */ = { + isa = PBXSourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + 15703B2922320A940018D2EE /* test-objC.m in Sources */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; 1572C4DE0CFB55B400E2776E /* Sources */ = { isa = PBXSourcesBuildPhase; buildActionMask = 2147483647; @@ -7610,7 +7658,6 @@ 151F5D9C0CCE98E60093AC3B /* Debug */ = { isa = XCBuildConfiguration; buildSettings = { - CODE_SIGN_IDENTITY = "-"; DYLIB_COMPATIBILITY_VERSION = 1; DYLIB_CURRENT_VERSION = "$(RC_ProjectSourceVersion)"; FRAMEWORK_SEARCH_PATHS = "$(SYMROOT)"; @@ -7626,7 +7673,6 @@ 151F5D9D0CCE98E60093AC3B /* Release */ = { isa = XCBuildConfiguration; buildSettings = { - CODE_SIGN_IDENTITY = "-"; DYLIB_COMPATIBILITY_VERSION = 1; DYLIB_CURRENT_VERSION = "$(RC_ProjectSourceVersion)"; FRAMEWORK_SEARCH_PATHS = "$(SYMROOT)"; @@ -7886,21 +7932,9 @@ "-lxpc", ); "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_asan[sdk=macosx*]" = "$(inherited) -L/usr/appleinternal/lib/sanitizers -lclang_rt.asan_osx_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"; + "OTHER_LDFLAGS_tsan[sdk=macosx*]" = "$(inherited) -L/usr/appleinternal/lib/sanitizers -lclang_rt.tsan_osx_dynamic"; OTHER_TAPI_FLAGS = "$(inherited) -umbrella System --extra-private-header=$(PROJECT_DIR)/libSystemConfiguration/libSystemConfiguration_internal.h --extra-private-header=$(PROJECT_DIR)/nwi/network_information_internal.h --extra-private-header=$(PROJECT_DIR)/nwi/network_config_agent_info_priv.h"; PRODUCT_NAME = libsystem_configuration; STRIP_INSTALLED_PRODUCT_asan = NO; @@ -7945,21 +7979,9 @@ "-lxpc", ); "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_asan[sdk=macosx*]" = "$(inherited) -L/usr/appleinternal/lib/sanitizers -lclang_rt.asan_osx_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"; + "OTHER_LDFLAGS_tsan[sdk=macosx*]" = "$(inherited) -L/usr/appleinternal/lib/sanitizers -lclang_rt.tsan_osx_dynamic"; OTHER_TAPI_FLAGS = "$(inherited) -umbrella System --extra-private-header=$(PROJECT_DIR)/libSystemConfiguration/libSystemConfiguration_internal.h --extra-private-header=$(PROJECT_DIR)/nwi/network_information_internal.h --extra-private-header=$(PROJECT_DIR)/nwi/network_config_agent_info_priv.h"; PRODUCT_NAME = libsystem_configuration; STRIP_INSTALLED_PRODUCT_asan = NO; @@ -7992,10 +8014,6 @@ ); MODULEMAP_FILE = SystemConfiguration.fproj/Modules/SystemConfiguration.modulemap; MODULEMAP_PRIVATE_FILE = SystemConfiguration.fproj/Modules/SystemConfiguration.private.modulemap; - OTHER_CFLAGS = ( - "$(inherited)", - "-DSC_LOG_OR_PRINT", - ); OTHER_CFLAGS_debug = "-O0"; OTHER_TAPI_FLAGS = "$(inherited) -DEXCLUDE_VPN_TUNNEL_PLUGIN_FUNCTIONS -I$(SDKROOT)$(SYSTEM_LIBRARY_DIR)/Frameworks/System.framework/PrivateHeaders --extra-private-header=$(PROJECT_DIR)/SystemConfiguration.fproj/SystemConfigurationInternal.h --extra-private-header=$(PROJECT_DIR)/SystemConfiguration.fproj/SCDynamicStoreInternal.h --verify-api-skip-external-headers"; PRODUCT_BUNDLE_IDENTIFIER = com.apple.SystemConfiguration; @@ -8026,10 +8044,6 @@ ); MODULEMAP_FILE = SystemConfiguration.fproj/Modules/SystemConfiguration.modulemap; MODULEMAP_PRIVATE_FILE = SystemConfiguration.fproj/Modules/SystemConfiguration.private.modulemap; - OTHER_CFLAGS = ( - "$(inherited)", - "-DSC_LOG_OR_PRINT", - ); OTHER_CFLAGS_debug = "-O0"; OTHER_TAPI_FLAGS = "$(inherited) -DEXCLUDE_VPN_TUNNEL_PLUGIN_FUNCTIONS -I$(SDKROOT)$(SYSTEM_LIBRARY_DIR)/Frameworks/System.framework/PrivateHeaders --extra-private-header=$(PROJECT_DIR)/SystemConfiguration.fproj/SystemConfigurationInternal.h --extra-private-header=$(PROJECT_DIR)/SystemConfiguration.fproj/SCDynamicStoreInternal.h --verify-api-skip-external-headers"; PRODUCT_BUNDLE_IDENTIFIER = com.apple.SystemConfiguration; @@ -8542,7 +8556,7 @@ SDKROOT = macosx.internal; SUPPORTED_PLATFORMS = macosx; SUPPORTS_TEXT_BASED_API = YES; - SWIFT_VERSION = 4.2; + SWIFT_VERSION = 5.0; TAPI_VERIFY_MODE = Pedantic; VERSIONING_SYSTEM = "apple-generic"; VERSION_INFO_PREFIX = "__attribute__((visibility(\"hidden\")))"; @@ -8630,7 +8644,7 @@ SUPPORTED_PLATFORMS = macosx; SUPPORTS_TEXT_BASED_API = YES; SWIFT_OPTIMIZATION_LEVEL = "-Owholemodule"; - SWIFT_VERSION = 4.2; + SWIFT_VERSION = 5.0; TAPI_VERIFY_MODE = Pedantic; VERSIONING_SYSTEM = "apple-generic"; VERSION_INFO_PREFIX = "__attribute__((visibility(\"hidden\")))"; @@ -8646,6 +8660,44 @@ }; name = Release; }; + 15703B2E22320A940018D2EE /* Debug */ = { + isa = XCBuildConfiguration; + buildSettings = { + CLANG_ALLOW_NON_MODULAR_INCLUDES_IN_FRAMEWORK_MODULES = YES; + CLANG_ENABLE_MODULES = YES; + CLANG_MODULES_DISABLE_PRIVATE_WARNING = YES; + OTHER_CFLAGS = ( + "$(inherited)", + "-Wnon-modular-include-in-module", + "-DUSING_PUBLIC_SDK", + ); + PRODUCT_NAME = "$(TARGET_NAME)"; + SDKROOT = iphoneos.internal; + "SDK_VARIANT[sdk=macosx*]" = iosmac; + SUPPORTED_PLATFORMS = "macosx iphoneos"; + SUPPORTS_IOSMAC = YES; + }; + name = Debug; + }; + 15703B2F22320A940018D2EE /* Release */ = { + isa = XCBuildConfiguration; + buildSettings = { + CLANG_ALLOW_NON_MODULAR_INCLUDES_IN_FRAMEWORK_MODULES = YES; + CLANG_ENABLE_MODULES = YES; + CLANG_MODULES_DISABLE_PRIVATE_WARNING = YES; + OTHER_CFLAGS = ( + "$(inherited)", + "-Wnon-modular-include-in-module", + "-DUSING_PUBLIC_SDK", + ); + PRODUCT_NAME = "$(TARGET_NAME)"; + SDKROOT = iphoneos.internal; + "SDK_VARIANT[sdk=macosx*]" = iosmac; + SUPPORTED_PLATFORMS = "macosx iphoneos"; + SUPPORTS_IOSMAC = YES; + }; + name = Release; + }; 1572C52A0CFB55B400E2776E /* Debug */ = { isa = XCBuildConfiguration; buildSettings = { @@ -8665,10 +8717,6 @@ ); MODULEMAP_FILE = SystemConfiguration.fproj/Modules/SystemConfiguration.modulemap; MODULEMAP_PRIVATE_FILE = SystemConfiguration.fproj/Modules/SystemConfiguration.private.modulemap; - OTHER_CFLAGS = ( - "$(inherited)", - "-DSC_LOG_OR_PRINT", - ); OTHER_TAPI_FLAGS = "$(inherited) -DEXCLUDE_VPN_TUNNEL_PLUGIN_FUNCTIONS --extra-private-header=$(PROJECT_DIR)/SystemConfiguration.fproj/SystemConfigurationInternal.h --extra-private-header=$(PROJECT_DIR)/SystemConfiguration.fproj/SCDynamicStoreInternal.h -DNO_TAPI_WARNINGS"; PRODUCT_BUNDLE_IDENTIFIER = com.apple.SystemConfiguration; PRODUCT_NAME = SystemConfiguration; @@ -8701,10 +8749,6 @@ ); MODULEMAP_FILE = SystemConfiguration.fproj/Modules/SystemConfiguration.modulemap; MODULEMAP_PRIVATE_FILE = SystemConfiguration.fproj/Modules/SystemConfiguration.private.modulemap; - OTHER_CFLAGS = ( - "$(inherited)", - "-DSC_LOG_OR_PRINT", - ); OTHER_TAPI_FLAGS = "$(inherited) -DEXCLUDE_VPN_TUNNEL_PLUGIN_FUNCTIONS --extra-private-header=$(PROJECT_DIR)/SystemConfiguration.fproj/SystemConfigurationInternal.h --extra-private-header=$(PROJECT_DIR)/SystemConfiguration.fproj/SCDynamicStoreInternal.h -DNO_TAPI_WARNINGS"; PRODUCT_BUNDLE_IDENTIFIER = com.apple.SystemConfiguration; PRODUCT_NAME = SystemConfiguration; @@ -8961,21 +9005,23 @@ "-Wl,-upward-lSystem", ); "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_asan[sdk=bridgeos*]" = "$(inherited) -L/usr/appleinternal/lib/sanitizers -lclang_rt.asan_bridgeos_dynamic"; + "OTHER_LDFLAGS_asan[sdk=iphoneos*]" = "$(inherited) -L/usr/appleinternal/lib/sanitizers -lclang_rt.asan_ios_dynamic"; + "OTHER_LDFLAGS_asan[sdk=iphonesimulator*]" = "$(inherited) -L/usr/appleinternal/lib/sanitizers -lclang_rt.asan_iossim_dynamic"; + "OTHER_LDFLAGS_asan[sdk=macosx*]" = "$(inherited) -L/usr/appleinternal/lib/sanitizers -lclang_rt.asan_osx_dynamic"; + "OTHER_LDFLAGS_asan[sdk=tvos*]" = "$(inherited) -L/usr/appleinternal/lib/sanitizers -lclang_rt.asan_tvos_dynamic"; + "OTHER_LDFLAGS_asan[sdk=tvossimulator*]" = "$(inherited) -L/usr/appleinternal/lib/sanitizers -lclang_rt.asan_tvossim_dynamic"; + "OTHER_LDFLAGS_asan[sdk=watchos*]" = "$(inherited) -L/usr/appleinternal/lib/sanitizers -lclang_rt.asan_watchos_dynamic"; + "OTHER_LDFLAGS_asan[sdk=watchsimulator*]" = "$(inherited) -L/usr/appleinternal/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"; + "OTHER_LDFLAGS_tsan[sdk=bridgeos*]" = "$(inherited) -L/usr/appleinternal/lib/sanitizers -lclang_rt.tsan_bridgeos_dynamic"; + "OTHER_LDFLAGS_tsan[sdk=iphoneos*]" = "$(inherited) -L/usr/appleinternal/lib/sanitizers -lclang_rt.tsan_ios_dynamic"; + "OTHER_LDFLAGS_tsan[sdk=iphonesimulator*]" = "$(inherited) -L/usr/appleinternal/lib/sanitizers -lclang_rt.tsan_iossim_dynamic"; + "OTHER_LDFLAGS_tsan[sdk=macosx*]" = "$(inherited) -L/usr/appleinternal/lib/sanitizers -lclang_rt.tsan_osx_dynamic"; + "OTHER_LDFLAGS_tsan[sdk=tvos*]" = "$(inherited) -L/usr/appleinternal/lib/sanitizers -lclang_rt.tsan_tvos_dynamic"; + "OTHER_LDFLAGS_tsan[sdk=tvossimulator*]" = "$(inherited) -L/usr/appleinternal/lib/sanitizers -lclang_rt.tsan_tvossim_dynamic"; + "OTHER_LDFLAGS_tsan[sdk=watchos*]" = "$(inherited) -L/usr/appleinternal/lib/sanitizers -lclang_rt.tsan_watchos_dynamic"; + "OTHER_LDFLAGS_tsan[sdk=watchsimulator*]" = "$(inherited) -L/usr/appleinternal/lib/sanitizers -lclang_rt.tsan_watchossim_dynamic"; OTHER_TAPI_FLAGS = "$(inherited) -umbrella System --extra-private-header=$(PROJECT_DIR)/libSystemConfiguration/libSystemConfiguration_internal.h --extra-private-header=$(PROJECT_DIR)/nwi/network_information_internal.h --extra-private-header=$(PROJECT_DIR)/nwi/network_config_agent_info_priv.h"; PRODUCT_NAME = libsystem_configuration; SDKROOT = iphoneos.internal; @@ -9015,21 +9061,23 @@ "-Wl,-upward-lSystem", ); "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_asan[sdk=bridgeos*]" = "$(inherited) -L/usr/appleinternal/lib/sanitizers -lclang_rt.asan_bridgeos_dynamic"; + "OTHER_LDFLAGS_asan[sdk=iphoneos*]" = "$(inherited) -L/usr/appleinternal/lib/sanitizers -lclang_rt.asan_ios_dynamic"; + "OTHER_LDFLAGS_asan[sdk=iphonesimulator*]" = "$(inherited) -L/usr/appleinternal/lib/sanitizers -lclang_rt.asan_iossim_dynamic"; + "OTHER_LDFLAGS_asan[sdk=macosx*]" = "$(inherited) -L/usr/appleinternal/lib/sanitizers -lclang_rt.asan_osx_dynamic"; + "OTHER_LDFLAGS_asan[sdk=tvos*]" = "$(inherited) -L/usr/appleinternal/lib/sanitizers -lclang_rt.asan_tvos_dynamic"; + "OTHER_LDFLAGS_asan[sdk=tvossimulator*]" = "$(inherited) -L/usr/appleinternal/lib/sanitizers -lclang_rt.asan_tvossim_dynamic"; + "OTHER_LDFLAGS_asan[sdk=watchos*]" = "$(inherited) -L/usr/appleinternal/lib/sanitizers -lclang_rt.asan_watchos_dynamic"; + "OTHER_LDFLAGS_asan[sdk=watchsimulator*]" = "$(inherited) -L/usr/appleinternal/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"; + "OTHER_LDFLAGS_tsan[sdk=bridgeos*]" = "$(inherited) -L/usr/appleinternal/lib/sanitizers -lclang_rt.tsan_bridgeos_dynamic"; + "OTHER_LDFLAGS_tsan[sdk=iphoneos*]" = "$(inherited) -L/usr/appleinternal/lib/sanitizers -lclang_rt.tsan_ios_dynamic"; + "OTHER_LDFLAGS_tsan[sdk=iphonesimulator*]" = "$(inherited) -L/usr/appleinternal/lib/sanitizers -lclang_rt.tsan_iossim_dynamic"; + "OTHER_LDFLAGS_tsan[sdk=macosx*]" = "$(inherited) -L/usr/appleinternal/lib/sanitizers -lclang_rt.tsan_osx_dynamic"; + "OTHER_LDFLAGS_tsan[sdk=tvos*]" = "$(inherited) -L/usr/appleinternal/lib/sanitizers -lclang_rt.tsan_tvos_dynamic"; + "OTHER_LDFLAGS_tsan[sdk=tvossimulator*]" = "$(inherited) -L/usr/appleinternal/lib/sanitizers -lclang_rt.tsan_tvossim_dynamic"; + "OTHER_LDFLAGS_tsan[sdk=watchos*]" = "$(inherited) -L/usr/appleinternal/lib/sanitizers -lclang_rt.tsan_watchos_dynamic"; + "OTHER_LDFLAGS_tsan[sdk=watchsimulator*]" = "$(inherited) -L/usr/appleinternal/lib/sanitizers -lclang_rt.tsan_watchossim_dynamic"; OTHER_TAPI_FLAGS = "$(inherited) -umbrella System --extra-private-header=$(PROJECT_DIR)/libSystemConfiguration/libSystemConfiguration_internal.h --extra-private-header=$(PROJECT_DIR)/nwi/network_information_internal.h --extra-private-header=$(PROJECT_DIR)/nwi/network_config_agent_info_priv.h"; PRODUCT_NAME = libsystem_configuration; SDKROOT = iphoneos.internal; @@ -9270,7 +9318,6 @@ isa = XCBuildConfiguration; buildSettings = { CODE_SIGN_ENTITLEMENTS = "configd.tproj/entitlements-ios.plist"; - CODE_SIGN_IDENTITY = "-"; FRAMEWORK_SEARCH_PATHS = ( "$(SYMROOT)", "$(SDKROOT)$(SYSTEM_LIBRARY_DIR)/PrivateFrameworks", @@ -9299,7 +9346,6 @@ isa = XCBuildConfiguration; buildSettings = { CODE_SIGN_ENTITLEMENTS = "configd.tproj/entitlements-ios.plist"; - CODE_SIGN_IDENTITY = "-"; FRAMEWORK_SEARCH_PATHS = ( "$(SYMROOT)", "$(SDKROOT)$(SYSTEM_LIBRARY_DIR)/PrivateFrameworks", @@ -9494,7 +9540,6 @@ "$(inherited)", "-idirafter", "$(SYSTEM_LIBRARY_DIR)/Frameworks/System.framework/PrivateHeaders", - "-DSC_LOG_OR_PRINT", ); OTHER_TAPI_FLAGS = "$(inherited) -DEXCLUDE_VPN_TUNNEL_PLUGIN_FUNCTIONS --extra-private-header=$(PROJECT_DIR)/SystemConfiguration.fproj/SystemConfigurationInternal.h --extra-private-header=$(PROJECT_DIR)/SystemConfiguration.fproj/SCDynamicStoreInternal.h -DNO_TAPI_WARNINGS"; PRODUCT_BUNDLE_IDENTIFIER = com.apple.SystemConfiguration; @@ -9533,7 +9578,6 @@ "$(inherited)", "-idirafter", "$(SYSTEM_LIBRARY_DIR)/Frameworks/System.framework/PrivateHeaders", - "-DSC_LOG_OR_PRINT", ); OTHER_TAPI_FLAGS = "$(inherited) -DEXCLUDE_VPN_TUNNEL_PLUGIN_FUNCTIONS --extra-private-header=$(PROJECT_DIR)/SystemConfiguration.fproj/SystemConfigurationInternal.h --extra-private-header=$(PROJECT_DIR)/SystemConfiguration.fproj/SCDynamicStoreInternal.h -DNO_TAPI_WARNINGS"; PRODUCT_BUNDLE_IDENTIFIER = com.apple.SystemConfiguration; @@ -9929,7 +9973,6 @@ buildSettings = { CLANG_ENABLE_OBJC_ARC = YES; CODE_SIGN_ENTITLEMENTS = "sctest/sctest-entitlements.plist"; - CODE_SIGN_IDENTITY = "-"; FRAMEWORK_SEARCH_PATHS = "$(SDKROOT)$(SYSTEM_LIBRARY_DIR)/PrivateFrameworks"; HEADER_SEARCH_PATHS = "$(SDKROOT)$(SYSTEM_LIBRARY_DIR)/Frameworks/System.framework/PrivateHeaders"; INSTALL_PATH = /usr/local/bin; @@ -9943,7 +9986,6 @@ buildSettings = { CLANG_ENABLE_OBJC_ARC = YES; CODE_SIGN_ENTITLEMENTS = "sctest/sctest-entitlements.plist"; - CODE_SIGN_IDENTITY = "-"; FRAMEWORK_SEARCH_PATHS = "$(SDKROOT)$(SYSTEM_LIBRARY_DIR)/PrivateFrameworks"; HEADER_SEARCH_PATHS = "$(SDKROOT)$(SYSTEM_LIBRARY_DIR)/Frameworks/System.framework/PrivateHeaders"; INSTALL_PATH = /usr/local/bin; @@ -9957,7 +9999,6 @@ buildSettings = { CLANG_ENABLE_OBJC_ARC = YES; CODE_SIGN_ENTITLEMENTS = "sctest/sctest-entitlements.plist"; - CODE_SIGN_IDENTITY = "-"; FRAMEWORK_SEARCH_PATHS = "$(SDKROOT)$(SYSTEM_LIBRARY_DIR)/PrivateFrameworks"; HEADER_SEARCH_PATHS = "$(SDKROOT)$(SYSTEM_LIBRARY_DIR)/Frameworks/System.framework/PrivateHeaders"; INSTALL_PATH = /usr/local/bin; @@ -9973,7 +10014,6 @@ buildSettings = { CLANG_ENABLE_OBJC_ARC = YES; CODE_SIGN_ENTITLEMENTS = "sctest/sctest-entitlements.plist"; - CODE_SIGN_IDENTITY = "-"; FRAMEWORK_SEARCH_PATHS = "$(SDKROOT)$(SYSTEM_LIBRARY_DIR)/PrivateFrameworks"; HEADER_SEARCH_PATHS = "$(SDKROOT)$(SYSTEM_LIBRARY_DIR)/Frameworks/System.framework/PrivateHeaders"; INSTALL_PATH = /usr/local/bin; @@ -10007,6 +10047,7 @@ OTHER_CFLAGS = ( "$(inherited)", "-Wnon-modular-include-in-module", + "-fmodules-cache-path=$(CLANG_MODULE_CACHE_PATH)", ); PRODUCT_NAME = "$(TARGET_NAME)"; }; @@ -10021,6 +10062,7 @@ OTHER_CFLAGS = ( "$(inherited)", "-Wnon-modular-include-in-module", + "-fmodules-cache-path=$(CLANG_MODULE_CACHE_PATH)", ); PRODUCT_NAME = "$(TARGET_NAME)"; }; @@ -10031,8 +10073,6 @@ buildSettings = { CLANG_ANALYZER_NONNULL = YES; CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE; - CLANG_CXX_LANGUAGE_STANDARD = "gnu++14"; - CLANG_CXX_LIBRARY = "libc++"; CLANG_ENABLE_MODULES = YES; CLANG_ENABLE_OBJC_ARC = YES; CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES; @@ -10040,7 +10080,6 @@ CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES; CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE; - CODE_SIGN_IDENTITY = "-"; CODE_SIGN_STYLE = Automatic; DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; DWARF_DSYM_FILE_SHOULD_ACCOMPANY_PRODUCT = YES; @@ -10048,13 +10087,11 @@ "$(SDKROOT)$(SYSTEM_LIBRARY_DIR)/PrivateFrameworks", "$(SDKROOT)$(APPLE_INTERNAL_LIBRARY_DIR)/Frameworks", ); - GCC_C_LANGUAGE_STANDARD = gnu11; GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; INFOPLIST_FILE = EventFactory/Info.plist; INSTALL_PATH = "$(APPLE_INTERNAL_LIBRARY_DIR)/Frameworks/EventFactory.framework/PlugIns"; LD_RUNPATH_SEARCH_PATHS = "@loader_path/../../../../../"; - MACOSX_DEPLOYMENT_TARGET = 10.14; ONLY_ACTIVE_ARCH = YES; PRODUCT_BUNDLE_IDENTIFIER = "com.apple.$(TARGET_NAME)"; PRODUCT_NAME = "$(TARGET_NAME)"; @@ -10067,8 +10104,6 @@ buildSettings = { CLANG_ANALYZER_NONNULL = YES; CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE; - CLANG_CXX_LANGUAGE_STANDARD = "gnu++14"; - CLANG_CXX_LIBRARY = "libc++"; CLANG_ENABLE_MODULES = YES; CLANG_ENABLE_OBJC_ARC = YES; CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES; @@ -10076,7 +10111,6 @@ CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES; CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE; - CODE_SIGN_IDENTITY = "-"; CODE_SIGN_STYLE = Automatic; COPY_PHASE_STRIP = NO; DWARF_DSYM_FILE_SHOULD_ACCOMPANY_PRODUCT = ""; @@ -10085,13 +10119,11 @@ "$(SDKROOT)$(SYSTEM_LIBRARY_DIR)/PrivateFrameworks", "$(SDKROOT)$(APPLE_INTERNAL_LIBRARY_DIR)/Frameworks", ); - GCC_C_LANGUAGE_STANDARD = gnu11; GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; INFOPLIST_FILE = EventFactory/Info.plist; INSTALL_PATH = "$(APPLE_INTERNAL_LIBRARY_DIR)/Frameworks/EventFactory.framework/PlugIns"; LD_RUNPATH_SEARCH_PATHS = "@loader_path/../../../../../"; - MACOSX_DEPLOYMENT_TARGET = 10.14; PRODUCT_BUNDLE_IDENTIFIER = "com.apple.$(TARGET_NAME)"; PRODUCT_NAME = "$(TARGET_NAME)"; SDKROOT = macosx.internal; @@ -10407,6 +10439,15 @@ defaultConfigurationIsVisible = 0; defaultConfigurationName = Release; }; + 15703B2D22320A940018D2EE /* Build configuration list for PBXNativeTarget "SCTest-ObjC-iOSMac" */ = { + isa = XCConfigurationList; + buildConfigurations = ( + 15703B2E22320A940018D2EE /* Debug */, + 15703B2F22320A940018D2EE /* Release */, + ); + defaultConfigurationIsVisible = 0; + defaultConfigurationName = Release; + }; 1572C5290CFB55B400E2776E /* Build configuration list for PBXNativeTarget "SystemConfiguration.framework-Embedded" */ = { isa = XCConfigurationList; buildConfigurations = ( diff --git a/dnsinfo/dnsinfo_server.c b/dnsinfo/dnsinfo_server.c index 419279c..4a13cc5 100644 --- a/dnsinfo/dnsinfo_server.c +++ b/dnsinfo/dnsinfo_server.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2004-2008, 2011-2017 Apple Inc. All rights reserved. + * Copyright (c) 2004-2008, 2011-2017, 2020 Apple Inc. All rights reserved. * * @APPLE_LICENSE_HEADER_START@ * @@ -490,7 +490,7 @@ int main(int argc, char **argv) { static Boolean verbose = (argc > 1) ? TRUE : FALSE; -// _sc_log = FALSE; + _sc_log = kSCLogDestinationFile; _sc_verbose = (argc > 1) ? TRUE : FALSE; _sc_debug = TRUE; @@ -506,4 +506,4 @@ main(int argc, char **argv) return 0; } -#endif /* MAIN */ +#endif /* MAIN */ diff --git a/get-network-info b/get-network-info index e2749fd..4a18b49 100755 --- a/get-network-info +++ b/get-network-info @@ -1,7 +1,7 @@ #!/bin/sh # -# Copyright © 2015-2019 Apple Inc. +# Copyright © 2015-2020 Apple Inc. # # get-network-info # @@ -466,6 +466,18 @@ collect_configuration_files () { fi if [ -e /etc/resolver ]; then tar -c -H /etc/resolver > etc-resolver.tar 2>/dev/null + elif [ -e /Library/Preferences/SystemConfiguration/resolver ]; then + tar -c -H /Library/Preferences/SystemConfiguration/resolver > LPS-resolver.tar 2>/dev/null + fi + + MIGRATION_FILES=$(/bin/ls -1 \ + /Library/Preferences/SystemConfiguration/preferences-pre-*.plist \ + /Library/Preferences/SystemConfiguration/NetworkInterfaces-pre-*.plist \ + 2>/dev/null) + if [ -n "${MIGRATION_FILES}" ]; then + MIGRATION_FILES+=" /Library/Preferences/SystemConfiguration/preferences.plist" + MIGRATION_FILES+=" /Library/Preferences/SystemConfiguration/NetworkInterfaces.plist" + tar -c -H ${MIGRATION_FILES} > migration.tar 2>/dev/null fi } @@ -705,7 +717,7 @@ stop_pcap () { if [ ${PCAP_STARTED} -ne 0 ]; then trap '' SIGINT /usr/local/bin/netdiagnose stop sysdiagpcap 2>&1 1>/dev/null - echo "`date +"%Y-%m-%d %H:%M:%S"`: stop_pcap done" >> get-network-info.txt + echo "`date +"%Y-%m-%d %H:%M:%S"`: stop_pcap" >> get-network-info.txt fi } diff --git a/nwi/network_information_server.c b/nwi/network_information_server.c index 805798c..2d6764b 100644 --- a/nwi/network_information_server.c +++ b/nwi/network_information_server.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2012-2018 Apple Inc. All rights reserved. + * Copyright (c) 2012-2018, 2020 Apple Inc. All rights reserved. * * @APPLE_LICENSE_HEADER_START@ * @@ -572,7 +572,7 @@ int main(int argc, char **argv) { static Boolean verbose = (argc > 1) ? TRUE : FALSE; -// _sc_log = FALSE; + _sc_log = kSCLogDestinationFile; _sc_verbose = (argc > 1) ? TRUE : FALSE; _sc_debug = TRUE; diff --git a/scselect.tproj/scselect.c b/scselect.tproj/scselect.c index 8140cbd..355ba73 100644 --- a/scselect.tproj/scselect.c +++ b/scselect.tproj/scselect.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2000-2009, 2011, 2012, 2014, 2015, 2018 Apple Inc. All rights reserved. + * Copyright (c) 2000-2009, 2011, 2012, 2014, 2015, 2018, 2020 Apple Inc. All rights reserved. * * @APPLE_LICENSE_HEADER_START@ * @@ -104,7 +104,7 @@ main(int argc, char **argv) switch(opt) { case 'd': _sc_debug = TRUE; - _sc_log = FALSE; /* enable framework logging */ + _sc_log = kSCLogDestinationFile; /* enable framework logging */ break; case 'v': _sc_verbose = TRUE; diff --git a/sctest/main.m b/sctest/main.m index ec71efc..7c79c2c 100644 --- a/sctest/main.m +++ b/sctest/main.m @@ -50,7 +50,7 @@ int main(int argc, const char * argv[]) { Class testClass; SCTest *testClassObject; - _sc_log = 0; // print (stdout) + _sc_log = kSCLogDestinationFile; // print (stdout) if (argc == 1) { usage(); @@ -88,7 +88,7 @@ int main(int argc, const char * argv[]) { } } - _sc_log = 3; // log AND print (stdout w/o timestamp) + _sc_log = kSCLogDestinationBoth_NoTime; // log AND print (stdout w/o timestamp) testClassObject = [(SCTest *)[testClass alloc] initWithOptions:options]; if (testClassObject.options[kSCTestGlobalOptionCPU] != nil) { diff --git a/scutil.tproj/scutil.c b/scutil.tproj/scutil.c index 0d27a4a..a5cc354 100644 --- a/scutil.tproj/scutil.c +++ b/scutil.tproj/scutil.c @@ -441,14 +441,14 @@ main(int argc, char * const argv[]) switch(opt) { case 'd': _sc_debug = TRUE; - _sc_log = FALSE; /* enable framework logging */ + _sc_log = kSCLogDestinationFile; /* enable framework logging */ break; case 'D': doDispatch = TRUE; break; case 'v': _sc_verbose = TRUE; - _sc_log = FALSE; /* enable framework logging */ + _sc_log = kSCLogDestinationFile; /* enable framework logging */ break; case 'p': enablePrivateAPI = TRUE; diff --git a/scutil.tproj/scutil.h b/scutil.tproj/scutil.h index c44303f..5740c39 100644 --- a/scutil.tproj/scutil.h +++ b/scutil.tproj/scutil.h @@ -38,7 +38,6 @@ #include #define SC_LOG_HANDLE _SC_LOG_DEFAULT -#define USE_SC_LOG_OR_PRINT 1 #include #include diff --git a/scutil.tproj/tests.c b/scutil.tproj/tests.c index 38b6579..bf8442d 100644 --- a/scutil.tproj/tests.c +++ b/scutil.tproj/tests.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2000, 2001, 2003-2018 Apple Inc. All rights reserved. + * Copyright (c) 2000, 2001, 2003-2018, 2020 Apple Inc. All rights reserved. * * @APPLE_LICENSE_HEADER_START@ * @@ -682,7 +682,7 @@ do_printDNSConfiguration(int argc, char **argv, dns_config_t *dns_config) } _sc_log_save = _sc_log; - _sc_log = FALSE; + _sc_log = kSCLogDestinationFile; _dns_configuration_log(dns_config, _sc_debug, NULL); _sc_log = _sc_log_save; -- 2.45.2