static long UnregisterGPONode( PCSTR pszDomain, PCSTR pszGPOName ) { long macError = eDSNoErr; tDataListPtr nodeNameList = NULL; char szChildNodeName[1024]; if (!pszDomain) { macError = eDSEmptyParameter; GOTO_CLEANUP_ON_MACERROR( macError ); } /* Build up node names for each child node found */ nodeNameList = dsDataListAllocate(0); if ( !nodeNameList ) { macError = eDSAllocationFailed; GOTO_CLEANUP_ON_MACERROR( macError ); } memset(szChildNodeName, 0, sizeof(szChildNodeName)); strcpy(szChildNodeName, PLUGIN_ROOT_PATH); strcat(szChildNodeName, "/"); strcat(szChildNodeName, pszDomain); strcat(szChildNodeName, "/"); strcat(szChildNodeName, pszGPOName); macError = dsBuildListFromPathAlloc(0, nodeNameList, szChildNodeName, "/"); GOTO_CLEANUP_ON_MACERROR( macError ); macError = DSUnregisterNode(GlobalState.Signature, nodeNameList); cleanup: if (nodeNameList) { dsDataListDeallocate(0, nodeNameList); free(nodeNameList); } return macError; }
/* * This must be called between GS_ACQUIRE_EXCLUSIVE() and GS_RELEASE(). */ static long Activate(void) { long macError = eDSNoErr; tDataListPtr nodeNameList = NULL; BOOLEAN bIsStarted = FALSE; LOG_ENTER(""); LOG("Verify that LSASS service is operational"); GlobalState.IsStartupComplete = false; // Verify that startup has completed successfully for lsass service. GetLsaStatus(&bIsStarted); if (bIsStarted) { LOG("LSASS service is operational"); GlobalState.IsStartupComplete = true; } if ( !GlobalState.DsRoot ) { macError = dsOpenDirService( &GlobalState.DsRoot ); GOTO_CLEANUP_ON_MACERROR( macError ); } if ( !GlobalState.NodeNameList ) { nodeNameList = dsDataListAllocate(0); if ( !nodeNameList ) { macError = eDSAllocationFailed; GOTO_CLEANUP_ON_MACERROR( macError ); } macError = dsBuildListFromPathAlloc(0, nodeNameList, PLUGIN_ROOT_PATH, "/"); GOTO_CLEANUP_ON_MACERROR( macError ); macError = DSRegisterNode(GlobalState.Signature, nodeNameList, kDirNodeType); GOTO_CLEANUP_ON_MACERROR( macError ); GlobalState.NodeNameList = nodeNameList; nodeNameList = NULL; } if ( !GlobalState.NodeDictionary ) { GlobalState.NodeDictionary = CFDictionaryCreateMutable(NULL, 0, &kCFCopyStringDictionaryKeyCallBacks, &kCFTypeDictionaryValueCallBacks); } cleanup: if (nodeNameList) { dsDataListDeallocate(0, nodeNameList); free(nodeNameList); } if (macError) { long localMacError = Deactivate(); if (localMacError) { LOG_ERROR("Unexpected error: %d", localMacError); } } LOG_LEAVE("--> %d", macError); return macError; }
tDirStatus SaveAuthAuthoritiesWithRecordRef( CDSLocalPlugin* inPlugin, tDirNodeReference inNodeRef, tRecordReference inRecordRef, CAuthAuthority &inAATank ) { tDirStatus siResult = eDSAuthFailed; UInt32 avIndex = 0; UInt32 avCount = 0; char *aaStr = NULL; CFMutableDictionaryRef nodeDict = NULL; CFStringRef preRootAuthString = NULL; tDataListPtr attrValueList = NULL; try { // retrieve the same nodeDict the plugin object is going to use CFDictionaryRef openRecordDict = inPlugin->RecordDictForRecordRef( inRecordRef ); if ( openRecordDict == NULL ) throw( eDSInvalidRecordRef ); nodeDict = (CFMutableDictionaryRef)CFDictionaryGetValue( openRecordDict, CFSTR(kOpenRecordDictNodeDict) ); if ( nodeDict == NULL ) throw( eDSInvalidNodeRef ); preRootAuthString = (CFStringRef) CFDictionaryGetValue( nodeDict, CFSTR(kNodeAuthenticatedUserName) ); if ( preRootAuthString != NULL ) CFRetain( preRootAuthString ); CFDictionarySetValue( nodeDict, CFSTR(kNodeAuthenticatedUserName), CFSTR("root") ); avCount = inAATank.GetValueCount(); if ( avCount == 0 ) { siResult = inPlugin->RemoveAttribute( inRecordRef, CFSTR(kDSNAttrAuthenticationAuthority) ); } else { attrValueList = dsDataListAllocate( 0 ); for ( avIndex = 0; avIndex < avCount; avIndex++ ) { aaStr = inAATank.GetValueAtIndex( avIndex ); if ( aaStr != NULL ) { siResult = dsAppendStringToListAlloc( 0, attrValueList, aaStr ); DSFreeString( aaStr ); if ( siResult != eDSNoErr ) throw( siResult ); } } // need to use SetAttributeValues() instead of RemoveAttribute() to avoid deleting the // shadow hash files. tDataNodePtr attrTypeNode = dsDataNodeAllocateString( 0, kDSNAttrAuthenticationAuthority ); sSetAttributeValues apiData = { kSetAttributeValues, 0, inRecordRef, attrTypeNode, attrValueList }; char *recTypeStr = inPlugin->GetRecordTypeFromRef( inRecordRef ); siResult = inPlugin->SetAttributeValues( &apiData, recTypeStr ); DSFreeString( recTypeStr ); dsDataNodeDeAllocate( 0, attrTypeNode ); } if ( siResult != eDSNoErr ) throw( siResult ); } catch( tDirStatus err ) { DbgLog( kLogPlugin, "SaveAuthAuthorities(): got error %d", err ); siResult = err; } if ( preRootAuthString != NULL ) { CFDictionarySetValue( nodeDict, CFSTR(kNodeAuthenticatedUserName), preRootAuthString ); CFRelease( preRootAuthString ); } else { CFDictionaryRemoveValue( nodeDict, CFSTR(kNodeAuthenticatedUserName) ); } DSFreeString( aaStr ); if ( attrValueList != NULL ) { dsDataListDeallocate( 0, attrValueList ); free( attrValueList ); } return siResult; }