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(q, argv, cl)
51 char *name, *entity, *table;
56 table = table_name[q->rtable];
59 sprintf(stmt_buf,"UPDATE %s SET modtime = SYSDATE, modby = %d, modwith = '%s' WHERE name = '%s'",table,who,entity,name);
60 EXEC SQL EXECUTE IMMEDIATE :stmt_buf;
65 /* generic set_modtime_by_id routine. This takes the table id from
66 * the query, and the id name from the validate record,
67 * and will update the modtime, modby, and modwho fields in the entry in
68 * the table whose id matches argv[0].
71 int set_modtime_by_id(q, argv, cl)
76 char *entity, *table, *id_name;
81 table = table_name[q->rtable];
82 id_name = q->validate->object_id;
85 sprintf(stmt_buf,"UPDATE %s SET modtime = SYSDATE, modby = %d, \
86 modwith = '%s' WHERE %s = %d",table,who,entity,id_name,id);
87 EXEC SQL EXECUTE IMMEDIATE :stmt_buf;
92 /* Sets the finger modtime on a user record. The users_id will be in argv[0].
95 int set_finger_modtime(q, argv, cl)
100 EXEC SQL BEGIN DECLARE SECTION;
103 EXEC SQL END DECLARE SECTION;
107 users_id = *(int *)argv[0];
109 EXEC SQL UPDATE users SET fmodtime=SYSDATE, fmodby = :who,
110 fmodwith = :entity WHERE users_id = :users_id;
116 /* Sets the pobox modtime on a user record. The users_id will be in argv[0].
119 int set_pobox_modtime(q, argv, cl)
124 EXEC SQL BEGIN DECLARE SECTION;
127 EXEC SQL END DECLARE SECTION;
131 users_id = *(int *)argv[0];
133 EXEC SQL UPDATE users SET pmodtime=SYSDATE, pmodby = :who,
134 pmodwith = :entity WHERE users_id = :users_id;
140 /* Like set_modtime, but uppercases the name first.
143 int set_uppercase_modtime(q, argv, cl)
148 char *name, *entity, *table;
153 table = table_name[q->rtable];
156 sprintf(stmt_buf,"UPDATE %s SET modtime = SYSDATE, modby = %d, modwith = '%s' WHERE name = UPPER('%s')",table,who,entity,name);
157 EXEC SQL EXECUTE IMMEDIATE :stmt_buf;
163 /* Sets the modtime on the machine whose mach_id is in argv[0]. This routine
164 * is necessary for add_machine_to_cluster becuase the table that query
165 * operates on is "mcm", not "machine".
168 int set_mach_modtime_by_id(q, argv, cl)
173 EXEC SQL BEGIN DECLARE SECTION;
176 EXEC SQL END DECLARE SECTION;
180 id = *(int *)argv[0];
181 EXEC SQL UPDATE machine SET modtime=SYSDATE, modby = :who,
182 modwith = :entity WHERE mach_id = :id;
188 /* Sets the modtime on the cluster whose mach_id is in argv[0]. This routine
189 * is necessary for add_cluster_data and delete_cluster_data becuase the
190 * table that query operates on is "svc", not "cluster".
193 int set_cluster_modtime_by_id(q, argv, cl)
198 EXEC SQL BEGIN DECLARE SECTION;
201 EXEC SQL END DECLARE SECTION;
206 id = *(int *)argv[0];
207 EXEC SQL UPDATE clusters SET modtime=SYSDATE, modby = :who,
208 modwith = :entity WHERE clu_id = :id;
213 /* sets the modtime on the serverhost where the service name is in argv[0]
214 * and the mach_id is in argv[1].
217 int set_serverhost_modtime(q, argv, cl)
222 EXEC SQL BEGIN DECLARE SECTION;
225 EXEC SQL END DECLARE SECTION;
231 id = *(int *)argv[1];
232 EXEC SQL UPDATE serverhosts
233 SET modtime = SYSDATE, modby = :who, modwith = :entity
234 WHERE service = :serv AND mach_id = :id;
239 /* sets the modtime on the nfsphys where the mach_id is in argv[0] and the
240 * directory name is in argv[1].
243 int set_nfsphys_modtime(q, argv, cl)
248 EXEC SQL BEGIN DECLARE SECTION;
251 EXEC SQL END DECLARE SECTION;
256 id = *(int *)argv[0];
258 EXEC SQL UPDATE nfsphys SET modtime = SYSDATE, modby = :who,
259 modwith = :entity WHERE dir = :dir AND mach_id = :id;
264 /* sets the modtime on a filesystem, where argv[0] contains the filesys
268 int set_filesys_modtime(q, argv, cl)
273 EXEC SQL BEGIN DECLARE SECTION;
274 char *label, *entity;
276 extern int _var_phys_id;
278 EXEC SQL END DECLARE SECTION;
284 if (!strcmp(q->shortname, "ufil"))
287 EXEC SQL UPDATE filesys SET modtime = SYSDATE, modby = :who,
288 modwith = :entity, phys_id = :_var_phys_id
289 WHERE label = :label;
294 /* sets the modtime on a zephyr class, where argv[0] contains the class
298 int set_zephyr_modtime(q, argv, cl)
303 EXEC SQL BEGIN DECLARE SECTION;
304 char *class, *entity;
306 EXEC SQL END DECLARE SECTION;
313 EXEC SQL UPDATE zephyr SET modtime = SYSDATE, modby = :who,
314 modwith = :entity WHERE class = :class;
320 /* fixes the modby field. This will be the second to last thing in the
321 * argv, the argv length is determined from the query structure. It is
322 * passed as a pointer to an integer. This will either turn it into a
323 * username, or # + the users_id.
325 int followup_fix_modby(q, sq, v, action, actarg, cl)
327 struct save_queue *sq;
329 int (*action)(), actarg;
337 while (sq_get_data(sq, &argv)) {
340 status = id_to_name(id, USERS_TABLE, &argv[i]);
342 status = id_to_name(-id, STRINGS_TABLE, &argv[i]);
343 if (status && status != MR_NO_MATCH)
345 (*action)(q->vcnt, argv, actarg);
346 for (j = 0; j < q->vcnt; j++)
355 /* After retrieving a user account, fix the modby field and signature.
356 * The modby field is the second to last thing in the
357 * argv, the argv length is determined from the query structure. It is
358 * passed as a pointer to an integer. This will either turn it into a
359 * username, or # + the users_id. Only "gua*" queries have a signature,
360 * these are ones with U_END return values. "gub*" queries also use this
361 * routine but don't have a signature.
363 int followup_guax(q, sq, v, action, actarg, cl)
365 struct save_queue *sq;
367 int (*action)(), actarg;
373 unsigned char sigbuf[256];
376 EXEC SQL BEGIN DECLARE SECTION;
377 int timestamp, who, siglen;
380 EXEC SQL VAR rsig IS STRING(256);
381 EXEC SQL END DECLARE SECTION;
386 while (sq_get_data(sq, &argv)) {
389 status = id_to_name(id, USERS_TABLE, &argv[i]);
391 status = id_to_name(-id, STRINGS_TABLE, &argv[i]);
392 if (status && status != MR_NO_MATCH)
395 if (q->vcnt == U_END && strlen(argv[U_SIGNATURE])) {
396 login = strtrim(argv[U_NAME]);
397 EXEC SQL SELECT signature, sigdate, sigwho
398 INTO :rsig, :timestamp, :who FROM users
399 WHERE login = :login;
400 if(dbms_errno) return mr_errcode;
402 status = id_to_name(who, STRINGS_TABLE, &kname);
403 si.timestamp = timestamp;
404 si.SigInfoVersion = 0; /* XXXXX this isn't used */
405 kname_parse(si.pname, si.pinst, si.prealm, kname);
407 si.rawsig = (unsigned char *)strsave(rsig);
408 if (log_flags & LOG_GDSS)
409 com_err(whoami, 0, "rawsig length = %d, sig=\"%s\"", strlen(si.rawsig), si.rawsig);
410 GDSS_Recompose(&si, sigbuf);
412 free(argv[U_SIGNATURE]);
413 argv[U_SIGNATURE] = strsave(sigbuf);
414 if (log_flags & LOG_GDSS)
415 com_err(whoami, 0, "generated signature length %d", strlen(sigbuf));
418 (*action)(q->vcnt, argv, actarg);
419 for (j = 0; j < q->vcnt; j++)
429 ** followup_ausr - add finger and pobox entries, set_user_modtime
432 ** argv[0] - login (add_user)
433 ** argv[3] - last name
434 ** argv[4] - first name
435 ** argv[5] - middle name
439 int followup_ausr(q, argv, cl)
444 EXEC SQL BEGIN DECLARE SECTION;
446 char *login, *entity, *name;
448 EXEC SQL END DECLARE SECTION;
450 char databuf[32], *kname_unparse();
451 EXEC SQL BEGIN DECLARE SECTION;
453 int sigwho, timestamp;
454 EXEC SQL END DECLARE SECTION;
459 if (strlen(argv[4]) && strlen(argv[5]))
460 sprintf(fullname, "%s %s %s", argv[4], argv[5], argv[3]);
461 else if (strlen(argv[4]))
462 sprintf(fullname, "%s %s", argv[4], argv[3]);
464 sprintf(fullname, "%s", argv[3]);
467 if (q->vcnt == U_END && *argv[U_SIGNATURE]) {
468 sprintf(databuf, "%s:%s", argv[U_NAME], argv[U_MITID]);
469 /* skip bytes for timestamp & kname */
470 si.rawsig = (unsigned char *) rawsig;
471 status = GDSS_Verify(databuf, strlen(databuf), argv[U_SIGNATURE], &si);
472 if (strlen(rawsig) > mr_sig_length) {
473 com_err(whoami, 0, "GDSS signature would be truncated."); /** untested **/
477 name = kname_unparse(si.pname, si.pinst, si.prealm);
478 status = name_to_id(name, STRINGS_TABLE, &sigwho);
479 if (status == MR_NO_MATCH) {
480 sigwho=add_string(name);
483 timestamp = si.timestamp;
485 if (log_flags & LOG_GDSS)
486 hex_dump(argv[U_SIGNATURE]);
487 return(gdss2et(status));
500 /* create finger entry, pobox & set modtime on user */
502 EXEC SQL UPDATE users
503 SET modtime=SYSDATE, modby=:who, modwith = :entity,
504 fullname = NVL(:fullname,CHR(0)), affiliation = type,
505 signature = NVL(:rawsig,CHR(0)), sigdate = :timestamp,
506 sigwho = :sigwho, fmodtime=SYSDATE, fmodby = :who,
507 fmodwith = :entity, potype='NONE', pmodtime=SYSDATE,
508 pmodby = :who, pmodwith = :entity
509 WHERE login = :login;
511 EXEC SQL UPDATE users
512 SET modtime=SYSDATE, modby=:who, modwith = :entity,
513 fullname = NVL(:fullname,CHR(0)), affiliation = type,
514 fmodtime=SYSDATE, fmodby = :who, fmodwith = :entity,
515 potype='NONE', pmodtime=SYSDATE, pmodby = :who, pmodwith = :entity
516 WHERE login = :login;
524 ** followup_uuac - do signature, set_user_modtime
527 ** argv[0] - login (add_user)
528 ** argv[U_SIGNATURE] - sig
532 int followup_uuac(q, argv, cl)
537 EXEC SQL BEGIN DECLARE SECTION;
540 EXEC SQL END DECLARE SECTION;
542 char databuf[32], *kname_unparse();
543 EXEC SQL BEGIN DECLARE SECTION;
546 int sigwho, timestamp;
547 EXEC SQL END DECLARE SECTION;
551 id = *(int *)argv[0];
556 if (q->vcnt == U_MODTIME && *argv[U_SIGNATURE + 1]) {
558 status = id_to_name(id, USERS_TABLE, &login);
559 sprintf(databuf, "%s:%s", login, argv[U_MITID+1]);
561 /* skip bytes for timestamp & kname */
562 si.rawsig = (unsigned char *) rawsig;
563 status = GDSS_Verify(databuf, strlen(databuf), argv[U_SIGNATURE+1], &si);
564 if (strlen(rawsig) > mr_sig_length) {
565 com_err(whoami, 0, "GDSS signature would be truncated."); /** untested **/
569 name = kname_unparse(si.pname, si.pinst, si.prealm);
570 status = name_to_id(name, STRINGS_TABLE, &sigwho);
571 if (status == MR_NO_MATCH) {
572 sigwho=add_string(name);
575 timestamp = si.timestamp;
577 if (log_flags & LOG_GDSS)
578 hex_dump(argv[U_SIGNATURE+1]);
579 return(gdss2et(status));
588 /* create finger entry, pobox & set modtime on user */
591 EXEC SQL UPDATE users SET modtime=SYSDATE, modby = :who, modwith = :entity,
592 signature = NVL(:rawsig,CHR(0)), sigdate = :timestamp, sigwho = :sigwho
593 WHERE users_id = :id;
595 EXEC SQL UPDATE users SET modtime=SYSDATE, modby = :who, modwith = :entity
596 WHERE users_id = :id;
601 /* followup_gpob: fixes argv[2] based on the IDs currently there and the
602 * type in argv[1]. Then completes the upcall to the user.
604 * argv[2] is of the form "123:234" where the first integer is the machine
605 * ID if it is a pop box, and the second is the string ID if it is an SMTP
606 * box. argv[1] should be "POP", "SMTP", or "NONE". Boxes of type NONE
610 int followup_gpob(q, sq, v, action, actarg, cl)
612 struct save_queue *sq;
620 int mid, sid, status, i;
623 while (sq_get_data(sq, &argv)) {
624 mr_trim_args(2, argv);
626 p = strchr(argv[2], ':');
631 if (!strcmp(ptype, "POP")) {
632 status = id_to_name(mid, MACHINE_TABLE, &argv[2]);
633 if (status == MR_NO_MATCH)
635 } else if (!strcmp(ptype, "SMTP")) {
636 status = id_to_name(sid, STRINGS_TABLE, &argv[2]);
637 if (status == MR_NO_MATCH)
639 } else /* ptype == "NONE" */ {
642 if (status) return(status);
644 if (!strcmp(q->shortname, "gpob")) {
647 status = id_to_name(sid, USERS_TABLE, &argv[4]);
649 status = id_to_name(-sid, STRINGS_TABLE, &argv[4]);
651 if (status && status != MR_NO_MATCH) return(status);
653 (*action)(q->vcnt, argv, actarg);
655 /* free saved data */
656 for (i = 0; i < q->vcnt; i++)
666 /* followup_gsnt: fix the ace_name in argv[7]. argv[6] will contain the
667 * ace_type: "LIST", "USER", or "NONE". Decode the id in argv[7] into the
668 * proper name based on the type, and repace that string in the argv.
669 * Also fixes the modby field by called followup_fix_modby.
672 int followup_gsnt(q, sq, v, action, actarg, cl)
674 struct save_queue *sq;
676 int (*action)(), actarg;
680 int id, i, idx, status;
684 while (sq_get_data(sq, &argv)) {
685 mr_trim_args(q->vcnt, argv);
687 id = atoi(argv[i = q->vcnt - 2]);
689 status = id_to_name(id, USERS_TABLE, &argv[i]);
691 status = id_to_name(-id, STRINGS_TABLE, &argv[i]);
692 if (status && status != MR_NO_MATCH)
695 id = atoi(argv[idx]);
696 type = argv[idx - 1];
698 if (!strcmp(type, "LIST")) {
699 status = id_to_name(id, LIST_TABLE, &argv[idx]);
700 } else if (!strcmp(type, "USER")) {
701 status = id_to_name(id, USERS_TABLE, &argv[idx]);
702 } else if (!strcmp(type, "KERBEROS")) {
703 status = id_to_name(id, STRINGS_TABLE, &argv[idx]);
704 } else if (!strcmp(type, "NONE")) {
707 argv[idx] = strsave("NONE");
711 argv[idx] = strsave("???");
713 if (status && status != MR_NO_MATCH)
717 (*action)(q->vcnt, argv, actarg);
719 /* free saved data */
720 for (i = 0; i < q->vcnt; i++)
730 /* followup_ghst: fix the ace_name in argv[12]. argv[11] will contain the
731 * ace_type: "LIST", "USER", or "NONE". Decode the id in argv[12] into the
732 * proper name based on the type, and repace that string in the argv.
733 * Also fixes the modby field by called followup_fix_modby.
736 int followup_ghst(q, sq, v, action, actarg, cl)
738 struct save_queue *sq;
740 int (*action)(), actarg;
744 int id, i, idx, status;
746 while (sq_get_data(sq, &argv)) {
747 mr_trim_args(q->vcnt, argv);
749 id = atoi(argv[i = q->vcnt - 2]);
751 status = id_to_name(id, USERS_TABLE, &argv[i]);
753 status = id_to_name(-id, STRINGS_TABLE, &argv[i]);
754 if (status && status != MR_NO_MATCH)
758 status = id_to_name(id, STRINGS_TABLE, &argv[13]);
759 if (status) return(status);
761 status = id_to_name(id, STRINGS_TABLE, &argv[14]);
762 if (status) return(status);
765 status = id_to_name(-id, STRINGS_TABLE, &argv[16]);
767 status = id_to_name(id, USERS_TABLE, &argv[16]);
768 if (status && status != MR_NO_MATCH)
772 id = atoi(argv[idx]);
773 type = strtrim(argv[idx - 1]);
775 if (!strcmp(type, "LIST")) {
776 status = id_to_name(id, LIST_TABLE, &argv[idx]);
777 } else if (!strcmp(type, "USER")) {
778 status = id_to_name(id, USERS_TABLE, &argv[idx]);
779 } else if (!strcmp(type, "KERBEROS")) {
780 status = id_to_name(id, STRINGS_TABLE, &argv[idx]);
781 } else if (!strcmp(type, "NONE")) {
784 argv[idx] = strsave("NONE");
788 argv[idx] = strsave("???");
790 if (status && status != MR_NO_MATCH)
794 (*action)(q->vcnt, argv, actarg);
796 /* free saved data */
797 for (i = 0; i < q->vcnt; i++)
807 /* followup_glin: fix the ace_name in argv[8]. argv[7] will contain the
808 * ace_type: "LIST", "USER", or "NONE". Decode the id in argv[8] into the
809 * proper name based on the type, and repace that string in the argv.
810 * Also fixes the modby field by called followup_fix_modby.
813 int followup_glin(q, sq, v, action, actarg, cl)
815 struct save_queue *sq;
817 int (*action)(), actarg;
821 int id, i, idx, status;
824 if (!strcmp(q->shortname, "gsin"))
827 while (sq_get_data(sq, &argv)) {
828 mr_trim_args(q->vcnt, argv);
830 id = atoi(argv[i = q->vcnt - 2]);
832 status = id_to_name(id, USERS_TABLE, &argv[i]);
834 status = id_to_name(-id, STRINGS_TABLE, &argv[i]);
835 if (status && status != MR_NO_MATCH)
838 id = atoi(argv[idx]);
839 type = argv[idx - 1];
841 if (!strcmp(type, "LIST")) {
842 status = id_to_name(id, LIST_TABLE, &argv[idx]);
843 } else if (!strcmp(type, "USER")) {
844 status = id_to_name(id, USERS_TABLE, &argv[idx]);
845 } else if (!strcmp(type, "KERBEROS")) {
846 status = id_to_name(id, STRINGS_TABLE, &argv[idx]);
847 } else if (!strcmp(type, "NONE")) {
850 argv[idx] = strsave("NONE");
854 argv[idx] = strsave("???");
856 if (status && status != MR_NO_MATCH)
859 if (!strcmp(q->shortname, "glin") && atoi(argv[6]) == -1) {
860 argv[6] = realloc(argv[6], strlen(UNIQUE_GID) + 1);
861 strcpy(argv[6], UNIQUE_GID);
865 (*action)(q->vcnt, argv, actarg);
867 /* free saved data */
868 for (i = 0; i < q->vcnt; i++)
878 /* followup_gqot: Fix the entity name, directory name & modby fields
879 * argv[0] = filsys_id
881 * argv[2] = entity_id
882 * argv[3] = ascii(quota)
885 int followup_gqot(q, sq, v, action, actarg, cl)
887 struct save_queue *sq;
889 int (*action)(), actarg;
894 EXEC SQL BEGIN DECLARE SECTION;
897 EXEC SQL END DECLARE SECTION;
900 if (!strcmp(q->name, "get_quota") ||
901 !strcmp(q->name, "get_quota_by_filesys"))
905 while (sq_get_data(sq, &argv)) {
907 switch (argv[1][0]) {
909 status = id_to_name(atoi(argv[2]), USERS_TABLE, &argv[2]);
913 status = id_to_name(atoi(argv[2]), LIST_TABLE, &argv[2]);
917 argv[2] = strsave("system:anyuser");
922 sprintf(argv[2], "%d", id);
925 id = atoi(argv[idx]);
927 argv[idx] = malloc(256);
931 EXEC SQL SELECT name INTO :name FROM filesys
932 WHERE label = :label;
934 EXEC SQL SELECT dir INTO :name FROM nfsphys
935 WHERE nfsphys_id = :id;
937 if (sqlca.sqlerrd[2] != 1) {
938 sprintf(argv[idx], "#%d", id);
941 id = atoi(argv[idx+3]);
943 status = id_to_name(id, USERS_TABLE, &argv[idx+3]);
945 status = id_to_name(-id, STRINGS_TABLE, &argv[idx+3]);
946 if (status && status != MR_NO_MATCH)
948 (*action)(q->vcnt, argv, actarg);
949 for (j = 0; j < q->vcnt; j++)
958 /* followup_aqot: Add allocation to nfsphys after creating quota.
959 * argv[0] = filsys_id
960 * argv[1] = type if "add_quota" or "update_quota"
962 * argv[3 or 2] = ascii(quota)
965 int followup_aqot(q, argv, cl)
970 EXEC SQL BEGIN DECLARE SECTION;
971 int quota, id, fs, who, physid, table;
972 char *entity, *qtype, *tname;
973 EXEC SQL END DECLARE SECTION;
979 tname=table_name[table];
980 fs = *(int *)argv[0];
981 EXEC SQL SELECT phys_id INTO :physid FROM filesys
982 WHERE filsys_id = :fs;
986 if (!strcmp(q->shortname, "aqot") || !strcmp(q->shortname, "uqot")) {
988 id = *(int *)argv[2];
989 quota = atoi(argv[3]);
990 sprintf(incr_qual,"q.filsys_id = %d",fs);
993 id = *(int *)argv[1];
994 quota = atoi(argv[2]);
995 sprintf(incr_qual,"q.filsys_id=%d AND q.type='%s' AND q.entity_id=%d",
999 /* quota case of incremental_{before|after} only looks at slot 1 */
1002 /* Follows one of many possible gross hacks to fix these particular
1003 * conflicts between what is possible in the query table and what
1004 * is possible in SQL.
1006 if(q->type==APPEND) {
1007 incremental_clear_before();
1008 EXEC SQL INSERT INTO quota
1009 (filsys_id, type, entity_id, quota, phys_id)
1010 VALUES (:fs, NVL(:qtype,CHR(0)), :id, :quota, :physid);
1011 incremental_after(table, incr_qual, incr_argv);
1013 incremental_before(table, incr_qual, incr_argv);
1014 EXEC SQL UPDATE quota SET quota = :quota
1015 WHERE filsys_id = :fs AND type = :qtype AND entity_id = :id;
1016 status = mr_errcode;
1017 incremental_after(table, incr_qual, incr_argv);
1022 flush_name(argv[0], table);
1023 if(q->type==APPEND) {
1024 EXEC SQL UPDATE tblstats SET appends = appends + 1, modtime = SYSDATE
1025 WHERE table_name = :tname;
1027 EXEC SQL UPDATE tblstats SET updates = updates + 1, modtime = SYSDATE
1028 WHERE table_name = :tname;
1031 /* Proceed with original followup */
1032 who = cl->client_id;
1033 entity = cl->entity;
1035 EXEC SQL UPDATE quota
1036 SET modtime = SYSDATE, modby = :who, modwith = :entity
1037 WHERE filsys_id = :fs and type = :qtype and entity_id = :id;
1038 EXEC SQL UPDATE nfsphys SET allocated = allocated + :quota
1039 WHERE nfsphys_id = :physid;
1040 if (dbms_errno) return(mr_errcode);
1045 /* Necessitated by the requirement of a correlation name by the incremental
1046 * routines, since query table deletes don't provide one.
1048 int followup_dqot(q, argv, cl)
1056 EXEC SQL BEGIN DECLARE SECTION;
1057 char incr_qual[80], *tname;
1058 EXEC SQL END DECLARE SECTION;
1061 tname=table_name[table];
1062 fs = *(int *)argv[0];
1063 if (!strcmp(q->shortname, "dqot")) {
1065 id = *(int *)argv[2];
1068 id = *(int *)argv[1];
1070 sprintf(incr_qual,"q.filsys_id=%d AND q.type='%s' AND q.entity_id=%d",
1073 /* quota case of incremental_{before|after} only looks at slot 1 */
1076 incremental_before(table, incr_qual, incr_argv);
1077 EXEC SQL DELETE FROM quota q WHERE q.filsys_id=:fs AND q.type=:qtype
1078 AND q.entity_id=:id;
1079 incremental_clear_after();
1083 flush_name(argv[0], table);
1085 EXEC SQL UPDATE tblstats SET deletes = deletes + 1, modtime = SYSDATE
1086 WHERE table_name = :tname;
1091 int followup_gpce(q, sq, v, action, actarg, cl)
1093 struct save_queue *sq;
1095 int (*action)(), actarg;
1103 while (sq_get_data(sq, &argv)) {
1104 id = atoi(argv[PCAP_QSERVER]);
1105 status = id_to_name(id, MACHINE_TABLE, &argv[PCAP_QSERVER]);
1106 if (status) return (status);
1109 status = id_to_name(id, USERS_TABLE, &argv[i]);
1111 status = id_to_name(-id, STRINGS_TABLE, &argv[i]);
1112 if (status && status != MR_NO_MATCH)
1114 (*action)(q->vcnt, argv, actarg);
1115 for (j = 0; j < q->vcnt; j++)
1127 int followup_gzcl(q, sq, v, action, actarg, cl)
1129 struct save_queue *sq;
1131 int (*action)(), actarg;
1137 while (sq_get_data(sq, &argv)) {
1138 mr_trim_args(q->vcnt, argv);
1140 id = atoi(argv[i = q->vcnt - 2]);
1142 status = id_to_name(id, USERS_TABLE, &argv[i]);
1144 status = id_to_name(-id, STRINGS_TABLE, &argv[i]);
1145 if (status && status != MR_NO_MATCH)
1148 for (i = 1; i < 8; i+=2) {
1149 id = atoi(argv[i+1]);
1150 if (!strcmp(argv[i], "LIST")) {
1151 status = id_to_name(id, LIST_TABLE, &argv[i+1]);
1152 } else if (!strcmp(argv[i], "USER")) {
1153 status = id_to_name(id, USERS_TABLE, &argv[i+1]);
1154 } else if (!strcmp(argv[i], "KERBEROS")) {
1155 status = id_to_name(id, STRINGS_TABLE, &argv[i+1]);
1156 } else if (!strcmp(argv[i], "NONE")) {
1159 argv[i+1] = strsave("NONE");
1163 argv[i+1] = strsave("???");
1165 if (status && status != MR_NO_MATCH)
1170 (*action)(q->vcnt, argv, actarg);
1172 /* free saved data */
1173 for (i = 0; i < q->vcnt; i++)
1185 int followup_gsha(q, sq, v, action, actarg, cl)
1187 struct save_queue *sq;
1189 int (*action)(), actarg;
1195 while (sq_get_data(sq, &argv)) {
1196 mr_trim_args(q->vcnt, argv);
1200 status = id_to_name(id, USERS_TABLE, &argv[4]);
1202 status = id_to_name(-id, STRINGS_TABLE, &argv[4]);
1203 if (status && status != MR_NO_MATCH)
1207 if (!strcmp(argv[1], "LIST")) {
1208 status = id_to_name(id, LIST_TABLE, &argv[2]);
1209 } else if (!strcmp(argv[1], "USER")) {
1210 status = id_to_name(id, USERS_TABLE, &argv[2]);
1211 } else if (!strcmp(argv[1], "KERBEROS")) {
1212 status = id_to_name(id, STRINGS_TABLE, &argv[2]);
1213 } else if (!strcmp(argv[1], "NONE")) {
1216 argv[2] = strsave("NONE");
1220 argv[2] = strsave("???");
1222 if (status && status != MR_NO_MATCH)
1226 (*action)(q->vcnt, argv, actarg);
1228 /* free saved data */
1229 for (i = 0; i < q->vcnt; i++)
1238 int _sdl_followup(q, argv, cl)
1248 EXEC SQL ALTER SESSION SET SQL_TRACE TRUE;
1250 EXEC SQL ALTER SESSION SET SQL_TRACE FALSE;
1257 static void hex_dump(p)
1260 fprintf(stderr, "Size: %d\n", strlen(p));
1261 while (strlen(p) >= 8) {
1262 fprintf(stderr, "%02x %02x %02x %02x %02x %02x %02x %02x\n",
1263 p[0], p[1], p[2], p[3], p[4], p[5], p[6], p[7]);
1266 switch (strlen(p)) {
1268 fprintf(stderr, "%02x %02x %02x %02x %02x %02x %02x\n",
1269 p[0], p[1], p[2], p[3], p[4], p[5], p[6]);
1272 fprintf(stderr, "%02x %02x %02x %02x %02x %02x\n",
1273 p[0], p[1], p[2], p[3], p[4], p[5]);
1276 fprintf(stderr, "%02x %02x %02x %02x %02x\n",
1277 p[0], p[1], p[2], p[3], p[4]);
1280 fprintf(stderr, "%02x %02x %02x %02x\n",
1281 p[0], p[1], p[2], p[3]);
1284 fprintf(stderr, "%02x %02x %02x\n",
1288 fprintf(stderr, "%02x %02x\n",
1292 fprintf(stderr, "%02x\n",