Commit 75e35447 authored by Hans Leidekker's avatar Hans Leidekker Committed by Alexandre Julliard

sxs: Add support for installing policy files.

parent eba81476
...@@ -308,26 +308,20 @@ static HRESULT parse_assembly( IXMLDOMDocument *doc, struct assembly **assembly ...@@ -308,26 +308,20 @@ static HRESULT parse_assembly( IXMLDOMDocument *doc, struct assembly **assembly
hr = IXMLDOMNode_get_attributes( node, &attrs ); hr = IXMLDOMNode_get_attributes( node, &attrs );
if (hr != S_OK) goto done; if (hr != S_OK) goto done;
a->type = get_attribute_value( attrs, typeW ); a->type = get_attribute_value( attrs, typeW );
if (a->type && !strcmpW( a->type, policyW ))
{
FIXME("ignoring policy assembly\n");
hr = ERROR_SXS_MANIFEST_FORMAT_ERROR;
goto done;
}
a->name = get_attribute_value( attrs, nameW ); a->name = get_attribute_value( attrs, nameW );
a->version = get_attribute_value( attrs, versionW ); a->version = get_attribute_value( attrs, versionW );
a->arch = get_attribute_value( attrs, architectureW ); a->arch = get_attribute_value( attrs, architectureW );
a->token = get_attribute_value( attrs, tokenW ); a->token = get_attribute_value( attrs, tokenW );
if (!a->type || strcmpW( a->type, win32W ) || !a->name || !a->version || !a->arch || !a->token) if (!a->type || (strcmpW( a->type, win32W ) && strcmpW( a->type, policyW )) ||
!a->name || !a->version || !a->arch || !a->token)
{ {
WARN("invalid win32 assembly\n"); WARN("invalid win32 assembly\n");
hr = ERROR_SXS_MANIFEST_FORMAT_ERROR; hr = ERROR_SXS_MANIFEST_FORMAT_ERROR;
goto done; goto done;
} }
if (!strcmpW( a->type, win32W )) hr = parse_files( doc, a );
hr = parse_files( doc, a );
done: done:
if (attrs) IXMLDOMNamedNodeMap_Release( attrs ); if (attrs) IXMLDOMNamedNodeMap_Release( attrs );
...@@ -338,6 +332,99 @@ done: ...@@ -338,6 +332,99 @@ done:
return hr; return hr;
} }
static WCHAR *build_sxs_path( void )
{
static const WCHAR winsxsW[] = {'\\','w','i','n','s','x','s','\\',0};
WCHAR sxsdir[MAX_PATH];
GetWindowsDirectoryW( sxsdir, MAX_PATH );
strcatW( sxsdir, winsxsW );
return strdupW( sxsdir );
}
static WCHAR *build_assembly_name( struct assembly *assembly )
{
static const WCHAR fmtW[] =
{'%','s','_','%','s','_','%','s','_','%','s','_','n','o','n','e','_','d','e','a','d','b','e','e','f',0};
WCHAR *ret, *p;
int len;
len = strlenW( fmtW );
len += strlenW( assembly->arch );
len += strlenW( assembly->name );
len += strlenW( assembly->token );
len += strlenW( assembly->version );
if (!(ret = HeapAlloc( GetProcessHeap(), 0, len * sizeof(WCHAR) ))) return NULL;
sprintfW( ret, fmtW, assembly->arch, assembly->name, assembly->token, assembly->version );
for (p = ret; *p; p++) *p = tolowerW( *p );
return ret;
}
static WCHAR *build_policy_name( struct assembly *assembly )
{
static const WCHAR fmtW[] =
{'%','s','_','%','s','_','%','s','_','n','o','n','e','_','d','e','a','d','b','e','e','f',0};
WCHAR *ret, *p;
int len;
len = strlenW( fmtW );
len += strlenW( assembly->arch );
len += strlenW( assembly->name );
len += strlenW( assembly->token );
if (!(ret = HeapAlloc( GetProcessHeap(), 0, len * sizeof(WCHAR) ))) return NULL;
sprintfW( ret, fmtW, assembly->arch, assembly->name, assembly->token );
for (p = ret; *p; p++) *p = tolowerW( *p );
return ret;
}
static HRESULT install_policy( const WCHAR *manifest, struct assembly *assembly )
{
static const WCHAR policiesW[] = {'p','o','l','i','c','i','e','s','\\',0};
static const WCHAR suffixW[] = {'.','p','o','l','i','c','y',0};
static const WCHAR backslashW[] = {'\\',0};
WCHAR *sxsdir, *name, *dst;
HRESULT hr = E_OUTOFMEMORY;
BOOL ret;
int len;
/* FIXME: handle catalog file */
if (!(sxsdir = build_sxs_path())) return E_OUTOFMEMORY;
if (!(name = build_policy_name( assembly ))) goto done;
len = strlenW( sxsdir );
len += strlenW( policiesW );
len += strlenW( name ) + 1;
len += strlenW( assembly->version );
len += strlenW( suffixW );
if (!(dst = HeapAlloc( GetProcessHeap(), 0, (len + 1) * sizeof(WCHAR) ))) goto done;
strcpyW( dst, sxsdir );
strcatW( dst, policiesW );
CreateDirectoryW( dst, NULL );
strcatW( dst, name );
CreateDirectoryW( dst, NULL );
strcatW( dst, backslashW );
strcatW( dst, assembly->version );
strcatW( dst, suffixW );
ret = CopyFileW( manifest, dst, FALSE );
HeapFree( GetProcessHeap(), 0, dst );
if (!ret)
{
hr = HRESULT_FROM_WIN32( GetLastError() );
WARN("failed to copy policy manifest file 0x%08x\n", hr);
}
hr = S_OK;
done:
HeapFree( GetProcessHeap(), 0, sxsdir );
HeapFree( GetProcessHeap(), 0, name );
return hr;
}
static WCHAR *build_source_filename( const WCHAR *manifest, struct file *file ) static WCHAR *build_source_filename( const WCHAR *manifest, struct file *file )
{ {
WCHAR *src; WCHAR *src;
...@@ -359,42 +446,23 @@ static WCHAR *build_source_filename( const WCHAR *manifest, struct file *file ) ...@@ -359,42 +446,23 @@ static WCHAR *build_source_filename( const WCHAR *manifest, struct file *file )
static HRESULT install_assembly( const WCHAR *manifest, struct assembly *assembly ) static HRESULT install_assembly( const WCHAR *manifest, struct assembly *assembly )
{ {
static const WCHAR winsxsW[] = {'\\','w','i','n','s','x','s','\\',0};
static const WCHAR manifestsW[] = {'m','a','n','i','f','e','s','t','s','\\',0}; static const WCHAR manifestsW[] = {'m','a','n','i','f','e','s','t','s','\\',0};
static const WCHAR deadbeefW[] = {'n','o','n','e','_','d','e','a','d','b','e','e','f',0};
static const WCHAR suffixW[] = {'.','m','a','n','i','f','e','s','t',0}; static const WCHAR suffixW[] = {'.','m','a','n','i','f','e','s','t',0};
static const WCHAR backslashW[] = {'\\',0}; static const WCHAR backslashW[] = {'\\',0};
static const WCHAR fmtW[] = {'%','s','_','%','s','_','%','s','_','%','s','_','%','s',0}; WCHAR *sxsdir, *p, *name, *dst, *src;
WCHAR sxsdir[MAX_PATH], *p, *name, *dst, *src;
int len;
struct file *file; struct file *file;
HRESULT hr = S_OK; HRESULT hr = E_OUTOFMEMORY;
BOOL ret; BOOL ret;
int len;
GetWindowsDirectoryW( sxsdir, MAX_PATH ); if (!(sxsdir = build_sxs_path())) return E_OUTOFMEMORY;
strcatW( sxsdir, winsxsW ); if (!(name = build_assembly_name( assembly ))) goto done;
len = strlenW( fmtW );
len += strlenW( assembly->arch );
len += strlenW( assembly->name );
len += strlenW( assembly->token );
len += strlenW( assembly->version );
len += strlenW( deadbeefW );
if (!(name = HeapAlloc( GetProcessHeap(), 0, len * sizeof(WCHAR) )))
return E_OUTOFMEMORY;
len = sprintfW( name, fmtW, assembly->arch, assembly->name, assembly->token, assembly->version, deadbeefW );
for (p = name; *p; p++) *p = tolowerW( *p );
len += strlenW( sxsdir ); len = strlenW( sxsdir );
len += strlenW( manifestsW ); len += strlenW( manifestsW );
len += strlenW( name );
len += strlenW( suffixW ); len += strlenW( suffixW );
if (!(dst = HeapAlloc( GetProcessHeap(), 0, (len + 1) * sizeof(WCHAR) ))) if (!(dst = HeapAlloc( GetProcessHeap(), 0, (len + 1) * sizeof(WCHAR) ))) goto done;
{
HeapFree( GetProcessHeap(), 0, name );
return E_OUTOFMEMORY;
}
strcpyW( dst, sxsdir ); strcpyW( dst, sxsdir );
strcatW( dst, manifestsW ); strcatW( dst, manifestsW );
strcatW( dst, name ); strcatW( dst, name );
...@@ -442,8 +510,10 @@ static HRESULT install_assembly( const WCHAR *manifest, struct assembly *assembl ...@@ -442,8 +510,10 @@ static HRESULT install_assembly( const WCHAR *manifest, struct assembly *assembl
goto done; goto done;
} }
} }
hr = S_OK;
done: done:
HeapFree( GetProcessHeap(), 0, sxsdir );
HeapFree( GetProcessHeap(), 0, name ); HeapFree( GetProcessHeap(), 0, name );
return hr; return hr;
} }
...@@ -454,6 +524,7 @@ static HRESULT WINAPI cache_InstallAssembly( ...@@ -454,6 +524,7 @@ static HRESULT WINAPI cache_InstallAssembly(
LPCWSTR path, LPCWSTR path,
LPCFUSION_INSTALL_REFERENCE ref ) LPCFUSION_INSTALL_REFERENCE ref )
{ {
static const WCHAR policyW[] = {'w','i','n','3','2','-','p','o','l','i','c','y',0};
HRESULT hr, init; HRESULT hr, init;
IXMLDOMDocument *doc = NULL; IXMLDOMDocument *doc = NULL;
struct assembly *assembly = NULL; struct assembly *assembly = NULL;
...@@ -489,7 +560,10 @@ static HRESULT WINAPI cache_InstallAssembly( ...@@ -489,7 +560,10 @@ static HRESULT WINAPI cache_InstallAssembly(
/* FIXME: verify name attributes */ /* FIXME: verify name attributes */
hr = install_assembly( path, assembly ); if (!strcmpW( assembly->type, policyW ))
hr = install_policy( path, assembly );
else
hr = install_assembly( path, assembly );
done: done:
free_assembly( assembly ); free_assembly( assembly );
......
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