diff options
author | Sean Hall <r.sean.hall@gmail.com> | 2020-05-23 15:55:58 +1000 |
---|---|---|
committer | Sean Hall <r.sean.hall@gmail.com> | 2020-05-23 16:00:11 +1000 |
commit | 6fbe9b0b7e98e63daa89c1347e5388dec9fdc57f (patch) | |
tree | 98c04dcb4cfdd19aca0d292b97810cac00aa6adb /src | |
parent | 242d5201cb75c686f4cb86e521ed0d8c025c563b (diff) | |
download | wix-6fbe9b0b7e98e63daa89c1347e5388dec9fdc57f.tar.gz wix-6fbe9b0b7e98e63daa89c1347e5388dec9fdc57f.tar.bz2 wix-6fbe9b0b7e98e63daa89c1347e5388dec9fdc57f.zip |
WIXFEAT:2006,2580,2751 Add Inheritable attribute to PermissionEx.
Diffstat (limited to 'src')
-rw-r--r-- | src/ca/secureobj.cpp | 25 | ||||
-rw-r--r-- | src/test/WixToolsetTest.Util/UtilExtensionFixture.cs | 2 | ||||
-rw-r--r-- | src/wixext/Tuples/SecureObjectsTuple.cs | 8 | ||||
-rw-r--r-- | src/wixext/UtilCompiler.cs | 13 | ||||
-rw-r--r-- | src/wixext/UtilTableDefinitions.cs | 1 | ||||
-rw-r--r-- | src/wixext/util.xsd | 5 |
6 files changed, 47 insertions, 7 deletions
diff --git a/src/ca/secureobj.cpp b/src/ca/secureobj.cpp index 392945d9..72842eb5 100644 --- a/src/ca/secureobj.cpp +++ b/src/ca/secureobj.cpp | |||
@@ -3,10 +3,10 @@ | |||
3 | #include "precomp.h" | 3 | #include "precomp.h" |
4 | 4 | ||
5 | // structs | 5 | // structs |
6 | LPCWSTR wzQUERY_SECUREOBJECTS = L"SELECT `Wix4SecureObject`.`Wix4SecureObject`, `Wix4SecureObject`.`Table`, `Wix4SecureObject`.`Domain`, `Wix4SecureObject`.`User`, " | 6 | LPCWSTR wzQUERY_SECUREOBJECTS = L"SELECT `Wix4SecureObject`.`Wix4SecureObject`, `Wix4SecureObject`.`Table`, `Wix4SecureObject`.`Domain`, `Wix4SecureObject`.`User`, `Wix4SecureObject`.`Attributes`, " |
7 | L"`Wix4SecureObject`.`Permission`, `Wix4SecureObject`.`Component_`, `Component`.`Attributes` FROM `Wix4SecureObject`,`Component` WHERE " | 7 | L"`Wix4SecureObject`.`Permission`, `Wix4SecureObject`.`Component_`, `Component`.`Attributes` FROM `Wix4SecureObject`,`Component` WHERE " |
8 | L"`Wix4SecureObject`.`Component_`=`Component`.`Component`"; | 8 | L"`Wix4SecureObject`.`Component_`=`Component`.`Component`"; |
9 | enum eQUERY_SECUREOBJECTS { QSO_SECUREOBJECT = 1, QSO_TABLE, QSO_DOMAIN, QSO_USER, QSO_PERMISSION, QSO_COMPONENT, QSO_COMPATTRIBUTES }; | 9 | enum eQUERY_SECUREOBJECTS { QSO_SECUREOBJECT = 1, QSO_TABLE, QSO_DOMAIN, QSO_USER, QSO_ATTRIBUTES, QSO_PERMISSION, QSO_COMPONENT, QSO_COMPATTRIBUTES }; |
10 | 10 | ||
11 | LPCWSTR wzQUERY_REGISTRY = L"SELECT `Registry`.`Registry`, `Registry`.`Root`, `Registry`.`Key` FROM `Registry` WHERE `Registry`.`Registry`=?"; | 11 | LPCWSTR wzQUERY_REGISTRY = L"SELECT `Registry`.`Registry`, `Registry`.`Root`, `Registry`.`Key` FROM `Registry` WHERE `Registry`.`Registry`=?"; |
12 | enum eQUERY_OBJECTCOMPONENT { QSOC_REGISTRY = 1, QSOC_REGROOT, QSOC_REGKEY }; | 12 | enum eQUERY_OBJECTCOMPONENT { QSOC_REGISTRY = 1, QSOC_REGROOT, QSOC_REGKEY }; |
@@ -16,6 +16,11 @@ enum eQUERY_SECURESERVICEINSTALL { QSSI_NAME = 1 }; | |||
16 | 16 | ||
17 | enum eOBJECTTYPE { OT_UNKNOWN, OT_SERVICE, OT_FOLDER, OT_FILE, OT_REGISTRY }; | 17 | enum eOBJECTTYPE { OT_UNKNOWN, OT_SERVICE, OT_FOLDER, OT_FILE, OT_REGISTRY }; |
18 | 18 | ||
19 | enum eSECURE_OBJECT_ATTRIBUTE | ||
20 | { | ||
21 | SECURE_OBJECT_ATTRIBUTE_INHERITABLE = 0x1, | ||
22 | }; | ||
23 | |||
19 | static eOBJECTTYPE EObjectTypeFromString( | 24 | static eOBJECTTYPE EObjectTypeFromString( |
20 | __in LPCWSTR pwzTable | 25 | __in LPCWSTR pwzTable |
21 | ) | 26 | ) |
@@ -335,6 +340,7 @@ extern "C" UINT __stdcall SchedSecureObjects( | |||
335 | 340 | ||
336 | DWORD cObjects = 0; | 341 | DWORD cObjects = 0; |
337 | eOBJECTTYPE eType = OT_UNKNOWN; | 342 | eOBJECTTYPE eType = OT_UNKNOWN; |
343 | DWORD dwAttributes = 0; | ||
338 | 344 | ||
339 | // | 345 | // |
340 | // initialize | 346 | // initialize |
@@ -409,7 +415,6 @@ extern "C" UINT __stdcall SchedSecureObjects( | |||
409 | // add the data to the CustomActionData | 415 | // add the data to the CustomActionData |
410 | hr = WcaGetRecordString(hRec, QSO_SECUREOBJECT, &pwzData); | 416 | hr = WcaGetRecordString(hRec, QSO_SECUREOBJECT, &pwzData); |
411 | ExitOnFailure(hr, "failed to get name of object"); | 417 | ExitOnFailure(hr, "failed to get name of object"); |
412 | |||
413 | hr = WcaWriteStringToCaData(pwzTable, &pwzCustomActionData); | 418 | hr = WcaWriteStringToCaData(pwzTable, &pwzCustomActionData); |
414 | ExitOnFailure(hr, "failed to add data to CustomActionData"); | 419 | ExitOnFailure(hr, "failed to add data to CustomActionData"); |
415 | 420 | ||
@@ -423,6 +428,11 @@ extern "C" UINT __stdcall SchedSecureObjects( | |||
423 | hr = WcaWriteStringToCaData(pwzData, &pwzCustomActionData); | 428 | hr = WcaWriteStringToCaData(pwzData, &pwzCustomActionData); |
424 | ExitOnFailure(hr, "failed to add data to CustomActionData"); | 429 | ExitOnFailure(hr, "failed to add data to CustomActionData"); |
425 | 430 | ||
431 | hr = WcaGetRecordInteger(hRec, QSO_ATTRIBUTES, reinterpret_cast<int*>(&dwAttributes)); | ||
432 | ExitOnFailure(hr, "failed to get attributes to configure object"); | ||
433 | hr = WcaWriteIntegerToCaData(dwAttributes, &pwzCustomActionData); | ||
434 | ExitOnFailure(hr, "failed to add data to CustomActionData"); | ||
435 | |||
426 | hr = WcaGetRecordString(hRec, QSO_PERMISSION, &pwzData); | 436 | hr = WcaGetRecordString(hRec, QSO_PERMISSION, &pwzData); |
427 | ExitOnFailure(hr, "failed to get permission to configure object"); | 437 | ExitOnFailure(hr, "failed to get permission to configure object"); |
428 | hr = WcaWriteStringToCaData(pwzData, &pwzCustomActionData); | 438 | hr = WcaWriteStringToCaData(pwzData, &pwzCustomActionData); |
@@ -568,7 +578,7 @@ LExit: | |||
568 | called as Type 1025 CustomAction (deferred binary DLL) | 578 | called as Type 1025 CustomAction (deferred binary DLL) |
569 | 579 | ||
570 | NOTE: deferred CustomAction since it modifies the machine | 580 | NOTE: deferred CustomAction since it modifies the machine |
571 | NOTE: CustomActionData == wzObject\twzTable\twzDomain\twzUser\tdwPermissions\twzObject\t... | 581 | NOTE: CustomActionData == wzObject\twzTable\twzDomain\twzUser\tdwAttributes\tdwPermissions\t... |
572 | ******************************************************************/ | 582 | ******************************************************************/ |
573 | extern "C" UINT __stdcall ExecSecureObjects( | 583 | extern "C" UINT __stdcall ExecSecureObjects( |
574 | __in MSIHANDLE hInstall | 584 | __in MSIHANDLE hInstall |
@@ -586,6 +596,7 @@ extern "C" UINT __stdcall ExecSecureObjects( | |||
586 | DWORD dwRevision = 0; | 596 | DWORD dwRevision = 0; |
587 | LPWSTR pwzUser = NULL; | 597 | LPWSTR pwzUser = NULL; |
588 | DWORD dwPermissions = 0; | 598 | DWORD dwPermissions = 0; |
599 | DWORD dwAttributes = 0; | ||
589 | LPWSTR pwzAccount = NULL; | 600 | LPWSTR pwzAccount = NULL; |
590 | PSID psid = NULL; | 601 | PSID psid = NULL; |
591 | 602 | ||
@@ -626,8 +637,10 @@ extern "C" UINT __stdcall ExecSecureObjects( | |||
626 | ExitOnFailure(hr, "failed to process CustomActionData"); | 637 | ExitOnFailure(hr, "failed to process CustomActionData"); |
627 | hr = WcaReadStringFromCaData(&pwz, &pwzUser); | 638 | hr = WcaReadStringFromCaData(&pwz, &pwzUser); |
628 | ExitOnFailure(hr, "failed to process CustomActionData"); | 639 | ExitOnFailure(hr, "failed to process CustomActionData"); |
640 | hr = WcaReadIntegerFromCaData(&pwz, reinterpret_cast<int*>(&dwAttributes)); | ||
641 | ExitOnFailure(hr, "failed to process CustomActionData"); | ||
629 | hr = WcaReadIntegerFromCaData(&pwz, reinterpret_cast<int*>(&dwPermissions)); | 642 | hr = WcaReadIntegerFromCaData(&pwz, reinterpret_cast<int*>(&dwPermissions)); |
630 | ExitOnFailure(hr, "failed to processCustomActionData"); | 643 | ExitOnFailure(hr, "failed to process CustomActionData"); |
631 | 644 | ||
632 | WcaLog(LOGMSG_VERBOSE, "Securing Object: %ls Type: %ls User: %ls", pwzObject, pwzTable, pwzUser); | 645 | WcaLog(LOGMSG_VERBOSE, "Securing Object: %ls Type: %ls User: %ls", pwzObject, pwzTable, pwzUser); |
633 | 646 | ||
@@ -690,7 +703,7 @@ extern "C" UINT __stdcall ExecSecureObjects( | |||
690 | // | 703 | // |
691 | ea.grfAccessMode = SET_ACCESS; | 704 | ea.grfAccessMode = SET_ACCESS; |
692 | 705 | ||
693 | if (0 == lstrcmpW(L"CreateFolder", pwzTable)) | 706 | if (dwAttributes & SECURE_OBJECT_ATTRIBUTE_INHERITABLE) |
694 | { | 707 | { |
695 | ea.grfInheritance = SUB_CONTAINERS_AND_OBJECTS_INHERIT; | 708 | ea.grfInheritance = SUB_CONTAINERS_AND_OBJECTS_INHERIT; |
696 | } | 709 | } |
diff --git a/src/test/WixToolsetTest.Util/UtilExtensionFixture.cs b/src/test/WixToolsetTest.Util/UtilExtensionFixture.cs index c8ad24ad..fabef160 100644 --- a/src/test/WixToolsetTest.Util/UtilExtensionFixture.cs +++ b/src/test/WixToolsetTest.Util/UtilExtensionFixture.cs | |||
@@ -105,7 +105,7 @@ namespace WixToolsetTest.Util | |||
105 | "CustomAction:Wix4ExecSecureObjectsRollback_X64\t11521\tWix4UtilCA_X64\tExecSecureObjectsRollback\t", | 105 | "CustomAction:Wix4ExecSecureObjectsRollback_X64\t11521\tWix4UtilCA_X64\tExecSecureObjectsRollback\t", |
106 | "CustomAction:Wix4SchedSecureObjects_X64\t1\tWix4UtilCA_X64\tSchedSecureObjects\t", | 106 | "CustomAction:Wix4SchedSecureObjects_X64\t1\tWix4UtilCA_X64\tSchedSecureObjects\t", |
107 | "CustomAction:Wix4SchedSecureObjectsRollback_X64\t1\tWix4UtilCA_X64\tSchedSecureObjectsRollback\t", | 107 | "CustomAction:Wix4SchedSecureObjectsRollback_X64\t1\tWix4UtilCA_X64\tSchedSecureObjectsRollback\t", |
108 | "Wix4SecureObject:INSTALLFOLDER\tCreateFolder\t\tEveryone\t268435456\tfilF5_pLhBuF5b4N9XEo52g_hUM5Lo", | 108 | "Wix4SecureObject:INSTALLFOLDER\tCreateFolder\t\tEveryone\t1\t268435456\tfilF5_pLhBuF5b4N9XEo52g_hUM5Lo", |
109 | }, results.OrderBy(s => s).ToArray()); | 109 | }, results.OrderBy(s => s).ToArray()); |
110 | } | 110 | } |
111 | 111 | ||
diff --git a/src/wixext/Tuples/SecureObjectsTuple.cs b/src/wixext/Tuples/SecureObjectsTuple.cs index 3602a5ea..95c24979 100644 --- a/src/wixext/Tuples/SecureObjectsTuple.cs +++ b/src/wixext/Tuples/SecureObjectsTuple.cs | |||
@@ -15,6 +15,7 @@ namespace WixToolset.Util | |||
15 | new IntermediateFieldDefinition(nameof(SecureObjectsTupleFields.Table), IntermediateFieldType.String), | 15 | new IntermediateFieldDefinition(nameof(SecureObjectsTupleFields.Table), IntermediateFieldType.String), |
16 | new IntermediateFieldDefinition(nameof(SecureObjectsTupleFields.Domain), IntermediateFieldType.String), | 16 | new IntermediateFieldDefinition(nameof(SecureObjectsTupleFields.Domain), IntermediateFieldType.String), |
17 | new IntermediateFieldDefinition(nameof(SecureObjectsTupleFields.User), IntermediateFieldType.String), | 17 | new IntermediateFieldDefinition(nameof(SecureObjectsTupleFields.User), IntermediateFieldType.String), |
18 | new IntermediateFieldDefinition(nameof(SecureObjectsTupleFields.Attributes), IntermediateFieldType.Number), | ||
18 | new IntermediateFieldDefinition(nameof(SecureObjectsTupleFields.Permission), IntermediateFieldType.Number), | 19 | new IntermediateFieldDefinition(nameof(SecureObjectsTupleFields.Permission), IntermediateFieldType.Number), |
19 | new IntermediateFieldDefinition(nameof(SecureObjectsTupleFields.ComponentRef), IntermediateFieldType.String), | 20 | new IntermediateFieldDefinition(nameof(SecureObjectsTupleFields.ComponentRef), IntermediateFieldType.String), |
20 | }, | 21 | }, |
@@ -32,6 +33,7 @@ namespace WixToolset.Util.Tuples | |||
32 | Table, | 33 | Table, |
33 | Domain, | 34 | Domain, |
34 | User, | 35 | User, |
36 | Attributes, | ||
35 | Permission, | 37 | Permission, |
36 | ComponentRef, | 38 | ComponentRef, |
37 | } | 39 | } |
@@ -72,6 +74,12 @@ namespace WixToolset.Util.Tuples | |||
72 | set => this.Set((int)SecureObjectsTupleFields.User, value); | 74 | set => this.Set((int)SecureObjectsTupleFields.User, value); |
73 | } | 75 | } |
74 | 76 | ||
77 | public int Attributes | ||
78 | { | ||
79 | get => this.Fields[(int)SecureObjectsTupleFields.Attributes].AsNumber(); | ||
80 | set => this.Set((int)SecureObjectsTupleFields.Attributes, value); | ||
81 | } | ||
82 | |||
75 | public int? Permission | 83 | public int? Permission |
76 | { | 84 | { |
77 | get => this.Fields[(int)SecureObjectsTupleFields.Permission].AsNullableNumber(); | 85 | get => this.Fields[(int)SecureObjectsTupleFields.Permission].AsNullableNumber(); |
diff --git a/src/wixext/UtilCompiler.cs b/src/wixext/UtilCompiler.cs index 65ca406d..672c3f68 100644 --- a/src/wixext/UtilCompiler.cs +++ b/src/wixext/UtilCompiler.cs | |||
@@ -49,6 +49,11 @@ namespace WixToolset.Util | |||
49 | TypeMask = 0xf, | 49 | TypeMask = 0xf, |
50 | } | 50 | } |
51 | 51 | ||
52 | internal enum WixPermissionExAttributes | ||
53 | { | ||
54 | Inheritable = 0x01 | ||
55 | } | ||
56 | |||
52 | internal enum WixRemoveFolderExOn | 57 | internal enum WixRemoveFolderExOn |
53 | { | 58 | { |
54 | Install = 1, | 59 | Install = 1, |
@@ -2367,6 +2372,8 @@ namespace WixToolset.Util | |||
2367 | string domain = null; | 2372 | string domain = null; |
2368 | string[] specialPermissions = null; | 2373 | string[] specialPermissions = null; |
2369 | string user = null; | 2374 | string user = null; |
2375 | var inheritable = YesNoType.NotSet; | ||
2376 | int attributes = 0; | ||
2370 | 2377 | ||
2371 | var permissionType = PermissionType.SecureObjects; | 2378 | var permissionType = PermissionType.SecureObjects; |
2372 | 2379 | ||
@@ -2407,6 +2414,9 @@ namespace WixToolset.Util | |||
2407 | } | 2414 | } |
2408 | domain = this.ParseHelper.GetAttributeValue(sourceLineNumbers, attrib); | 2415 | domain = this.ParseHelper.GetAttributeValue(sourceLineNumbers, attrib); |
2409 | break; | 2416 | break; |
2417 | case "Inheritable": | ||
2418 | inheritable = this.ParseHelper.GetAttributeYesNoValue(sourceLineNumbers, attrib); | ||
2419 | break; | ||
2410 | case "User": | 2420 | case "User": |
2411 | user = this.ParseHelper.GetAttributeValue(sourceLineNumbers, attrib); | 2421 | user = this.ParseHelper.GetAttributeValue(sourceLineNumbers, attrib); |
2412 | break; | 2422 | break; |
@@ -2444,6 +2454,8 @@ namespace WixToolset.Util | |||
2444 | this.Messaging.Write(ErrorMessages.GenericReadNotAllowed(sourceLineNumbers)); | 2454 | this.Messaging.Write(ErrorMessages.GenericReadNotAllowed(sourceLineNumbers)); |
2445 | } | 2455 | } |
2446 | 2456 | ||
2457 | attributes |= inheritable == YesNoType.No ? 0 : (int)WixPermissionExAttributes.Inheritable; // default to inheritable. | ||
2458 | |||
2447 | this.ParseHelper.ParseForExtensionElements(this.Context.Extensions, intermediate, section, element); | 2459 | this.ParseHelper.ParseForExtensionElements(this.Context.Extensions, intermediate, section, element); |
2448 | 2460 | ||
2449 | if (!this.Messaging.EncounteredError) | 2461 | if (!this.Messaging.EncounteredError) |
@@ -2457,6 +2469,7 @@ namespace WixToolset.Util | |||
2457 | Table = tableName, | 2469 | Table = tableName, |
2458 | Domain = domain, | 2470 | Domain = domain, |
2459 | User = user, | 2471 | User = user, |
2472 | Attributes = attributes, | ||
2460 | Permission = permission, | 2473 | Permission = permission, |
2461 | ComponentRef = componentId, | 2474 | ComponentRef = componentId, |
2462 | }); | 2475 | }); |
diff --git a/src/wixext/UtilTableDefinitions.cs b/src/wixext/UtilTableDefinitions.cs index 5e227a05..4dfeb4bd 100644 --- a/src/wixext/UtilTableDefinitions.cs +++ b/src/wixext/UtilTableDefinitions.cs | |||
@@ -164,6 +164,7 @@ namespace WixToolset.Util | |||
164 | new ColumnDefinition("Table", ColumnType.String, 32, primaryKey: true, nullable: false, ColumnCategory.Text, description: "Table SecureObject should be securing"), | 164 | new ColumnDefinition("Table", ColumnType.String, 32, primaryKey: true, nullable: false, ColumnCategory.Text, description: "Table SecureObject should be securing"), |
165 | new ColumnDefinition("Domain", ColumnType.String, 255, primaryKey: true, nullable: true, ColumnCategory.Text, description: "Domain half of user account to secure", modularizeType: ColumnModularizeType.Property), | 165 | new ColumnDefinition("Domain", ColumnType.String, 255, primaryKey: true, nullable: true, ColumnCategory.Text, description: "Domain half of user account to secure", modularizeType: ColumnModularizeType.Property), |
166 | new ColumnDefinition("User", ColumnType.String, 255, primaryKey: true, nullable: false, ColumnCategory.Text, description: "User name half of user account to secure", modularizeType: ColumnModularizeType.Property), | 166 | new ColumnDefinition("User", ColumnType.String, 255, primaryKey: true, nullable: false, ColumnCategory.Text, description: "User name half of user account to secure", modularizeType: ColumnModularizeType.Property), |
167 | new ColumnDefinition("Attributes", ColumnType.Number, 4, primaryKey: false, nullable: false, ColumnCategory.Integer, minValue: 0, maxValue: 2147483647, description: "A 32-bit word that specifies the attribute flags to be applied."), | ||
167 | new ColumnDefinition("Permission", ColumnType.Number, 4, primaryKey: false, nullable: true, ColumnCategory.Unknown, minValue: -2147483647, maxValue: 2147483647, description: "Permissions to grant to User"), | 168 | new ColumnDefinition("Permission", ColumnType.Number, 4, primaryKey: false, nullable: true, ColumnCategory.Unknown, minValue: -2147483647, maxValue: 2147483647, description: "Permissions to grant to User"), |
168 | new ColumnDefinition("Component_", ColumnType.String, 72, primaryKey: false, nullable: false, ColumnCategory.Identifier, keyTable: "Component", keyColumn: 1, description: "Foreign key into the Component table used to determine install state", modularizeType: ColumnModularizeType.Column), | 169 | new ColumnDefinition("Component_", ColumnType.String, 72, primaryKey: false, nullable: false, ColumnCategory.Identifier, keyTable: "Component", keyColumn: 1, description: "Foreign key into the Component table used to determine install state", modularizeType: ColumnModularizeType.Column), |
169 | }, | 170 | }, |
diff --git a/src/wixext/util.xsd b/src/wixext/util.xsd index a8c3d208..93cdd4ba 100644 --- a/src/wixext/util.xsd +++ b/src/wixext/util.xsd | |||
@@ -775,6 +775,11 @@ | |||
775 | <xs:complexType> | 775 | <xs:complexType> |
776 | <xs:attribute name="Domain" type="xs:string"></xs:attribute> | 776 | <xs:attribute name="Domain" type="xs:string"></xs:attribute> |
777 | <xs:attribute name="User" use="required" type="xs:string"></xs:attribute> | 777 | <xs:attribute name="User" use="required" type="xs:string"></xs:attribute> |
778 | <xs:attribute name="Inheritable" type="xs:YesNoType"> | ||
779 | <xs:annotation> | ||
780 | <xs:documentation>Whether the permissions are inheritable. The default is "yes".</xs:documentation> | ||
781 | </xs:annotation> | ||
782 | </xs:attribute> | ||
778 | <!-- Common ACLs --> | 783 | <!-- Common ACLs --> |
779 | <xs:attribute name="Read" type="YesNoType"></xs:attribute> | 784 | <xs:attribute name="Read" type="YesNoType"></xs:attribute> |
780 | <xs:attribute name="Delete" type="YesNoType"></xs:attribute> | 785 | <xs:attribute name="Delete" type="YesNoType"></xs:attribute> |