Module: wine Branch: master Commit: 8ae81d0620a0c11febea41fdfd463f692e506dbc URL: http://source.winehq.org/git/wine.git/?a=commit;h=8ae81d0620a0c11febea41fdfd...
Author: James Hawkins truiken@gmail.com Date: Thu Nov 30 18:15:40 2006 -0800
msi: Set the UserSID property.
---
dlls/msi/package.c | 54 ++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 files changed, 54 insertions(+), 0 deletions(-)
diff --git a/dlls/msi/package.c b/dlls/msi/package.c index 57bf0f6..d4b9d25 100644 --- a/dlls/msi/package.c +++ b/dlls/msi/package.c @@ -41,6 +41,7 @@ #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 = NULL; + 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 ); }