diff options
Diffstat (limited to '')
-rw-r--r-- | src/wix/wixnative/resetacls.cpp | 56 |
1 files changed, 0 insertions, 56 deletions
diff --git a/src/wix/wixnative/resetacls.cpp b/src/wix/wixnative/resetacls.cpp deleted file mode 100644 index 91bc633d..00000000 --- a/src/wix/wixnative/resetacls.cpp +++ /dev/null | |||
@@ -1,56 +0,0 @@ | |||
1 | // Copyright (c) .NET Foundation and contributors. All rights reserved. Licensed under the Microsoft Reciprocal License. See LICENSE.TXT file in the project root for full license information. | ||
2 | |||
3 | #include "precomp.h" | ||
4 | |||
5 | HRESULT ResetAclsCommand( | ||
6 | __in int argc, | ||
7 | __in_ecount(argc) LPWSTR argv[]) | ||
8 | { | ||
9 | Unused(argc); | ||
10 | Unused(argv); | ||
11 | |||
12 | HRESULT hr = S_OK; | ||
13 | ACL* pacl = NULL; | ||
14 | DWORD cbAcl = sizeof(ACL); | ||
15 | LPWSTR sczFilePath = NULL; | ||
16 | |||
17 | // create an empty (not NULL!) ACL to use on all the files | ||
18 | pacl = static_cast<ACL*>(MemAlloc(cbAcl, FALSE)); | ||
19 | ConsoleExitOnNull(pacl, hr, E_OUTOFMEMORY, CONSOLE_COLOR_RED, "failed to allocate ACL"); | ||
20 | |||
21 | #pragma prefast(push) | ||
22 | #pragma prefast(disable:25029) | ||
23 | if (!::InitializeAcl(pacl, cbAcl, ACL_REVISION)) | ||
24 | #pragma prefast(op) | ||
25 | { | ||
26 | ConsoleExitOnLastError(hr, CONSOLE_COLOR_RED, "failed to initialize ACL"); | ||
27 | } | ||
28 | |||
29 | hr = WixNativeReadStdinPreamble(); | ||
30 | ExitOnFailure(hr, "failed to read stdin preamble before resetting ACLs"); | ||
31 | |||
32 | // Reset the existing security permissions on each provided file. | ||
33 | for (;;) | ||
34 | { | ||
35 | hr = ConsoleReadW(&sczFilePath); | ||
36 | ConsoleExitOnFailure(hr, CONSOLE_COLOR_RED, "failed to read file path from stdin"); | ||
37 | |||
38 | if (!*sczFilePath) | ||
39 | { | ||
40 | break; | ||
41 | } | ||
42 | |||
43 | hr = ::SetNamedSecurityInfoW(sczFilePath, SE_FILE_OBJECT, DACL_SECURITY_INFORMATION | UNPROTECTED_DACL_SECURITY_INFORMATION, NULL, NULL, pacl, NULL); | ||
44 | if (ERROR_FILE_NOT_FOUND != hr && ERROR_PATH_NOT_FOUND != hr) | ||
45 | { | ||
46 | ConsoleExitOnFailure(hr = HRESULT_FROM_WIN32(hr), CONSOLE_COLOR_RED, "failed to set security descriptor for file: %ls", sczFilePath); | ||
47 | } | ||
48 | } | ||
49 | |||
50 | AssertSz(::IsValidAcl(pacl), "ResetAcls() - created invalid ACL"); | ||
51 | |||
52 | LExit: | ||
53 | ReleaseStr(sczFilePath); | ||
54 | ReleaseMem(pacl); | ||
55 | return hr; | ||
56 | } | ||