Skip to content

Commit e7dcc14

Browse files
grammmikejengelh
authored andcommitted
emsmdb: make openstream treat MAPI_BEST_ACCESS as documented
MAPI_BEST_ACCESS is supposed to imply a fallback to readonly, but this was not implemented. This patch makes rop_openstream downgrade MAPI_BEST_ACCESS requests to read-only when lacking the appropriate rights on the object, instead of returning ecAccessDenied. Delegate users with only read powers can now fetch attachment bodies like they were already able to do with message exports. [The latter are handled via fxstream –jengelh] References: GXL-646, DESK-4130
1 parent 273d2b6 commit e7dcc14

File tree

2 files changed

+14
-5
lines changed

2 files changed

+14
-5
lines changed

exch/emsmdb/oxcprpt.cpp

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -881,7 +881,7 @@ ec_error_t rop_openstream(proptag_t proptag, uint8_t flags, uint32_t *pstream_si
881881
auto pobject = rop_processor_get_object(plogmap, logon_id, hin, &object_type);
882882
if (pobject == nullptr)
883883
return ecNullObject;
884-
BOOL b_write = flags == MAPI_CREATE || flags == MAPI_MODIFY ? TRUE : false;
884+
const bool b_write = flags & MAPI_BEST_ACCESS; /* one bit suffices for wanting to write */
885885
switch (object_type) {
886886
case ems_objtype::folder:
887887
/* MS-OXCPERM 3.1.4.1 */
@@ -898,8 +898,11 @@ ec_error_t rop_openstream(proptag_t proptag, uint8_t flags, uint32_t *pstream_si
898898
static_cast<folder_object *>(pobject)->folder_id,
899899
eff_user, &permission))
900900
return ecError;
901-
if (!(permission & frightsOwner))
902-
return ecAccessDenied;
901+
if (!(permission & frightsOwner)) {
902+
if ((flags & MAPI_BEST_ACCESS) != MAPI_BEST_ACCESS)
903+
return ecAccessDenied;
904+
flags &= ~MAPI_BEST_ACCESS;
905+
}
903906
}
904907
}
905908
max_length = MAX_LENGTH_FOR_FOLDER;
@@ -922,8 +925,11 @@ ec_error_t rop_openstream(proptag_t proptag, uint8_t flags, uint32_t *pstream_si
922925
auto tag_access = object_type == ems_objtype::message ?
923926
static_cast<message_object *>(pobject)->get_tag_access() :
924927
static_cast<attachment_object *>(pobject)->get_tag_access();
925-
if (!(tag_access & MAPI_ACCESS_MODIFY))
926-
return ecAccessDenied;
928+
if (!(tag_access & MAPI_ACCESS_MODIFY)) {
929+
if ((flags & MAPI_BEST_ACCESS) != MAPI_BEST_ACCESS)
930+
return ecAccessDenied;
931+
flags &= ~MAPI_BEST_ACCESS;
932+
}
927933
}
928934
max_length = g_max_mail_len;
929935
break;

include/gromox/mapidefs.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1560,6 +1560,9 @@ enum {
15601560
/*
15611561
* Documented for ropOpenMessage, ropOpenAttachment, various I*::OpenEntry,
15621562
* IMAPISession::OpenMsgStore.
1563+
*
1564+
* MAPI_CREATE implies MAPI_MODIFY already, therefore a value with both bits
1565+
* being set can (and does) have a different meaning.
15631566
*/
15641567
#define MAPI_BEST_ACCESS 0x3U
15651568

0 commit comments

Comments
 (0)