msi: Set the UserSID property [try2]
James Hawkins
truiken at gmail.com
Thu Nov 30 20:15:40 CST 2006
Hi,
This version fixes a memory leak.
Changelog:
* Set the UserSID property.
dlls/msi/package.c | 54 ++++++++++++++++++++++++++++++++++++++++++++++++++++
1 files changed, 54 insertions(+), 0 deletions(-)
--
James Hawkins
-------------- next part --------------
diff --git a/dlls/msi/package.c b/dlls/msi/package.c
index 57bf0f6..32abf54 100644
--- a/dlls/msi/package.c
+++ b/dlls/msi/package.c
@@ -41,6 +41,7 @@ #include "shlobj.h"
#include "wine/unicode.h"
#include "objbase.h"
#include "msidefs.h"
+#include "sddl.h"
#include "msipriv.h"
@@ -113,6 +114,56 @@ static UINT set_installed_prop( MSIPACKA
return r;
}
+static UINT set_user_sid_prop( MSIPACKAGE *package )
+{
+ SID_NAME_USE use;
+ LPWSTR user_name;
+ LPWSTR sid_str, dom;
+ DWORD size, dom_size;
+ PSID psid = NULL;
+ UINT r = ERROR_FUNCTION_FAILED;
+
+ static const WCHAR user_sid[] = {'U','s','e','r','S','I','D',0};
+
+ size = 0;
+ GetUserNameW( NULL, &size );
+
+ user_name = msi_alloc( (size + 1) * sizeof(WCHAR) );
+ if (!user_name)
+ return ERROR_OUTOFMEMORY;
+
+ if (!GetUserNameW( user_name, &size ))
+ goto done;
+
+ size = 0;
+ dom_size = 0;
+ LookupAccountNameW( NULL, user_name, NULL, &size, NULL, &dom_size, &use );
+
+ psid = msi_alloc( size );
+ dom = msi_alloc( dom_size );
+ if (!psid || !dom)
+ {
+ r = ERROR_OUTOFMEMORY;
+ goto done;
+ }
+
+ if (!LookupAccountNameW( NULL, user_name, psid, &size, dom, &dom_size, &use ))
+ goto done;
+
+ if (!ConvertSidToStringSidW( psid, &sid_str ))
+ goto done;
+
+ r = MSI_SetPropertyW( package, user_sid, sid_str );
+
+done:
+ LocalFree( sid_str );
+ msi_free( dom );
+ msi_free( psid );
+ msi_free( user_name );
+
+ return r;
+}
+
/*
* There are a whole slew of these we need to set
*
@@ -379,6 +430,9 @@ static VOID set_installer_properties(MSI
msi_free( company );
}
+ if ( set_user_sid_prop( package ) != ERROR_SUCCESS)
+ ERR("Failed to set the UserSID property\n");
+
msi_free( check );
CloseHandle( hkey );
}
--
1.4.2.4
More information about the wine-patches
mailing list