X-Git-Url: http://andersk.mit.edu/gitweb/moira.git/blobdiff_plain/59c3208b3b5a7b09f5f7cf04f225600008327cc1..f0ce8752af6b6aa13ed7fdc827b2a2cd8150b4d2:/server/qfollow.pc diff --git a/server/qfollow.pc b/server/qfollow.pc index 54854f4b..6ae39f92 100644 --- a/server/qfollow.pc +++ b/server/qfollow.pc @@ -394,7 +394,7 @@ int followup_gpob(struct query *q, struct save_queue *sq, struct validate *v, char *ptype, *p; int mid, sid, status, i; EXEC SQL BEGIN DECLARE SECTION; - int users_id, pid, iid, bid; + int users_id, pid, iid, bid, eid; char mach[MACHINE_NAME_SIZE], fs[FILESYS_LABEL_SIZE]; char str[STRINGS_STRING_SIZE]; EXEC SQL END DECLARE SECTION; @@ -406,7 +406,7 @@ int followup_gpob(struct query *q, struct save_queue *sq, struct validate *v, ptype = argv[1]; users_id = atoi(argv[2]); - EXEC SQL SELECT pop_id, imap_id, box_id INTO :pid, :iid, :bid + EXEC SQL SELECT pop_id, imap_id, box_id, exchange_id INTO :pid, :iid, :bid, :eid FROM users WHERE users_id = :users_id; if (sqlca.sqlcode) return MR_USER; @@ -421,7 +421,7 @@ int followup_gpob(struct query *q, struct save_queue *sq, struct validate *v, /* If SMTP, don't bother fetching IMAP and POP boxes. */ if (ptype[1] == 'M') - pid = iid = 0; + pid = iid = eid = 0; } if (iid) { @@ -440,12 +440,20 @@ int followup_gpob(struct query *q, struct save_queue *sq, struct validate *v, if (sqlca.sqlcode) return MR_MACHINE; } + if (eid) + { + /* EXCHANGE, or SPLIT with EXCHANGE */ + EXEC SQL SELECT m.name INTO :mach FROM machine m, users u + WHERE u.users_id = :users_id AND u.exchange_id = m.mach_id; + if (sqlca.sqlcode) + return MR_MACHINE; + } free(argv[2]); free(argv[3]); /* Now assemble the right answer. */ - if (!strcmp(ptype, "POP")) + if (!strcmp(ptype, "POP") || !strcmp(ptype, "EXCHANGE")) { argv[2] = xstrdup(strtrim(mach)); argv[3] = xmalloc(strlen(argv[0]) + strlen(argv[2]) + 2); @@ -526,13 +534,18 @@ int followup_gsnt(struct query *q, struct save_queue *sq, struct validate *v, client *cl) { char **argv; - int status; + int status, idx; + + if (q->version < 8) + idx = 0; + else + idx = 3; while (sq_get_data(sq, &argv)) { mr_trim_args(q->vcnt, argv); - status = fix_ace(argv[7], &argv[8]); + status = fix_ace(argv[7 + idx], &argv[8 + idx]); if (status && status != MR_NO_MATCH) return status; } @@ -548,29 +561,36 @@ int followup_ghst(struct query *q, struct save_queue *sq, struct validate *v, client *cl) { char **argv; - int id, status; + int id, status, idx; + + if (q->version < 6) + idx = 0; + else if (q->version >= 6 && q->version < 8) + idx = 1; + else + idx = 2; while (sq_get_data(sq, &argv)) { mr_trim_args(q->vcnt, argv); - id = atoi(argv[13]); - status = id_to_name(id, STRINGS_TABLE, &argv[13]); + id = atoi(argv[13 + idx]); + status = id_to_name(id, STRINGS_TABLE, &argv[13 + idx]); if (status) return status; - id = atoi(argv[14]); - status = id_to_name(id, STRINGS_TABLE, &argv[14]); + id = atoi(argv[14 + idx]); + status = id_to_name(id, STRINGS_TABLE, &argv[14 + idx]); if (status) return status; - id = atoi(argv[16]); + id = atoi(argv[16 + idx]); if (id < 0) - status = id_to_name(-id, STRINGS_TABLE, &argv[16]); + status = id_to_name(-id, STRINGS_TABLE, &argv[16 + idx]); else - status = id_to_name(id, USERS_TABLE, &argv[16]); + status = id_to_name(id, USERS_TABLE, &argv[16 + idx]); if (status && status != MR_NO_MATCH) return status; - status = fix_ace(argv[11], &argv[12]); + status = fix_ace(argv[11 + idx], &argv[12 + idx]); if (status && status != MR_NO_MATCH) return status; } @@ -594,13 +614,21 @@ int followup_glin(struct query *q, struct save_queue *sq, struct validate *v, if (q->version == 2) status = fix_ace(argv[7], &argv[8]); - else + else if (q->version > 2 && q->version < 10) status = fix_ace(argv[8], &argv[9]); + else + status = fix_ace(argv[10], &argv[11]); + if (status && status != MR_NO_MATCH) return status; + if (q->version > 3) { - status = fix_ace(argv[10], &argv[11]); + if (q->version < 10) + status = fix_ace(argv[10], &argv[11]); + else if (q->version >= 10) + status = fix_ace(argv[12], &argv[13]); + if (status && status != MR_NO_MATCH) return status; } @@ -788,7 +816,7 @@ int followup_aqot(struct query *q, char *argv[], client *cl) * conflicts between what is possible in the query table and what * is possible in SQL. */ - if (q->type == APPEND) + if (q->type == MR_Q_APPEND) { incremental_clear_before(); EXEC SQL INSERT INTO quota @@ -807,8 +835,7 @@ int followup_aqot(struct query *q, char *argv[], client *cl) if (dbms_errno) return mr_errcode; - flush_name(argv[0], table); - if (q->type == APPEND) + if (q->type == MR_Q_APPEND) { EXEC SQL UPDATE tblstats SET appends = appends + 1, modtime = SYSDATE WHERE table_name = :tname; @@ -872,7 +899,6 @@ int followup_dqot(struct query *q, char **argv, client *cl) if (dbms_errno) return mr_errcode; - flush_name(argv[0], table); EXEC SQL UPDATE tblstats SET deletes = deletes + 1, modtime = SYSDATE WHERE table_name = :tname; @@ -886,14 +912,19 @@ int followup_gzcl(struct query *q, struct save_queue *sq, struct validate *v, int (*action)(int, char *[], void *), void *actarg, client *cl) { - int i, status; + int i, n, status; char **argv; + if (q->version < 5) + n = 8; + else + n = 10; + while (sq_get_data(sq, &argv)) { mr_trim_args(q->vcnt, argv); - for (i = 1; i < 8; i += 2) + for (i = 1; i < n; i += 2) { status = fix_ace(argv[i], &argv[i + 1]); if (status && status != MR_NO_MATCH) @@ -959,3 +990,81 @@ int trigger_dcm(struct query *q, char *argv[], client *cl) return MR_SUCCESS; } } + +/* followup_gcon: fix the ace_name, memace_name, and modby */ + +int followup_gcon(struct query *q, struct save_queue *sq, struct validate *v, + int (*action)(int, char *[], void *), void *actarg, + client *cl) +{ + char **argv; + int status, idx = 0; + + if (q->version >= 9) + idx = 1; + + while (sq_get_data(sq, &argv)) + { + mr_trim_args(q->vcnt, argv); + + status = fix_ace(argv[4 + idx], &argv[5 + idx]); + if (status && status != MR_NO_MATCH) + return status; + + status = fix_ace(argv[6 + idx], &argv[7 + idx]); + if (status && status != MR_NO_MATCH) + return status; + } + + return followup_fix_modby(q, sq, v, action, actarg, cl); +} + +/* followup_get_user: fix the modby and creator. + * This assumes that the modby and creator fields are always + * in the same relative position in the argv. + */ + +int followup_get_user(struct query *q, struct save_queue *sq, struct + validate *v, int (*action)(int, char *[], void *), + void *actarg, client *cl) +{ + char **argv; + int i, j, k, status, id; + + i = q->vcnt - 4; + j = q->vcnt - 1; + while (sq_get_data(sq, &argv)) + { + mr_trim_args(q->vcnt, argv); + + id = atoi(argv[i]); + if (id > 0) + status = id_to_name(id, USERS_TABLE, &argv[i]); + else + status = id_to_name(-id, STRINGS_TABLE, &argv[i]); + if (status && status != MR_NO_MATCH) + return status; + + id = atoi(argv[j]); + if (id > 0) + status = id_to_name(id, USERS_TABLE, &argv[j]); + else + status = id_to_name(-id, STRINGS_TABLE, &argv[j]); + if (status && status != MR_NO_MATCH) + return status; + + if (q->version > 11) + { + status = fix_ace(argv[15], &argv[16]); + if (status && status != MR_NO_MATCH) + return status; + } + + (*action)(q->vcnt, argv, actarg); + for (k = 0; k < q->vcnt; k++) + free(argv[k]); + free(argv); + } + sq_destroy(sq); + return MR_SUCCESS; +}