Skip to content

Commit 06a4199

Browse files
committed
exch: better function/variable names for cu_extract_delegate
References: GXH-169
1 parent f2a4f32 commit 06a4199

File tree

4 files changed

+33
-32
lines changed

4 files changed

+33
-32
lines changed

exch/emsmdb/oxomsg.cpp

Lines changed: 22 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -131,15 +131,17 @@ static ec_error_t oxomsg_rectify_message(message_object *pmessage,
131131
}
132132

133133
/**
134+
* Inspects a message that a delegate (secretary) wants to submit.
135+
*
134136
* Returns:
135-
* - %true and @username is empty: no delegation was requested
136-
* - %true and @username is set: delegation with given identity;
137+
* - %true and @username is empty: no delegation
138+
* - %true and @username is set: delegator ("boss") extracted and
137139
* identity guaranteed to exist; caller still needs to perform a
138140
* permission check.
139141
* - %false: unable to contact server,
140-
* or requested identity not present in the system
142+
* or requested identity (boss) not present in the system
141143
*/
142-
static bool oxomsg_extract_delegate(message_object *pmessage,
144+
static bool oxomsg_extract_delegator(message_object *pmessage,
143145
std::string &username)
144146
{
145147
static constexpr proptag_t proptag_buff[] =
@@ -312,25 +314,25 @@ ec_error_t rop_submitmessage(uint8_t submit_flags, LOGMAP *plogmap,
312314
static_cast<unsigned long long>(pmessage->get_id()));
313315
return ecAccessDenied;
314316
}
315-
std::string username;
316-
if (!oxomsg_extract_delegate(pmessage, username))
317+
std::string delegator;
318+
if (!oxomsg_extract_delegator(pmessage, delegator))
317319
return ecError;
318-
auto account = plogon->get_account();
320+
auto actor = plogon->get_account();
319321
repr_grant repr_grant;
320-
if (username.empty()) {
322+
if (delegator.empty()) {
321323
/* "No impersonation requested" is modeled as {impersonate yourself}. */
322-
username = account;
324+
delegator = actor;
323325
repr_grant = repr_grant::send_as;
324326
} else {
325-
repr_grant = oxomsg_get_perm(account, username.c_str());
327+
repr_grant = oxomsg_get_perm(actor, delegator.c_str());
326328
}
327329
if (repr_grant < repr_grant::send_on_behalf) {
328-
auto ret = pass_scheduling("E-2081", account, username.c_str(), *pmessage,
330+
auto ret = pass_scheduling("E-2081", actor, delegator.c_str(), *pmessage,
329331
tmp_propvals.get<const char>(PR_MESSAGE_CLASS));
330332
if (ret != ecSuccess)
331333
return ret;
332334
}
333-
auto ret = oxomsg_rectify_message(pmessage, username.c_str(),
335+
auto ret = oxomsg_rectify_message(pmessage, delegator.c_str(),
334336
repr_grant >= repr_grant::send_as);
335337
if (ret != ecSuccess)
336338
return ret;
@@ -618,27 +620,27 @@ ec_error_t rop_transportsend(TPROPVAL_ARRAY **pppropvals, LOGMAP *plogmap,
618620
static_cast<unsigned long long>(pmessage->get_id()));
619621
return ecAccessDenied;
620622
}
621-
std::string username;
622-
if (!oxomsg_extract_delegate(pmessage, username))
623+
std::string delegator;
624+
if (!oxomsg_extract_delegator(pmessage, delegator))
623625
return ecError;
624-
auto account = plogon->get_account();
626+
auto actor = plogon->get_account();
625627
repr_grant repr_grant;
626-
if (username.empty()) {
627-
username = account;
628+
if (delegator.empty()) {
629+
delegator = actor;
628630
repr_grant = repr_grant::send_as;
629631
} else {
630-
repr_grant = oxomsg_get_perm(account, username.c_str());
632+
repr_grant = oxomsg_get_perm(actor, delegator.c_str());
631633
}
632634
if (repr_grant < repr_grant::send_on_behalf) {
633635
TPROPVAL_ARRAY cls_vals{};
634636
if (pmessage->get_properties(0, &cls_tags, &cls_vals) != 0)
635637
/* ignore, since we can test for cls_vals fill */;
636-
auto ret = pass_scheduling("E-2080", account, username.c_str(), *pmessage,
638+
auto ret = pass_scheduling("E-2080", actor, delegator.c_str(), *pmessage,
637639
cls_vals.get<const char>(PR_MESSAGE_CLASS));
638640
if (ret != ecSuccess)
639641
return ret;
640642
}
641-
auto ret = oxomsg_rectify_message(pmessage, username.c_str(),
643+
auto ret = oxomsg_rectify_message(pmessage, delegator.c_str(),
642644
repr_grant >= repr_grant::send_as);
643645
if (ret != ecSuccess)
644646
return ret;

exch/zcore/common_util.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,7 @@ BOOL common_util_verify_columns_and_sorts(
114114
}
115115

116116
/* Cf. oxomsg_extract_delegate for comments */
117-
bool cu_extract_delegate(message_object *pmessage, std::string &username)
117+
bool cu_extract_delegator(message_object *pmessage, std::string &username)
118118
{
119119
TPROPVAL_ARRAY tmp_propvals;
120120
static constexpr proptag_t proptag_buff[] =

exch/zcore/common_util.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ extern int common_util_run(const char *data_path);
8383
BOOL common_util_verify_columns_and_sorts(
8484
const PROPTAG_ARRAY *pcolumns,
8585
const SORTORDER_SET *psort_criteria);
86-
extern bool cu_extract_delegate(message_object *, std::string &dlgt);
86+
extern bool cu_extract_delegator(message_object *, std::string &);
8787
extern repr_grant cu_get_delegate_perm_MD(const char *account, const char *maildir);
8888
extern repr_grant cu_get_delegate_perm_AA(const char *account, const char *account_representing);
8989
extern ec_error_t cu_set_propval(TPROPVAL_ARRAY *parray, gromox::proptag_t, const void *);

exch/zcore/zserver.cpp

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -3264,23 +3264,23 @@ ec_error_t zs_submitmessage(GUID hsession, uint32_t hmessage) try
32643264
/* FAI message cannot be sent */
32653265
if (flag != nullptr && *flag != 0)
32663266
return ecAccessDenied;
3267-
std::string username;
3268-
if (!cu_extract_delegate(pmessage, username))
3267+
std::string delegator;
3268+
if (!cu_extract_delegator(pmessage, delegator))
32693269
return ecSendAsDenied;
3270-
auto account = pstore->get_account();
3270+
auto actor = pstore->get_account();
32713271
repr_grant repr_grant;
3272-
if (username.empty()) {
3273-
username = account;
3272+
if (delegator.empty()) {
3273+
delegator = actor;
32743274
repr_grant = repr_grant::send_as;
32753275
} else {
3276-
repr_grant = cu_get_delegate_perm_AA(account, username.c_str());
3276+
repr_grant = cu_get_delegate_perm_AA(actor, delegator.c_str());
32773277
}
32783278
if (repr_grant < repr_grant::send_on_behalf) {
32793279
mlog(LV_INFO, "I-1334: uid %s tried to submit %s:%llxh with from=<%s>, but no impersonation permission given.",
3280-
account, pstore->dir, LLU{pmessage->get_id()}, username.c_str());
3280+
actor, pstore->dir, LLU{pmessage->get_id()}, delegator.c_str());
32813281
return ecAccessDenied;
32823282
}
3283-
auto err = rectify_message(pmessage, username.c_str(),
3283+
auto err = rectify_message(pmessage, delegator.c_str(),
32843284
repr_grant >= repr_grant::send_as);
32853285
if (err != ecSuccess)
32863286
return err;
@@ -3337,8 +3337,7 @@ ec_error_t zs_submitmessage(GUID hsession, uint32_t hmessage) try
33373337
auto deferred_time = props_to_defer_interval(tmp_propvals);
33383338
if (deferred_time > 0) {
33393339
snprintf(command_buff, 1024, "%s %s %llu",
3340-
common_util_get_submit_command(),
3341-
pstore->get_account(),
3340+
common_util_get_submit_command(), actor,
33423341
LLU{rop_util_get_gc_value(pmessage->get_id())});
33433342
timer_id = system_services_add_timer(
33443343
command_buff, deferred_time);

0 commit comments

Comments
 (0)