From nobody Mon Feb 9 03:13:35 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1500376307294186.9979602799791; Tue, 18 Jul 2017 04:11:47 -0700 (PDT) Received: from localhost ([::1]:55498 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dXQPp-0006XP-Tb for importer@patchew.org; Tue, 18 Jul 2017 07:11:45 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:52093) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dXQGX-0005pr-Jg for qemu-devel@nongnu.org; Tue, 18 Jul 2017 07:02:10 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dXQGU-00033S-GD for qemu-devel@nongnu.org; Tue, 18 Jul 2017 07:02:09 -0400 Received: from mx0b-001b2d01.pphosted.com ([148.163.158.5]:39485 helo=mx0a-001b2d01.pphosted.com) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1dXQGU-00033J-9p for qemu-devel@nongnu.org; Tue, 18 Jul 2017 07:02:06 -0400 Received: from pps.filterd (m0098414.ppops.net [127.0.0.1]) by mx0b-001b2d01.pphosted.com (8.16.0.21/8.16.0.21) with SMTP id v6IAwsJk047903 for ; Tue, 18 Jul 2017 07:02:05 -0400 Received: from e35.co.us.ibm.com (e35.co.us.ibm.com [32.97.110.153]) by mx0b-001b2d01.pphosted.com with ESMTP id 2bs6nd8q57-1 (version=TLSv1.2 cipher=AES256-SHA bits=256 verify=NOT) for ; Tue, 18 Jul 2017 07:02:05 -0400 Received: from localhost by e35.co.us.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Tue, 18 Jul 2017 05:02:04 -0600 Received: from b03cxnp07028.gho.boulder.ibm.com (9.17.130.15) by e35.co.us.ibm.com (192.168.1.135) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; Tue, 18 Jul 2017 05:02:02 -0600 Received: from b03ledav001.gho.boulder.ibm.com (b03ledav001.gho.boulder.ibm.com [9.17.130.232]) by b03cxnp07028.gho.boulder.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id v6IB1xsY58720436; Tue, 18 Jul 2017 04:02:01 -0700 Received: from b03ledav001.gho.boulder.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id B82186E03F; Tue, 18 Jul 2017 05:02:01 -0600 (MDT) Received: from localhost (unknown [9.80.83.16]) by b03ledav001.gho.boulder.ibm.com (Postfix) with ESMTP id 7BE436E050; Tue, 18 Jul 2017 05:02:01 -0600 (MDT) From: Michael Roth To: qemu-devel@nongnu.org Date: Tue, 18 Jul 2017 06:01:37 -0500 X-Mailer: git-send-email 2.7.4 In-Reply-To: <1500375704-28002-1-git-send-email-mdroth@linux.vnet.ibm.com> References: <1500375704-28002-1-git-send-email-mdroth@linux.vnet.ibm.com> X-TM-AS-GCONF: 00 x-cbid: 17071811-0012-0000-0000-000014B0FD6F X-IBM-SpamModules-Scores: X-IBM-SpamModules-Versions: BY=3.00007381; HX=3.00000241; KW=3.00000007; PH=3.00000004; SC=3.00000214; SDB=6.00889293; UDB=6.00444191; IPR=6.00669465; BA=6.00005478; NDR=6.00000001; ZLA=6.00000005; ZF=6.00000009; ZB=6.00000000; ZP=6.00000000; ZH=6.00000000; ZU=6.00000002; MB=3.00016258; XFM=3.00000015; UTC=2017-07-18 11:02:04 X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 17071811-0013-0000-0000-00004EA7EB9B Message-Id: <1500375704-28002-2-git-send-email-mdroth@linux.vnet.ibm.com> X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10432:, , definitions=2017-07-18_04:, , signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 spamscore=0 suspectscore=1 malwarescore=0 phishscore=0 adultscore=0 bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1706020000 definitions=main-1707180174 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x [generic] [fuzzy] X-Received-From: 148.163.158.5 Subject: [Qemu-devel] [PULL v2 1/8] qga-win: fix installation on localized windows X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Daniel Rempel , peter.maydell@linaro.org, Sameeh Jubran Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" From: Daniel Rempel Bug: https://bugzilla.redhat.com/show_bug.cgi?id=3D1357789 Replace hardcoded user and group names ("Administrators", "SYSTEM") with th= e ones acquired from system. Windows uses localized strings for these names= and it may cause the installation to fail. Windows has Well-known SIDs for "Administrators" group and "SYSTEM" user so= they were used to identify required users and groups. Well-known SIDs: https://support.microsoft.com/en-us/help/243330/well-known= -security-identifiers-in-windows-operating-systems Signed-off-by: Daniel Rempel Signed-off-by: Sameeh Jubran Reviewed-by: Sameeh Jubran Signed-off-by: Michael Roth --- qga/vss-win32/install.cpp | 35 +++++++++++++++++++++++++++++++++-- 1 file changed, 33 insertions(+), 2 deletions(-) diff --git a/qga/vss-win32/install.cpp b/qga/vss-win32/install.cpp index f41fcdf..ba7c94e 100644 --- a/qga/vss-win32/install.cpp +++ b/qga/vss-win32/install.cpp @@ -18,6 +18,9 @@ #include #include #include +#include + +#define BUFFER_SIZE 1024 =20 extern HINSTANCE g_hinstDll; =20 @@ -135,6 +138,27 @@ out: return hr; } =20 +/* Acquire group or user name by SID */ +static HRESULT getNameByStringSID( + const wchar_t *sid, LPWSTR buffer, LPDWORD bufferLen) +{ + HRESULT hr =3D S_OK; + PSID psid =3D NULL; + SID_NAME_USE groupType; + DWORD domainNameLen =3D BUFFER_SIZE; + wchar_t domainName[BUFFER_SIZE]; + + chk(ConvertStringSidToSidW(sid, &psid)); + LookupAccountSidW(NULL, psid, buffer, bufferLen, + domainName, &domainNameLen, &groupType); + hr =3D HRESULT_FROM_WIN32(GetLastError()); + + LocalFree(psid); + +out: + return hr; +} + /* Find and iterate QGA VSS provider in COM+ Application Catalog */ static HRESULT QGAProviderFind( HRESULT (*found)(ICatalogCollection *, int, void *), void *arg) @@ -216,6 +240,10 @@ STDAPI COMRegister(void) CHAR dllPath[MAX_PATH], tlbPath[MAX_PATH]; bool unregisterOnFailure =3D false; int count =3D 0; + DWORD bufferLen =3D BUFFER_SIZE; + wchar_t buffer[BUFFER_SIZE]; + const wchar_t *administratorsGroupSID =3D L"S-1-5-32-544"; + const wchar_t *systemUserSID =3D L"S-1-5-18"; =20 if (!g_hinstDll) { errmsg(E_FAIL, "Failed to initialize DLL"); @@ -284,11 +312,12 @@ STDAPI COMRegister(void) =20 /* Setup roles of the applicaion */ =20 + chk(getNameByStringSID(administratorsGroupSID, buffer, &bufferLen)); chk(pApps->GetCollection(_bstr_t(L"Roles"), key, (IDispatch **)pRoles.replace())); chk(pRoles->Populate()); chk(pRoles->Add((IDispatch **)pObj.replace())); - chk(put_Value(pObj, L"Name", L"Administrators")); + chk(put_Value(pObj, L"Name", buffer)); chk(put_Value(pObj, L"Description", L"Administrators group")); chk(pRoles->SaveChanges(&n)); chk(pObj->get_Key(&key)); @@ -303,8 +332,10 @@ STDAPI COMRegister(void) chk(GetAdminName(&name)); chk(put_Value(pObj, L"User", _bstr_t(".\\") + name)); =20 + bufferLen =3D BUFFER_SIZE; + chk(getNameByStringSID(systemUserSID, buffer, &bufferLen)); chk(pUsersInRole->Add((IDispatch **)pObj.replace())); - chk(put_Value(pObj, L"User", L"SYSTEM")); + chk(put_Value(pObj, L"User", buffer)); chk(pUsersInRole->SaveChanges(&n)); =20 out: --=20 2.7.4