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("Cluster %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
57 SELECT machine.name FROM machine, mcmap
58 WHERE machine.mach_id=mcmap.mach_id AND mcmap.clu_id=:iid;
59 if (sqlca.sqlcode != 0) ingerr(&sqlca.sqlcode);
62 EXEC SQL FETCH csr202 INTO :name;
63 if (sqlca.sqlcode != 0) {
64 ingerr(&sqlca.sqlcode);
71 printf("Machine %s, non-existant cluster %d in cluster map\n", name, id);
73 EXEC SQL CLOSE csr202;
80 EXEC SQL BEGIN DECLARE SECTION;
81 int iid = id, found = 1;
83 EXEC SQL END DECLARE SECTION;
85 EXEC SQL DECLARE csr234 CURSOR FOR
86 SELECT name FROM hostalias WHERE mach_id=:iid;
87 if (sqlca.sqlcode != 0) ingerr(&sqlca.sqlcode);
90 EXEC SQL FETCH csr234 INTO :name;
91 if (sqlca.sqlcode != 0) {
92 ingerr(&sqlca.sqlcode);
99 printf("Alias %s, non-existant machine %d in hostalias map\n", name, id);
101 EXEC SQL CLOSE csr234;
108 EXEC SQL BEGIN DECLARE SECTION;
109 int iid = id, found = 1;
111 EXEC SQL END DECLARE SECTION;
113 EXEC SQL DECLARE csr235 CURSOR FOR
114 SELECT name FROM printcap WHERE mach_id=:iid;
115 if (sqlca.sqlcode != 0) ingerr(&sqlca.sqlcode);
116 EXEC SQL OPEN csr235;
118 EXEC SQL FETCH csr235 INTO :name;
119 if (sqlca.sqlcode != 0) {
120 ingerr(&sqlca.sqlcode);
127 printf("Printer %s, non-existant spool machine %d in printcap table\n", name, id);
129 EXEC SQL CLOSE csr235;
136 EXEC SQL BEGIN DECLARE SECTION;
137 int iid = id, found = 1;
139 EXEC SQL END DECLARE SECTION;
141 EXEC SQL DECLARE csr236 CURSOR FOR
142 SELECT name FROM printcap WHERE quotaserver=:iid;
143 if (sqlca.sqlcode != 0) ingerr(&sqlca.sqlcode);
144 EXEC SQL OPEN csr236;
146 EXEC SQL FETCH csr236 INTO :name;
147 if (sqlca.sqlcode != 0) {
148 ingerr(&sqlca.sqlcode);
155 printf("Printer %s, non-existant quota server %d in printcap table\n", name, id);
157 EXEC SQL CLOSE csr236;
161 user_check(id, u, hint)
166 u->comment=maybe_fixup_unref_string(u->comment, id, u->login, "users",
167 "comment", "users_id");
169 u->modby=maybe_fixup_modby(u->modby, id, u->login, "users",
170 "modby", "users_id");
172 u->fmodby=maybe_fixup_modby(u->fmodby, id, u->login, "users",
173 "fmodby", "users_id");
175 u->pmodby=maybe_fixup_modby(u->pmodby, id, u->login, "users",
176 "pmodby", "users_id");
178 u->sigwho=maybe_fixup_unref_string(u->sigwho, id, u->login, "users",
179 "sigwho", "users_id");
181 pobox_check(id, u, hint);
184 maybe_fixup_unref_string(sid, oid, oname, table, field, idfield)
187 char *field, *idfield;
189 int ret=(sid<0)?-sid:sid, doit=0, newid;
190 EXEC SQL BEGIN DECLARE SECTION;
193 EXEC SQL END DECLARE SECTION;
195 if(newid=int_hash_lookup(string_dups, ret)) {
196 printf("%s entry %s(%d) has a %s with duplicate string %d\n",
197 table, oname, oid, field, ret);
198 if(single_fix("Replace duplicate", 0)){
203 } else if(!string_check(ret)) {
204 printf("%s entry %s(%d) has a %s with non-existant string %d\n",
205 table, oname, oid, field, ret);
206 if (single_fix("Delete", 1)) {
213 sprintf(stmt_buf, "UPDATE %s SET %s = %d WHERE %s = %d",
214 table, field, (sid<0)?-ret:ret, idfield, oid);
215 EXEC SQL EXECUTE IMMEDIATE :stmt_buf;
216 EXEC SQL INQUIRE_SQL(:rowcount = rowcount);
220 printf("Not fixed, rowcount = %d\n", rowcount);
224 return((sid<0)?-ret:ret);
228 maybe_fixup_modby(sid, oid, oname, table, field, idfield)
231 char *field, *idfield;
233 EXEC SQL BEGIN DECLARE SECTION;
236 EXEC SQL END DECLARE SECTION;
239 return maybe_fixup_unref_string(sid, oid, oname, table, field, idfield);
241 if(!hash_lookup(users, sid)) {
242 printf("%s entry %s(%d) has a %s with non-existant user %d\n",
243 table, oname, oid, field, sid);
244 if (single_fix("Delete", 1)) {
245 sprintf(stmt_buf, "UPDATE %s SET %s = %d WHERE %s=%d",
246 table, field, 0, idfield, oid);
247 EXEC SQL EXECUTE IMMEDIATE :stmt_buf;
248 EXEC SQL INQUIRE_SQL(:rowcount = rowcount);
252 printf("Not fixed, rowcount = %d\n", rowcount);
261 maybe_fixup_unref_string2(table, field, cursor, sid)
263 char *field, *table, *cursor;
265 int ret=(sid<0)?-sid:sid, doit=0, newid;
266 EXEC SQL BEGIN DECLARE SECTION;
269 EXEC SQL END DECLARE SECTION;
271 if(newid=int_hash_lookup(string_dups, ret)) {
272 printf("%s entry has a %s with duplicate string %d\n",
274 if(single_fix("Replace duplicate", 0)){
279 } else if(!string_check(ret)) {
280 printf("%s entry has a %s with non-existant string %d\n",
282 if (single_fix("Delete", 1)) {
289 sprintf(stmt_buf, "UPDATE %s SET %s = %d WHERE CURRENT OF %s",
290 table, field, (sid<0)?-ret:ret, cursor);
291 EXEC SQL EXECUTE IMMEDIATE :stmt_buf;
292 EXEC SQL INQUIRE_SQL(:rowcount = rowcount);
296 printf("Not fixed, rowcount = %d\n", rowcount);
299 return((sid<0)?-ret:ret);
302 maybe_fixup_modby2(table, field, cursor, id)
304 EXEC SQL BEGIN DECLARE SECTION;
307 EXEC SQL END DECLARE SECTION;
309 if(id<0) return maybe_fixup_unref_string2(table, field, cursor, id);
311 if(!hash_lookup(users, id)) {
312 printf("%s entry has a %s with non-existant user %d\n",
314 if (single_fix("Delete", 1)) {
315 sprintf(stmt_buf, "UPDATE %s SET %s = %d WHERE CURRENT OF %s",
316 table, field, 0, cursor);
317 EXEC SQL EXECUTE IMMEDIATE :stmt_buf;
318 EXEC SQL INQUIRE_SQL(:rowcount = rowcount);
322 printf("Not fixed, rowcount = %d\n", rowcount);
331 pobox_check(id, u, hint)
338 if (!hash_lookup(machines, u->pobox_id)) {
339 printf("User %s(%s) has P.O.Box on non-existant machine %d\n",
340 u->login, u->fullname, u->pobox_id);
341 if (single_fix("Delete", 0)) {
342 remove_pobox(u->users_id);
348 if( int_hash_lookup( string_dups, u->pobox_id ) ) {
349 printf("User %s(%s) has P.O.Box with duplicate string %d\n",
350 u->login, u->fullname, u->pobox_id);
351 if(single_fix("Update", 0)){
352 printf("Replacing box_id dup string ID %d with %d\n",
354 int_hash_lookup(string_dups, u->pobox_id));
355 u->pobox_id = int_hash_lookup( string_dups, u->pobox_id );
356 fix_smtp_pobox(u->users_id, u->pobox_id);
357 string_check(u->pobox_id);
359 } else if (!string_check(u->pobox_id)) {
360 printf("User %s(%s) has P.O.Box with non-existant string %d\n",
361 u->login, u->fullname, u->pobox_id);
362 if (single_fix("Delete", 0)) {
363 remove_pobox(u->users_id);
377 EXEC SQL BEGIN DECLARE SECTION;
378 int rowcount, iid = id;
379 EXEC SQL END DECLARE SECTION;
381 EXEC SQL UPDATE users SET potype='NONE' WHERE users.users_id = :iid;
382 EXEC SQL INQUIRE_SQL(:rowcount = rowcount);
384 printf("%d entr%s removed\n", rowcount, rowcount==1?"y":"ies");
386 printf("Not removed\n");
390 fix_smtp_pobox(id, sid)
393 EXEC SQL BEGIN DECLARE SECTION;
394 int rowcount, iid = id, isid=sid;
395 EXEC SQL END DECLARE SECTION;
397 EXEC SQL UPDATE users SET box_id=:isid WHERE users.users_id = :iid;
398 EXEC SQL INQUIRE_SQL(:rowcount = rowcount);
400 printf("%d entr%s updated\n", rowcount, rowcount==1?"y":"ies");
402 printf("Not updated\n");
406 mach_check(id, m, hint)
411 if (!hash_lookup(subnets, m->snet_id)) {
412 printf("Machine %s is on a non-existant subnet %d\n",
413 m->name, m->snet_id);
414 if (single_fix("Move to null-subnet", 1)) {
415 EXEC SQL BEGIN DECLARE SECTION;
416 int rowcount, iid = id;
417 EXEC SQL END DECLARE SECTION;
419 EXEC SQL UPDATE machine SET snet_id=0 WHERE mach_id = :iid;
420 EXEC SQL INQUIRE_SQL(:rowcount = rowcount);
422 printf("%d entr%s fixed\n", rowcount, rowcount==1?"y":"ies");
424 printf("Not fixed\n");
429 switch (m->owner_type) {
431 if (!hash_lookup(users, m->owner_id)) {
432 printf("Machine %s has non-existant USER owner %d\n",
433 m->name, m->owner_id);
434 if (single_fix("Set to no owner", 1)) {
440 if (!hash_lookup(lists, m->owner_id)) {
441 printf("Machine %s has non-existant LIST owner %d\n",
442 m->name, m->owner_id);
443 if (single_fix("Set to no owner", 1)) {
451 m->owner_id=maybe_fixup_unref_string(m->owner_id, id, m->name,
452 "machine", "owner_id", "mach_id");
458 m->acomment=maybe_fixup_unref_string(m->acomment, id, m->name,
459 "machine", "acomment", "mach_id");
461 m->ocomment=maybe_fixup_unref_string(m->ocomment, id, m->name,
462 "machine", "ocomment", "mach_id");
464 m->creator=maybe_fixup_modby(m->creator, id, m->name, "machine",
465 "creator", "mach_id");
466 m->modby=maybe_fixup_modby(m->modby, id, m->name, "machine",
470 subnet_check(id, s, hint)
475 switch (s->owner_type) {
477 if (!hash_lookup(users, s->owner_id)) {
478 printf("Subnet %s has non-existant USER owner %d\n",
479 s->name, s->owner_id);
480 if (single_fix("Set to no owner", 1)) {
481 clear_subnet_owner(s);
486 if (!hash_lookup(lists, s->owner_id)) {
487 printf("Machine %s has non-existant LIST owner %d\n",
488 s->name, s->owner_id);
489 if (single_fix("Set to no owner", 1)) {
490 clear_subnet_owner(s);
497 s->owner_id=maybe_fixup_unref_string(s->owner_id, id, s->name,
498 "machine", "owner_id", "mach_id");
500 clear_subnet_owner(s);
503 s->modby=maybe_fixup_modby(s->modby, id, s->name, "subnet",
508 clear_subnet_owner(s)
511 EXEC SQL BEGIN DECLARE SECTION;
512 int rowcount, id = s->snet_id;
513 EXEC SQL END DECLARE SECTION;
515 EXEC SQL UPDATE subnet SET owner_type='NONE', owner_id=0
517 EXEC SQL INQUIRE_SQL(:rowcount = rowcount);
519 printf("%d entr%s fixed\n", rowcount, rowcount==1?"y":"ies");
521 printf("Not fixed\n");
528 EXEC SQL BEGIN DECLARE SECTION;
529 int rowcount, id = m->mach_id;
530 EXEC SQL END DECLARE SECTION;
532 EXEC SQL UPDATE machine SET owner_type='NONE', owner_id=0
534 EXEC SQL INQUIRE_SQL(:rowcount = rowcount);
536 printf("%d entr%s fixed\n", rowcount, rowcount==1?"y":"ies");
538 printf("Not fixed\n");
542 cluster_check(id, c, hint)
547 c->modby=maybe_fixup_modby(c->modby, id, c->name, "cluster",
556 EXEC SQL BEGIN DECLARE SECTION;
557 int iid = id, found = 1;
558 char label[17], data[33];
559 EXEC SQL END DECLARE SECTION;
561 EXEC SQL DECLARE csr203 CURSOR FOR
562 SELECT serv_label, serv_cluster FROM svc
564 if (sqlca.sqlcode != 0) ingerr(&sqlca.sqlcode);
565 EXEC SQL OPEN csr203;
567 EXEC SQL FETCH csr203 INTO :label, :data;
568 if (sqlca.sqlcode != 0) {
569 ingerr(&sqlca.sqlcode);
576 printf("Cluster data [%s] %s for non-existant cluster %d\n",
579 EXEC SQL CLOSE csr203;
583 list_check(id, l, hint)
588 switch (l->acl_type) {
590 if (!hash_lookup(lists, l->acl_id)) {
591 printf("List %s has bad LIST acl %d\n", l->name, l->acl_id);
592 if (single_fix("Patch", 1)) {
593 fix_list_acl(l->list_id);
598 if (!hash_lookup(users, l->acl_id)) {
599 printf("List %s has bad USER acl %d\n", l->name, l->acl_id);
600 if (single_fix("Patch", 1)) {
601 fix_list_acl(l->list_id);
606 l->acl_id = maybe_fixup_unref_string(l->acl_id, id, l->name,
607 "list", "acl_id", "list_id");
609 printf("List %s has bad KERBEROS acl %d\n", l->name, l->acl_id);
610 if(single_fix("Patch", 1)) {
611 fix_list_acl(l->list_id);
621 EXEC SQL BEGIN DECLARE SECTION;
622 int rowcount, iid = id;
623 EXEC SQL END DECLARE SECTION;
625 EXEC SQL UPDATE list SET acl_id = :iid, acl_type='LIST'
626 WHERE list_id = :iid;
627 EXEC SQL INQUIRE_SQL(:rowcount = rowcount);
629 printf("%d entr%s fixed\n", rowcount, rowcount==1?"y":"ies");
631 printf("Not fixed\n");
639 EXEC SQL BEGIN DECLARE SECTION;
640 int mid, iid = id, found = 1;
641 char mtype[9], *name = "";
642 EXEC SQL END DECLARE SECTION;
644 EXEC SQL DECLARE csr204 CURSOR FOR
645 SELECT member_type, member_id FROM imembers
646 WHERE list_id = :iid AND direct=1;
647 if (sqlca.sqlcode != 0) ingerr(&sqlca.sqlcode);
648 EXEC SQL OPEN csr204;
650 EXEC SQL FETCH csr204 INTO :mtype, :mid;
651 if (sqlca.sqlcode != 0) {
652 ingerr(&sqlca.sqlcode);
659 name = ((struct list *) hash_lookup(lists, mid))->name;
660 else if (mtype[0] == 'U')
661 name = ((struct user *) hash_lookup(users, mid))->login;
662 else if (mtype[0] == 'S' || mtype[0] == 'K')
663 name = ((struct string *) hash_lookup(strings, mid))->name;
664 printf("Non-existant list %d has member %s %s\n", iid, mtype, name);
666 EXEC SQL CLOSE csr204;
673 EXEC SQL BEGIN DECLARE SECTION;
674 int lid, iid = id, found = 1;
676 EXEC SQL END DECLARE SECTION;
678 EXEC SQL DECLARE csr205 CURSOR FOR
679 SELECT list_id FROM imembers
680 WHERE member_id = :iid AND member_type='USER' AND direct=1;
681 if (sqlca.sqlcode != 0) ingerr(&sqlca.sqlcode);
682 EXEC SQL OPEN csr205;
684 EXEC SQL FETCH csr205 INTO :lid;
685 if (sqlca.sqlcode != 0) {
686 ingerr(&sqlca.sqlcode);
691 printf("List %s has non-existant user member, id %d\n",
692 ((struct list *)hash_lookup(lists, lid))->name, iid);
694 EXEC SQL CLOSE csr205;
701 EXEC SQL BEGIN DECLARE SECTION;
702 int lid, iid = id, found = 1;
704 EXEC SQL END DECLARE SECTION;
706 EXEC SQL DECLARE csr206 CURSOR FOR
707 SELECT list_id FROM imembers
708 WHERE member_id = :iid AND member_type='LIST' AND direct=1;
709 if (sqlca.sqlcode != 0) ingerr(&sqlca.sqlcode);
710 EXEC SQL OPEN csr206;
712 EXEC SQL FETCH csr206 INTO :lid;
713 if (sqlca.sqlcode != 0) {
714 ingerr(&sqlca.sqlcode);
719 printf("List %s has non-existant list member, id %d\n",
720 ((struct list *)hash_lookup(lists, lid))->name, iid);
722 EXEC SQL CLOSE csr206;
729 EXEC SQL BEGIN DECLARE SECTION;
730 int lid, iid = id, found = 1;
732 EXEC SQL END DECLARE SECTION;
734 EXEC SQL DECLARE csr207 CURSOR FOR
735 SELECT list_id FROM imembers
736 WHERE member_id = :iid AND member_type='STRING' AND direct=1;
737 if (sqlca.sqlcode != 0) ingerr(&sqlca.sqlcode);
738 EXEC SQL OPEN csr207;
740 EXEC SQL FETCH csr207 INTO :lid;
741 if (sqlca.sqlcode != 0) {
742 ingerr(&sqlca.sqlcode);
747 printf("List %s has non-existant string member, id %d\n",
748 ((struct list *)hash_lookup(lists, lid))->name, iid);
750 EXEC SQL CLOSE csr207;
758 EXEC SQL BEGIN DECLARE SECTION;
759 int lid, iid = id, found = 1;
761 EXEC SQL END DECLARE SECTION;
763 EXEC SQL DECLARE csr208 CURSOR FOR
764 SELECT list_id FROM imembers
765 WHERE member_id = :iid AND member_type='KERBEROS' AND direct=1;
766 if (sqlca.sqlcode != 0) ingerr(&sqlca.sqlcode);
767 EXEC SQL OPEN csr208;
769 EXEC SQL FETCH csr208 INTO :lid;
770 if (sqlca.sqlcode != 0) {
771 ingerr(&sqlca.sqlcode);
776 printf("List %s has non-existant kerberos member, id %d\n",
777 ((struct list *)hash_lookup(lists, lid))->name, iid);
779 EXEC SQL CLOSE csr208;
785 EXEC SQL BEGIN DECLARE SECTION;
787 EXEC SQL END DECLARE SECTION;
789 EXEC SQL BEGIN DECLARE SECTION;
791 EXEC SQL END DECLARE SECTION;
793 EXEC SQL DELETE FROM imembers WHERE member_type='USER' AND
794 member_id = :id AND direct = 1;
795 EXEC SQL INQUIRE_SQL(:rowcount = rowcount);
797 printf("%d entr%s deleted\n", rowcount, rowcount==1?"y":"ies");
799 printf("Not deleted\n");
800 modified("imembers");
804 EXEC SQL BEGIN DECLARE SECTION;
806 EXEC SQL END DECLARE SECTION;
808 EXEC SQL BEGIN DECLARE SECTION;
810 EXEC SQL END DECLARE SECTION;
812 EXEC SQL DELETE FROM imembers WHERE member_type='LIST' AND
813 member_id = :id AND direct=1;
814 EXEC SQL INQUIRE_SQL(:rowcount = rowcount);
816 printf("%d entr%s deleted\n", rowcount, rowcount==1?"y":"ies");
818 printf("Not deleted\n");
819 modified("imembers");
823 EXEC SQL BEGIN DECLARE SECTION;
825 EXEC SQL END DECLARE SECTION;
827 EXEC SQL BEGIN DECLARE SECTION;
829 EXEC SQL END DECLARE SECTION;
831 EXEC SQL DELETE FROM imembers WHERE member_type='STRING' AND
832 member_id = :id AND direct=1;
833 EXEC SQL INQUIRE_SQL(:rowcount = rowcount);
835 printf("%d entr%s deleted\n", rowcount, rowcount==1?"y":"ies");
837 printf("Not deleted\n");
838 modified("imembers");
843 EXEC SQL BEGIN DECLARE SECTION;
845 EXEC SQL END DECLARE SECTION;
847 EXEC SQL BEGIN DECLARE SECTION;
849 EXEC SQL END DECLARE SECTION;
851 EXEC SQL DELETE FROM imembers WHERE member_type='KERBEROS' AND
852 member_id = :id AND direct=1;
853 EXEC SQL INQUIRE_SQL(:rowcount = rowcount);
855 printf("%d entr%s deleted\n", rowcount, rowcount==1?"y":"ies");
857 printf("Not deleted\n");
858 modified("imembers");
863 EXEC SQL BEGIN DECLARE SECTION;
865 EXEC SQL END DECLARE SECTION;
867 EXEC SQL BEGIN DECLARE SECTION;
869 EXEC SQL END DECLARE SECTION;
872 EXEC SQL DECLARE csr209 CURSOR FOR
873 SELECT service FROM serverhosts
875 if (sqlca.sqlcode != 0) ingerr(&sqlca.sqlcode);
876 EXEC SQL OPEN csr209;
878 EXEC SQL FETCH csr209 INTO :name;
879 if (sqlca.sqlcode != 0) {
880 ingerr(&sqlca.sqlcode);
885 printf("ServerHost entry for service %s non-existant host %d\n",
888 EXEC SQL CLOSE csr209;
893 EXEC SQL BEGIN DECLARE SECTION;
895 EXEC SQL END DECLARE SECTION;
897 EXEC SQL BEGIN DECLARE SECTION;
899 EXEC SQL END DECLARE SECTION;
901 EXEC SQL DELETE FROM serverhosts WHERE mach_id = :id;
902 EXEC SQL INQUIRE_SQL(:rowcount = rowcount);
904 printf("%d entr%s deleted\n", rowcount, rowcount==1?"y":"ies");
906 printf("Not deleted\n");
907 modified("serverhosts");
911 static int fnchecklen;
918 if (n->mach_id == f->mach_id &&
919 !strncmp(f->dir, n->dir, strlen(n->dir)) &&
920 strlen(n->dir) > fnchecklen) {
922 fnchecklen = strlen(n->dir);
927 check_fs(id, f, hint)
928 EXEC SQL BEGIN DECLARE SECTION;
930 EXEC SQL END DECLARE SECTION;
931 register struct filesys *f;
934 EXEC SQL BEGIN DECLARE SECTION;
935 int id1, id2, id3, rowcount;
937 EXEC SQL END DECLARE SECTION;
941 if (!hash_lookup(machines, f->mach_id)) {
942 printf("Filesys %s with bad machine %d\n", f->name, f->mach_id);
943 if (single_fix("Fix", 0)) {
944 EXEC SQL UPDATE filesys SET mach_id = 0 WHERE filsys_id = :id;
945 EXEC SQL INQUIRE_SQL(:rowcount = rowcount);
947 printf("%d entr%s fixed\n",rowcount, rowcount==1?"y":"ies");
949 printf("Not fixed\n");
955 if (!hash_lookup(users, f->owner)) {
956 printf("Filesys %s with bad owning user %d\n", f->name, f->owner);
957 if (single_fix("Fix", 1)) {
958 zero_fix("filesys", "owner", "filsys_id", f->filsys_id);
962 if (!hash_lookup(lists, f->owners)) {
963 printf("Filesys %s with bad owning group %d\n", f->name, f->owners);
964 if (single_fix("Fix", 1)) {
965 zero_fix("filesys", "owners", "filsys_id", f->filsys_id);
970 if (f->type == 'N') {
971 if (!hash_lookup(nfsphys, f->phys_id)) {
972 m = (struct machine *)hash_lookup(machines, f->mach_id);
973 printf("Filesys %s with bad phys_id %d\n", f->name, f->phys_id);
974 if (single_fix("Fix", 1)) {
976 hash_step(nfsphys, fsmatch, f);
977 if (fnchecklen != 0) {
981 EXEC SQL UPDATE filesys SET phys_id = :id1 WHERE filsys_id = :id2;
982 EXEC SQL INQUIRE_SQL(:rowcount = rowcount);
984 printf("%d entr%s fixed\n",rowcount, rowcount==1?"y":"ies");
986 printf("Not fixed\n");
989 printf("No NFSphys exsits for %s:%s\n", m->name, f->dir);
990 if (single_fix("Create", 0)) {
995 if (set_next_object_id("nfsphys_id", "nfsphys") !=
997 printf("Unable to assign unique ID\n");
1000 EXEC SQL SELECT COUNT(*) INTO :rowcount FROM numvalues
1001 WHERE name='nfsphys_id';
1002 if (rowcount != 1) {
1003 printf("Unable to retrieve unique ID\n");
1006 EXEC SQL INSERT INTO mfsphys (mfsphys_id, mach_id,
1007 device, dir, status, allocated, size, modtime,
1008 modby, modwith) VALUES (:id1, :id3, '???', :dir,
1009 0, 0, 0, 'now', 0, 'dbck');
1010 EXEC SQL INQUIRE_SQL(:rowcount = rowcount);
1012 printf("%d entr%s created\n", rowcount,
1013 rowcount==1?"y":"ies");
1015 printf("Not created\n");
1016 modified("nfsphys");
1017 n = (struct nfsphys *)malloc(sizeof(struct nfsphys));
1019 out_of_mem("storing new nfsphys");
1020 strcpy(n->dir, dir);
1022 n->nfsphys_id = id1;
1025 if( hash_store(nfsphys, id1, n) == -1 ) {
1026 out_of_mem("storing nfsphys in hash table");
1028 EXEC SQL UPDATE filesys SET phys_id = :id1
1029 WHERE filsys_id = :id2;
1030 EXEC SQL INQUIRE_SQL(:rowcount = rowcount);
1032 printf("%d filesys entr%s fixed\n", rowcount,
1033 rowcount==1?"y":"ies");
1035 printf("Not fixed\n");
1036 modified("filesys");
1045 check_nfsphys(id, n, hint)
1050 if (!hash_lookup(machines, n->mach_id)) {
1051 printf("NFSphys %d(%s) on non-existant machine %d\n",
1052 id, n->dir, n->mach_id);
1053 if (single_fix("Delete", 0))
1054 single_delete("nfsphys", "nfsphys_id", id);
1058 show_fsg_missing(id)
1059 EXEC SQL BEGIN DECLARE SECTION;
1061 EXEC SQL END DECLARE SECTION;
1063 EXEC SQL BEGIN DECLARE SECTION;
1065 EXEC SQL END DECLARE SECTION;
1068 EXEC SQL DECLARE csr210 CURSOR FOR
1069 SELECT filsys_id FROM fsgroup
1070 WHERE group_id = :id;
1071 if (sqlca.sqlcode != 0) ingerr(&sqlca.sqlcode);
1072 EXEC SQL OPEN csr210;
1074 EXEC SQL FETCH csr210 INTO :id1;
1075 if (sqlca.sqlcode != 0) {
1076 ingerr(&sqlca.sqlcode);
1081 if (f = (struct filesys *) hash_lookup(filesys, id1))
1082 printf("Missing fsgroup %d has member filesystem %s\n", id, f->name);
1084 printf("Missing fsgroup %d has member filesystem %d\n", id, id1);
1086 EXEC SQL CLOSE csr210;
1117 printf("FSGroup %s has type %s instead of FSGROUP\n", f->name, t);
1124 EXEC SQL BEGIN DECLARE SECTION;
1125 int rowcount, id = f->filsys_id;
1126 EXEC SQL END DECLARE SECTION;
1128 EXEC SQL UPDATE filesys SET type='FSGROUP' WHERE filsys_id = :id;
1129 EXEC SQL INQUIRE_SQL(:rowcount = rowcount);
1131 printf("%d entr%s fixed\n", rowcount, rowcount==1?"y":"ies");
1133 printf("Not fixed\n");
1134 modified("filesys");
1137 show_fsg_nomember(id)
1138 EXEC SQL BEGIN DECLARE SECTION;
1140 EXEC SQL END DECLARE SECTION;
1142 EXEC SQL BEGIN DECLARE SECTION;
1144 EXEC SQL END DECLARE SECTION;
1147 EXEC SQL DECLARE csr211 CURSOR FOR
1148 SELECT group_id FROM fsgroup
1149 WHERE filsys_id = :id;
1150 if (sqlca.sqlcode != 0) ingerr(&sqlca.sqlcode);
1151 EXEC SQL OPEN csr211;
1153 EXEC SQL FETCH csr211 INTO :id1;
1154 if (sqlca.sqlcode != 0) {
1155 ingerr(&sqlca.sqlcode);
1160 if (f = (struct filesys *) hash_lookup(filesys, id1))
1161 printf("FSGroup %s has missing member %d\n", f->name, id);
1163 printf("FSGroup %d has missing member %d\n", id1, id);
1165 EXEC SQL CLOSE csr211;
1169 show_quota_nouser(id)
1170 EXEC SQL BEGIN DECLARE SECTION;
1172 EXEC SQL END DECLARE SECTION;
1174 EXEC SQL BEGIN DECLARE SECTION;
1176 EXEC SQL END DECLARE SECTION;
1178 EXEC SQL DECLARE csr212 CURSOR FOR
1179 SELECT filsys_id FROM quota
1180 WHERE entity_id = :id AND type='USER';
1181 if (sqlca.sqlcode != 0) ingerr(&sqlca.sqlcode);
1182 EXEC SQL OPEN csr212;
1184 EXEC SQL FETCH csr212 INTO :id1;
1185 if (sqlca.sqlcode != 0) {
1186 ingerr(&sqlca.sqlcode);
1191 printf("Quota on fs %d for non-existant user %d\n", id1, id);
1193 EXEC SQL CLOSE csr212;
1197 show_quota_nolist(id)
1198 EXEC SQL BEGIN DECLARE SECTION;
1200 EXEC SQL END DECLARE SECTION;
1202 EXEC SQL BEGIN DECLARE SECTION;
1204 EXEC SQL END DECLARE SECTION;
1206 EXEC SQL DECLARE csr213 CURSOR FOR
1207 SELECT filsys_id FROM quota
1208 WHERE entity_id = :id AND type='GROUP';
1209 if (sqlca.sqlcode != 0) ingerr(&sqlca.sqlcode);
1210 EXEC SQL OPEN csr213;
1212 EXEC SQL FETCH csr213 INTO :id1;
1213 if (sqlca.sqlcode != 0) {
1214 ingerr(&sqlca.sqlcode);
1219 printf("Quota on fs %d for non-existant list %d\n", id1, id);
1221 EXEC SQL CLOSE csr213;
1225 fix_quota_nouser(id)
1226 EXEC SQL BEGIN DECLARE SECTION;
1228 EXEC SQL END DECLARE SECTION;
1230 EXEC SQL BEGIN DECLARE SECTION;
1232 EXEC SQL END DECLARE SECTION;
1234 id1 = ((struct filesys *)hash_lookup(filesys, id))->phys_id;
1235 EXEC SQL DELETE FROM quota
1236 WHERE entity_id = :id AND type = 'USER';
1237 EXEC SQL INQUIRE_SQL(:rowcount = rowcount);
1239 printf("%d entr%s deleted\n",rowcount, rowcount==1?"y":"ies");
1241 printf("Not deleted\n");
1245 fix_quota_nolist(id)
1246 EXEC SQL BEGIN DECLARE SECTION;
1248 EXEC SQL END DECLARE SECTION;
1250 EXEC SQL BEGIN DECLARE SECTION;
1252 EXEC SQL END DECLARE SECTION;
1254 id1 = ((struct filesys *)hash_lookup(filesys, id))->phys_id;
1255 EXEC SQL DELETE FROM quota WHERE entity_id = :id AND type='GROUP';
1256 EXEC SQL INQUIRE_SQL(:rowcount = rowcount);
1258 printf("%d entr%s deleted\n",rowcount, rowcount==1?"y":"ies");
1260 printf("Not deleted\n");
1265 EXEC SQL BEGIN DECLARE SECTION;
1267 EXEC SQL END DECLARE SECTION;
1269 EXEC SQL BEGIN DECLARE SECTION;
1272 EXEC SQL END DECLARE SECTION;
1274 EXEC SQL DECLARE csr214 CURSOR FOR
1275 SELECT entity_id, type FROM quota
1276 WHERE filsys_id = :id;
1277 if (sqlca.sqlcode != 0) ingerr(&sqlca.sqlcode);
1278 EXEC SQL OPEN csr214;
1280 EXEC SQL FETCH csr214 INTO :id1, :type;
1281 if (sqlca.sqlcode != 0) {
1282 ingerr(&sqlca.sqlcode);
1287 printf("Quota for %s %d on non-existant filesys %d\n", type, id1, id);
1289 EXEC SQL CLOSE csr214;
1295 single_delete("quota", "filsys_id", id);
1298 show_quota_wrongpid(id)
1299 EXEC SQL BEGIN DECLARE SECTION;
1301 EXEC SQL END DECLARE SECTION;
1303 EXEC SQL BEGIN DECLARE SECTION;
1306 EXEC SQL END DECLARE SECTION;
1310 f = (struct filesys *)hash_lookup(filesys, id);
1311 EXEC SQL DECLARE csr215 CURSOR FOR
1312 SELECT entity_id, type FROM quota
1313 WHERE filsys_id = :id;
1314 if (sqlca.sqlcode != 0) ingerr(&sqlca.sqlcode);
1315 EXEC SQL OPEN csr215;
1317 EXEC SQL FETCH csr215 INTO :id1, :type;
1318 if (sqlca.sqlcode != 0) {
1319 ingerr(&sqlca.sqlcode);
1324 printf("Quota for %s %d on filesys %s has wrong phys_id %d\n",
1325 type, id1, f->name, id);
1327 EXEC SQL CLOSE csr215;
1331 fix_quota_physid(id)
1332 EXEC SQL BEGIN DECLARE SECTION;
1334 EXEC SQL END DECLARE SECTION;
1336 EXEC SQL BEGIN DECLARE SECTION;
1338 EXEC SQL END DECLARE SECTION;
1340 id1 = ((struct filesys *)hash_lookup(filesys, id))->phys_id;
1341 EXEC SQL UPDATE quota SET phys_id = :id1
1342 WHERE filsys_id = :id AND phys_id != :id1;
1343 EXEC SQL INQUIRE_SQL(:rowcount = rowcount);
1345 printf("%d entr%s fixed\n",rowcount, rowcount==1?"y":"ies");
1347 printf("Not fixed\n");
1352 EXEC SQL BEGIN DECLARE SECTION;
1354 EXEC SQL END DECLARE SECTION;
1356 EXEC SQL BEGIN DECLARE SECTION;
1358 EXEC SQL END DECLARE SECTION;
1361 EXEC SQL DECLARE csr216 CURSOR FOR
1362 SELECT name FROM servers
1363 WHERE acl_type='USER' and acl_id = :id;
1364 if (sqlca.sqlcode != 0) ingerr(&sqlca.sqlcode);
1365 EXEC SQL OPEN csr216;
1367 EXEC SQL FETCH csr216 INTO :name;
1368 if (sqlca.sqlcode != 0) {
1369 ingerr(&sqlca.sqlcode);
1374 printf("Service %s has acl non-existant user %d\n", name, id);
1377 EXEC SQL CLOSE csr216;
1382 EXEC SQL BEGIN DECLARE SECTION;
1384 EXEC SQL END DECLARE SECTION;
1386 EXEC SQL BEGIN DECLARE SECTION;
1388 EXEC SQL END DECLARE SECTION;
1391 EXEC SQL DECLARE csr217 CURSOR FOR
1392 SELECT name FROM servers
1393 WHERE acl_type='LIST' AND acl_id = :id;
1394 if (sqlca.sqlcode != 0) ingerr(&sqlca.sqlcode);
1395 EXEC SQL OPEN csr217;
1397 EXEC SQL FETCH csr217 INTO :name;
1398 if (sqlca.sqlcode != 0) {
1399 ingerr(&sqlca.sqlcode);
1404 printf("Service %s has acl non-existant list %d\n", name, id);
1407 EXEC SQL CLOSE csr217;
1412 EXEC SQL BEGIN DECLARE SECTION;
1414 EXEC SQL END DECLARE SECTION;
1416 EXEC SQL BEGIN DECLARE SECTION;
1418 EXEC SQL END DECLARE SECTION;
1420 EXEC SQL UPDATE servers SET acl_id=0 WHERE acl_id = :id AND
1422 EXEC SQL INQUIRE_SQL(:rowcount = rowcount);
1424 printf("%d entr%s fixed\n", rowcount, rowcount==1?"y":"ies");
1426 printf("Not fixed\n");
1427 modified("servers");
1431 EXEC SQL BEGIN DECLARE SECTION;
1433 EXEC SQL END DECLARE SECTION;
1435 EXEC SQL BEGIN DECLARE SECTION;
1437 EXEC SQL END DECLARE SECTION;
1439 EXEC SQL UPDATE servers SET acl_id=0 WHERE acl_id = :id AND
1441 EXEC SQL INQUIRE_SQL(:rowcount = rowcount);
1443 printf("%d entr%s fixed\n", rowcount, rowcount==1?"y":"ies");
1445 printf("Not fixed\n");
1446 modified("servers");
1451 EXEC SQL BEGIN DECLARE SECTION;
1453 EXEC SQL END DECLARE SECTION;
1455 EXEC SQL BEGIN DECLARE SECTION;
1457 EXEC SQL END DECLARE SECTION;
1461 EXEC SQL DECLARE csr218 CURSOR FOR
1462 SELECT string_id FROM krbmap
1463 WHERE users_id = :id ;
1464 if (sqlca.sqlcode != 0) ingerr(&sqlca.sqlcode);
1465 EXEC SQL OPEN csr218;
1467 EXEC SQL FETCH csr218 INTO :id1;
1468 if (sqlca.sqlcode != 0) {
1469 ingerr(&sqlca.sqlcode);
1473 if (s = ((struct string *)hash_lookup(strings, id1)))
1478 printf("Kerberos map for non-existant user %d to principal %s\n",
1481 EXEC SQL CLOSE csr218;
1487 EXEC SQL BEGIN DECLARE SECTION;
1489 EXEC SQL END DECLARE SECTION;
1491 EXEC SQL BEGIN DECLARE SECTION;
1493 EXEC SQL END DECLARE SECTION;
1497 EXEC SQL DECLARE csr219 CURSOR FOR
1498 SELECT users_id FROM krbmap
1499 WHERE string_id = :id;
1500 if (sqlca.sqlcode != 0) ingerr(&sqlca.sqlcode);
1501 EXEC SQL OPEN csr219;
1503 EXEC SQL FETCH csr219 INTO :id1;
1504 if (sqlca.sqlcode != 0) {
1505 ingerr(&sqlca.sqlcode);
1509 if (u = ((struct user *)hash_lookup(users, id1)))
1514 printf("Kerberos map for user %s (%d) to non-existant string %d\n",
1517 EXEC SQL CLOSE csr219;
1523 EXEC SQL BEGIN DECLARE SECTION;
1525 EXEC SQL END DECLARE SECTION;
1527 EXEC SQL BEGIN DECLARE SECTION;
1529 EXEC SQL END DECLARE SECTION;
1532 EXEC SQL DECLARE csr220 CURSOR FOR
1533 SELECT name FROM palladium
1534 WHERE mach_id = :id;
1535 if (sqlca.sqlcode != 0) ingerr(&sqlca.sqlcode);
1536 EXEC SQL OPEN csr220;
1538 EXEC SQL FETCH csr220 INTO :name;
1539 if (sqlca.sqlcode != 0) {
1540 ingerr(&sqlca.sqlcode);
1545 printf("Palladium server/supervisor %s is on non-existant machine %d\n",
1549 EXEC SQL CLOSE csr220;
1556 EXEC SQL BEGIN DECLARE SECTION;
1557 int id1, id2, id3, id4, id5;
1558 char type[9], name[33];
1559 EXEC SQL END DECLARE SECTION;
1560 struct save_queue *sq, *sq1, *sq2, *sq3, *sq4, *sq5;
1566 printf("Phase 2 - Checking references\n");
1568 dprintf("Checking users...\n");
1569 hash_step(users, user_check, NULL);
1571 dprintf("Checking machines...\n");
1572 hash_step(machines, mach_check, NULL);
1574 dprintf("Checking subnets...\n");
1575 hash_step(subnets, subnet_check, NULL);
1577 dprintf("Checking clusters...\n");
1578 hash_step(clusters, cluster_check, NULL);
1580 dprintf("Checking mcmap...\n");
1583 EXEC SQL DECLARE csr221 CURSOR FOR
1584 SELECT mach_id, clu_id FROM mcmap;
1585 if (sqlca.sqlcode != 0) ingerr(&sqlca.sqlcode);
1586 EXEC SQL OPEN csr221;
1587 if (sqlca.sqlcode != 0) ingerr(&sqlca.sqlcode);
1589 EXEC SQL FETCH csr221 INTO :id1, :id2;
1590 if (sqlca.sqlcode != 0) {
1591 ingerr(&sqlca.sqlcode);
1595 if (!(m = (struct machine *)hash_lookup(machines, id1)))
1596 sq_save_unique_data(sq1, id1);
1597 else if (!hash_lookup(clusters, id2))
1598 sq_save_unique_data(sq2, id2);
1599 if (m) m->clucount++;
1601 EXEC SQL CLOSE csr221;
1602 generic_delete(sq1, show_mcm_mach, "mcmap", "mach_id", 1);
1603 generic_delete(sq2, show_mcm_clu, "mcmap", "clu_id", 1);
1605 dprintf("Checking service clusters...\n");
1607 EXEC SQL DECLARE csr222 CURSOR FOR
1608 SELECT clu_id FROM svc;
1609 if (sqlca.sqlcode != 0) ingerr(&sqlca.sqlcode);
1610 EXEC SQL OPEN csr222;
1612 EXEC SQL FETCH csr222 INTO :id1;
1613 if (sqlca.sqlcode != 0) {
1614 ingerr(&sqlca.sqlcode);
1618 if (!hash_lookup(clusters, id1))
1619 sq_save_unique_data(sq1, id1);
1621 EXEC SQL CLOSE csr222;
1622 generic_delete(sq1, show_svc, "svc", "clu_id", 1);
1624 dprintf("Checking lists...\n");
1625 hash_step(lists, list_check, NULL);
1627 dprintf("Checking members...\n");
1634 EXEC SQL DECLARE csr223 CURSOR FOR
1635 SELECT list_id, member_type, member_id, ref_count, direct
1636 FROM imembers FOR DEFERRED UPDATE OF member_id;
1637 if (sqlca.sqlcode != 0) ingerr(&sqlca.sqlcode);
1638 EXEC SQL OPEN csr223;
1640 EXEC SQL FETCH csr223 INTO :id1, :type, :id2, :id3, :id4;
1641 if (sqlca.sqlcode != 0) {
1642 ingerr(&sqlca.sqlcode);
1646 if ((l = (struct list *) hash_lookup(lists, id1)) == NULL)
1647 sq_save_unique_data(sq1, id1);
1648 else if (type[0] == 'U' && !hash_lookup(users, id2))
1649 sq_save_unique_data(sq2, id2);
1650 else if (type[0] == 'L' && !hash_lookup(lists, id2))
1651 sq_save_unique_data(sq3, id2);
1652 else if (type[0] == 'S' && !maybe_fixup_unref_string2("imembers","member_id","csr223",id2))
1653 sq_save_unique_data(sq4, id2);
1654 else if (type[0] == 'K' && !maybe_fixup_unref_string2("imembers","member_id","csr223",id2))
1655 sq_save_unique_data(sq5, id2);
1659 EXEC SQL CLOSE csr223;
1660 generic_delete(sq1, show_member_list, "imembers", "list_id", 1);
1661 generic_fix(sq2, show_mem_user, "Delete", del_mem_user, 1);
1662 generic_fix(sq3, show_mem_list, "Delete", del_mem_list, 1);
1663 generic_fix(sq4, show_mem_str, "Delete", del_mem_str, 1);
1664 generic_fix(sq5, show_mem_krb, "Delete", del_mem_krb, 1);
1666 dprintf("Checking servers...\n");
1669 EXEC SQL DECLARE csr224 CURSOR FOR
1670 SELECT name, acl_type, acl_id, modby FROM servers
1671 FOR DEFERRED UPDATE of modby;
1672 if (sqlca.sqlcode != 0) ingerr(&sqlca.sqlcode);
1673 EXEC SQL OPEN csr224;
1675 EXEC SQL FETCH csr224 INTO :name, :type, :id1, :id2;
1676 if (sqlca.sqlcode != 0) {
1677 ingerr(&sqlca.sqlcode);
1681 maybe_fixup_modby2("servers","modby","csr224",id2);
1683 if (!strcmp(type, "USER") && !hash_lookup(users, id1)) {
1684 sq_save_data(sq1, id1);
1685 } else if (!strcmp(type, "LIST") && !hash_lookup(lists, id1)) {
1686 sq_save_data(sq2, id1);
1689 EXEC SQL CLOSE csr224;
1690 generic_fix(sq1, show_srv_user, "Fix", zero_srv_user, 1);
1691 generic_fix(sq2, show_srv_list, "Fix", zero_srv_list, 1);
1693 dprintf("Checking serverhosts...\n");
1695 EXEC SQL DECLARE csr225 CURSOR FOR
1696 SELECT mach_id, modby FROM serverhosts
1697 FOR DEFERRED UPDATE OF modby;
1698 if (sqlca.sqlcode != 0) ingerr(&sqlca.sqlcode);
1699 EXEC SQL OPEN csr225;
1701 EXEC SQL FETCH csr225 INTO :id1, :id2;
1702 if (sqlca.sqlcode != 0) {
1703 ingerr(&sqlca.sqlcode);
1707 maybe_fixup_modby2("serverhosts", "modby", "csr225", id2);
1708 if (!hash_lookup(machines, id1))
1709 sq_save_data(sq, id1);
1711 EXEC SQL CLOSE csr225;
1712 generic_fix(sq, show_sh, "Delete", del_sh_mach, 0);
1714 dprintf("Checking nfsphys...\n");
1715 hash_step(nfsphys, check_nfsphys, NULL);
1717 dprintf("Checking filesys...\n");
1718 hash_step(filesys, check_fs, NULL);
1720 dprintf("Checking filesystem groups...\n");
1724 EXEC SQL DECLARE csr226 CURSOR FOR
1725 SELECT group_id, filsys_id FROM fsgroup;
1726 if (sqlca.sqlcode != 0) ingerr(&sqlca.sqlcode);
1727 EXEC SQL OPEN csr226;
1729 EXEC SQL FETCH csr226 INTO :id1, :id2;
1730 if (sqlca.sqlcode != 0) {
1731 ingerr(&sqlca.sqlcode);
1735 if (!(f = (struct filesys *) hash_lookup(filesys, id1)))
1736 sq_save_data(sq1, id1);
1737 if (!hash_lookup(filesys, id2))
1738 sq_save_data(sq3, id2);
1740 EXEC SQL CLOSE csr226;
1741 generic_delete(sq1, show_fsg_missing, "fsgroup", "group_id", 0);
1742 generic_delete(sq3, show_fsg_nomember, "fsgroup", "filsys_id", 1);
1744 dprintf("Checking quotas...\n");
1749 EXEC SQL DECLARE csr227 CURSOR FOR
1750 SELECT entity_id, type, filsys_id, phys_id, quota, modby
1751 FROM quota FOR DEFERRED UPDATE OF modby;
1752 if (sqlca.sqlcode != 0) ingerr(&sqlca.sqlcode);
1753 EXEC SQL OPEN csr227;
1755 EXEC SQL FETCH csr227 INTO :id1, :type, :id2, :id3, :id4, :id5;
1756 if (sqlca.sqlcode != 0) {
1757 ingerr(&sqlca.sqlcode);
1761 maybe_fixup_modby2("quota", "modby", "csr227", id5);
1762 if (type[0] == 'U' && id1 != 0 && !hash_lookup(users, id1))
1763 sq_save_data(sq1, id1);
1764 else if (type[0] == 'G' && !hash_lookup(lists, id1))
1765 sq_save_data(sq4, id1);
1766 else if (!(f = (struct filesys *) hash_lookup(filesys, id2)))
1767 sq_save_data(sq2, id2);
1768 else if (id3 != f->phys_id ||
1769 ((n = (struct nfsphys*) hash_lookup(nfsphys, id3)) ==
1770 (struct nfsphys *)NULL))
1771 sq_save_data(sq3, id2);
1775 EXEC SQL CLOSE csr227;
1776 generic_fix(sq1, show_quota_nouser, "Delete", fix_quota_nouser, 1);
1777 generic_fix(sq2, show_quota_nofs, "Delete", fix_quota_nofs, 0);
1778 generic_fix(sq3, show_quota_wrongpid, "Fix", fix_quota_physid, 1);
1779 generic_fix(sq4, show_quota_nolist, "Delete", fix_quota_nolist, 1);
1781 dprintf("Not checking zephyr.\n");
1783 dprintf("Checking hostaccess...\n");
1784 EXEC SQL DECLARE csr228 CURSOR FOR
1785 SELECT mach_id, acl_type, acl_id, modby FROM hostaccess
1786 FOR DEFERRED UPDATE OF modby;
1787 if (sqlca.sqlcode != 0) ingerr(&sqlca.sqlcode);
1788 EXEC SQL OPEN csr228;
1790 EXEC SQL FETCH csr228 INTO :id1, :type, :id2, :id3;
1791 if (sqlca.sqlcode != 0) {
1792 ingerr(&sqlca.sqlcode);
1796 maybe_fixup_modby2("hostaccess", "modby", "csr228", id3);
1798 if (!hash_lookup(machines, id1)) {
1799 printf("Hostaccess for non-existant host %d\n", id1);
1800 printf("Not fixing this error\n");
1802 if (!strcmp(type, "USER") && !hash_lookup(users, id2)) {
1803 printf("Hostaccess for %d is non-existant user %d\n", id1, id2);
1804 printf("Not fixing this error\n");
1805 } else if (!strcmp(type, "LIST") && !hash_lookup(lists, id2)) {
1806 printf("Hostaccess for %d is non-existant list %d\n", id1, id2);
1807 printf("Not fixing this error\n");
1810 EXEC SQL CLOSE csr228;
1812 dprintf("Checking palladium...\n");
1814 EXEC SQL DECLARE csr229 CURSOR FOR
1815 SELECT mach_id, modby FROM palladium
1816 FOR DEFERRED UPDATE OF modby;
1817 if (sqlca.sqlcode != 0) ingerr(&sqlca.sqlcode);
1818 EXEC SQL OPEN csr229;
1820 EXEC SQL FETCH csr229 INTO :id1, :id2;
1821 if (sqlca.sqlcode != 0) {
1822 ingerr(&sqlca.sqlcode);
1826 maybe_fixup_modby2("palladium", "modby", "csr229", id2);
1827 if (!hash_lookup(machines, id1)) {
1828 sq_save_unique_data(sq1, id1);
1831 EXEC SQL CLOSE csr229;
1832 generic_delete(sq1, show_pdm_mach, "palladium", "mach_id", 1);
1834 dprintf("Checking krbmap...\n");
1837 EXEC SQL DECLARE csr230 CURSOR FOR
1838 SELECT users_id, string_id FROM krbmap
1839 FOR DEFERRED UPDATE OF string_id;
1840 if (sqlca.sqlcode != 0) ingerr(&sqlca.sqlcode);
1841 EXEC SQL OPEN csr230;
1843 EXEC SQL FETCH csr230 INTO :id1, :id2;
1844 if (sqlca.sqlcode != 0) {
1845 ingerr(&sqlca.sqlcode);
1849 if (!hash_lookup(users, id1))
1850 sq_save_unique_data(sq1, id1);
1851 else if (!maybe_fixup_unref_string2("krbmap","string_id","csr230",id2))
1852 sq_save_unique_data(sq2, id2);
1854 EXEC SQL CLOSE csr230;
1855 generic_delete(sq1, show_krb_usr, "krbmap", "users_id", 1);
1856 generic_delete(sq2, show_krb_str, "krbmap", "string_id", 1);
1858 dprintf("Checking capacls...\n");
1859 EXEC SQL DECLARE csr231 CURSOR FOR
1860 SELECT list_id, tag FROM capacls;
1861 if (sqlca.sqlcode != 0) ingerr(&sqlca.sqlcode);
1862 EXEC SQL OPEN csr231;
1864 EXEC SQL FETCH csr231 INTO :id1, :name;
1865 if (sqlca.sqlcode != 0) {
1866 ingerr(&sqlca.sqlcode);
1870 if (!hash_lookup(lists, id1)) {
1871 printf("Capacl for %s is non-existant list %d\n", name, id1);
1872 printf("Not fixing this error\n");
1875 EXEC SQL CLOSE csr231;
1877 dprintf("Checking hostaliases\n");
1879 EXEC SQL DECLARE csr232 CURSOR FOR
1880 SELECT mach_id FROM hostalias;
1881 if (sqlca.sqlcode != 0) ingerr(&sqlca.sqlcode);
1882 EXEC SQL OPEN csr232;
1884 EXEC SQL FETCH csr232 INTO :id1;
1885 if (sqlca.sqlcode != 0) {
1886 ingerr(&sqlca.sqlcode);
1890 if (!hash_lookup(machines, id1))
1891 sq_save_unique_data(sq1, id1);
1893 EXEC SQL CLOSE csr232;
1894 generic_delete(sq1, show_hostalias, "hostalias", "mach_id", 1);
1896 dprintf("Checking printcaps\n");
1899 EXEC SQL DECLARE csr233 CURSOR FOR
1900 SELECT mach_id, quotaserver, modby FROM printcap;
1901 if (sqlca.sqlcode != 0) ingerr(&sqlca.sqlcode);
1902 EXEC SQL OPEN csr233;
1904 EXEC SQL FETCH csr233 INTO :id1, :id2, :id3;
1905 if (sqlca.sqlcode != 0) {
1906 ingerr(&sqlca.sqlcode);
1910 maybe_fixup_modby2("printcap", "modby", "csr233", id3);
1911 if (!hash_lookup(machines, id1))
1912 sq_save_unique_data(sq1, id1);
1913 else if(!hash_lookup(machines, id2))
1914 sq_save_unique_data(sq2, id2);
1916 EXEC SQL CLOSE csr233;
1917 generic_delete(sq1, show_pcap_mach, "printcap", "mach_id", 1);
1918 generic_delete(sq2, show_pcap_quota, "printcap", "quotaserver", 1);