From 3b634eb3b085406355924fec695a0507a9c625ec Mon Sep 17 00:00:00 2001 From: zacheiss Date: Wed, 17 Oct 2001 21:34:06 +0000 Subject: [PATCH] Deal with tracking creation times for users. --- server/mr_server.h | 3 ++ server/qfollow.pc | 46 +++++++++++++++++++++++++++++ server/qsetup.pc | 6 ++++ server/qsupport.pc | 3 +- server/queries2.c | 73 +++++++++++++++++++++++++--------------------- 5 files changed, 96 insertions(+), 35 deletions(-) diff --git a/server/mr_server.h b/server/mr_server.h index 1fb83e92..c1b8d0d8 100644 --- a/server/mr_server.h +++ b/server/mr_server.h @@ -191,6 +191,9 @@ int followup_gpsv(struct query *q, struct save_queue *sq, struct validate *v, int followup_gcon(struct query *q, struct save_queue *sq, struct validate *v, int (*action)(int, char **, void *), void *actarg, client *cl); +int followup_get_user(struct query *q, struct save_queue *sq, + struct validate *v, int (*action)(int, char **, void *), + void *actarg, client *cl); int followup_ausr(struct query *q, char *argv[], client *cl); int followup_aqot(struct query *q, char *argv[], client *cl); diff --git a/server/qfollow.pc b/server/qfollow.pc index 4f7d344d..08ea6aba 100644 --- a/server/qfollow.pc +++ b/server/qfollow.pc @@ -1000,3 +1000,49 @@ int followup_gcon(struct query *q, struct save_queue *sq, struct validate *v, 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; + + (*action)(q->vcnt, argv, actarg); + for (k = 0; k < q->vcnt; k++) + free(argv[k]); + free(argv); + } + sq_destroy(sq); + return MR_SUCCESS; +} + + + + diff --git a/server/qsetup.pc b/server/qsetup.pc index 573d7c61..62484540 100644 --- a/server/qsetup.pc +++ b/server/qsetup.pc @@ -91,6 +91,12 @@ int setup_ausr(struct query *q, char *argv[], client *cl) if ((mr_errcode = prefetch_value(q, argv, cl)) != MR_SUCCESS) return mr_errcode; + /* If this is an UPDATE query, we're done. */ + if (row == 2) + return MR_SUCCESS; + + /* For an add query, we need to fill in the creator id. */ + sprintf(argv[q->argc + q->vcnt + 1], "%d", cl->client_id); return MR_SUCCESS; } diff --git a/server/qsupport.pc b/server/qsupport.pc index 85c54490..0a29f0ce 100644 --- a/server/qsupport.pc +++ b/server/qsupport.pc @@ -1627,7 +1627,8 @@ int register_user(struct query *q, char **argv, client *cl) nstatus = 1; EXEC SQL UPDATE users SET login = :login, status = :nstatus, modtime = SYSDATE, modby = :who, modwith = :entity, - pmodtime = SYSDATE, pmodby = :who, pmodwith = :entity + pmodtime = SYSDATE, pmodby = :who, pmodwith = :entity, + created = SYSDATE, creator = :who WHERE users_id = :users_id; if (dbms_errno) diff --git a/server/queries2.c b/server/queries2.c index f08463b5..485e4ed0 100644 --- a/server/queries2.c +++ b/server/queries2.c @@ -90,7 +90,7 @@ static char *gual_fields[] = { "login", "login", "unix_uid", "shell", "winconsoleshell", "last", "first", "middle", "status", "clearid", "class", "comments", "signature", "secure", - "modtime", "modby", "modwith", + "modtime", "modby", "modwith", "created", "creator", }; static char *gubl2_fields[] = { @@ -102,7 +102,8 @@ static char *gubl2_fields[] = { static char *gubl_fields[] = { "login", "login", "unix_uid", "shell", "winconsoleshell", "last", "first", "middle", - "status", "clearid", "class", "modtime", "modby", "modwith", + "status", "clearid", "class", "modtime", "modby", "modwith", "created", + "creator", }; static struct validate gubl_validate = @@ -115,7 +116,7 @@ static struct validate gubl_validate = 0, access_login, 0, - followup_fix_modby, + followup_get_user, }; static char *guau2_fields[] = { @@ -129,7 +130,7 @@ static char *guau_fields[] = { "unix_uid", "login", "unix_uid", "shell", "winconsoleshell", "last", "first", "middle", "status", "clearid", "class", "comments", "signature", "secure", - "modtime", "modby", "modwith", + "modtime", "modby", "modwith", "created", "creator", }; static char *guan2_fields[] = { @@ -143,7 +144,7 @@ static char *guan_fields[] = { "first", "last", "login", "unix_uid", "shell", "winconsoleshell", "last", "first", "middle", "status", "clearid", "class", "comments", "signature", "secure", - "modtime", "modby", "modwith", + "modtime", "modby", "modwith", "created", "creator", }; static struct validate guan_validate = @@ -156,7 +157,7 @@ static struct validate guan_validate = 0, 0, 0, - followup_fix_modby, + followup_get_user, }; static char *guac2_fields[] = { @@ -170,7 +171,7 @@ static char *guac_fields[] = { "class", "login", "unix_uid", "shell", "winconsoleshell", "last", "first", "middle", "status", "clearid", "class", "comments", "signature", "secure", - "modtime", "modby", "modwith", + "modtime", "modby", "modwith", "created", "creator", }; static char *guam2_fields[] = { @@ -184,7 +185,7 @@ static char *guam_fields[] = { "clearid", "login", "unix_uid", "shell", "winconsoleshell", "last", "first", "middle", "status", "clearid", "class", "comments", "signature", "secure", - "modtime", "modby", "modwith", + "modtime", "modby", "modwith", "created", "creator", }; static char *gubu2_fields[] = { @@ -196,7 +197,8 @@ static char *gubu2_fields[] = { static char *gubu_fields[] = { "unix_uid", "login", "unix_uid", "shell", "winconsoleshell", "last", "first", "middle", - "status", "clearid", "class", "modtime", "modby", "modwith", + "status", "clearid", "class", "modtime", "modby", "modwith", "created", + "creator", }; static struct validate gubu_validate = @@ -209,7 +211,7 @@ static struct validate gubu_validate = 0, access_login, 0, - followup_fix_modby, + followup_get_user, }; static char *gubn2_fields[] = { @@ -221,7 +223,8 @@ static char *gubn2_fields[] = { static char *gubn_fields[] = { "first", "last", "login", "unix_uid", "shell", "winconsoleshell", "last", "first", "middle", - "status", "clearid", "class", "modtime", "modby", "modwith", + "status", "clearid", "class", "modtime", "modby", "modwith", "created", + "creator", }; static struct validate gubn_validate = @@ -234,7 +237,7 @@ static struct validate gubn_validate = 0, 0, 0, - followup_fix_modby, + followup_get_user, }; static char *gubc2_fields[] = { @@ -247,6 +250,7 @@ static char *gubc_fields[] = { "class", "login", "unix_uid", "shell", "winconsoleshell", "last", "first", "middle", "status", "clearid", "class", "modtime", "modby", "modwith", + "created", "creator", }; static char *gubm2_fields[] = { @@ -259,6 +263,7 @@ static char *gubm_fields[] = { "clearid", "login", "unix_uid", "shell", "winconsoleshell", "last", "first", "middle", "status", "clearid", "class", "modtime", "modby", "modwith", + "created", "creator", }; static char *auac2_fields[] = { @@ -3570,9 +3575,9 @@ struct query Queries[] = { RETRIEVE, "u", USERS_TABLE, - "u.login, u.unix_uid, u.shell, u.winconsoleshell, u.last, u.first, u.middle, u.status, u.clearid, u.type, str.string, CHR(0), u.secure, TO_CHAR(u.modtime, 'DD-mon-YYYY HH24:MI:SS'), u.modby, u.modwith FROM users u, strings str", + "u.login, u.unix_uid, u.shell, u.winconsoleshell, u.last, u.first, u.middle, u.status, u.clearid, u.type, str.string, CHR(0), u.secure, TO_CHAR(u.modtime, 'DD-mon-YYYY HH24:MI:SS'), u.modby, u.modwith, TO_CHAR(u.created, 'DD-mon-YYYY HH24:MI:SS'), u.creator FROM users u, strings str", gual_fields, - 16, + 18, "u.login LIKE '%s' AND u.users_id != 0 AND u.comments = str.string_id", 1, "u.login", @@ -3604,9 +3609,9 @@ struct query Queries[] = { RETRIEVE, "u", USERS_TABLE, - "u.login, u.unix_uid, u.shell, u.winconsoleshell, u.last, u.first, u.middle, u.status, u.clearid, u.type, str.string, CHR(0), u.secure, TO_CHAR(u.modtime, 'DD-mon-YYYY HH24:MI:SS'), u.modby, u.modwith FROM users u, strings str", + "u.login, u.unix_uid, u.shell, u.winconsoleshell, u.last, u.first, u.middle, u.status, u.clearid, u.type, str.string, CHR(0), u.secure, TO_CHAR(u.modtime, 'DD-mon-YYYY HH24:MI:SS'), u.modby, u.modwith, TO_CHAR(u.created, 'DD-mon-YYYY HH24:MI:SS'), u.creator FROM users u, strings str", guau_fields, - 16, + 18, "u.unix_uid = %s AND u.users_id != 0 AND u.comments = str.string_id", 1, "u.login", @@ -3638,9 +3643,9 @@ struct query Queries[] = { RETRIEVE, "u", USERS_TABLE, - "u.login, u.unix_uid, u.shell, u.winconsoleshell, u.last, u.first, u.middle, u.status, u.clearid, u.type, str.string, CHR(0), u.secure, TO_CHAR(u.modtime, 'DD-mon-YYYY HH24:MI:SS'), u.modby, u.modwith FROM users u, strings str", + "u.login, u.unix_uid, u.shell, u.winconsoleshell, u.last, u.first, u.middle, u.status, u.clearid, u.type, str.string, CHR(0), u.secure, TO_CHAR(u.modtime, 'DD-mon-YYYY HH24:MI:SS'), u.modby, u.modwith, TO_CHAR(u.created, 'DD-mon-YYYY HH24:MI:SS'), u.creator FROM users u, strings str", guan_fields, - 16, + 18, "u.first LIKE '%s' AND u.last LIKE '%s' AND u.users_id != 0 and u.comments = str.string_id", 2, "u.login", @@ -3672,9 +3677,9 @@ struct query Queries[] = { RETRIEVE, "u", USERS_TABLE, - "u.login, u.unix_uid, u.shell, u.winconsoleshell, u.last, u.first, u.middle, u.status, u.clearid, u.type, str.string, CHR(0), u.secure, TO_CHAR(u.modtime, 'DD-mon-YYYY HH24:MI:SS'), u.modby, u.modwith FROM users u, strings str", + "u.login, u.unix_uid, u.shell, u.winconsoleshell, u.last, u.first, u.middle, u.status, u.clearid, u.type, str.string, CHR(0), u.secure, TO_CHAR(u.modtime, 'DD-mon-YYYY HH24:MI:SS'), u.modby, u.modwith, TO_CHAR(u.created, 'DD-mon-YYYY HH24:MI:SS'), u.creator FROM users u, strings str", guac_fields, - 16, + 18, "u.type = UPPER('%s') AND u.users_id != 0 AND u.comments = str.string_id", 1, "u.login", @@ -3706,9 +3711,9 @@ struct query Queries[] = { RETRIEVE, "u", USERS_TABLE, - "u.login, u.unix_uid, u.shell, u.winconsoleshell, u.last, u.first, u.middle, u.status, u.clearid, u.type, str.string, CHR(0), u.secure, TO_CHAR(u.modtime, 'DD-mon-YYYY HH24:MI:SS'), u.modby, u.modwith FROM users u, strings str", + "u.login, u.unix_uid, u.shell, u.winconsoleshell, u.last, u.first, u.middle, u.status, u.clearid, u.type, str.string, CHR(0), u.secure, TO_CHAR(u.modtime, 'DD-mon-YYYY HH24:MI:SS'), u.modby, u.modwith, TO_CHAR(u.created, 'DD-mon-YYYY HH24:MI:SS'), u.creator FROM users u, strings str", guam_fields, - 16, + 18, "u.clearid LIKE '%s' AND u.users_id != 0 AND u.comments = str.string_id", 1, "u.login", @@ -3740,9 +3745,9 @@ struct query Queries[] = { RETRIEVE, "u", USERS_TABLE, - "u.login, u.unix_uid, u.shell, u.winconsoleshell, u.last, u.first, u.middle, u.status, u.clearid, u.type, TO_CHAR(u.modtime, 'DD-mon-YYYY HH24:MI:SS'), u.modby, u.modwith FROM users u", + "u.login, u.unix_uid, u.shell, u.winconsoleshell, u.last, u.first, u.middle, u.status, u.clearid, u.type, TO_CHAR(u.modtime, 'DD-mon-YYYY HH24:MI:SS'), u.modby, u.modwith, TO_CHAR(u.created, 'DD-mon-YYYY HH24:MI:SS'), u.creator FROM users u", gubl_fields, - 13, + 15, "u.login LIKE '%s' AND u.users_id != 0", 1, "u.login", @@ -3774,9 +3779,9 @@ struct query Queries[] = { RETRIEVE, "u", USERS_TABLE, - "u.login, u.unix_uid, u.shell, u.winconsoleshell, u.last, u.first, u.middle, u.status, u.clearid, u.type, TO_CHAR(u.modtime, 'DD-mon-YYYY HH24:MI:SS'), u.modby, u.modwith FROM users u", + "u.login, u.unix_uid, u.shell, u.winconsoleshell, u.last, u.first, u.middle, u.status, u.clearid, u.type, TO_CHAR(u.modtime, 'DD-mon-YYYY HH24:MI:SS'), u.modby, u.modwith, TO_CHAR(u.created, 'DD-mon-YYYY HH24:MI:SS'), u.creator FROM users u", gubu_fields, - 13, + 15, "u.unix_uid = %s AND u.users_id != 0", 1, "u.login", @@ -3808,9 +3813,9 @@ struct query Queries[] = { RETRIEVE, "u", USERS_TABLE, - "u.login, u.unix_uid, u.shell, u.winconsoleshell, u.last, u.first, u.middle, u.status, u.clearid, u.type, TO_CHAR(u.modtime, 'DD-mon-YYYY HH24:MI:SS'), u.modby, u.modwith FROM users u", + "u.login, u.unix_uid, u.shell, u.winconsoleshell, u.last, u.first, u.middle, u.status, u.clearid, u.type, TO_CHAR(u.modtime, 'DD-mon-YYYY HH24:MI:SS'), u.modby, u.modwith, TO_CHAR(u.created, 'DD-mon-YYYY HH24:MI:SS'), u.creator FROM users u", gubn_fields, - 13, + 15, "u.first LIKE '%s' AND u.last LIKE '%s' AND u.users_id != 0", 2, "u.login", @@ -3842,9 +3847,9 @@ struct query Queries[] = { RETRIEVE, "u", USERS_TABLE, - "u.login, u.unix_uid, u.shell, u.winconsoleshell, u.last, u.first, u.middle, u.status, u.clearid, u.type, TO_CHAR(u.modtime, 'DD-mon-YYYY HH24:MI:SS'), u.modby, u.modwith FROM users u", + "u.login, u.unix_uid, u.shell, u.winconsoleshell, u.last, u.first, u.middle, u.status, u.clearid, u.type, TO_CHAR(u.modtime, 'DD-mon-YYYY HH24:MI:SS'), u.modby, u.modwith, TO_CHAR(u.created, 'DD-mon-YYYY HH24:MI:SS') FROM users u", gubc_fields, - 13, + 15, "u.type = UPPER('%s') AND u.users_id != 0", 1, "u.login", @@ -3876,9 +3881,9 @@ struct query Queries[] = { RETRIEVE, "u", USERS_TABLE, - "u.login, u.unix_uid, u.shell, u.winconsoleshell, u.last, u.first, u.middle, u.status, u.clearid, u.type, TO_CHAR(u.modtime, 'DD-mon-YYYY HH24:MI:SS'), u.modby, u.modwith FROM users u", + "u.login, u.unix_uid, u.shell, u.winconsoleshell, u.last, u.first, u.middle, u.status, u.clearid, u.type, TO_CHAR(u.modtime, 'DD-mon-YYYY HH24:MI:SS'), u.modby, u.modwith, TO_CHAR(u.created, 'DD-mon-YYYY HH24:MI:SS'), u.creator FROM users u", gubm_fields, - 13, + 15, "u.clearid LIKE '%s' AND u.users_id != 0", 1, "u.login", @@ -3916,7 +3921,7 @@ struct query Queries[] = { /* We set signature to "NVL(CHR(0), '%s')", which is to say, "CHR(0)", * but using up one argv element. */ - "INTO users (login, unix_uid, shell, winconsoleshell, last, first, middle, status, clearid, type, comments, signature, secure, users_id) VALUES ('%s', %s, '%s', NVL('%s', CHR(0)), NVL('%s', CHR(0)), NVL('%s', CHR(0)), NVL('%s', CHR(0)), %s, NVL('%s', CHR(0)), '%s', %d, NVL(CHR(0), '%s'), %s, %s)", + "INTO users (login, unix_uid, shell, winconsoleshell, last, first, middle, status, clearid, type, comments, signature, secure, users_id, created, creator) VALUES ('%s', %s, '%s', NVL('%s', CHR(0)), NVL('%s', CHR(0)), NVL('%s', CHR(0)), NVL('%s', CHR(0)), %s, NVL('%s', CHR(0)), '%s', %d, NVL(CHR(0), '%s'), %s, %s, SYSDATE, %s)", auac_fields, 13, NULL, @@ -3950,7 +3955,7 @@ struct query Queries[] = { APPEND, "u", USERS_TABLE, - "INTO users (login, unix_uid, shell, winconsoleshell, last, first, middle, status, clearid, type, comments, signature, secure, users_id) VALUES ('%s', %s, '%s', NVL('%s', CHR(0)), NVL('%s', CHR(0)), NVL('%s', CHR(0)), %s, NVL('%s', CHR(0)), '%s', 0, CHR(0), 0, %s)", + "INTO users (login, unix_uid, shell, winconsoleshell, last, first, middle, status, clearid, type, comments, signature, secure, users_id, created, creator) VALUES ('%s', %s, '%s', NVL('%s', CHR(0)), NVL('%s', CHR(0)), NVL('%s', CHR(0)), %s, NVL('%s', CHR(0)), '%s', 0, CHR(0), 0, %s, SYSDATE, %s)", auac_fields, 10, 0, -- 2.45.1