I am continuing to work on changes to secureobj.cpp. I found a subtle, but important bug; instead of using the Name field from the ServiceInstall table as the object target path, GetTargetPath (and the code before it) was using the ServiceInstall (Id) field. Attached is a patch to version 3.0.4624.0 that fixes GetTargetPath for services. Once I finish up changes to Cody's patch, I will include that as well.

Thanks,

Thomas S. Trias
Senior Developer
Artizan Internet Services
http://www.artizan.com/


-------- Original Message  --------
Subject: Changes to secureobj.cpp in 3.0.4610
From: Thomas S. Trias <[EMAIL PROTECTED]>
To: Windows Installer XML toolset developer mailing list <[email protected]>
Date: 10/22/2008 11:53 AM
I am merging the changes made by Cody Cutrer into Wix 3.0.4610, and I noticed that the code for SchedSecureObjects has been cleaned up considerably.

I have a couple of comments / questions:

* Shouldn't there be a check on the return value of GetTargetPath on line 383?

* Do you see any problems with only storing rollback information once per table / path pair?

In Cody's code, the rollback information is only stored once per object (table and path); I have altered the code in SchedSecureObjectsRollback to reflect this behavior.

Attached is a unified diff of the changes to secureobj.cpp. It includes a check of the HRESULT from GetTargetPath.

Thanks,


--- src\ca\wixca\dll\secureobj.cpp      2008-11-13 15:09:52.000000000 -0600
+++ src\ca\wixca\dll\secureobj.cpp      2008-11-13 15:07:25.000000000 -0600
@@ -24,12 +24,15 @@
                                 
L"`SecureObjects`.`Component_`=`Component`.`Component`";
 enum eQUERY_SECUREOBJECTS { QSO_SECUREOBJECT = 1, QSO_TABLE, QSO_DOMAIN, 
QSO_USER, QSO_PERMISSION, QSO_COMPONENT, QSO_COMPATTRIBUTES };
 
 LPCWSTR wzQUERY_REGISTRY = L"SELECT `Registry`.`Registry`, `Registry`.`Root`, 
`Registry`.`Key` FROM `Registry` WHERE `Registry`.`Registry`=?";
 enum eQUERY_OBJECTCOMPONENT { QSOC_REGISTRY = 1, QSOC_REGROOT, QSOC_REGKEY};
 
+LPCWSTR wzQUERY_SERVICEINSTALL = L"SELECT `ServiceInstall`.`ServiceInstall`, 
`ServiceInstall`.`Name` FROM `ServiceInstall` WHERE 
`ServiceInstall`.`ServiceInstall`=?";
+enum eQUERY_SERVICEINSATLL { QSI_SERVICEINSTALL = 1, QSI_NAME};
+
 enum eOBJECTTYPE { OT_UNKNOWN, OT_SERVICE, OT_FOLDER, OT_FILE, OT_REGISTRY };
 
 static eOBJECTTYPE EObjectTypeFromString(
     __in LPCWSTR pwzTable
     )
 {
@@ -195,14 +198,39 @@
     LPWSTR pwzKey = NULL;
     LPWSTR pwzFormattedString = NULL;
 
     if (OT_SERVICE == eType)
     {
         // Our object string must be stored in "ppwzTargetPath" so we can 
store rollback information
-        hr = StrAllocString(ppwzTargetPath, pwzSecureObject, 0);
-        ExitOnFailure1(hr, "failed to allocate string to store target service: 
%S", pwzSecureObject);
+        // hr = StrAllocString(ppwzTargetPath, pwzSecureObject, 0);
+        // ExitOnFailure1(hr, "failed to allocate string to store target 
service: %S", pwzSecureObject);
+
+        PMSIHANDLE hViewServiceInstall = NULL;
+
+        hr = WcaTableExists(L"ServiceInstall");
+        if (S_FALSE == hr)
+        {
+            hr = E_UNEXPECTED;
+        }
+        ExitOnFailure(hr, "failed to open ServiceInstall table to secure 
object");
+
+        hr = WcaOpenView(wzQUERY_SERVICEINSTALL, &hViewServiceInstall);
+        ExitOnFailure(hr, "failed to open view on ServiceInstall table");
+
+        // create a record that stores the object to secure
+        hRec = MsiCreateRecord(1);
+        MsiRecordSetStringW(hRec, 1, pwzSecureObject);
+
+        // execute a view looking for the object's Component_
+        hr = WcaExecuteView(hViewServiceInstall, hRec);
+        ExitOnFailure(hr, "failed to execute view on ServiceInstall table");
+        hr = WcaFetchSingleRecord(hViewServiceInstall, &hRecObject);
+        ExitOnFailure(hr, "failed to fetch Component for secure object");
+
+        hr = WcaGetRecordFormattedString(hRecObject, QSI_NAME, ppwzTargetPath);
+        ExitOnFailure1(hr, "Failed to get service name for secure object: %S", 
pwzSecureObject);
     }
     else if (OT_FOLDER == eType)
     {
         hr = WcaGetTargetPath(pwzSecureObject, ppwzTargetPath);
         ExitOnFailure1(hr, "failed to get target path for directory id: %S", 
pwzSecureObject);
     }
-------------------------------------------------------------------------
This SF.Net email is sponsored by the Moblin Your Move Developer's challenge
Build the coolest Linux based applications with Moblin SDK & win great prizes
Grand prize is a trip for two to an Open Source event anywhere in the world
http://moblin-contest.org/redirect.php?banner_id=100&url=/
_______________________________________________
WiX-devs mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/wix-devs

Reply via email to