Commit ffc4a49b authored by Vincent Povirk's avatar Vincent Povirk Committed by Alexandre Julliard

ole32: Always allow changes to read-only transacted storages.

The only time the write permissions of transacted storages matter is when committing.
parent d49510e7
...@@ -864,15 +864,16 @@ static HRESULT WINAPI StorageBaseImpl_CreateStream( ...@@ -864,15 +864,16 @@ static HRESULT WINAPI StorageBaseImpl_CreateStream(
(grfMode & STGM_TRANSACTED)) (grfMode & STGM_TRANSACTED))
return STG_E_INVALIDFUNCTION; return STG_E_INVALIDFUNCTION;
/*
* Don't worry about permissions in transacted mode, as we can always write
* changes; we just can't always commit them.
*/
if(!(This->openFlags & STGM_TRANSACTED)) {
/* Can't create a stream on read-only storage */ /* Can't create a stream on read-only storage */
if ( STGM_ACCESS_MODE( This->openFlags ) == STGM_READ ) if ( STGM_ACCESS_MODE( This->openFlags ) == STGM_READ )
return STG_E_ACCESSDENIED; return STG_E_ACCESSDENIED;
/* /* Can't create a stream with greater access than the parent. */
* Check that we're compatible with the parent's storage mode
* if not in transacted mode
*/
if(!(This->openFlags & STGM_TRANSACTED)) {
if ( STGM_ACCESS_MODE( grfMode ) > STGM_ACCESS_MODE( This->openFlags ) ) if ( STGM_ACCESS_MODE( grfMode ) > STGM_ACCESS_MODE( This->openFlags ) )
return STG_E_ACCESSDENIED; return STG_E_ACCESSDENIED;
} }
...@@ -899,11 +900,6 @@ static HRESULT WINAPI StorageBaseImpl_CreateStream( ...@@ -899,11 +900,6 @@ static HRESULT WINAPI StorageBaseImpl_CreateStream(
else else
return STG_E_FILEALREADYEXISTS; return STG_E_FILEALREADYEXISTS;
} }
else if (STGM_ACCESS_MODE(This->openFlags) == STGM_READ)
{
WARN("read-only storage\n");
return STG_E_ACCESSDENIED;
}
/* /*
* memset the empty entry * memset the empty entry
...@@ -1058,7 +1054,8 @@ static HRESULT WINAPI StorageBaseImpl_CreateStorage( ...@@ -1058,7 +1054,8 @@ static HRESULT WINAPI StorageBaseImpl_CreateStorage(
/* /*
* Check that we're compatible with the parent's storage mode * Check that we're compatible with the parent's storage mode
*/ */
if ( STGM_ACCESS_MODE( grfMode ) > STGM_ACCESS_MODE( This->openFlags ) ) if ( !(This->openFlags & STGM_TRANSACTED) &&
STGM_ACCESS_MODE( grfMode ) > STGM_ACCESS_MODE( This->openFlags ) )
{ {
WARN("access denied\n"); WARN("access denied\n");
return STG_E_ACCESSDENIED; return STG_E_ACCESSDENIED;
...@@ -1075,7 +1072,8 @@ static HRESULT WINAPI StorageBaseImpl_CreateStorage( ...@@ -1075,7 +1072,8 @@ static HRESULT WINAPI StorageBaseImpl_CreateStorage(
* An element with this name already exists * An element with this name already exists
*/ */
if (STGM_CREATE_MODE(grfMode) == STGM_CREATE && if (STGM_CREATE_MODE(grfMode) == STGM_CREATE &&
STGM_ACCESS_MODE(This->openFlags) != STGM_READ) ((This->openFlags & STGM_TRANSACTED) ||
STGM_ACCESS_MODE(This->openFlags) != STGM_READ))
{ {
hr = IStorage_DestroyElement(iface, pwcsName); hr = IStorage_DestroyElement(iface, pwcsName);
if (FAILED(hr)) if (FAILED(hr))
...@@ -1087,7 +1085,8 @@ static HRESULT WINAPI StorageBaseImpl_CreateStorage( ...@@ -1087,7 +1085,8 @@ static HRESULT WINAPI StorageBaseImpl_CreateStorage(
return STG_E_FILEALREADYEXISTS; return STG_E_FILEALREADYEXISTS;
} }
} }
else if (STGM_ACCESS_MODE(This->openFlags) == STGM_READ) else if (!(This->openFlags & STGM_TRANSACTED) &&
STGM_ACCESS_MODE(This->openFlags) == STGM_READ)
{ {
WARN("read-only storage\n"); WARN("read-only storage\n");
return STG_E_ACCESSDENIED; return STG_E_ACCESSDENIED;
...@@ -1831,7 +1830,8 @@ static HRESULT WINAPI StorageBaseImpl_DestroyElement( ...@@ -1831,7 +1830,8 @@ static HRESULT WINAPI StorageBaseImpl_DestroyElement(
if (This->reverted) if (This->reverted)
return STG_E_REVERTED; return STG_E_REVERTED;
if ( STGM_ACCESS_MODE( This->openFlags ) == STGM_READ ) if ( !(This->openFlags & STGM_TRANSACTED) &&
STGM_ACCESS_MODE( This->openFlags ) == STGM_READ )
return STG_E_ACCESSDENIED; return STG_E_ACCESSDENIED;
entryToDeleteRef = findElement( entryToDeleteRef = findElement(
......
...@@ -1505,7 +1505,7 @@ static void test_nonroot_transacted(void) ...@@ -1505,7 +1505,7 @@ static void test_nonroot_transacted(void)
{ {
/* The storage can be modified. */ /* The storage can be modified. */
r = IStorage_CreateStorage(stg2, stgname, STGM_READWRITE | STGM_SHARE_EXCLUSIVE, 0, 0, &stg3); r = IStorage_CreateStorage(stg2, stgname, STGM_READWRITE | STGM_SHARE_EXCLUSIVE, 0, 0, &stg3);
todo_wine ok(r==S_OK, "IStorage->CreateStorage failed, hr=%08x\n", r); ok(r==S_OK, "IStorage->CreateStorage failed, hr=%08x\n", r);
if (r == S_OK) if (r == S_OK)
IStream_Release(stg3); IStream_Release(stg3);
......
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