OsqueryAWSCredentialsProviderChain::OsqueryAWSCredentialsProviderChain(bool sts) : AWSCredentialsProviderChain() { // The order of the AddProvider calls determines the order in which the // provider chain attempts to retrieve credentials. if (sts && !FLAGS_aws_sts_arn_role.empty()) { AddProvider(std::make_shared<OsquerySTSAWSCredentialsProvider>()); } AddProvider(std::make_shared<OsqueryFlagsAWSCredentialsProvider>()); if (!FLAGS_aws_profile_name.empty()) { AddProvider( std::make_shared<Aws::Auth::ProfileConfigFileAWSCredentialsProvider>( FLAGS_aws_profile_name.c_str())); } AddProvider(std::make_shared<Aws::Auth::EnvironmentAWSCredentialsProvider>()); AddProvider( std::make_shared<Aws::Auth::ProfileConfigFileAWSCredentialsProvider>()); AddProvider( std::make_shared<Aws::Auth::InstanceProfileCredentialsProvider>()); }
INT WINAPI NSQUERY::LookupServiceBegin( IN LPWSAQUERYSETW lpqsRestrictions, IN DWORD dwControlFlags, IN PNSCATALOG NsCatalog ) /*++ Routine Description: Complete the initialization of a NSQUERY object and call NSPLookupServiceBegin() for all service providers refereneced by the query. Arguments: NsCatalog - Supplies a reference to the name-space catalog object from which providers may be selected. Return Value: --*/ { INT ReturnCode, ReturnCode1; INT ErrorCode; PNSCATALOGENTRY ProviderEntry; PNSPROVIDERSTATE Provider; PLIST_ENTRY ListEntry; BOOL Continue = TRUE; WSASERVICECLASSINFOW ClassInfo; LPWSASERVICECLASSINFOW ClassInfoBuf=NULL; DWORD ClassInfoSize=0; DWORD dwTempOutputFlags = lpqsRestrictions->dwOutputFlags; LPWSTR lpszTempComment = lpqsRestrictions->lpszComment; DWORD dwTempNumberCsAddrs = lpqsRestrictions->dwNumberOfCsAddrs; PCSADDR_INFO lpTempCsaBuffer = lpqsRestrictions->lpcsaBuffer; // Select the service provider(s) that will be used for this query. A // service provider is selected using the provider GUID or the namespace ID // the namespace ID may be a specific namespace i.e. NS_DNS or NS_ALL for // all installed namespaces. // // Make sure that the ignored fields are cleared so that the // CopyQuerySetW function call below doesn't AV. // // This was a fix for bug #91655 // lpqsRestrictions->dwOutputFlags = 0; lpqsRestrictions->lpszComment = NULL; lpqsRestrictions->dwNumberOfCsAddrs = 0; lpqsRestrictions->lpcsaBuffer = NULL; #ifdef RASAUTODIAL // // Save the original parameters of the query, in // case we have to restart it due to an autodial // attempt. // if (m_restartable) { ReturnCode = CopyQuerySetW(lpqsRestrictions, &m_query_set); Continue = (ReturnCode == ERROR_SUCCESS); if (!Continue) { SetLastError(ReturnCode); ReturnCode = SOCKET_ERROR; m_restartable = FALSE; } m_control_flags = dwControlFlags; m_catalog = NsCatalog; } #endif // RASAUTODIAL if (Continue) { if (lpqsRestrictions->lpNSProviderId) { // Use a single namespace provider ReturnCode = NsCatalog->GetCountedCatalogItemFromProviderId( lpqsRestrictions->lpNSProviderId, &ProviderEntry); if (ERROR_SUCCESS != ReturnCode){ SetLastError(WSAEINVAL); Continue = FALSE; ReturnCode = SOCKET_ERROR; } //if if (Continue){ Continue = AddProvider(ProviderEntry->GetProvider()); } //if } //if else{ NSPENUMERATIONCONTEXT Context; Context.lpqs = lpqsRestrictions; Context.ErrorCode = ERROR_SUCCESS; Context.aNsQuery = this; Context.Catalog = NsCatalog; NsCatalog->EnumerateCatalogItems( LookupBeginEnumerationProc, &Context); if (ERROR_SUCCESS != Context.ErrorCode){ SetLastError(Context.ErrorCode); ReturnCode = SOCKET_ERROR; Continue = FALSE; } //if } //else } //if if (Continue){ //Get the class information for this query. Call once with a zero //buffer to size the buffer we need to allocate then call to get the //real answer ClassInfo.lpServiceClassId = lpqsRestrictions->lpServiceClassId; ReturnCode = NsCatalog->GetServiceClassInfo( &ClassInfoSize, &ClassInfo); ErrorCode = GetLastError(); if ((SOCKET_ERROR == ReturnCode) && WSAEFAULT == ErrorCode ){ ClassInfoBuf = (LPWSASERVICECLASSINFOW)new BYTE[ClassInfoSize]; if (ClassInfoBuf){ ReturnCode = NsCatalog->GetServiceClassInfo( &ClassInfoSize, ClassInfoBuf); } //if else{ Continue = FALSE; } //else } //if } //if if( Continue && IsListEmpty( &m_provider_list ) ) { Continue = FALSE; ReturnCode = SOCKET_ERROR; SetLastError(WSASERVICE_NOT_FOUND); } if (Continue){ ReturnCode1 = SOCKET_ERROR; //Call Begin on all the selected providers ListEntry = m_provider_list.Flink; Provider = CONTAINING_RECORD( ListEntry, NSPROVIDERSTATE, m_query_linkage); while (Provider){ ReturnCode = Provider->LookupServiceBegin(lpqsRestrictions, ClassInfoBuf, dwControlFlags); if(ReturnCode == SOCKET_ERROR) { // // this provider didn't like it. So remove it // from the list // PNSPROVIDERSTATE Provider1; Provider1 = Provider; Provider = NextProvider(Provider); RemoveEntryList(&Provider1->m_query_linkage); delete(Provider1); } else { ReturnCode1 = ReturnCode; Provider = NextProvider(Provider); } } //while } //if if (!Continue || ((ReturnCode = ReturnCode1) == SOCKET_ERROR)){ // We failed somewhere along the way so clean up the provider on the // provider list. while (!IsListEmpty(&m_provider_list)){ ListEntry = RemoveHeadList(&m_provider_list); Provider = CONTAINING_RECORD( ListEntry, NSPROVIDERSTATE, m_query_linkage); delete(Provider); } //while if (ClassInfoBuf){ delete ClassInfoBuf; } //if } //if else{ ListEntry = m_provider_list.Flink; m_current_provider = CONTAINING_RECORD( ListEntry, NSPROVIDERSTATE, m_query_linkage); } //else // // Restore ignored field values to what callee had set. // lpqsRestrictions->dwOutputFlags = dwTempOutputFlags; lpqsRestrictions->lpszComment = lpszTempComment; lpqsRestrictions->dwNumberOfCsAddrs = dwTempNumberCsAddrs; lpqsRestrictions->lpcsaBuffer = lpTempCsaBuffer; return(ReturnCode); }
static BOOLEAN InitializeFmIfsOnce(void) { OBJECT_ATTRIBUTES ObjectAttributes; UNICODE_STRING RegistryPath = RTL_CONSTANT_STRING(L"\\REGISTRY\\Machine\\SOFTWARE\\ReactOS\\ReactOS\\CurrentVersion\\IFS"); HANDLE hKey = NULL; PKEY_VALUE_FULL_INFORMATION Buffer; ULONG BufferSize = sizeof(KEY_VALUE_FULL_INFORMATION) + MAX_PATH; ULONG RequiredSize; ULONG i = 0; UNICODE_STRING Name; UNICODE_STRING Data; NTSTATUS Status; InitializeListHead(&ProviderListHead); /* Read IFS providers from HKLM\SOFTWARE\ReactOS\ReactOS\CurrentVersion\IFS */ InitializeObjectAttributes(&ObjectAttributes, &RegistryPath, 0, NULL, NULL); Status = NtOpenKey(&hKey, KEY_QUERY_VALUE, &ObjectAttributes); if (Status == STATUS_OBJECT_NAME_NOT_FOUND) return TRUE; else if (!NT_SUCCESS(Status)) return FALSE; Buffer = (PKEY_VALUE_FULL_INFORMATION)RtlAllocateHeap( RtlGetProcessHeap(), 0, BufferSize); if (!Buffer) { NtClose(hKey); return FALSE; } while (TRUE) { Status = NtEnumerateValueKey( hKey, i++, KeyValueFullInformation, Buffer, BufferSize, &RequiredSize); if (Status == STATUS_BUFFER_OVERFLOW) continue; else if (!NT_SUCCESS(Status)) break; else if (Buffer->Type != REG_SZ) continue; Name.Length = Name.MaximumLength = Buffer->NameLength; Name.Buffer = Buffer->Name; Data.Length = Data.MaximumLength = Buffer->DataLength; Data.Buffer = (PWCHAR)((ULONG_PTR)Buffer + Buffer->DataOffset); if (Data.Length > sizeof(WCHAR) && Data.Buffer[Data.Length / sizeof(WCHAR) - 1] == UNICODE_NULL) Data.Length -= sizeof(WCHAR); AddProvider(&Name, Data.Buffer); } NtClose(hKey); RtlFreeHeap(RtlGetProcessHeap(), 0, Buffer); return TRUE; }