6 * Copyright (C) 1987 by the Massachusetts Institute of Technology
7 * For copying and distribution information, please see the file
13 static char *rcsid_qsupport_dc = "$Header$";
16 #include <mit-copyright.h>
17 #include "mr_server.h"
24 EXEC SQL INCLUDE sqlca;
27 extern char *whoami, *table_name[];
28 extern int dbms_errno, mr_errcode;
30 EXEC SQL BEGIN DECLARE SECTION;
31 extern char stmt_buf[];
32 EXEC SQL END DECLARE SECTION;
34 static void hex_dump(unsigned char *p);
36 EXEC SQL WHENEVER SQLERROR DO dbmserr();
39 /* FOLLOWUP ROUTINES */
41 /* generic set_modtime routine. This takes the table id from the query,
42 * and will update the modtime, modby, and modwho fields in the entry in
43 * the table whose name field matches argv[0].
46 int set_modtime(struct query *q, char *argv[], client *cl)
48 char *name, *entity, *table;
53 table = table_name[q->rtable];
56 sprintf(stmt_buf, "UPDATE %s SET modtime = SYSDATE, modby = %d, "
57 "modwith = '%s' WHERE name = '%s'", table, who, entity, name);
58 EXEC SQL EXECUTE IMMEDIATE :stmt_buf;
63 /* generic set_modtime_by_id routine. This takes the table id from
64 * the query, and the id name from the validate record,
65 * and will update the modtime, modby, and modwho fields in the entry in
66 * the table whose id matches argv[0].
69 int set_modtime_by_id(struct query *q, char *argv[], client *cl)
71 char *entity, *table, *id_name;
76 table = table_name[q->rtable];
77 id_name = q->validate->object_id;
80 sprintf(stmt_buf, "UPDATE %s SET modtime = SYSDATE, modby = %d, "
81 "modwith = '%s' WHERE %s = %d", table, who, entity, id_name, id);
82 EXEC SQL EXECUTE IMMEDIATE :stmt_buf;
87 /* Sets the finger modtime on a user record. The users_id will be in argv[0].
90 int set_finger_modtime(struct query *q, char *argv[], client *cl)
92 EXEC SQL BEGIN DECLARE SECTION;
95 EXEC SQL END DECLARE SECTION;
99 users_id = *(int *)argv[0];
101 EXEC SQL UPDATE users SET fmodtime = SYSDATE, fmodby = :who,
102 fmodwith = :entity WHERE users_id = :users_id;
108 /* Sets the pobox modtime on a user record. The users_id will be in argv[0].
111 int set_pobox_modtime(struct query *q, char *argv[], client *cl)
113 EXEC SQL BEGIN DECLARE SECTION;
116 EXEC SQL END DECLARE SECTION;
120 users_id = *(int *)argv[0];
122 EXEC SQL UPDATE users SET pmodtime = SYSDATE, pmodby = :who,
123 pmodwith = :entity WHERE users_id = :users_id;
129 /* Like set_modtime, but uppercases the name first.
132 int set_uppercase_modtime(struct query *q, char *argv[], client *cl)
134 char *name, *entity, *table;
139 table = table_name[q->rtable];
142 sprintf(stmt_buf, "UPDATE %s SET modtime = SYSDATE, modby = %d, "
143 "modwith = '%s' WHERE name = UPPER('%s')", table, who, entity, name);
144 EXEC SQL EXECUTE IMMEDIATE :stmt_buf;
150 /* Sets the modtime on the machine whose mach_id is in argv[0]. This routine
151 * is necessary for add_machine_to_cluster becuase the table that query
152 * operates on is "mcm", not "machine".
155 int set_mach_modtime_by_id(struct query *q, char *argv[], client *cl)
157 EXEC SQL BEGIN DECLARE SECTION;
160 EXEC SQL END DECLARE SECTION;
164 id = *(int *)argv[0];
165 EXEC SQL UPDATE machine SET modtime = SYSDATE, modby = :who,
166 modwith = :entity WHERE mach_id = :id;
172 /* Sets the modtime on the cluster whose mach_id is in argv[0]. This routine
173 * is necessary for add_cluster_data and delete_cluster_data becuase the
174 * table that query operates on is "svc", not "cluster".
177 int set_cluster_modtime_by_id(struct query *q, char *argv[], client *cl)
179 EXEC SQL BEGIN DECLARE SECTION;
182 EXEC SQL END DECLARE SECTION;
187 id = *(int *)argv[0];
188 EXEC SQL UPDATE clusters SET modtime = SYSDATE, modby = :who,
189 modwith = :entity WHERE clu_id = :id;
194 /* sets the modtime on the serverhost where the service name is in argv[0]
195 * and the mach_id is in argv[1].
198 int set_serverhost_modtime(struct query *q, char *argv[], client *cl)
200 EXEC SQL BEGIN DECLARE SECTION;
203 EXEC SQL END DECLARE SECTION;
209 id = *(int *)argv[1];
210 EXEC SQL UPDATE serverhosts
211 SET modtime = SYSDATE, modby = :who, modwith = :entity
212 WHERE service = :serv AND mach_id = :id;
217 /* sets the modtime on the nfsphys where the mach_id is in argv[0] and the
218 * directory name is in argv[1].
221 int set_nfsphys_modtime(struct query *q, char *argv[], client *cl)
223 EXEC SQL BEGIN DECLARE SECTION;
226 EXEC SQL END DECLARE SECTION;
231 id = *(int *)argv[0];
233 EXEC SQL UPDATE nfsphys SET modtime = SYSDATE, modby = :who,
234 modwith = :entity WHERE dir = :dir AND mach_id = :id;
239 /* sets the modtime on a filesystem, where argv[0] contains the filesys
243 int set_filesys_modtime(struct query *q, char *argv[], client *cl)
245 EXEC SQL BEGIN DECLARE SECTION;
246 char *label, *entity;
248 extern int _var_phys_id;
249 EXEC SQL END DECLARE SECTION;
255 if (!strcmp(q->shortname, "ufil"))
258 EXEC SQL UPDATE filesys SET modtime = SYSDATE, modby = :who,
259 modwith = :entity, phys_id = :_var_phys_id
260 WHERE label = :label;
265 /* sets the modtime on a zephyr class, where argv[0] contains the class
269 int set_zephyr_modtime(struct query *q, char *argv[], client *cl)
271 EXEC SQL BEGIN DECLARE SECTION;
272 char *class, *entity;
274 EXEC SQL END DECLARE SECTION;
281 EXEC SQL UPDATE zephyr SET modtime = SYSDATE, modby = :who,
282 modwith = :entity WHERE class = :class;
288 /* fixes the modby field. This will be the second to last thing in the
289 * argv, the argv length is determined from the query structure. It is
290 * passed as a pointer to an integer. This will either turn it into a
291 * username, or # + the users_id.
293 int followup_fix_modby(struct query *q, struct save_queue *sq,
294 struct validate *v, int (*action)(), int actarg,
302 while (sq_get_data(sq, &argv))
306 status = id_to_name(id, USERS_TABLE, &argv[i]);
308 status = id_to_name(-id, STRINGS_TABLE, &argv[i]);
309 if (status && status != MR_NO_MATCH)
311 (*action)(q->vcnt, argv, actarg);
312 for (j = 0; j < q->vcnt; j++)
321 /* After retrieving a user account, fix the modby field and signature.
322 * The modby field is the second to last thing in the
323 * argv, the argv length is determined from the query structure. It is
324 * passed as a pointer to an integer. This will either turn it into a
325 * username, or # + the users_id. Only "gua*" queries have a signature,
326 * these are ones with U_END return values. "gub*" queries also use this
327 * routine but don't have a signature.
329 int followup_guax(struct query *q, struct save_queue *sq, struct validate *v,
330 int (*action)(), int actarg, client *cl)
335 unsigned char sigbuf[256];
338 EXEC SQL BEGIN DECLARE SECTION;
339 int timestamp, who, siglen;
342 EXEC SQL VAR rsig IS STRING(256);
343 EXEC SQL END DECLARE SECTION;
348 while (sq_get_data(sq, &argv))
352 status = id_to_name(id, USERS_TABLE, &argv[i]);
354 status = id_to_name(-id, STRINGS_TABLE, &argv[i]);
355 if (status && status != MR_NO_MATCH)
358 if (q->vcnt == U_END && strlen(argv[U_SIGNATURE]))
360 login = strtrim(argv[U_NAME]);
361 EXEC SQL SELECT signature, sigdate, sigwho
362 INTO :rsig, :timestamp, :who FROM users
363 WHERE login = :login;
367 status = id_to_name(who, STRINGS_TABLE, &kname);
368 si.timestamp = timestamp;
369 si.SigInfoVersion = 0; /* XXXXX this isn't used */
370 kname_parse(si.pname, si.pinst, si.prealm, kname);
372 si.rawsig = (unsigned char *)strsave(rsig);
373 if (log_flags & LOG_GDSS)
374 com_err(whoami, 0, "rawsig length = %d, sig=\"%s\"",
375 strlen(si.rawsig), si.rawsig);
376 GDSS_Recompose(&si, sigbuf);
378 free(argv[U_SIGNATURE]);
379 argv[U_SIGNATURE] = strsave(sigbuf);
380 if (log_flags & LOG_GDSS)
381 com_err(whoami, 0, "generated signature length %d",
385 (*action)(q->vcnt, argv, actarg);
386 for (j = 0; j < q->vcnt; j++)
396 ** followup_ausr - add finger and pobox entries, set_user_modtime
399 ** argv[0] - login (add_user)
400 ** argv[3] - last name
401 ** argv[4] - first name
402 ** argv[5] - middle name
406 int followup_ausr(struct query *q, char *argv[], client *cl)
408 EXEC SQL BEGIN DECLARE SECTION;
410 char *login, *entity, *name;
412 EXEC SQL END DECLARE SECTION;
414 char databuf[32], *kname_unparse();
415 EXEC SQL BEGIN DECLARE SECTION;
417 int sigwho, timestamp;
418 EXEC SQL END DECLARE SECTION;
423 if (strlen(argv[4]) && strlen(argv[5]))
424 sprintf(fullname, "%s %s %s", argv[4], argv[5], argv[3]);
425 else if (strlen(argv[4]))
426 sprintf(fullname, "%s %s", argv[4], argv[3]);
428 sprintf(fullname, "%s", argv[3]);
431 if (q->vcnt == U_END && *argv[U_SIGNATURE])
433 sprintf(databuf, "%s:%s", argv[U_NAME], argv[U_MITID]);
434 /* skip bytes for timestamp & kname */
435 si.rawsig = (unsigned char *) rawsig;
436 status = GDSS_Verify(databuf, strlen(databuf), argv[U_SIGNATURE], &si);
437 if (strlen(rawsig) > mr_sig_length)
439 com_err(whoami, 0, "GDSS signature would be truncated.");
444 name = kname_unparse(si.pname, si.pinst, si.prealm);
445 status = name_to_id(name, STRINGS_TABLE, &sigwho);
446 if (status == MR_NO_MATCH)
447 sigwho = add_string(name);
450 timestamp = si.timestamp;
454 if (log_flags & LOG_GDSS)
455 hex_dump(argv[U_SIGNATURE]);
456 return gdss2et(status);
471 /* create finger entry, pobox & set modtime on user */
473 EXEC SQL UPDATE users
474 SET modtime = SYSDATE, modby = :who, modwith = :entity,
475 fullname = NVL(:fullname, CHR(0)), affiliation = type,
476 signature = NVL(:rawsig, CHR(0)), sigdate = :timestamp,
477 sigwho = :sigwho, fmodtime = SYSDATE, fmodby = :who,
478 fmodwith = :entity, potype = 'NONE', pmodtime = SYSDATE,
479 pmodby = :who, pmodwith = :entity
480 WHERE login = :login;
482 EXEC SQL UPDATE users
483 SET modtime = SYSDATE, modby = :who, modwith = :entity,
484 fullname = NVL(:fullname, CHR(0)), affiliation = type,
485 fmodtime = SYSDATE, fmodby = :who, fmodwith = :entity,
486 potype = 'NONE', pmodtime = SYSDATE, pmodby = :who, pmodwith = :entity
487 WHERE login = :login;
495 ** followup_uuac - do signature, set_user_modtime
498 ** argv[0] - login (add_user)
499 ** argv[U_SIGNATURE] - sig
503 int followup_uuac(struct query *q, char *argv[], client *cl)
505 EXEC SQL BEGIN DECLARE SECTION;
508 EXEC SQL END DECLARE SECTION;
510 char databuf[32], *kname_unparse();
511 EXEC SQL BEGIN DECLARE SECTION;
514 int sigwho, timestamp;
515 EXEC SQL END DECLARE SECTION;
519 id = *(int *)argv[0];
524 if (q->vcnt == U_MODTIME && *argv[U_SIGNATURE + 1])
527 status = id_to_name(id, USERS_TABLE, &login);
528 sprintf(databuf, "%s:%s", login, argv[U_MITID + 1]);
530 /* skip bytes for timestamp & kname */
531 si.rawsig = (unsigned char *) rawsig;
532 status = GDSS_Verify(databuf, strlen(databuf), argv[U_SIGNATURE + 1],
534 if (strlen(rawsig) > mr_sig_length)
536 com_err(whoami, 0, "GDSS signature would be truncated.");
541 name = kname_unparse(si.pname, si.pinst, si.prealm);
542 status = name_to_id(name, STRINGS_TABLE, &sigwho);
543 if (status == MR_NO_MATCH)
544 sigwho = add_string(name);
547 timestamp = si.timestamp;
551 if (log_flags & LOG_GDSS)
552 hex_dump(argv[U_SIGNATURE + 1]);
553 return gdss2et(status);
564 /* create finger entry, pobox & set modtime on user */
567 EXEC SQL UPDATE users SET modtime = SYSDATE, modby = :who, modwith = :entity,
568 signature = NVL(:rawsig, CHR(0)), sigdate = :timestamp, sigwho = :sigwho
569 WHERE users_id = :id;
571 EXEC SQL UPDATE users SET modtime = SYSDATE, modby = :who, modwith = :entity
572 WHERE users_id = :id;
577 /* followup_gpob: fixes argv[2] based on the IDs currently there and the
578 * type in argv[1]. Then completes the upcall to the user.
580 * argv[2] is of the form "123:234" where the first integer is the machine
581 * ID if it is a pop box, and the second is the string ID if it is an SMTP
582 * box. argv[1] should be "POP", "SMTP", or "NONE". Boxes of type NONE
586 int followup_gpob(struct query *q, struct save_queue *sq, struct validate *v,
587 int (*action)(), int actarg, client *cl)
591 int mid, sid, status, i;
594 while (sq_get_data(sq, &argv))
596 mr_trim_args(2, argv);
598 p = strchr(argv[2], ':');
603 if (!strcmp(ptype, "POP"))
605 status = id_to_name(mid, MACHINE_TABLE, &argv[2]);
606 if (status == MR_NO_MATCH)
609 else if (!strcmp(ptype, "SMTP"))
611 status = id_to_name(sid, STRINGS_TABLE, &argv[2]);
612 if (status == MR_NO_MATCH)
615 else /* ptype == "NONE" */
620 if (!strcmp(q->shortname, "gpob"))
624 status = id_to_name(sid, USERS_TABLE, &argv[4]);
626 status = id_to_name(-sid, STRINGS_TABLE, &argv[4]);
628 if (status && status != MR_NO_MATCH)
631 (*action)(q->vcnt, argv, actarg);
633 /* free saved data */
634 for (i = 0; i < q->vcnt; i++)
644 /* followup_gsnt: fix the ace_name in argv[7]. argv[6] will contain the
645 * ace_type: "LIST", "USER", or "NONE". Decode the id in argv[7] into the
646 * proper name based on the type, and repace that string in the argv.
647 * Also fixes the modby field by called followup_fix_modby.
650 int followup_gsnt(struct query *q, struct save_queue *sq, struct validate *v,
651 int (*action)(), int actarg, client *cl)
654 int id, i, idx, status;
658 while (sq_get_data(sq, &argv))
660 mr_trim_args(q->vcnt, argv);
662 id = atoi(argv[i = q->vcnt - 2]);
664 status = id_to_name(id, USERS_TABLE, &argv[i]);
666 status = id_to_name(-id, STRINGS_TABLE, &argv[i]);
667 if (status && status != MR_NO_MATCH)
670 id = atoi(argv[idx]);
671 type = argv[idx - 1];
673 if (!strcmp(type, "LIST"))
674 status = id_to_name(id, LIST_TABLE, &argv[idx]);
675 else if (!strcmp(type, "USER"))
676 status = id_to_name(id, USERS_TABLE, &argv[idx]);
677 else if (!strcmp(type, "KERBEROS"))
678 status = id_to_name(id, STRINGS_TABLE, &argv[idx]);
679 else if (!strcmp(type, "NONE"))
683 argv[idx] = strsave("NONE");
689 argv[idx] = strsave("???");
691 if (status && status != MR_NO_MATCH)
695 (*action)(q->vcnt, argv, actarg);
697 /* free saved data */
698 for (i = 0; i < q->vcnt; i++)
708 /* followup_ghst: fix the ace_name in argv[12]. argv[11] will contain the
709 * ace_type: "LIST", "USER", or "NONE". Decode the id in argv[12] into the
710 * proper name based on the type, and repace that string in the argv.
711 * Also fixes the modby field by called followup_fix_modby.
714 int followup_ghst(struct query *q, struct save_queue *sq, struct validate *v,
715 int (*action)(), int actarg, client *cl)
718 int id, i, idx, status;
720 while (sq_get_data(sq, &argv))
722 mr_trim_args(q->vcnt, argv);
724 id = atoi(argv[i = q->vcnt - 2]);
726 status = id_to_name(id, USERS_TABLE, &argv[i]);
728 status = id_to_name(-id, STRINGS_TABLE, &argv[i]);
729 if (status && status != MR_NO_MATCH)
733 status = id_to_name(id, STRINGS_TABLE, &argv[13]);
737 status = id_to_name(id, STRINGS_TABLE, &argv[14]);
742 status = id_to_name(-id, STRINGS_TABLE, &argv[16]);
744 status = id_to_name(id, USERS_TABLE, &argv[16]);
745 if (status && status != MR_NO_MATCH)
749 id = atoi(argv[idx]);
750 type = strtrim(argv[idx - 1]);
752 if (!strcmp(type, "LIST"))
753 status = id_to_name(id, LIST_TABLE, &argv[idx]);
754 else if (!strcmp(type, "USER"))
755 status = id_to_name(id, USERS_TABLE, &argv[idx]);
756 else if (!strcmp(type, "KERBEROS"))
757 status = id_to_name(id, STRINGS_TABLE, &argv[idx]);
758 else if (!strcmp(type, "NONE"))
762 argv[idx] = strsave("NONE");
768 argv[idx] = strsave("???");
770 if (status && status != MR_NO_MATCH)
774 (*action)(q->vcnt, argv, actarg);
776 /* free saved data */
777 for (i = 0; i < q->vcnt; i++)
787 /* followup_glin: fix the ace_name in argv[8]. argv[7] will contain the
788 * ace_type: "LIST", "USER", or "NONE". Decode the id in argv[8] into the
789 * proper name based on the type, and repace that string in the argv.
790 * Also fixes the modby field by called followup_fix_modby.
793 int followup_glin(struct query *q, struct save_queue *sq, struct validate *v,
794 int (*action)(), int actarg, client *cl)
797 int id, i, idx, status;
800 if (!strcmp(q->shortname, "gsin"))
803 while (sq_get_data(sq, &argv))
805 mr_trim_args(q->vcnt, argv);
807 id = atoi(argv[i = q->vcnt - 2]);
809 status = id_to_name(id, USERS_TABLE, &argv[i]);
811 status = id_to_name(-id, STRINGS_TABLE, &argv[i]);
812 if (status && status != MR_NO_MATCH)
815 id = atoi(argv[idx]);
816 type = argv[idx - 1];
818 if (!strcmp(type, "LIST"))
819 status = id_to_name(id, LIST_TABLE, &argv[idx]);
820 else if (!strcmp(type, "USER"))
821 status = id_to_name(id, USERS_TABLE, &argv[idx]);
822 else if (!strcmp(type, "KERBEROS"))
823 status = id_to_name(id, STRINGS_TABLE, &argv[idx]);
824 else if (!strcmp(type, "NONE"))
828 argv[idx] = strsave("NONE");
834 argv[idx] = strsave("???");
836 if (status && status != MR_NO_MATCH)
839 if (!strcmp(q->shortname, "glin") && atoi(argv[6]) == -1)
841 argv[6] = realloc(argv[6], strlen(UNIQUE_GID) + 1);
842 strcpy(argv[6], UNIQUE_GID);
846 (*action)(q->vcnt, argv, actarg);
848 /* free saved data */
849 for (i = 0; i < q->vcnt; i++)
859 /* followup_gqot: Fix the entity name, directory name & modby fields
860 * argv[0] = filsys_id
862 * argv[2] = entity_id
863 * argv[3] = ascii(quota)
866 int followup_gqot(struct query *q, struct save_queue *sq, struct validate *v,
867 int (*action)(), int actarg, client *cl)
871 EXEC SQL BEGIN DECLARE SECTION;
874 EXEC SQL END DECLARE SECTION;
877 if (!strcmp(q->name, "get_quota") ||
878 !strcmp(q->name, "get_quota_by_filesys"))
882 while (sq_get_data(sq, &argv))
889 status = id_to_name(atoi(argv[2]), USERS_TABLE, &argv[2]);
893 status = id_to_name(atoi(argv[2]), LIST_TABLE, &argv[2]);
897 argv[2] = strsave("system:anyuser");
902 sprintf(argv[2], "%d", id);
905 id = atoi(argv[idx]);
907 argv[idx] = malloc(256);
912 EXEC SQL SELECT name INTO :name FROM filesys
913 WHERE label = :label;
917 EXEC SQL SELECT dir INTO :name FROM nfsphys
918 WHERE nfsphys_id = :id;
920 if (sqlca.sqlerrd[2] != 1)
921 sprintf(argv[idx], "#%d", id);
923 id = atoi(argv[idx + 3]);
925 status = id_to_name(id, USERS_TABLE, &argv[idx + 3]);
927 status = id_to_name(-id, STRINGS_TABLE, &argv[idx + 3]);
928 if (status && status != MR_NO_MATCH)
930 (*action)(q->vcnt, argv, actarg);
931 for (j = 0; j < q->vcnt; j++)
940 /* followup_aqot: Add allocation to nfsphys after creating quota.
941 * argv[0] = filsys_id
942 * argv[1] = type if "add_quota" or "update_quota"
944 * argv[3 or 2] = ascii(quota)
947 int followup_aqot(struct query *q, char *argv[], client *cl)
949 EXEC SQL BEGIN DECLARE SECTION;
950 int quota, id, fs, who, physid, table;
951 char *entity, *qtype, *tname;
952 EXEC SQL END DECLARE SECTION;
958 tname = table_name[table];
959 fs = *(int *)argv[0];
960 EXEC SQL SELECT phys_id INTO :physid FROM filesys
961 WHERE filsys_id = :fs;
965 if (!strcmp(q->shortname, "aqot") || !strcmp(q->shortname, "uqot"))
968 id = *(int *)argv[2];
969 quota = atoi(argv[3]);
970 sprintf(incr_qual, "q.filsys_id = %d", fs);
975 id = *(int *)argv[1];
976 quota = atoi(argv[2]);
977 sprintf(incr_qual, "q.filsys_id = %d AND q.type = '%s' AND "
978 "q.entity_id = %d", fs, qtype, id);
981 /* quota case of incremental_{before|after} only looks at slot 1 */
982 incr_argv[1] = qtype;
984 /* Follows one of many possible gross hacks to fix these particular
985 * conflicts between what is possible in the query table and what
986 * is possible in SQL.
988 if (q->type == APPEND)
990 incremental_clear_before();
991 EXEC SQL INSERT INTO quota
992 (filsys_id, type, entity_id, quota, phys_id)
993 VALUES (:fs, NVL(:qtype, CHR(0)), :id, :quota, :physid);
994 incremental_after(table, incr_qual, incr_argv);
998 incremental_before(table, incr_qual, incr_argv);
999 EXEC SQL UPDATE quota SET quota = :quota
1000 WHERE filsys_id = :fs AND type = :qtype AND entity_id = :id;
1001 status = mr_errcode;
1002 incremental_after(table, incr_qual, incr_argv);
1007 flush_name(argv[0], table);
1008 if (q->type == APPEND)
1010 EXEC SQL UPDATE tblstats SET appends = appends + 1, modtime = SYSDATE
1011 WHERE table_name = :tname;
1015 EXEC SQL UPDATE tblstats SET updates = updates + 1, modtime = SYSDATE
1016 WHERE table_name = :tname;
1019 /* Proceed with original followup */
1020 who = cl->client_id;
1021 entity = cl->entity;
1023 EXEC SQL UPDATE quota
1024 SET modtime = SYSDATE, modby = :who, modwith = :entity
1025 WHERE filsys_id = :fs and type = :qtype and entity_id = :id;
1026 EXEC SQL UPDATE nfsphys SET allocated = allocated + :quota
1027 WHERE nfsphys_id = :physid;
1034 /* Necessitated by the requirement of a correlation name by the incremental
1035 * routines, since query table deletes don't provide one.
1037 int followup_dqot(struct query *q, char **argv, client *cl)
1042 EXEC SQL BEGIN DECLARE SECTION;
1043 char incr_qual[80], *tname;
1044 EXEC SQL END DECLARE SECTION;
1047 tname = table_name[table];
1048 fs = *(int *)argv[0];
1049 if (!strcmp(q->shortname, "dqot"))
1052 id = *(int *)argv[2];
1057 id = *(int *)argv[1];
1059 sprintf(incr_qual, "q.filsys_id = %d AND q.type = '%s' AND q.entity_id = %d",
1062 /* quota case of incremental_{before|after} only looks at slot 1 */
1063 incr_argv[1] = qtype;
1065 incremental_before(table, incr_qual, incr_argv);
1066 EXEC SQL DELETE FROM quota q WHERE q.filsys_id = :fs AND q.type = :qtype
1067 AND q.entity_id = :id;
1068 incremental_clear_after();
1072 flush_name(argv[0], table);
1074 EXEC SQL UPDATE tblstats SET deletes = deletes + 1, modtime = SYSDATE
1075 WHERE table_name = :tname;
1080 int followup_gpce(struct query *q, struct save_queue *sq, struct validate *v,
1081 int (*action)(), int actarg, client *cl)
1088 while (sq_get_data(sq, &argv))
1090 id = atoi(argv[PCAP_QSERVER]);
1091 status = id_to_name(id, MACHINE_TABLE, &argv[PCAP_QSERVER]);
1096 status = id_to_name(id, USERS_TABLE, &argv[i]);
1098 status = id_to_name(-id, STRINGS_TABLE, &argv[i]);
1099 if (status && status != MR_NO_MATCH)
1101 (*action)(q->vcnt, argv, actarg);
1102 for (j = 0; j < q->vcnt; j++)
1114 int followup_gzcl(struct query *q, struct save_queue *sq, struct validate *v,
1115 int (*action)(), int actarg, client *cl)
1120 while (sq_get_data(sq, &argv))
1122 mr_trim_args(q->vcnt, argv);
1124 id = atoi(argv[i = q->vcnt - 2]);
1126 status = id_to_name(id, USERS_TABLE, &argv[i]);
1128 status = id_to_name(-id, STRINGS_TABLE, &argv[i]);
1129 if (status && status != MR_NO_MATCH)
1132 for (i = 1; i < 8; i += 2)
1134 id = atoi(argv[i + 1]);
1135 if (!strcmp(argv[i], "LIST"))
1136 status = id_to_name(id, LIST_TABLE, &argv[i + 1]);
1137 else if (!strcmp(argv[i], "USER"))
1138 status = id_to_name(id, USERS_TABLE, &argv[i + 1]);
1139 else if (!strcmp(argv[i], "KERBEROS"))
1140 status = id_to_name(id, STRINGS_TABLE, &argv[i + 1]);
1141 else if (!strcmp(argv[i], "NONE"))
1145 argv[i + 1] = strsave("NONE");
1151 argv[i + 1] = strsave("???");
1153 if (status && status != MR_NO_MATCH)
1158 (*action)(q->vcnt, argv, actarg);
1160 /* free saved data */
1161 for (i = 0; i < q->vcnt; i++)
1173 int followup_gsha(struct query *q, struct save_queue *sq, struct validate *v,
1174 int (*action)(), int actarg, client *cl)
1179 while (sq_get_data(sq, &argv))
1181 mr_trim_args(q->vcnt, argv);
1185 status = id_to_name(id, USERS_TABLE, &argv[4]);
1187 status = id_to_name(-id, STRINGS_TABLE, &argv[4]);
1188 if (status && status != MR_NO_MATCH)
1192 if (!strcmp(argv[1], "LIST"))
1193 status = id_to_name(id, LIST_TABLE, &argv[2]);
1194 else if (!strcmp(argv[1], "USER"))
1195 status = id_to_name(id, USERS_TABLE, &argv[2]);
1196 else if (!strcmp(argv[1], "KERBEROS"))
1197 status = id_to_name(id, STRINGS_TABLE, &argv[2]);
1198 else if (!strcmp(argv[1], "NONE"))
1202 argv[2] = strsave("NONE");
1208 argv[2] = strsave("???");
1210 if (status && status != MR_NO_MATCH)
1214 (*action)(q->vcnt, argv, actarg);
1216 /* free saved data */
1217 for (i = 0; i < q->vcnt; i++)
1226 int _sdl_followup(struct query *q, char *argv[], client *cl)
1233 EXEC SQL ALTER SESSION SET SQL_TRACE TRUE;
1235 EXEC SQL ALTER SESSION SET SQL_TRACE FALSE;
1241 static void hex_dump(unsigned char *p)
1243 fprintf(stderr, "Size: %d\n", strlen(p));
1244 while (strlen(p) >= 8)
1246 fprintf(stderr, "%02x %02x %02x %02x %02x %02x %02x %02x\n",
1247 p[0], p[1], p[2], p[3], p[4], p[5], p[6], p[7]);
1253 fprintf(stderr, "%02x %02x %02x %02x %02x %02x %02x\n",
1254 p[0], p[1], p[2], p[3], p[4], p[5], p[6]);
1257 fprintf(stderr, "%02x %02x %02x %02x %02x %02x\n",
1258 p[0], p[1], p[2], p[3], p[4], p[5]);
1261 fprintf(stderr, "%02x %02x %02x %02x %02x\n",
1262 p[0], p[1], p[2], p[3], p[4]);
1265 fprintf(stderr, "%02x %02x %02x %02x\n",
1266 p[0], p[1], p[2], p[3]);
1269 fprintf(stderr, "%02x %02x %02x\n",
1273 fprintf(stderr, "%02x %02x\n",
1277 fprintf(stderr, "%02x\n",