static DWORD LwSmDriverGetStatus( PLW_SERVICE_OBJECT pObject, PLW_SERVICE_STATUS pStatus ) { DWORD dwError = 0; LWIO_DRIVER_STATE driverState = 0; PDRIVER_STATE pState = LwSmGetServiceObjectData(pObject); pStatus->home = LW_SERVICE_HOME_IO_MANAGER; dwError = LwNtStatusToWin32Error(LwIoGetPid(&pStatus->pid)); if (dwError) { pStatus->pid = -1; } dwError = LwNtStatusToWin32Error(LwIoQueryStateDriver(pState->pName, &driverState)); if (dwError || driverState != LWIO_DRIVER_STATE_LOADED) { LwInterlockedCompareExchange(&pState->State, LW_SERVICE_STATE_DEAD, LW_SERVICE_STATE_RUNNING); } pStatus->state = LwInterlockedRead(&pState->State); return 0; }
static DWORD LsaUnjoinDomain( IN PCWSTR pwszDnsDomainName, IN PCWSTR pwszMachineSamAccountName, IN OPTIONAL PCWSTR pwszUserName, IN OPTIONAL PCWSTR pwszUserDomain, IN OPTIONAL PCWSTR pwszUserPassword, IN DWORD dwUnjoinFlags ) { DWORD dwError = ERROR_SUCCESS; NTSTATUS ntStatus = STATUS_SUCCESS; PWSTR pwszDCName = NULL; PIO_CREDS pCreds = NULL; dwError = LsaGetRwDcName(pwszDnsDomainName, FALSE, &pwszDCName); BAIL_ON_LSA_ERROR(dwError); /* disable the account only if requested */ if (dwUnjoinFlags & LSAJOIN_ACCT_DELETE) { if (pwszUserName && pwszUserPassword) { ntStatus = LwIoCreatePlainCredsW(pwszUserName, pwszUserDomain, pwszUserPassword, &pCreds); dwError = LwNtStatusToWin32Error(ntStatus); BAIL_ON_LSA_ERROR(dwError); } else { ntStatus = LwIoGetActiveCreds(NULL, &pCreds); dwError = LwNtStatusToWin32Error(ntStatus); BAIL_ON_LSA_ERROR(dwError); } ntStatus = LsaDisableMachineAccount(pwszDCName, pCreds, pwszMachineSamAccountName); dwError = LwNtStatusToWin32Error(ntStatus); BAIL_ON_LSA_ERROR(dwError); } error: LSA_ASSERT(!ntStatus || dwError); LW_SAFE_FREE_MEMORY(pwszDCName); if (pCreds) { LwIoDeleteCreds(pCreds); } return dwError; }
static DWORD MapSidToName( HANDLE hLsa, PSID pSid, PWSTR* ppwszName ) { DWORD dwError = 0; PSTR pszSid = NULL; LSA_QUERY_LIST QueryList; PLSA_SECURITY_OBJECT* ppObjects = NULL; dwError = LwNtStatusToWin32Error( RtlAllocateCStringFromSid(&pszSid, pSid)); BAIL_ON_SRVSVC_ERROR(dwError); QueryList.ppszStrings = (PCSTR*) &pszSid; dwError = LsaFindObjects( hLsa, NULL, 0, LSA_OBJECT_TYPE_UNDEFINED, LSA_QUERY_TYPE_BY_SID, 1, QueryList, &ppObjects); BAIL_ON_SRVSVC_ERROR(dwError); if (ppObjects[0] == NULL) { dwError = LW_ERROR_NO_SUCH_OBJECT; BAIL_ON_SRVSVC_ERROR(dwError); } dwError = LwNtStatusToWin32Error( LwRtlWC16StringAllocatePrintfW( ppwszName, L"%s\\%s", ppObjects[0]->pszNetbiosDomainName, ppObjects[0]->pszSamAccountName)); BAIL_ON_SRVSVC_ERROR(dwError); cleanup: LsaFreeSecurityObjectList(1, ppObjects); LW_SAFE_FREE_STRING(pszSid); return dwError; error: *ppwszName = NULL; goto cleanup; }
DWORD LsaPstoreGetJoinedDomainsA( OUT PSTR** DnsDomainNames, OUT PDWORD Count ) { DWORD dwError = 0; int EE = 0; PSTR* dnsDomainNames = NULL; DWORD count = 0; PWSTR* dnsDomainNamesW = NULL; DWORD countW = 0; dwError = LsaPstoreGetJoinedDomainsW( &dnsDomainNamesW, &countW); GOTO_CLEANUP_ON_WINERROR_EE(dwError, EE); if (!countW) { GOTO_CLEANUP_EE(EE); } dwError = LwNtStatusToWin32Error(LW_RTL_ALLOCATE( &dnsDomainNames, VOID, countW * sizeof(dnsDomainNames[0]))); GOTO_CLEANUP_ON_WINERROR_EE(dwError, EE); for (count = 0; count < countW; count++) { dwError = LwNtStatusToWin32Error(LwRtlCStringAllocateFromWC16String( &dnsDomainNames[count], dnsDomainNamesW[count])); GOTO_CLEANUP_ON_WINERROR_EE(dwError, EE); } cleanup: if (dwError) { LSA_PSTORE_FREE_STRING_ARRAY_A(&dnsDomainNames, &count); } LSA_PSTORE_FREE_STRING_ARRAY_W(&dnsDomainNamesW, &countW); *DnsDomainNames = dnsDomainNames; *Count = count; LSA_PSTORE_LOG_LEAVE_ERROR_EE(dwError, EE); return dwError; }
DWORD LsaPstorepBackendDeletePasswordInfoW( IN PLSA_PSTORE_BACKEND_STATE State, IN PCWSTR DnsDomainName ) { DWORD dwError = 0; int EE = 0; PSTR dnsDomainNameA = NULL; dwError = LwNtStatusToWin32Error(LwRtlCStringAllocateFromWC16String( &dnsDomainNameA, DnsDomainName)); GOTO_CLEANUP_ON_WINERROR_EE(dwError, EE); dwError = LwpsLegacyDeletePassword( State->OldStoreHandle, dnsDomainNameA); GOTO_CLEANUP_ON_WINERROR_EE(dwError, EE); cleanup: LW_RTL_FREE(&dnsDomainNameA); LSA_PSTORE_LOG_LEAVE_ERROR_EE(dwError, EE); return dwError; }
static DWORD VmAfdCreateAccessToken( PACCESS_TOKEN * AccessToken, PTOKEN_USER User, PTOKEN_GROUPS Groups, PTOKEN_PRIVILEGES Privileges, PTOKEN_OWNER Owner, PTOKEN_PRIMARY_GROUP PrimaryGroup, PTOKEN_DEFAULT_DACL DefaultDacl) { DWORD dwError = 0; NTSTATUS ntStatus = 0; ntStatus = RtlCreateAccessToken( AccessToken, User, Groups, Privileges, Owner, PrimaryGroup, DefaultDacl, NULL); dwError = LwNtStatusToWin32Error(ntStatus); return dwError; }
static DWORD VmAfdAllocateSidFromUid( uid_t uid, PSID *ppSid) { DWORD dwError = 0; NTSTATUS ntStatus = 0; PSID pSid = NULL; PSTR pszSid = NULL; dwError = VmAfdAllocateStringPrintf( &pszSid, "S-1-22-1-%d", /* Unix uid SID string */ uid); BAIL_ON_VMAFD_ERROR(dwError); ntStatus = RtlAllocateSidFromCString( &pSid, pszSid); dwError = LwNtStatusToWin32Error(ntStatus); BAIL_ON_VMAFD_ERROR(dwError); *ppSid = pSid; cleanup: VMAFD_SAFE_FREE_STRINGA(pszSid); return dwError; error: goto cleanup; }
static DWORD EVTAddAllowAces( PACL pDacl, DWORD dwCount, PSID* ppSidArray, ACCESS_MASK dwAccessMask ) { DWORD dwInputIndex = 0; DWORD dwError = 0; for (dwInputIndex = 0; dwInputIndex < dwCount; dwInputIndex++) { dwError = LwNtStatusToWin32Error( RtlAddAccessAllowedAceEx(pDacl, ACL_REVISION, 0, dwAccessMask, ppSidArray[dwInputIndex])); BAIL_ON_EVT_ERROR(dwError); } cleanup: return dwError; error: goto cleanup; }
DWORD LsaPstoreGetDefaultDomainA( OUT PSTR* DnsDomainName ) { DWORD dwError = 0; int EE = 0; PWSTR dnsDomainNameW = NULL; PSTR dnsDomainName = NULL; dwError = LsaPstoreGetDefaultDomainW(&dnsDomainNameW); GOTO_CLEANUP_ON_WINERROR_EE(dwError, EE); dwError = LwNtStatusToWin32Error(LwRtlCStringAllocateFromWC16String( &dnsDomainName, dnsDomainNameW)); GOTO_CLEANUP_ON_WINERROR_EE(dwError, EE); cleanup: if (dwError) { LW_RTL_FREE(&dnsDomainName); } LSA_PSTORE_FREE(&dnsDomainNameW); *DnsDomainName = dnsDomainName; LSA_PSTORE_LOG_LEAVE_ERROR_EE(dwError, EE); return dwError; }
DWORD LsaPstorepBackendGetDefaultDomainW( IN PLSA_PSTORE_BACKEND_STATE State, OUT PWSTR* DnsDomainName ) { DWORD dwError = 0; int EE = 0; PSTR dnsDomainNameA = NULL; PWSTR dnsDomainName = NULL; dwError = LwpsLegacyGetDefaultJoinedDomain( State->OldStoreHandle, &dnsDomainNameA); GOTO_CLEANUP_ON_WINERROR_EE(dwError, EE); dwError = LwNtStatusToWin32Error(LwRtlWC16StringAllocateFromCString( &dnsDomainName, dnsDomainNameA)); GOTO_CLEANUP_ON_WINERROR_EE(dwError, EE); cleanup: if (dwError) { LW_RTL_FREE(&dnsDomainName); } LW_RTL_FREE(&dnsDomainNameA); *DnsDomainName = dnsDomainName; LSA_PSTORE_LOG_LEAVE_ERROR_EE(dwError, EE); return dwError; }
NET_API_STATUS NetrFileClose( PSRVSVC_CONTEXT pContext, const wchar16_t *servername, UINT32 fileid ) { NET_API_STATUS status = ERROR_SUCCESS; BAIL_ON_INVALID_PTR(pContext, status); TRY { status = _NetrFileClose( pContext->hBinding, (wchar16_t *)servername, fileid); } CATCH_ALL(pDceException) { NTSTATUS ntStatus = LwRpcStatusToNtStatus(pDceException->match.value); status = LwNtStatusToWin32Error(ntStatus); } ENDTRY; BAIL_ON_WIN_ERROR(status); cleanup: return status; error: goto cleanup; }
DWORD DsrAllocateDsRoleInfo( OUT PDSR_ROLE_INFO pOut, IN OUT PDWORD pdwOffset, IN OUT PDWORD pdwSpaceLeft, IN PDSR_ROLE_INFO pIn, IN WORD swLevel, IN OUT PDWORD pdwSize ) { NTSTATUS ntStatus = STATUS_SUCCESS; DWORD dwError = ERROR_SUCCESS; PVOID pBuffer = pOut; BAIL_ON_INVALID_PTR(pdwOffset, ntStatus); BAIL_ON_INVALID_PTR(pIn, ntStatus); BAIL_ON_INVALID_PTR(pdwSize, ntStatus); switch(swLevel) { case DS_ROLE_BASIC_INFORMATION: LWBUF_ALLOC_DWORD(pBuffer, pIn->Basic.dwRole); LWBUF_ALLOC_DWORD(pBuffer, pIn->Basic.dwFlags); LWBUF_ALLOC_PWSTR(pBuffer, pIn->Basic.pwszDomain); LWBUF_ALLOC_PWSTR(pBuffer, pIn->Basic.pwszDnsDomain); LWBUF_ALLOC_PWSTR(pBuffer, pIn->Basic.pwszForest); LWBUF_ALLOC_BLOB(pBuffer, sizeof(pIn->Basic.DomainGuid), &pIn->Basic.DomainGuid); break; case DS_ROLE_UPGRADE_STATUS: LWBUF_ALLOC_WORD(pBuffer, pIn->Upgrade.swUpgradeStatus); LWBUF_ALIGN_TYPE(pdwOffset, pdwSize, pdwSpaceLeft, DWORD); LWBUF_ALLOC_DWORD(pBuffer, pIn->Upgrade.dwPrevious); break; case DS_ROLE_OP_STATUS: LWBUF_ALLOC_WORD(pBuffer, pIn->OpStatus.swStatus); break; default: ntStatus = STATUS_INVALID_PARAMETER; break; } BAIL_ON_WIN_ERROR(dwError); cleanup: if (dwError == ERROR_SUCCESS && ntStatus != STATUS_SUCCESS) { dwError = LwNtStatusToWin32Error(dwError); } return dwError; error: goto cleanup; }
DWORD VmDirPagedSearchCacheInit( VOID ) { DWORD dwError = 0; dwError = VmDirAllocateMutex(&gPagedSearchCache.mutex); BAIL_ON_VMDIR_ERROR(dwError); dwError = LwRtlCreateHashTable( &gPagedSearchCache.pHashTbl, PagedSearchRecordGetKey, LwRtlHashDigestPstr, LwRtlHashEqualPstr, NULL, VMDIR_PAGED_SEARCH_CACHE_HASH_TABLE_SIZE); dwError = LwNtStatusToWin32Error(dwError); BAIL_ON_VMDIR_ERROR(dwError); cleanup: return dwError; error: VmDirPagedSearchCacheFree(); goto cleanup; }
static PVDIR_PAGED_SEARCH_RECORD VmDirPagedSearchCacheFind( PCSTR pszCookie ) { DWORD dwError = 0; PLW_HASHTABLE_NODE pNode = NULL; PVDIR_PAGED_SEARCH_RECORD pSearchRecord = NULL; BOOLEAN bInLock = FALSE; if (IsNullOrEmptyString(pszCookie)) { BAIL_WITH_VMDIR_ERROR(dwError, VMDIR_ERROR_INVALID_PARAMETER); } VMDIR_LOCK_MUTEX(bInLock, gPagedSearchCache.mutex); dwError = LwRtlHashTableFindKey( gPagedSearchCache.pHashTbl, &pNode, (PVOID)pszCookie); dwError = LwNtStatusToWin32Error(dwError); BAIL_ON_VMDIR_ERROR(dwError); pSearchRecord = LW_STRUCT_FROM_FIELD(pNode, VDIR_PAGED_SEARCH_RECORD, Node); _RefPagedSearchRecord(pSearchRecord); cleanup: VMDIR_UNLOCK_MUTEX(bInLock, gPagedSearchCache.mutex); return pSearchRecord; error: goto cleanup; }
DWORD LsaPstorepBackendSetDefaultDomainW( IN PLSA_PSTORE_BACKEND_STATE State, IN OPTIONAL PCWSTR DnsDomainName ) { DWORD dwError = 0; int EE = 0; PSTR dnsDomainNameA = NULL; if (DnsDomainName) { dwError = LwNtStatusToWin32Error(LwRtlCStringAllocateFromWC16String( &dnsDomainNameA, DnsDomainName)); GOTO_CLEANUP_ON_WINERROR_EE(dwError, EE); } dwError = LwpsLegacySetDefaultJoinedDomain( State->OldStoreHandle, dnsDomainNameA); GOTO_CLEANUP_ON_WINERROR_EE(dwError, EE); cleanup: LW_RTL_FREE(&dnsDomainNameA); LSA_PSTORE_LOG_LEAVE_ERROR_EE(dwError, EE); return dwError; }
static DWORD LwSmDriverStop( PLW_SERVICE_OBJECT pObject ) { DWORD dwError = 0; PDRIVER_STATE pState = LwSmGetServiceObjectData(pObject); if (LwInterlockedCompareExchange(&pState->State, LW_SERVICE_STATE_STOPPING, LW_SERVICE_STATE_RUNNING) == LW_SERVICE_STATE_RUNNING) { dwError = LwNtStatusToWin32Error(LwIoUnloadDriver(pState->pName)); BAIL_ON_ERROR(dwError); pState->State = LW_SERVICE_STATE_STOPPED; LwSmNotifyServiceObjectStateChange(pObject, LW_SERVICE_STATE_STOPPED); } cleanup: return dwError; error: goto cleanup; }
DWORD LsaPstoreSetDefaultDomainA( IN OPTIONAL PCSTR DnsDomainName ) { DWORD dwError = 0; int EE = 0; PWSTR dnsDomainNameW = NULL; if (DnsDomainName) { dwError = LwNtStatusToWin32Error(LwRtlWC16StringAllocateFromCString( &dnsDomainNameW, DnsDomainName)); GOTO_CLEANUP_ON_WINERROR_EE(dwError, EE); } dwError = LsaPstoreSetDefaultDomainW(dnsDomainNameW); GOTO_CLEANUP_ON_WINERROR_EE(dwError, EE); cleanup: LW_RTL_FREE(&dnsDomainNameW); LSA_PSTORE_LOG_LEAVE_ERROR_EE(dwError, EE); return dwError; }
DWORD VMCAAllocateStringW( PCWSTR pwszSrc, PWSTR* ppwszDst ) { DWORD dwError = 0; if (!pwszSrc || !ppwszDst) { dwError = ERROR_INVALID_PARAMETER; } else { #ifdef _WIN32 PWSTR pwszNewString = NULL; size_t len = wcslen(pwszSrc); dwError = VMCAAllocateMemory( (DWORD) (len + 1)*sizeof(WCHAR), (PVOID *)&pwszNewString ); BAIL_ON_VMCA_ERROR(dwError); wcscpy_s(pwszNewString, (len + 1), pwszSrc); *ppwszDst = pwszNewString; #else dwError = LwNtStatusToWin32Error( LwRtlWC16StringDuplicate(ppwszDst, pwszSrc)); BAIL_ON_VMCA_ERROR(dwError); #endif } error: return dwError; }
static DWORD LsaPstorepInitializePlugin( OUT PLSA_PSTORE_PLUGIN_INFO PluginInfo, IN PCSTR PluginName ) { DWORD dwError = 0; int EE = 0; LSA_PSTORE_PLUGIN_INITIALIZE_FUNCTION initFunction = NULL; dwError = LwNtStatusToWin32Error(LwRtlCStringDuplicate(&PluginInfo->Name, PluginName)); GOTO_CLEANUP_ON_WINERROR_EE(dwError, EE); dwError = LsaPstorepGetPluginPath(PluginInfo->Name, &PluginInfo->Path); GOTO_CLEANUP_ON_WINERROR_EE(dwError, EE); dwError = LsaPstorepOpenPlugin( PluginInfo->Path, LSA_PSTORE_PLUGIN_INITIALIZE_FUNCTION_NAME, &PluginInfo->LibraryHandle, OUT_PPVOID(&initFunction)); GOTO_CLEANUP_ON_WINERROR_EE(dwError, EE); dwError = initFunction(LSA_PSTORE_PLUGIN_VERSION, PluginInfo->Name, &PluginInfo->Dispatch, &PluginInfo->Context); GOTO_CLEANUP_ON_WINERROR_EE(dwError, EE); if (!PluginInfo->Dispatch) { LW_RTL_LOG_ERROR("LSA pstore plugin %s is missing a dispatch table", PluginInfo->Name); dwError = ERROR_DLL_INIT_FAILED; GOTO_CLEANUP_EE(EE); } if (!PluginInfo->Dispatch->Cleanup) { LW_RTL_LOG_ERROR("LSA pstore plugin %s is missing the Cleanup function", PluginInfo->Name); dwError = ERROR_DLL_INIT_FAILED; GOTO_CLEANUP_EE(EE); } LW_RTL_LOG_VERBOSE("Loaded LSA pstore plugin %s from %s", PluginInfo->Name, PluginInfo->Path); cleanup: if (dwError) { LsaPstorepCleanupPlugin(PluginInfo); } LSA_PSTORE_LOG_LEAVE_ERROR_EE(dwError, EE); return dwError; }
static DWORD MapBuiltinNameToSid( PSID *ppSid, PCWSTR pwszName ) { DWORD dwError = 0; union { SID sid; BYTE buffer[SID_MAX_SIZE]; } Sid; ULONG SidSize = sizeof(Sid.buffer); PWSTR pwszEveryone = NULL; dwError = LwNtStatusToWin32Error( RtlWC16StringAllocateFromCString( &pwszEveryone, "Everyone")); BAIL_ON_SRVSVC_ERROR(dwError); if (LwRtlWC16StringIsEqual(pwszName, pwszEveryone, FALSE)) { dwError = LwNtStatusToWin32Error( RtlCreateWellKnownSid( WinWorldSid, NULL, &Sid.sid, &SidSize)); } BAIL_ON_SRVSVC_ERROR(dwError); dwError = LwNtStatusToWin32Error( RtlDuplicateSid(ppSid, &Sid.sid)); cleanup: LW_RTL_FREE(&pwszEveryone); return dwError; error: goto cleanup; }
static DWORD MapBuiltinSidToName( PWSTR *ppwszName, PSID pSid ) { DWORD dwError = 0; union { SID sid; BYTE buffer[SID_MAX_SIZE]; } Sid; ULONG SidSize = sizeof(Sid.buffer); PWSTR pwszEveryone = NULL; dwError = LwNtStatusToWin32Error( RtlCreateWellKnownSid( WinWorldSid, NULL, &Sid.sid, &SidSize)); BAIL_ON_LTNET_ERROR(dwError); if (RtlEqualSid(&Sid.sid, pSid)) { dwError = LwNtStatusToWin32Error( RtlWC16StringAllocateFromCString( &pwszEveryone, "Everyone")); BAIL_ON_LTNET_ERROR(dwError); } *ppwszName = pwszEveryone; cleanup: return dwError; error: LwNetWC16StringFree(pwszEveryone); goto cleanup; }
ULONG VmDirAllocateCStringFromSid( PSTR* ppszStringSid, PSID pSid ) { return LwNtStatusToWin32Error( RtlAllocateCStringFromSid(ppszStringSid,pSid)); }
ULONG VmDirAllocateSidFromCString( PCSTR pszSidString, PSID* ppSid ) { return LwNtStatusToWin32Error( RtlAllocateSidFromCString(ppSid, (PCSTR)pszSidString)); }
static DWORD NtlmGetLocalGuestAccountSid( OUT PSTR* ppszGuestSid ) { DWORD dwError = LW_ERROR_SUCCESS; NTSTATUS ntStatus = STATUS_SUCCESS; PLW_MAP_SECURITY_CONTEXT pContext = NULL; PSID pGuestSid = NULL; PSTR pszGuestSid = NULL; ntStatus = LwMapSecurityCreateContext(&pContext); dwError = LwNtStatusToWin32Error(ntStatus); BAIL_ON_LSA_ERROR(dwError); ntStatus = LwMapSecurityGetLocalGuestAccountSid(pContext, &pGuestSid); dwError = LwNtStatusToWin32Error(ntStatus); BAIL_ON_LSA_ERROR(dwError); ntStatus = RtlAllocateCStringFromSid(&pszGuestSid, pGuestSid); dwError = LwNtStatusToWin32Error(ntStatus); BAIL_ON_LSA_ERROR(dwError); cleanup: if (pContext && pGuestSid) { LwMapSecurityFreeSid(pContext, &pGuestSid); } LwMapSecurityFreeContext(&pContext); *ppszGuestSid = pszGuestSid; return dwError; error: LW_SAFE_FREE_STRING(pszGuestSid); goto cleanup; }
ULONG VmDirInitializeSid( PSID Sid, PSID_IDENTIFIER_AUTHORITY IdentifierAuthority, UCHAR SubAuthorityCount ) { return LwNtStatusToWin32Error(RtlInitializeSid(Sid, IdentifierAuthority, SubAuthorityCount)); }
static DWORD MapNameToSid( HANDLE hLsa, PCWSTR pwszName, PSID* ppSid ) { DWORD dwError = 0; PSTR pszName = NULL; LSA_QUERY_LIST QueryList; PLSA_SECURITY_OBJECT* ppObjects = NULL; dwError = LwWc16sToMbs(pwszName, &pszName); BAIL_ON_SRVSVC_ERROR(dwError); QueryList.ppszStrings = (PCSTR*) &pszName; dwError = LsaFindObjects( hLsa, NULL, 0, LSA_OBJECT_TYPE_UNDEFINED, LSA_QUERY_TYPE_BY_NAME, 1, QueryList, &ppObjects); BAIL_ON_SRVSVC_ERROR(dwError); if (ppObjects[0] == NULL) { dwError = LW_ERROR_NO_SUCH_OBJECT; BAIL_ON_SRVSVC_ERROR(dwError); } dwError = LwNtStatusToWin32Error( RtlAllocateSidFromCString(ppSid, ppObjects[0]->pszObjectSid)); BAIL_ON_SRVSVC_ERROR(dwError); cleanup: LsaFreeSecurityObjectList(1, ppObjects); LW_SAFE_FREE_STRING(pszName); return dwError; error: *ppSid = NULL; goto cleanup; }
DWORD LsaPstorepBackendGetPasswordInfoW( IN PLSA_PSTORE_BACKEND_STATE State, IN PCWSTR DnsDomainName, OUT OPTIONAL PLSA_MACHINE_PASSWORD_INFO_W* PasswordInfo ) { DWORD dwError = 0; int EE = 0; PSTR dnsDomainNameA = NULL; PLSA_MACHINE_PASSWORD_INFO_W passwordInfo = NULL; PLSA_MACHINE_PASSWORD_INFO_A passwordInfoA = NULL; dwError = LwNtStatusToWin32Error(LwRtlCStringAllocateFromWC16String( &dnsDomainNameA, DnsDomainName)); GOTO_CLEANUP_ON_WINERROR_EE(dwError, EE); dwError = LwpsLegacyReadPassword( State->OldStoreHandle, dnsDomainNameA, &passwordInfoA); GOTO_CLEANUP_ON_WINERROR_EE(dwError, EE); dwError = LsaPstorepConvertAnsiToWidePasswordInfo( passwordInfoA, &passwordInfo); GOTO_CLEANUP_ON_WINERROR_EE(dwError, EE); cleanup: if (dwError) { LSA_PSTORE_FREE_PASSWORD_INFO_W(&passwordInfo); } LSA_PSTORE_FREE_PASSWORD_INFO_A(&passwordInfoA); LW_RTL_FREE(&dnsDomainNameA); if (PasswordInfo) { *PasswordInfo = passwordInfo; } else { LSA_PSTORE_FREE_PASSWORD_INFO_W(&passwordInfo); } LSA_PSTORE_LOG_LEAVE_ERROR_EE(dwError, EE); return dwError; }
static DWORD LwSmMain( VOID ) { DWORD dwError = 0; PLW_TASK pTask = NULL; dwError = LwNtStatusToWin32Error(LwRtlCreateTask( gpPool, &pTask, NULL, MainTask, NULL)); BAIL_ON_ERROR(dwError); LwRtlWakeTask(pTask); dwError = LwNtStatusToWin32Error(LwRtlMain()); BAIL_ON_ERROR(dwError); cleanup: if (pTask) { LwRtlCancelTask(pTask); LwRtlWaitTask(pTask); LwRtlReleaseTask(&pTask); } return dwError; error: goto cleanup; }
DWORD RegSrvApiInit( VOID ) { DWORD dwError = 0; dwError = LwNtStatusToWin32Error(LwMapSecurityInitialize()); BAIL_ON_REG_ERROR(dwError); dwError = LwNtStatusToWin32Error(LwMapSecurityCreateContext(&gpRegLwMapSecurityCtx)); BAIL_ON_REG_ERROR(dwError); #if defined(REG_USE_FILE) dwError = FileProvider_Initialize(&gpRegProvider); BAIL_ON_REG_ERROR(dwError); #elif defined(REG_USE_SQLITE) dwError = SqliteProvider_Initialize(&gpRegProvider, ROOT_KEYS); BAIL_ON_REG_ERROR(dwError); #endif // make sure gpRegProvider is not NULL if (!gpRegProvider) { dwError = ERROR_INTERNAL_ERROR; BAIL_ON_REG_ERROR(dwError); } cleanup: return dwError; error: goto cleanup; }
// macros use this function // static DWORD VmAuthsvcRpcGetErrorCode( dcethread_exc* pDceException ) { DWORD dwError = 0; dwError = dcethread_exc_getstatus(pDceException); #ifndef _WIN32 dwError = LwNtStatusToWin32Error(LwRpcStatusToNtStatus(dwError)); #endif return dwError; }