[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PATCH] qga-win: fall back to hardcoded user and group name
From: |
Chen Hanxiao |
Subject: |
[Qemu-devel] [PATCH] qga-win: fall back to hardcoded user and group names if LookupAccountSidW failed |
Date: |
Fri, 29 Sep 2017 17:11:22 +0800 |
From: Chen Hanxiao <address@hidden>
On some of windows (win08 sp2),
it doesn't work by calling LookupAccountSidW with
well-known SIDs,
We got an error:
error 997 overlapped I/O operation is in progress
But hardcoded names work.
This patch introduces a workaroud for this issue:
if LookupAccountSidW failed, try hardcoded one.
Signed-off-by: Chen Hanxiao <address@hidden>
---
qga/vss-win32/install.cpp | 10 ++++++++--
1 file changed, 8 insertions(+), 2 deletions(-)
diff --git a/qga/vss-win32/install.cpp b/qga/vss-win32/install.cpp
index ba7c94eb25..dcf6299af9 100644
--- a/qga/vss-win32/install.cpp
+++ b/qga/vss-win32/install.cpp
@@ -312,7 +312,10 @@ STDAPI COMRegister(void)
/* Setup roles of the applicaion */
- chk(getNameByStringSID(administratorsGroupSID, buffer, &bufferLen));
+ hr = getNameByStringSID(administratorsGroupSID, buffer, &bufferLen);
+ if (FAILED(hr)) {
+ wsprintfW(buffer, L"%ls", L"Administrators");
+ }
chk(pApps->GetCollection(_bstr_t(L"Roles"), key,
(IDispatch **)pRoles.replace()));
chk(pRoles->Populate());
@@ -333,7 +336,10 @@ STDAPI COMRegister(void)
chk(put_Value(pObj, L"User", _bstr_t(".\\") + name));
bufferLen = BUFFER_SIZE;
- chk(getNameByStringSID(systemUserSID, buffer, &bufferLen));
+ hr = getNameByStringSID(systemUserSID, buffer, &bufferLen);
+ if (FAILED(hr)) {
+ wsprintfW(buffer, L"%ls", L"SYSTEM");
+ }
chk(pUsersInRole->Add((IDispatch **)pObj.replace()));
chk(put_Value(pObj, L"User", buffer));
chk(pUsersInRole->SaveChanges(&n));
--
2.13.5
- [Qemu-devel] [PATCH] qga-win: fall back to hardcoded user and group names if LookupAccountSidW failed,
Chen Hanxiao <=