From: Asanka Herath Date: Thu, 1 Sep 2005 02:55:01 +0000 (+0000) Subject: windows-loopback-20050831 X-Git-Tag: openafs-devel-1_5_0~344 X-Git-Url: https://git.openafs.org/?p=openafs.git;a=commitdiff_plain;h=001f9b9732a3a30ea0c51c12a0f69c400102d7a7;hp=69a98684f0a85db5618a472835a0e588b01b5d6e windows-loopback-20050831 As stated in the afs-install-notes, the MS Client for Networks should be enabled on the loopback adapter, so enable it. Prevent an install failure by not calling CoInitialize twice in the same thread. --- diff --git a/src/WINNT/install/loopback/loopbackutils.cpp b/src/WINNT/install/loopback/loopbackutils.cpp index 01248d2..0547fd4 100644 --- a/src/WINNT/install/loopback/loopbackutils.cpp +++ b/src/WINNT/install/loopback/loopbackutils.cpp @@ -544,7 +544,7 @@ extern "C" DWORD InstallLoopBack(LPCTSTR pConnectionName, LPCTSTR ip, LPCTSTR ma ret = SetIpAddress(pCfgGuidString, ip, mask); if (ret) { - ReportMessage(0,"Could not set the ip address and network mask",NULL,NULL,0); + ReportMessage(0,"Could not set the ip address and network mask",NULL,NULL,ret); goto cleanup; } ret = LoopbackBindings(pCfgGuidString); diff --git a/src/WINNT/install/loopback/wmi.cpp b/src/WINNT/install/loopback/wmi.cpp index a9fa2ea..793e5e2 100644 --- a/src/WINNT/install/loopback/wmi.cpp +++ b/src/WINNT/install/loopback/wmi.cpp @@ -237,6 +237,8 @@ WMIEnableStatic( BSTR InstancePath = 0; BSTR MethodName = 0; // needs to be BSTR for ExecMethod() + BOOL comInitialized = FALSE; + VARIANT v_ip_list; VariantInit(&v_ip_list); @@ -261,8 +263,13 @@ WMIEnableStatic( // Initialize COM and connect up to CIMOM + ReportMessage(0, "Intializing COM", NULL, NULL, 0); hr = CoInitializeEx(0, COINIT_MULTITHREADED); - CLEANUP_ON_FAILURE(hr); + if (hr == S_OK || hr == S_FALSE) { + comInitialized = TRUE; + } else { + goto cleanup; + } /* When called from an MSI this will generally fail. This should only be called once per process and not surprisingly MSI beats us to it. So ignore return value and @@ -271,12 +278,15 @@ WMIEnableStatic( RPC_C_AUTHN_LEVEL_CONNECT, RPC_C_IMP_LEVEL_IMPERSONATE, NULL, EOAC_NONE, 0); + /* CLEANUP_ON_FAILURE(hr); */ + ReportMessage(0, "Creating Wbem Locator object", NULL, NULL, 0); hr = CoCreateInstance(CLSID_WbemLocator, 0, CLSCTX_INPROC_SERVER, IID_IWbemLocator, (LPVOID *) &pLocator); CLEANUP_ON_FAILURE(hr); + ReportMessage(0, "Connecting to WMI", NULL, NULL, 0); hr = pLocator->ConnectServer(NamespacePath, NULL, NULL, NULL, 0, NULL, NULL, &pNamespace); CLEANUP_ON_FAILURE(hr); @@ -400,6 +410,7 @@ WMIEnableStatic( VariantClear(&v_ip_list); VariantClear(&v_mask_list); + // SysFreeString is NULL safe SysFreeString(NamespacePath); SysFreeString(ClassPath); SysFreeString(InstancePath); @@ -412,7 +423,9 @@ WMIEnableStatic( if (pLocator) pLocator->Release(); if (pNamespace) pNamespace->Release(); - CoUninitialize(); + if (comInitialized) + CoUninitialize(); + return hr; } @@ -507,8 +520,9 @@ extern "C" HRESULT LoopbackBindings (LPCWSTR loopback_guid) } if ( !_wcsicmp(swId, L"ms_netbios") || - !_wcsicmp(swId, L"ms_tcpip") || - !_wcsicmp(swId, L"ms_netbt") ) + !_wcsicmp(swId, L"ms_tcpip") || + !_wcsicmp(swId, L"ms_netbt") || + !_wcsicmp(swId, L"ms_msclient")) { if (pPath->IsEnabled()!=S_OK) { @@ -518,7 +532,6 @@ extern "C" HRESULT LoopbackBindings (LPCWSTR loopback_guid) bConfigChanged=TRUE; } - } else //if (!_wcsicmp(swId, L"ms_server") || (!_wcsicmp(swId, L"ms_msclient")) {