All of lore.kernel.org
 help / color / mirror / Atom feed
* [Qemu-devel] [PATCH] qga-win: fall back to hardcoded user and group names if LookupAccountSidW failed
@ 2017-09-29  9:11 Chen Hanxiao
  2017-09-29 21:31 ` Tomáš Golembiovský
  0 siblings, 1 reply; 10+ messages in thread
From: Chen Hanxiao @ 2017-09-29  9:11 UTC (permalink / raw)
  To: mdroth; +Cc: qemu-devel, Chen Hanxiao

From: Chen Hanxiao <chenhanxiao@gmail.com>

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 <chenhanxiao@gmail.com>
---
 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

^ permalink raw reply related	[flat|nested] 10+ messages in thread

end of thread, other threads:[~2017-11-03 11:17 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-09-29  9:11 [Qemu-devel] [PATCH] qga-win: fall back to hardcoded user and group names if LookupAccountSidW failed Chen Hanxiao
2017-09-29 21:31 ` Tomáš Golembiovský
2017-10-25 21:58   ` Michael Roth
2017-10-26  9:27     ` Chen Hanxiao
2017-10-26  9:59       ` Michael Roth
2017-10-26 11:01         ` Chen Hanxiao
2017-10-26 13:54     ` Tomáš Golembiovský
2017-10-27  1:05       ` Michael Roth
2017-11-02 10:58         ` Chen Hanxiao
2017-11-03 11:16           ` Tomáš Golembiovský

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.