]> git.saurik.com Git - apple/configd.git/commitdiff
configd-210.tar.gz mac-os-x-1052 v210
authorApple <opensource@apple.com>
Tue, 12 Feb 2008 09:14:35 +0000 (09:14 +0000)
committerApple <opensource@apple.com>
Tue, 12 Feb 2008 09:14:35 +0000 (09:14 +0000)
26 files changed:
Plugins/ATconfig/Info.plist
Plugins/IPMonitor/Info.plist
Plugins/InterfaceNamer/Info.plist
Plugins/KernelEventMonitor/Info.plist
Plugins/Kicker/Info.plist
Plugins/LinkConfiguration/Info.plist
Plugins/NetworkIdentification/Info.plist
Plugins/PreferencesMonitor/Info.plist
SCMonitor/English.lproj/Localizable.strings [new file with mode: 0644]
SCMonitor/Info.plist [new file with mode: 0644]
SCMonitor/monitor.c [new file with mode: 0644]
SystemConfiguration.fproj/English.lproj/NetworkInterface.strings
SystemConfiguration.fproj/Info.plist
SystemConfiguration.fproj/SCNetworkConfigurationInternal.h
SystemConfiguration.fproj/SCNetworkConfigurationPrivate.h
SystemConfiguration.fproj/SCNetworkInterface.c
SystemConfiguration.fproj/SCNetworkService.c
SystemConfiguration.fproj/SCNetworkSet.c
SystemConfiguration.fproj/SCPLock.c
SystemConfiguration.fproj/SCPOpen.c
SystemConfiguration.fproj/helper/SCHelper_client.h
SystemConfiguration.fproj/helper/SCHelper_server.c
configd.xcodeproj/project.pbxproj
scutil.tproj/commands.c
scutil.tproj/prefs.c
scutil.tproj/prefs.h

index 44bafb217b9a2bc0b3e93787acafc4803052711e..93463cfbbf1e0dba4f72e27254a1feda6d49b0d7 100644 (file)
@@ -1,5 +1,5 @@
 <?xml version="1.0" encoding="UTF-8"?>
-<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
+<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
 <plist version="1.0">
 <dict>
        <key>CFBundleDevelopmentRegion</key>
        <key>CFBundlePackageType</key>
        <string>BNDL</string>
        <key>CFBundleShortVersionString</key>
-       <string>1.9.0</string>
+       <string>1.9.1</string>
        <key>CFBundleSignature</key>
        <string>????</string>
        <key>CFBundleVersion</key>
-       <string>0.0.1d1</string>
+       <string>1.9.1</string>
        <key>Builtin</key>
        <true/>
        <key>Requires</key>
index deba33254e55cfcada12a591eeb89a1d35da070b..34dd24f68e64eee20b890c7ed0390dd85469b762 100644 (file)
@@ -1,5 +1,5 @@
 <?xml version="1.0" encoding="UTF-8"?>
-<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
+<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
 <plist version="1.0">
 <dict>
        <key>CFBundleDevelopmentRegion</key>
        <key>CFBundlePackageType</key>
        <string>BNDL</string>
        <key>CFBundleShortVersionString</key>
-       <string>1.9.0</string>
+       <string>1.9.1</string>
        <key>CFBundleSignature</key>
        <string>????</string>
        <key>CFBundleVersion</key>
-       <string>0.0.1d1</string>
+       <string>1.9.1</string>
        <key>Requires</key>
        <array>
                <string>com.apple.SystemConfiguration.IPConfiguration</string>
index a0de58f8e9670db5382d471e3012ddd42bdfc3bf..db1a7b05c77089b7a61fe786c521d67341773f83 100644 (file)
@@ -1,5 +1,5 @@
 <?xml version="1.0" encoding="UTF-8"?>
-<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
+<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
 <plist version="1.0">
 <dict>
        <key>CFBundleDevelopmentRegion</key>
        <key>CFBundlePackageType</key>
        <string>BNDL</string>
        <key>CFBundleShortVersionString</key>
-       <string>1.9.0</string>
+       <string>1.9.1</string>
        <key>CFBundleSignature</key>
        <string>????</string>
        <key>CFBundleVersion</key>
-       <string>0.0.1d1</string>
+       <string>1.9.1</string>
        <key>Builtin</key>
        <true/>
 </dict>
index d0cb258db2566830a392b5dc87d09f908dbca25b..fa16b156faaa8d429d0c2b091ebdd0c990ceb894 100644 (file)
@@ -1,5 +1,5 @@
 <?xml version="1.0" encoding="UTF-8"?>
-<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
+<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
 <plist version="1.0">
 <dict>
        <key>CFBundleDevelopmentRegion</key>
        <key>CFBundlePackageType</key>
        <string>BNDL</string>
        <key>CFBundleShortVersionString</key>
-       <string>1.9.0</string>
+       <string>1.9.1</string>
        <key>CFBundleSignature</key>
        <string>????</string>
        <key>CFBundleVersion</key>
-       <string>0.0.1d1</string>
+       <string>1.9.1</string>
        <key>Requires</key>
        <array>
                <string>com.apple.SystemConfiguration.InterfaceNamer</string>
index bc42eb32614569932b96e86a05534086fab7a491..5102cde24d46a5a517eca152820280309e6d55e7 100644 (file)
@@ -1,5 +1,5 @@
 <?xml version="1.0" encoding="UTF-8"?>
-<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
+<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
 <plist version="1.0">
 <dict>
        <key>CFBundleDevelopmentRegion</key>
        <key>CFBundlePackageType</key>
        <string>BNDL</string>
        <key>CFBundleShortVersionString</key>
-       <string>1.9.0</string>
+       <string>1.9.1</string>
        <key>CFBundleSignature</key>
        <string>????</string>
        <key>CFBundleVersion</key>
-       <string>0.0.1d1</string>
+       <string>1.9.1</string>
        <key>Requires</key>
        <array>
                <string>com.apple.SystemConfiguration.ATconfig</string>
index abac7dc13491ade5c67800f2da0ddfcdd571b7d9..34a5eff2dbccfa6157ac5fc64ac32bc3c1c6ad7a 100644 (file)
@@ -1,5 +1,5 @@
 <?xml version="1.0" encoding="UTF-8"?>
-<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
+<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
 <plist version="1.0">
 <dict>
        <key>CFBundleDevelopmentRegion</key>
        <key>CFBundlePackageType</key>
        <string>BNDL</string>
        <key>CFBundleShortVersionString</key>
-       <string>1.9.0</string>
+       <string>1.9.1</string>
        <key>CFBundleSignature</key>
        <string>????</string>
        <key>CFBundleVersion</key>
-       <string>0.0.1d1</string>
+       <string>1.9.1</string>
        <key>Requires</key>
        <array>
                <string>com.apple.SystemConfiguration.InterfaceNamer</string>
index 4a4623eadf2d1d3ecd582d6235c7cde0b86f9352..b7a9070ef6b2a462630ccc96f5d1cdb0e9296a62 100644 (file)
@@ -1,5 +1,5 @@
 <?xml version="1.0" encoding="UTF-8"?>
-<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
+<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
 <plist version="1.0">
 <dict>
        <key>CFBundleDevelopmentRegion</key>
        <key>CFBundlePackageType</key>
        <string>BNDL</string>
        <key>CFBundleShortVersionString</key>
-       <string>1.9.0</string>
+       <string>1.9.1</string>
        <key>CFBundleSignature</key>
        <string>????</string>
        <key>CFBundleVersion</key>
-       <string>0.0.1d1</string>
+       <string>1.9.1</string>
        <key>Builtin</key>
        <true/>
 </dict>
index d0b4485d50117de62426b1ce06601a4d3e7a7137..0061104e4f6b79056644e8da3df4d090749f8318 100644 (file)
@@ -1,5 +1,5 @@
 <?xml version="1.0" encoding="UTF-8"?>
-<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
+<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
 <plist version="1.0">
 <dict>
        <key>CFBundleDevelopmentRegion</key>
        <key>CFBundlePackageType</key>
        <string>BNDL</string>
        <key>CFBundleShortVersionString</key>
-       <string>1.9.0</string>
+       <string>1.9.1</string>
        <key>CFBundleSignature</key>
        <string>????</string>
        <key>CFBundleVersion</key>
-       <string>0.0.1d1</string>
+       <string>1.9.1</string>
        <key>Builtin</key>
        <true/>
        <key>Requires</key>
diff --git a/SCMonitor/English.lproj/Localizable.strings b/SCMonitor/English.lproj/Localizable.strings
new file mode 100644 (file)
index 0000000..bc1126f
Binary files /dev/null and b/SCMonitor/English.lproj/Localizable.strings differ
diff --git a/SCMonitor/Info.plist b/SCMonitor/Info.plist
new file mode 100644 (file)
index 0000000..85bea89
--- /dev/null
@@ -0,0 +1,40 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
+<plist version="1.0">
+<dict>
+       <key>CFBundleDevelopmentRegion</key>
+       <string>English</string>
+       <key>CFBundleExecutable</key>
+       <string>${EXECUTABLE_NAME}</string>
+       <key>CFBundleIdentifier</key>
+       <string>com.apple.SystemConfiguration.${EXECUTABLE_NAME}</string>
+       <key>CFBundleInfoDictionaryVersion</key>
+       <string>6.0</string>
+       <key>CFBundleName</key>
+       <string>${EXECUTABLE_NAME}</string>
+       <key>CFBundlePackageType</key>
+       <string>BNDL</string>
+       <key>CFBundleSignature</key>
+       <string>????</string>
+       <key>CFBundleShortVersionString</key>
+       <string>1.9.1</string>
+       <key>CFBundleVersion</key>
+       <string>1.9.1</string>
+       <key>CFPlugInDynamicRegistration</key>
+       <string>NO</string>
+       <key>CFPlugInFactories</key>
+       <dict>
+               <key>FB86416D-6164-2070-726F-70735C216EC0</key>
+               <string>UserEventAgentFactory</string>
+       </dict>
+       <key>CFPlugInTypes</key>
+       <dict>
+               <key>FC86416D-6164-2070-726F-70735C216EC0</key>
+               <array>
+                       <string>FB86416D-6164-2070-726F-70735C216EC0</string>
+               </array>
+       </dict>
+       <key>CFPlugInUnloadFunction</key>
+       <string></string>
+</dict>
+</plist>
diff --git a/SCMonitor/monitor.c b/SCMonitor/monitor.c
new file mode 100644 (file)
index 0000000..6ff25d6
--- /dev/null
@@ -0,0 +1,601 @@
+/*
+ * Copyright (c) 2007 Apple Computer, Inc. All rights reserved.
+ *
+ * @APPLE_LICENSE_HEADER_START@
+ * 
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
+ * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
+ * 
+ * @APPLE_LICENSE_HEADER_END@
+ */
+
+/*
+ * Modification History
+ *
+ * October 24, 2007            Allan Nathanson <ajn@apple.com>
+ * - initial revision
+ */
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <unistd.h>
+#include <CoreFoundation/CoreFoundation.h>
+#include <SystemConfiguration/SystemConfiguration.h>
+#include <SystemConfiguration/SCPrivate.h>
+#include <ApplicationServices/ApplicationServices.h>
+#include "UserEventAgentInterface.h"
+
+#define MY_BUNDLE_ID    CFSTR("com.apple.SystemConfiguration.SCMonitor")
+#define        MY_ICON_PATH    "/System/Library/PreferencePanes/Network.prefPane/Contents/Resources/Network.icns"
+
+#define        NETWORK_PREF_APP        "/System/Library/PreferencePanes/Network.prefPane"
+#define        NETWORK_PREF_CMD        "New Interface"
+
+typedef struct {
+       UserEventAgentInterfaceStruct   *_UserEventAgentInterface;
+       CFUUIDRef                       _factoryID;
+       UInt32                          _refCount;
+
+       CFRunLoopSourceRef              monitorRls;
+
+       CFMutableSetRef                 knownInterfaces;
+
+       CFMutableArrayRef               userInterfaces;
+       CFUserNotificationRef           userNotification;
+       CFRunLoopSourceRef              userRls;
+} MyType;
+
+static CFMutableDictionaryRef  notify_to_instance      = NULL;
+
+
+#pragma mark -
+#pragma mark Watch for new [network] interfaces
+
+
+static void
+open_NetworkPrefPane(void)
+{
+       AEDesc          aeDesc  = { typeNull, NULL };
+       CFArrayRef      prefArray;
+       CFURLRef        prefURL;
+       LSLaunchURLSpec prefSpec;
+       OSStatus        status;
+
+       prefURL = CFURLCreateWithFileSystemPath(kCFAllocatorDefault,
+                                               CFSTR(NETWORK_PREF_APP),
+                                               kCFURLPOSIXPathStyle,
+                                               FALSE);
+       prefArray = CFArrayCreate(NULL, (const void **)&prefURL, 1, &kCFTypeArrayCallBacks);
+       CFRelease(prefURL);
+
+       status = AECreateDesc('ptru',
+                             (const void *)NETWORK_PREF_CMD,
+                             strlen(NETWORK_PREF_CMD),
+                             &aeDesc);
+       if (status != noErr) {
+               SCLog(TRUE, LOG_ERR, CFSTR("SCMonitor: AECreateDesc() failed: %d"), status);
+       }
+
+       prefSpec.appURL         = NULL;
+       prefSpec.itemURLs       = prefArray;
+       prefSpec.passThruParams = &aeDesc;
+       prefSpec.launchFlags    = kLSLaunchAsync | kLSLaunchDontAddToRecents;
+       prefSpec.asyncRefCon    = NULL;
+
+       status = LSOpenFromURLSpec(&prefSpec, NULL);
+       if (status != noErr) {
+               SCLog(TRUE, LOG_ERR, CFSTR("SCMonitor: LSOpenFromURLSpec() failed: %d"), status);
+       }
+
+       CFRelease(prefArray);
+       if (aeDesc.descriptorType != typeNull) AEDisposeDesc(&aeDesc);
+       return;
+}
+
+
+static void
+notify_remove(MyType *myInstance, Boolean cancel)
+{
+       if (myInstance->userInterfaces != NULL) {
+               CFRelease(myInstance->userInterfaces);
+               myInstance->userInterfaces = NULL;
+       }
+
+       if (myInstance->userRls != NULL) {
+               CFRunLoopSourceInvalidate(myInstance->userRls);
+               CFRelease(myInstance->userRls);
+               myInstance->userRls = NULL;
+       }
+
+       if (myInstance->userNotification != NULL) {
+               if (cancel) {
+                       SInt32  status;
+
+                       status = CFUserNotificationCancel(myInstance->userNotification);
+                       if (status != 0) {
+                               SCLog(TRUE, LOG_ERR,
+                                     CFSTR("SCMonitor: CFUserNotificationCancel() failed, status=%d"),
+                                     status);
+                       }
+               }
+               CFRelease(myInstance->userNotification);
+               myInstance->userNotification = NULL;
+       }
+
+       return;
+}
+
+
+static void
+notify_reply(CFUserNotificationRef userNotification, CFOptionFlags response_flags)
+{
+       MyType  *myInstance     = NULL;
+
+       // get instance for notification
+       if (notify_to_instance != NULL) {
+               myInstance = (MyType *)CFDictionaryGetValue(notify_to_instance, userNotification);
+               if (myInstance != NULL) {
+                       CFDictionaryRemoveValue(notify_to_instance, userNotification);
+                       if (CFDictionaryGetCount(notify_to_instance) == 0) {
+                               CFRelease(notify_to_instance);
+                               notify_to_instance = NULL;
+                       }
+               }
+       }
+       if (myInstance == NULL) {
+               SCLog(TRUE, LOG_ERR, CFSTR("SCMonitor: can't find user notification"));
+               return;
+       }
+
+       // process response
+       switch (response_flags & 0x3) {
+               case kCFUserNotificationDefaultResponse:
+                       // user asked to configure interface
+                       open_NetworkPrefPane();
+                       break;
+               default:
+                       // user cancelled
+                       break;
+       }
+
+       notify_remove(myInstance, FALSE);
+       return;
+}
+
+static void
+notify_add(MyType *myInstance)
+{
+       CFBundleRef             bundle;
+       CFMutableDictionaryRef  dict    = NULL;
+       SInt32                  error   = 0;
+       CFIndex                 i;
+       CFMutableArrayRef       message;
+       CFIndex                 n       = CFArrayGetCount(myInstance->userInterfaces);
+       CFURLRef                url     = NULL;
+
+       if (myInstance->userNotification != NULL) {
+               CFMutableArrayRef       save    = NULL;
+
+               if (n > 0) {
+                       CFRetain(myInstance->userInterfaces);
+                       save = myInstance->userInterfaces;
+               }
+               notify_remove(myInstance, TRUE);
+               myInstance->userInterfaces = save;
+               if (n == 0) {
+                       return;
+               }
+       }
+
+       dict = CFDictionaryCreateMutable(NULL,
+                                        0,
+                                        &kCFTypeDictionaryKeyCallBacks,
+                                        &kCFTypeDictionaryValueCallBacks);
+
+       // set localization URL
+       bundle = CFBundleGetBundleWithIdentifier(MY_BUNDLE_ID);
+       if (bundle != NULL) {
+               url = CFBundleCopyBundleURL(bundle);
+       }
+       if (url != NULL) {
+               // set URL
+               CFDictionarySetValue(dict, kCFUserNotificationLocalizationURLKey, url);
+               CFRelease(url);
+       } else {
+               SCLog(TRUE, LOG_NOTICE, CFSTR("SCMonitor: can't find bundle"));
+               goto done;
+       }
+
+       // set icon URL
+       url = CFURLCreateFromFileSystemRepresentation(NULL,
+                                                     (const UInt8 *)MY_ICON_PATH,
+                                                     strlen(MY_ICON_PATH),
+                                                     FALSE);
+       if (url != NULL) {
+               CFDictionarySetValue(dict, kCFUserNotificationIconURLKey, url);
+               CFRelease(url);
+       }
+
+       // header
+       CFDictionarySetValue(dict,
+                            kCFUserNotificationAlertHeaderKey,
+                            (n == 1) ? CFSTR("HEADER_1") : CFSTR("HEADER_N"));
+
+       // message
+       message = CFArrayCreateMutable(NULL, 0, &kCFTypeArrayCallBacks);
+       CFArrayAppendValue(message,
+                          (n == 1) ? CFSTR("MESSAGE_S1") : CFSTR("MESSAGE_SN"));
+       for (i = 0; i < n; i++) {
+               SCNetworkInterfaceRef   interface;
+               CFStringRef             name;
+
+               interface = CFArrayGetValueAtIndex(myInstance->userInterfaces, i);
+               name = SCNetworkInterfaceGetLocalizedDisplayName(interface);
+               if (n == 1) {
+                       CFArrayAppendValue(message, name);
+               } else {
+                       CFStringRef     str;
+
+                       str = CFStringCreateWithFormat(NULL, NULL, CFSTR("\r\t%@"), name);
+                       CFArrayAppendValue(message, str);
+                       CFRelease(str);
+               }
+       }
+       CFArrayAppendValue(message,
+                          (n == 1) ? CFSTR("MESSAGE_E1") : CFSTR("MESSAGE_EN"));
+       CFDictionarySetValue(dict, kCFUserNotificationAlertMessageKey, message);
+       CFRelease(message);
+
+       // button titles
+       CFDictionaryAddValue(dict, kCFUserNotificationDefaultButtonTitleKey,   CFSTR("OPEN_NP"));
+       CFDictionaryAddValue(dict, kCFUserNotificationAlternateButtonTitleKey, CFSTR("CANCEL"));
+
+       // create and post notification
+       myInstance->userNotification = CFUserNotificationCreate(NULL,
+                                                               0,
+                                                               kCFUserNotificationNoteAlertLevel,
+                                                               &error,
+                                                               dict);
+       if (myInstance->userNotification == NULL) {
+               SCLog(TRUE, LOG_ERR, CFSTR("SCMonitor: CFUserNotificationCreate() failed, %d"), error);
+               goto done;
+       }
+
+       // establish callback
+       myInstance->userRls = CFUserNotificationCreateRunLoopSource(NULL,
+                                                                   myInstance->userNotification,
+                                                                   notify_reply,
+                                                                   0);
+       if (myInstance->userRls == NULL) {
+               SCLog(TRUE, LOG_ERR, CFSTR("SCMonitor: CFUserNotificationCreateRunLoopSource() failed"));
+               CFRelease(myInstance->userNotification);
+               myInstance->userNotification = NULL;
+               goto done;
+       }
+       CFRunLoopAddSource(CFRunLoopGetCurrent(), myInstance->userRls,  kCFRunLoopDefaultMode);
+
+       // add instance for notification
+       if (notify_to_instance == NULL) {
+               notify_to_instance = CFDictionaryCreateMutable(NULL,
+                                                              0,
+                                                              &kCFTypeDictionaryKeyCallBacks,
+                                                              NULL);   // no retain/release/... for values
+       }
+       CFDictionarySetValue(notify_to_instance, myInstance->userNotification, myInstance);
+
+    done :
+
+       if (dict != NULL) CFRelease(dict);
+       return;
+}
+
+
+static void
+updateInterfaceList(SCDynamicStoreRef store, CFArrayRef changes, void * arg)
+{
+       CFIndex                 i;
+       CFArrayRef              interfaces;
+       MyType                  *myInstance     = (MyType *)arg;
+       CFIndex                 n;
+       SCPreferencesRef        prefs;
+       CFMutableSetRef         previouslyKnown = NULL;
+       SCNetworkSetRef         set             = NULL;
+
+       prefs = SCPreferencesCreate(NULL, CFSTR("SCMonitor"), NULL);
+       if (prefs == NULL) {
+               return;
+       }
+
+       set = SCNetworkSetCopyCurrent(prefs);
+       if (set == NULL) {
+               set = SCNetworkSetCreate(prefs);
+               if (set == NULL) {
+                       goto done;
+               }
+       }
+
+       previouslyKnown = CFSetCreateMutableCopy(NULL, 0, myInstance->knownInterfaces);
+
+       interfaces = SCNetworkInterfaceCopyAll();
+       if (interfaces != NULL) {
+
+               n = CFArrayGetCount(interfaces);
+               for (i = 0; i < n; i++) {
+                       CFStringRef             bsdName;
+                       SCNetworkInterfaceRef   interface;
+                       Boolean                 ok;
+
+                       interface = CFArrayGetValueAtIndex(interfaces, i);
+                       bsdName = SCNetworkInterfaceGetBSDName(interface);
+                       if (bsdName == NULL) {
+                               // if no BSD name
+                               continue;
+                       }
+
+                       CFSetRemoveValue(previouslyKnown, bsdName);
+
+                       if (CFSetContainsValue(myInstance->knownInterfaces, bsdName)) {
+                               // if known interface
+                               continue;
+                       }
+
+                       CFSetAddValue(myInstance->knownInterfaces, bsdName);
+
+                       ok = SCNetworkSetEstablishDefaultInterfaceConfiguration(set, interface);
+                       if (ok) {
+                               // this is a *new* interface
+                               if (myInstance->userInterfaces == NULL) {
+                                       myInstance->userInterfaces = CFArrayCreateMutable(NULL, 0, &kCFTypeArrayCallBacks);
+                               }
+                               CFArrayAppendValue(myInstance->userInterfaces, interface);
+                       }
+               }
+
+               CFRelease(interfaces);
+       }
+
+       n = CFSetGetCount(previouslyKnown);
+       if (n > 0) {
+               const void *    names_q[32];
+               const void **   names                 = names_q;
+
+               if (n > (CFIndex)(sizeof(names_q) / sizeof(CFTypeRef)))
+                       names = CFAllocatorAllocate(NULL, n * sizeof(CFTypeRef), 0);
+               CFSetGetValues(previouslyKnown, names);
+               for (i = 0; i < n; i++) {
+                       if (myInstance->userInterfaces != NULL) {
+                               CFIndex j;
+
+                               j = CFArrayGetCount(myInstance->userInterfaces);
+                               while (--j >= 0) {
+                                       CFStringRef             bsdName;
+                                       SCNetworkInterfaceRef   interface;
+
+                                       interface = CFArrayGetValueAtIndex(myInstance->userInterfaces, j);
+                                       bsdName = SCNetworkInterfaceGetBSDName(interface);
+                                       if (CFEqual(bsdName, names[i])) {
+                                               // if we have previously posted a notification
+                                               // for this no-longer-present interface
+                                               CFArrayRemoveValueAtIndex(myInstance->userInterfaces, j);
+                                       }
+                               }
+                       }
+
+                       CFSetRemoveValue(myInstance->knownInterfaces, names[i]);
+               }
+               if (names != names_q)       CFAllocatorDeallocate(NULL, names);
+       }
+
+    done :
+
+       // post notification
+       if (myInstance->userInterfaces != NULL) {
+               notify_add(myInstance);
+       }
+
+       if (set != NULL) CFRelease(set);
+       CFRelease(prefs);
+       return;
+}
+
+
+static void
+watcher_remove(MyType *myInstance)
+{
+       if (myInstance->monitorRls != NULL) {
+               CFRunLoopSourceInvalidate(myInstance->monitorRls);
+               CFRelease(myInstance->monitorRls);
+               myInstance->monitorRls = NULL;
+       }
+
+       if (myInstance->knownInterfaces != NULL) {
+               CFRelease(myInstance->knownInterfaces);
+               myInstance->knownInterfaces = NULL;
+       }
+
+       return;
+}
+
+
+static void
+watcher_add(MyType *myInstance)
+{
+       SCDynamicStoreContext   context = { 0, (void *)myInstance, NULL, NULL, NULL };
+       CFDictionaryRef         dict;
+       CFStringRef             key;
+       CFArrayRef              keys;
+       SCDynamicStoreRef       store;
+
+       store = SCDynamicStoreCreate(NULL, CFSTR("SCMonitor"), updateInterfaceList, &context);
+       if (store == NULL) {
+               SCLog(TRUE, LOG_ERR,
+                     CFSTR("SCMonitor: SCDynamicStoreCreate() failed: %s"),
+                     SCErrorString(SCError()));
+               return;
+       }
+
+       key = SCDynamicStoreKeyCreateNetworkInterface(NULL, kSCDynamicStoreDomainState);
+
+       // watch for changes to the list of network interfaces
+       keys = CFArrayCreate(NULL, (const void **)&key, 1, &kCFTypeArrayCallBacks);
+       SCDynamicStoreSetNotificationKeys(store, NULL, keys);
+       CFRelease(keys);
+       myInstance->monitorRls = SCDynamicStoreCreateRunLoopSource(NULL, store, 0);
+       CFRunLoopAddSource(CFRunLoopGetCurrent(),
+                          myInstance->monitorRls,
+                          kCFRunLoopDefaultMode);
+
+       // initialize the list of known interfaces
+       myInstance->knownInterfaces = CFSetCreateMutable(NULL, 0, &kCFTypeSetCallBacks);
+       dict = SCDynamicStoreCopyValue(store, key);
+       if (dict != NULL) {
+               if (isA_CFDictionary(dict)) {
+                       CFIndex         i;
+                       CFArrayRef      interfaces;
+                       CFIndex         n;
+
+                       interfaces = CFDictionaryGetValue(dict, kSCPropNetInterfaces);
+                       n = isA_CFArray(interfaces) ? CFArrayGetCount(interfaces) : 0;
+                       for (i = 0; i < n; i++) {
+                               CFStringRef     bsdName;
+
+                               bsdName = CFArrayGetValueAtIndex(interfaces, i);
+                               if (isA_CFString(bsdName)) {
+                                       CFSetAddValue(myInstance->knownInterfaces, bsdName);
+                               }
+                       }
+               }
+
+               CFRelease(dict);
+       }
+
+       CFRelease(key);
+       CFRelease(store);
+       return;
+}
+
+
+#pragma mark -
+#pragma mark UserEventAgent stubs
+
+
+static HRESULT
+myQueryInterface(void *myInstance, REFIID iid, LPVOID *ppv)
+{
+       CFUUIDRef       interfaceID     = CFUUIDCreateFromUUIDBytes(NULL, iid);
+
+       // Test the requested ID against the valid interfaces.
+       if (CFEqual(interfaceID, kUserEventAgentInterfaceID)) {
+               ((MyType *) myInstance)->_UserEventAgentInterface->AddRef(myInstance);
+               *ppv = myInstance;
+               CFRelease(interfaceID);
+               return S_OK;
+       }
+
+       if (CFEqual(interfaceID, IUnknownUUID)) {
+               ((MyType *) myInstance)->_UserEventAgentInterface->AddRef(myInstance);
+               *ppv = myInstance;
+               CFRelease(interfaceID);
+               return S_OK;
+       }
+
+       // Requested interface unknown, bail with error.
+       *ppv = NULL;
+       CFRelease(interfaceID);
+       return E_NOINTERFACE;
+}
+
+
+static ULONG
+myAddRef(void *myInstance)
+{
+       ((MyType *) myInstance)->_refCount++;
+       return ((MyType *) myInstance)->_refCount;
+}
+
+
+static ULONG
+myRelease(void *myInstance)
+{
+       ((MyType *) myInstance)->_refCount--;
+       if (((MyType *) myInstance)->_refCount == 0) {
+               CFUUIDRef       factoryID       = ((MyType *) myInstance)->_factoryID;
+
+               if (factoryID != NULL) {
+                       CFPlugInRemoveInstanceForFactory(factoryID);
+                       CFRelease(factoryID);
+
+                       watcher_remove((MyType *)myInstance);
+                       notify_remove((MyType *)myInstance, TRUE);
+               }
+               free(myInstance);
+               return 0;
+       }
+
+       return ((MyType *) myInstance)->_refCount;
+}
+
+
+static void
+myInstall(void *myInstance)
+{
+       watcher_add((MyType *)myInstance);
+       return;
+}
+
+
+static UserEventAgentInterfaceStruct UserEventAgentInterfaceFtbl = {
+       NULL,                   // Required padding for COM
+       myQueryInterface,       // These three are the required COM functions
+       myAddRef,
+       myRelease,
+       myInstall               // Interface implementation
+};
+
+
+void *
+UserEventAgentFactory(CFAllocatorRef allocator, CFUUIDRef typeID)
+{
+       MyType  *newOne = NULL;
+
+       if (CFEqual(typeID, kUserEventAgentTypeID)) {
+               newOne  = (MyType *)malloc(sizeof(MyType));
+               bzero(newOne, sizeof(*newOne));
+               newOne->_UserEventAgentInterface = &UserEventAgentInterfaceFtbl;
+               newOne->_factoryID = (CFUUIDRef)CFRetain(kUserEventAgentFactoryID);
+               CFPlugInAddInstanceForFactory(kUserEventAgentFactoryID);
+               newOne->_refCount = 1;
+       }
+
+       return newOne;
+}
+
+
+#ifdef MAIN
+int
+main(int argc, char **argv)
+{
+       MyType *newOne = (MyType *)malloc(sizeof(MyType));
+
+       _sc_log     = FALSE;
+       _sc_verbose = (argc > 1) ? TRUE : FALSE;
+
+       bzero(newOne, sizeof(*newOne));
+       myInstall(newOne);
+       CFRunLoopRun();
+       exit(0);
+       return (0);
+}
+#endif // MAIN
index 1c9c12fce6b57f96ea0f6c9bf397693af2f1ee76..a297a9afed60a20ef619d1582ebee14edad70932 100644 (file)
Binary files a/SystemConfiguration.fproj/English.lproj/NetworkInterface.strings and b/SystemConfiguration.fproj/English.lproj/NetworkInterface.strings differ
index 9b342a72397c916873d115035229b41d64d429c7..7df7a6fb431d1f799b13bbb3b5965f2550ae31ee 100644 (file)
@@ -1,5 +1,5 @@
 <?xml version="1.0" encoding="UTF-8"?>
-<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
+<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
 <plist version="1.0">
 <dict>
        <key>CFBundleDevelopmentRegion</key>
@@ -7,7 +7,7 @@
        <key>CFBundleExecutable</key>
        <string>SystemConfiguration</string>
        <key>CFBundleGetInfoString</key>
-       <string>1.9.0</string>
+       <string>1.9.1</string>
        <key>CFBundleIdentifier</key>
        <string>com.apple.SystemConfiguration</string>
        <key>CFBundleInfoDictionaryVersion</key>
        <key>CFBundlePackageType</key>
        <string>FMWK</string>
        <key>CFBundleShortVersionString</key>
-       <string>1.9.0</string>
+       <string>1.9.1</string>
        <key>CFBundleSignature</key>
        <string>????</string>
        <key>CFBundleVersion</key>
-       <string>1.9.0</string>
+       <string>1.9.1</string>
 </dict>
 </plist>
index f516c823e362b73afce1ce57440047647b0839e7..5203eb50435463526d6a682ffe5b52255a63c844 100644 (file)
@@ -64,6 +64,9 @@ typedef struct {
        // prefs
        SCPreferencesRef        prefs;
 
+       // name
+       CFStringRef             name;
+
 } SCNetworkServicePrivate, *SCNetworkServicePrivateRef;
 
 
index a51cd295c2b206e3ef572ce93d11ba12ae100181..9d00ed522fd7c703ded5edfc0ed778271d0c613c 100644 (file)
@@ -375,6 +375,26 @@ isA_SCNetworkSet(CFTypeRef obj)
 Boolean
 SCNetworkSetEstablishDefaultConfiguration              (SCNetworkSetRef                set);
 
+/*!
+       @function SCNetworkSetEstablishDefaultInterfaceConfiguration
+       @discussion Updates a network set by adding services for
+               the specified network interface if is not currently
+               represented.
+               If the provided set contains one (or more) services, new
+               services will only be added for interfaces that are not
+               represented in *any* set.
+               Otherwise, new services will be added for interfaces that
+               are not represented in the provided set.
+               The new services are established with "default" configuration
+               options.
+       @param set The network set.
+       @param interface The network interface.
+       @result TRUE if the configuration was updated; FALSE if no
+               changes were required or if an error was encountered.
+ */
+Boolean
+SCNetworkSetEstablishDefaultInterfaceConfiguration     (SCNetworkSetRef                set,
+                                                        SCNetworkInterfaceRef          interface);
 
 __END_DECLS
 
index d695a6a889ec4bca9cdf4fc88c7a300eb32efdda..dd834531076681503fd5a3f17676e885753e3383 100644 (file)
@@ -1342,6 +1342,40 @@ processNetworkInterface(SCNetworkInterfacePrivateRef     interfacePrivate,
                                                                interfacePrivate->localized_arg2 = port_name;
                                                        }
                                                }
+                                       } else if (CFEqual(provider, CFSTR("IOUSBDevice"))) {
+                                               CFTypeRef       val;
+
+                                               // check if a "Product Name" has been provided
+                                               val = IORegistryEntrySearchCFProperty(interface,
+                                                                                     kIOServicePlane,
+                                                                                     CFSTR(kIOPropertyProductNameKey),
+                                                                                     NULL,
+                                                                                     kIORegistryIterateRecursively | kIORegistryIterateParents);
+                                               if (val != NULL) {
+                                                       CFStringRef     productName;
+
+                                                       productName = IOCopyCFStringValue(val);
+                                                       CFRelease(val);
+
+                                                       if (productName != NULL) {
+                                                               if (CFStringGetLength(productName) > 0) {
+                                                                       // if we have a [somewhat reasonable?] product name
+                                                                       if (interfacePrivate->name != NULL) {
+                                                                               CFRelease(interfacePrivate->name);
+                                                                       }
+                                                                       interfacePrivate->name = CFRetain(productName);
+                                                                       if (interfacePrivate->localized_name != NULL) {
+                                                                               CFRelease(interfacePrivate->localized_name);
+                                                                       }
+                                                                       interfacePrivate->localized_name = copy_interface_string(bundle, productName, TRUE);
+                                                               }
+
+                                                               CFRelease(productName);
+                                                       }
+                                               } else {
+                                                       interfacePrivate->localized_key  = CFSTR("usb-ether");
+                                                       interfacePrivate->localized_arg1 = IODictionaryCopyCFStringValue(interface_dict, CFSTR(kIOBSDNameKey));
+                                               }
                                        }
                                        CFRelease(provider);
                                }
@@ -1759,7 +1793,7 @@ processSerialInterface(SCNetworkInterfacePrivateRef       interfacePrivate,
                                                if (interfacePrivate->localized_name != NULL) {
                                                        CFRelease(interfacePrivate->localized_name);
                                                }
-                                               interfacePrivate->localized_name = CFRetain(productName);
+                                               interfacePrivate->localized_name = copy_interface_string(bundle, productName, TRUE);
 
                                                // if not provided, also check if the product name
                                                // matches a CCL script
index 8245e5ccebbeee60926480b67d6318b26cd53b24..43725da48745d95f266718001eef564a7f57cd1e 100644 (file)
@@ -75,6 +75,9 @@ __SCNetworkServiceCopyDescription(CFTypeRef cf)
        CFStringAppendFormat(result, NULL, CFSTR("<SCNetworkService %p [%p]> {"), cf, allocator);
        CFStringAppendFormat(result, NULL, CFSTR("id = %@"), servicePrivate->serviceID);
        CFStringAppendFormat(result, NULL, CFSTR(", prefs = %p"), servicePrivate->prefs);
+       if (servicePrivate->name != NULL) {
+               CFStringAppendFormat(result, NULL, CFSTR(", name = %@"), servicePrivate->name);
+       }
        CFStringAppendFormat(result, NULL, CFSTR("}"));
 
        return result;
@@ -89,8 +92,9 @@ __SCNetworkServiceDeallocate(CFTypeRef cf)
        /* release resources */
 
        CFRelease(servicePrivate->serviceID);
-       if (servicePrivate->interface != NULL)  CFRelease(servicePrivate->interface);
+       if (servicePrivate->interface != NULL) CFRelease(servicePrivate->interface);
        CFRelease(servicePrivate->prefs);
+       if (servicePrivate->name != NULL) CFRelease(servicePrivate->name);
 
        return;
 }
@@ -157,6 +161,7 @@ __SCNetworkServiceCreatePrivate(CFAllocatorRef              allocator,
        servicePrivate->prefs           = CFRetain(prefs);
        servicePrivate->serviceID       = CFStringCreateCopy(NULL, serviceID);
        servicePrivate->interface       = (interface != NULL) ? CFRetain(interface) : NULL;
+       servicePrivate->name            = NULL;
 
        return servicePrivate;
 }
@@ -659,7 +664,7 @@ SCNetworkServiceCreate(SCPreferencesRef prefs, SCNetworkInterfaceRef interface)
                                // update template for v.92 modems
                                if ((overrides == NULL) &&
                                    CFDictionaryGetValueIfPresent(config,
-                                                                 kSCPropNetModemConnectionScript,
+                                                                 kSCPropNetModemConnectionScript,
                                                                  (const void **)&script) &&
                                    CFEqual(script, CFSTR("v.34 Personality")) &&
                                    _SCNetworkInterfaceIsModemV92(interface)) {
@@ -861,6 +866,10 @@ SCNetworkServiceGetName(SCNetworkServiceRef service)
                return NULL;
        }
 
+       if (servicePrivate->name != NULL) {
+               return servicePrivate->name;
+       }
+
        path = SCPreferencesPathKeyCreateNetworkServiceEntity(NULL,                             // allocator
                                                              servicePrivate->serviceID,        // service
                                                              NULL);                            // entity
@@ -869,7 +878,9 @@ SCNetworkServiceGetName(SCNetworkServiceRef service)
 
        if (isA_CFDictionary(entity)) {
                name = CFDictionaryGetValue(entity, kSCPropUserDefinedName);
-               name = isA_CFString(name);
+               if (isA_CFString(name)) {
+                       servicePrivate->name = CFRetain(name);
+               }
        }
 
        interface = SCNetworkServiceGetInterface(service);
@@ -885,23 +896,48 @@ SCNetworkServiceGetName(SCNetworkServiceRef service)
        }
 
        if (interface != NULL) {
-               if (name != NULL) {
-                       CFStringRef     interface_name;
+               CFStringRef     interface_name;
+               CFStringRef     suffix          = NULL;
 
+               if (servicePrivate->name != NULL) {
                        interface_name = __SCNetworkInterfaceGetNonLocalizedDisplayName(interface);
-                       if ((interface_name != NULL) && CFEqual(name, interface_name)) {
-                               // if service name matches the [non-]localized
-                               // interface name
-                               name = NULL;
+                       if (interface_name != NULL) {
+                               if (CFEqual(name, interface_name)) {
+                                       // if service name matches the [non-]localized
+                                       // interface name
+                                       CFRelease(servicePrivate->name);
+                                       servicePrivate->name = NULL;
+                               } else if (CFStringHasPrefix(name, interface_name)) {
+                                       CFIndex prefixLen       = CFStringGetLength(interface_name);
+                                       CFIndex suffixLen       = CFStringGetLength(name);
+
+                                       suffix = CFStringCreateWithSubstring(NULL,
+                                                                            name,
+                                                                            CFRangeMake(prefixLen, suffixLen - prefixLen));
+                                       CFRelease(servicePrivate->name);
+                                       servicePrivate->name = NULL;
+                               }
                        }
                }
 
-               if (name == NULL) {
-                       name = SCNetworkInterfaceGetLocalizedDisplayName(interface);
+               if (servicePrivate->name == NULL) {
+                       interface_name = SCNetworkInterfaceGetLocalizedDisplayName(interface);
+                       if (interface_name != NULL) {
+                               if (suffix != NULL) {
+                                       servicePrivate->name = CFStringCreateWithFormat(NULL,
+                                                                                       NULL,
+                                                                                       CFSTR("%@%@"),
+                                                                                       interface_name,
+                                                                                       suffix);
+                               } else {
+                                       servicePrivate->name = CFRetain(interface_name);
+                               }
+                       }
                }
+               if (suffix != NULL) CFRelease(suffix);
        }
 
-       return name;
+       return servicePrivate->name;
 }
 
 
@@ -1039,6 +1075,7 @@ SCNetworkServiceSetName(SCNetworkServiceRef service, CFStringRef name)
        CFDictionaryRef                 entity;
        Boolean                         ok              = FALSE;
        CFStringRef                     path;
+       CFStringRef                     saveName        = NULL;
        SCNetworkServicePrivateRef      servicePrivate  = (SCNetworkServicePrivateRef)service;
 
        if (!isA_SCNetworkService(service)) {
@@ -1046,9 +1083,12 @@ SCNetworkServiceSetName(SCNetworkServiceRef service, CFStringRef name)
                return FALSE;
        }
 
-       if ((name != NULL) && !isA_CFString(name)) {
-               _SCErrorSet(kSCStatusInvalidArgument);
-               return FALSE;
+       if (name != NULL) {
+               if (!isA_CFString(name)) {
+                       _SCErrorSet(kSCStatusInvalidArgument);
+                       return FALSE;
+               }
+               saveName = CFRetain(name);
        }
 
        if (name != NULL) {
@@ -1070,12 +1110,36 @@ SCNetworkServiceSetName(SCNetworkServiceRef service, CFStringRef name)
                        CFStringRef     interface_name;
 
                        interface_name = SCNetworkInterfaceGetLocalizedDisplayName(interface);
-                       if ((interface_name != NULL) && CFEqual(name, interface_name)) {
-                               // if service name matches the localized interface name
-                               // then store the non-localized name.
-                               interface_name = __SCNetworkInterfaceGetNonLocalizedDisplayName(interface);
-                               if (interface_name != NULL) {
-                                       name = interface_name;
+                       if (interface_name != NULL) {
+                               if (CFEqual(name, interface_name)) {
+                                       // if service name matches the localized interface name
+                                       // then store the non-localized name.
+                                       interface_name = __SCNetworkInterfaceGetNonLocalizedDisplayName(interface);
+                                       if (interface_name != NULL) {
+                                               CFRelease(saveName);
+                                               saveName = CFRetain(interface_name);
+                                       }
+                               } else if (CFStringHasPrefix(name, interface_name)) {
+                                       CFIndex         prefixLen       = CFStringGetLength(interface_name);
+                                       CFStringRef     suffix;
+                                       CFIndex         suffixLen       = CFStringGetLength(name);
+
+                                       // if service name matches the localized interface name plus
+                                       // a few extra characters) then store the non-localized name with
+                                       // the same suffix.
+                                       suffix = CFStringCreateWithSubstring(NULL,
+                                                                            name,
+                                                                            CFRangeMake(prefixLen, suffixLen - prefixLen));
+                                       interface_name = __SCNetworkInterfaceGetNonLocalizedDisplayName(interface);
+                                       if (interface_name != NULL) {
+                                               CFRelease(saveName);
+                                               saveName = CFStringCreateWithFormat(NULL,
+                                                                                   NULL,
+                                                                                   CFSTR("%@%@"),
+                                                                                   interface_name,
+                                                                                   suffix);
+                                       }
+                                       CFRelease(suffix);
                                }
                        }
                }
@@ -1134,6 +1198,7 @@ SCNetworkServiceSetName(SCNetworkServiceRef service, CFStringRef name)
                                         * the "name" is not unique.
                                         */
                                        CFRelease(sets);
+                                       if (saveName != NULL) CFRelease(saveName);
                                        _SCErrorSet(kSCStatusKeyExists);
                                        return FALSE;
                                }
@@ -1160,8 +1225,8 @@ SCNetworkServiceSetName(SCNetworkServiceRef service, CFStringRef name)
                CFMutableDictionaryRef  newEntity;
 
                newEntity = CFDictionaryCreateMutableCopy(NULL, 0, entity);
-               if (name != NULL) {
-                       CFDictionarySetValue(newEntity, kSCPropUserDefinedName, name);
+               if (saveName != NULL) {
+                       CFDictionarySetValue(newEntity, kSCPropUserDefinedName, saveName);
                } else {
                        CFDictionaryRemoveValue(newEntity, kSCPropUserDefinedName);
                }
@@ -1169,6 +1234,11 @@ SCNetworkServiceSetName(SCNetworkServiceRef service, CFStringRef name)
                CFRelease(newEntity);
        }
        CFRelease(path);
+       if (saveName != NULL) CFRelease(saveName);
+
+       if (servicePrivate->name != NULL) CFRelease(servicePrivate->name);
+       if (name != NULL) CFRetain(name);
+       servicePrivate->name = name;
 
        return ok;
 }
index 922f7e01cb6e887b1a80c7cb61cb582c3644d843..1b29b1818a19da277e4e9a00180ccd3a34aeb0ab 100644 (file)
@@ -770,7 +770,7 @@ SCNetworkSetGetName(SCNetworkSetRef set)
        }
 
        if (setPrivate->name != NULL) {
-               return setPrivate->name;;
+               return setPrivate->name;
        }
 
        path = SCPreferencesPathKeyCreateSet(NULL, setPrivate->setID);
@@ -1173,21 +1173,62 @@ add_supported_interfaces(CFMutableArrayRef interface_list, SCNetworkInterfaceRef
 }
 
 
-Boolean
-SCNetworkSetEstablishDefaultConfiguration(SCNetworkSetRef set)
+static CFStringRef
+next_service_name(SCNetworkServiceRef service)
+{
+       CFArrayRef              components;
+       CFIndex                 n;
+       CFStringRef             name;
+       CFMutableArrayRef       newComponents;
+       SInt32                  suffix  = 2;
+
+       name = SCNetworkServiceGetName(service);
+       if (name == NULL) {
+               return NULL;
+       }
+
+       components = CFStringCreateArrayBySeparatingStrings(NULL, name, CFSTR(" "));
+       if (components != NULL) {
+               newComponents = CFArrayCreateMutableCopy(NULL, 0, components);
+               CFRelease(components);
+       } else {
+               newComponents = CFArrayCreateMutable(NULL, 0, &kCFTypeArrayCallBacks);
+               CFArrayAppendValue(newComponents, name);
+       }
+
+       n = CFArrayGetCount(newComponents);
+       if (n > 1) {
+               CFStringRef     str;
+
+               str = CFArrayGetValueAtIndex(newComponents, n - 1);
+               suffix = CFStringGetIntValue(str);
+               if (suffix++ > 0) {
+                       CFArrayRemoveValueAtIndex(newComponents, n - 1);
+               } else {
+                       suffix = 2;
+               }
+       }
+
+       name = CFStringCreateWithFormat(NULL, NULL, CFSTR("%d"), suffix);
+       CFArrayAppendValue(newComponents, name);
+       CFRelease(name);
+
+       name = CFStringCreateByCombiningStrings(NULL, newComponents, CFSTR(" "));
+       CFRelease(newComponents);
+
+       return name;
+}
+
+
+static Boolean
+__SCNetworkSetEstablishDefaultConfigurationForInterfaces(SCNetworkSetRef set, CFArrayRef interfaces)
 {
        CFIndex                 i;
-       CFArrayRef              interfaces;
        CFIndex                 n;
        Boolean                 ok              = TRUE;
        CFArrayRef              services;
-       Boolean                 setUpdated      = FALSE;
        SCNetworkSetPrivateRef  setPrivate      = (SCNetworkSetPrivateRef)set;
-
-       if (!isA_SCNetworkSet(set)) {
-               _SCErrorSet(kSCStatusInvalidArgument);
-               return FALSE;
-       }
+       Boolean                 updated         = FALSE;
 
        // first, assume that we only want to add new services
        // for those interfaces that are not represented in the
@@ -1202,7 +1243,6 @@ SCNetworkSetEstablishDefaultConfiguration(SCNetworkSetRef set)
                services = SCNetworkServiceCopyAll(setPrivate->prefs);
        }
 
-       interfaces = SCNetworkInterfaceCopyAll();
        n = (interfaces != NULL) ? CFArrayGetCount(interfaces) : 0;
        for (i = 0; i < n; i++) {
                SCNetworkInterfaceRef   interface;
@@ -1247,19 +1287,57 @@ SCNetworkSetEstablishDefaultConfiguration(SCNetworkSetRef set)
                                        goto nextInterface;
                                }
 
-                               ok = SCNetworkSetAddService(set, service);
-                               if (!ok) {
-                                       SCLog(TRUE, LOG_DEBUG,
-                                             CFSTR("could not add service for \"%@\": %s\n"),
-                                             SCNetworkInterfaceGetLocalizedDisplayName(interface),
-                                             SCErrorString(SCError()));
-                                       SCNetworkServiceRemove(service);
-                                       CFRelease(service);
-                                       goto nextInterface;
+                               while (TRUE) {
+                                       CFStringRef     newName;
+
+                                       ok = SCNetworkSetAddService(set, service);
+                                       if (ok) {
+                                               break;
+                                       }
+
+                                       if (SCError() != kSCStatusKeyExists) {
+                                               SCLog(TRUE, LOG_DEBUG,
+                                                     CFSTR("could not add service for \"%@\": %s\n"),
+                                                     SCNetworkInterfaceGetLocalizedDisplayName(interface),
+                                                     SCErrorString(SCError()));
+                                               SCNetworkServiceRemove(service);
+                                               CFRelease(service);
+                                               goto nextInterface;
+                                       }
+
+                                       // we have two interfaces with the same service
+                                       // name, acquire a new, hopefully unique, name
+
+                                       newName = next_service_name(service);
+                                       if (newName == NULL) {
+                                               SCLog(TRUE, LOG_DEBUG,
+                                                     CFSTR("could not set unique name for \"%@\": %s\n"),
+                                                     SCNetworkInterfaceGetLocalizedDisplayName(interface),
+                                                     SCErrorString(SCError()));
+                                               SCNetworkServiceRemove(service);
+                                               CFRelease(service);
+                                               goto nextInterface;
+                                       }
+
+                                       ok = SCNetworkServiceSetName(service, newName);
+                                       CFRelease(newName);
+                                       if (ok) {
+                                               continue;
+                                       }
+
+                                       if (SCError() != kSCStatusKeyExists) {
+                                               SCLog(TRUE, LOG_DEBUG,
+                                                     CFSTR("could not set unique name for \"%@\": %s\n"),
+                                                     SCNetworkInterfaceGetLocalizedDisplayName(interface),
+                                                     SCErrorString(SCError()));
+                                               SCNetworkServiceRemove(service);
+                                               CFRelease(service);
+                                               goto nextInterface;
+                                       }
                                }
 
                                CFRelease(service);
-                               setUpdated = TRUE;
+                               updated = TRUE;
                        } else {
                                add_supported_interfaces(interface_list, interface);
                        }
@@ -1270,13 +1348,56 @@ SCNetworkSetEstablishDefaultConfiguration(SCNetworkSetRef set)
                }
                CFRelease(interface_list);
        }
-       if (interfaces != NULL) CFRelease(interfaces);
        if (services != NULL)   CFRelease(services);
 
-       if (ok && !setUpdated) {
+       if (ok && !updated) {
                // if no changes were made
                _SCErrorSet(kSCStatusOK);
        }
 
-       return setUpdated;
+       return updated;
+}
+
+
+Boolean
+SCNetworkSetEstablishDefaultConfiguration(SCNetworkSetRef set)
+{
+       CFArrayRef      interfaces;
+       Boolean         updated;
+
+       if (!isA_SCNetworkSet(set)) {
+               _SCErrorSet(kSCStatusInvalidArgument);
+               return FALSE;
+       }
+
+       interfaces = SCNetworkInterfaceCopyAll();
+       updated = __SCNetworkSetEstablishDefaultConfigurationForInterfaces(set, interfaces);
+       if (interfaces != NULL) CFRelease(interfaces);
+
+       return updated;
+}
+
+
+Boolean
+SCNetworkSetEstablishDefaultInterfaceConfiguration(SCNetworkSetRef set, SCNetworkInterfaceRef interface)
+{
+       CFMutableArrayRef       interfaces;
+       Boolean                 updated;
+
+       if (!isA_SCNetworkSet(set)) {
+               _SCErrorSet(kSCStatusInvalidArgument);
+               return FALSE;
+       }
+
+       if (!isA_SCNetworkInterface(interface)) {
+               _SCErrorSet(kSCStatusInvalidArgument);
+               return FALSE;
+       }
+
+       interfaces = CFArrayCreateMutable(NULL, 0, &kCFTypeArrayCallBacks);
+       CFArrayAppendValue(interfaces, interface);
+       updated = __SCNetworkSetEstablishDefaultConfigurationForInterfaces(set, interfaces);
+       CFRelease(interfaces);
+
+       return updated;
 }
index 493c1ece7091e4700b0993d3b9281b05f5512504..0e6fcb377b68326fcf4e587205d45b8290a1954e 100644 (file)
@@ -200,7 +200,8 @@ SCPreferencesLock(SCPreferencesRef prefs, Boolean wait)
        char                    buf[32];
        SCPreferencesPrivateRef prefsPrivate    = (SCPreferencesPrivateRef)prefs;
        int                     sc_status       = kSCStatusFailed;
-       struct stat             statbuf;
+       struct stat             statBuf;
+       struct stat             statBuf2;
 
        if (prefs == NULL) {
                /* sorry, you must provide a session */
@@ -242,54 +243,52 @@ SCPreferencesLock(SCPreferencesRef prefs, Boolean wait)
 
     retry :
 
-       prefsPrivate->lockFD = open(prefsPrivate->lockPath, O_WRONLY|O_CREAT, 0644);
+       prefsPrivate->lockFD = open(prefsPrivate->lockPath,
+                                   wait ? O_WRONLY|O_CREAT|O_EXLOCK
+                                        : O_WRONLY|O_CREAT|O_EXLOCK|O_NONBLOCK,
+                                   0644);
        if (prefsPrivate->lockFD == -1) {
-               if (errno == EROFS) {
-                       goto locked;
-               }
-
-               if ((errno == ENOENT) &&
-                   ((prefsPrivate->prefsID == NULL) || !CFStringHasPrefix(prefsPrivate->prefsID, CFSTR("/")))) {
-                       int     ret;
-
-                       // create parent (/Library/Preferences/SystemConfiguration)
-                       ret = createParentDirectory(prefsPrivate->lockPath);
-                       if (ret == 0) {
-                               SCLog(TRUE, LOG_NOTICE,
-                                     CFSTR("created directory for \"%s\""),
-                                     prefsPrivate->newPath ? prefsPrivate->newPath : prefsPrivate->path);
-                               goto retry;
-                       } else if (errno == EROFS) {
-                               goto locked;
-                       }
-               }
-
-               sc_status = errno;
-               SCLog(TRUE, LOG_ERR,
-                     CFSTR("SCPreferencesLock open() failed: %s"),
-                     strerror(errno));
-               goto error;
-       }
-
-       if (flock(prefsPrivate->lockFD, wait ? LOCK_EX : LOCK_EX|LOCK_NB) == -1) {
                switch (errno) {
+                       case ENOENT :
+                               if ((prefsPrivate->prefsID == NULL) ||
+                                   !CFStringHasPrefix(prefsPrivate->prefsID, CFSTR("/"))) {
+                                       int     ret;
+
+                                       // create parent (/Library/Preferences/SystemConfiguration)
+                                       ret = createParentDirectory(prefsPrivate->lockPath);
+                                       if (ret == 0) {
+                                               SCLog(TRUE, LOG_NOTICE,
+                                                     CFSTR("created directory for \"%s\""),
+                                                     prefsPrivate->newPath ? prefsPrivate->newPath : prefsPrivate->path);
+                                               goto retry;
+                                       } else if (errno == EROFS) {
+                                               goto locked;
+                                       }
+                               }
+                               break;
+                       case EROFS :
+                               // if read-only filesystem
+                               goto locked;
                        case EWOULDBLOCK :
                                // if already locked (and we are not blocking)
                                sc_status = kSCStatusPrefsBusy;
-                               break;
+                               goto error;
                        default :
-                               sc_status = errno;
-                               SCLog(TRUE, LOG_ERR,
-                                     CFSTR("SCPreferencesLock flock() failed: %s"),
-                                     strerror(errno));
                                break;
                }
 
+               sc_status = errno;
+               SCLog(TRUE, LOG_ERR,
+                     CFSTR("SCPreferencesLock open() failed: %s"),
+                     strerror(errno));
                goto error;
        }
 
-       if (stat(prefsPrivate->lockPath, &statbuf) == -1) {
-               // if the lock file was unlinked
+       if ((stat(prefsPrivate->lockPath, &statBuf) == -1) ||
+           (fstat(prefsPrivate->lockFD, &statBuf2) == -1) ||
+           (statBuf.st_dev != statBuf2.st_dev) ||
+           (statBuf.st_ino != statBuf2.st_ino)) {
+               // if the lock file was unlinked or re-created
                close(prefsPrivate->lockFD);
                prefsPrivate->lockFD = -1;
                goto retry;
@@ -305,7 +304,6 @@ SCPreferencesLock(SCPreferencesRef prefs, Boolean wait)
        if (prefsPrivate->accessed) {
                CFDataRef       currentSignature;
                Boolean         match;
-               struct stat     statBuf;
 
                /*
                 * the preferences have been accessed since the
index d8a13650027e522bed7002bcaacb8dfcdc019998..7ea196835a63d43895c3d4cd44c8b1fc7d82176d 100644 (file)
@@ -199,7 +199,6 @@ __SCPreferencesCreate_helper(SCPreferencesRef prefs)
        Boolean                 ok;
        SCPreferencesPrivateRef prefsPrivate    = (SCPreferencesPrivateRef)prefs;
        uint32_t                status          = kSCStatusOK;
-       CFDataRef               reply           = NULL;
 
        // start helper
        prefsPrivate->helper = _SCHelperOpen(prefsPrivate->authorizationData);
@@ -216,8 +215,6 @@ __SCPreferencesCreate_helper(SCPreferencesRef prefs)
        }
 
        // have the helper "open" the prefs
-       status = kSCStatusOK;
-       reply  = NULL;
        ok = _SCHelperExec(prefsPrivate->helper,
                           SCHELPER_MSG_PREFS_OPEN,
                           data,
@@ -271,8 +268,6 @@ __SCPreferencesAccess_helper(SCPreferencesRef prefs)
        }
 
        // have the helper "access" the prefs
-       status = kSCStatusOK;
-       reply  = NULL;
        ok = _SCHelperExec(prefsPrivate->helper,
                           SCHELPER_MSG_PREFS_ACCESS,
                           NULL,
@@ -853,6 +848,36 @@ SCPreferencesUnscheduleFromRunLoop(SCPreferencesRef     prefs,
 }
 
 
+static void
+__SCPreferencesSynchronize_helper(SCPreferencesRef prefs)
+{
+       Boolean                 ok;
+       SCPreferencesPrivateRef prefsPrivate    = (SCPreferencesPrivateRef)prefs;
+       uint32_t                status          = kSCStatusOK;
+       
+       if (prefsPrivate->helper == -1) {
+               // if no helper
+               return;
+       }
+       
+       // have the helper "synchronize" the prefs
+       ok = _SCHelperExec(prefsPrivate->helper,
+                          SCHELPER_MSG_PREFS_SYNCHRONIZE,
+                          NULL,
+                          &status,
+                          NULL);
+       if (!ok) {
+               // close helper
+               if (prefsPrivate->helper != -1) {
+                       _SCHelperClose(prefsPrivate->helper);
+                       prefsPrivate->helper = -1;
+               }
+       }
+       
+       return;
+}
+
+
 void
 SCPreferencesSynchronize(SCPreferencesRef       prefs)
 {
@@ -864,6 +889,10 @@ SCPreferencesSynchronize(SCPreferencesRef       prefs)
                return;
        }
 
+       if (prefsPrivate->authorizationData != NULL) {
+               __SCPreferencesSynchronize_helper(prefs);
+       }
+
        if (prefsPrivate->prefs != NULL) {
                CFRelease(prefsPrivate->prefs);
                prefsPrivate->prefs = NULL;
index 384279345c7459b46dd91827b7f7db3cfe6d35a4..3fb24bb28eb12825eb4e065fa5fa8c2bfcabb8c5 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2005, 2006 Apple Computer, Inc. All rights reserved.
+ * Copyright (c) 2005-2007 Apple Inc. All rights reserved.
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
@@ -46,6 +46,7 @@ enum {
        SCHELPER_MSG_PREFS_APPLY,
        SCHELPER_MSG_PREFS_UNLOCK,
        SCHELPER_MSG_PREFS_CLOSE,
+       SCHELPER_MSG_PREFS_SYNCHRONIZE,
 
        // SCNetworkConfiguration
        SCHELPER_MSG_INTERFACE_REFRESH  = 200,
index 9231e08221b7ab0ba86c660910a3201551583702..7a8ca555c4ca953b13005935d8a6196ec3d5539b 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2005, 2006 Apple Computer, Inc. All rights reserved.
+ * Copyright (c) 2005-2007 Apple Inc. All rights reserved.
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
@@ -73,7 +73,7 @@ do_Auth(void *info, CFDataRef data, uint32_t *status, CFDataRef *reply)
                if (CFDataGetLength(data) == sizeof(extForm.bytes)) {
                        OSStatus        err;
 
-                       memcpy(extForm.bytes, CFDataGetBytePtr(data), sizeof(extForm.bytes));
+                       bcopy(CFDataGetBytePtr(data), extForm.bytes, sizeof(extForm.bytes));
                        err = AuthorizationCreateFromExternalForm(&extForm, &authorization);
                        if (err != errAuthorizationSuccess) {
                                SCLog(TRUE, LOG_ERR,
@@ -373,7 +373,6 @@ do_prefs_Access(void *info, CFDataRef data, uint32_t *status, CFDataRef *reply)
                *status = SCError();
        }
 
-       SCPreferencesSynchronize(prefs);
        return TRUE;
 }
 
@@ -453,7 +452,6 @@ do_prefs_Commit(void *info, CFDataRef data, uint32_t *status, CFDataRef *reply)
                *status = SCError();
        }
 
-       SCPreferencesSynchronize(prefs);
        return TRUE;
 }
 
@@ -526,6 +524,25 @@ do_prefs_Close(void *info, CFDataRef data, uint32_t *status, CFDataRef *reply)
 }
 
 
+/*
+ * SYNCHRONIZE
+ *   (in)  data   = N/A
+ *   (out) status = kSCStatusOK
+ *   (out) reply  = N/A
+ */
+static Boolean
+do_prefs_Synchronize(void *info, CFDataRef data, uint32_t *status, CFDataRef *reply)
+{
+       if (prefs == NULL) {
+               return FALSE;
+       }
+       
+       SCPreferencesSynchronize(prefs);
+       *status = kSCStatusOK;
+       return TRUE;
+}
+
+
 static Boolean
 hasAuthorization()
 {
@@ -589,6 +606,7 @@ static const struct helper {
        { SCHELPER_MSG_PREFS_APPLY,             "PREFS apply",          TRUE,   do_prefs_Apply          , NULL          },
        { SCHELPER_MSG_PREFS_UNLOCK,            "PREFS unlock",         FALSE,  do_prefs_Unlock         , NULL          },
        { SCHELPER_MSG_PREFS_CLOSE,             "PREFS close",          FALSE,  do_prefs_Close          , NULL          },
+       { SCHELPER_MSG_PREFS_SYNCHRONIZE,       "PREFS synchronize",    FALSE,  do_prefs_Synchronize    , NULL          },
 
        { SCHELPER_MSG_INTERFACE_REFRESH,       "INTERFACE refresh",    TRUE,   do_interface_refresh    , NULL          },
 
index e1e8d3f206936473ec132df8685f949ed441f669..59f21e4f601041cf94e4a9753855868dde8a95a6 100644 (file)
@@ -16,6 +16,7 @@
                                1558480607550D470046C2E9 /* PBXTargetDependency */,
                                1558480807550D470046C2E9 /* PBXTargetDependency */,
                                1558480A07550D470046C2E9 /* PBXTargetDependency */,
+                               150ECB3C0D0079280065E94D /* PBXTargetDependency */,
                        );
                        name = configd_executables;
                        productName = configd_executables;
                15DAF2DC08466D4900D1B2BD /* SCHelper_client.c in Sources */ = {isa = PBXBuildFile; fileRef = 15DAF2D808466D4900D1B2BD /* SCHelper_client.c */; };
                15DAF2DF08466D4900D1B2BD /* helper_comm.h in Headers */ = {isa = PBXBuildFile; fileRef = 15DAF2D708466D4900D1B2BD /* helper_comm.h */; };
                15DAF2E108466D4900D1B2BD /* SCHelper_server.c in Sources */ = {isa = PBXBuildFile; fileRef = 15DAF2D908466D4900D1B2BD /* SCHelper_server.c */; };
+               15E517680CCFBCD0008FFE82 /* SystemConfiguration.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 15DAD6C807591A1A0084A6ED /* SystemConfiguration.framework */; };
+               15FC130B0CCEA59E0013872C /* monitor.c in Sources */ = {isa = PBXBuildFile; fileRef = 15FC130A0CCEA59E0013872C /* monitor.c */; };
+               15FC13180CCF74740013872C /* CoreFoundation.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 15CB6A6F05C0722B0099E85F /* CoreFoundation.framework */; };
+               15FEE80E0CCFD341001312F9 /* ApplicationServices.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 15FEE80D0CCFD341001312F9 /* ApplicationServices.framework */; };
+               15FEE81F0CD03E75001312F9 /* Localizable.strings in Resources */ = {isa = PBXBuildFile; fileRef = 15FEE8180CD03CBB001312F9 /* Localizable.strings */; };
                F95B8A430B03E07A00993BA3 /* SCNetworkSignature.c in Sources */ = {isa = PBXBuildFile; fileRef = F95B8A420B03E07A00993BA3 /* SCNetworkSignature.c */; };
                F95B8A460B03E09300993BA3 /* SCNetworkSignature.h in Headers */ = {isa = PBXBuildFile; fileRef = F95B8A440B03E09300993BA3 /* SCNetworkSignature.h */; settings = {ATTRIBUTES = (Private, ); }; };
                F95B8A470B03E09300993BA3 /* SCNetworkSignaturePrivate.h in Headers */ = {isa = PBXBuildFile; fileRef = F95B8A450B03E09300993BA3 /* SCNetworkSignaturePrivate.h */; settings = {ATTRIBUTES = (Private, ); }; };
 /* End PBXBuildFile section */
 
 /* Begin PBXContainerItemProxy section */
+               150ECB3B0D0079280065E94D /* PBXContainerItemProxy */ = {
+                       isa = PBXContainerItemProxy;
+                       containerPortal = 15CB6A7705C0722B0099E85F /* Project object */;
+                       proxyType = 1;
+                       remoteGlobalIDString = 151F5D990CCE98E50093AC3B /* SCMonitor */;
+                       remoteInfo = SCMonitor;
+               };
                1520A385084681350010B584 /* PBXContainerItemProxy */ = {
                        isa = PBXContainerItemProxy;
                        containerPortal = 15CB6A7705C0722B0099E85F /* Project object */;
                1514D76D05C08A5F00757DC9 /* config_types.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; name = config_types.h; path = SystemConfiguration.fproj/config_types.h; sourceTree = SOURCE_ROOT; };
                151BDA2B05D9E28B00657BC7 /* SCPreferencesPathKey.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; name = SCPreferencesPathKey.h; path = SystemConfiguration.fproj/SCPreferencesPathKey.h; sourceTree = SOURCE_ROOT; };
                151BDA5D05D9E2ED00657BC7 /* SCPreferencesPathKey.c */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.c; name = SCPreferencesPathKey.c; path = SystemConfiguration.fproj/SCPreferencesPathKey.c; sourceTree = SOURCE_ROOT; };
+               151F5D9A0CCE98E50093AC3B /* SCMonitor.plugin */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = SCMonitor.plugin; sourceTree = BUILT_PRODUCTS_DIR; };
                151F63EC09328A3C0096DCC9 /* genSCPreferences */ = {isa = PBXFileReference; explicitFileType = "compiled.mach-o.executable"; includeInIndex = 0; path = genSCPreferences; sourceTree = BUILT_PRODUCTS_DIR; };
                1520A3DE0846B2DC0010B584 /* Security.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Security.framework; path = /System/Library/Frameworks/Security.framework; sourceTree = "<absolute>"; };
                1521FC5C060F296A003B28F5 /* dnsinfo_create.c */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.c; name = dnsinfo_create.c; path = dnsinfo/dnsinfo_create.c; sourceTree = SOURCE_ROOT; };
                15DC346C0711D49400A3311C /* net_service.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = net_service.h; sourceTree = "<group>"; };
                15DC346D0711D49400A3311C /* net_set.c */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.c; path = net_set.c; sourceTree = "<group>"; };
                15DC346E0711D49400A3311C /* net_set.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = net_set.h; sourceTree = "<group>"; };
+               15FC12F20CCEA4F00013872C /* Info.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; name = Info.plist; path = SCMonitor/Info.plist; sourceTree = "<group>"; };
+               15FC130A0CCEA59E0013872C /* monitor.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; name = monitor.c; path = SCMonitor/monitor.c; sourceTree = "<group>"; };
                15FCAACF05FD0EBF00CB79E6 /* shared_dns_info_types.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; name = shared_dns_info_types.h; path = dnsinfo/shared_dns_info_types.h; sourceTree = SOURCE_ROOT; };
                15FCAAD005FD0EBF00CB79E6 /* shared_dns_info.defs */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.mig; name = shared_dns_info.defs; path = dnsinfo/shared_dns_info.defs; sourceTree = "<group>"; };
                15FD71090754D628001CC321 /* Kicker.bundle */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = Kicker.bundle; sourceTree = BUILT_PRODUCTS_DIR; };
                15FD73970754DE49001CC321 /* Info.plist */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = text.xml; path = Info.plist; sourceTree = "<group>"; };
                15FD73EE0754DE62001CC321 /* Info.plist */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = text.xml; path = Info.plist; sourceTree = "<group>"; };
                15FD743E0754DE7A001CC321 /* Info.plist */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = text.xml; path = Info.plist; sourceTree = "<group>"; };
+               15FEE80D0CCFD341001312F9 /* ApplicationServices.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = ApplicationServices.framework; path = /System/Library/Frameworks/ApplicationServices.framework; sourceTree = "<absolute>"; };
+               15FEE8160CD03CA3001312F9 /* English */ = {isa = PBXFileReference; fileEncoding = 10; lastKnownFileType = text.plist.strings; name = English; path = SCMonitor/English.lproj/Localizable.strings; sourceTree = "<group>"; };
                23C1E2B4062DD2C700835B54 /* pppcontroller_types.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; name = pppcontroller_types.h; path = /usr/local/include/ppp/pppcontroller_types.h; sourceTree = "<absolute>"; };
                23C1E2B8062DD45900835B54 /* pppcontroller.defs */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.mig; name = pppcontroller.defs; path = SystemConfiguration.fproj/pppcontroller.defs; sourceTree = "<group>"; };
                23C1E2BE062DD5DB00835B54 /* pppcontroller.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; name = pppcontroller.h; path = configd.build/SystemConfiguration.framework.build/DerivedSources/pppcontroller.h; sourceTree = BUILT_PRODUCTS_DIR; };
 /* End PBXFileReference section */
 
 /* Begin PBXFrameworksBuildPhase section */
+               151F5D980CCE98E50093AC3B /* Frameworks */ = {
+                       isa = PBXFrameworksBuildPhase;
+                       buildActionMask = 2147483647;
+                       files = (
+                               15FC13180CCF74740013872C /* CoreFoundation.framework in Frameworks */,
+                               15E517680CCFBCD0008FFE82 /* SystemConfiguration.framework in Frameworks */,
+                               15FEE80E0CCFD341001312F9 /* ApplicationServices.framework in Frameworks */,
+                       );
+                       runOnlyForDeploymentPostprocessing = 0;
+               };
                1547001B08455B98006787CE /* Frameworks */ = {
                        isa = PBXFrameworksBuildPhase;
                        buildActionMask = 2147483647;
                        name = "Initial Preferences";
                        sourceTree = "<group>";
                };
+               151F5DA80CCE995D0093AC3B /* SCMonitor */ = {
+                       isa = PBXGroup;
+                       children = (
+                               15FC130A0CCEA59E0013872C /* monitor.c */,
+                               15FC12F20CCEA4F00013872C /* Info.plist */,
+                               15FEE8180CD03CBB001312F9 /* Localizable.strings */,
+                       );
+                       name = SCMonitor;
+                       sourceTree = "<group>";
+               };
                1547002E084561B4006787CE /* SCHelper */ = {
                        isa = PBXGroup;
                        children = (
                                1582B36B05FD1A4D009C2750 /* DNSConfiguration */,
                                15CB690705C0722A0099E85F /* SystemConfiguration */,
                                1547002E084561B4006787CE /* SCHelper */,
+                               151F5DA80CCE995D0093AC3B /* SCMonitor */,
                                15CB69C205C0722B0099E85F /* configd */,
                                15CB6A2205C0722B0099E85F /* scselect */,
                                15CB6A3705C0722B0099E85F /* scutil */,
                                15DAD6C807591A1A0084A6ED /* SystemConfiguration.framework */,
                                15DAD5EE075913CE0084A6ED /* libdnsinfo.a */,
                                1547001D08455B98006787CE /* SCHelper */,
+                               151F5D9A0CCE98E50093AC3B /* SCMonitor.plugin */,
                                158ADCA60754ECC800124717 /* configd, scutil, scselect */,
                                158ADBFD0754ECB100124717 /* Plugins */,
                                151F63EC09328A3C0096DCC9 /* genSCPreferences */,
                        isa = PBXGroup;
                        children = (
                                158AD9F80754EA2F00124717 /* AppleTalk.framework */,
+                               15FEE80D0CCFD341001312F9 /* ApplicationServices.framework */,
                                15CB6A6F05C0722B0099E85F /* CoreFoundation.framework */,
                                1543636A0752D03C00A8EC6C /* IOKit.framework */,
                                1520A3DE0846B2DC0010B584 /* Security.framework */,
 /* End PBXHeadersBuildPhase section */
 
 /* Begin PBXNativeTarget section */
+               151F5D990CCE98E50093AC3B /* SCMonitor */ = {
+                       isa = PBXNativeTarget;
+                       buildConfigurationList = 151F5D9F0CCE98E60093AC3B /* Build configuration list for PBXNativeTarget "SCMonitor" */;
+                       buildPhases = (
+                               151F5D960CCE98E50093AC3B /* Resources */,
+                               151F5D970CCE98E50093AC3B /* Sources */,
+                               151F5D980CCE98E50093AC3B /* Frameworks */,
+                       );
+                       buildRules = (
+                       );
+                       dependencies = (
+                       );
+                       name = SCMonitor;
+                       productName = SCMonitor;
+                       productReference = 151F5D9A0CCE98E50093AC3B /* SCMonitor.plugin */;
+                       productType = "com.apple.product-type.bundle";
+               };
                151F63DA09328A3C0096DCC9 /* Schema */ = {
                        isa = PBXNativeTarget;
                        buildConfigurationList = 151F63DC09328A3C0096DCC9 /* Build configuration list for PBXNativeTarget "Schema" */;
                                151F63DA09328A3C0096DCC9 /* Schema */,
                                15DAD63F07591A1A0084A6ED /* SystemConfiguration.framework */,
                                1547001808455B98006787CE /* SCHelper */,
+                               151F5D990CCE98E50093AC3B /* SCMonitor */,
                                159D549F07529FFF004F8947 /* configd */,
                                1558481207550EC10046C2E9 /* scselect */,
                                155847430754FDCD0046C2E9 /* scutil */,
 /* End PBXProject section */
 
 /* Begin PBXResourcesBuildPhase section */
+               151F5D960CCE98E50093AC3B /* Resources */ = {
+                       isa = PBXResourcesBuildPhase;
+                       buildActionMask = 2147483647;
+                       files = (
+                               15FEE81F0CD03E75001312F9 /* Localizable.strings in Resources */,
+                       );
+                       runOnlyForDeploymentPostprocessing = 0;
+               };
                15828AE30753B5F900AD4710 /* Resources */ = {
                        isa = PBXResourcesBuildPhase;
                        buildActionMask = 2147483647;
 /* End PBXShellScriptBuildPhase section */
 
 /* Begin PBXSourcesBuildPhase section */
+               151F5D970CCE98E50093AC3B /* Sources */ = {
+                       isa = PBXSourcesBuildPhase;
+                       buildActionMask = 2147483647;
+                       files = (
+                               15FC130B0CCEA59E0013872C /* monitor.c in Sources */,
+                       );
+                       runOnlyForDeploymentPostprocessing = 0;
+               };
                1547001A08455B98006787CE /* Sources */ = {
                        isa = PBXSourcesBuildPhase;
                        buildActionMask = 2147483647;
 /* End PBXSourcesBuildPhase section */
 
 /* Begin PBXTargetDependency section */
+               150ECB3C0D0079280065E94D /* PBXTargetDependency */ = {
+                       isa = PBXTargetDependency;
+                       target = 151F5D990CCE98E50093AC3B /* SCMonitor */;
+                       targetProxy = 150ECB3B0D0079280065E94D /* PBXContainerItemProxy */;
+               };
                1520A386084681350010B584 /* PBXTargetDependency */ = {
                        isa = PBXTargetDependency;
                        target = 1547001808455B98006787CE /* SCHelper */;
                        name = Localizable.strings;
                        sourceTree = "<group>";
                };
+               15FEE8180CD03CBB001312F9 /* Localizable.strings */ = {
+                       isa = PBXVariantGroup;
+                       children = (
+                               15FEE8160CD03CA3001312F9 /* English */,
+                       );
+                       name = Localizable.strings;
+                       sourceTree = "<group>";
+               };
 /* End PBXVariantGroup section */
 
 /* Begin XCBuildConfiguration section */
+               151F5D9C0CCE98E60093AC3B /* Development */ = {
+                       isa = XCBuildConfiguration;
+                       buildSettings = {
+                               COPY_PHASE_STRIP = NO;
+                               FRAMEWORK_SEARCH_PATHS = "$(SYMROOT)";
+                               GCC_DYNAMIC_NO_PIC = NO;
+                               GCC_ENABLE_FIX_AND_CONTINUE = YES;
+                               GCC_MODEL_TUNING = G5;
+                               GCC_OPTIMIZATION_LEVEL = 0;
+                               INFOPLIST_FILE = "$(SRCROOT)/SCMonitor/Info.plist";
+                               INSTALL_MODE_FLAG = "a-w,a+rX";
+                               INSTALL_PATH = /System/Library/UserEventPlugins;
+                               PRODUCT_NAME = SCMonitor;
+                               WRAPPER_EXTENSION = plugin;
+                               ZERO_LINK = YES;
+                       };
+                       name = Development;
+               };
+               151F5D9D0CCE98E60093AC3B /* Deployment */ = {
+                       isa = XCBuildConfiguration;
+                       buildSettings = {
+                               COPY_PHASE_STRIP = YES;
+                               DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym";
+                               FRAMEWORK_SEARCH_PATHS = "$(SYMROOT)";
+                               GCC_ENABLE_FIX_AND_CONTINUE = NO;
+                               GCC_MODEL_TUNING = G5;
+                               INFOPLIST_FILE = "$(SRCROOT)/SCMonitor/Info.plist";
+                               INSTALL_MODE_FLAG = "a-w,a+rX";
+                               INSTALL_PATH = /System/Library/UserEventPlugins;
+                               PRODUCT_NAME = SCMonitor;
+                               WRAPPER_EXTENSION = plugin;
+                               ZERO_LINK = NO;
+                       };
+                       name = Deployment;
+               };
+               151F5D9E0CCE98E60093AC3B /* Default */ = {
+                       isa = XCBuildConfiguration;
+                       buildSettings = {
+                               FRAMEWORK_SEARCH_PATHS = "$(SYMROOT)";
+                               GCC_ENABLE_FIX_AND_CONTINUE = YES;
+                               GCC_MODEL_TUNING = G5;
+                               INFOPLIST_FILE = "$(SRCROOT)/SCMonitor/Info.plist";
+                               INSTALL_MODE_FLAG = "a-w,a+rX";
+                               INSTALL_PATH = /System/Library/UserEventPlugins;
+                               PRODUCT_NAME = SCMonitor;
+                               VALID_ARCHS = "i386 ppc";
+                               WRAPPER_EXTENSION = plugin;
+                               ZERO_LINK = YES;
+                       };
+                       name = Default;
+               };
                151F63DD09328A3C0096DCC9 /* Development */ = {
                        isa = XCBuildConfiguration;
                        buildSettings = {
                        buildSettings = {
                                COPY_PHASE_STRIP = NO;
                                DYLIB_COMPATIBILITY_VERSION = 1;
-                               DYLIB_CURRENT_VERSION = 204;
+                               DYLIB_CURRENT_VERSION = 210;
                                GCC_WARN_FOUR_CHARACTER_CONSTANTS = YES;
                                INSTALLHDRS_COPY_PHASE = YES;
                                INSTALL_MODE_FLAG = "a-w,a+rX";
                        buildSettings = {
                                COPY_PHASE_STRIP = YES;
                                DYLIB_COMPATIBILITY_VERSION = 1;
-                               DYLIB_CURRENT_VERSION = 204;
+                               DYLIB_CURRENT_VERSION = 210;
                                GCC_WARN_FOUR_CHARACTER_CONSTANTS = YES;
                                INSTALLHDRS_COPY_PHASE = YES;
                                INSTALL_MODE_FLAG = "a-w,a+rX";
                        isa = XCBuildConfiguration;
                        buildSettings = {
                                DYLIB_COMPATIBILITY_VERSION = 1;
-                               DYLIB_CURRENT_VERSION = 204;
+                               DYLIB_CURRENT_VERSION = 210;
                                INSTALLHDRS_COPY_PHASE = YES;
                                INSTALL_MODE_FLAG = "a-w,a+rX";
                                INSTALL_PATH = /usr/local/lib;
                        buildSettings = {
                                COPY_PHASE_STRIP = NO;
                                DYLIB_COMPATIBILITY_VERSION = 1;
-                               DYLIB_CURRENT_VERSION = 204;
+                               DYLIB_CURRENT_VERSION = 210;
                                FRAMEWORK_SEARCH_PATHS = "$(SYSTEM_LIBRARY_DIR)/PrivateFrameworks";
                                HEADER_SEARCH_PATHS = "$(SYSTEM_LIBRARY_DIR)/Frameworks/System.framework/PrivateHeaders";
                                INFOPLIST_FILE = SystemConfiguration.fproj/Info.plist;
                        buildSettings = {
                                COPY_PHASE_STRIP = YES;
                                DYLIB_COMPATIBILITY_VERSION = 1;
-                               DYLIB_CURRENT_VERSION = 204;
+                               DYLIB_CURRENT_VERSION = 210;
                                FRAMEWORK_SEARCH_PATHS = "$(SYSTEM_LIBRARY_DIR)/PrivateFrameworks";
                                HEADER_SEARCH_PATHS = "$(SYSTEM_LIBRARY_DIR)/Frameworks/System.framework/PrivateHeaders";
                                INFOPLIST_FILE = SystemConfiguration.fproj/Info.plist;
                        isa = XCBuildConfiguration;
                        buildSettings = {
                                DYLIB_COMPATIBILITY_VERSION = 1;
-                               DYLIB_CURRENT_VERSION = 204;
+                               DYLIB_CURRENT_VERSION = 210;
                                FRAMEWORK_SEARCH_PATHS = "$(SYSTEM_LIBRARY_DIR)/PrivateFrameworks";
                                HEADER_SEARCH_PATHS = "$(SYSTEM_LIBRARY_DIR)/Frameworks/System.framework/PrivateHeaders";
                                INFOPLIST_FILE = SystemConfiguration.fproj/Info.plist;
                156EB63F0905594A00EEF749 /* Development */ = {
                        isa = XCBuildConfiguration;
                        buildSettings = {
-                               CURRENT_PROJECT_VERSION = 204;
+                               CURRENT_PROJECT_VERSION = 210;
                                DEAD_CODE_STRIPPING = YES;
                                INSTALL_GROUP = wheel;
                                INSTALL_MODE_FLAG = "u+s,ugo-w,o+rX";
                156EB6400905594A00EEF749 /* Deployment */ = {
                        isa = XCBuildConfiguration;
                        buildSettings = {
-                               CURRENT_PROJECT_VERSION = 204;
+                               CURRENT_PROJECT_VERSION = 210;
                                DEAD_CODE_STRIPPING = YES;
                                INSTALL_GROUP = wheel;
                                INSTALL_MODE_FLAG = "u+s,ugo-w,o+rX";
                156EB6410905594A00EEF749 /* Default */ = {
                        isa = XCBuildConfiguration;
                        buildSettings = {
-                               CURRENT_PROJECT_VERSION = 204;
+                               CURRENT_PROJECT_VERSION = 210;
                                DEAD_CODE_STRIPPING = YES;
                                INSTALL_GROUP = wheel;
                                INSTALL_MODE_FLAG = "u+s,ugo-w,o+rX";
 /* End XCBuildConfiguration section */
 
 /* Begin XCConfigurationList section */
+               151F5D9F0CCE98E60093AC3B /* Build configuration list for PBXNativeTarget "SCMonitor" */ = {
+                       isa = XCConfigurationList;
+                       buildConfigurations = (
+                               151F5D9C0CCE98E60093AC3B /* Development */,
+                               151F5D9D0CCE98E60093AC3B /* Deployment */,
+                               151F5D9E0CCE98E60093AC3B /* Default */,
+                       );
+                       defaultConfigurationIsVisible = 0;
+                       defaultConfigurationName = Default;
+               };
                151F63DC09328A3C0096DCC9 /* Build configuration list for PBXNativeTarget "Schema" */ = {
                        isa = XCConfigurationList;
                        buildConfigurations = (
index 0b20ebfcb11f28077d35b1dc6e629203aee287e4..e50043a0cdf21e4efe630f2b75583132a367d344 100644 (file)
@@ -299,6 +299,9 @@ const cmdInfo commands_prefs[] = {
        { "close",      0,      1,      do_prefs_close,         2,      1,
                " close [!]                     : close current \"preference\" session"         },
 
+       { "synchronize",0,      1,      do_prefs_synchronize,   2,      0,
+               " synchronize            : synchronize a \"preferences\" session"               },
+       
        { "list",       0,      1,      do_prefs_list,          4,      0,
                " list [path]                   : list preference paths"                        },
 
index 361cbc37a3a2f2fc9f46eb2a0b1ca07177978f35..855de89c39d45b780c74c7b4babd4d4f27d3d5e1 100644 (file)
@@ -663,6 +663,15 @@ do_prefs_quit(int argc, char **argv)
 }
 
 
+__private_extern__
+void
+do_prefs_synchronize(int argc, char **argv)
+{
+       SCPreferencesSynchronize(prefs);
+       return;
+}
+
+
 static CFComparisonResult
 sort_paths(const void *p1, const void *p2, void *context) {
        CFStringRef path1 = (CFStringRef)p1;
index 27ae2cfb0ed8d053af525e0528aee83b01c39a2b..feb55bea585828beb3c5fc012012755c119e3d82 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2003, 2005, 2006 Apple Computer, Inc. All rights reserved.
+ * Copyright (c) 2003, 2005-2007 Apple Inc. All rights reserved.
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
@@ -58,6 +58,7 @@ void  do_prefs_unlock         (int argc, char **argv);
 void   do_prefs_commit         (int argc, char **argv);
 void   do_prefs_apply          (int argc, char **argv);
 void   do_prefs_close          (int argc, char **argv);
+void   do_prefs_synchronize    (int argc, char **argv);
 
 void   do_prefs_list           (int argc, char **argv);
 void   do_prefs_get            (int argc, char **argv);