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");
122 mach_check(id, m, hint)
127 if (!hash_lookup(subnets, m->snet_id)) {
128 printf("Machine %s is on a non-existant subnet %d\n",
129 m->name, m->snet_id);
130 if (single_fix("Move to null-subnet", 1)) {
131 EXEC SQL BEGIN DECLARE SECTION;
132 int rowcount, iid = id;
133 EXEC SQL END DECLARE SECTION;
135 EXEC SQL UPDATE machine SET snet_id=0 WHERE mach_id = :iid;
136 EXEC SQL INQUIRE_SQL(:rowcount = rowcount);
138 printf("%d entr%s fixed\n", rowcount, rowcount==1?"y":"ies");
140 printf("Not fixed\n");
145 switch (m->owner_type) {
147 if (!hash_lookup(users, m->owner_id)) {
148 printf("Machine %s has non-existant USER owner %d\n",
149 m->name, m->owner_id);
150 if (single_fix("Set to no owner", 1)) {
156 if (!hash_lookup(lists, m->owner_id)) {
157 printf("Machine %s has non-existant LIST owner %d\n",
158 m->name, m->owner_id);
159 if (single_fix("Set to no owner", 1)) {
171 EXEC SQL BEGIN DECLARE SECTION;
172 int rowcount, id = m->mach_id;
173 EXEC SQL END DECLARE SECTION;
175 EXEC SQL UPDATE machine SET owner_type='NONE', owner_id=0
177 EXEC SQL INQUIRE_SQL(:rowcount = rowcount);
179 printf("%d entr%s fixed\n", rowcount, rowcount==1?"y":"ies");
181 printf("Not fixed\n");
189 EXEC SQL BEGIN DECLARE SECTION;
190 int iid = id, found = 1;
191 char label[17], data[33];
192 EXEC SQL END DECLARE SECTION;
194 EXEC SQL DECLARE csr203 CURSOR FOR
195 SELECT serv_label, serv_cluster FROM svc
197 if (sqlca.sqlcode != 0) ingerr(&sqlca.sqlcode);
198 EXEC SQL OPEN csr203;
200 EXEC SQL FETCH csr203 INTO :label, :data;
201 if (sqlca.sqlcode != 0) {
202 ingerr(&sqlca.sqlcode);
209 printf("Cluster data [%s] %s for non-existant cluster %d\n",
212 EXEC SQL CLOSE csr203;
216 list_check(id, l, hint)
221 switch (l->acl_type) {
223 if (!hash_lookup(lists, l->acl_id)) {
224 printf("List %s has bad LIST acl %d\n", l->name, l->acl_id);
225 if (single_fix("Patch", 1)) {
226 fix_list_acl(l->list_id);
231 if (!hash_lookup(users, l->acl_id)) {
232 printf("List %s has bad USER acl %d\n", l->name, l->acl_id);
233 if (single_fix("Patch", 1)) {
234 fix_list_acl(l->list_id);
244 EXEC SQL BEGIN DECLARE SECTION;
245 int rowcount, iid = id;
246 EXEC SQL END DECLARE SECTION;
248 EXEC SQL UPDATE list SET acl_id = :iid, acl_type='LIST'
249 WHERE list_id = :iid;
250 EXEC SQL INQUIRE_SQL(:rowcount = rowcount);
252 printf("%d entr%s fixed\n", rowcount, rowcount==1?"y":"ies");
254 printf("Not fixed\n");
262 EXEC SQL BEGIN DECLARE SECTION;
263 int mid, iid = id, found = 1;
264 char mtype[9], *name = "";
265 EXEC SQL END DECLARE SECTION;
267 EXEC SQL DECLARE csr204 CURSOR FOR
268 SELECT member_type, member_id FROM imembers
269 WHERE list_id = :iid AND direct=1;
270 if (sqlca.sqlcode != 0) ingerr(&sqlca.sqlcode);
271 EXEC SQL OPEN csr204;
273 EXEC SQL FETCH csr204 INTO :mtype, :mid;
274 if (sqlca.sqlcode != 0) {
275 ingerr(&sqlca.sqlcode);
282 name = ((struct list *) hash_lookup(lists, mid))->name;
283 else if (mtype[0] == 'U')
284 name = ((struct user *) hash_lookup(users, mid))->login;
285 else if (mtype[0] == 'S' || mtype[0] == 'K')
286 name = ((struct string *) hash_lookup(strings, mid))->name;
287 printf("Non-existant list %d has member %s %s\n", iid, mtype, name);
289 EXEC SQL CLOSE csr204;
296 EXEC SQL BEGIN DECLARE SECTION;
297 int lid, iid = id, found = 1;
299 EXEC SQL END DECLARE SECTION;
301 EXEC SQL DECLARE csr205 CURSOR FOR
302 SELECT list_id FROM imembers
303 WHERE member_id = :iid AND member_type='USER' AND direct=1;
304 if (sqlca.sqlcode != 0) ingerr(&sqlca.sqlcode);
305 EXEC SQL OPEN csr205;
307 EXEC SQL FETCH csr205 INTO :lid;
308 if (sqlca.sqlcode != 0) {
309 ingerr(&sqlca.sqlcode);
314 printf("List %s has non-existant user member, id %d\n",
315 ((struct list *)hash_lookup(lists, lid))->name, iid);
317 EXEC SQL CLOSE csr205;
324 EXEC SQL BEGIN DECLARE SECTION;
325 int lid, iid = id, found = 1;
327 EXEC SQL END DECLARE SECTION;
329 EXEC SQL DECLARE csr206 CURSOR FOR
330 SELECT list_id FROM imembers
331 WHERE member_id = :iid AND member_type='LIST' AND direct=1;
332 if (sqlca.sqlcode != 0) ingerr(&sqlca.sqlcode);
333 EXEC SQL OPEN csr206;
335 EXEC SQL FETCH csr206 INTO :lid;
336 if (sqlca.sqlcode != 0) {
337 ingerr(&sqlca.sqlcode);
342 printf("List %s has non-existant list member, id %d\n",
343 ((struct list *)hash_lookup(lists, lid))->name, iid);
345 EXEC SQL CLOSE csr206;
352 EXEC SQL BEGIN DECLARE SECTION;
353 int lid, iid = id, found = 1;
355 EXEC SQL END DECLARE SECTION;
357 EXEC SQL DECLARE csr207 CURSOR FOR
358 SELECT list_id FROM imembers
359 WHERE member_id = :iid AND member_type='STRING' AND direct=1;
360 if (sqlca.sqlcode != 0) ingerr(&sqlca.sqlcode);
361 EXEC SQL OPEN csr207;
363 EXEC SQL FETCH csr207 INTO :lid;
364 if (sqlca.sqlcode != 0) {
365 ingerr(&sqlca.sqlcode);
370 printf("List %s has non-existant string member, id %d\n",
371 ((struct list *)hash_lookup(lists, lid))->name, iid);
373 EXEC SQL CLOSE csr207;
381 EXEC SQL BEGIN DECLARE SECTION;
382 int lid, iid = id, found = 1;
384 EXEC SQL END DECLARE SECTION;
386 EXEC SQL DECLARE csr208 CURSOR FOR
387 SELECT list_id FROM imembers
388 WHERE member_id = :iid AND member_type='KERBEROS' AND direct=1;
389 if (sqlca.sqlcode != 0) ingerr(&sqlca.sqlcode);
390 EXEC SQL OPEN csr208;
392 EXEC SQL FETCH csr208 INTO :lid;
393 if (sqlca.sqlcode != 0) {
394 ingerr(&sqlca.sqlcode);
399 printf("List %s has non-existant kerberos member, id %d\n",
400 ((struct list *)hash_lookup(lists, lid))->name, iid);
402 EXEC SQL CLOSE csr208;
408 EXEC SQL BEGIN DECLARE SECTION;
410 EXEC SQL END DECLARE SECTION;
412 EXEC SQL BEGIN DECLARE SECTION;
414 EXEC SQL END DECLARE SECTION;
416 EXEC SQL DELETE FROM imembers WHERE member_type='USER' AND
417 member_id = :id AND direct = 1;
418 EXEC SQL INQUIRE_SQL(:rowcount = rowcount);
420 printf("%d entr%s deleted\n", rowcount, rowcount==1?"y":"ies");
422 printf("Not deleted\n");
423 modified("imembers");
427 EXEC SQL BEGIN DECLARE SECTION;
429 EXEC SQL END DECLARE SECTION;
431 EXEC SQL BEGIN DECLARE SECTION;
433 EXEC SQL END DECLARE SECTION;
435 EXEC SQL DELETE FROM imembers WHERE member_type='LIST' AND
436 member_id = :id AND direct=1;
437 EXEC SQL INQUIRE_SQL(:rowcount = rowcount);
439 printf("%d entr%s deleted\n", rowcount, rowcount==1?"y":"ies");
441 printf("Not deleted\n");
442 modified("imembers");
446 EXEC SQL BEGIN DECLARE SECTION;
448 EXEC SQL END DECLARE SECTION;
450 EXEC SQL BEGIN DECLARE SECTION;
452 EXEC SQL END DECLARE SECTION;
454 EXEC SQL DELETE FROM imembers WHERE member_type='STRING' AND
455 member_id = :id AND direct=1;
456 EXEC SQL INQUIRE_SQL(:rowcount = rowcount);
458 printf("%d entr%s deleted\n", rowcount, rowcount==1?"y":"ies");
460 printf("Not deleted\n");
461 modified("imembers");
466 EXEC SQL BEGIN DECLARE SECTION;
468 EXEC SQL END DECLARE SECTION;
470 EXEC SQL BEGIN DECLARE SECTION;
472 EXEC SQL END DECLARE SECTION;
474 EXEC SQL DELETE FROM imembers WHERE member_type='KERBEROS' AND
475 member_id = :id AND direct=1;
476 EXEC SQL INQUIRE_SQL(:rowcount = rowcount);
478 printf("%d entr%s deleted\n", rowcount, rowcount==1?"y":"ies");
480 printf("Not deleted\n");
481 modified("imembers");
486 EXEC SQL BEGIN DECLARE SECTION;
488 EXEC SQL END DECLARE SECTION;
490 EXEC SQL BEGIN DECLARE SECTION;
492 EXEC SQL END DECLARE SECTION;
495 EXEC SQL DECLARE csr209 CURSOR FOR
496 SELECT service FROM serverhosts
498 if (sqlca.sqlcode != 0) ingerr(&sqlca.sqlcode);
499 EXEC SQL OPEN csr209;
501 EXEC SQL FETCH csr209 INTO :name;
502 if (sqlca.sqlcode != 0) {
503 ingerr(&sqlca.sqlcode);
508 printf("ServerHost entry for service %s non-existant host %d\n",
511 EXEC SQL CLOSE csr209;
516 EXEC SQL BEGIN DECLARE SECTION;
518 EXEC SQL END DECLARE SECTION;
520 EXEC SQL BEGIN DECLARE SECTION;
522 EXEC SQL END DECLARE SECTION;
524 EXEC SQL DELETE FROM serverhosts WHERE mach_id = :id;
525 EXEC SQL INQUIRE_SQL(:rowcount = rowcount);
527 printf("%d entr%s deleted\n", rowcount, rowcount==1?"y":"ies");
529 printf("Not deleted\n");
530 modified("serverhosts");
534 static int fnchecklen;
541 if (n->mach_id == f->mach_id &&
542 !strncmp(f->dir, n->dir, strlen(n->dir)) &&
543 strlen(n->dir) > fnchecklen) {
545 fnchecklen = strlen(n->dir);
550 check_fs(id, f, hint)
551 EXEC SQL BEGIN DECLARE SECTION;
553 EXEC SQL END DECLARE SECTION;
554 register struct filesys *f;
557 EXEC SQL BEGIN DECLARE SECTION;
558 int id1, id2, id3, rowcount;
560 EXEC SQL END DECLARE SECTION;
564 if (!hash_lookup(machines, f->mach_id)) {
565 printf("Filesys %s with bad machine %d\n", f->name, f->mach_id);
566 if (single_fix("Fix", 0)) {
567 EXEC SQL UPDATE filesys SET mach_id = 0 WHERE filsys_id = :id;
568 EXEC SQL INQUIRE_SQL(:rowcount = rowcount);
570 printf("%d entr%s fixed\n",rowcount, rowcount==1?"y":"ies");
572 printf("Not fixed\n");
578 if (!hash_lookup(users, f->owner)) {
579 printf("Filesys %s with bad owning user %d\n", f->name, f->owner);
580 if (single_fix("Fix", 1)) {
581 zero_fix("filesys", "owner", "filsys_id", f->filsys_id);
585 if (!hash_lookup(lists, f->owners)) {
586 printf("Filesys %s with bad owning group %d\n", f->name, f->owners);
587 if (single_fix("Fix", 1)) {
588 zero_fix("filesys", "owners", "filsys_id", f->filsys_id);
593 if (f->type == 'N') {
594 if (!hash_lookup(nfsphys, f->phys_id)) {
595 m = (struct machine *)hash_lookup(machines, f->mach_id);
596 printf("Filesys %s with bad phys_id %d\n", f->name, f->phys_id);
597 if (single_fix("Fix", 1)) {
599 hash_step(nfsphys, fsmatch, f);
600 if (fnchecklen != 0) {
604 EXEC SQL UPDATE filesys SET phys_id = :id1 WHERE filsys_id = :id2;
605 EXEC SQL INQUIRE_SQL(:rowcount = rowcount);
607 printf("%d entr%s fixed\n",rowcount, rowcount==1?"y":"ies");
609 printf("Not fixed\n");
612 printf("No NFSphys exsits for %s:%s\n", m->name, f->dir);
613 if (single_fix("Create", 0)) {
618 if (set_next_object_id("nfsphys_id", "nfsphys") !=
620 printf("Unable to assign unique ID\n");
623 EXEC SQL SELECT COUNT(*) INTO :rowcount FROM numvalues
624 WHERE name='nfsphys_id';
626 printf("Unable to retrieve unique ID\n");
629 EXEC SQL INSERT INTO mfsphys (mfsphys_id, mach_id,
630 device, dir, status, allocated, size, modtime,
631 modby, modwith) VALUES (:id1, :id3, '???', :dir,
632 0, 0, 0, 'now', 0, 'dbck');
633 EXEC SQL INQUIRE_SQL(:rowcount = rowcount);
635 printf("%d entr%s created\n", rowcount,
636 rowcount==1?"y":"ies");
638 printf("Not created\n");
640 n = (struct nfsphys *)malloc(sizeof(struct nfsphys));
642 out_of_mem("storing new nfsphys");
648 hash_store(nfsphys, id1, n);
649 EXEC SQL UPDATE filesys SET phys_id = :id1
650 WHERE filsys_id = :id2;
651 EXEC SQL INQUIRE_SQL(:rowcount = rowcount);
653 printf("%d filesys entr%s fixed\n", rowcount,
654 rowcount==1?"y":"ies");
656 printf("Not fixed\n");
666 check_nfsphys(id, n, hint)
671 if (!hash_lookup(machines, n->mach_id)) {
672 printf("NFSphys %d(%s) on non-existant machine %d\n",
673 id, n->dir, n->mach_id);
674 if (single_fix("Delete", 0))
675 single_delete("nfsphys", "nfsphys_id", id);
680 EXEC SQL BEGIN DECLARE SECTION;
682 EXEC SQL END DECLARE SECTION;
684 EXEC SQL BEGIN DECLARE SECTION;
686 EXEC SQL END DECLARE SECTION;
689 EXEC SQL DECLARE csr210 CURSOR FOR
690 SELECT filsys_id FROM fsgroup
691 WHERE group_id = :id;
692 if (sqlca.sqlcode != 0) ingerr(&sqlca.sqlcode);
693 EXEC SQL OPEN csr210;
695 EXEC SQL FETCH csr210 INTO :id1;
696 if (sqlca.sqlcode != 0) {
697 ingerr(&sqlca.sqlcode);
702 if (f = (struct filesys *) hash_lookup(filesys, id1))
703 printf("Missing fsgroup %d has member filesystem %s\n", id, f->name);
705 printf("Missing fsgroup %d has member filesystem %d\n", id, id1);
707 EXEC SQL CLOSE csr210;
738 printf("FSGroup %s has type %s instead of FSGROUP\n", f->name, t);
745 EXEC SQL BEGIN DECLARE SECTION;
746 int rowcount, id = f->filsys_id;
747 EXEC SQL END DECLARE SECTION;
749 EXEC SQL UPDATE filesys SET type='FSGROUP' WHERE filsys_id = :id;
750 EXEC SQL INQUIRE_SQL(:rowcount = rowcount);
752 printf("%d entr%s fixed\n", rowcount, rowcount==1?"y":"ies");
754 printf("Not fixed\n");
758 show_fsg_nomember(id)
759 EXEC SQL BEGIN DECLARE SECTION;
761 EXEC SQL END DECLARE SECTION;
763 EXEC SQL BEGIN DECLARE SECTION;
765 EXEC SQL END DECLARE SECTION;
768 EXEC SQL DECLARE csr211 CURSOR FOR
769 SELECT group_id FROM fsgroup
770 WHERE filsys_id = :id;
771 if (sqlca.sqlcode != 0) ingerr(&sqlca.sqlcode);
772 EXEC SQL OPEN csr211;
774 EXEC SQL FETCH csr211 INTO :id1;
775 if (sqlca.sqlcode != 0) {
776 ingerr(&sqlca.sqlcode);
781 if (f = (struct filesys *) hash_lookup(filesys, id1))
782 printf("FSGroup %s has missing member %d\n", f->name, id);
784 printf("FSGroup %d has missing member %d\n", id1, id);
786 EXEC SQL CLOSE csr211;
790 show_quota_nouser(id)
791 EXEC SQL BEGIN DECLARE SECTION;
793 EXEC SQL END DECLARE SECTION;
795 EXEC SQL BEGIN DECLARE SECTION;
797 EXEC SQL END DECLARE SECTION;
799 EXEC SQL DECLARE csr212 CURSOR FOR
800 SELECT filsys_id FROM quota
801 WHERE entity_id = :id AND type='USER';
802 if (sqlca.sqlcode != 0) ingerr(&sqlca.sqlcode);
803 EXEC SQL OPEN csr212;
805 EXEC SQL FETCH csr212 INTO :id1;
806 if (sqlca.sqlcode != 0) {
807 ingerr(&sqlca.sqlcode);
812 printf("Quota on fs %d for non-existant user %d\n", id1, id);
814 EXEC SQL CLOSE csr212;
818 show_quota_nolist(id)
819 EXEC SQL BEGIN DECLARE SECTION;
821 EXEC SQL END DECLARE SECTION;
823 EXEC SQL BEGIN DECLARE SECTION;
825 EXEC SQL END DECLARE SECTION;
827 EXEC SQL DECLARE csr213 CURSOR FOR
828 SELECT filsys_id FROM quota
829 WHERE entity_id = :id AND type='GROUP';
830 if (sqlca.sqlcode != 0) ingerr(&sqlca.sqlcode);
831 EXEC SQL OPEN csr213;
833 EXEC SQL FETCH csr213 INTO :id1;
834 if (sqlca.sqlcode != 0) {
835 ingerr(&sqlca.sqlcode);
840 printf("Quota on fs %d for non-existant list %d\n", id1, id);
842 EXEC SQL CLOSE csr213;
847 EXEC SQL BEGIN DECLARE SECTION;
849 EXEC SQL END DECLARE SECTION;
851 EXEC SQL BEGIN DECLARE SECTION;
853 EXEC SQL END DECLARE SECTION;
855 id1 = ((struct filesys *)hash_lookup(filesys, id))->phys_id;
856 EXEC SQL DELETE FROM quota
857 WHERE entity_id = :id AND type = 'USER';
858 EXEC SQL INQUIRE_SQL(:rowcount = rowcount);
860 printf("%d entr%s deleted\n",rowcount, rowcount==1?"y":"ies");
862 printf("Not deleted\n");
867 EXEC SQL BEGIN DECLARE SECTION;
869 EXEC SQL END DECLARE SECTION;
871 EXEC SQL BEGIN DECLARE SECTION;
873 EXEC SQL END DECLARE SECTION;
875 id1 = ((struct filesys *)hash_lookup(filesys, id))->phys_id;
876 EXEC SQL DELETE FROM quota WHERE entity_id = :id AND type='GROUP';
877 EXEC SQL INQUIRE_SQL(:rowcount = rowcount);
879 printf("%d entr%s deleted\n",rowcount, rowcount==1?"y":"ies");
881 printf("Not deleted\n");
886 EXEC SQL BEGIN DECLARE SECTION;
888 EXEC SQL END DECLARE SECTION;
890 EXEC SQL BEGIN DECLARE SECTION;
893 EXEC SQL END DECLARE SECTION;
895 EXEC SQL DECLARE csr214 CURSOR FOR
896 SELECT entity_id, type FROM quota
897 WHERE filsys_id = :id;
898 if (sqlca.sqlcode != 0) ingerr(&sqlca.sqlcode);
899 EXEC SQL OPEN csr214;
901 EXEC SQL FETCH csr214 INTO :id1, :type;
902 if (sqlca.sqlcode != 0) {
903 ingerr(&sqlca.sqlcode);
908 printf("Quota for %s %d on non-existant filesys %d\n", type, id1, id);
910 EXEC SQL CLOSE csr214;
916 single_delete("quota", "filsys_id", id);
919 show_quota_wrongpid(id)
920 EXEC SQL BEGIN DECLARE SECTION;
922 EXEC SQL END DECLARE SECTION;
924 EXEC SQL BEGIN DECLARE SECTION;
927 EXEC SQL END DECLARE SECTION;
931 f = (struct filesys *)hash_lookup(filesys, id);
932 EXEC SQL DECLARE csr215 CURSOR FOR
933 SELECT entity_id, type FROM quota
934 WHERE filsys_id = :id;
935 if (sqlca.sqlcode != 0) ingerr(&sqlca.sqlcode);
936 EXEC SQL OPEN csr215;
938 EXEC SQL FETCH csr215 INTO :id1, :type;
939 if (sqlca.sqlcode != 0) {
940 ingerr(&sqlca.sqlcode);
945 printf("Quota for %s %d on filesys %s has wrong phys_id %d\n",
946 type, id1, f->name, id);
948 EXEC SQL CLOSE csr215;
953 EXEC SQL BEGIN DECLARE SECTION;
955 EXEC SQL END DECLARE SECTION;
957 EXEC SQL BEGIN DECLARE SECTION;
959 EXEC SQL END DECLARE SECTION;
961 id1 = ((struct filesys *)hash_lookup(filesys, id))->phys_id;
962 EXEC SQL UPDATE quota SET phys_id = :id1
963 WHERE filsys_id = :id AND phys_id != :id1;
964 EXEC SQL INQUIRE_SQL(:rowcount = rowcount);
966 printf("%d entr%s fixed\n",rowcount, rowcount==1?"y":"ies");
968 printf("Not fixed\n");
973 EXEC SQL BEGIN DECLARE SECTION;
975 EXEC SQL END DECLARE SECTION;
977 EXEC SQL BEGIN DECLARE SECTION;
979 EXEC SQL END DECLARE SECTION;
982 EXEC SQL DECLARE csr216 CURSOR FOR
983 SELECT name FROM servers
984 WHERE acl_type='USER' and acl_id = :id;
985 if (sqlca.sqlcode != 0) ingerr(&sqlca.sqlcode);
986 EXEC SQL OPEN csr216;
988 EXEC SQL FETCH csr216 INTO :name;
989 if (sqlca.sqlcode != 0) {
990 ingerr(&sqlca.sqlcode);
995 printf("Service %s has acl non-existant user %d\n", name, id);
998 EXEC SQL CLOSE csr216;
1003 EXEC SQL BEGIN DECLARE SECTION;
1005 EXEC SQL END DECLARE SECTION;
1007 EXEC SQL BEGIN DECLARE SECTION;
1009 EXEC SQL END DECLARE SECTION;
1012 EXEC SQL DECLARE csr217 CURSOR FOR
1013 SELECT name FROM servers
1014 WHERE acl_type='LIST' AND acl_id = :id;
1015 if (sqlca.sqlcode != 0) ingerr(&sqlca.sqlcode);
1016 EXEC SQL OPEN csr217;
1018 EXEC SQL FETCH csr217 INTO :name;
1019 if (sqlca.sqlcode != 0) {
1020 ingerr(&sqlca.sqlcode);
1025 printf("Service %s has acl non-existant list %d\n", name, id);
1028 EXEC SQL CLOSE csr217;
1033 EXEC SQL BEGIN DECLARE SECTION;
1035 EXEC SQL END DECLARE SECTION;
1037 EXEC SQL BEGIN DECLARE SECTION;
1039 EXEC SQL END DECLARE SECTION;
1041 EXEC SQL UPDATE servers SET acl_id=0 WHERE acl_id = :id AND
1043 EXEC SQL INQUIRE_SQL(:rowcount = rowcount);
1045 printf("%d entr%s fixed\n", rowcount, rowcount==1?"y":"ies");
1047 printf("Not fixed\n");
1048 modified("servers");
1052 EXEC SQL BEGIN DECLARE SECTION;
1054 EXEC SQL END DECLARE SECTION;
1056 EXEC SQL BEGIN DECLARE SECTION;
1058 EXEC SQL END DECLARE SECTION;
1060 EXEC SQL UPDATE servers SET acl_id=0 WHERE acl_id = :id AND
1062 EXEC SQL INQUIRE_SQL(:rowcount = rowcount);
1064 printf("%d entr%s fixed\n", rowcount, rowcount==1?"y":"ies");
1066 printf("Not fixed\n");
1067 modified("servers");
1072 EXEC SQL BEGIN DECLARE SECTION;
1074 EXEC SQL END DECLARE SECTION;
1076 EXEC SQL BEGIN DECLARE SECTION;
1078 EXEC SQL END DECLARE SECTION;
1082 EXEC SQL DECLARE csr218 CURSOR FOR
1083 SELECT string_id FROM krbmap
1084 WHERE users_id = :id ;
1085 if (sqlca.sqlcode != 0) ingerr(&sqlca.sqlcode);
1086 EXEC SQL OPEN csr218;
1088 EXEC SQL FETCH csr218 INTO :id1;
1089 if (sqlca.sqlcode != 0) {
1090 ingerr(&sqlca.sqlcode);
1094 if (s = ((struct string *)hash_lookup(strings, id1)))
1099 printf("Kerberos map for non-existant user %d to principal %s\n",
1102 EXEC SQL CLOSE csr218;
1108 EXEC SQL BEGIN DECLARE SECTION;
1110 EXEC SQL END DECLARE SECTION;
1112 EXEC SQL BEGIN DECLARE SECTION;
1114 EXEC SQL END DECLARE SECTION;
1118 EXEC SQL DECLARE csr219 CURSOR FOR
1119 SELECT users_id FROM krbmap
1120 WHERE string_id = :id;
1121 if (sqlca.sqlcode != 0) ingerr(&sqlca.sqlcode);
1122 EXEC SQL OPEN csr219;
1124 EXEC SQL FETCH csr219 INTO :id1;
1125 if (sqlca.sqlcode != 0) {
1126 ingerr(&sqlca.sqlcode);
1130 if (u = ((struct user *)hash_lookup(users, id1)))
1135 printf("Kerberos map for user %s (%d) to non-existant string %d\n",
1138 EXEC SQL CLOSE csr219;
1144 EXEC SQL BEGIN DECLARE SECTION;
1146 EXEC SQL END DECLARE SECTION;
1148 EXEC SQL BEGIN DECLARE SECTION;
1150 EXEC SQL END DECLARE SECTION;
1153 EXEC SQL DECLARE csr220 CURSOR FOR
1154 SELECT name FROM palladium
1155 WHERE mach_id = :id;
1156 if (sqlca.sqlcode != 0) ingerr(&sqlca.sqlcode);
1157 EXEC SQL OPEN csr220;
1159 EXEC SQL FETCH csr220 INTO :name;
1160 if (sqlca.sqlcode != 0) {
1161 ingerr(&sqlca.sqlcode);
1166 printf("Palladium server/supervisor %s is on non-existant machine %d\n",
1170 EXEC SQL CLOSE csr220;
1177 EXEC SQL BEGIN DECLARE SECTION;
1178 int id1, id2, id3, id4, id5;
1179 char type[9], name[33];
1180 EXEC SQL END DECLARE SECTION;
1181 struct save_queue *sq, *sq1, *sq2, *sq3, *sq4, *sq5;
1187 printf("Phase 2 - Checking references\n");
1189 dprintf("Checking users...\n");
1190 hash_step(users, pobox_check, NULL);
1192 dprintf("Checking machines...\n");
1193 hash_step(machines, mach_check, NULL);
1195 dprintf("Checking mcmap...\n");
1198 EXEC SQL DECLARE csr221 CURSOR FOR
1199 SELECT mach_id, clu_id FROM mcmap;
1200 if (sqlca.sqlcode != 0) ingerr(&sqlca.sqlcode);
1201 EXEC SQL OPEN csr221;
1203 EXEC SQL FETCH csr221 INTO :id1, :id2;
1204 if (sqlca.sqlcode != 0) {
1205 ingerr(&sqlca.sqlcode);
1209 if (!(m = (struct machine *)hash_lookup(machines, id1)))
1210 sq_save_unique_data(sq1, id1);
1211 if (!hash_lookup(clusters, id2))
1212 sq_save_unique_data(sq2, id2);
1213 if (m) m->clucount++;
1215 EXEC SQL CLOSE csr221;
1216 generic_delete(sq1, show_mcm_mach, "mcmap", "mach_id", 1);
1217 generic_delete(sq2, show_mcm_clu, "mcmap", "clu_id", 1);
1219 dprintf("Checking service clusters...\n");
1221 EXEC SQL DECLARE csr222 CURSOR FOR
1222 SELECT clu_id FROM svc;
1223 if (sqlca.sqlcode != 0) ingerr(&sqlca.sqlcode);
1224 EXEC SQL OPEN csr222;
1226 EXEC SQL FETCH csr222 INTO :id1;
1227 if (sqlca.sqlcode != 0) {
1228 ingerr(&sqlca.sqlcode);
1232 if (!hash_lookup(clusters, id1))
1233 sq_save_unique_data(sq1, id1);
1235 EXEC SQL CLOSE csr222;
1236 generic_delete(sq1, show_svc, "svc", "clu_id", 1);
1238 dprintf("Checking lists...\n");
1239 hash_step(lists, list_check, NULL);
1241 dprintf("Checking members...\n");
1248 EXEC SQL DECLARE csr223 CURSOR FOR
1249 SELECT list_id, member_type, member_id, ref_count, direct
1250 FROM imembers ORDER BY list_id;
1251 if (sqlca.sqlcode != 0) ingerr(&sqlca.sqlcode);
1252 EXEC SQL OPEN csr223;
1254 EXEC SQL FETCH csr223 INTO :id1, :type, :id2, :id3, :id4;
1255 if (sqlca.sqlcode != 0) {
1256 ingerr(&sqlca.sqlcode);
1260 if ((l = (struct list *) hash_lookup(lists, id1)) == NULL)
1261 sq_save_unique_data(sq1, id1);
1262 else if (type[0] == 'U' && !hash_lookup(users, id2))
1263 sq_save_unique_data(sq2, id2);
1264 else if (type[0] == 'L' && !hash_lookup(lists, id2))
1265 sq_save_unique_data(sq3, id2);
1266 else if (type[0] == 'S' && !string_check(id2))
1267 sq_save_unique_data(sq4, id2);
1268 else if (type[0] == 'K' && !string_check(id2))
1269 sq_save_unique_data(sq5, id2);
1273 EXEC SQL CLOSE csr223;
1274 generic_delete(sq1, show_member_list, "imembers", "list_id", 1);
1275 generic_fix(sq2, show_mem_user, "Delete", del_mem_user, 1);
1276 generic_fix(sq3, show_mem_list, "Delete", del_mem_list, 1);
1277 generic_fix(sq4, show_mem_str, "Delete", del_mem_str, 1);
1278 generic_fix(sq5, show_mem_krb, "Delete", del_mem_krb, 1);
1280 dprintf("Checking servers...\n");
1283 EXEC SQL DECLARE csr224 CURSOR FOR
1284 SELECT name, acl_type, acl_id FROM servers;
1285 if (sqlca.sqlcode != 0) ingerr(&sqlca.sqlcode);
1286 EXEC SQL OPEN csr224;
1288 EXEC SQL FETCH csr224 INTO :name, :type, :id1;
1289 if (sqlca.sqlcode != 0) {
1290 ingerr(&sqlca.sqlcode);
1295 if (!strcmp(type, "USER") && !hash_lookup(users, id1)) {
1296 sq_save_data(sq1, id1);
1297 } else if (!strcmp(type, "LIST") && !hash_lookup(lists, id1)) {
1298 sq_save_data(sq2, id1);
1301 EXEC SQL CLOSE csr224;
1302 generic_fix(sq1, show_srv_user, "Fix", zero_srv_user, 1);
1303 generic_fix(sq2, show_srv_list, "Fix", zero_srv_list, 1);
1305 dprintf("Checking serverhosts...\n");
1307 EXEC SQL DECLARE csr225 CURSOR FOR
1308 SELECT mach_id FROM serverhosts;
1309 if (sqlca.sqlcode != 0) ingerr(&sqlca.sqlcode);
1310 EXEC SQL OPEN csr225;
1312 EXEC SQL FETCH csr225 INTO :id1;
1313 if (sqlca.sqlcode != 0) {
1314 ingerr(&sqlca.sqlcode);
1318 if (!hash_lookup(machines, id1))
1319 sq_save_data(sq, id1);
1321 EXEC SQL CLOSE csr225;
1322 generic_fix(sq, show_sh, "Delete", del_sh_mach, 0);
1324 dprintf("Checking nfsphys...\n");
1325 hash_step(nfsphys, check_nfsphys, NULL);
1327 dprintf("Checking filesys...\n");
1328 hash_step(filesys, check_fs, NULL);
1330 dprintf("Checking filesystem groups...\n");
1334 EXEC SQL DECLARE csr226 CURSOR FOR
1335 SELECT group_id, filsys_id FROM fsgroup;
1336 if (sqlca.sqlcode != 0) ingerr(&sqlca.sqlcode);
1337 EXEC SQL OPEN csr226;
1339 EXEC SQL FETCH csr226 INTO :id1, :id2;
1340 if (sqlca.sqlcode != 0) {
1341 ingerr(&sqlca.sqlcode);
1345 if (!(f = (struct filesys *) hash_lookup(filesys, id1)))
1346 sq_save_data(sq1, id1);
1347 if (!hash_lookup(filesys, id2))
1348 sq_save_data(sq3, id2);
1350 EXEC SQL CLOSE csr226;
1351 generic_delete(sq1, show_fsg_missing, "fsgroup", "group_id", 0);
1352 generic_delete(sq3, show_fsg_nomember, "fsgroup", "filsys_id", 1);
1354 dprintf("Checking quotas...\n");
1359 EXEC SQL DECLARE csr227 CURSOR FOR
1360 SELECT entity_id, type, filsys_id, phys_id, quota FROM quota;
1361 if (sqlca.sqlcode != 0) ingerr(&sqlca.sqlcode);
1362 EXEC SQL OPEN csr227;
1364 EXEC SQL FETCH csr227 INTO :id1, :type, :id2, :id3, :id4;
1365 if (sqlca.sqlcode != 0) {
1366 ingerr(&sqlca.sqlcode);
1370 if (type[0] == 'U' && id1 != 0 && !hash_lookup(users, id1))
1371 sq_save_data(sq1, id1);
1372 else if (type[0] == 'G' && !hash_lookup(lists, id1))
1373 sq_save_data(sq4, id1);
1374 else if (!(f = (struct filesys *) hash_lookup(filesys, id2)))
1375 sq_save_data(sq2, id2);
1376 else if (id3 != f->phys_id ||
1377 ((n = (struct nfsphys*) hash_lookup(nfsphys, id3)) ==
1378 (struct nfsphys *)NULL))
1379 sq_save_data(sq3, id2);
1383 EXEC SQL CLOSE csr227;
1384 generic_fix(sq1, show_quota_nouser, "Delete", fix_quota_nouser, 1);
1385 generic_fix(sq2, show_quota_nofs, "Delete", fix_quota_nofs, 0);
1386 generic_fix(sq3, show_quota_wrongpid, "Fix", fix_quota_physid, 1);
1387 generic_fix(sq4, show_quota_nolist, "Delete", fix_quota_nolist, 1);
1389 dprintf("Not checking zephyr.\n");
1391 dprintf("Checking hostaccess...\n");
1392 EXEC SQL DECLARE csr228 CURSOR FOR
1393 SELECT mach_id, acl_type, acl_id FROM hostaccess;
1394 if (sqlca.sqlcode != 0) ingerr(&sqlca.sqlcode);
1395 EXEC SQL OPEN csr228;
1397 EXEC SQL FETCH csr228 INTO :id1, :type, :id2;
1398 if (sqlca.sqlcode != 0) {
1399 ingerr(&sqlca.sqlcode);
1404 if (!hash_lookup(machines, id1)) {
1405 printf("Hostaccess for non-existant host %d\n", id1);
1406 printf("Not fixing this error\n");
1408 if (!strcmp(type, "USER") && !hash_lookup(users, id2)) {
1409 printf("Hostaccess for %d is non-existant user %d\n", id1, id2);
1410 printf("Not fixing this error\n");
1411 } else if (!strcmp(type, "LIST") && !hash_lookup(lists, id2)) {
1412 printf("Hostaccess for %d is non-existant list %d\n", id1, id2);
1413 printf("Not fixing this error\n");
1416 EXEC SQL CLOSE csr228;
1418 dprintf("Checking palladium...\n");
1420 EXEC SQL DECLARE csr229 CURSOR FOR
1421 SELECT mach_id FROM palladium;
1422 if (sqlca.sqlcode != 0) ingerr(&sqlca.sqlcode);
1423 EXEC SQL OPEN csr229;
1425 EXEC SQL FETCH csr229 INTO :id1;
1426 if (sqlca.sqlcode != 0) {
1427 ingerr(&sqlca.sqlcode);
1431 if (!hash_lookup(machines, id1)) {
1432 sq_save_unique_data(sq1, id1);
1435 EXEC SQL CLOSE csr229;
1436 generic_delete(sq1, show_pdm_mach, "palladium", "mach_id", 1);
1438 dprintf("Checking krbmap...\n");
1441 EXEC SQL DECLARE csr230 CURSOR FOR
1442 SELECT users_id, string_id FROM krbmap;
1443 if (sqlca.sqlcode != 0) ingerr(&sqlca.sqlcode);
1444 EXEC SQL OPEN csr230;
1446 EXEC SQL FETCH csr230 INTO :id1, :id2;
1447 if (sqlca.sqlcode != 0) {
1448 ingerr(&sqlca.sqlcode);
1452 if (!hash_lookup(users, id1))
1453 sq_save_unique_data(sq1, id1);
1454 if (!string_check(id2))
1455 sq_save_unique_data(sq2, id2);
1457 EXEC SQL CLOSE csr230;
1458 generic_delete(sq1, show_krb_usr, "krbmap", "users_id", 1);
1459 generic_delete(sq2, show_krb_str, "krbmap", "string_id", 1);
1461 dprintf("Checking capacls...\n");
1462 EXEC SQL DECLARE csr231 CURSOR FOR
1463 SELECT list_id, tag FROM capacls;
1464 if (sqlca.sqlcode != 0) ingerr(&sqlca.sqlcode);
1465 EXEC SQL OPEN csr231;
1467 EXEC SQL FETCH csr231 INTO :id1, :name;
1468 if (sqlca.sqlcode != 0) {
1469 ingerr(&sqlca.sqlcode);
1473 if (!hash_lookup(lists, id1)) {
1474 printf("Capacl for %s is non-existant list %d\n", name, id1);
1475 printf("Not fixing this error\n");
1478 EXEC SQL CLOSE csr231;