]> andersk Git - moira.git/commitdiff
Deal with tracking creation times for users.
authorzacheiss <zacheiss>
Wed, 17 Oct 2001 21:34:06 +0000 (21:34 +0000)
committerzacheiss <zacheiss>
Wed, 17 Oct 2001 21:34:06 +0000 (21:34 +0000)
server/mr_server.h
server/qfollow.pc
server/qsetup.pc
server/qsupport.pc
server/queries2.c

index 1fb83e92cb8eaa88b4874e22406f4647ca43d64f..c1b8d0d86e0a72823cd0f3c020b3472a984a0434 100644 (file)
@@ -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);
index 4f7d344daa17fb064cbc1e842caeff175103562d..08ea6aba84bb51e96ea1dc546d6c7041f51a8dcd 100644 (file)
@@ -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;
+}
+
+
+
+
index 573d7c61104639adeea00c4618b73cd2aa450c7f..624845405a0522fea2677ce6478eb124d70587db 100644 (file)
@@ -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;
 }
 
index 85c5449018d18d5d5fa6693b771c6a16e9a44600..0a29f0cece01dec0773d59c0497041aed02b470a 100644 (file)
@@ -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)
index f08463b55da5db4dabda12e0ec97e7873e8dad58..485e4ed00b6cdf7020cbc10c3b4f1fc92a6a6c28 100644 (file)
@@ -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,
This page took 0.318339 seconds and 5 git commands to generate.