Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 182f86a

Browse filesBrowse files
committed
win,msi: use localized "Authenticated Users" name
Well known user account names are localized on Windows. Look up the "Authenticated Users" user by its security identifier to get the localized name. PR-URL: #39241 Fixes: #39224 Refs: e817ba7 Refs: https://hackerone.com/reports/1211160 Reviewed-By: Michaël Zasso <targos@protonmail.com> Reviewed-By: Beth Griggs <bgriggs@redhat.com>
1 parent d692770 commit 182f86a
Copy full SHA for 182f86a

File tree

Expand file treeCollapse file tree

3 files changed

+39
-2
lines changed
Open diff view settings
Filter options
Expand file treeCollapse file tree

3 files changed

+39
-2
lines changed
Open diff view settings
Collapse file

‎tools/msvs/msi/custom_actions.cc‎

Copy file name to clipboardExpand all lines: tools/msvs/msi/custom_actions.cc
+31Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@
33
#include <windows.h>
44
#include <msiquery.h>
55
#include <wcautil.h>
6+
#include <sddl.h>
7+
#include <Lmcons.h>
68

79
#define GUID_BUFFER_SIZE 39 // {8-4-4-4-12}\0
810

@@ -96,6 +98,35 @@ extern "C" UINT WINAPI BroadcastEnvironmentUpdate(MSIHANDLE hInstall) {
9698
return WcaFinalize(er);
9799
}
98100

101+
#define AUTHENTICATED_USERS_SID L"S-1-5-11"
102+
103+
extern "C" UINT WINAPI GetLocalizedUserNames(MSIHANDLE hInstall) {
104+
HRESULT hr = S_OK;
105+
UINT er = ERROR_SUCCESS;
106+
TCHAR userName[UNLEN + 1] = {0};
107+
DWORD userNameSize = UNLEN + 1;
108+
TCHAR domain[DNLEN + 1] = {0};
109+
DWORD domainSize = DNLEN + 1;
110+
PSID sid;
111+
SID_NAME_USE nameUse;
112+
113+
hr = WcaInitialize(hInstall, "GetLocalizedUserNames");
114+
ExitOnFailure(hr, "Failed to initialize");
115+
116+
er = ConvertStringSidToSidW(AUTHENTICATED_USERS_SID, &sid);
117+
ExitOnLastError(er, "Failed to convert security identifier");
118+
119+
er = LookupAccountSidW(NULL, sid, userName, &userNameSize, domain, &domainSize, &nameUse);
120+
ExitOnLastError(er, "Failed to lookup security identifier");
121+
122+
MsiSetProperty(hInstall, L"AUTHENTICATED_USERS", userName);
123+
ExitOnWin32Error(er, hr, "Failed to set localized Authenticated User name");
124+
125+
LExit:
126+
er = SUCCEEDED(hr) ? ERROR_SUCCESS : ERROR_INSTALL_FAILURE;
127+
LocalFree(sid);
128+
return WcaFinalize(er);
129+
}
99130

100131
extern "C" BOOL WINAPI DllMain(HINSTANCE hInst, ULONG ulReason, VOID* dummy) {
101132
switch (ulReason) {
Collapse file

‎tools/msvs/msi/custom_actions.def‎

Copy file name to clipboardExpand all lines: tools/msvs/msi/custom_actions.def
+1Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,3 +3,4 @@ LIBRARY "custom_actions"
33
EXPORTS
44
SetInstallScope
55
BroadcastEnvironmentUpdate
6+
GetLocalizedUserNames
Collapse file

‎tools/msvs/msi/product.wxs‎

Copy file name to clipboardExpand all lines: tools/msvs/msi/product.wxs
+7-2Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,8 +47,6 @@
4747
<Property Id="WIXUI_INSTALLDIR" Value="INSTALLDIR"/>
4848

4949
<!-- PropertyRef of the account users for setting InstallDir permission explicitly -->
50-
<Property Id="AUTHENTICATED_USERS" Value="Authenticated Users"/>
51-
5250
<PropertyRef Id="WIX_ACCOUNT_LOCALSYSTEM" />
5351
<PropertyRef Id="WIX_ACCOUNT_USERS" />
5452
<PropertyRef Id="WIX_ACCOUNT_ADMINISTRATORS" />
@@ -329,6 +327,12 @@
329327
Execute="immediate"
330328
Return="check" />
331329

330+
<CustomAction Id="GetLocalizedUserNames"
331+
BinaryKey="CustomActionsDLL"
332+
DllEntry="GetLocalizedUserNames"
333+
Execute="immediate"
334+
Return="check" />
335+
332336
<Property Id="WixShellExecTarget" Value="[#InstallToolsBat]" />
333337
<CustomAction Id="LaunchApplication" BinaryKey="WixCA" DllEntry="WixShellExec" />
334338

@@ -338,6 +342,7 @@
338342

339343
<InstallExecuteSequence>
340344
<Custom Action='SetInstallScope' Before='FindRelatedProducts'/>
345+
<Custom Action='GetLocalizedUserNames' After='SetInstallScope'/>
341346
<Custom Action='BroadcastEnvironmentUpdate' After='InstallFinalize'/>
342347
</InstallExecuteSequence>
343348

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.