2 * Copyright (c) 2003-2007,2009-2010,2013-2014 Apple Inc. All Rights Reserved.
4 * @APPLE_LICENSE_HEADER_START@
6 * This file contains Original Code and/or Modifications of Original Code
7 * as defined in and that are subject to the Apple Public Source License
8 * Version 2.0 (the 'License'). You may not use this file except in
9 * compliance with the License. Please obtain a copy of the License at
10 * http://www.opensource.apple.com/apsl/ and read it before using this
13 * The Original Code and all software distributed under the License are
14 * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
15 * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
16 * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
17 * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
18 * Please see the License for the specific language governing rights and
19 * limitations under the License.
21 * @APPLE_LICENSE_HEADER_END@
31 #include <sys/utsname.h>
35 #include <readpassphrase.h>
37 #include <Security/SecItem.h>
39 #include <CoreFoundation/CFNumber.h>
40 #include <CoreFoundation/CFString.h>
42 #include <Security/SecureObjectSync/SOSCloudCircle.h>
43 #include <Security/SecureObjectSync/SOSCloudCircleInternal.h>
44 #include <Security/SecureObjectSync/SOSPeerInfo.h>
45 #include "keychain/SecureObjectSync/SOSPeerInfoPriv.h"
46 #include "keychain/SecureObjectSync/SOSPeerInfoV2.h"
47 #include "keychain/SecureObjectSync/SOSUserKeygen.h"
48 #include "keychain/SecureObjectSync/SOSKVSKeys.h"
49 #include "keychain/securityd/SOSCloudCircleServer.h"
50 #include <Security/SecureObjectSync/SOSBackupSliceKeyBag.h>
51 #include <Security/SecOTRSession.h>
52 #include "keychain/SecureObjectSync/CKBridge/SOSCloudKeychainClient.h"
54 #include <utilities/SecCFWrappers.h>
55 #include <utilities/debugging.h>
57 #include "SecurityTool/sharedTool/readline.h"
60 #include "keychain_sync.h"
61 #include "keychain_log.h"
62 #include "syncbackup.h"
64 #include "secToolFileIO.h"
65 #include "secViewDisplay.h"
66 #include "accountCirclesViewsPrint.h"
68 #include <Security/SecPasswordGenerate.h>
70 #define MAXKVSKEYTYPE kUnknownKey
71 #define DATE_LENGTH 18
74 static bool clearAllKVS(CFErrorRef *error)
76 __block bool result = false;
77 const uint64_t maxTimeToWaitInSeconds = 30ull * NSEC_PER_SEC;
78 dispatch_queue_t processQueue = dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0);
79 dispatch_semaphore_t waitSemaphore = dispatch_semaphore_create(0);
80 dispatch_time_t finishTime = dispatch_time(DISPATCH_TIME_NOW, maxTimeToWaitInSeconds);
82 secnotice("circleOps", "security tool called SOSCloudKeychainClearAll to clear KVS");
83 SOSCloudKeychainClearAll(processQueue, ^(CFDictionaryRef returnedValues, CFErrorRef cerror)
85 result = (cerror != NULL);
86 dispatch_semaphore_signal(waitSemaphore);
89 dispatch_semaphore_wait(waitSemaphore, finishTime);
94 static bool enableDefaultViews()
97 CFMutableSetRef viewsToEnable = SOSViewCopyViewSet(kViewSetV0);
98 CFMutableSetRef viewsToDisable = CFSetCreateMutable(NULL, 0, NULL);
100 result = SOSCCViewSet(viewsToEnable, viewsToDisable);
101 CFRelease(viewsToEnable);
102 CFRelease(viewsToDisable);
106 static bool requestToJoinCircle(CFErrorRef *error)
108 // Set the visual state of switch based on membership in circle
109 bool hadError = false;
110 SOSCCStatus ccstatus = SOSCCThisDeviceIsInCircle(error);
114 case kSOSCCCircleAbsent:
115 hadError = !SOSCCResetToOffering(error);
116 hadError &= enableDefaultViews();
118 case kSOSCCNotInCircle:
119 hadError = !SOSCCRequestToJoinCircle(error);
120 hadError &= enableDefaultViews();
123 printerr(CFSTR("Request to join circle with bad status: %@ (%d)\n"), SOSCCGetStatusDescription(ccstatus), ccstatus);
129 static bool setPassword(char *labelAndPassword, CFErrorRef *err)
132 char *token0 = strtok_r(labelAndPassword, ":", &last);
133 char *token1 = strtok_r(NULL, "", &last);
134 CFStringRef label = token1 ? CFStringCreateWithCString(NULL, token0, kCFStringEncodingUTF8) : CFSTR("security command line tool");
135 char *password_token = token1 ? token1 : token0;
136 password_token = password_token ? password_token : "";
137 CFDataRef password = CFDataCreate(NULL, (const UInt8*) password_token, strlen(password_token));
138 bool returned = !SOSCCSetUserCredentials(label, password, err);
144 static bool tryPassword(char *labelAndPassword, CFErrorRef *err)
147 char *token0 = strtok_r(labelAndPassword, ":", &last);
148 char *token1 = strtok_r(NULL, "", &last);
149 CFStringRef label = token1 ? CFStringCreateWithCString(NULL, token0, kCFStringEncodingUTF8) : CFSTR("security command line tool");
150 char *password_token = token1 ? token1 : token0;
151 password_token = password_token ? password_token : "";
152 CFDataRef password = CFDataCreate(NULL, (const UInt8*) password_token, strlen(password_token));
153 bool returned = !SOSCCTryUserCredentials(label, password, err);
160 * Prompt user, call SOSCCTryUserCredentials.
161 * Does not support optional label syntax like -T/-P.
162 * Returns true on success.
165 promptAndTryPassword(CFErrorRef *error)
167 bool success = false;
171 if (readpassphrase("iCloud password: ", passbuf, sizeof(passbuf), RPP_REQUIRE_TTY) != NULL) {
172 password = CFDataCreate(NULL, (const UInt8 *)passbuf, strlen(passbuf));
173 if (password != NULL) {
174 success = SOSCCTryUserCredentials(CFSTR("security command line tool"), password, error);
175 CFReleaseNull(password);
182 static bool syncAndWait(CFErrorRef *err)
184 __block CFTypeRef objects = NULL;
186 dispatch_queue_t generalq = dispatch_queue_create("general", DISPATCH_QUEUE_SERIAL);
188 const uint64_t maxTimeToWaitInSeconds = 30ull * NSEC_PER_SEC;
189 dispatch_semaphore_t waitSemaphore = dispatch_semaphore_create(0);
190 dispatch_time_t finishTime = dispatch_time(DISPATCH_TIME_NOW, maxTimeToWaitInSeconds);
192 CloudKeychainReplyBlock replyBlock = ^ (CFDictionaryRef returnedValues, CFErrorRef error)
194 secinfo("sync", "SOSCloudKeychainSynchronizeAndWait returned: %@", returnedValues);
196 secerror("SOSCloudKeychainSynchronizeAndWait returned error: %@", error);
197 objects = CFRetainSafe(returnedValues);
199 secinfo("sync", "SOSCloudKeychainGetObjectsFromCloud block exit: %@", objects);
200 dispatch_semaphore_signal(waitSemaphore);
203 SOSCloudKeychainSynchronizeAndWait(generalq, replyBlock);
205 dispatch_semaphore_wait(waitSemaphore, finishTime);
207 (void)SOSCCDumpCircleKVSInformation(NULL);
208 fprintf(outFile, "\n");
212 static void dumpStringSet(CFStringRef label, CFSetRef s) {
213 if(!s || !label) return;
215 printmsg(CFSTR("%@: { "), label);
216 __block bool first = true;
217 CFSetForEach(s, ^(const void *p) {
218 CFStringRef fmt = CFSTR(", %@");
222 CFStringRef string = (CFStringRef) p;
223 printmsg(fmt, string);
226 printmsg(CFSTR(" }\n"), NULL);
229 static bool dumpMyPeer(CFErrorRef *error) {
230 SOSPeerInfoRef myPeer = SOSCCCopyMyPeerInfo(error);
232 if (!myPeer) return false;
234 CFStringRef peerID = SOSPeerInfoGetPeerID(myPeer);
235 CFStringRef peerName = SOSPeerInfoGetPeerName(myPeer);
236 CFIndex peerVersion = SOSPeerInfoGetVersion(myPeer);
237 bool retirement = SOSPeerInfoIsRetirementTicket(myPeer);
239 printmsg(CFSTR("Peer Name: %@ PeerID: %@ Version: %d\n"), peerName, peerID, peerVersion);
241 CFDateRef retdate = SOSPeerInfoGetRetirementDate(myPeer);
242 printmsg(CFSTR("Retired: %@\n"), retdate);
246 if(peerVersion >= 2) {
247 CFMutableSetRef views = SOSPeerInfoV2DictionaryCopySet(myPeer, sViewsKey);
248 CFStringRef serialNumber = SOSPeerInfoV2DictionaryCopyString(myPeer, sSerialNumberKey);
249 CFBooleanRef preferIDS = SOSPeerInfoV2DictionaryCopyBoolean(myPeer, sPreferIDS);
250 CFBooleanRef preferIDSFragmentation = SOSPeerInfoV2DictionaryCopyBoolean(myPeer, sPreferIDSFragmentation);
251 CFBooleanRef preferIDSACKModel = SOSPeerInfoV2DictionaryCopyBoolean(myPeer, sPreferIDSACKModel);
252 CFStringRef transportType = SOSPeerInfoV2DictionaryCopyString(myPeer, sTransportType);
253 CFStringRef idsDeviceID = SOSPeerInfoV2DictionaryCopyString(myPeer, sDeviceID);
255 printmsg(CFSTR("Serial#: %@ PrefIDS#: %@ PrefFragmentation#: %@ PrefACK#: %@ transportType#: %@ idsDeviceID#: %@\n"),
256 serialNumber, preferIDS, preferIDSFragmentation, preferIDSACKModel, transportType, idsDeviceID);
258 printmsg(CFSTR("Serial#: %@\n"),
260 dumpStringSet(CFSTR(" Views: "), views);
263 CFReleaseSafe(serialNumber);
264 CFReleaseSafe(preferIDS);
265 CFReleaseSafe(preferIDSFragmentation);
266 CFReleaseSafe(views);
267 CFReleaseSafe(transportType);
268 CFReleaseSafe(idsDeviceID);
271 bool ret = myPeer != NULL;
272 CFReleaseNull(myPeer);
276 static bool setBag(char *itemName, CFErrorRef *err)
278 __block bool success = false;
279 __block CFErrorRef error = NULL;
281 CFStringRef random = SecPasswordCreateWithRandomDigits(10, NULL);
283 CFStringPerformWithUTF8CFData(random, ^(CFDataRef stringAsData) {
284 if (0 == strncasecmp(optarg, "single", 6) || 0 == strncasecmp(optarg, "all", 3)) {
285 bool includeV0 = (0 == strncasecmp(optarg, "all", 3));
286 printmsg(CFSTR("Setting iCSC single using entropy from string: %@\n"), random);
287 CFDataRef aks_bag = SecAKSCopyBackupBagWithSecret(CFDataGetLength(stringAsData), (uint8_t*)CFDataGetBytePtr(stringAsData), &error);
290 success = SOSCCRegisterSingleRecoverySecret(aks_bag, includeV0, &error);
292 printmsg(CFSTR("Failed registering single secret %@"), error);
293 CFReleaseNull(aks_bag);
296 printmsg(CFSTR("Failed to create aks_bag: %@"), error);
298 CFReleaseNull(aks_bag);
299 } else if (0 == strncasecmp(optarg, "device", 6)) {
300 printmsg(CFSTR("Setting Device Secret using entropy from string: %@\n"), random);
302 SOSPeerInfoRef me = SOSCCCopyMyPeerWithNewDeviceRecoverySecret(stringAsData, &error);
304 success = me != NULL;
307 printmsg(CFSTR("Failed: %@\n"), err);
310 printmsg(CFSTR("Unrecognized argument to -b %s\n"), optarg);
318 static void prClientViewState(char *label, bool result) {
319 fprintf(outFile, "Sync Status for %s: %s\n", label, (result) ? "enabled": "not enabled");
322 static bool clientViewStatus(CFErrorRef *error) {
323 prClientViewState("KeychainV0", SOSCCIsIcloudKeychainSyncing());
324 prClientViewState("Safari", SOSCCIsSafariSyncing());
325 prClientViewState("AppleTV", SOSCCIsAppleTVSyncing());
326 prClientViewState("HomeKit", SOSCCIsHomeKitSyncing());
327 prClientViewState("Wifi", SOSCCIsWiFiSyncing());
328 prClientViewState("AlwaysOnNoInitialSync", SOSCCIsContinuityUnlockSyncing());
333 static bool dumpYetToSync(CFErrorRef *error) {
334 CFArrayRef yetToSyncViews = SOSCCCopyYetToSyncViewsList(error);
336 bool hadError = yetToSyncViews;
338 if (yetToSyncViews) {
339 __block CFStringRef separator = CFSTR("");
341 printmsg(CFSTR("Yet to sync views: ["), NULL);
343 CFArrayForEach(yetToSyncViews, ^(const void *value) {
344 if (isString(value)) {
345 printmsg(CFSTR("%@%@"), separator, value);
347 separator = CFSTR(", ");
350 printmsg(CFSTR("]\n"), NULL);
357 #pragma mark --remove-peer
360 add_matching_peerinfos(CFMutableArrayRef list, CFArrayRef spids, CFArrayRef (*copy_peer_func)(CFErrorRef *))
368 peers = copy_peer_func(&error);
370 for (i = 0; i < CFArrayGetCount(peers); i++) {
371 pi = (SOSPeerInfoRef)CFArrayGetValueAtIndex(peers, i);
372 for (j = 0; j < CFArrayGetCount(spids); j++) {
373 spid = (CFStringRef)CFArrayGetValueAtIndex(spids, j);
374 if (CFStringGetLength(spid) < 8) {
377 if (CFStringHasPrefix(SOSPeerInfoGetPeerID(pi), spid)) {
378 CFArrayAppendValue(list, pi);
391 copy_peerinfos(CFArrayRef spids)
393 CFMutableArrayRef matches;
395 matches = CFArrayCreateMutable(NULL, 0, &kCFTypeArrayCallBacks);
396 add_matching_peerinfos(matches, spids, SOSCCCopyValidPeerPeerInfo);
397 add_matching_peerinfos(matches, spids, SOSCCCopyNotValidPeerPeerInfo);
398 add_matching_peerinfos(matches, spids, SOSCCCopyRetirementPeerInfo);
404 doRemovePeers(CFArrayRef peerids, CFErrorRef *error)
406 bool success = false;
407 CFArrayRef peers = NULL;
408 CFErrorRef localError = NULL;
412 peers = copy_peerinfos(peerids);
413 if (peers == NULL || CFArrayGetCount(peers) == 0) {
414 fprintf(stdout, "No matching peers to remove.\n");
419 fprintf(stdout, "Matched the following devices:\n");
420 for (i = 0; i < CFArrayGetCount(peers); i++) {
422 CFShow(CFArrayGetValueAtIndex(peers, i));
425 if (readpassphrase("Confirm removal (y/N): ", buf, sizeof(buf), RPP_ECHO_ON | RPP_FORCEUPPER) == NULL) {
434 success = SOSCCRemovePeersFromCircle(peers, &localError);
435 if (!success && isSOSErrorCoded(localError, kSOSErrorPrivateKeyAbsent)) {
436 CFReleaseNull(localError);
438 success = promptAndTryPassword(&localError);
440 success = SOSCCRemovePeersFromCircle(peers, &localError);
445 CFReleaseNull(peers);
447 if (!success && error != NULL) {
450 CFReleaseNull(localError);
458 // enable, disable, accept, reject, status, Reset, Clear
460 keychain_sync(int argc, char * const *argv)
465 " -e enable (join/create circle)"
466 " -i info (current status)"
469 "Account/Circle Management"
470 " -a accept all applicants"
471 " -l [reason] sign out of circle + set custom departure reason"
472 " -q sign out of circle"
473 " -r reject all applicants"
474 " -E ensure fresh parameters"
475 " -b device|all|single Register a backup bag - THIS RESETS BACKUPS!\n"
476 " -A Apply to a ring\n"
477 " -B Withdrawl from a ring\n"
480 " -I Dump Ring Information\n"
482 " -N (re-)set to new account (USE WITH CARE: device will not leave circle before resetting account!)"
483 " -O reset to offering"
485 " -X [limit] best effort bail from circle in limit seconds"
486 " -o list view unaware peers in circle"
487 " -0 boot view unaware peers from circle"
488 " -1 grab account state from the keychain"
489 " -2 delete account state from the keychain"
490 " -3 grab engine state from the keychain"
491 " -4 delete engine state from the keychain"
492 " -5 cleanup old KVS keys in KVS"
493 " -6 [test]populate KVS with garbage KVS keys
496 " -P [label:]password set password (optionally for a given label) for sync"
497 " -T [label:]password try password (optionally for a given label) for sync"
500 " -k pend all registered kvs keys"
501 " -C clear all values from KVS"
502 " -D [itemName] dump contents of KVS"
506 " -v [enable|disable|query:viewname] enable, disable, or query my PeerInfo's view set"
507 " viewnames are: keychain|masterkey|iclouddrive|photos|cloudkit|escrow|fde|maildrop|icloudbackup|notes|imessage|appletv|homekit|"
508 " wifi|passwords|creditcards|icloudidentity|othersyncable"
509 " -L list all known view and their status"
510 " -U purge private key material cache\n"
511 " -V Report View Sync Status on all known clients.\n"
512 " -H Set escrow record.\n"
513 " -J Get the escrow record.\n"
514 " -M Check peer availability.\n"
520 const struct option longopts[] = {
521 { "remove-peer", required_argument, &action, SYNC_REMOVE_PEER, },
522 { NULL, 0, NULL, 0, },
525 CFErrorRef error = NULL;
526 bool hadError = false;
527 CFMutableArrayRef peers2remove = NULL;
528 SOSLogSetOutputTo(NULL, NULL);
530 while ((ch = getopt_long(argc, argv, "ab:deg:hikl:mopq:rSv:w:x:zA:B:MNJCDEF:HG:ILOP:RT:UWX:VY0123456", longopts, NULL)) != -1)
534 fprintf(outFile, "Signing out of circle\n");
535 hadError = !SOSCCSignedOut(true, &error);
538 int reason = (int) strtoul(optarg, NULL, 10);
540 reason < kSOSDepartureReasonError ||
541 reason >= kSOSNumDepartureReasons) {
542 fprintf(errFile, "Invalid custom departure reason %s\n", optarg);
544 fprintf(outFile, "Setting custom departure reason %d\n", reason);
545 hadError = !SOSCCSetLastDepartureReason(reason, &error);
546 notify_post(kSOSCCCircleChangedNotification);
554 fprintf(outFile, "Signing out of circle\n");
555 bool signOutImmediately = false;
556 if (strcasecmp(optarg, "true") == 0) {
557 signOutImmediately = true;
558 } else if (strcasecmp(optarg, "false") == 0) {
559 signOutImmediately = false;
561 fprintf(outFile, "Please provide a \"true\" or \"false\" whether you'd like to leave the circle immediately\n");
563 hadError = !SOSCCSignedOut(signOutImmediately, &error);
564 notify_post(kSOSCCCircleChangedNotification);
568 fprintf(outFile, "Turning ON keychain syncing\n");
569 hadError = requestToJoinCircle(&error);
573 fprintf(outFile, "Turning OFF keychain syncing\n");
574 hadError = !SOSCCRemoveThisDeviceFromCircle(&error);
579 CFArrayRef applicants = SOSCCCopyApplicantPeerInfo(NULL);
581 hadError = !SOSCCAcceptApplicants(applicants, &error);
582 CFRelease(applicants);
584 fprintf(errFile, "No applicants to accept\n");
591 CFArrayRef applicants = SOSCCCopyApplicantPeerInfo(NULL);
593 hadError = !SOSCCRejectApplicants(applicants, &error);
594 CFRelease(applicants);
596 fprintf(errFile, "No applicants to reject\n");
602 SOSCCDumpCircleInformation();
603 SOSCCDumpEngineInformation();
607 notify_post("com.apple.security.cloudkeychain.forceupdate");
612 SOSCCDumpViewUnwarePeers();
618 CFArrayRef unawares = SOSCCCopyViewUnawarePeerInfo(&error);
620 hadError = !SOSCCRemovePeersFromCircle(unawares, &error);
624 CFReleaseNull(unawares);
629 CFDataRef accountState = SOSCCCopyAccountState(&error);
631 printmsg(CFSTR(" %@\n"), CFDataCopyHexString(accountState));
635 CFReleaseNull(accountState);
640 bool status = SOSCCDeleteAccountState(&error);
642 printmsg(CFSTR("Deleted account from the keychain %d\n"), status);
650 CFDataRef engineState = SOSCCCopyEngineData(&error);
652 printmsg(CFSTR(" %@\n"), CFDataCopyHexString(engineState));
656 CFReleaseNull(engineState);
661 bool status = SOSCCDeleteEngineState(&error);
663 printmsg(CFSTR("Deleted engine-state from the keychain %d\n"), status);
671 bool result = SOSCCCleanupKVSKeys(&error);
674 printmsg(CFSTR("Got all the keys from KVS %d\n"), result);
682 bool result = SOSCCTestPopulateKVSWithBadKeys(&error);
685 printmsg(CFSTR("Populated KVS with garbage %d\n"), result);
693 fprintf(outFile, "Ensuring Fresh Parameters\n");
694 bool result = SOSCCRequestEnsureFreshParameters(&error);
700 fprintf(outFile, "Refreshed Parameters Ensured!\n");
702 fprintf(outFile, "Problem trying to ensure fresh parameters\n");
708 fprintf(outFile, "Applying to Ring\n");
709 CFStringRef ringName = CFStringCreateWithCString(kCFAllocatorDefault, (char *)optarg, kCFStringEncodingUTF8);
710 hadError = SOSCCApplyToARing(ringName, &error);
711 CFReleaseNull(ringName);
716 fprintf(outFile, "Withdrawing from Ring\n");
717 CFStringRef ringName = CFStringCreateWithCString(kCFAllocatorDefault, (char *)optarg, kCFStringEncodingUTF8);
718 hadError = SOSCCWithdrawlFromARing(ringName, &error);
719 CFReleaseNull(ringName);
724 fprintf(outFile, "Status of this device in the Ring\n");
725 CFStringRef ringName = CFStringCreateWithCString(kCFAllocatorDefault, (char *)optarg, kCFStringEncodingUTF8);
726 hadError = SOSCCRingStatus(ringName, &error);
727 CFReleaseNull(ringName);
732 fprintf(outFile, "Enabling Ring\n");
733 CFStringRef ringName = CFStringCreateWithCString(kCFAllocatorDefault, (char *)optarg, kCFStringEncodingUTF8);
734 hadError = SOSCCEnableRing(ringName, &error);
735 CFReleaseNull(ringName);
740 fprintf(outFile, "Setting random escrow record\n");
741 bool success = SOSCCSetEscrowRecord(CFSTR("label"), 8, &error);
750 CFDictionaryRef attempts = SOSCCCopyEscrowRecord(&error);
752 CFDictionaryForEach(attempts, ^(const void *key, const void *value) {
754 char *keyString = CFStringToCString(key);
755 fprintf(outFile, "%s:\n", keyString);
758 if(isDictionary(value)){
759 CFDictionaryForEach(value, ^(const void *key, const void *value) {
761 char *keyString = CFStringToCString(key);
762 fprintf(outFile, "%s: ", keyString);
766 char *time = CFStringToCString(value);
767 fprintf(outFile, "timestamp: %s\n", time);
770 else if(isNumber(value)){
772 CFNumberGetValue(value, kCFNumberLongLongType, &tries);
773 fprintf(outFile, "date: %llu\n", tries);
780 CFReleaseNull(attempts);
786 fprintf(outFile, "Printing all the rings\n");
787 CFStringRef ringdescription = SOSCCGetAllTheRings(&error);
791 fprintf(outFile, "Rings: %s", CFStringToCString(ringdescription));
797 hadError = !SOSCCAccountSetToNew(&error);
799 notify_post(kSOSCCCircleChangedNotification);
803 hadError = !SOSCCResetToEmpty(&error);
807 hadError = !SOSCCResetToOffering(&error);
811 hadError = !dumpMyPeer(&error);
815 hadError = clearAllKVS(&error);
819 hadError = setPassword(optarg, &error);
823 hadError = tryPassword(optarg, &error);
828 uint64_t limit = strtoul(optarg, NULL, 10);
829 hadError = !SOSCCBailFromCircle_BestEffort(limit, &error);
834 hadError = !SOSCCPurgeUserCredentials(&error);
838 (void)SOSCCDumpCircleKVSInformation(optarg);
842 hadError = syncAndWait(&error);
846 hadError = !viewcmd(optarg, &error);
850 hadError = clientViewStatus(&error);
853 hadError = !listviewcmd(&error);
857 hadError = setBag(optarg, &error);
861 hadError = dumpYetToSync(&error);
865 case SYNC_REMOVE_PEER: {
867 optstr = CFStringCreateWithCString(NULL, optarg, kCFStringEncodingUTF8);
868 if (peers2remove == NULL) {
869 peers2remove = CFArrayCreateMutable(NULL, 0, &kCFTypeArrayCallBacks);
871 CFArrayAppendValue(peers2remove, optstr);
876 return SHOW_USAGE_MESSAGE;
881 return SHOW_USAGE_MESSAGE;
884 if (peers2remove != NULL) {
885 hadError = !doRemovePeers(peers2remove, &error);
886 CFRelease(peers2remove);
890 printerr(CFSTR("Error: %@\n"), error);