Skip to content

Commit dac65aa

Browse files
committed
ruleproc: auto-enter MRs into target calender even sender won't get response
The FB readout permissions for the sender must not apply to the autoprocessor itself. MRs should be entered into the target calendar even if the sender does not have rights to elicit insight into the schedule. References: GXL-602, DESK-3257, DESK-3790, DESK-3821
1 parent 166b6f1 commit dac65aa

File tree

3 files changed

+25
-11
lines changed

3 files changed

+25
-11
lines changed

include/gromox/freebusy.hpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,4 +8,5 @@
88

99
using namespace gromox;
1010

11+
extern GX_EXPORT unsigned int freebusy_perms(const char *actor, const char *target);
1112
extern GX_EXPORT bool get_freebusy(const char *, const char *, time_t, time_t, std::vector<freebusy_event> &);

lib/freebusy.cpp

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -325,16 +325,24 @@ static bool goid_to_icaluid(BINARY *gobj, std::string &uid_buf)
325325
return true;
326326
}
327327

328+
unsigned int freebusy_perms(const char *actor, const char *target)
329+
{
330+
auto cal_eid = rop_util_make_eid_ex(1, PRIVATE_FID_CALENDAR);
331+
uint32_t perm = 0;
332+
if (!exmdb_client->get_folder_perm(target, cal_eid, actor, &perm))
333+
return 0;
334+
return perm & (frightsFreeBusySimple | frightsFreeBusyDetailed | frightsReadAny);
335+
}
336+
328337
bool get_freebusy(const char *username, const char *dir, time_t start_time,
329338
time_t end_time, std::vector<freebusy_event> &fb_data)
330339
{
331340
uint32_t permission = 0;
332341
auto cal_eid = rop_util_make_eid_ex(1, PRIVATE_FID_CALENDAR);
333342

334343
if (username != nullptr) {
335-
if (!exmdb_client->get_folder_perm(dir, cal_eid, username, &permission))
336-
return false;
337-
if (!(permission & (frightsFreeBusySimple | frightsFreeBusyDetailed | frightsReadAny)))
344+
permission = freebusy_perms(username, dir);
345+
if (permission == 0)
338346
return false;
339347
} else {
340348
permission = frightsFreeBusyDetailed | frightsReadAny;

lib/ruleproc.cpp

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1174,15 +1174,16 @@ static ec_error_t mr_do_request(rxparam &par, const PROPID_ARRAY &propids,
11741174
}
11751175

11761176
/* Lookup conflict state */
1177-
bool res_in_use = false;
1177+
bool res_in_use = false, response_allowed = false;
11781178
auto start_nt = rq_prop.get<uint64_t>(PR_START_DATE);
11791179
auto end_nt = rq_prop.get<uint64_t>(PR_END_DATE);
11801180
if (start_nt != nullptr && end_nt != nullptr) {
11811181
std::vector<freebusy_event> fbdata;
11821182
auto start_ts = rop_util_nttime_to_unix(*start_nt);
11831183
auto end_ts = rop_util_nttime_to_unix(*end_nt);
11841184
/* XXX: May need PR_SENDER rather than Envelope-From */
1185-
if (!get_freebusy(par.ev_from, par.cur.dirc(), start_ts, end_ts, fbdata))
1185+
response_allowed = freebusy_perms(par.ev_from, par.cur.dirc()) != 0;
1186+
if (!get_freebusy(nullptr, par.cur.dirc(), start_ts, end_ts, fbdata))
11861187
mlog(LV_ERR, "W-PREC: cannot retrieve freebusy %s", par.cur.dirc());
11871188

11881189
for (const freebusy_event &event : fbdata)
@@ -1197,9 +1198,11 @@ static ec_error_t mr_do_request(rxparam &par, const PROPID_ARRAY &propids,
11971198

11981199
/* Decline double-booking if so configured */
11991200
if (res_in_use && policy.decline_overlap) {
1200-
auto err = mr_send_response(par, recurring_flg, propids, respDeclined);
1201-
if (err != ecSuccess)
1202-
return err;
1201+
if (response_allowed) {
1202+
auto err = mr_send_response(par, recurring_flg, propids, respDeclined);
1203+
if (err != ecSuccess)
1204+
return err;
1205+
}
12031206
return mr_mark_done(par);
12041207
}
12051208

@@ -1212,9 +1215,11 @@ static ec_error_t mr_do_request(rxparam &par, const PROPID_ARRAY &propids,
12121215
if (policy.is_resource())
12131216
return mr_mark_done(par);
12141217
if (tent == respAccepted) {
1215-
err = mr_send_response(par, recurring_flg, propids, tent);
1216-
if (err != ecSuccess)
1217-
return err;
1218+
if (response_allowed) {
1219+
err = mr_send_response(par, recurring_flg, propids, tent);
1220+
if (err != ecSuccess)
1221+
return err;
1222+
}
12181223
return mr_mark_done(par);
12191224
}
12201225
return ecSuccess;

0 commit comments

Comments
 (0)