3 * Query followup routines
5 * Copyright (C) 1987-1998 by the Massachusetts Institute of Technology
6 * For copying and distribution information, please see the file
11 #include <mit-copyright.h>
12 #include "mr_server.h"
23 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, char *[], void *),
295 void *actarg, client *cl)
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, char *[], void *), void *actarg,
336 unsigned char sigbuf[256];
339 EXEC SQL BEGIN DECLARE SECTION;
343 EXEC SQL VAR rsig IS STRING(256);
344 EXEC SQL END DECLARE SECTION;
349 while (sq_get_data(sq, &argv))
353 status = id_to_name(id, USERS_TABLE, &argv[i]);
355 status = id_to_name(-id, STRINGS_TABLE, &argv[i]);
356 if (status && status != MR_NO_MATCH)
359 if (q->vcnt == U_END && strlen(argv[U_SIGNATURE]))
361 login = strtrim(argv[U_NAME]);
362 EXEC SQL SELECT signature, sigdate, sigwho
363 INTO :rsig, :timestamp, :who FROM users
364 WHERE login = :login;
368 status = id_to_name(who, STRINGS_TABLE, &kname);
369 si.timestamp = timestamp;
370 si.SigInfoVersion = 0; /* XXXXX this isn't used */
371 kname_parse(si.pname, si.pinst, si.prealm, kname);
373 si.rawsig = (unsigned char *)strdup(rsig);
374 if (log_flags & LOG_GDSS)
375 com_err(whoami, 0, "rawsig length = %d, sig=\"%s\"",
376 strlen(si.rawsig), si.rawsig);
377 GDSS_Recompose(&si, sigbuf);
379 free(argv[U_SIGNATURE]);
380 argv[U_SIGNATURE] = strdup(sigbuf);
381 if (log_flags & LOG_GDSS)
382 com_err(whoami, 0, "generated signature length %d",
386 (*action)(q->vcnt, argv, actarg);
387 for (j = 0; j < q->vcnt; j++)
397 ** followup_ausr - add finger and pobox entries, set_user_modtime
400 ** argv[0] - login (add_user)
401 ** argv[3] - last name
402 ** argv[4] - first name
403 ** argv[5] - middle name
407 int followup_ausr(struct query *q, char *argv[], client *cl)
409 EXEC SQL BEGIN DECLARE SECTION;
411 char *login, *entity, *name;
413 EXEC SQL END DECLARE SECTION;
416 EXEC SQL BEGIN DECLARE SECTION;
418 int sigwho, timestamp;
419 EXEC SQL END DECLARE SECTION;
424 if (strlen(argv[4]) && strlen(argv[5]))
425 sprintf(fullname, "%s %s %s", argv[4], argv[5], argv[3]);
426 else if (strlen(argv[4]))
427 sprintf(fullname, "%s %s", argv[4], argv[3]);
429 sprintf(fullname, "%s", argv[3]);
432 if (q->vcnt == U_END && *argv[U_SIGNATURE])
434 sprintf(databuf, "%s:%s", argv[U_NAME], argv[U_MITID]);
435 /* skip bytes for timestamp & kname */
436 si.rawsig = (unsigned char *) rawsig;
437 status = GDSS_Verify(databuf, strlen(databuf), argv[U_SIGNATURE], &si);
438 if (strlen(rawsig) > mr_sig_length)
440 com_err(whoami, 0, "GDSS signature would be truncated.");
445 name = kname_unparse(si.pname, si.pinst, si.prealm);
446 status = name_to_id(name, STRINGS_TABLE, &sigwho);
447 if (status == MR_NO_MATCH)
448 sigwho = add_string(name);
451 timestamp = si.timestamp;
455 if (log_flags & LOG_GDSS)
456 hex_dump(argv[U_SIGNATURE]);
457 return gdss2et(status);
472 /* create finger entry, pobox & set modtime on user */
474 EXEC SQL UPDATE users
475 SET modtime = SYSDATE, modby = :who, modwith = :entity,
476 fullname = NVL(:fullname, CHR(0)), affiliation = type,
477 signature = NVL(:rawsig, CHR(0)), sigdate = :timestamp,
478 sigwho = :sigwho, fmodtime = SYSDATE, fmodby = :who,
479 fmodwith = :entity, potype = 'NONE', pmodtime = SYSDATE,
480 pmodby = :who, pmodwith = :entity
481 WHERE login = :login;
483 EXEC SQL UPDATE users
484 SET modtime = SYSDATE, modby = :who, modwith = :entity,
485 fullname = NVL(:fullname, CHR(0)), affiliation = type,
486 fmodtime = SYSDATE, fmodby = :who, fmodwith = :entity,
487 potype = 'NONE', pmodtime = SYSDATE, pmodby = :who, pmodwith = :entity
488 WHERE login = :login;
496 ** followup_uuac - do signature, set_user_modtime
499 ** argv[0] - login (add_user)
500 ** argv[U_SIGNATURE] - sig
504 int followup_uuac(struct query *q, char *argv[], client *cl)
506 EXEC SQL BEGIN DECLARE SECTION;
509 EXEC SQL END DECLARE SECTION;
512 EXEC SQL BEGIN DECLARE SECTION;
515 int sigwho, timestamp;
516 EXEC SQL END DECLARE SECTION;
520 id = *(int *)argv[0];
525 if (q->vcnt == U_MODTIME && *argv[U_SIGNATURE + 1])
528 status = id_to_name(id, USERS_TABLE, &login);
529 sprintf(databuf, "%s:%s", login, argv[U_MITID + 1]);
531 /* skip bytes for timestamp & kname */
532 si.rawsig = (unsigned char *) rawsig;
533 status = GDSS_Verify(databuf, strlen(databuf), argv[U_SIGNATURE + 1],
535 if (strlen(rawsig) > mr_sig_length)
537 com_err(whoami, 0, "GDSS signature would be truncated.");
542 name = kname_unparse(si.pname, si.pinst, si.prealm);
543 status = name_to_id(name, STRINGS_TABLE, &sigwho);
544 if (status == MR_NO_MATCH)
545 sigwho = add_string(name);
548 timestamp = si.timestamp;
552 if (log_flags & LOG_GDSS)
553 hex_dump(argv[U_SIGNATURE + 1]);
554 return gdss2et(status);
565 /* create finger entry, pobox & set modtime on user */
568 EXEC SQL UPDATE users SET modtime = SYSDATE, modby = :who, modwith = :entity,
569 signature = NVL(:rawsig, CHR(0)), sigdate = :timestamp, sigwho = :sigwho
570 WHERE users_id = :id;
572 EXEC SQL UPDATE users SET modtime = SYSDATE, modby = :who, modwith = :entity
573 WHERE users_id = :id;
578 /* followup_gpob: fixes argv[2] based on the IDs currently there and the
579 * type in argv[1]. Then completes the upcall to the user.
581 * argv[2] is of the form "123:234" where the first integer is the machine
582 * ID if it is a pop box, and the second is the string ID if it is an SMTP
583 * box. argv[1] should be "POP", "SMTP", or "NONE". Boxes of type NONE
587 int followup_gpob(struct query *q, struct save_queue *sq, struct validate *v,
588 int (*action)(int, char *[], void *), void *actarg,
593 int mid, sid, status, i;
596 while (sq_get_data(sq, &argv))
598 mr_trim_args(2, argv);
600 p = strchr(argv[2], ':');
605 if (!strcmp(ptype, "POP"))
607 status = id_to_name(mid, MACHINE_TABLE, &argv[2]);
608 if (status == MR_NO_MATCH)
611 else if (!strcmp(ptype, "SMTP"))
613 status = id_to_name(sid, STRINGS_TABLE, &argv[2]);
614 if (status == MR_NO_MATCH)
617 else /* ptype == "NONE" */
622 if (!strcmp(q->shortname, "gpob"))
626 status = id_to_name(sid, USERS_TABLE, &argv[4]);
628 status = id_to_name(-sid, STRINGS_TABLE, &argv[4]);
630 if (status && status != MR_NO_MATCH)
633 (*action)(q->vcnt, argv, actarg);
635 /* free saved data */
636 for (i = 0; i < q->vcnt; i++)
646 /* followup_gsnt: fix the ace_name in argv[7]. argv[6] will contain the
647 * ace_type: "LIST", "USER", or "NONE". Decode the id in argv[7] into the
648 * proper name based on the type, and repace that string in the argv.
649 * Also fixes the modby field by called followup_fix_modby.
652 int followup_gsnt(struct query *q, struct save_queue *sq, struct validate *v,
653 int (*action)(int, char *[], void *), void *actarg,
657 int id, i, idx, status;
661 while (sq_get_data(sq, &argv))
663 mr_trim_args(q->vcnt, argv);
665 id = atoi(argv[i = q->vcnt - 2]);
667 status = id_to_name(id, USERS_TABLE, &argv[i]);
669 status = id_to_name(-id, STRINGS_TABLE, &argv[i]);
670 if (status && status != MR_NO_MATCH)
673 id = atoi(argv[idx]);
674 type = argv[idx - 1];
676 if (!strcmp(type, "LIST"))
677 status = id_to_name(id, LIST_TABLE, &argv[idx]);
678 else if (!strcmp(type, "USER"))
679 status = id_to_name(id, USERS_TABLE, &argv[idx]);
680 else if (!strcmp(type, "KERBEROS"))
681 status = id_to_name(id, STRINGS_TABLE, &argv[idx]);
682 else if (!strcmp(type, "NONE"))
686 argv[idx] = strdup("NONE");
692 argv[idx] = strdup("???");
694 if (status && status != MR_NO_MATCH)
698 (*action)(q->vcnt, argv, actarg);
700 /* free saved data */
701 for (i = 0; i < q->vcnt; i++)
711 /* followup_ghst: fix the ace_name in argv[12]. argv[11] will contain the
712 * ace_type: "LIST", "USER", or "NONE". Decode the id in argv[12] into the
713 * proper name based on the type, and repace that string in the argv.
714 * Also fixes the modby field by called followup_fix_modby.
717 int followup_ghst(struct query *q, struct save_queue *sq, struct validate *v,
718 int (*action)(int, char *[], void *), void *actarg,
722 int id, i, idx, status;
724 while (sq_get_data(sq, &argv))
726 mr_trim_args(q->vcnt, argv);
728 id = atoi(argv[i = q->vcnt - 2]);
730 status = id_to_name(id, USERS_TABLE, &argv[i]);
732 status = id_to_name(-id, STRINGS_TABLE, &argv[i]);
733 if (status && status != MR_NO_MATCH)
737 status = id_to_name(id, STRINGS_TABLE, &argv[13]);
741 status = id_to_name(id, STRINGS_TABLE, &argv[14]);
746 status = id_to_name(-id, STRINGS_TABLE, &argv[16]);
748 status = id_to_name(id, USERS_TABLE, &argv[16]);
749 if (status && status != MR_NO_MATCH)
753 id = atoi(argv[idx]);
754 type = strtrim(argv[idx - 1]);
756 if (!strcmp(type, "LIST"))
757 status = id_to_name(id, LIST_TABLE, &argv[idx]);
758 else if (!strcmp(type, "USER"))
759 status = id_to_name(id, USERS_TABLE, &argv[idx]);
760 else if (!strcmp(type, "KERBEROS"))
761 status = id_to_name(id, STRINGS_TABLE, &argv[idx]);
762 else if (!strcmp(type, "NONE"))
766 argv[idx] = strdup("NONE");
772 argv[idx] = strdup("???");
774 if (status && status != MR_NO_MATCH)
778 (*action)(q->vcnt, argv, actarg);
780 /* free saved data */
781 for (i = 0; i < q->vcnt; i++)
791 /* followup_glin: fix the ace_name in argv[8]. argv[7] will contain the
792 * ace_type: "LIST", "USER", or "NONE". Decode the id in argv[8] into the
793 * proper name based on the type, and repace that string in the argv.
794 * Also fixes the modby field by called followup_fix_modby.
797 int followup_glin(struct query *q, struct save_queue *sq, struct validate *v,
798 int (*action)(int, char *[], void *), void *actarg,
802 int id, i, idx, status;
805 if (!strcmp(q->shortname, "gsin"))
808 while (sq_get_data(sq, &argv))
810 mr_trim_args(q->vcnt, argv);
812 id = atoi(argv[i = q->vcnt - 2]);
814 status = id_to_name(id, USERS_TABLE, &argv[i]);
816 status = id_to_name(-id, STRINGS_TABLE, &argv[i]);
817 if (status && status != MR_NO_MATCH)
820 id = atoi(argv[idx]);
821 type = argv[idx - 1];
823 if (!strcmp(type, "LIST"))
824 status = id_to_name(id, LIST_TABLE, &argv[idx]);
825 else if (!strcmp(type, "USER"))
826 status = id_to_name(id, USERS_TABLE, &argv[idx]);
827 else if (!strcmp(type, "KERBEROS"))
828 status = id_to_name(id, STRINGS_TABLE, &argv[idx]);
829 else if (!strcmp(type, "NONE"))
833 argv[idx] = strdup("NONE");
839 argv[idx] = strdup("???");
841 if (status && status != MR_NO_MATCH)
844 if (!strcmp(q->shortname, "glin") && atoi(argv[6]) == -1)
846 argv[6] = realloc(argv[6], strlen(UNIQUE_GID) + 1);
847 strcpy(argv[6], UNIQUE_GID);
851 (*action)(q->vcnt, argv, actarg);
853 /* free saved data */
854 for (i = 0; i < q->vcnt; i++)
864 /* followup_gqot: Fix the entity name, directory name & modby fields
865 * argv[0] = filsys_id
867 * argv[2] = entity_id
868 * argv[3] = ascii(quota)
871 int followup_gqot(struct query *q, struct save_queue *sq, struct validate *v,
872 int (*action)(int, char *[], void *), void *actarg,
877 EXEC SQL BEGIN DECLARE SECTION;
880 EXEC SQL END DECLARE SECTION;
883 if (!strcmp(q->name, "get_quota") ||
884 !strcmp(q->name, "get_quota_by_filesys"))
888 while (sq_get_data(sq, &argv))
895 status = id_to_name(atoi(argv[2]), USERS_TABLE, &argv[2]);
899 status = id_to_name(atoi(argv[2]), LIST_TABLE, &argv[2]);
903 argv[2] = strdup("system:anyuser");
908 sprintf(argv[2], "%d", id);
911 id = atoi(argv[idx]);
913 argv[idx] = malloc(256);
918 EXEC SQL SELECT name INTO :name FROM filesys
919 WHERE label = :label;
923 EXEC SQL SELECT dir INTO :name FROM nfsphys
924 WHERE nfsphys_id = :id;
926 if (sqlca.sqlerrd[2] != 1)
927 sprintf(argv[idx], "#%d", id);
929 id = atoi(argv[idx + 3]);
931 status = id_to_name(id, USERS_TABLE, &argv[idx + 3]);
933 status = id_to_name(-id, STRINGS_TABLE, &argv[idx + 3]);
934 if (status && status != MR_NO_MATCH)
936 (*action)(q->vcnt, argv, actarg);
937 for (j = 0; j < q->vcnt; j++)
946 /* followup_aqot: Add allocation to nfsphys after creating quota.
947 * argv[0] = filsys_id
948 * argv[1] = type if "add_quota" or "update_quota"
950 * argv[3 or 2] = ascii(quota)
953 int followup_aqot(struct query *q, char *argv[], client *cl)
955 EXEC SQL BEGIN DECLARE SECTION;
956 int quota, id, fs, who, physid, table;
957 char *entity, *qtype, *tname;
958 EXEC SQL END DECLARE SECTION;
964 tname = table_name[table];
965 fs = *(int *)argv[0];
966 EXEC SQL SELECT phys_id INTO :physid FROM filesys
967 WHERE filsys_id = :fs;
971 if (!strcmp(q->shortname, "aqot") || !strcmp(q->shortname, "uqot"))
974 id = *(int *)argv[2];
975 quota = atoi(argv[3]);
976 sprintf(incr_qual, "q.filsys_id = %d", fs);
981 id = *(int *)argv[1];
982 quota = atoi(argv[2]);
983 sprintf(incr_qual, "q.filsys_id = %d AND q.type = '%s' AND "
984 "q.entity_id = %d", fs, qtype, id);
987 /* quota case of incremental_{before|after} only looks at slot 1 */
988 incr_argv[1] = qtype;
990 /* Follows one of many possible gross hacks to fix these particular
991 * conflicts between what is possible in the query table and what
992 * is possible in SQL.
994 if (q->type == APPEND)
996 incremental_clear_before();
997 EXEC SQL INSERT INTO quota
998 (filsys_id, type, entity_id, quota, phys_id)
999 VALUES (:fs, NVL(:qtype, CHR(0)), :id, :quota, :physid);
1000 incremental_after(table, incr_qual, incr_argv);
1004 incremental_before(table, incr_qual, incr_argv);
1005 EXEC SQL UPDATE quota SET quota = :quota
1006 WHERE filsys_id = :fs AND type = :qtype AND entity_id = :id;
1007 status = mr_errcode;
1008 incremental_after(table, incr_qual, incr_argv);
1013 flush_name(argv[0], table);
1014 if (q->type == APPEND)
1016 EXEC SQL UPDATE tblstats SET appends = appends + 1, modtime = SYSDATE
1017 WHERE table_name = :tname;
1021 EXEC SQL UPDATE tblstats SET updates = updates + 1, modtime = SYSDATE
1022 WHERE table_name = :tname;
1025 /* Proceed with original followup */
1026 who = cl->client_id;
1027 entity = cl->entity;
1029 EXEC SQL UPDATE quota
1030 SET modtime = SYSDATE, modby = :who, modwith = :entity
1031 WHERE filsys_id = :fs and type = :qtype and entity_id = :id;
1032 EXEC SQL UPDATE nfsphys SET allocated = allocated + :quota
1033 WHERE nfsphys_id = :physid;
1040 /* Necessitated by the requirement of a correlation name by the incremental
1041 * routines, since query table deletes don't provide one.
1043 int followup_dqot(struct query *q, char **argv, client *cl)
1048 EXEC SQL BEGIN DECLARE SECTION;
1049 char incr_qual[80], *tname;
1050 EXEC SQL END DECLARE SECTION;
1053 tname = table_name[table];
1054 fs = *(int *)argv[0];
1055 if (!strcmp(q->shortname, "dqot"))
1058 id = *(int *)argv[2];
1063 id = *(int *)argv[1];
1065 sprintf(incr_qual, "q.filsys_id = %d AND q.type = '%s' AND q.entity_id = %d",
1068 /* quota case of incremental_{before|after} only looks at slot 1 */
1069 incr_argv[1] = qtype;
1071 incremental_before(table, incr_qual, incr_argv);
1072 EXEC SQL DELETE FROM quota q WHERE q.filsys_id = :fs AND q.type = :qtype
1073 AND q.entity_id = :id;
1074 incremental_clear_after();
1078 flush_name(argv[0], table);
1080 EXEC SQL UPDATE tblstats SET deletes = deletes + 1, modtime = SYSDATE
1081 WHERE table_name = :tname;
1086 int followup_gpce(struct query *q, struct save_queue *sq, struct validate *v,
1087 int (*action)(int, char *[], void *), void *actarg,
1095 while (sq_get_data(sq, &argv))
1097 id = atoi(argv[PCAP_QSERVER]);
1098 status = id_to_name(id, MACHINE_TABLE, &argv[PCAP_QSERVER]);
1103 status = id_to_name(id, USERS_TABLE, &argv[i]);
1105 status = id_to_name(-id, STRINGS_TABLE, &argv[i]);
1106 if (status && status != MR_NO_MATCH)
1108 (*action)(q->vcnt, argv, actarg);
1109 for (j = 0; j < q->vcnt; j++)
1121 int followup_gzcl(struct query *q, struct save_queue *sq, struct validate *v,
1122 int (*action)(int, char *[], void *), void *actarg,
1128 while (sq_get_data(sq, &argv))
1130 mr_trim_args(q->vcnt, argv);
1132 id = atoi(argv[i = q->vcnt - 2]);
1134 status = id_to_name(id, USERS_TABLE, &argv[i]);
1136 status = id_to_name(-id, STRINGS_TABLE, &argv[i]);
1137 if (status && status != MR_NO_MATCH)
1140 for (i = 1; i < 8; i += 2)
1142 id = atoi(argv[i + 1]);
1143 if (!strcmp(argv[i], "LIST"))
1144 status = id_to_name(id, LIST_TABLE, &argv[i + 1]);
1145 else if (!strcmp(argv[i], "USER"))
1146 status = id_to_name(id, USERS_TABLE, &argv[i + 1]);
1147 else if (!strcmp(argv[i], "KERBEROS"))
1148 status = id_to_name(id, STRINGS_TABLE, &argv[i + 1]);
1149 else if (!strcmp(argv[i], "NONE"))
1153 argv[i + 1] = strdup("NONE");
1159 argv[i + 1] = strdup("???");
1161 if (status && status != MR_NO_MATCH)
1166 (*action)(q->vcnt, argv, actarg);
1168 /* free saved data */
1169 for (i = 0; i < q->vcnt; i++)
1181 int followup_gsha(struct query *q, struct save_queue *sq, struct validate *v,
1182 int (*action)(int, char *[], void *), void *actarg,
1188 while (sq_get_data(sq, &argv))
1190 mr_trim_args(q->vcnt, argv);
1194 status = id_to_name(id, USERS_TABLE, &argv[4]);
1196 status = id_to_name(-id, STRINGS_TABLE, &argv[4]);
1197 if (status && status != MR_NO_MATCH)
1201 if (!strcmp(argv[1], "LIST"))
1202 status = id_to_name(id, LIST_TABLE, &argv[2]);
1203 else if (!strcmp(argv[1], "USER"))
1204 status = id_to_name(id, USERS_TABLE, &argv[2]);
1205 else if (!strcmp(argv[1], "KERBEROS"))
1206 status = id_to_name(id, STRINGS_TABLE, &argv[2]);
1207 else if (!strcmp(argv[1], "NONE"))
1211 argv[2] = strdup("NONE");
1217 argv[2] = strdup("???");
1219 if (status && status != MR_NO_MATCH)
1223 (*action)(q->vcnt, argv, actarg);
1225 /* free saved data */
1226 for (i = 0; i < q->vcnt; i++)
1235 int _sdl_followup(struct query *q, char *argv[], client *cl)
1242 EXEC SQL ALTER SESSION SET SQL_TRACE TRUE;
1244 EXEC SQL ALTER SESSION SET SQL_TRACE FALSE;
1250 static void hex_dump(unsigned char *p)
1252 fprintf(stderr, "Size: %d\n", strlen(p));
1253 while (strlen(p) >= 8)
1255 fprintf(stderr, "%02x %02x %02x %02x %02x %02x %02x %02x\n",
1256 p[0], p[1], p[2], p[3], p[4], p[5], p[6], p[7]);
1262 fprintf(stderr, "%02x %02x %02x %02x %02x %02x %02x\n",
1263 p[0], p[1], p[2], p[3], p[4], p[5], p[6]);
1266 fprintf(stderr, "%02x %02x %02x %02x %02x %02x\n",
1267 p[0], p[1], p[2], p[3], p[4], p[5]);
1270 fprintf(stderr, "%02x %02x %02x %02x %02x\n",
1271 p[0], p[1], p[2], p[3], p[4]);
1274 fprintf(stderr, "%02x %02x %02x %02x\n",
1275 p[0], p[1], p[2], p[3]);
1278 fprintf(stderr, "%02x %02x %02x\n",
1282 fprintf(stderr, "%02x %02x\n",
1286 fprintf(stderr, "%02x\n",