static void WiFiScanResult(void* context, const char* ssid, const uint8_t bssid[6], uint8_t rssi, AJ_WiFiSecurityType secType, AJ_WiFiCipherType cipherType) { static const char* const sec[] = { "OPEN", "WEP", "WPA", "WPA2" }; static const char* const typ[] = { "", ":TKIP", ":CCMP", ":WEP" }; AJ_InfoPrintf(("WiFiScanResult found ssid=%s rssi=%d security=%s%s\n", ssid, rssi, sec[secType], typ[cipherType])); AJOBS_AuthType authType = GetAuthType(secType, cipherType); GotScanInfo(ssid, bssid, rssi, authType); }
DWORD DJFixLoginConfigFile( PCSTR pszPath ) { DWORD ceError = ERROR_SUCCESS; PCSTR pszFilePath = NULL; PSTR pszTmpPath = NULL; PSTR pszFinalPath = NULL; BOOLEAN bFileExists = FALSE; FILE* fp = NULL; FILE* fp_new = NULL; DynamicArray lines; PSTR currentSystem = NULL; memset(&lines, 0, sizeof(lines)); if (IsNullOrEmptyString(pszPath)) pszFilePath = LOGIN_CONFIG_PATH; else pszFilePath = pszPath; GCE(ceError = CTGetFileTempPath( pszFilePath, &pszFinalPath, &pszTmpPath)); GCE(ceError = CTCheckFileExists(pszFinalPath, &bFileExists)); if (!bFileExists) goto cleanup; GCE(ceError = CTOpenFile(pszFinalPath, "r", &fp)); GCE(ceError = CTReadLines(fp, &lines)); GCE(ceError = CTSafeCloseFile(&fp)); GCE(ceError = GetAuthType(&lines, ¤tSystem)); if(!strcmp(currentSystem, "PAM_AUTH")) goto cleanup; GCE(ceError = SetAuthType(&lines, "PAM_AUTH")); GCE(ceError = CTOpenFile(pszTmpPath, "w", &fp_new)); GCE(ceError = CTWriteLines(fp_new, &lines)); GCE(ceError = CTSafeCloseFile(&fp_new)); GCE(ceError = CTSafeReplaceFile(pszFilePath, pszTmpPath)); cleanup: CTSafeCloseFile(&fp); CTSafeCloseFile(&fp_new); CT_SAFE_FREE_STRING(currentSystem); CT_SAFE_FREE_STRING(pszTmpPath); CT_SAFE_FREE_STRING(pszFinalPath); CTFreeLines(&lines); return ceError; }
static QueryResult QueryPamMode(const JoinProcessOptions *options, LWException **exc) { BOOLEAN bFileExists = FALSE; DistroInfo distro; QueryResult result = NotApplicable; FILE* fp = NULL; DynamicArray lines; PCSTR pszFilePath = LOGIN_CONFIG_PATH; PSTR currentSystem = NULL; memset(&lines, 0, sizeof(lines)); memset(&distro, 0, sizeof(distro)); if(!options->joiningDomain || options->enableMultipleJoins) goto cleanup; LW_CLEANUP_CTERR(exc, DJGetDistroInfo(NULL, &distro)); if(distro.os != OS_AIX || strcmp(distro.version, "5.3")) goto cleanup; LW_CLEANUP_CTERR(exc, CTCheckFileExists(pszFilePath, &bFileExists)); if (!bFileExists) goto cleanup; result = SufficientlyConfigured; LW_CLEANUP_CTERR(exc, CTOpenFile(pszFilePath, "r", &fp)); LW_CLEANUP_CTERR(exc, CTReadLines(fp, &lines)); LW_CLEANUP_CTERR(exc, CTSafeCloseFile(&fp)); LW_CLEANUP_CTERR(exc, GetAuthType(&lines, ¤tSystem)); if(strcmp(currentSystem, "PAM_AUTH")) goto cleanup; result = FullyConfigured; cleanup: CT_SAFE_FREE_STRING(currentSystem); DJFreeDistroInfo(&distro); CTSafeCloseFile(&fp); CTFreeLines(&lines); return result; }
nsresult nsHttpChannelAuthProvider::GetAuthenticator(const char *challenge, nsCString &authType, nsIHttpAuthenticator **auth) { LOG(("nsHttpChannelAuthProvider::GetAuthenticator [this=%p channel=%p]\n", this, mAuthChannel)); GetAuthType(challenge, authType); // normalize to lowercase ToLowerCase(authType); nsCAutoString contractid; contractid.Assign(NS_HTTP_AUTHENTICATOR_CONTRACTID_PREFIX); contractid.Append(authType); return CallGetService(contractid.get(), auth); }
HRESULT CIhvSecurityProfile::GetNativeData ( LPVOID* ppvData ) { HRESULT hr = S_OK; PIHV_SECURITY_PROFILE pIhvProfile = NULL; BSTR bstrParam2 = NULL; if ( !ppvData ) { hr = E_INVALIDARG; BAIL_ON_FAILURE( hr ); } pIhvProfile = (PIHV_SECURITY_PROFILE) malloc( sizeof( IHV_SECURITY_PROFILE ) ); if ( !pIhvProfile ) { hr = E_OUTOFMEMORY; BAIL_ON_FAILURE( hr ); } ZeroMemory( pIhvProfile, sizeof( IHV_SECURITY_PROFILE ) ); hr = GetFullSecurityFlag ( &(pIhvProfile->bUseFullSecurity) ); BAIL_ON_FAILURE( hr ); hr = GetAuthType ( &(pIhvProfile->AuthType) ); BAIL_ON_FAILURE( hr ); hr = GetCipherType ( &(pIhvProfile->CipherType) ); BAIL_ON_FAILURE( hr ); hr = GetParamDWORD ( &(pIhvProfile->dwParam1) ); BAIL_ON_FAILURE( hr ); hr = GetParamBSTR ( &bstrParam2 ); BAIL_ON_FAILURE( hr ); if ( NULL == bstrParam2 ) { hr = E_POINTER; BAIL_ON_FAILURE( hr ); } hr = Wstr2Wstr ( bstrParam2, &(pIhvProfile->pszParam2) ); BAIL_ON_FAILURE( hr ); // Transfering local cache to OUT parameter. (*ppvData) = pIhvProfile; pIhvProfile = NULL; error: if ( pIhvProfile ) { free( pIhvProfile->pszParam2 ); // NULL Safe. free( pIhvProfile ); } SYS_FREE_STRING( bstrParam2 ); return hr; }
// // Calls the accessors to build native data. // HRESULT CIhvSecurityProfile::GetNativeData ( LPVOID* ppvData ) { HRESULT hr = S_OK; PIHV_SECURITY_PROFILE pIhvProfile = NULL; BSTR bstrParam2 = NULL; if ( !ppvData ) { hr = E_INVALIDARG; BAIL_ON_FAILURE( hr ); } pIhvProfile = (PIHV_SECURITY_PROFILE) PrivateMemoryAlloc( sizeof( IHV_SECURITY_PROFILE ) ); if ( !pIhvProfile ) { hr = E_OUTOFMEMORY; BAIL_ON_FAILURE( hr ); } pIhvProfile->bUseIhvConnectivityOnly = ( m_pRootNode == NULL ); // Ignoring errors since structure is already // populated with defaults. hr = GetFullSecurityFlag ( &(pIhvProfile->bUseFullSecurity) ); hr = GetAuthType ( &(pIhvProfile->AuthType) ); hr = GetCipherType ( &(pIhvProfile->CipherType) ); hr = GetParam1 ( &(pIhvProfile->dwParam1) ); hr = GetParam2 ( &bstrParam2 ); BAIL_ON_FAILURE( hr ); if ( NULL == bstrParam2 ) { hr = E_POINTER; BAIL_ON_FAILURE( hr ); } hr = Wstr2Wstr ( bstrParam2, &(pIhvProfile->pszParam2) ); // Consuming earlier failures. hr = S_OK; // Transfering local cache to OUT parameter. (*ppvData) = pIhvProfile; pIhvProfile = NULL; error: if ( pIhvProfile ) { PrivateMemoryFree( pIhvProfile->pszParam2 ); // NULL Safe. PrivateMemoryFree( pIhvProfile ); } SYS_FREE_STRING( bstrParam2 ); return hr; }