]> git.saurik.com Git - apple/configd.git/blobdiff - configd.tproj/_snapshot.c
configd-1109.101.1.tar.gz
[apple/configd.git] / configd.tproj / _snapshot.c
index b606be1ea7b846cde567efce38ce27eed3c871c8..854d36cb3f7fc05dfd3091946205184295ad5848 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2000-2006, 2009-2011, 2015 Apple Inc. All rights reserved.
+ * Copyright (c) 2000-2006, 2009-2011, 2015, 2018, 2019 Apple Inc. All rights reserved.
  *
  * @APPLE_LICENSE_HEADER_START@
  *
@@ -44,7 +44,6 @@
 #define        SNAPSHOT_PATH_STATE     _PATH_VARTMP "configd-state"
 #define        SNAPSHOT_PATH_STORE     _PATH_VARTMP "configd-store.plist"
 #define        SNAPSHOT_PATH_PATTERN   _PATH_VARTMP "configd-pattern.plist"
-#define        SNAPSHOT_PATH_SESSION   _PATH_VARTMP "configd-session.plist"
 
 
 #define N_QUICK        100
@@ -70,7 +69,7 @@ _expandStore(CFDictionaryRef storeData)
                        oValues = CFAllocatorAllocate(NULL, nElements * sizeof(CFTypeRef), 0);
                        nValues = CFAllocatorAllocate(NULL, nElements * sizeof(CFTypeRef), 0);
                }
-               bzero(nValues, nElements * sizeof(CFTypeRef));
+               memset(nValues, 0, nElements * sizeof(CFTypeRef));
 
                CFDictionaryGetKeysAndValues(storeData, keys, oValues);
                for (i = 0; i < nElements; i++) {
@@ -82,7 +81,11 @@ _expandStore(CFDictionaryRef storeData)
 
                                nValues[i] = CFDictionaryCreateMutableCopy(NULL, 0, oValues[i]);
 
-                               _SCUnserialize(&plist, data, NULL, 0);
+                               if (!_SCUnserialize(&plist, data, NULL, 0)) {
+                                       SC_log(LOG_NOTICE, "_SCUnserialize() failed, key=%@", keys[i]);
+                                       continue;
+                               }
+
                                CFDictionarySetValue((CFMutableDictionaryRef)nValues[i],
                                                     kSCDData,
                                                     plist);
@@ -122,6 +125,7 @@ __private_extern__
 int
 __SCDynamicStoreSnapshot(SCDynamicStoreRef store)
 {
+#pragma unused(store)
        CFDictionaryRef                 expandedStoreData;
        FILE                            *f;
        int                             fd;
@@ -138,12 +142,8 @@ __SCDynamicStoreSnapshot(SCDynamicStoreRef store)
        if (f == NULL) {
                return kSCStatusFailed;
        }
-       SCPrint(TRUE, f, CFSTR("Main thread :\n\n"));
+       SCPrint(TRUE, f, CFSTR("Main [plug-in] thread :\n\n"));
        SCPrint(TRUE, f, CFSTR("%@\n"), CFRunLoopGetCurrent());
-       if (plugin_runLoop != NULL) {
-               SCPrint(TRUE, f, CFSTR("Plug-in thread :\n\n"));
-               SCPrint(TRUE, f, CFSTR("%@\n"), plugin_runLoop);
-       }
        listSessions(f);
        (void) fclose(f);
 
@@ -185,24 +185,6 @@ __SCDynamicStoreSnapshot(SCDynamicStoreRef store)
        (void) close(fd);
        CFRelease(xmlData);
 
-       /* Save a snapshot of the "session" data */
-
-       (void) unlink(SNAPSHOT_PATH_SESSION);
-       fd = open(SNAPSHOT_PATH_SESSION, O_WRONLY|O_CREAT|O_TRUNC|O_EXCL, 0644);
-       if (fd == -1) {
-               return kSCStatusFailed;
-       }
-
-       xmlData = CFPropertyListCreateData(NULL, sessionData, kCFPropertyListXMLFormat_v1_0, 0, NULL);
-       if (xmlData == NULL) {
-               SC_log(LOG_NOTICE, "CFPropertyListCreateData() failed");
-               close(fd);
-               return kSCStatusFailed;
-       }
-       (void) write(fd, CFDataGetBytePtr(xmlData), CFDataGetLength(xmlData));
-       (void) close(fd);
-       CFRelease(xmlData);
-
        return kSCStatusOK;
 }