Commit e1a65bed authored by Huw Davies's avatar Huw Davies Committed by Alexandre Julliard

msi: Be more selective about which access modes are used to open or create keys.

An installer was failing when trying to create subkeys after denying delete access to their parent key.
parent 4a992fec
...@@ -2633,9 +2633,8 @@ static inline REGSAM get_registry_view( const MSICOMPONENT *comp ) ...@@ -2633,9 +2633,8 @@ static inline REGSAM get_registry_view( const MSICOMPONENT *comp )
return view; return view;
} }
static HKEY open_key( const MSICOMPONENT *comp, HKEY root, const WCHAR *path, BOOL create ) static HKEY open_key( const MSICOMPONENT *comp, HKEY root, const WCHAR *path, BOOL create, REGSAM access )
{ {
REGSAM access = KEY_ALL_ACCESS;
WCHAR *subkey, *p, *q; WCHAR *subkey, *p, *q;
HKEY hkey, ret = NULL; HKEY hkey, ret = NULL;
LONG res; LONG res;
...@@ -2657,7 +2656,7 @@ static HKEY open_key( const MSICOMPONENT *comp, HKEY root, const WCHAR *path, BO ...@@ -2657,7 +2656,7 @@ static HKEY open_key( const MSICOMPONENT *comp, HKEY root, const WCHAR *path, BO
} }
if (q && q[1]) if (q && q[1])
{ {
ret = open_key( comp, hkey, q + 1, create ); ret = open_key( comp, hkey, q + 1, create, access );
RegCloseKey( hkey ); RegCloseKey( hkey );
} }
else ret = hkey; else ret = hkey;
...@@ -2882,7 +2881,7 @@ static UINT ITERATE_WriteRegistryValues(MSIRECORD *row, LPVOID param) ...@@ -2882,7 +2881,7 @@ static UINT ITERATE_WriteRegistryValues(MSIRECORD *row, LPVOID param)
strcpyW(uikey,szRoot); strcpyW(uikey,szRoot);
strcatW(uikey,deformated); strcatW(uikey,deformated);
if (!(hkey = open_key( comp, root_key, deformated, TRUE ))) if (!(hkey = open_key( comp, root_key, deformated, TRUE, KEY_QUERY_VALUE | KEY_SET_VALUE )))
{ {
ERR("Could not create key %s\n", debugstr_w(deformated)); ERR("Could not create key %s\n", debugstr_w(deformated));
msi_free(uikey); msi_free(uikey);
...@@ -2979,7 +2978,7 @@ static void delete_key( const MSICOMPONENT *comp, HKEY root, const WCHAR *path ) ...@@ -2979,7 +2978,7 @@ static void delete_key( const MSICOMPONENT *comp, HKEY root, const WCHAR *path )
{ {
*p = 0; *p = 0;
if (!p[1]) continue; /* trailing backslash */ if (!p[1]) continue; /* trailing backslash */
hkey = open_key( comp, root, subkey, FALSE ); hkey = open_key( comp, root, subkey, FALSE, access );
if (!hkey) break; if (!hkey) break;
res = RegDeleteKeyExW( hkey, p + 1, access, 0 ); res = RegDeleteKeyExW( hkey, p + 1, access, 0 );
RegCloseKey( hkey ); RegCloseKey( hkey );
...@@ -3001,7 +3000,7 @@ static void delete_value( const MSICOMPONENT *comp, HKEY root, const WCHAR *path ...@@ -3001,7 +3000,7 @@ static void delete_value( const MSICOMPONENT *comp, HKEY root, const WCHAR *path
HKEY hkey; HKEY hkey;
DWORD num_subkeys, num_values; DWORD num_subkeys, num_values;
if ((hkey = open_key( comp, root, path, FALSE ))) if ((hkey = open_key( comp, root, path, FALSE, KEY_SET_VALUE | KEY_QUERY_VALUE )))
{ {
if ((res = RegDeleteValueW( hkey, value ))) if ((res = RegDeleteValueW( hkey, value )))
TRACE("failed to delete value %s (%d)\n", debugstr_w(value), res); TRACE("failed to delete value %s (%d)\n", debugstr_w(value), res);
...@@ -3022,7 +3021,7 @@ static void delete_tree( const MSICOMPONENT *comp, HKEY root, const WCHAR *path ...@@ -3022,7 +3021,7 @@ static void delete_tree( const MSICOMPONENT *comp, HKEY root, const WCHAR *path
LONG res; LONG res;
HKEY hkey; HKEY hkey;
if (!(hkey = open_key( comp, root, path, FALSE ))) return; if (!(hkey = open_key( comp, root, path, FALSE, KEY_ALL_ACCESS ))) return;
res = RegDeleteTreeW( hkey, NULL ); res = RegDeleteTreeW( hkey, NULL );
if (res) TRACE("failed to delete subtree of %s (%d)\n", debugstr_w(path), res); if (res) TRACE("failed to delete subtree of %s (%d)\n", debugstr_w(path), res);
delete_key( comp, root, path ); delete_key( comp, root, path );
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment