3 * (c) Copyright 1988 by the Massachusetts Institute of Technology.
4 * For copying and distribution information, please see the file
8 #include <mit-copyright.h>
12 EXEC SQL INCLUDE sqlca;
14 static char phase2_qc_rcsid[] = "$Header$";
20 EXEC SQL BEGIN DECLARE SECTION;
21 int iid = id, found = 1;
23 EXEC SQL END DECLARE SECTION;
25 EXEC SQL DECLARE csr201 CURSOR FOR
26 SELECT cluster.name FROM cluster, mcmap
27 WHERE cluster.clu_id=mcmap.clu_id AND mcmap.mach_id = :iid;
28 if (sqlca.sqlcode != 0) ingerr(&sqlca.sqlcode);
31 EXEC SQL FETCH csr201 INTO :name;
32 if (sqlca.sqlcode != 0) {
33 ingerr(&sqlca.sqlcode);
39 printf("Clusqter %s, non-existant machine %d in cluster map\n", name, id);
41 EXEC SQL CLOSE csr201;
48 EXEC SQL BEGIN DECLARE SECTION;
49 int iid = id, found = 1;
51 EXEC SQL END DECLARE SECTION;
53 EXEC SQL DECLARE csr202 CURSOR FOR
54 SELECT machine.name FROM machine, mcmap
55 WHERE machine.mach_id=mcmap.mach_id AND mcmap.clu_id=:iid;
56 if (sqlca.sqlcode != 0) ingerr(&sqlca.sqlcode);
59 EXEC SQL FETCH csr202 INTO :name;
60 if (sqlca.sqlcode != 0) {
61 ingerr(&sqlca.sqlcode);
67 printf("Machine %s, non-existant cluster %d in cluster map\n", name, id);
69 EXEC SQL CLOSE csr202;
73 pobox_check(id, u, hint)
80 if (!hash_lookup(machines, u->pobox_id)) {
81 printf("User %s(%s) has P.O.Box on non-existant machine %d\n",
82 u->login, u->fullname, u->pobox_id);
83 if (single_fix("Delete", 0)) {
84 remove_pobox(u->users_id);
90 if (!string_check(u->pobox_id)) {
91 printf("User %s(%s) has P.O.Box with non-existant string %d\n",
92 u->login, u->fullname, u->pobox_id);
93 if (single_fix("Delete", 0)) {
94 remove_pobox(u->users_id);
108 EXEC SQL BEGIN DECLARE SECTION;
109 int rowcount, iid = id;
110 EXEC SQL END DECLARE SECTION;
112 EXEC SQL UPDATE users SET potype='NONE' WHERE users.users_id = :iid;
113 EXEC SQL INQUIRE_SQL(:rowcount = rowcount);
115 printf("%d entr%s removed\n", rowcount, rowcount==1?"y":"ies");
117 printf("Not removed\n");
124 EXEC SQL BEGIN DECLARE SECTION;
125 int iid = id, found = 1;
126 char label[17], data[33];
127 EXEC SQL END DECLARE SECTION;
129 EXEC SQL DECLARE csr203 CURSOR FOR
130 SELECT serv_label, serv_cluster FROM svc
132 if (sqlca.sqlcode != 0) ingerr(&sqlca.sqlcode);
133 EXEC SQL OPEN csr203;
135 EXEC SQL FETCH csr203 INTO :label, :data;
136 if (sqlca.sqlcode != 0) {
137 ingerr(&sqlca.sqlcode);
144 printf("Cluster data [%s] %s for non-existant cluster %d\n",
147 EXEC SQL CLOSE csr203;
151 list_check(id, l, hint)
156 switch (l->acl_type) {
158 if (!hash_lookup(lists, l->acl_id)) {
159 printf("List %s has bad LIST acl %d\n", l->name, l->acl_id);
160 if (single_fix("Patch", 1)) {
161 fix_list_acl(l->list_id);
166 if (!hash_lookup(users, l->acl_id)) {
167 printf("List %s has bad USER acl %d\n", l->name, l->acl_id);
168 if (single_fix("Patch", 1)) {
169 fix_list_acl(l->list_id);
179 EXEC SQL BEGIN DECLARE SECTION;
180 int rowcount, iid = id;
181 EXEC SQL END DECLARE SECTION;
183 EXEC SQL UPDATE list SET acl_id = :iid, acl_type='LIST'
184 WHERE list_id = :iid;
185 EXEC SQL INQUIRE_SQL(:rowcount = rowcount);
187 printf("%d entr%s fixed\n", rowcount, rowcount==1?"y":"ies");
189 printf("Not fixed\n");
197 EXEC SQL BEGIN DECLARE SECTION;
198 int mid, iid = id, found = 1;
199 char mtype[9], *name = "";
200 EXEC SQL END DECLARE SECTION;
202 EXEC SQL DECLARE csr204 CURSOR FOR
203 SELECT member_type, member_id FROM imembers
204 WHERE list_id = :iid AND direct=1;
205 if (sqlca.sqlcode != 0) ingerr(&sqlca.sqlcode);
206 EXEC SQL OPEN csr204;
208 EXEC SQL FETCH csr204 INTO :mtype, :mid;
209 if (sqlca.sqlcode != 0) {
210 ingerr(&sqlca.sqlcode);
217 name = ((struct list *) hash_lookup(lists, mid))->name;
218 else if (mtype[0] == 'U')
219 name = ((struct user *) hash_lookup(users, mid))->login;
220 else if (mtype[0] == 'S' || mtype[0] == 'K')
221 name = ((struct string *) hash_lookup(strings, mid))->name;
222 printf("Non-existant list %d has member %s %s\n", iid, mtype, name);
224 EXEC SQL CLOSE csr204;
231 EXEC SQL BEGIN DECLARE SECTION;
232 int lid, iid = id, found = 1;
234 EXEC SQL END DECLARE SECTION;
236 EXEC SQL DECLARE csr205 CURSOR FOR
237 SELECT list_id FROM imembers
238 WHERE member_id = :iid AND member_type='USER' AND direct=1;
239 if (sqlca.sqlcode != 0) ingerr(&sqlca.sqlcode);
240 EXEC SQL OPEN csr205;
242 EXEC SQL FETCH csr205 INTO :lid;
243 if (sqlca.sqlcode != 0) {
244 ingerr(&sqlca.sqlcode);
249 printf("List %s has non-existant user member, id %d\n",
250 ((struct list *)hash_lookup(lists, lid))->name, iid);
252 EXEC SQL CLOSE csr205;
259 EXEC SQL BEGIN DECLARE SECTION;
260 int lid, iid = id, found = 1;
262 EXEC SQL END DECLARE SECTION;
264 EXEC SQL DECLARE csr206 CURSOR FOR
265 SELECT list_id FROM imembers
266 WHERE member_id = :iid AND member_type='LIST' AND direct=1;
267 if (sqlca.sqlcode != 0) ingerr(&sqlca.sqlcode);
268 EXEC SQL OPEN csr206;
270 EXEC SQL FETCH csr206 INTO :lid;
271 if (sqlca.sqlcode != 0) {
272 ingerr(&sqlca.sqlcode);
277 printf("List %s has non-existant list member, id %d\n",
278 ((struct list *)hash_lookup(lists, lid))->name, iid);
280 EXEC SQL CLOSE csr206;
287 EXEC SQL BEGIN DECLARE SECTION;
288 int lid, iid = id, found = 1;
290 EXEC SQL END DECLARE SECTION;
292 EXEC SQL DECLARE csr207 CURSOR FOR
293 SELECT list_id FROM imembers
294 WHERE member_id = :iid AND member_type='STRING' AND direct=1;
295 if (sqlca.sqlcode != 0) ingerr(&sqlca.sqlcode);
296 EXEC SQL OPEN csr207;
298 EXEC SQL FETCH csr207 INTO :lid;
299 if (sqlca.sqlcode != 0) {
300 ingerr(&sqlca.sqlcode);
305 printf("List %s has non-existant string member, id %d\n",
306 ((struct list *)hash_lookup(lists, lid))->name, iid);
308 EXEC SQL CLOSE csr207;
316 EXEC SQL BEGIN DECLARE SECTION;
317 int lid, iid = id, found = 1;
319 EXEC SQL END DECLARE SECTION;
321 EXEC SQL DECLARE csr208 CURSOR FOR
322 SELECT list_id FROM imembers
323 WHERE member_id = :iid AND member_type='KERBEROS' AND direct=1;
324 if (sqlca.sqlcode != 0) ingerr(&sqlca.sqlcode);
325 EXEC SQL OPEN csr208;
327 EXEC SQL FETCH csr208 INTO :lid;
328 if (sqlca.sqlcode != 0) {
329 ingerr(&sqlca.sqlcode);
334 printf("List %s has non-existant kerberos member, id %d\n",
335 ((struct list *)hash_lookup(lists, lid))->name, iid);
337 EXEC SQL CLOSE csr208;
343 EXEC SQL BEGIN DECLARE SECTION;
345 EXEC SQL END DECLARE SECTION;
347 EXEC SQL BEGIN DECLARE SECTION;
349 EXEC SQL END DECLARE SECTION;
351 EXEC SQL DELETE FROM imembers WHERE member_type='USER' AND
352 member_id = :id AND direct = 1;
353 EXEC SQL INQUIRE_SQL(:rowcount = rowcount);
355 printf("%d entr%s deleted\n", rowcount, rowcount==1?"y":"ies");
357 printf("Not deleted\n");
358 modified("imembers");
362 EXEC SQL BEGIN DECLARE SECTION;
364 EXEC SQL END DECLARE SECTION;
366 EXEC SQL BEGIN DECLARE SECTION;
368 EXEC SQL END DECLARE SECTION;
370 EXEC SQL DELETE FROM imembers WHERE member_type='LIST' AND
371 member_id = :id AND direct=1;
372 EXEC SQL INQUIRE_SQL(:rowcount = rowcount);
374 printf("%d entr%s deleted\n", rowcount, rowcount==1?"y":"ies");
376 printf("Not deleted\n");
377 modified("imembers");
381 EXEC SQL BEGIN DECLARE SECTION;
383 EXEC SQL END DECLARE SECTION;
385 EXEC SQL BEGIN DECLARE SECTION;
387 EXEC SQL END DECLARE SECTION;
389 EXEC SQL DELETE FROM imembers WHERE member_type='STRING' AND
390 member_id = :id AND direct=1;
391 EXEC SQL INQUIRE_SQL(:rowcount = rowcount);
393 printf("%d entr%s deleted\n", rowcount, rowcount==1?"y":"ies");
395 printf("Not deleted\n");
396 modified("imembers");
401 EXEC SQL BEGIN DECLARE SECTION;
403 EXEC SQL END DECLARE SECTION;
405 EXEC SQL BEGIN DECLARE SECTION;
407 EXEC SQL END DECLARE SECTION;
409 EXEC SQL DELETE FROM imembers WHERE member_type='KERBEROS' AND
410 member_id = :id AND direct=1;
411 EXEC SQL INQUIRE_SQL(:rowcount = rowcount);
413 printf("%d entr%s deleted\n", rowcount, rowcount==1?"y":"ies");
415 printf("Not deleted\n");
416 modified("imembers");
421 EXEC SQL BEGIN DECLARE SECTION;
423 EXEC SQL END DECLARE SECTION;
425 EXEC SQL BEGIN DECLARE SECTION;
427 EXEC SQL END DECLARE SECTION;
430 EXEC SQL DECLARE csr209 CURSOR FOR
431 SELECT service FROM serverhosts
433 if (sqlca.sqlcode != 0) ingerr(&sqlca.sqlcode);
434 EXEC SQL OPEN csr209;
436 EXEC SQL FETCH csr209 INTO :name;
437 if (sqlca.sqlcode != 0) {
438 ingerr(&sqlca.sqlcode);
443 printf("ServerHost entry for service %s non-existant host %d\n",
446 EXEC SQL CLOSE csr209;
451 EXEC SQL BEGIN DECLARE SECTION;
453 EXEC SQL END DECLARE SECTION;
455 EXEC SQL BEGIN DECLARE SECTION;
457 EXEC SQL END DECLARE SECTION;
459 EXEC SQL DELETE FROM serverhosts WHERE mach_id = :id;
460 EXEC SQL INQUIRE_SQL(:rowcount = rowcount);
462 printf("%d entr%s deleted\n", rowcount, rowcount==1?"y":"ies");
464 printf("Not deleted\n");
465 modified("serverhosts");
469 static int fnchecklen;
476 if (n->mach_id == f->mach_id &&
477 !strncmp(f->dir, n->dir, strlen(n->dir)) &&
478 strlen(n->dir) > fnchecklen) {
480 fnchecklen = strlen(n->dir);
485 check_fs(id, f, hint)
486 EXEC SQL BEGIN DECLARE SECTION;
488 EXEC SQL END DECLARE SECTION;
489 register struct filesys *f;
492 EXEC SQL BEGIN DECLARE SECTION;
493 int id1, id2, id3, rowcount;
495 EXEC SQL END DECLARE SECTION;
499 if (!hash_lookup(machines, f->mach_id)) {
500 printf("Filesys %s with bad machine %d\n", f->name, f->mach_id);
501 if (single_fix("Fix", 0)) {
502 EXEC SQL UPDATE filesys SET mach_id = 0 WHERE filsys_id = :id;
503 EXEC SQL INQUIRE_SQL(:rowcount = rowcount);
505 printf("%d entr%s fixed\n",rowcount, rowcount==1?"y":"ies");
507 printf("Not fixed\n");
513 if (!hash_lookup(users, f->owner)) {
514 printf("Filesys %s with bad owning user %d\n", f->name, f->owner);
515 if (single_fix("Fix", 1)) {
516 zero_fix("filesys", "owner", "filsys_id", f->filsys_id);
520 if (!hash_lookup(lists, f->owners)) {
521 printf("Filesys %s with bad owning group %d\n", f->name, f->owners);
522 if (single_fix("Fix", 1)) {
523 zero_fix("filesys", "owners", "filsys_id", f->filsys_id);
528 if (f->type == 'N') {
529 if (!hash_lookup(nfsphys, f->phys_id)) {
530 m = (struct machine *)hash_lookup(machines, f->mach_id);
531 printf("Filesys %s with bad phys_id %d\n", f->name, f->phys_id);
532 if (single_fix("Fix", 1)) {
534 hash_step(nfsphys, fsmatch, f);
535 if (fnchecklen != 0) {
539 EXEC SQL UPDATE filesys SET phys_id = :id1 WHERE filsys_id = :id2;
540 EXEC SQL INQUIRE_SQL(:rowcount = rowcount);
542 printf("%d entr%s fixed\n",rowcount, rowcount==1?"y":"ies");
544 printf("Not fixed\n");
547 printf("No NFSphys exsits for %s:%s\n", m->name, f->dir);
548 if (single_fix("Create", 0)) {
553 if (set_next_object_id("nfsphys_id", "nfsphys") !=
555 printf("Unable to assign unique ID\n");
558 EXEC SQL SELECT COUNT(*) INTO :rowcount FROM numvalues
559 WHERE name='nfsphys_id';
561 printf("Unable to retrieve unique ID\n");
564 EXEC SQL INSERT INTO mfsphys (mfsphys_id, mach_id,
565 device, dir, status, allocated, size, modtime,
566 modby, modwith) VALUES (:id1, :id3, '???', :dir,
567 0, 0, 0, 'now', 0, 'dbck');
568 EXEC SQL INQUIRE_SQL(:rowcount = rowcount);
570 printf("%d entr%s created\n", rowcount,
571 rowcount==1?"y":"ies");
573 printf("Not created\n");
575 n = (struct nfsphys *)malloc(sizeof(struct nfsphys));
577 out_of_mem("storing new nfsphys");
583 hash_store(nfsphys, id1, n);
584 EXEC SQL UPDATE filesys SET phys_id = :id1
585 WHERE filsys_id = :id2;
586 EXEC SQL INQUIRE_SQL(:rowcount = rowcount);
588 printf("%d filesys entr%s fixed\n", rowcount,
589 rowcount==1?"y":"ies");
591 printf("Not fixed\n");
601 check_nfsphys(id, n, hint)
606 if (!hash_lookup(machines, n->mach_id)) {
607 printf("NFSphys %d(%s) on non-existant machine %d\n",
608 id, n->dir, n->mach_id);
609 if (single_fix("Delete", 0))
610 single_delete("nfsphys", "nfsphys_id", id);
615 EXEC SQL BEGIN DECLARE SECTION;
617 EXEC SQL END DECLARE SECTION;
619 EXEC SQL BEGIN DECLARE SECTION;
621 EXEC SQL END DECLARE SECTION;
624 EXEC SQL DECLARE csr210 CURSOR FOR
625 SELECT filsys_id FROM fsgroup
626 WHERE group_id = :id;
627 if (sqlca.sqlcode != 0) ingerr(&sqlca.sqlcode);
628 EXEC SQL OPEN csr210;
630 EXEC SQL FETCH csr210 INTO :id1;
631 if (sqlca.sqlcode != 0) {
632 ingerr(&sqlca.sqlcode);
637 if (f = (struct filesys *) hash_lookup(filesys, id1))
638 printf("Missing fsgroup %d has member filesystem %s\n", id, f->name);
640 printf("Missing fsgroup %d has member filesystem %d\n", id, id1);
642 EXEC SQL CLOSE csr210;
673 printf("FSGroup %s has type %s instead of FSGROUP\n", f->name, t);
680 EXEC SQL BEGIN DECLARE SECTION;
681 int rowcount, id = f->filsys_id;
682 EXEC SQL END DECLARE SECTION;
684 EXEC SQL UPDATE filesys SET type='FSGROUP' WHERE filsys_id = :id;
685 EXEC SQL INQUIRE_SQL(:rowcount = rowcount);
687 printf("%d entr%s fixed\n", rowcount, rowcount==1?"y":"ies");
689 printf("Not fixed\n");
693 show_fsg_nomember(id)
694 EXEC SQL BEGIN DECLARE SECTION;
696 EXEC SQL END DECLARE SECTION;
698 EXEC SQL BEGIN DECLARE SECTION;
700 EXEC SQL END DECLARE SECTION;
703 EXEC SQL DECLARE csr211 CURSOR FOR
704 SELECT group_id FROM fsgroup
705 WHERE filsys_id = :id;
706 if (sqlca.sqlcode != 0) ingerr(&sqlca.sqlcode);
707 EXEC SQL OPEN csr211;
709 EXEC SQL FETCH csr211 INTO :id1;
710 if (sqlca.sqlcode != 0) {
711 ingerr(&sqlca.sqlcode);
716 if (f = (struct filesys *) hash_lookup(filesys, id1))
717 printf("FSGroup %s has missing member %d\n", f->name, id);
719 printf("FSGroup %d has missing member %d\n", id1, id);
721 EXEC SQL CLOSE csr211;
725 show_quota_nouser(id)
726 EXEC SQL BEGIN DECLARE SECTION;
728 EXEC SQL END DECLARE SECTION;
730 EXEC SQL BEGIN DECLARE SECTION;
732 EXEC SQL END DECLARE SECTION;
734 EXEC SQL DECLARE csr212 CURSOR FOR
735 SELECT filsys_id FROM quota
736 WHERE entity_id = :id AND type='USER';
737 if (sqlca.sqlcode != 0) ingerr(&sqlca.sqlcode);
738 EXEC SQL OPEN csr212;
740 EXEC SQL FETCH csr212 INTO :id1;
741 if (sqlca.sqlcode != 0) {
742 ingerr(&sqlca.sqlcode);
747 printf("Quota on fs %d for non-existant user %d\n", id1, id);
749 EXEC SQL CLOSE csr212;
753 show_quota_nolist(id)
754 EXEC SQL BEGIN DECLARE SECTION;
756 EXEC SQL END DECLARE SECTION;
758 EXEC SQL BEGIN DECLARE SECTION;
760 EXEC SQL END DECLARE SECTION;
762 EXEC SQL DECLARE csr213 CURSOR FOR
763 SELECT filsys_id FROM quota
764 WHERE entity_id = :id AND type='GROUP';
765 if (sqlca.sqlcode != 0) ingerr(&sqlca.sqlcode);
766 EXEC SQL OPEN csr213;
768 EXEC SQL FETCH csr213 INTO :id1;
769 if (sqlca.sqlcode != 0) {
770 ingerr(&sqlca.sqlcode);
775 printf("Quota on fs %d for non-existant list %d\n", id1, id);
777 EXEC SQL CLOSE csr213;
782 EXEC SQL BEGIN DECLARE SECTION;
784 EXEC SQL END DECLARE SECTION;
786 EXEC SQL BEGIN DECLARE SECTION;
788 EXEC SQL END DECLARE SECTION;
790 id1 = ((struct filesys *)hash_lookup(filesys, id))->phys_id;
791 EXEC SQL DELETE FROM quota
792 WHERE entity_id = :id AND type = 'USER';
793 EXEC SQL INQUIRE_SQL(:rowcount = rowcount);
795 printf("%d entr%s deleted\n",rowcount, rowcount==1?"y":"ies");
797 printf("Not deleted\n");
802 EXEC SQL BEGIN DECLARE SECTION;
804 EXEC SQL END DECLARE SECTION;
806 EXEC SQL BEGIN DECLARE SECTION;
808 EXEC SQL END DECLARE SECTION;
810 id1 = ((struct filesys *)hash_lookup(filesys, id))->phys_id;
811 EXEC SQL DELETE FROM quota WHERE entity_id = :id AND type='GROUP';
812 EXEC SQL INQUIRE_SQL(:rowcount = rowcount);
814 printf("%d entr%s deleted\n",rowcount, rowcount==1?"y":"ies");
816 printf("Not deleted\n");
821 EXEC SQL BEGIN DECLARE SECTION;
823 EXEC SQL END DECLARE SECTION;
825 EXEC SQL BEGIN DECLARE SECTION;
828 EXEC SQL END DECLARE SECTION;
830 EXEC SQL DECLARE csr214 CURSOR FOR
831 SELECT entity_id, type FROM quota
832 WHERE filsys_id = :id;
833 if (sqlca.sqlcode != 0) ingerr(&sqlca.sqlcode);
834 EXEC SQL OPEN csr214;
836 EXEC SQL FETCH csr214 INTO :id1, :type;
837 if (sqlca.sqlcode != 0) {
838 ingerr(&sqlca.sqlcode);
843 printf("Quota for %s %d on non-existant filesys %d\n", type, id1, id);
845 EXEC SQL CLOSE csr214;
851 single_delete("quota", "filsys_id", id);
854 show_quota_wrongpid(id)
855 EXEC SQL BEGIN DECLARE SECTION;
857 EXEC SQL END DECLARE SECTION;
859 EXEC SQL BEGIN DECLARE SECTION;
862 EXEC SQL END DECLARE SECTION;
866 f = (struct filesys *)hash_lookup(filesys, id);
867 EXEC SQL DECLARE csr215 CURSOR FOR
868 SELECT entity_id, type FROM quota
869 WHERE filsys_id = :id;
870 if (sqlca.sqlcode != 0) ingerr(&sqlca.sqlcode);
871 EXEC SQL OPEN csr215;
873 EXEC SQL FETCH csr215 INTO :id1, :type;
874 if (sqlca.sqlcode != 0) {
875 ingerr(&sqlca.sqlcode);
880 printf("Quota for %s %d on filesys %s has wrong phys_id %d\n",
881 type, id1, f->name, id);
883 EXEC SQL CLOSE csr215;
888 EXEC SQL BEGIN DECLARE SECTION;
890 EXEC SQL END DECLARE SECTION;
892 EXEC SQL BEGIN DECLARE SECTION;
894 EXEC SQL END DECLARE SECTION;
896 id1 = ((struct filesys *)hash_lookup(filesys, id))->phys_id;
897 EXEC SQL UPDATE quota SET phys_id = :id1
898 WHERE filsys_id = :id AND phys_id != :id1;
899 EXEC SQL INQUIRE_SQL(:rowcount = rowcount);
901 printf("%d entr%s fixed\n",rowcount, rowcount==1?"y":"ies");
903 printf("Not fixed\n");
908 EXEC SQL BEGIN DECLARE SECTION;
910 EXEC SQL END DECLARE SECTION;
912 EXEC SQL BEGIN DECLARE SECTION;
914 EXEC SQL END DECLARE SECTION;
917 EXEC SQL DECLARE csr216 CURSOR FOR
918 SELECT name FROM servers
919 WHERE acl_type='USER' and acl_id = :id;
920 if (sqlca.sqlcode != 0) ingerr(&sqlca.sqlcode);
921 EXEC SQL OPEN csr216;
923 EXEC SQL FETCH csr216 INTO :name;
924 if (sqlca.sqlcode != 0) {
925 ingerr(&sqlca.sqlcode);
930 printf("Service %s has acl non-existant user %d\n", name, id);
933 EXEC SQL CLOSE csr216;
938 EXEC SQL BEGIN DECLARE SECTION;
940 EXEC SQL END DECLARE SECTION;
942 EXEC SQL BEGIN DECLARE SECTION;
944 EXEC SQL END DECLARE SECTION;
947 EXEC SQL DECLARE csr217 CURSOR FOR
948 SELECT name FROM servers
949 WHERE acl_type='LIST' AND acl_id = :id;
950 if (sqlca.sqlcode != 0) ingerr(&sqlca.sqlcode);
951 EXEC SQL OPEN csr217;
953 EXEC SQL FETCH csr217 INTO :name;
954 if (sqlca.sqlcode != 0) {
955 ingerr(&sqlca.sqlcode);
960 printf("Service %s has acl non-existant list %d\n", name, id);
963 EXEC SQL CLOSE csr217;
968 EXEC SQL BEGIN DECLARE SECTION;
970 EXEC SQL END DECLARE SECTION;
972 EXEC SQL BEGIN DECLARE SECTION;
974 EXEC SQL END DECLARE SECTION;
976 EXEC SQL UPDATE servers SET acl_id=0 WHERE acl_id = :id AND
978 EXEC SQL INQUIRE_SQL(:rowcount = rowcount);
980 printf("%d entr%s fixed\n", rowcount, rowcount==1?"y":"ies");
982 printf("Not fixed\n");
987 EXEC SQL BEGIN DECLARE SECTION;
989 EXEC SQL END DECLARE SECTION;
991 EXEC SQL BEGIN DECLARE SECTION;
993 EXEC SQL END DECLARE SECTION;
995 EXEC SQL UPDATE servers SET acl_id=0 WHERE acl_id = :id AND
997 EXEC SQL INQUIRE_SQL(:rowcount = rowcount);
999 printf("%d entr%s fixed\n", rowcount, rowcount==1?"y":"ies");
1001 printf("Not fixed\n");
1002 modified("servers");
1007 EXEC SQL BEGIN DECLARE SECTION;
1009 EXEC SQL END DECLARE SECTION;
1011 EXEC SQL BEGIN DECLARE SECTION;
1013 EXEC SQL END DECLARE SECTION;
1017 EXEC SQL DECLARE csr218 CURSOR FOR
1018 SELECT string_id FROM krbmap
1019 WHERE users_id = :id ;
1020 if (sqlca.sqlcode != 0) ingerr(&sqlca.sqlcode);
1021 EXEC SQL OPEN csr218;
1023 EXEC SQL FETCH csr218 INTO :id1;
1024 if (sqlca.sqlcode != 0) {
1025 ingerr(&sqlca.sqlcode);
1029 if (s = ((struct string *)hash_lookup(strings, id1)))
1034 printf("Kerberos map for non-existant user %d to principal %s\n",
1037 EXEC SQL CLOSE csr218;
1043 EXEC SQL BEGIN DECLARE SECTION;
1045 EXEC SQL END DECLARE SECTION;
1047 EXEC SQL BEGIN DECLARE SECTION;
1049 EXEC SQL END DECLARE SECTION;
1053 EXEC SQL DECLARE csr219 CURSOR FOR
1054 SELECT users_id FROM krbmap
1055 WHERE string_id = :id;
1056 if (sqlca.sqlcode != 0) ingerr(&sqlca.sqlcode);
1057 EXEC SQL OPEN csr219;
1059 EXEC SQL FETCH csr219 INTO :id1;
1060 if (sqlca.sqlcode != 0) {
1061 ingerr(&sqlca.sqlcode);
1065 if (u = ((struct user *)hash_lookup(users, id1)))
1070 printf("Kerberos map for user %s (%d) to non-existant string %d\n",
1073 EXEC SQL CLOSE csr219;
1079 EXEC SQL BEGIN DECLARE SECTION;
1081 EXEC SQL END DECLARE SECTION;
1083 EXEC SQL BEGIN DECLARE SECTION;
1085 EXEC SQL END DECLARE SECTION;
1088 EXEC SQL DECLARE csr220 CURSOR FOR
1089 SELECT name FROM palladium
1090 WHERE mach_id = :id;
1091 if (sqlca.sqlcode != 0) ingerr(&sqlca.sqlcode);
1092 EXEC SQL OPEN csr220;
1094 EXEC SQL FETCH csr220 INTO :name;
1095 if (sqlca.sqlcode != 0) {
1096 ingerr(&sqlca.sqlcode);
1101 printf("Palladium server/supervisor %s is on non-existant machine %d\n",
1105 EXEC SQL CLOSE csr220;
1112 EXEC SQL BEGIN DECLARE SECTION;
1113 int id1, id2, id3, id4, id5;
1114 char type[9], name[33];
1115 EXEC SQL END DECLARE SECTION;
1116 struct save_queue *sq, *sq1, *sq2, *sq3, *sq4, *sq5;
1122 printf("Phase 2 - Checking references\n");
1124 dprintf("Checking users...\n");
1125 hash_step(users, pobox_check, NULL);
1127 dprintf("Checking mcmap...\n");
1130 EXEC SQL DECLARE csr221 CURSOR FOR
1131 SELECT mach_id, clu_id FROM mcmap;
1132 if (sqlca.sqlcode != 0) ingerr(&sqlca.sqlcode);
1133 EXEC SQL OPEN csr221;
1135 EXEC SQL FETCH csr221 INTO :id1, :id2;
1136 if (sqlca.sqlcode != 0) {
1137 ingerr(&sqlca.sqlcode);
1141 if (!(m = (struct machine *)hash_lookup(machines, id1)))
1142 sq_save_unique_data(sq1, id1);
1143 if (!hash_lookup(clusters, id2))
1144 sq_save_unique_data(sq2, id2);
1145 if (m) m->clucount++;
1147 EXEC SQL CLOSE csr221;
1148 generic_delete(sq1, show_mcm_mach, "mcmap", "mach_id", 1);
1149 generic_delete(sq2, show_mcm_clu, "mcmap", "clu_id", 1);
1151 dprintf("Checking service clusters...\n");
1153 EXEC SQL DECLARE csr222 CURSOR FOR
1154 SELECT clu_id FROM svc;
1155 if (sqlca.sqlcode != 0) ingerr(&sqlca.sqlcode);
1156 EXEC SQL OPEN csr222;
1158 EXEC SQL FETCH csr222 INTO :id1;
1159 if (sqlca.sqlcode != 0) {
1160 ingerr(&sqlca.sqlcode);
1164 if (!hash_lookup(clusters, id1))
1165 sq_save_unique_data(sq1, id1);
1167 EXEC SQL CLOSE csr222;
1168 generic_delete(sq1, show_svc, "svc", "clu_id", 1);
1170 dprintf("Checking lists...\n");
1171 hash_step(lists, list_check, NULL);
1173 dprintf("Checking members...\n");
1180 EXEC SQL DECLARE csr223 CURSOR FOR
1181 SELECT list_id, member_type, member_id, ref_count, direct
1182 FROM imembers ORDER BY list_id;
1183 if (sqlca.sqlcode != 0) ingerr(&sqlca.sqlcode);
1184 EXEC SQL OPEN csr223;
1186 EXEC SQL FETCH csr223 INTO :id1, :type, :id2, :id3, :id4;
1187 if (sqlca.sqlcode != 0) {
1188 ingerr(&sqlca.sqlcode);
1192 if ((l = (struct list *) hash_lookup(lists, id1)) == NULL)
1193 sq_save_unique_data(sq1, id1);
1194 else if (type[0] == 'U' && !hash_lookup(users, id2))
1195 sq_save_unique_data(sq2, id2);
1196 else if (type[0] == 'L' && !hash_lookup(lists, id2))
1197 sq_save_unique_data(sq3, id2);
1198 else if (type[0] == 'S' && !string_check(id2))
1199 sq_save_unique_data(sq4, id2);
1200 else if (type[0] == 'K' && !string_check(id2))
1201 sq_save_unique_data(sq5, id2);
1205 EXEC SQL CLOSE csr223;
1206 generic_delete(sq1, show_member_list, "imembers", "list_id", 1);
1207 generic_fix(sq2, show_mem_user, "Delete", del_mem_user, 1);
1208 generic_fix(sq3, show_mem_list, "Delete", del_mem_list, 1);
1209 generic_fix(sq4, show_mem_str, "Delete", del_mem_str, 1);
1210 generic_fix(sq5, show_mem_krb, "Delete", del_mem_krb, 1);
1212 dprintf("Checking servers...\n");
1215 EXEC SQL DECLARE csr224 CURSOR FOR
1216 SELECT name, acl_type, acl_id FROM servers;
1217 if (sqlca.sqlcode != 0) ingerr(&sqlca.sqlcode);
1218 EXEC SQL OPEN csr224;
1220 EXEC SQL FETCH csr224 INTO :name, :type, :id1;
1221 if (sqlca.sqlcode != 0) {
1222 ingerr(&sqlca.sqlcode);
1227 if (!strcmp(type, "USER") && !hash_lookup(users, id1)) {
1228 sq_save_data(sq1, id1);
1229 } else if (!strcmp(type, "LIST") && !hash_lookup(lists, id1)) {
1230 sq_save_data(sq2, id1);
1233 EXEC SQL CLOSE csr224;
1234 generic_fix(sq1, show_srv_user, "Fix", zero_srv_user, 1);
1235 generic_fix(sq2, show_srv_list, "Fix", zero_srv_list, 1);
1237 dprintf("Checking serverhosts...\n");
1239 EXEC SQL DECLARE csr225 CURSOR FOR
1240 SELECT mach_id FROM serverhosts;
1241 if (sqlca.sqlcode != 0) ingerr(&sqlca.sqlcode);
1242 EXEC SQL OPEN csr225;
1244 EXEC SQL FETCH csr225 INTO :id1;
1245 if (sqlca.sqlcode != 0) {
1246 ingerr(&sqlca.sqlcode);
1250 if (!hash_lookup(machines, id1))
1251 sq_save_data(sq, id1);
1253 EXEC SQL CLOSE csr225;
1254 generic_fix(sq, show_sh, "Delete", del_sh_mach, 0);
1256 dprintf("Checking nfsphys...\n");
1257 hash_step(nfsphys, check_nfsphys, NULL);
1259 dprintf("Checking filesys...\n");
1260 hash_step(filesys, check_fs, NULL);
1262 dprintf("Checking filesystem groups...\n");
1266 EXEC SQL DECLARE csr226 CURSOR FOR
1267 SELECT group_id, filsys_id FROM fsgroup;
1268 if (sqlca.sqlcode != 0) ingerr(&sqlca.sqlcode);
1269 EXEC SQL OPEN csr226;
1271 EXEC SQL FETCH csr226 INTO :id1, :id2;
1272 if (sqlca.sqlcode != 0) {
1273 ingerr(&sqlca.sqlcode);
1277 if (!(f = (struct filesys *) hash_lookup(filesys, id1)))
1278 sq_save_data(sq1, id1);
1279 if (!hash_lookup(filesys, id2))
1280 sq_save_data(sq3, id2);
1282 EXEC SQL CLOSE csr226;
1283 generic_delete(sq1, show_fsg_missing, "fsgroup", "group_id", 0);
1284 generic_delete(sq3, show_fsg_nomember, "fsgroup", "filsys_id", 1);
1286 dprintf("Checking quotas...\n");
1291 EXEC SQL DECLARE csr227 CURSOR FOR
1292 SELECT entity_id, type, filsys_id, phys_id, quota FROM quota;
1293 if (sqlca.sqlcode != 0) ingerr(&sqlca.sqlcode);
1294 EXEC SQL OPEN csr227;
1296 EXEC SQL FETCH csr227 INTO :id1, :type, :id2, :id3, :id4;
1297 if (sqlca.sqlcode != 0) {
1298 ingerr(&sqlca.sqlcode);
1302 if (type[0] == 'U' && id1 != 0 && !hash_lookup(users, id1))
1303 sq_save_data(sq1, id1);
1304 else if (type[0] == 'G' && !hash_lookup(lists, id1))
1305 sq_save_data(sq4, id1);
1306 else if (!(f = (struct filesys *) hash_lookup(filesys, id2)))
1307 sq_save_data(sq2, id2);
1308 else if (id3 != f->phys_id ||
1309 ((n = (struct nfsphys*) hash_lookup(nfsphys, id3)) ==
1310 (struct nfsphys *)NULL))
1311 sq_save_data(sq3, id2);
1315 EXEC SQL CLOSE csr227;
1316 generic_fix(sq1, show_quota_nouser, "Delete", fix_quota_nouser, 1);
1317 generic_fix(sq2, show_quota_nofs, "Delete", fix_quota_nofs, 0);
1318 generic_fix(sq3, show_quota_wrongpid, "Fix", fix_quota_physid, 1);
1319 generic_fix(sq4, show_quota_nolist, "Delete", fix_quota_nolist, 1);
1321 dprintf("Not checking zephyr.\n");
1323 dprintf("Checking hostaccess...\n");
1324 EXEC SQL DECLARE csr228 CURSOR FOR
1325 SELECT mach_id, acl_type, acl_id FROM hostaccess;
1326 if (sqlca.sqlcode != 0) ingerr(&sqlca.sqlcode);
1327 EXEC SQL OPEN csr228;
1329 EXEC SQL FETCH csr228 INTO :id1, :type, :id2;
1330 if (sqlca.sqlcode != 0) {
1331 ingerr(&sqlca.sqlcode);
1336 if (!hash_lookup(machines, id1)) {
1337 printf("Hostaccess for non-existant host %d\n", id1);
1338 printf("Not fixing this error\n");
1340 if (!strcmp(type, "USER") && !hash_lookup(users, id2)) {
1341 printf("Hostaccess for %d is non-existant user %d\n", id1, id2);
1342 printf("Not fixing this error\n");
1343 } else if (!strcmp(type, "LIST") && !hash_lookup(lists, id2)) {
1344 printf("Hostaccess for %d is non-existant list %d\n", id1, id2);
1345 printf("Not fixing this error\n");
1348 EXEC SQL CLOSE csr228;
1350 dprintf("Checking palladium...\n");
1352 EXEC SQL DECLARE csr229 CURSOR FOR
1353 SELECT mach_id FROM palladium;
1354 if (sqlca.sqlcode != 0) ingerr(&sqlca.sqlcode);
1355 EXEC SQL OPEN csr229;
1357 EXEC SQL FETCH csr229 INTO :id1;
1358 if (sqlca.sqlcode != 0) {
1359 ingerr(&sqlca.sqlcode);
1363 if (!hash_lookup(machines, id1)) {
1364 sq_save_unique_data(sq1, id1);
1367 EXEC SQL CLOSE csr229;
1368 generic_delete(sq1, show_pdm_mach, "palladium", "mach_id", 1);
1370 dprintf("Checking krbmap...\n");
1373 EXEC SQL DECLARE csr230 CURSOR FOR
1374 SELECT users_id, string_id FROM krbmap;
1375 if (sqlca.sqlcode != 0) ingerr(&sqlca.sqlcode);
1376 EXEC SQL OPEN csr230;
1378 EXEC SQL FETCH csr230 INTO :id1, :id2;
1379 if (sqlca.sqlcode != 0) {
1380 ingerr(&sqlca.sqlcode);
1384 if (!hash_lookup(users, id1))
1385 sq_save_unique_data(sq1, id1);
1386 if (!string_check(id2))
1387 sq_save_unique_data(sq2, id2);
1389 EXEC SQL CLOSE csr230;
1390 generic_delete(sq1, show_krb_usr, "krbmap", "users_id", 1);
1391 generic_delete(sq2, show_krb_str, "krbmap", "string_id", 1);
1393 dprintf("Checking capacls...\n");
1394 EXEC SQL DECLARE csr231 CURSOR FOR
1395 SELECT list_id, tag FROM capacls;
1396 if (sqlca.sqlcode != 0) ingerr(&sqlca.sqlcode);
1397 EXEC SQL OPEN csr231;
1399 EXEC SQL FETCH csr231 INTO :id1, :name;
1400 if (sqlca.sqlcode != 0) {
1401 ingerr(&sqlca.sqlcode);
1405 if (!hash_lookup(lists, id1)) {
1406 printf("Capacl for %s is non-existant list %d\n", name, id1);
1407 printf("Not fixing this error\n");
1410 EXEC SQL CLOSE csr231;