3 * (c) Copyright 1988-1998 by the Massachusetts Institute of Technology.
4 * For copying and distribution information, please see the file
8 #include <mit-copyright.h>
16 EXEC SQL INCLUDE sqlca;
20 EXEC SQL WHENEVER SQLERROR DO dbmserr();
22 int show_mcm_mach(void *id);
23 int show_mcm_clu(void *id);
24 int show_hostalias(void *id);
25 int show_pcap_mach(void *id);
26 int show_pcap_quota(void *id);
27 void user_check(int id, void *user, void *hint);
28 int maybe_fixup_unref_string(int sid, int oid, char *oname, char *table,
29 char *field, char *idfield);
30 int maybe_fixup_modby(int sid, int oid, char *oname, char *table,
31 char *field, char *idfield);
32 int maybe_fixup_unref_string2(char *table, char *field, char *cursor, int sid);
33 int maybe_fixup_modby2(char *table, char *field, char *cursor, int id);
34 void pobox_check(int id, struct user *u);
35 void remove_pobox(int id);
36 void fix_smtp_pobox(int id, int sid);
37 void mach_check(int id, void *machine, void *hint);
38 void subnet_check(int id, void *subnet, void *hint);
39 void clear_subnet_owner(struct subnet *s);
40 void clear_mach_owner(struct machine *m);
41 void cluster_check(int id, void *cluster, void *hint);
42 int show_svc(void *id);
43 void list_check(int id, void *list, void *hint);
44 void fix_list_acl(int id);
45 int show_member_list(void *id);
46 int show_mem_user(void *id);
47 int show_mem_list(void *id);
48 int show_mem_str(void *id);
49 int show_mem_krb(void *id);
50 void del_mem_user(void *id);
51 void del_mem_list(void *id);
52 void del_mem_str(void *id);
53 void del_mem_krb(void *id);
54 int show_sh(void *id);
55 void del_sh_mach(void *id);
56 void fsmatch(int id, void *nfsphys, void *filesys);
57 void check_fs(int id, void *filesys, void *hint);
58 void check_nfsphys(int id, void *nfsphys, void *hint);
59 int show_fsg_missing(void *id);
60 int show_fsg_type(void *filesys);
61 void fix_fsg_type(void *filesys);
62 int show_fsg_nomember(void *id);
63 int show_quota_nouser(void *id);
64 int show_quota_nolist(void *id);
65 void fix_quota_nouser(void *id);
66 void fix_quota_nolist(void *id);
67 int show_quota_nofs(void *id);
68 void fix_quota_nofs(void *id);
69 int show_quota_wrongpid(void *id);
70 void fix_quota_physid(void *id);
71 int show_srv_user(void *id);
72 int show_srv_list(void *id);
73 void zero_srv_user(void *id);
74 void zero_srv_list(void *id);
75 int show_krb_usr(void *id);
76 int show_krb_str(void *id);
77 int show_pdm_mach(void *id);
79 int show_mcm_mach(void *id)
81 EXEC SQL BEGIN DECLARE SECTION;
82 int iid = (int)id, found = 1;
83 char name[CLUSTERS_NAME_SIZE];
84 EXEC SQL END DECLARE SECTION;
86 EXEC SQL DECLARE csr201 CURSOR FOR
87 SELECT clusters.name FROM clusters, mcmap
88 WHERE clusters.clu_id = mcmap.clu_id AND mcmap.mach_id = :iid;
92 EXEC SQL FETCH csr201 INTO :name;
98 printf("Cluster %s, non-existant machine %d in cluster map\n",
101 EXEC SQL CLOSE csr201;
105 int show_mcm_clu(void *id)
107 EXEC SQL BEGIN DECLARE SECTION;
108 int iid = (int)id, found = 1;
109 char name[MACHINE_NAME_SIZE];
110 EXEC SQL END DECLARE SECTION;
112 EXEC SQL DECLARE csr202 CURSOR FOR
113 SELECT machine.name FROM machine, mcmap
114 WHERE machine.mach_id = mcmap.mach_id AND mcmap.clu_id = :iid;
115 EXEC SQL OPEN csr202;
118 EXEC SQL FETCH csr202 INTO :name;
125 printf("Machine %s, non-existant cluster %d in cluster map\n",
128 EXEC SQL CLOSE csr202;
132 int show_hostalias(void *id)
134 EXEC SQL BEGIN DECLARE SECTION;
135 int iid = (int)id, found = 1;
136 char name[HOSTALIAS_NAME_SIZE];
137 EXEC SQL END DECLARE SECTION;
139 EXEC SQL DECLARE csr234 CURSOR FOR
140 SELECT name FROM hostalias WHERE mach_id = :iid;
141 EXEC SQL OPEN csr234;
144 EXEC SQL FETCH csr234 INTO :name;
151 printf("Alias %s, non-existant machine %d in hostalias map\n",
154 EXEC SQL CLOSE csr234;
158 int show_pcap_mach(void *id)
160 EXEC SQL BEGIN DECLARE SECTION;
161 int iid = (int)id, found = 1;
162 char name[PRINTCAP_NAME_SIZE];
163 EXEC SQL END DECLARE SECTION;
165 EXEC SQL DECLARE csr235 CURSOR FOR
166 SELECT name FROM printcap WHERE mach_id = :iid;
167 EXEC SQL OPEN csr235;
170 EXEC SQL FETCH csr235 INTO :name;
177 printf("Printer %s, non-existant spool machine %d in printcap table\n",
180 EXEC SQL CLOSE csr235;
184 int show_pcap_quota(void *id)
186 EXEC SQL BEGIN DECLARE SECTION;
187 int iid = (int)id, found = 1;
188 char name[PRINTCAP_NAME_SIZE];
189 EXEC SQL END DECLARE SECTION;
191 EXEC SQL DECLARE csr236 CURSOR FOR
192 SELECT name FROM printcap WHERE quotaserver = :iid;
193 EXEC SQL OPEN csr236;
196 EXEC SQL FETCH csr236 INTO :name;
203 printf("Printer %s, non-existant quota server %d in printcap table\n",
206 EXEC SQL CLOSE csr236;
210 void user_check(int id, void *user, void *hint)
212 struct user *u = user;
214 u->comment = maybe_fixup_unref_string(u->comment, id, u->login, "users",
215 "comments", "users_id");
217 u->modby = maybe_fixup_modby(u->modby, id, u->login, "users",
218 "modby", "users_id");
220 u->fmodby = maybe_fixup_modby(u->fmodby, id, u->login, "users",
221 "fmodby", "users_id");
223 u->pmodby = maybe_fixup_modby(u->pmodby, id, u->login, "users",
224 "pmodby", "users_id");
226 u->sigwho = maybe_fixup_unref_string(u->sigwho, id, u->login, "users",
227 "sigwho", "users_id");
232 int maybe_fixup_unref_string(int sid, int oid, char *oname, char *table,
233 char *field, char *idfield)
235 int ret = (sid < 0) ? -sid : sid, doit = 0, newid;
236 EXEC SQL BEGIN DECLARE SECTION;
239 EXEC SQL END DECLARE SECTION;
241 if ((newid = (int)hash_lookup(string_dups, ret)))
243 printf("%s entry %s(%d) has a %s with duplicate string %d\n",
244 table, oname, oid, field, ret);
245 if (single_fix("Replace duplicate", 0))
252 else if (!string_check(ret))
254 printf("%s entry %s(%d) has a %s with non-existant string %d\n",
255 table, oname, oid, field, ret);
256 if (single_fix("Delete", 1))
265 sprintf(stmt_buf, "UPDATE %s SET %s = %d WHERE %s = %d",
266 table, field, (sid < 0) ? -ret : ret, idfield, oid);
267 EXEC SQL EXECUTE IMMEDIATE :stmt_buf;
268 rowcount = sqlca.sqlerrd[2];
272 printf("Not fixed, rowcount = %d\n", rowcount);
276 return (sid < 0) ? -ret : ret;
279 int maybe_fixup_modby(int sid, int oid, char *oname, char *table,
280 char *field, char *idfield)
282 EXEC SQL BEGIN DECLARE SECTION;
285 EXEC SQL END DECLARE SECTION;
288 return maybe_fixup_unref_string(sid, oid, oname, table, field, idfield);
291 if (!hash_lookup(users, sid))
293 printf("%s entry %s(%d) has a %s with non-existant user %d\n",
294 table, oname, oid, field, sid);
295 if (single_fix("Delete", 1))
297 sprintf(stmt_buf, "UPDATE %s SET %s = 0 WHERE %s = %d",
298 table, field, idfield, oid);
299 EXEC SQL EXECUTE IMMEDIATE :stmt_buf;
300 rowcount = sqlca.sqlerrd[2];
304 printf("Not fixed, rowcount = %d\n", rowcount);
313 int maybe_fixup_unref_string2(char *table, char *field, char *cursor, int sid)
315 int ret = (sid < 0) ? -sid : sid, doit = 0, newid;
316 EXEC SQL BEGIN DECLARE SECTION;
319 EXEC SQL END DECLARE SECTION;
321 if ((newid = (int)hash_lookup(string_dups, ret)))
323 printf("%s entry has a %s with duplicate string %d\n",
325 if (single_fix("Replace duplicate", 0))
332 else if (!string_check(ret))
334 printf("%s entry has a %s with non-existant string %d\n",
336 if (single_fix("Delete", 1))
345 sprintf(stmt_buf, "UPDATE %s SET %s = %d WHERE CURRENT OF %s",
346 table, field, (sid < 0) ? -ret : ret, cursor);
347 EXEC SQL EXECUTE IMMEDIATE :stmt_buf;
348 rowcount = sqlca.sqlerrd[2];
352 printf("Not fixed, rowcount = %d\n", rowcount);
355 return (sid < 0) ? -ret : ret;
358 int maybe_fixup_modby2(char *table, char *field, char *cursor, int id)
360 EXEC SQL BEGIN DECLARE SECTION;
363 EXEC SQL END DECLARE SECTION;
366 return maybe_fixup_unref_string2(table, field, cursor, id);
369 if (!hash_lookup(users, id))
371 printf("%s entry has a %s with non-existant user %d\n",
373 if (single_fix("Delete", 1))
375 sprintf(stmt_buf, "UPDATE %s SET %s = 0 WHERE CURRENT OF %s",
376 table, field, cursor);
377 EXEC SQL EXECUTE IMMEDIATE :stmt_buf;
378 rowcount = sqlca.sqlerrd[2];
382 printf("Not fixed, rowcount = %d\n", rowcount);
391 void pobox_check(int id, struct user *u)
396 if (!hash_lookup(machines, u->pobox_id))
398 printf("User %s(%s) has P.O.Box on non-existant machine %d\n",
399 u->login, u->fullname, u->pobox_id);
400 if (single_fix("Delete", 0))
402 remove_pobox(u->users_id);
408 if (hash_lookup(string_dups, u->pobox_id))
410 printf("User %s(%s) has P.O.Box with duplicate string %d\n",
411 u->login, u->fullname, u->pobox_id);
412 if (single_fix("Update", 0))
414 printf("Replacing box_id dup string ID %d with %d\n",
416 (int)hash_lookup(string_dups, u->pobox_id));
417 u->pobox_id = (int)hash_lookup(string_dups, u->pobox_id);
418 fix_smtp_pobox(u->users_id, u->pobox_id);
419 string_check(u->pobox_id);
422 else if (!string_check(u->pobox_id))
424 printf("User %s(%s) has P.O.Box with non-existant string %d\n",
425 u->login, u->fullname, u->pobox_id);
426 if (single_fix("Delete", 0))
428 remove_pobox(u->users_id);
439 void remove_pobox(int id)
441 EXEC SQL BEGIN DECLARE SECTION;
442 int rowcount, iid = (int)id;
443 EXEC SQL END DECLARE SECTION;
445 EXEC SQL UPDATE users SET potype = 'NONE' WHERE users.users_id = :iid;
446 rowcount = sqlca.sqlerrd[2];
448 printf("%d entr%s removed\n", rowcount, rowcount == 1 ? "y" : "ies");
450 printf("Not removed\n");
454 void fix_smtp_pobox(int id, int sid)
456 EXEC SQL BEGIN DECLARE SECTION;
457 int rowcount, iid = id, isid = sid;
458 EXEC SQL END DECLARE SECTION;
460 EXEC SQL UPDATE users SET box_id = :isid WHERE users.users_id = :iid;
461 rowcount = sqlca.sqlerrd[2];
463 printf("%d entr%s updated\n", rowcount, rowcount == 1 ? "y" : "ies");
465 printf("Not updated\n");
469 void mach_check(int id, void *machine, void *hint)
471 struct machine *m = machine;
473 if (!hash_lookup(subnets, m->snet_id))
475 printf("Machine %s is on a non-existant subnet %d\n",
476 m->name, m->snet_id);
477 if (single_fix("Move to null-subnet", 1))
479 EXEC SQL BEGIN DECLARE SECTION;
480 int rowcount, iid = id;
481 EXEC SQL END DECLARE SECTION;
483 EXEC SQL UPDATE machine SET snet_id = 0 WHERE mach_id = :iid;
484 rowcount = sqlca.sqlerrd[2];
486 printf("%d entr%s fixed\n", rowcount, rowcount == 1 ? "y" : "ies");
488 printf("Not fixed\n");
493 switch (m->owner_type)
496 if (!hash_lookup(users, m->owner_id))
498 printf("Machine %s has non-existant USER owner %d\n",
499 m->name, m->owner_id);
500 if (single_fix("Set to no owner", 1))
505 if (!hash_lookup(lists, m->owner_id))
507 printf("Machine %s has non-existant LIST owner %d\n",
508 m->name, m->owner_id);
509 if (single_fix("Set to no owner", 1))
516 m->owner_id = maybe_fixup_unref_string(m->owner_id, id, m->name,
517 "machine", "owner_id",
519 if (m->owner_id == 0)
524 m->acomment = maybe_fixup_unref_string(m->acomment, id, m->name,
525 "machine", "acomment", "mach_id");
527 m->ocomment = maybe_fixup_unref_string(m->ocomment, id, m->name,
528 "machine", "ocomment", "mach_id");
530 m->creator = maybe_fixup_modby(m->creator, id, m->name, "machine",
531 "creator", "mach_id");
532 m->modby = maybe_fixup_modby(m->modby, id, m->name, "machine",
536 void subnet_check(int id, void *subnet, void *hint)
538 struct subnet *s = subnet;
540 switch (s->owner_type)
543 if (!hash_lookup(users, s->owner_id))
545 printf("Subnet %s has non-existant USER owner %d\n",
546 s->name, s->owner_id);
547 if (single_fix("Set to no owner", 1))
548 clear_subnet_owner(s);
552 if (!hash_lookup(lists, s->owner_id))
554 printf("Machine %s has non-existant LIST owner %d\n",
555 s->name, s->owner_id);
556 if (single_fix("Set to no owner", 1))
557 clear_subnet_owner(s);
563 s->owner_id = maybe_fixup_unref_string(s->owner_id, id, s->name,
564 "machine", "owner_id",
566 if (s->owner_id == 0)
567 clear_subnet_owner(s);
570 s->modby = maybe_fixup_modby(s->modby, id, s->name, "subnet",
574 void clear_subnet_owner(struct subnet *s)
576 EXEC SQL BEGIN DECLARE SECTION;
577 int rowcount, id = s->snet_id;
578 EXEC SQL END DECLARE SECTION;
580 EXEC SQL UPDATE subnet SET owner_type = 'NONE', owner_id = 0
582 rowcount = sqlca.sqlerrd[2];
584 printf("%d entr%s fixed\n", rowcount, rowcount == 1 ? "y" : "ies");
586 printf("Not fixed\n");
590 void clear_mach_owner(struct machine *m)
592 EXEC SQL BEGIN DECLARE SECTION;
593 int rowcount, id = m->mach_id;
594 EXEC SQL END DECLARE SECTION;
596 EXEC SQL UPDATE machine SET owner_type = 'NONE', owner_id = 0
598 rowcount = sqlca.sqlerrd[2];
600 printf("%d entr%s fixed\n", rowcount, rowcount == 1 ? "y" : "ies");
602 printf("Not fixed\n");
606 void cluster_check(int id, void *cluster, void *hint)
608 struct cluster *c = cluster;
610 c->modby = maybe_fixup_modby(c->modby, id, c->name, "clusters",
614 int show_svc(void *id)
616 EXEC SQL BEGIN DECLARE SECTION;
617 int iid = (int)id, found = 1;
618 char label[SVC_SERV_LABEL_SIZE], data[SVC_SERV_CLUSTER_SIZE];
619 EXEC SQL END DECLARE SECTION;
621 EXEC SQL DECLARE csr203 CURSOR FOR
622 SELECT serv_label, serv_cluster FROM svc
624 EXEC SQL OPEN csr203;
627 EXEC SQL FETCH csr203 INTO :label, :data;
634 printf("Cluster data [%s] %s for non-existant cluster %d\n",
637 EXEC SQL CLOSE csr203;
641 void list_check(int id, void *list, void *hint)
643 struct list *l = list;
645 l->modby = maybe_fixup_modby(l->modby, id, l->name, "list",
651 if (!hash_lookup(lists, l->acl_id))
653 printf("List %s has bad LIST acl %d\n", l->name, l->acl_id);
654 if (single_fix("Patch", 1))
655 fix_list_acl(l->list_id);
659 if (!hash_lookup(users, l->acl_id))
661 printf("List %s has bad USER acl %d\n", l->name, l->acl_id);
662 if (single_fix("Patch", 1))
663 fix_list_acl(l->list_id);
667 l->acl_id = maybe_fixup_unref_string(l->acl_id, id, l->name,
668 "list", "acl_id", "list_id");
671 printf("List %s has bad KERBEROS acl %d\n", l->name, l->acl_id);
672 if (single_fix("Patch", 1))
673 fix_list_acl(l->list_id);
679 void fix_list_acl(int id)
681 EXEC SQL BEGIN DECLARE SECTION;
682 int rowcount, iid = (int)id;
683 EXEC SQL END DECLARE SECTION;
685 EXEC SQL UPDATE list SET acl_id = :iid, acl_type = 'LIST'
686 WHERE list_id = :iid;
687 rowcount = sqlca.sqlerrd[2];
689 printf("%d entr%s fixed\n", rowcount, rowcount == 1 ? "y" : "ies");
691 printf("Not fixed\n");
695 int show_member_list(void *id)
697 EXEC SQL BEGIN DECLARE SECTION;
698 int mid, iid = (int)id, found = 1;
699 char mtype[IMEMBERS_MEMBER_TYPE_SIZE], *name = NULL;
700 EXEC SQL END DECLARE SECTION;
702 EXEC SQL DECLARE csr204 CURSOR FOR
703 SELECT member_type, member_id FROM imembers
704 WHERE list_id = :iid;
705 EXEC SQL OPEN csr204;
708 EXEC SQL FETCH csr204 INTO :mtype, :mid;
716 struct list *l = hash_lookup(lists, mid);
720 else if (mtype[0] == 'U')
722 struct user *u = hash_lookup(users, mid);
726 else if (mtype[0] == 'S' || mtype[0] == 'K')
728 struct string *s = hash_lookup(strings, mid);
733 printf("Non-existant list %d has member %s %s\n", iid, mtype, name);
736 printf("Non-existant list %d has non-existent member %s %d\n",
740 EXEC SQL CLOSE csr204;
744 int show_mem_user(void *id)
746 EXEC SQL BEGIN DECLARE SECTION;
747 int lid, iid = (int)id, found = 1;
748 EXEC SQL END DECLARE SECTION;
751 EXEC SQL DECLARE csr205 CURSOR FOR
752 SELECT list_id FROM imembers
753 WHERE member_id = :iid AND member_type = 'USER';
754 EXEC SQL OPEN csr205;
757 EXEC SQL FETCH csr205 INTO :lid;
760 l = hash_lookup(lists, lid);
765 printf("List %s has non-existant user member, id %d\n", l->name, iid);
767 EXEC SQL CLOSE csr205;
771 int show_mem_list(void *id)
773 EXEC SQL BEGIN DECLARE SECTION;
774 int lid, iid = (int)id, found = 1;
775 EXEC SQL END DECLARE SECTION;
778 EXEC SQL DECLARE csr206 CURSOR FOR
779 SELECT list_id FROM imembers
780 WHERE member_id = :iid AND member_type = 'LIST';
781 EXEC SQL OPEN csr206;
784 EXEC SQL FETCH csr206 INTO :lid;
787 l = hash_lookup(lists, lid);
792 printf("List %s has non-existant list member, id %d\n", l->name, iid);
794 EXEC SQL CLOSE csr206;
798 int show_mem_str(void *id)
800 EXEC SQL BEGIN DECLARE SECTION;
801 int lid, iid = (int)id, found = 1;
802 EXEC SQL END DECLARE SECTION;
805 EXEC SQL DECLARE csr207 CURSOR FOR
806 SELECT list_id FROM imembers
807 WHERE member_id = :iid AND member_type = 'STRING';
808 EXEC SQL OPEN csr207;
811 EXEC SQL FETCH csr207 INTO :lid;
814 l = hash_lookup(lists, lid);
819 printf("List %s has non-existant string member, id %d\n", l->name, iid);
821 EXEC SQL CLOSE csr207;
826 int show_mem_krb(void *id)
828 EXEC SQL BEGIN DECLARE SECTION;
829 int lid, iid = (int)id, found = 1;
830 EXEC SQL END DECLARE SECTION;
833 EXEC SQL DECLARE csr208 CURSOR FOR
834 SELECT list_id FROM imembers
835 WHERE member_id = :iid AND member_type = 'KERBEROS';
836 EXEC SQL OPEN csr208;
839 EXEC SQL FETCH csr208 INTO :lid;
842 l = hash_lookup(lists, lid);
847 printf("List %s has non-existant kerberos member, id %d\n",
850 EXEC SQL CLOSE csr208;
855 void del_mem_user(void *id)
857 EXEC SQL BEGIN DECLARE SECTION;
858 int iid = (int)id, rowcount;
859 EXEC SQL END DECLARE SECTION;
861 EXEC SQL DELETE FROM imembers WHERE member_type = 'USER' AND
863 rowcount = sqlca.sqlerrd[2];
865 printf("%d entr%s deleted\n", rowcount, rowcount == 1 ? "y" : "ies");
867 printf("Not deleted\n");
868 modified("imembers");
871 void del_mem_list(void *id)
873 EXEC SQL BEGIN DECLARE SECTION;
874 int iid = (int)id, rowcount;
875 EXEC SQL END DECLARE SECTION;
877 EXEC SQL DELETE FROM imembers WHERE member_type = 'LIST' AND
879 rowcount = sqlca.sqlerrd[2];
881 printf("%d entr%s deleted\n", rowcount, rowcount == 1 ? "y" : "ies");
883 printf("Not deleted\n");
884 modified("imembers");
887 void del_mem_str(void *id)
889 EXEC SQL BEGIN DECLARE SECTION;
890 int iid = (int)id, rowcount;
891 EXEC SQL END DECLARE SECTION;
893 EXEC SQL DELETE FROM imembers WHERE member_type = 'STRING' AND
895 rowcount = sqlca.sqlerrd[2];
897 printf("%d entr%s deleted\n", rowcount, rowcount == 1 ? "y" : "ies");
899 printf("Not deleted\n");
900 modified("imembers");
904 void del_mem_krb(void *id)
906 EXEC SQL BEGIN DECLARE SECTION;
907 int iid = (int)id, rowcount;
908 EXEC SQL END DECLARE SECTION;
910 EXEC SQL DELETE FROM imembers WHERE member_type = 'KERBEROS' AND
912 rowcount = sqlca.sqlerrd[2];
914 printf("%d entr%s deleted\n", rowcount, rowcount == 1 ? "y" : "ies");
916 printf("Not deleted\n");
917 modified("imembers");
921 int show_sh(void *id)
923 EXEC SQL BEGIN DECLARE SECTION;
924 char name[SERVERHOSTS_SERVICE_SIZE];
926 EXEC SQL END DECLARE SECTION;
929 EXEC SQL DECLARE csr209 CURSOR FOR
930 SELECT service FROM serverhosts
931 WHERE mach_id = :iid;
932 EXEC SQL OPEN csr209;
935 EXEC SQL FETCH csr209 INTO :name;
940 printf("ServerHost entry for service %s non-existant host %d\n",
943 EXEC SQL CLOSE csr209;
947 void del_sh_mach(void *id)
949 EXEC SQL BEGIN DECLARE SECTION;
950 int iid = (int)id, rowcount;
951 EXEC SQL END DECLARE SECTION;
953 EXEC SQL DELETE FROM serverhosts WHERE mach_id = :iid;
954 rowcount = sqlca.sqlerrd[2];
956 printf("%d entr%s deleted\n", rowcount, rowcount == 1 ? "y" : "ies");
958 printf("Not deleted\n");
959 modified("serverhosts");
963 static int fnchecklen;
965 void fsmatch(int id, void *nfsphys, void *filesys)
967 struct nfsphys *n = nfsphys;
968 struct filesys *f = filesys;
970 if (n->mach_id == f->mach_id &&
971 !strncmp(f->dir, n->dir, strlen(n->dir)) &&
972 strlen(n->dir) > fnchecklen)
975 fnchecklen = strlen(n->dir);
980 void check_fs(int id, void *filesys, void *hint)
982 EXEC SQL BEGIN DECLARE SECTION;
983 int iid = id, id1, id2, id3, rowcount;
985 EXEC SQL END DECLARE SECTION;
986 struct filesys *f = filesys;
990 if (!hash_lookup(machines, f->mach_id))
992 printf("Filesys %s with bad machine %d\n", f->name, f->mach_id);
993 if (single_fix("Fix", 0))
995 EXEC SQL UPDATE filesys SET mach_id = 0 WHERE filsys_id = :iid;
996 rowcount = sqlca.sqlerrd[2];
998 printf("%d entr%s fixed\n", rowcount, rowcount == 1 ? "y" : "ies");
1000 printf("Not fixed\n");
1001 modified("filesys");
1006 if (!hash_lookup(users, f->owner))
1008 printf("Filesys %s with bad owning user %d\n", f->name, f->owner);
1009 if (single_fix("Fix", 1))
1011 zero_fix("filesys", "owner", "filsys_id", f->filsys_id);
1015 if (!hash_lookup(lists, f->owners))
1017 printf("Filesys %s with bad owning group %d\n", f->name, f->owners);
1018 if (single_fix("Fix", 1))
1020 zero_fix("filesys", "owners", "filsys_id", f->filsys_id);
1027 if (!hash_lookup(nfsphys, f->phys_id))
1029 m = hash_lookup(machines, f->mach_id);
1030 printf("Filesys %s with bad phys_id %d\n", f->name, f->phys_id);
1031 if (single_fix("Fix", 1))
1034 hash_step(nfsphys, fsmatch, f);
1035 if (fnchecklen != 0)
1040 EXEC SQL UPDATE filesys SET phys_id = :id1
1041 WHERE filsys_id = :id2;
1042 rowcount = sqlca.sqlerrd[2];
1044 printf("%d entr%s fixed\n", rowcount,
1045 rowcount == 1 ? "y" : "ies");
1047 printf("Not fixed\n");
1048 modified("filesys");
1052 printf("No NFSphys exsits for %s:%s\n", m->name, f->dir);
1053 if (single_fix("Create", 0))
1059 if (set_next_object_id("nfsphys_id", "nfsphys") !=
1062 printf("Unable to assign unique ID\n");
1065 EXEC SQL SELECT COUNT(*) INTO :rowcount FROM numvalues
1066 WHERE name = 'nfsphys_id';
1069 printf("Unable to retrieve unique ID\n");
1072 EXEC SQL INSERT INTO nfsphys
1073 (nfsphys_id, mach_id, device, dir, status, allocated,
1074 size, modtime, modby, modwith) VALUES
1075 (:id1, :id3, '\?\?\?', :dir, 0, 0, 0, SYSDATE, 0,
1077 rowcount = sqlca.sqlerrd[2];
1080 printf("%d entr%s created\n", rowcount,
1081 rowcount == 1 ? "y" : "ies");
1084 printf("Not created\n");
1085 modified("nfsphys");
1086 n = malloc(sizeof(struct nfsphys));
1088 out_of_mem("storing new nfsphys");
1089 strcpy(n->dir, dir);
1091 n->nfsphys_id = id1;
1094 if (hash_store(nfsphys, id1, n) == -1)
1095 out_of_mem("storing nfsphys in hash table");
1096 EXEC SQL UPDATE filesys SET phys_id = :id1
1097 WHERE filsys_id = :id2;
1098 rowcount = sqlca.sqlerrd[2];
1101 printf("%d filesys entr%s fixed\n", rowcount,
1102 rowcount == 1 ? "y" : "ies");
1105 printf("Not fixed\n");
1106 modified("filesys");
1114 void check_nfsphys(int id, void *nfsphys, void *hint)
1116 struct nfsphys *n = nfsphys;
1118 n->modby = maybe_fixup_modby(n->modby, id, n->dir, "nfsphys",
1119 "modby", "nfsphys_id");
1121 if (!hash_lookup(machines, n->mach_id))
1123 printf("NFSphys %d(%s) on non-existant machine %d\n",
1124 id, n->dir, n->mach_id);
1125 if (single_fix("Delete", 0))
1126 single_delete("nfsphys", "nfsphys_id", id);
1130 int show_fsg_missing(void *id)
1132 EXEC SQL BEGIN DECLARE SECTION;
1133 int iid = (int)id, id1, found = 1;
1134 EXEC SQL END DECLARE SECTION;
1137 EXEC SQL DECLARE csr210 CURSOR FOR
1138 SELECT filsys_id FROM fsgroup
1139 WHERE group_id = :iid;
1140 EXEC SQL OPEN csr210;
1143 EXEC SQL FETCH csr210 INTO :id1;
1148 if ((f = hash_lookup(filesys, id1)))
1149 printf("Missing fsgroup %d has member filesystem %s\n", iid, f->name);
1151 printf("Missing fsgroup %d has member filesystem %d\n", iid, id1);
1153 EXEC SQL CLOSE csr210;
1157 int show_fsg_type(void *filesys)
1159 struct filesys *f = filesys;
1185 printf("FSGroup %s has type %s instead of FSGROUP\n", f->name, t);
1189 void fix_fsg_type(void *filesys)
1191 struct filesys *f = filesys;
1192 EXEC SQL BEGIN DECLARE SECTION;
1193 int rowcount, id = f->filsys_id;
1194 EXEC SQL END DECLARE SECTION;
1196 EXEC SQL UPDATE filesys SET type = 'FSGROUP' WHERE filsys_id = :id;
1197 rowcount = sqlca.sqlerrd[2];
1199 printf("%d entr%s fixed\n", rowcount, rowcount == 1 ? "y" : "ies");
1201 printf("Not fixed\n");
1202 modified("filesys");
1205 int show_fsg_nomember(void *id)
1207 EXEC SQL BEGIN DECLARE SECTION;
1208 int iid = (int)id, id1, found = 1;
1209 EXEC SQL END DECLARE SECTION;
1212 EXEC SQL DECLARE csr211 CURSOR FOR
1213 SELECT group_id FROM fsgroup
1214 WHERE filsys_id = :iid;
1215 EXEC SQL OPEN csr211;
1218 EXEC SQL FETCH csr211 INTO :id1;
1223 if ((f = hash_lookup(filesys, id1)))
1224 printf("FSGroup %s has missing member %d\n", f->name, iid);
1226 printf("FSGroup %d has missing member %d\n", id1, iid);
1228 EXEC SQL CLOSE csr211;
1232 int show_quota_nouser(void *id)
1234 EXEC SQL BEGIN DECLARE SECTION;
1235 int iid = (int)id, id1, found = 1;
1236 EXEC SQL END DECLARE SECTION;
1238 EXEC SQL DECLARE csr212 CURSOR FOR
1239 SELECT filsys_id FROM quota
1240 WHERE entity_id = :iid AND type = 'USER';
1241 EXEC SQL OPEN csr212;
1244 EXEC SQL FETCH csr212 INTO :id1;
1249 printf("Quota on fs %d for non-existant user %d\n", id1, iid);
1251 EXEC SQL CLOSE csr212;
1255 int show_quota_nolist(void *id)
1257 EXEC SQL BEGIN DECLARE SECTION;
1258 int iid = (int)id, id1, found = 1;
1259 EXEC SQL END DECLARE SECTION;
1261 EXEC SQL DECLARE csr213 CURSOR FOR
1262 SELECT filsys_id FROM quota
1263 WHERE entity_id = :iid AND type = 'GROUP';
1264 EXEC SQL OPEN csr213;
1267 EXEC SQL FETCH csr213 INTO :id1;
1272 printf("Quota on fs %d for non-existant list %d\n", id1, iid);
1274 EXEC SQL CLOSE csr213;
1278 void fix_quota_nouser(void *id)
1280 EXEC SQL BEGIN DECLARE SECTION;
1281 int iid = (int)id, rowcount, id1;
1282 EXEC SQL END DECLARE SECTION;
1284 id1 = ((struct filesys *)hash_lookup(filesys, iid))->phys_id;
1285 EXEC SQL DELETE FROM quota
1286 WHERE entity_id = :iid AND type = 'USER';
1287 rowcount = sqlca.sqlerrd[2];
1289 printf("%d entr%s deleted\n", rowcount, rowcount == 1 ? "y" : "ies");
1291 printf("Not deleted\n");
1295 void fix_quota_nolist(void *id)
1297 EXEC SQL BEGIN DECLARE SECTION;
1298 int iid = (int)id, rowcount, id1;
1299 EXEC SQL END DECLARE SECTION;
1301 id1 = ((struct filesys *)hash_lookup(filesys, iid))->phys_id;
1302 EXEC SQL DELETE FROM quota WHERE entity_id = :iid AND type = 'GROUP';
1303 rowcount = sqlca.sqlerrd[2];
1305 printf("%d entr%s deleted\n", rowcount, rowcount == 1 ? "y" : "ies");
1307 printf("Not deleted\n");
1311 int show_quota_nofs(void *id)
1313 EXEC SQL BEGIN DECLARE SECTION;
1314 int iid = (int)id, id1, found = 1;
1315 char type[QUOTA_TYPE_SIZE];
1316 EXEC SQL END DECLARE SECTION;
1318 EXEC SQL DECLARE csr214 CURSOR FOR
1319 SELECT entity_id, type FROM quota
1320 WHERE filsys_id = :iid;
1321 EXEC SQL OPEN csr214;
1324 EXEC SQL FETCH csr214 INTO :id1, :type;
1329 printf("Quota for %s %d on non-existant filesys %d\n", type, id1, iid);
1331 EXEC SQL CLOSE csr214;
1335 void fix_quota_nofs(void *id)
1337 single_delete("quota", "filsys_id", (int)id);
1340 int show_quota_wrongpid(void *id)
1342 EXEC SQL BEGIN DECLARE SECTION;
1343 int iid = (int)id, id1, found = 1;
1344 char type[QUOTA_TYPE_SIZE];
1345 EXEC SQL END DECLARE SECTION;
1348 f = hash_lookup(filesys, iid);
1349 EXEC SQL DECLARE csr215 CURSOR FOR
1350 SELECT entity_id, type FROM quota
1351 WHERE filsys_id = :iid;
1352 EXEC SQL OPEN csr215;
1355 EXEC SQL FETCH csr215 INTO :id1, :type;
1360 printf("Quota for %s %d on filesys %s has wrong phys_id %d\n",
1361 type, id1, f->name, iid);
1363 EXEC SQL CLOSE csr215;
1367 void fix_quota_physid(void *id)
1369 EXEC SQL BEGIN DECLARE SECTION;
1370 int iid = (int)id, rowcount, id1;
1371 EXEC SQL END DECLARE SECTION;
1373 id1 = ((struct filesys *)hash_lookup(filesys, iid))->phys_id;
1374 EXEC SQL UPDATE quota SET phys_id = :id1
1375 WHERE filsys_id = :iid AND phys_id != :id1;
1376 rowcount = sqlca.sqlerrd[2];
1378 printf("%d entr%s fixed\n", rowcount, rowcount == 1 ? "y" : "ies");
1380 printf("Not fixed\n");
1384 int show_srv_user(void *id)
1386 EXEC SQL BEGIN DECLARE SECTION;
1387 char name[SERVERS_NAME_SIZE];
1389 EXEC SQL END DECLARE SECTION;
1392 EXEC SQL DECLARE csr216 CURSOR FOR
1393 SELECT name FROM servers
1394 WHERE acl_type = 'USER' and acl_id = :iid;
1395 EXEC SQL OPEN csr216;
1398 EXEC SQL FETCH csr216 INTO :name;
1403 printf("Service %s has acl non-existant user %d\n", name, iid);
1406 EXEC SQL CLOSE csr216;
1410 int show_srv_list(void *id)
1412 EXEC SQL BEGIN DECLARE SECTION;
1413 char name[SERVERS_NAME_SIZE];
1415 EXEC SQL END DECLARE SECTION;
1418 EXEC SQL DECLARE csr217 CURSOR FOR
1419 SELECT name FROM servers
1420 WHERE acl_type = 'LIST' AND acl_id = :iid;
1421 EXEC SQL OPEN csr217;
1424 EXEC SQL FETCH csr217 INTO :name;
1429 printf("Service %s has acl non-existant list %d\n", name, iid);
1432 EXEC SQL CLOSE csr217;
1436 void zero_srv_user(void *id)
1438 EXEC SQL BEGIN DECLARE SECTION;
1439 int iid = (int)id, rowcount;
1440 EXEC SQL END DECLARE SECTION;
1442 EXEC SQL UPDATE servers SET acl_id = 0 WHERE acl_id = :iid AND
1444 rowcount = sqlca.sqlerrd[2];
1446 printf("%d entr%s fixed\n", rowcount, rowcount == 1 ? "y" : "ies");
1448 printf("Not fixed\n");
1449 modified("servers");
1452 void zero_srv_list(void *id)
1454 EXEC SQL BEGIN DECLARE SECTION;
1455 int iid = (int)id, rowcount;
1456 EXEC SQL END DECLARE SECTION;
1458 EXEC SQL UPDATE servers SET acl_id = 0 WHERE acl_id = :iid AND
1460 rowcount = sqlca.sqlerrd[2];
1462 printf("%d entr%s fixed\n", rowcount, rowcount == 1 ? "y" : "ies");
1464 printf("Not fixed\n");
1465 modified("servers");
1468 int show_krb_usr(void *id)
1470 EXEC SQL BEGIN DECLARE SECTION;
1471 int iid = (int)id, found = 1, id1;
1472 EXEC SQL END DECLARE SECTION;
1476 EXEC SQL DECLARE csr218 CURSOR FOR
1477 SELECT string_id FROM krbmap
1478 WHERE users_id = :iid;
1479 EXEC SQL OPEN csr218;
1482 EXEC SQL FETCH csr218 INTO :id1;
1486 if ((s = hash_lookup(strings, id1)))
1491 printf("Kerberos map for non-existant user %d to principal %s\n",
1494 EXEC SQL CLOSE csr218;
1498 int show_krb_str(void *id)
1500 EXEC SQL BEGIN DECLARE SECTION;
1501 int iid = (int)id, found = 1, id1;
1502 EXEC SQL END DECLARE SECTION;
1506 EXEC SQL DECLARE csr219 CURSOR FOR
1507 SELECT users_id FROM krbmap
1508 WHERE string_id = :iid;
1509 EXEC SQL OPEN csr219;
1512 EXEC SQL FETCH csr219 INTO :id1;
1516 if ((u = hash_lookup(users, id1)))
1521 printf("Kerberos map for user %s (%d) to non-existant string %d\n",
1524 EXEC SQL CLOSE csr219;
1528 int show_pdm_mach(void *id)
1530 EXEC SQL BEGIN DECLARE SECTION;
1531 char name[PALLADIUM_NAME_SIZE];
1533 EXEC SQL END DECLARE SECTION;
1536 EXEC SQL DECLARE csr220 CURSOR FOR
1537 SELECT name FROM palladium
1538 WHERE mach_id = :iid;
1539 EXEC SQL OPEN csr220;
1542 EXEC SQL FETCH csr220 INTO :name;
1547 printf("Palladium server/supervisor %s is on non-existant machine %d\n",
1551 EXEC SQL CLOSE csr220;
1558 struct save_queue *sq, *sq1, *sq2, *sq3, *sq4, *sq5;
1564 printf("Phase 2 - Checking references\n");
1566 dprintf("Checking users...\n");
1567 hash_step(users, user_check, NULL);
1569 dprintf("Checking machines...\n");
1570 hash_step(machines, mach_check, NULL);
1572 dprintf("Checking subnets...\n");
1573 hash_step(subnets, subnet_check, NULL);
1575 dprintf("Checking clusters...\n");
1576 hash_step(clusters, cluster_check, NULL);
1578 dprintf("Checking mcmap...\n");
1581 EXEC SQL DECLARE csr221 CURSOR FOR
1582 SELECT mach_id, clu_id FROM mcmap;
1583 EXEC SQL OPEN csr221;
1586 EXEC SQL BEGIN DECLARE SECTION;
1587 int mach_id, clu_id;
1588 EXEC SQL END DECLARE SECTION;
1590 EXEC SQL FETCH csr221 INTO :mach_id, :clu_id;
1594 if (!(m = hash_lookup(machines, mach_id)))
1595 sq_save_unique_data(sq1, (void *)mach_id);
1596 else if (!hash_lookup(clusters, clu_id))
1597 sq_save_unique_data(sq2, (void *)clu_id);
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 EXEC SQL OPEN csr222;
1612 EXEC SQL BEGIN DECLARE SECTION;
1614 EXEC SQL END DECLARE SECTION;
1616 EXEC SQL FETCH csr222 INTO :clu_id;
1620 if (!hash_lookup(clusters, clu_id))
1621 sq_save_unique_data(sq1, (void *)clu_id);
1623 EXEC SQL CLOSE csr222;
1624 generic_delete(sq1, show_svc, "svc", "clu_id", 1);
1626 dprintf("Checking lists...\n");
1627 hash_step(lists, list_check, NULL);
1629 dprintf("Checking members...\n");
1636 EXEC SQL DECLARE csr223 CURSOR FOR
1637 SELECT list_id, member_type, member_id, ref_count, direct
1638 FROM imembers FOR UPDATE OF member_id;
1639 EXEC SQL OPEN csr223;
1642 EXEC SQL BEGIN DECLARE SECTION;
1643 int list_id, id, ref_count, direct;
1644 char type[IMEMBERS_MEMBER_TYPE_SIZE];
1645 EXEC SQL END DECLARE SECTION;
1647 EXEC SQL FETCH csr223 INTO :list_id, :type, :id,
1648 :ref_count, :direct;
1652 if (!(l = hash_lookup(lists, list_id)))
1653 sq_save_unique_data(sq1, (void *)list_id);
1654 else if (type[0] == 'U' && !hash_lookup(users, id))
1655 sq_save_unique_data(sq2, (void *)id);
1656 else if (type[0] == 'L' && !hash_lookup(lists, id))
1657 sq_save_unique_data(sq3, (void *)id);
1658 else if (type[0] == 'S' && !maybe_fixup_unref_string2("imembers", "member_id", "csr223", id))
1659 sq_save_unique_data(sq4, (void *)id);
1660 else if (type[0] == 'K' && !maybe_fixup_unref_string2("imembers", "member_id", "csr223", id))
1661 sq_save_unique_data(sq5, (void *)id);
1665 EXEC SQL CLOSE csr223;
1666 generic_delete(sq1, show_member_list, "imembers", "list_id", 1);
1667 generic_fix(sq2, show_mem_user, "Delete", del_mem_user, 1);
1668 generic_fix(sq3, show_mem_list, "Delete", del_mem_list, 1);
1669 generic_fix(sq4, show_mem_str, "Delete", del_mem_str, 1);
1670 generic_fix(sq5, show_mem_krb, "Delete", del_mem_krb, 1);
1672 dprintf("Checking servers...\n");
1675 EXEC SQL DECLARE csr224 CURSOR FOR
1676 SELECT name, acl_type, acl_id, modby FROM servers
1677 FOR UPDATE of modby;
1678 EXEC SQL OPEN csr224;
1681 EXEC SQL BEGIN DECLARE SECTION;
1683 char name[SERVERS_NAME_SIZE], acl_type[SERVERS_ACL_TYPE_SIZE];
1684 EXEC SQL END DECLARE SECTION;
1686 EXEC SQL FETCH csr224 INTO :name, :acl_type, :acl_id, :modby;
1690 maybe_fixup_modby2("servers", "modby", "csr224", modby);
1692 if (!strcmp(acl_type, "USER") && !hash_lookup(users, acl_id))
1693 sq_save_data(sq1, (void *)acl_id);
1694 else if (!strcmp(acl_type, "LIST") && !hash_lookup(lists, acl_id))
1695 sq_save_data(sq2, (void *)acl_id);
1697 EXEC SQL CLOSE csr224;
1698 generic_fix(sq1, show_srv_user, "Fix", zero_srv_user, 1);
1699 generic_fix(sq2, show_srv_list, "Fix", zero_srv_list, 1);
1701 dprintf("Checking serverhosts...\n");
1703 EXEC SQL DECLARE csr225 CURSOR FOR
1704 SELECT mach_id, modby FROM serverhosts
1705 FOR UPDATE OF modby;
1706 EXEC SQL OPEN csr225;
1709 EXEC SQL BEGIN DECLARE SECTION;
1711 EXEC SQL END DECLARE SECTION;
1713 EXEC SQL FETCH csr225 INTO :mach_id, :modby;
1717 maybe_fixup_modby2("serverhosts", "modby", "csr225", modby);
1718 if (!hash_lookup(machines, mach_id))
1719 sq_save_data(sq, (void *)mach_id);
1721 EXEC SQL CLOSE csr225;
1722 generic_fix(sq, show_sh, "Delete", del_sh_mach, 0);
1724 dprintf("Checking nfsphys...\n");
1725 hash_step(nfsphys, check_nfsphys, NULL);
1727 dprintf("Checking filesys...\n");
1728 hash_step(filesys, check_fs, NULL);
1730 dprintf("Checking filesystem groups...\n");
1734 EXEC SQL DECLARE csr226 CURSOR FOR
1735 SELECT group_id, filsys_id FROM fsgroup;
1736 EXEC SQL OPEN csr226;
1739 EXEC SQL BEGIN DECLARE SECTION;
1740 int group_id, filsys_id;
1741 EXEC SQL END DECLARE SECTION;
1743 EXEC SQL FETCH csr226 INTO :group_id, :filsys_id;
1747 if (!(f = hash_lookup(filesys, group_id)))
1748 sq_save_data(sq1, (void *)group_id);
1749 if (!hash_lookup(filesys, filsys_id))
1750 sq_save_data(sq3, (void *)filsys_id);
1752 EXEC SQL CLOSE csr226;
1753 generic_delete(sq1, show_fsg_missing, "fsgroup", "group_id", 0);
1754 generic_delete(sq3, show_fsg_nomember, "fsgroup", "filsys_id", 1);
1756 dprintf("Checking quotas...\n");
1761 EXEC SQL DECLARE csr227 CURSOR FOR
1762 SELECT entity_id, type, filsys_id, phys_id, quota, modby
1763 FROM quota FOR UPDATE OF modby;
1764 EXEC SQL OPEN csr227;
1767 EXEC SQL BEGIN DECLARE SECTION;
1768 int entity_id, filsys_id, phys_id, quota, modby;
1769 char type[QUOTA_TYPE_SIZE];
1770 EXEC SQL END DECLARE SECTION;
1772 EXEC SQL FETCH csr227 INTO :entity_id, :type, :filsys_id,
1773 :phys_id, :quota, :modby;
1777 maybe_fixup_modby2("quota", "modby", "csr227", modby);
1778 if (type[0] == 'U' && entity_id != 0 && !hash_lookup(users, entity_id))
1779 sq_save_data(sq1, (void *)entity_id);
1780 else if (type[0] == 'G' && !hash_lookup(lists, entity_id))
1781 sq_save_data(sq4, (void *)entity_id);
1782 else if (!(f = hash_lookup(filesys, filsys_id)))
1783 sq_save_data(sq2, (void *)filsys_id);
1784 else if (phys_id != f->phys_id || !(n = hash_lookup(nfsphys, phys_id)))
1785 sq_save_data(sq3, (void *)phys_id);
1789 EXEC SQL CLOSE csr227;
1790 generic_fix(sq1, show_quota_nouser, "Delete", fix_quota_nouser, 1);
1791 generic_fix(sq2, show_quota_nofs, "Delete", fix_quota_nofs, 0);
1792 generic_fix(sq3, show_quota_wrongpid, "Fix", fix_quota_physid, 1);
1793 generic_fix(sq4, show_quota_nolist, "Delete", fix_quota_nolist, 1);
1795 dprintf("Not checking zephyr.\n");
1797 dprintf("Checking hostaccess...\n");
1798 EXEC SQL DECLARE csr228 CURSOR FOR
1799 SELECT mach_id, acl_type, acl_id, modby FROM hostaccess
1800 FOR UPDATE OF modby;
1801 EXEC SQL OPEN csr228;
1804 EXEC SQL BEGIN DECLARE SECTION;
1805 int mach_id, acl_id, modby;
1806 char acl_type[HOSTACCESS_ACL_TYPE_SIZE];
1807 EXEC SQL END DECLARE SECTION;
1809 EXEC SQL FETCH csr228 INTO :mach_id, :acl_type, :acl_id, :modby;
1813 maybe_fixup_modby2("hostaccess", "modby", "csr228", modby);
1815 if (!hash_lookup(machines, mach_id))
1817 printf("Hostaccess for non-existant host %d\n", mach_id);
1818 printf("Not fixing this error\n");
1820 if (!strcmp(acl_type, "USER") && !hash_lookup(users, acl_id))
1822 printf("Hostaccess for %d is non-existant user %d\n", mach_id, acl_id);
1823 printf("Not fixing this error\n");
1825 else if (!strcmp(acl_type, "LIST") && !hash_lookup(lists, acl_id))
1827 printf("Hostaccess for %d is non-existant list %d\n", mach_id, acl_id);
1828 printf("Not fixing this error\n");
1831 EXEC SQL CLOSE csr228;
1833 dprintf("Checking palladium...\n");
1835 EXEC SQL DECLARE csr229 CURSOR FOR
1836 SELECT mach_id, modby FROM palladium
1837 FOR UPDATE OF modby;
1838 EXEC SQL OPEN csr229;
1841 EXEC SQL BEGIN DECLARE SECTION;
1843 EXEC SQL END DECLARE SECTION;
1845 EXEC SQL FETCH csr229 INTO :mach_id, :modby;
1849 maybe_fixup_modby2("palladium", "modby", "csr229", modby);
1850 if (!hash_lookup(machines, mach_id))
1851 sq_save_unique_data(sq1, (void *)mach_id);
1853 EXEC SQL CLOSE csr229;
1854 generic_delete(sq1, show_pdm_mach, "palladium", "mach_id", 1);
1856 dprintf("Checking krbmap...\n");
1859 EXEC SQL DECLARE csr230 CURSOR FOR
1860 SELECT users_id, string_id FROM krbmap
1861 FOR UPDATE OF string_id;
1862 EXEC SQL OPEN csr230;
1865 EXEC SQL BEGIN DECLARE SECTION;
1866 int users_id, string_id;
1867 EXEC SQL END DECLARE SECTION;
1869 EXEC SQL FETCH csr230 INTO :users_id, :string_id;
1873 if (!hash_lookup(users, users_id))
1874 sq_save_unique_data(sq1, (void *)users_id);
1875 else if (!maybe_fixup_unref_string2("krbmap", "string_id", "csr230", string_id))
1876 sq_save_unique_data(sq2, (void *)string_id);
1878 EXEC SQL CLOSE csr230;
1879 generic_delete(sq1, show_krb_usr, "krbmap", "users_id", 1);
1880 generic_delete(sq2, show_krb_str, "krbmap", "string_id", 1);
1882 dprintf("Checking capacls...\n");
1883 EXEC SQL DECLARE csr231 CURSOR FOR
1884 SELECT list_id, tag FROM capacls;
1885 EXEC SQL OPEN csr231;
1888 EXEC SQL BEGIN DECLARE SECTION;
1890 char tag[CAPACLS_TAG_SIZE];
1891 EXEC SQL END DECLARE SECTION;
1893 EXEC SQL FETCH csr231 INTO :list_id, :tag;
1897 if (!hash_lookup(lists, list_id))
1899 printf("Capacl for %s is non-existant list %d\n", tag, list_id);
1900 printf("Not fixing this error\n");
1903 EXEC SQL CLOSE csr231;
1905 dprintf("Checking hostaliases\n");
1907 EXEC SQL DECLARE csr232 CURSOR FOR
1908 SELECT mach_id FROM hostalias;
1909 EXEC SQL OPEN csr232;
1912 EXEC SQL BEGIN DECLARE SECTION;
1914 EXEC SQL END DECLARE SECTION;
1916 EXEC SQL FETCH csr232 INTO :mach_id;
1920 if (!hash_lookup(machines, mach_id))
1921 sq_save_unique_data(sq1, (void *)mach_id);
1923 EXEC SQL CLOSE csr232;
1924 generic_delete(sq1, show_hostalias, "hostalias", "mach_id", 1);
1926 dprintf("Checking printcaps\n");
1929 EXEC SQL DECLARE csr233 CURSOR FOR
1930 SELECT mach_id, quotaserver, modby FROM printcap;
1931 EXEC SQL OPEN csr233;
1934 EXEC SQL BEGIN DECLARE SECTION;
1935 int mach_id, quotaserver, modby;
1936 EXEC SQL END DECLARE SECTION;
1938 EXEC SQL FETCH csr233 INTO :mach_id, :quotaserver, :modby;
1942 maybe_fixup_modby2("printcap", "modby", "csr233", modby);
1943 if (!hash_lookup(machines, mach_id))
1944 sq_save_unique_data(sq1, (void *)mach_id);
1945 else if (!hash_lookup(machines, quotaserver))
1946 sq_save_unique_data(sq2, (void *)quotaserver);
1948 EXEC SQL CLOSE csr233;
1949 generic_delete(sq1, show_pcap_mach, "printcap", "mach_id", 1);
1950 generic_delete(sq2, show_pcap_quota, "printcap", "quotaserver", 1);