From nobody Wed May 8 05:15:46 2024 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; dkim=fail; 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 1499245362050513.2090684746539; Wed, 5 Jul 2017 02:02:42 -0700 (PDT) Received: from localhost ([::1]:44912 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dSgCm-00051j-SK for importer@patchew.org; Wed, 05 Jul 2017 05:02:40 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:45012) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dSgBa-0004Rp-Ay for qemu-devel@nongnu.org; Wed, 05 Jul 2017 05:01:27 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dSgBW-0000yv-7u for qemu-devel@nongnu.org; Wed, 05 Jul 2017 05:01:26 -0400 Received: from mail-wm0-x242.google.com ([2a00:1450:400c:c09::242]:36779) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1dSgBW-0000yq-1c for qemu-devel@nongnu.org; Wed, 05 Jul 2017 05:01:22 -0400 Received: by mail-wm0-x242.google.com with SMTP id y5so30943574wmh.3 for ; Wed, 05 Jul 2017 02:01:21 -0700 (PDT) Received: from bark.daynix ([141.226.163.173]) by smtp.gmail.com with ESMTPSA id a126sm8724371wmh.14.2017.07.05.02.01.19 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 05 Jul 2017 02:01:20 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=daynix-com.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:in-reply-to:references:list-id; bh=a5ymLakjguAQ6c1caZPdacJ4MlVzVjKD19Pqp6j8n4Q=; b=sxT1q/SL21QPw2XgsrVrFf04NUY6RtF8qpLxc1acULJJqIN240mQAUNudP1x1l9clm WrBQ/SEUpYE8mZwbjtCEw0IRYIPC2QAGbwdZnv4lLwG9bHm7cMesvJ4+zjuMGH9IyNy4 hvmHB6FQ2poO1fJUKakHTtBVpUXhL5ZuZjORW2rf4saPbvVas7wFvJqO8Pkv9mI4xiVh V2YD0cvv6Asvbk/JS96fdmLOBRrONpALWUGxSyUbe8uMTM8RjaqOyApSUqQsKD6LjTwR PZuRZsVnPRyUHQ4M/l1afRpmq8fOrM0oD4rzTgfBCCiMiL529/RWBdjI2o6Chs5VGha9 bIOg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:list-id; bh=a5ymLakjguAQ6c1caZPdacJ4MlVzVjKD19Pqp6j8n4Q=; b=sLmuM3lTs7OdLjzias0Cn+/6JOes0nz7m2PmT8eq+hLcbbv6f3/0AIz2HJM+2CYm34 l8Sn//+EjREE4c+2KITiUS7Jpgh3tMvyL77FkFMbaH97HgFalaWgPfAjNa/wuLkQHPOM KvxY1bfNQgWiz611WM1OWKDlamuKSk1KMBgI/dwieiR9exnH3zQWzlZFbeO3jWLSPIyb kZk2tzSapopem7S21qRk7NQ+mP5aBIR/ix5jb74GmAorCkpm32csWqwY+m3oFi0MI5Sj NUTG2TwVeTZXiPERYSXE/L+oZwAANDaVIGoUqeIgUWHUFdV+5Mw3ggfAzZAU5neWnOcc Oh/w== X-Gm-Message-State: AKS2vOz1bIVUW03830TbqnK7QolEUZDOvJqVSWjpBph8MffXzl3JYdSi czYUxovicYQteOjn/0M= X-Received: by 10.28.45.133 with SMTP id t127mr22248148wmt.107.1499245280554; Wed, 05 Jul 2017 02:01:20 -0700 (PDT) From: Sameeh Jubran To: qemu-devel@nongnu.org, Michael Roth Date: Wed, 5 Jul 2017 12:01:13 +0300 Message-Id: <20170705090113.7036-2-sameeh@daynix.com> X-Mailer: git-send-email 2.9.4 In-Reply-To: <20170705090113.7036-1-sameeh@daynix.com> References: <20170705090113.7036-1-sameeh@daynix.com> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2a00:1450:400c:c09::242 Subject: [Qemu-devel] [Qemu-GA-Win PATCH v3] 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: Yan Vugenfirer Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZohoMail: RDKM_2 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 --- 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.9.4